Photos.cxx
00001 #include <stdarg.h>
00002 #include <iostream>
00003 #include <vector>
00004
00005 #include "PhotosRandom.h"
00006 #include "PhotosEvent.h"
00007 #include "Photos.h"
00008 #include "Log.h"
00009 using std::vector;
00010 using std::cout;
00011 using std::endl;
00012 using std::ios_base;
00013
00014 namespace Photospp
00015 {
00016
00017 Photos Photos::_instance;
00018
00019 vector<vector<int>* > *Photos::supBremList = 0;
00020 vector<vector<int>* > *Photos::forceBremList = 0;
00021 vector<pair<int,double>* > *Photos::forceMassList = 0;
00022 vector<int> *Photos::ignoreStatusCodeList = 0;
00023 bool Photos::isSuppressed=false;
00024 bool Photos::massFrom4Vector=true;
00025 double Photos::momentum_conservation_threshold = 0.1;
00026 bool Photos::meCorrectionWtForZ=false;
00027 bool Photos::meCorrectionWtForW=false;
00028 bool Photos::meCorrectionWtForScalar=false;
00029 bool Photos::isCreateHistoryEntries=false;
00030 int Photos::historyEntriesStatus = 3;
00031 double (*Photos::randomDouble)() = PhotosRandom::randomReal;
00032
00033 Photos::Photos()
00034 {
00035 setAlphaQED (0.00729735039);
00036 setInfraredCutOff (0.01);
00037 setInterference (true);
00038 setDoubleBrem (true);
00039 setQuatroBrem (false);
00040 setTopProcessRadiation(true);
00041 setCorrectionWtForW (true);
00042
00043
00044
00045 phokey_.iexp = 1;
00046 }
00047
00048 void Photos::initialize()
00049 {
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 if(!phokey_.iexp) initializeKinematicCorrections(1);
00062 else setExponentiation(true);
00063
00064 int buf=1;
00065 iphqrk_(&buf);
00066
00067 buf=2;
00068 iphekl_(&buf);
00069
00070
00071 for(int i=0;i<10;i++) phosta_.status[i]=0;
00072
00073 phosta_.ifstop=1;
00074
00075 pholun_.phlun=6;
00076
00077
00078 phpico_.pi =3.14159265358979324;
00079 phpico_.twopi=6.28318530717958648;
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 if(phokey_.interf) maxWtInterference(2.0);
00092 else maxWtInterference(1.0);
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 int coutPrec = cout.precision(6);
00110 ios_base::fmtflags flags = cout.setf(ios_base::floatfield);
00111 cout<<endl;
00112 cout<<"********************************************************************************"<<endl<<endl;
00113
00114 cout<<" ========================="<<endl;
00115 cout<<" PHOTOS, Version: "<<VER_MAJOR<<"."<<VER_MINOR<<endl;
00116 cout<<" Released at: "<<DAT_DAY<<"/"<<DAT_MONTH<<"/"<<DAT_YEAR<<endl;
00117 cout<<" ========================="<<endl<<endl;
00118
00119 cout<<" Photos QED corrections in Particle Decays"<<endl<<endl;
00120
00121 cout<<" Monte Carlo Program - by E. Barberio, B. van Eijk and Z. Was"<<endl;
00122 cout<<" From version 2.09 - by P. Golonka and Z. Was"<<endl;
00123 cout<<" From version 3.00 - by N. Davidson, T. Przedzinski and Z. Was"<<endl;
00124
00125 cout<<"********************************************************************************"<<endl<<endl;
00126
00127 cout<<" Internal (default) input parameters: "<<endl<<endl;
00128 cout<<" INTERF= "<<phokey_.interf<<" ISEC= " <<phokey_.isec <<" ITRE= "<<phokey_.itre
00129 <<" IEXP= " <<phokey_.iexp <<" IFTOP= "<<phokey_.iftop<<" IFW= " <<phokey_.ifw <<endl;
00130 cout<<" ALPHA_QED= "<<phocop_.alpha<<" XPHCUT= "<<phocop_.xphcut<<endl<<endl;
00131
00132 if(phokey_.interf) cout<<" Option with interference is active"<<endl;
00133 if(phokey_.isec) cout<<" Option with double photons is active"<<endl;
00134 if(phokey_.itre) cout<<" Option with triple/quatric photons is active"<<endl;
00135 if(phokey_.iexp) cout<<" Option with exponentiation is active EPSEXP="<<phokey_.expeps<<endl;
00136 if(phokey_.iftop) cout<<" Emision in t tbar production is active"<<endl;
00137 if(phokey_.ifw) cout<<" Correction wt in decay of W is active"<<endl;
00138 if(meCorrectionWtForZ) cout<<" ME in decay of Z is active"<<endl;
00139 if(meCorrectionWtForW) cout<<" ME in decay of W is active"<<endl;
00140 cout<<endl<<" WARNING: /HEPEVT/ is not anymore used."<<endl<<endl;
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 cout<<"********************************************************************************"<<endl;
00151
00152 cout.precision(coutPrec);
00153 cout.flags (flags);
00154
00155
00156
00157 Photos::suppressBremForDecay(0,110);
00158 Photos::suppressBremForDecay(0,990);
00159 Photos::suppressBremForDecay(0,9902110);
00160 Photos::suppressBremForDecay(0,9902210);
00161 Photos::suppressBremForDecay(0,9900110);
00162 Photos::suppressBremForDecay(0,9900210);
00163 Photos::suppressBremForDecay(0,9900220);
00164 Photos::suppressBremForDecay(0,9900330);
00165 Photos::suppressBremForDecay(0,9900440);
00166
00167
00168 PhotosRandom::initialize();
00169 }
00170 void Photos::iniInfo()
00171 {
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 int coutPrec = cout.precision(6);
00184 ios_base::fmtflags flags = cout.setf(ios_base::floatfield);
00185 cout<<endl;
00186 cout<<"********************************************************************************"<<endl<<endl;
00187 cout<<" ========================================="<<endl;
00188 cout<<" PHOTOS, information routine"<<endl;
00189 cout<<" Input parameters after reinitialization: "<<endl<<endl;
00190 cout<<" ========================================="<<endl<<endl;
00191 cout<<"********************************************************************************"<<endl<<endl;
00192 cout<<" INTERF= "<<phokey_.interf<<" ISEC= " <<phokey_.isec <<" ITRE= "<<phokey_.itre
00193 <<" IEXP= " <<phokey_.iexp <<" IFTOP= "<<phokey_.iftop<<" IFW= " <<phokey_.ifw <<endl;
00194 cout<<" ALPHA_QED= "<<phocop_.alpha<<" XPHCUT= "<<phocop_.xphcut<<endl<<endl;
00195
00196 if(phokey_.interf) cout<<" Option with interference is active"<<endl;
00197 if(phokey_.isec) cout<<" Option with double photons is active"<<endl;
00198 if(phokey_.itre) cout<<" Option with triple/quatric photons is active"<<endl;
00199 if(phokey_.iexp) cout<<" Option with exponentiation is active EPSEXP="<<phokey_.expeps<<endl;
00200 if(phokey_.iftop) cout<<" Emision in t tbar production is active"<<endl;
00201 if(phokey_.ifw) cout<<" Correction wt in decay of W is active"<<endl;
00202 if(meCorrectionWtForZ) cout<<" ME in decay of Z is active"<<endl;
00203 if(meCorrectionWtForW) cout<<" ME in decay of W is active"<<endl;
00204 if(meCorrectionWtForScalar) cout<<" ME in decay of Scalar is active"<<endl;
00205
00206 cout<<endl<<" WARNING: /HEPEVT/ is not anymore used."<<endl<<endl;
00207
00208 cout.precision(coutPrec);
00209 cout.flags (flags);
00210 }
00211
00212 void Photos::processParticle(PhotosParticle *p)
00213 {
00214 PhotosBranch b(p);
00215 if(!b.getSuppressionStatus()) b.process();
00216 }
00217
00218 void Photos::processBranch(PhotosParticle *p)
00219 {
00220 vector<PhotosParticle *> particles = p->getDecayTree();
00221 vector<PhotosBranch *> branches = PhotosBranch::createBranches(particles);
00222 for(int i=0;i<(int)branches.size();i++) branches.at(i)->process();
00223 }
00224
00225 void Photos::suppressBremForDecay(int count, int motherID, ... )
00226 {
00227 va_list arg;
00228 va_start(arg, motherID);
00229 vector<int> *v = new vector<int>();
00230 v->push_back(motherID);
00231 for(int i = 0;i<count;i++)
00232 {
00233 v->push_back(va_arg(arg,int));
00234 }
00235 va_end(arg);
00236 v->push_back(0);
00237 if(!supBremList) supBremList = new vector< vector<int>* >();
00238 supBremList->push_back(v);
00239 }
00240
00241 void Photos::suppressBremForBranch(int count, int motherID, ... )
00242 {
00243 va_list arg;
00244 va_start(arg, motherID);
00245 vector<int> *v = new vector<int>();
00246 v->push_back(motherID);
00247 for(int i = 0;i<count;i++)
00248 {
00249 v->push_back(va_arg(arg,int));
00250 }
00251 va_end(arg);
00252 v->push_back(1);
00253 if(!supBremList) supBremList = new vector< vector<int>* >();
00254 supBremList->push_back(v);
00255 }
00256
00257 void Photos::forceBremForDecay(int count, int motherID, ... )
00258 {
00259 va_list arg;
00260 va_start(arg, motherID);
00261 vector<int> *v = new vector<int>();
00262 v->push_back(motherID);
00263 for(int i = 0;i<count;i++)
00264 {
00265 v->push_back(va_arg(arg,int));
00266 }
00267 va_end(arg);
00268 v->push_back(0);
00269 if(!forceBremList) forceBremList = new vector< vector<int>* >();
00270 forceBremList->push_back(v);
00271 }
00272
00273 void Photos::forceBremForBranch(int count, int motherID, ... )
00274 {
00275 va_list arg;
00276 va_start(arg, motherID);
00277 vector<int> *v = new vector<int>();
00278 v->push_back(motherID);
00279 for(int i = 0;i<count;i++)
00280 {
00281 v->push_back(va_arg(arg,int));
00282 }
00283 va_end(arg);
00284 v->push_back(1);
00285 if(!forceBremList) forceBremList = new vector< vector<int>* >();
00286 forceBremList->push_back(v);
00287 }
00288
00289 void Photos::createHistoryEntries(bool flag, int status)
00290 {
00291 if(status<3)
00292 {
00293 Log::Warning()<<"Photos::createHistoryEntries: status must be >=3"<<endl;
00294 return;
00295 }
00296
00297 isCreateHistoryEntries = flag;
00298 historyEntriesStatus = status;
00299 ignoreParticlesOfStatus(status);
00300 }
00301
00302 void Photos::ignoreParticlesOfStatus(int status)
00303 {
00304 if(status<3)
00305 {
00306 Log::Warning()<<"Photos::ignoreParticlesOfStatus: status must be >=3"<<endl;
00307 return;
00308 }
00309
00310 if(!ignoreStatusCodeList) ignoreStatusCodeList = new vector<int>();
00311
00312
00313 for(unsigned int i=0;i<ignoreStatusCodeList->size();i++)
00314 if( status==ignoreStatusCodeList->at(i) ) return;
00315
00316 ignoreStatusCodeList->push_back(status);
00317 }
00318
00319 void Photos::deIgnoreParticlesOfStatus(int status)
00320 {
00321 if(!ignoreStatusCodeList) return;
00322
00323 for(unsigned int i=0;i<ignoreStatusCodeList->size();i++)
00324 {
00325 if( status==ignoreStatusCodeList->at(i) )
00326 {
00327 ignoreStatusCodeList->erase(ignoreStatusCodeList->begin()+i);
00328 return;
00329 }
00330 }
00331 }
00332
00333 bool Photos::isStatusCodeIgnored(int status)
00334 {
00335 if(!ignoreStatusCodeList) return false;
00336
00337 for(unsigned int i=0;i<ignoreStatusCodeList->size();i++)
00338 if( status==ignoreStatusCodeList->at(i) ) return true;
00339
00340 return false;
00341 }
00342
00343 void Photos::setRandomGenerator( double (*gen)() )
00344 {
00345 if(gen==NULL) randomDouble = PhotosRandom::randomReal;
00346 else randomDouble = gen;
00347 }
00348
00349 void Photos::setExponentiation(bool expo)
00350 {
00351 phokey_.iexp = (int) expo;
00352 if(expo)
00353 {
00354 setDoubleBrem(false);
00355 setQuatroBrem(false);
00356 setInfraredCutOff(0.0000001);
00357 initializeKinematicCorrections(5);
00358 phokey_.expeps=0.0001;
00359 }
00360 }
00361
00362 void Photos::setMeCorrectionWtForW(bool corr)
00363 {
00364 meCorrectionWtForW=corr;
00365 }
00366
00367 void Photos::setMeCorrectionWtForZ(bool corr)
00368 {
00369 meCorrectionWtForZ=corr;
00370 }
00371 void Photos::setMeCorrectionWtForScalar(bool corr)
00372 {
00373 meCorrectionWtForScalar=corr;
00374 }
00375
00376 void Photos::setStopAtCriticalError(bool stop)
00377 {
00378 phosta_.ifstop=(int)stop;
00379 if(!stop)
00380 {
00381 Log::Info()<<"PHOTOS production mode. Elementary test of data flow from event record disabled. "<<endl
00382 <<"Prior checks of the complete configuration "<<endl
00383 <<"(for the particular set of input parameters) must have been done! "<<endl;
00384 }
00385 }
00386
00387
00388 void Photos::forceMassFromEventRecord(int pdgid)
00389 {
00390 if(!forceMassList) forceMassList = new vector<pair<int,double>* >();
00391 forceMassList->push_back( new pair<int,double>(pdgid, -1.0) );
00392 }
00393
00394 void Photos::forceMass(int pdgid, double mass)
00395 {
00396 if(mass<0.0)
00397 {
00398 Log::Warning()<<"Photos::forceMass: Mass must be > 0.0"<<endl;
00399 return;
00400 }
00401
00402 if(!forceMassList) forceMassList = new vector<pair<int,double>* >();
00403 forceMassList->push_back( new pair<int,double>(pdgid, mass) );
00404 }
00405
00406 }