readpythiaConfigFile.h

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <iostream>
00003 #include <fstream>
00004 #include <sstream>
00005 #include "HepMC/PythiaWrapper.h"
00006 #include "MyPythia6Wrapper.h"
00007 
00008 // ---------------------------------------------------------------------- 
00009 void  readConfigFile( const std::string &configfile )
00010 {
00011   using namespace std;
00012 
00013     string line;
00014     ifstream myfile (configfile.c_str());
00015     if (myfile.is_open())
00016         {
00017             // read line by line of the file
00018             while (! myfile.eof() )
00019                 {
00020                     string myblock;
00021                     string myentry;
00022                     string mystr; 
00023 
00024                     // initialize values. Set to some unlike values.
00025                     int myint1=-9999;
00026                     int myint2=-9999;
00027                     int myint3=-9999;
00028                     int myint4=-9999;
00029                     int myint5=-9999;
00030 
00031                     double myfl0=-9999.9;
00032                     double myfl1=-9999.9;
00033                     double myfl2=-9999.9;
00034                     double myfl3=-9999.9;
00035                     double myfl4=-9999.9;
00036 
00037                     // write read lines into string line
00038                     getline (myfile,line);
00039 
00040                     // now split the line into the subwords
00041                     // and write the substrings into vector
00042                     std::istringstream instring(line);
00043                     std::istringstream instring2(line);
00044                     std::istringstream instring3(line);
00045                     std::string temp;
00046 
00047                     // fill the variables ... i like istringstream objects. Very convinient!
00048                     instring >> myblock >> myentry >> mystr;
00049                     instring2 >> temp >> temp >> myfl0 >>  myfl1 >> myfl2 >> myfl3 >> myfl4;
00050                     instring3 >> temp >> temp >> myint1 >> myint2 >> myint3 >> myint4 >> myint5;
00051 
00052                     // check for Comments. If the line starts with # than skip the line
00053                     std::string::size_type pos = myblock.find("#");
00054                     if(pos != std::string::npos) continue;
00055                     // check for Comments. If the line starts with * than skip the line
00056                     std::string::size_type pos2 = myblock.find("*");
00057                     if(pos2 != std::string::npos) continue;
00058                     // check for Comments. If the line starts with '/' than skip the line
00059                     std::string::size_type pos3 = myblock.find("/");
00060                     if(pos3 != std::string::npos) continue;
00061 
00062                     if(myblock.empty()) continue;
00063 
00064                     // This is just for debugging to see wether the variables are filled properly
00065                     //cout << myblock << " " << myentry << " " << mystr << std::endl;
00066                     //cout << myfl0 << " " << myfl1 << " " << myfl2 << " " << myfl3 << " " << myfl4 << std::endl;
00067                     //cout << myint1 << " " << myint2 << " " << myint3 << " " << myint4 << " " << myint5 << std::endl;
00068 
00069                     // read pysub entries
00070                     if (myblock == "pysubs") {
00071                         if((myentry == "msel") && (myint1!=-9999)){
00072                             pysubs.msel=myint1;
00073                             std::cout << "pysubs.msel=" << pysubs.msel << std::endl;
00074                         }
00075                         else if ((myentry == "msub") && (myint1!=-9999) && (myint2!=-9999)){
00076                             pysubs.msub[myint1-1]=myint2;        
00077                             std::cout << "pysubs.msub["<<myint1<<"-1]=" << pysubs.msub[myint1-1] << std::endl;
00078                         }
00079                         else if ((myentry == "ckin") && (myint1!=-9999) && (myfl1!=-9999.9)){
00080                             pysubs.ckin[myint1-1]=myfl1;         
00081                             std::cout << "pysubs.ckin["<<myint1<<"-1]=" << pysubs.ckin[myint1-1] << std::endl;
00082                         }
00083                         else if ((myentry == "kfin") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999)){
00084                             pysubs.kfin[myint2-1][myint1-1]=myint3;      
00085                             std::cout << "pysubs.kfin[" << myint2<<"-1]["<<myint1<<"-1]=" << pysubs.kfin[myint2-1][myint1-1] << std::endl;
00086                         }
00087                         else {
00088                             std::cout << "pythia6:  block PYSUBS has MSEL, MSUB, KFIN AND CKIN: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00089                         }
00090                     }
00091                     else if (myblock == "pypars"){
00092                         if((myentry == "mstp") && (myint1!=-9999) && (myint2!=-9999)){
00093                             pypars.mstp[myint1-1]=myint2;
00094                             std::cout << "pypars.mstp[" << myint1<<"-1]=" << pypars.mstp[myint1-1] << std::endl;
00095                         }
00096                         else if((myentry == "msti") && (myint1!=-9999) && (myint2!=-9999)){
00097                             pypars.msti[myint1-1]=myint2;
00098                             std::cout << "pypars.msti[" << myint1<<"-1]=" << pypars.msti[myint1-1] << std::endl;
00099                         }
00100                         else if((myentry == "parp") && (myint1!=-9999) && (myfl1!=-9999.9)){
00101                             pypars.parp[myint1-1]=myfl1;
00102                             std::cout << "pypars.parp[" << myint1<<"-1]=" << pypars.parp[myint1-1] << std::endl;
00103                         }
00104                         else if((myentry == "pari") && (myint1!=-9999) && (myfl1!=-9999.9)){
00105                             pypars.pari[myint1-1]=myfl1;
00106                             std::cout << "pypars.parp[" << myint1<<"-1]=" << pypars.pari[myint1-1] << std::endl;
00107                         }
00108                         else {
00109                             std::cout << "pythia6:  block PYPARS has MSTP,PARP, MSTI AND PARI: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00110                         }
00111                     }
00112                     else if (myblock == "pydat1"){
00113                         if((myentry == "mstu") && (myint1!=-9999) && (myint2!=-9999)){
00114                             pydat1.mstu[myint1-1]=myint2;
00115                             std::cout << "pydat1.mstu[" << myint1<<"-1]=" << pydat1.mstu[myint1-1] << std::endl;
00116                         }       
00117                         else if((myentry == "mstj") && (myint1!=-9999) && (myint2!=-9999)){
00118                             pydat1.mstj[myint1 - 1]=myint2;
00119                             std::cout << "pydat1.mstj[" << myint1<<"-1]=" <<  pydat1.mstj[myint1] << std::endl;
00120                         }
00121                         else if((myentry == "paru") && (myint1!=-9999) && (myfl1!=-9999.9)){
00122                             pydat1.paru[myint1-1]=myfl1;
00123                             std::cout << "pydat1.paru[" << myint1<<"-1]=" << pydat1.paru[myint1-1] << std::endl;
00124                         }       
00125                         else if((myentry == "parj") && (myint1!=-9999) && (myfl1!=-9999.9)){
00126                             pydat1.parj[myint1-1]=myfl1;
00127                             std::cout << "pydat1.parj[" << myint1<<"-1]=" << pydat1.parj[myint1-1] << std::endl;
00128                         }
00129                         else {
00130                             std::cout << "pythia6: block PYDAT1  HAS MSTU, MSTJ, PARU AND PARJ: YOU HAVE SPECIFIED "<< myentry << std::endl;
00131                         }
00132                     }
00133                     else if (myblock == "pydat2"){
00134                         if((myentry == "kchg") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999)){
00135                             pydat2.kchg[myint2-1][myint1-1]=myint3;
00136                             std::cout << "pydat2.kchg[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat2.kchg[myint2-1][myint1-1] << std::endl;
00137                         }       
00138                         else if((myentry == "pmas") && (myint1!=-9999) && (myint2!=-9999) && (myfl2!=-9999.9)){
00139                             pydat2.pmas[myint2-1][myint1-1]=myfl2;
00140                             std::cout << "pydat2.pmas[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat2.pmas[myint2-1][myint1-1] << std::endl;
00141                         }
00142                         else if((myentry == "parf") && (myint1!=-9999) && (myfl1!=-9999.9)){
00143                             pydat2.parf[myint1-1]=myfl1;
00144                             std::cout << "pydat2.parf[" << myint1<<"-1]=" << pydat2.parf[myint1-1] << std::endl;
00145                         }       
00146                         else if((myentry == "vckm") && (myint1!=-9999) && (myint2!=-9999) && (myfl2!=-9999.9)){
00147                             pydat2.vckm[myint2-1][myint1-1]=myfl2;
00148                             std::cout << "pydat2.vckm[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat2.vckm[myint2-1][myint1-1] << std::endl;
00149                         }
00150                         else {
00151                             std::cout << "pythia6: block PYDAT2  HAS KCHG, PMAS, PARF AND VCKM: YOU HAVE SPECIFIED "<< myentry << std::endl;
00152                         }
00153                     }
00154                     else if (myblock == "pydat3"){
00155                         if((myentry == "mdcy") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999)){
00156                             pydat3.mdcy[myint2-1][myint1-1]=myint3;
00157                             std::cout << "pydat2.mdcy[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat3.mdcy[myint2-1][myint1-1] << std::endl;
00158                         }       
00159                         else if((myentry == "mdme") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999)){
00160                             pydat3.mdme[myint2-1][myint1-1]=myint3;
00161                             std::cout << "pydat3.mdme[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat3.mdme[myint2-1][myint1-1] << std::endl;
00162                         }
00163                         else if((myentry == "brat") && (myint1!=-9999) && (myfl1!=-9999.9)){
00164                             pydat3.brat[myint1-1]=myfl1;
00165                             std::cout << "pydat2.brat[" << myint1<<"-1]=" << pydat3.brat[myint1-1] << std::endl;
00166                         }       
00167                         else if((myentry == "kfdp") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999)){
00168                             pydat3.kfdp[myint2-1][myint1-1]=myint3;
00169                             std::cout << "pydat2.kfdp[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat3.kfdp[myint2-1][myint1-1] << std::endl;
00170                         }
00171                         else {
00172                             std::cout << "pythia6:  block PYDAT3  HAS KFDP, MDCY, BRAT AND MDME : YOU HAVE SPECIFIED "<< myentry << std::endl ;
00173                         }
00174                     }
00175                     else if (myblock == "pydatr"){
00176                         if((myentry == "mrpy") && (myint1!=-9999) && (myint2!=-9999)){
00177                             pydatr.mrpy[myint1-1]=myint2;
00178                             std::cout << "pydatr.mrpy[" << myint1<<"-1]=" << pydatr.mrpy[myint1-1] << std::endl;
00179                         }       
00180                         else if((myentry == "rrpy") && (myint1!=-9999) && (myfl1!=-9999.9)){
00181                             pydatr.rrpy[myint1-1]=myfl1;
00182                             std::cout << "pydatr.rrpy[" << myint1<<"-1]=" << pydatr.rrpy[myint1-1] << std::endl;
00183                         }
00184                         else {
00185                             std::cout << "pythia6:  block PYDATR  HAS MRPY AND RRPY : YOU HAVE SPECIFIED "<< myentry << std::endl;
00186                         }
00187                     }
00188                     else if (myblock == "pyint2"){
00189                         if ((myentry == "iset") && (myint1!=-9999) && (myint2!=-9999)){
00190                             pyint2.iset[myint1-1]=myint2; 
00191                             std::cout << "pyint2.iset[" << myint1<<"-1]=" << pyint2.iset[myint1-1] << std::endl;
00192                         }
00193                         else if ((myentry == "kfpr") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999)){
00194                             pyint2.kfpr[myint2-1][myint1-1]=myint3;  
00195                             std::cout << "pyint2.kfpr[" << myint2<<"-1][" << myint1<< "-1]=" << pyint2.kfpr[myint2-1][myint1-1] << std::endl;
00196                         }
00197                         else if ((myentry == "coef") && (myint1!=-9999) && (myint2!=-9999) && (myfl2!=-9999.9)){
00198                             pyint2.coef[myint2-1][myint1-1]=myfl2;  
00199                             std::cout << "pyint2.coef[" << myint2<<"-1][" << myint1<< "-1]=" << pyint2.coef[myint2-1][myint1-1] << std::endl;
00200                         }
00201                         else if ((myentry == "icol") && (myint1!=-9999) && (myint2!=-9999) && (myint3!=-9999) && (myint4!=-9999)){
00202                             pyint2.icol[myint3-1][myint2-1][myint1-1]=myint4;  
00203                             std::cout << "pyint2.icol[" << myint3<<"-1][" << myint2<< "-1]["<< myint1<< "-1]=" << pyint2.icol[myint3-1][myint2-1][myint1-1] << std::endl;
00204                         }
00205                         else {
00206                             std::cout  << "pythia6:    block PYINT2 has ISET KFPR COEF AND ICOL: YOU HAVE SPECIFIED "<< myentry << std::endl;
00207                         }
00208                     }
00209                     else if (myblock == "select"){
00210                         if ((myentry == "pytune") && (myint1!=-9999)){
00211                             pytune( &myint1 );
00212                             std::cout << "pytune("<< myint1<< ")" << std::endl;
00213                         }
00214                         else {
00215                             std::cout  << "pythia6:    block SELECT has PYTUNE: YOU HAVE SPECIFIED "<< myentry << std::endl;
00216                         }
00217                     }
00218 
00219                     else
00220                         std::cout << "pythia6:  available list: PYSUBS, PYPARS, PYDAT1, PYDAT2, PYDAT3, PYDATR ... you have specified " << myblock << std::endl ;
00221                     
00222                 }
00223             myfile.close();
00224         }
00225     else cout << "Unable to open file"; 
00226     
00227 };
00228 

Generated on Wed Aug 31 09:44:47 2011 for HepMCAnalysis by  doxygen 1.4.7