Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

readherwigConfigFile.h

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <iostream>
00003 #include <fstream>
00004 #include <sstream>
00005 #include "MyHerwigWrapper.h"
00006 
00007 void  readConfigFile(string configfile){
00008     string line;
00009     ifstream myfile (configfile.c_str());
00010     if (myfile.is_open())
00011         {
00012             // read line by line of the file
00013             while (! myfile.eof() )
00014                 {
00015                     string myblock;
00016                     string myentry;
00017                     string mystr;
00018 
00019                    // initialize values. Set to some unlike values.
00020                     int myint1=-9999;
00021                     int myint2=-9999;
00022                     int myint3=-9999;
00023                     int myint4=-9999;
00024                     int myint5=-9999;
00025 
00026                     double myfl0=-9999.9;
00027                     double myfl1=-9999.9;
00028                     double myfl2=-9999.9;
00029                     double myfl3=-9999.9;
00030                     double myfl4=-9999.9;
00031 
00032                     // write read lines into string line
00033                     getline (myfile,line);
00034 
00035                     // now split the line into the subwords
00036                     // and write the substrings into vector
00037                     std::istringstream instring(line);
00038                     std::istringstream instring2(line);
00039                     std::istringstream instring3(line);
00040                     std::string temp;
00041 
00042                     // fill the variables ... i like istringstream objects. Very convinient!
00043                     instring >> myblock >> myentry >> mystr;
00044                     instring2 >> temp >> temp >> myfl0 >>  myfl1 >> myfl2 >> myfl3 >> myfl4;
00045                     instring3 >> temp >> temp >> myint1 >> myint2 >> myint3 >> myint4 >> myint5;
00046 
00047                     // check for Comments. If the line starts with # than skip the line
00048                     std::string::size_type pos = myblock.find("#");
00049                     if(pos != std::string::npos) continue;
00050                     // check for Comments. If the line starts with * than skip the line
00051                     std::string::size_type pos2 = myblock.find("*");
00052                     if(pos2 != std::string::npos) continue;
00053                     // check for Comments. If the line starts with '/' than skip the line
00054                     std::string::size_type pos3 = myblock.find("/");
00055                     if(pos3 != std::string::npos) continue;
00056 
00057                     if(myblock.empty()) continue;
00058 
00059                     // read hwproc entries
00060                     if (myblock == "hwproc") {
00061                         if((myentry == "pbeam1") && (myfl0!=-9999.9)){
00062                             hwproc.pbeam1=myfl0;
00063                             std::cout << "hwproc.pbeam1= " << hwproc.pbeam1 << std::endl;
00064                         }
00065 
00066 
00067                         else if((myentry == "pbeam2") && (myfl0!=-9999.9)){
00068                             hwproc.pbeam2=myfl0;
00069                             std::cout << "hwproc.pbeam2= " << hwproc.pbeam2 << std::endl;
00070                         }
00071  
00072                         else if((myentry == "iproc") && (myint1!=-9999)){
00073                             hwproc.iproc=myint1;
00074                             std::cout << "hwproc.iproc= " << hwproc.iproc << std::endl;
00075                         }
00076   
00077                         else {
00078                            std::cout << "Herwig:  block hwproc has pbeam1, pbeam2, iproc: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00079                         }
00080                    
00081                     }
00082                    
00083                     else if (myblock == "hwprop") {
00084                         if((myentry == "rmass") && (myint1!=-9999) && (myfl1!=-9999.9)){
00085                             hwprop.rmass[myint1-1]=myfl1;
00086                             std::cout << "hwprop.rmass[ "<<myint1-1<<"]=" << hwprop.rmass[myint1-1] << std::endl;
00087                         }
00088   
00089                         else {
00090                            std::cout << "Herwig:  block hwproc has rmass: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00091                         }
00092                    
00093                     }
00094                                       
00095                   
00096                    else if (myblock == "hwpram"){
00097                         if((myentry == "gamw") && (myfl0!=-9999.9) ){
00098                             hwpram.gamw=myfl0;
00099                             std::cout << "hwpram.gamw= " << hwpram.gamw << std::endl;
00100                         }      
00101                         else if((myentry == "gamz") && (myfl0!=-9999.9) ){
00102                             hwpram.gamz=myfl0;
00103                             std::cout << "hwpram.gamz= " << hwpram.gamz << std::endl;
00104                         }
00105 
00106                         else if((myentry == "modpdf") && (myint1!=-9999) ){
00107                             hwpram.modpdf[0]=myint1;
00108                             hwpram.modpdf[1]=myint1;
00109                             std::cout << "beam1:hwpram.modpdf= " << hwpram.modpdf[0] << std::endl;
00110                             std::cout << "beam2:hwpram.modpdf= " << hwpram.modpdf[1] << std::endl;
00111                         }
00112                         else if((myentry == "clpow") && (myfl0!=-9999.9) ){
00113                             hwpram.clpow=myfl0;
00114                             std::cout << "hwpram.clpow= " << hwpram.clpow << std::endl;
00115                         }                
00116                         else if((myentry == "prsof") && (myfl0!=-9999.9) ){
00117                             hwpram.prsof=myfl0;
00118                             std::cout << "hwpram.prsof= " << hwpram.prsof << std::endl;
00119                         }
00120                    
00121                         else {
00122                             std::cout << "Herwig:  block hwpram has gamw, gamz, modpdf, clpow and prsof: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00123                         }
00124                    }
00125 
00126                     else if (myblock == "hwprch") {
00127                         if(myentry == "autpdf") {
00128                           //  char tempstr[20] = mystr.c_str();
00129                           //for(int i=0; i<2; i++) 
00130                           //  for(int j=0; j<20; j++)  
00131                           //    hwprch.autpdf[i][j]=tempstr[j];
00132                           //  std::cout << "hwprch.autpdf=" << hwprch.autpdf<< std::endl;
00133                           //hwprch.autpdf[2][20]= {"HWLHAPDF","HWLHAPDF"};
00134                           //  hwprch.autpdf[0][0]= 'H';
00135                           //  hwprch.autpdf[1][20]= "HWLHAPDF";
00136                         }
00137   
00138                         else {
00139                            std::cout << "Herwig:  block hwprch has autpdf: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00140                         }
00141                    
00142                     }
00143                    
00144             
00145                    else if (myblock == "hwdist") {
00146                         if( (myentry == "pltcut") && (myfl0!=-9999.9)) {
00147                             hwdist.pltcut = myfl0;
00148                             std::cout << "hwdist.pltcut=" << hwdist.pltcut<< std::endl;
00149                         }
00150                    
00151                        else if( (myentry == "mixing") && (myint1!=-9999)) {
00152                             hwdist.mixing = myint1;
00153                             std::cout << "hwdist.mixing=" << hwdist.mixing<< std::endl;
00154                         }
00155                        else {
00156                            std::cout << "Herwig:  block hwdist has pltcut and mixing: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00157                         }
00158 
00159                     }
00160 
00161                    else if (myblock == "hwhard") {
00162                         if( (myentry == "ptmin") && (myfl0!=-9999.9)) {
00163                             hwhard.ptmin = myfl0;
00164                             std::cout << "hwhard.ptmin=" << hwhard.ptmin<< std::endl;
00165                         }
00166                    
00167                        else {
00168                            std::cout << "Herwig:  block hwhard has ptmin: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00169                         }
00170 
00171                     }
00172                   
00173                    else if (myblock == "jmparm") {
00174                         if( (myentry == "jmueo") && (myint1!=-9999)) {
00175                             jmparm.jmueo = myint1;
00176                             std::cout << "jmparm.jmueo=" << jmparm.jmueo<< std::endl;
00177                         }
00178                    
00179                        else if( (myentry == "msflag") && (myint1!=-9999)) {
00180                             jmparm.jmueo = myint1;
00181                             std::cout << "jmparm.jmueo=" << jmparm.jmueo<< std::endl;
00182                         }
00183 
00184                        else if( (myentry == "jmbug") && (myint1!=-9999)) {
00185                             jmparm.jmbug = myint1;
00186                             std::cout << "jmparm.jmbug=" << jmparm.jmbug<< std::endl;
00187                         }
00188 
00189                        else if( (myentry == "ptjim") && (myfl0!=-9999.9)) {
00190                             jmparm.ptjim = myfl0;
00191                             std::cout << "jmparm.ptjim=" << jmparm.ptjim<< std::endl;
00192                         }
00193 
00194                        else if( (myentry == "jmrad") && (myint1!=-9999) && (myfl1!=-9999.9)) {
00195                             jmparm.jmrad[myint1-1] = myfl1;
00196                             std::cout << "jmparm.jmrad["<<myint1-1<<"]="<< jmparm.jmrad[myint1-1]<< std::endl;
00197                         }
00198 
00199                        else {
00200                            std::cout << "Herwig:  block jmparm has jmueo, msflag, jubug, ptjim and jmrad: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00201                         }
00202 
00203                     }
00204 
00205                    else if (myblock == "hwdspn") {
00206                         if(myentry == "taudec") {
00207                            // std::cout <<"mystr="<<mystr.c_str()<<std::endl;
00208                            // std::cout <<"mystr="<<*(mystr.c_str())<<std::endl;
00209                            // hwdspn.taudec[1] = *mystr.c_str();
00210                            // std::cout << "hwdspn.taudec=" << hwdspn.taudec[1]<< std::endl;
00211                         }
00212                    
00213                        else {
00214                            std::cout << "Herwig:  block hwdspn has taudec: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00215                         }
00216 
00217                     }
00218 
00219 
00220 
00221                 }
00222                myfile.close();
00223          }
00224       else cout << "Unable to open file";
00225 
00226 };

Generated on Mon Feb 16 15:58:17 2009 for HepMCAnalysis by  doxygen 1.3.9.1