readCascadeConfigFile.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 "CascadeWrapper.h"
00007 #include "MyCascadeWrapper.h"
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             // read line by line of the file
00017             while (! myfile.eof() )
00018                 {
00019                     string myblock;
00020                     string myentry;
00021                     string mystr;
00022 
00023                     // initialize values. Set to some unlike values.
00024                     int myint1=-9999;
00025                     int myint2=-9999;
00026                     int myint3=-9999;
00027                     int myint4=-9999;
00028                     int myint5=-9999;
00029 
00030                     double myfl1=-9999.9;
00031                     double myfl2=-9999.9;
00032                     double myfl3=-9999.9;
00033                     double myfl4=-9999.9;
00034                     double myfl5=-9999.9;
00035 
00036                     // write read lines into string line
00037                     getline (myfile,line);
00038 
00039                     // now split the line into the subwords
00040                     // and write the substrings into vector
00041                     std::istringstream instring(line);
00042                     std::istringstream instring2(line);
00043                     std::istringstream instring3(line);
00044                     std::string temp;
00045 
00046                     // fill the variables ... i like istringstream objects. Very convinient!
00047                     //instring >> myblock >> myentry >> mystr;
00048                     //instring2 >> temp >> temp >> myfl0 >>  myfl1 >> myfl2 >> myfl3 >> myfl4;
00049                     //instring3 >> temp >> temp >> myint1 >> myint2 >> myint3 >> myint4 >> myint5;
00050                     instring >> myblock >>myentry;
00051                     instring2 >> temp >> myfl1 >>  myfl2 >> myfl3 >> myfl4 >> myfl5;
00052                     instring3 >> temp >> myint1 >> myint2 >> myint3 >> myint4 >> myint5;
00053 
00054                     // check for Comments. If the line starts with # than skip the line
00055                     std::string::size_type pos = myblock.find("#");
00056                     if(pos != std::string::npos) continue;
00057                     // check for Comments. If the line starts with * than skip the line
00058                     std::string::size_type pos2 = myblock.find("*");
00059                     if(pos2 != std::string::npos) continue;
00060                     // check for Comments. If the line starts with '/' than skip the line
00061                     std::string::size_type pos3 = myblock.find("/");
00062                     if(pos3 != std::string::npos) continue;
00063                     // check for Comments. If the line starts with '!' than skip the line
00064                     std::string::size_type pos4 = myblock.find("!");
00065                     if(pos4 != std::string::npos) continue;
00066 
00067                     if(myblock.empty()) continue;
00068 
00069                     // This is just for debugging to see wether the variables are filled properly
00070                     //cout << myblock << " " << myentry << " " << mystr << std::endl;
00071                     //cout << myfl1 << " " << myfl2 << " " << myfl3 << " " << myfl4 << std::endl;
00072                     //cout << myint1 << " " << myint2 << " " << myint3 << " " << myint4 << " " << myint5 << std::endl;
00073 
00074                     if (myblock == "'PBE1'" && myfl3!=-9999.9) {
00075                       cainpu.plepin=myfl3;
00076                       std::cout << "'PBE1' = " << cainpu.plepin << std::endl;
00077                     }
00078                     else if (myblock == "'KBE1'" && myint3!=-9999) {
00079                       caluco.ke=myint3;
00080                       std::cout << "'KBE1' = " << caluco.ke << std::endl;
00081                     }
00082                     else if (myblock == "'IRE1'" && myint3!=-9999) {
00083                       capar6.ires[1-1]=myint3;
00084                       std::cout << "'IRE1' = " << capar6.ires[1-1] << std::endl;
00085                     }
00086                     else if (myblock == "'PBE2'" && myfl3!=-9999.9) {
00087                       cainpu.ppin=myfl3;
00088                       std::cout << "'PBE2' = " << cainpu.ppin << std::endl;
00089                     }
00090                     else if (myblock == "'KBE2'" && myint3!=-9999) {
00091                       caluco.kp=myint3;
00092                       std::cout << "'KBE2' = " << caluco.kp << std::endl;
00093                     }
00094                     else if (myblock == "'IRE2'" && myint3!=-9999) {
00095                       capar6.ires[2-1]=myint3;
00096                       std::cout << "'IRE2' = " << capar6.ires[2-1] << std::endl;
00097                     }
00098                     else if (myblock == "'QMIN'" && myfl3!=-9999.9) {
00099                       values.qmi=myfl3;
00100                       std::cout << "'QMIN' = " << values.qmi << std::endl;
00101                     }
00102                     else if (myblock == "'QMAX'" && myfl3!=-9999.9) {
00103                       values.qma=myfl3;
00104                       std::cout << "'QMAX' = " << values.qma << std::endl;
00105                     }
00106                     else if (myblock == "'YMIN'" && myfl3!=-9999.9) {
00107                       values.ymi=myfl3;
00108                       std::cout << "'YMIN' = " << values.ymi << std::endl;
00109                     }
00110                     else if (myblock == "'YMAX'" && myfl3!=-9999.9) {
00111                       values.yma=myfl3;
00112                       std::cout << "'YMAX' = " << values.yma << std::endl;
00113                     }
00114                     else if (myblock == "'THEI'" && myfl3!=-9999.9) {
00115                       caelec.themi=myfl3;
00116                       std::cout << "'THEI' = " << caelec.themi << std::endl;
00117                     }
00118                     else if (myblock == "'THEM'" && myfl3!=-9999.9) {
00119                       caelec.thema=myfl3;
00120                       std::cout << "'THEM' = " << caelec.thema << std::endl;
00121                     }
00122                     else if (myblock == "'NFLA'" && myint3!=-9999) {
00123                       caluco.nflav=myint3;
00124                       std::cout << "'NFLA' = " << caluco.nflav << std::endl;
00125                     }
00126                     else if (myblock == "'MULT'" && myint3!=-9999) {
00127                       camult.mult=myint3;
00128                       std::cout << "'MULT' = " << camult.mult << std::endl;
00129                     }
00130                     else if (myblock == "'IPRO'" && myint3!=-9999) {
00131                       capar1.ipro=myint3;
00132                       std::cout << "'IPRO' = " << capar1.ipro << std::endl;
00133                     }
00134                     else if (myblock == "'IHFL'" && myint3!=-9999) {
00135                       cahflav.ihfla=myint3;
00136                       std::cout << "'IHFL' = " << cahflav.ihfla << std::endl;
00137                     }
00138                     else if (myblock == "'PTCU'" && myfl3!=-9999.9) {
00139                       captcut.pt2cut[1-1]=myfl3;
00140                       std::cout << "'PTCU' = " << captcut.pt2cut[1-1] << std::endl;
00141                     }
00142                     else if (myblock == "'NFRA'" && myint3!=-9999) {
00143                       cainpu.nfrag=myint3;
00144                       std::cout << "'NFRA' = " << cainpu.nfrag << std::endl;
00145                     }
00146                     else if (myblock == "'IFPS'" && myint3!=-9999) {
00147                       cainpu.ifps=myint3;
00148                       std::cout << "'IFPS' = " << cainpu.ifps << std::endl;
00149                     }
00150                     else if (myblock == "'ITIM'" && myint3!=-9999) {
00151                       casshwr.itimshr=myint3;
00152                       std::cout << "'ITIM' = " << casshwr.itimshr << std::endl;
00153                     }
00154                     else if (myblock == "'ICCF'" && myint3!=-9999) {
00155                       casshwr.iccfm=myint3;
00156                       std::cout << "'ICCF' = " << casshwr.iccfm << std::endl;
00157                     }
00158                     else if (myblock == "'IRAM'" && myint3!=-9999) {
00159                       capar1.irunaem=myint3;
00160                       std::cout << "'IRAM' = " << capar1.irunaem << std::endl;
00161                     }
00162                     else if (myblock == "'IRAS'" && myint3!=-9999) {
00163                       capar1.iruna=myint3;
00164                       std::cout << "'IRAS' = " << capar1.iruna << std::endl;
00165                     }
00166                     else if (myblock == "'IQ2S'" && myint3!=-9999) {
00167                       capar1.iq2=myint3;
00168                       std::cout << "'IQ2S' = " << capar1.iq2 << std::endl;
00169                     }
00170                     else if (myblock == "'SCAL'" && myfl3!=-9999) {
00171                       scalf.scalfa=myfl3;
00172                       std::cout << "'SCAL' = " << scalf.scalfa << std::endl;
00173                     }
00174                     else if (myblock == "'IGLU'" && myint3!=-9999) {
00175                       cagluon.iglu=myint3;
00176                       std::cout << "'IGLU' = " << cagluon.iglu << std::endl;
00177                     }
00178                     else if (myblock == "'NCAL'" && myint3!=-9999) {
00179                       integr.ncb=myint3;
00180                       std::cout << "'NCAL' = " << integr.ncb << std::endl;
00181                     }
00182                     else if (myblock == "'ACC1'" && myfl3!=-9999.9) {
00183                       integr.acc1=myfl3;
00184                       std::cout << "'ACC1' = " << integr.acc1 << std::endl;
00185                     }
00186                     else if (myblock == "'ACC2'" && myfl3!=-9999.9) {
00187                       integr.acc2=myfl3;
00188                       std::cout << "'ACC2' = " << integr.acc2 << std::endl;
00189                     }
00190                     else if (myblock == "'INTE'" && myint3!=-9999) {
00191                       cainpu.inter=myint3;
00192                       std::cout << "'INTE' = " << cainpu.inter << std::endl;
00193                     }
00194                     //not sure if common blick is correct
00195                     else if (myblock == "'KT1'" && myfl3!=-9999.9) {
00196                       casprkt.prkt1=myfl3;
00197                       std::cout << "'KT1' = " << casprkt.prkt1 << std::endl;
00198                     }
00199                     //not sure if common blick is correct
00200                     else if (myblock == "'KT2'" && myfl3!=-9999.9) {
00201                       casprkt.prkt2=myfl3;
00202                       std::cout << "'KT2' = " << casprkt.prkt2 << std::endl;
00203                     }
00204                     //not sure if common blick is correct
00205                     else if (myblock == "'KTRE'" && myfl3!=-9999.9) {
00206                       casprkt.prktrem=myfl3;
00207                       std::cout << "'KTRE' = " << casprkt.prktrem << std::endl;
00208                     }
00209                     else if (myblock == "'ILHA'" && myint3!=-9999) {
00210                       caherup.ilha=myint3;
00211                       std::cout << "'ILHA' = " << caherup.ilha << std::endl;
00212                     }
00213                     //these commented lines has still to be set
00214                     //else if (myblock == "'UPDF'" && myentry.size()!=0) {
00215                     //std::cout<<"myentry = "<<myentry<<std::endl;
00216                     //caspdf.pdfpath=myentry.c_str();
00217                     //caspdf.pdfpath=myentry.c_str();
00218                     //std::cout << "'UPDF' = " << caspdf.pdfpath[myentry.size()-1] << std::endl;
00219                     //}
00220                     //this common block seems to be nowhere defined
00221                     //else if (myblock == "'GPYT'" && myint3!=-9999) {
00222                     //.=myint3;
00223                     //std::cout << "'GPYT' = " << . << std::endl;
00224                     //}
00225                     else if (myblock == "'PMAS'" && myint1!=-9999 && myint2!=-9999 && myfl3!=-9999.9) {
00226                       pydat2.pmas[myint2-1][myint1-1]=myfl3;
00227                       std::cout << "PMAS = pydat2.pmas[" << myint2<<"-1]["<< myint1 << "-1]=" << pydat2.pmas[myint2-1][myint1-1] << std::endl;
00228                     }
00229                     else if(myblock == "'PARU'" && myint1!=-9999 && myfl3!=-9999.9) {
00230                       std::cout<<"here"<<std::endl;
00231                       pydat1.paru[myint1-1]=myfl3;
00232                       std::cout << "PARU = pydat1.paru[" << myint1<<"-1]=" << pydat1.paru[myint1-1] << std::endl;
00233                     }
00234                     if((myblock == "'MSTU'") && (myint1!=-9999) && (myint3!=-9999)){
00235                       pydat1.mstu[myint1-1]=myint3;
00236                       std::cout << "MSTU = pydat1.mstu[" << myint1<<"-1]=" << pydat1.mstu[myint1-1] << std::endl;
00237                     }
00238                     else if((myblock == "'MSTJ'") && (myint1!=-9999) && (myint3!=-9999)){
00239                       pydat1.mstj[myint1-1]=myint3;
00240                       std::cout << "MSTJ = pydat1.mstj[" << myint1<<"-1]=" <<  pydat1.mstj[myint1-1] << std::endl;
00241                     }
00242                     else {
00243                       std::cout << "cascade:  available list: CAELEC, CAHERUP, CAHFLAV, CAINPU, CALUCO, CAMULT, CAPAR1, CAPAR6, CAPTCUT, CASPRKT, CASSHWR, INTEGR, VALUES, ... you have specified " << myblock << std::endl ;
00244                     }
00245                 }
00246             myfile.close();
00247         }
00248     else cout << "Unable to open file"; 
00249     
00250 };
00251 

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