00001 #include <stdio.h>
00002 #include <iostream>
00003 #include <fstream>
00004 #include <sstream>
00005 #include "MyHerwigWrapper.h"
00006
00007 void readConfigFile( const std::string &configfile )
00008 {
00009 using namespace std;
00010
00011 string line;
00012 ifstream myfile (configfile.c_str());
00013 if (myfile.is_open())
00014 {
00015
00016 while (! myfile.eof() )
00017 {
00018 string myblock;
00019 string myentry;
00020 string mystr;
00021
00022
00023 int myint1=-9999;
00024 int myint2=-9999;
00025 int myint3=-9999;
00026 int myint4=-9999;
00027 int myint5=-9999;
00028
00029 double myfl0=-9999.9;
00030 double myfl1=-9999.9;
00031 double myfl2=-9999.9;
00032 double myfl3=-9999.9;
00033 double myfl4=-9999.9;
00034
00035
00036 getline (myfile,line);
00037
00038
00039
00040 istringstream instring(line);
00041 istringstream instring2(line);
00042 istringstream instring3(line);
00043 string temp;
00044
00045
00046 instring >> myblock >> myentry >> mystr;
00047 instring2 >> temp >> temp >> myfl0 >> myfl1 >> myfl2 >> myfl3 >> myfl4;
00048 instring3 >> temp >> temp >> myint1 >> myint2 >> myint3 >> myint4 >> myint5;
00049
00050
00051 string::size_type pos = myblock.find("#");
00052 if(pos != string::npos) continue;
00053
00054 string::size_type pos2 = myblock.find("*");
00055 if(pos2 != string::npos) continue;
00056
00057 string::size_type pos3 = myblock.find("/");
00058 if(pos3 != string::npos) continue;
00059
00060 if(myblock.empty()) continue;
00061
00062
00063 if (myblock == "hwproc") {
00064 if((myentry == "pbeam1") && (myfl0!=-9999.9)){
00065 hwproc.pbeam1=myfl0;
00066 cout << "hwproc.pbeam1= " << hwproc.pbeam1 << endl;
00067 }
00068 else if((myentry == "pbeam2") && (myfl0!=-9999.9)){
00069 hwproc.pbeam2=myfl0;
00070 cout << "hwproc.pbeam2= " << hwproc.pbeam2 << endl;
00071 }
00072 else if((myentry == "iproc") && (myint1!=-9999)){
00073 hwproc.iproc=myint1;
00074 cout << "hwproc.iproc= " << hwproc.iproc << endl;
00075 }
00076 else {
00077 cout << "Herwig: block hwproc has pbeam1, pbeam2, iproc: YOU HAVE SPECIFIED "<< myentry <<endl;
00078 }
00079
00080 }
00081 else if (myblock == "hwprop") {
00082 if((myentry == "rmass") && (myint1!=-9999) && (myfl1!=-9999.9)){
00083 hwprop.rmass[myint1]=myfl1;
00084 cout << "hwprop.rmass[ "<<myint1<<"]=" << hwprop.rmass[myint1] << endl;
00085 }
00086 else {
00087 cout << "Herwig: block hwproc has rmass: YOU HAVE SPECIFIED "<< myentry <<endl;
00088 }
00089
00090 }
00091 else if (myblock == "hwpram"){
00092 if((myentry == "gamw") && (myfl0!=-9999.9) ){
00093 hwpram.gamw=myfl0;
00094 cout << "hwpram.gamw= " << hwpram.gamw << endl;
00095 }
00096 else if((myentry == "gamz") && (myfl0!=-9999.9) ){
00097 hwpram.gamz=myfl0;
00098 cout << "hwpram.gamz= " << hwpram.gamz << endl;
00099 }
00100 else if((myentry == "modpdf") && (myint1!=-9999) ){
00101 hwpram.modpdf[0]=myint1;
00102 hwpram.modpdf[1]=myint1;
00103 cout << "beam1:hwpram.modpdf= " << hwpram.modpdf[0] << endl;
00104 cout << "beam2:hwpram.modpdf= " << hwpram.modpdf[1] << endl;
00105 }
00106 else if((myentry == "clpow") && (myfl0!=-9999.9) ){
00107 hwpram.clpow=myfl0;
00108 cout << "hwpram.clpow= " << hwpram.clpow << endl;
00109 }
00110 else if((myentry == "prsof") && (myfl0!=-9999.9) ){
00111 hwpram.prsof=myfl0;
00112 cout << "hwpram.prsof= " << hwpram.prsof << endl;
00113 }
00114 else {
00115 cout << "Herwig: block hwpram has gamw, gamz, modpdf, clpow and prsof: YOU HAVE SPECIFIED "<< myentry <<endl;
00116 }
00117 }
00118 else if (myblock == "hwprch") {
00119 if(myentry == "autpdf") {
00120 string pdfsetName = mystr.c_str();
00121 pdfsetName.copy(hwprch.autpdf[1-1],20);
00122 pdfsetName.copy(hwprch.autpdf[2-1],20);
00123 cout << "beam1:hwprch.autpdf= " << hwprch.autpdf[1-1] << endl;
00124 cout << "beam2:hwprch.autpdf= " << hwprch.autpdf[2-1] << endl;
00125 }
00126 else {
00127 cout << "Herwig: block hwprch has autpdf: YOU HAVE SPECIFIED "<< myentry <<endl;
00128 }
00129
00130 }
00131 else if (myblock == "hwdist") {
00132 if( (myentry == "pltcut") && (myfl0!=-9999.9)) {
00133 hwdist.pltcut = myfl0;
00134 cout << "hwdist.pltcut=" << hwdist.pltcut<< endl;
00135 }
00136 else if( (myentry == "mixing") && (myint1!=-9999)) {
00137 hwdist.mixing = myint1;
00138 cout << "hwdist.mixing=" << hwdist.mixing<< endl;
00139 }
00140 else {
00141 cout << "Herwig: block hwdist has pltcut and mixing: YOU HAVE SPECIFIED "<< myentry <<endl;
00142 }
00143 }
00144 else if (myblock == "hwhard") {
00145 if( (myentry == "ptmin") && (myfl0!=-9999.9)) {
00146 hwhard.ptmin = myfl0;
00147 cout << "hwhard.ptmin=" << hwhard.ptmin<< endl;
00148 }
00149 else {
00150 cout << "Herwig: block hwhard has ptmin: YOU HAVE SPECIFIED "<< myentry <<endl;
00151 }
00152
00153 }
00154 else if (myblock == "jmparm") {
00155 if( (myentry == "jmueo") && (myint1!=-9999)) {
00156 jmparm.jmueo = myint1;
00157 cout << "jmparm.jmueo=" << jmparm.jmueo<< endl;
00158 }
00159 else if( (myentry == "msflag") && (myint1!=-9999)) {
00160 jmparm.msflag = myint1;
00161 cout << "jmparm.msflag=" << jmparm.msflag<< endl;
00162 }
00163 else if( (myentry == "jmbug") && (myint1!=-9999)) {
00164 jmparm.jmbug = myint1;
00165 cout << "jmparm.jmbug=" << jmparm.jmbug<< endl;
00166 }
00167 else if( (myentry == "ptjim") && (myfl0!=-9999.9)) {
00168 jmparm.ptjim = myfl0;
00169 cout << "jmparm.ptjim=" << jmparm.ptjim<< endl;
00170 }
00171 else if( (myentry == "jmrad") && (myint1!=-9999) && (myfl1!=-9999.9)) {
00172 jmparm.jmrad[myint1-1] = myfl1;
00173 cout << "jmparm.jmrad["<<myint1-1<<"]="<< jmparm.jmrad[myint1-1]<< endl;
00174 }
00175 else {
00176 cout << "Herwig: block jmparm has jmueo, msflag, jubug, ptjim and jmrad: YOU HAVE SPECIFIED "<< myentry <<endl;
00177 }
00178 }
00179 else if (myblock == "hwdspn") {
00180 if(myentry == "taudec") {
00181 string taudecay = mystr.c_str();
00182 taudecay.copy(hwdspn.taudec,20);
00183 cout << "hwdspn.taudec= " << hwdspn.taudec << endl;
00184 }
00185 else {
00186 cout << "Herwig: block hwdspn has taudec: YOU HAVE SPECIFIED "<< myentry <<endl;
00187 }
00188 }
00189 }
00190 myfile.close();
00191 }
00192 else cout << "Unable to open file";
00193 };
00194