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
00013 while (! myfile.eof() )
00014 {
00015 string myblock;
00016 string myentry;
00017 string mystr;
00018
00019
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
00033 getline (myfile,line);
00034
00035
00036
00037 std::istringstream instring(line);
00038 std::istringstream instring2(line);
00039 std::istringstream instring3(line);
00040 std::string temp;
00041
00042
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
00048 std::string::size_type pos = myblock.find("#");
00049 if(pos != std::string::npos) continue;
00050
00051 std::string::size_type pos2 = myblock.find("*");
00052 if(pos2 != std::string::npos) continue;
00053
00054 std::string::size_type pos3 = myblock.find("/");
00055 if(pos3 != std::string::npos) continue;
00056
00057 if(myblock.empty()) continue;
00058
00059
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 else if((myentry == "pbeam2") && (myfl0!=-9999.9)){
00066 hwproc.pbeam2=myfl0;
00067 std::cout << "hwproc.pbeam2= " << hwproc.pbeam2 << std::endl;
00068 }
00069 else if((myentry == "iproc") && (myint1!=-9999)){
00070 hwproc.iproc=myint1;
00071 std::cout << "hwproc.iproc= " << hwproc.iproc << std::endl;
00072 }
00073 else {
00074 std::cout << "Herwig: block hwproc has pbeam1, pbeam2, iproc: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00075 }
00076
00077 }
00078 else if (myblock == "hwprop") {
00079 if((myentry == "rmass") && (myint1!=-9999) && (myfl1!=-9999.9)){
00080 hwprop.rmass[myint1-1]=myfl1;
00081 std::cout << "hwprop.rmass[ "<<myint1-1<<"]=" << hwprop.rmass[myint1-1] << std::endl;
00082 }
00083 else {
00084 std::cout << "Herwig: block hwproc has rmass: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00085 }
00086
00087 }
00088 else if (myblock == "hwpram"){
00089 if((myentry == "gamw") && (myfl0!=-9999.9) ){
00090 hwpram.gamw=myfl0;
00091 std::cout << "hwpram.gamw= " << hwpram.gamw << std::endl;
00092 }
00093 else if((myentry == "gamz") && (myfl0!=-9999.9) ){
00094 hwpram.gamz=myfl0;
00095 std::cout << "hwpram.gamz= " << hwpram.gamz << std::endl;
00096 }
00097 else if((myentry == "modpdf") && (myint1!=-9999) ){
00098 hwpram.modpdf[0]=myint1;
00099 hwpram.modpdf[1]=myint1;
00100 std::cout << "beam1:hwpram.modpdf= " << hwpram.modpdf[0] << std::endl;
00101 std::cout << "beam2:hwpram.modpdf= " << hwpram.modpdf[1] << std::endl;
00102 }
00103 else if((myentry == "clpow") && (myfl0!=-9999.9) ){
00104 hwpram.clpow=myfl0;
00105 std::cout << "hwpram.clpow= " << hwpram.clpow << std::endl;
00106 }
00107 else if((myentry == "prsof") && (myfl0!=-9999.9) ){
00108 hwpram.prsof=myfl0;
00109 std::cout << "hwpram.prsof= " << hwpram.prsof << std::endl;
00110 }
00111 else {
00112 std::cout << "Herwig: block hwpram has gamw, gamz, modpdf, clpow and prsof: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00113 }
00114 }
00115 else if (myblock == "hwprch") {
00116 if(myentry == "autpdf") {
00117 std::string pdfsetName = mystr.c_str();
00118 pdfsetName.copy(hwprch.autpdf[1-1],20);
00119 pdfsetName.copy(hwprch.autpdf[2-1],20);
00120 std::cout << "beam1:hwprch.autpdf= " << hwprch.autpdf[1-1] << std::endl;
00121 std::cout << "beam2:hwprch.autpdf= " << hwprch.autpdf[2-1] << std::endl;
00122 }
00123 else {
00124 std::cout << "Herwig: block hwprch has autpdf: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00125 }
00126
00127 }
00128 else if (myblock == "hwdist") {
00129 if( (myentry == "pltcut") && (myfl0!=-9999.9)) {
00130 hwdist.pltcut = myfl0;
00131 std::cout << "hwdist.pltcut=" << hwdist.pltcut<< std::endl;
00132 }
00133 else if( (myentry == "mixing") && (myint1!=-9999)) {
00134 hwdist.mixing = myint1;
00135 std::cout << "hwdist.mixing=" << hwdist.mixing<< std::endl;
00136 }
00137 else {
00138 std::cout << "Herwig: block hwdist has pltcut and mixing: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00139 }
00140 }
00141 else if (myblock == "hwhard") {
00142 if( (myentry == "ptmin") && (myfl0!=-9999.9)) {
00143 hwhard.ptmin = myfl0;
00144 std::cout << "hwhard.ptmin=" << hwhard.ptmin<< std::endl;
00145 }
00146 else {
00147 std::cout << "Herwig: block hwhard has ptmin: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00148 }
00149
00150 }
00151 else if (myblock == "jmparm") {
00152 if( (myentry == "jmueo") && (myint1!=-9999)) {
00153 jmparm.jmueo = myint1;
00154 std::cout << "jmparm.jmueo=" << jmparm.jmueo<< std::endl;
00155 }
00156 else if( (myentry == "msflag") && (myint1!=-9999)) {
00157 jmparm.msflag = myint1;
00158 std::cout << "jmparm.msflag=" << jmparm.msflag<< std::endl;
00159 }
00160 else if( (myentry == "jmbug") && (myint1!=-9999)) {
00161 jmparm.jmbug = myint1;
00162 std::cout << "jmparm.jmbug=" << jmparm.jmbug<< std::endl;
00163 }
00164 else if( (myentry == "ptjim") && (myfl0!=-9999.9)) {
00165 jmparm.ptjim = myfl0;
00166 std::cout << "jmparm.ptjim=" << jmparm.ptjim<< std::endl;
00167 }
00168 else if( (myentry == "jmrad") && (myint1!=-9999) && (myfl1!=-9999.9)) {
00169 jmparm.jmrad[myint1-1] = myfl1;
00170 std::cout << "jmparm.jmrad["<<myint1-1<<"]="<< jmparm.jmrad[myint1-1]<< std::endl;
00171 }
00172 else {
00173 std::cout << "Herwig: block jmparm has jmueo, msflag, jubug, ptjim and jmrad: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00174 }
00175 }
00176 else if (myblock == "hwdspn") {
00177 if(myentry == "taudec") {
00178 std::string taudecay = mystr.c_str();
00179 taudecay.copy(hwdspn.taudec,20);
00180 std::cout << "hwdspn.taudec= " << hwdspn.taudec << std::endl;
00181 }
00182 else {
00183 std::cout << "Herwig: block hwdspn has taudec: YOU HAVE SPECIFIED "<< myentry <<std::endl;
00184 }
00185 }
00186 }
00187 myfile.close();
00188 }
00189 else cout << "Unable to open file";
00190 };