FairRoot/PandaRoot
Photos.cxx
Go to the documentation of this file.
1 #include <stdarg.h>
2 #include <iostream>
3 #include <vector>
4 
5 #include "PhotosRandom.h"
6 #include "PhotosEvent.h"
7 #include "Photos.h"
8 #include "Log.h"
9 using std::vector;
10 using std::cout;
11 using std::endl;
12 using std::ios_base;
13 
14 namespace Photospp
15 {
16 
18 
19 vector<vector<int>* > *Photos::supBremList = 0;
20 vector<vector<int>* > *Photos::forceBremList = 0;
21 vector<pair<int,double>* > *Photos::forceMassList = 0;
22 vector<int> *Photos::ignoreStatusCodeList = 0;
23 bool Photos::isSuppressed=false;
24 bool Photos::massFrom4Vector=true;
32 
34 {
35  setAlphaQED (0.00729735039);
36  setInfraredCutOff (0.01);
37  setInterference (true);
38  setDoubleBrem (true);
39  setQuatroBrem (false);
41  setCorrectionWtForW (true);
42 
43  // setExponentiation(true) moved to initialize() due to communication
44  // problems with Fortran under MacOS.
45  phokey_.iexp = 1;
46 }
47 
49 {
50 // Should return if already initialized?
51 
52 /*******************************************************************************
53  All the following parameter setters can be called after PHOINI.
54  Initialization of kinematic correction against rounding errors.
55  The set values will be used later if called with zero.
56  Default parameter is 1 (no correction) optionally 2, 3, 4
57  In case of exponentiation new version 5 is needed in most cases.
58  Definition given here will be thus overwritten in such a case
59  below in routine PHOCIN
60 *******************************************************************************/
62  else setExponentiation(true);
63 
64  int buf=1;
65  iphqrk_(&buf); // Blocks emission from quarks if buf=1 (default); enables if buf=2
66  // Physical treatment will be 3, option 2 is not realistic and for tests only
67  buf=2;
68  iphekl_(&buf); // Blocks emission in pi0 to gamma e+ e- if parameter is >1 (enables otherwise)
69 
70 // Initialize status counter for warning messages
71  for(int i=0;i<10;i++) phosta_.status[i]=0;
72 // elementary security level, should remain 1 but we may want to have a method to change.
73  phosta_.ifstop=1;
74 
75  pholun_.phlun=6; // Logical output unit for printing error messages
76 
77 // Define pi and 2*pi
78  phpico_.pi =3.14159265358979324;
79  phpico_.twopi=6.28318530717958648;
80 
81 // Further initialization done automatically
82 // see places with - VARIANT A - VARIANT B - all over to switch between options
83 
84 //----------- SLOWER VARIANT A, but stable ------------------
85 //--- it is limiting choice for small XPHCUT in fixed orer
86 //--- modes of operation
87 
88 // Best choice is if FINT=2**N where N+1 is maximal number
89 // of charged daughters
90 // see report on overweihted events
91  if(phokey_.interf) maxWtInterference(2.0);
92  else maxWtInterference(1.0);
93 
94 /*
95 ----------- FASTER VARIANT B ------------------
96 -- it is good for tests of fixed order and small XPHCUT
97 -- but is less promising for more complex cases of interference
98 -- sometimes fails because of that
99 
100  if(phokey_.interf) maxWtInterference(1.8);
101  else maxWtInterference(0.0);
102 ------------END VARIANTS A B -----------------------
103 */
104 
105 
106 //------------------------------------------------------------------------------
107 // Print PHOTOS header
108 //------------------------------------------------------------------------------
109  int coutPrec = cout.precision(6);
110  ios_base::fmtflags flags = cout.setf(ios_base::floatfield);
111  cout<<endl;
112  cout<<"********************************************************************************"<<endl<<endl;
113 
114  cout<<" ========================="<<endl;
115  cout<<" PHOTOS, Version: "<<VER_MAJOR<<"."<<VER_MINOR<<endl;
116  cout<<" Released at: "<<DAT_DAY<<"/"<<DAT_MONTH<<"/"<<DAT_YEAR<<endl;
117  cout<<" ========================="<<endl<<endl;
118 
119  cout<<" Photos QED corrections in Particle Decays"<<endl<<endl;
120 
121  cout<<" Monte Carlo Program - by E. Barberio, B. van Eijk and Z. Was"<<endl;
122  cout<<" From version 2.09 - by P. Golonka and Z. Was"<<endl;
123  cout<<" From version 3.00 - by N. Davidson, T. Przedzinski and Z. Was"<<endl;
124 
125  cout<<"********************************************************************************"<<endl<<endl;
126 
127  cout<<" Internal (default) input parameters: "<<endl<<endl;
128  cout<<" INTERF= "<<phokey_.interf<<" ISEC= " <<phokey_.isec <<" ITRE= "<<phokey_.itre
129  <<" IEXP= " <<phokey_.iexp <<" IFTOP= "<<phokey_.iftop<<" IFW= " <<phokey_.ifw <<endl;
130  cout<<" ALPHA_QED= "<<phocop_.alpha<<" XPHCUT= "<<phocop_.xphcut<<endl<<endl;
131 
132  if(phokey_.interf) cout<<" Option with interference is active"<<endl;
133  if(phokey_.isec) cout<<" Option with double photons is active"<<endl;
134  if(phokey_.itre) cout<<" Option with triple/quatric photons is active"<<endl;
135  if(phokey_.iexp) cout<<" Option with exponentiation is active EPSEXP="<<phokey_.expeps<<endl;
136  if(phokey_.iftop) cout<<" Emision in t tbar production is active"<<endl;
137  if(phokey_.ifw) cout<<" Correction wt in decay of W is active"<<endl;
138  if(meCorrectionWtForZ) cout<<" ME in decay of Z is active"<<endl;
139  if(meCorrectionWtForW) cout<<" ME in decay of W is active"<<endl;
140  cout<<endl<<" WARNING: /HEPEVT/ is not anymore used."<<endl<<endl;
141 /*
142  cout<<endl<<" WARNING (1): /HEPEVT/ is not anymore the standard common block"<<endl<<endl;
143 
144  cout<<" PHOTOS expects /HEPEVT/ to have REAL*8 variables. To change to"<<endl;
145  cout<<" REAL*4 modify its declaration in subr. PHOTOS_GET PHOTOS_SET:"<<endl;
146  cout<<" REAL*8 d_h_phep, d_h_vhep"<<endl;
147  cout<<" WARNING (2): check dims. of /hepevt/ /phoqed/ /ph_hepevt/."<<endl;
148  cout<<" HERE: d_h_nmxhep=10000 and NMXHEP=10000"<<endl<<endl;
149 */
150  cout<<"********************************************************************************"<<endl;
151  // Revert output stream flags and precision
152  cout.precision(coutPrec);
153  cout.flags (flags);
154 
155  // Add reggeon, pomeron and its diffractive states to the list
156  // of decays where bremsstrahlung is suppressed
159  Photos::suppressBremForDecay(0,9902110);
160  Photos::suppressBremForDecay(0,9902210);
161  Photos::suppressBremForDecay(0,9900110);
162  Photos::suppressBremForDecay(0,9900210);
163  Photos::suppressBremForDecay(0,9900220);
164  Photos::suppressBremForDecay(0,9900330);
165  Photos::suppressBremForDecay(0,9900440);
166 
167 // Initialize Marsaglia and Zaman random number generator
169 }
171 {
172 // prints infomation like Photos::initialize; may be called after reinitializations.
173 
174 /*******************************************************************************
175  Once parameter setters are called after PHOINI one may want to know and write
176  into output info including all reinitializations.
177 *******************************************************************************/
178 
179 
180 //------------------------------------------------------------------------------
181 // Print PHOTOS header again
182 //------------------------------------------------------------------------------
183  int coutPrec = cout.precision(6);
184  ios_base::fmtflags flags = cout.setf(ios_base::floatfield);
185  cout<<endl;
186  cout<<"********************************************************************************"<<endl<<endl;
187  cout<<" ========================================="<<endl;
188  cout<<" PHOTOS, information routine"<<endl;
189  cout<<" Input parameters after reinitialization: "<<endl<<endl;
190  cout<<" ========================================="<<endl<<endl;
191  cout<<"********************************************************************************"<<endl<<endl;
192  cout<<" INTERF= "<<phokey_.interf<<" ISEC= " <<phokey_.isec <<" ITRE= "<<phokey_.itre
193  <<" IEXP= " <<phokey_.iexp <<" IFTOP= "<<phokey_.iftop<<" IFW= " <<phokey_.ifw <<endl;
194  cout<<" ALPHA_QED= "<<phocop_.alpha<<" XPHCUT= "<<phocop_.xphcut<<endl<<endl;
195 
196  if(phokey_.interf) cout<<" Option with interference is active"<<endl;
197  if(phokey_.isec) cout<<" Option with double photons is active"<<endl;
198  if(phokey_.itre) cout<<" Option with triple/quatric photons is active"<<endl;
199  if(phokey_.iexp) cout<<" Option with exponentiation is active EPSEXP="<<phokey_.expeps<<endl;
200  if(phokey_.iftop) cout<<" Emision in t tbar production is active"<<endl;
201  if(phokey_.ifw) cout<<" Correction wt in decay of W is active"<<endl;
202  if(meCorrectionWtForZ) cout<<" ME in decay of Z is active"<<endl;
203  if(meCorrectionWtForW) cout<<" ME in decay of W is active"<<endl;
204  if(meCorrectionWtForScalar) cout<<" ME in decay of Scalar is active"<<endl;
205 
206  cout<<endl<<" WARNING: /HEPEVT/ is not anymore used."<<endl<<endl;
207  // Revert output stream flags and precision
208  cout.precision(coutPrec);
209  cout.flags (flags);
210 }
211 
213 {
214  PhotosBranch b(p);
215  if(!b.getSuppressionStatus()) b.process();
216 }
217 
219 {
220  vector<PhotosParticle *> particles = p->getDecayTree();
221  vector<PhotosBranch *> branches = PhotosBranch::createBranches(particles);
222  for(int i=0;i<(int)branches.size();i++) branches.at(i)->process();
223 }
224 
225 void Photos::suppressBremForDecay(int count, int motherID, ... )
226 {
227  va_list arg;
228  va_start(arg, motherID);
229  vector<int> *v = new vector<int>();
230  v->push_back(motherID);
231  for(int i = 0;i<count;i++)
232  {
233  v->push_back(va_arg(arg,int));
234  }
235  va_end(arg);
236  v->push_back(0);
237  if(!supBremList) supBremList = new vector< vector<int>* >();
238  supBremList->push_back(v);
239 }
240 
241 void Photos::suppressBremForBranch(int count, int motherID, ... )
242 {
243  va_list arg;
244  va_start(arg, motherID);
245  vector<int> *v = new vector<int>();
246  v->push_back(motherID);
247  for(int i = 0;i<count;i++)
248  {
249  v->push_back(va_arg(arg,int));
250  }
251  va_end(arg);
252  v->push_back(1);
253  if(!supBremList) supBremList = new vector< vector<int>* >();
254  supBremList->push_back(v);
255 }
256 
257 void Photos::forceBremForDecay(int count, int motherID, ... )
258 {
259  va_list arg;
260  va_start(arg, motherID);
261  vector<int> *v = new vector<int>();
262  v->push_back(motherID);
263  for(int i = 0;i<count;i++)
264  {
265  v->push_back(va_arg(arg,int));
266  }
267  va_end(arg);
268  v->push_back(0);
269  if(!forceBremList) forceBremList = new vector< vector<int>* >();
270  forceBremList->push_back(v);
271 }
272 
273 void Photos::forceBremForBranch(int count, int motherID, ... )
274 {
275  va_list arg;
276  va_start(arg, motherID);
277  vector<int> *v = new vector<int>();
278  v->push_back(motherID);
279  for(int i = 0;i<count;i++)
280  {
281  v->push_back(va_arg(arg,int));
282  }
283  va_end(arg);
284  v->push_back(1);
285  if(!forceBremList) forceBremList = new vector< vector<int>* >();
286  forceBremList->push_back(v);
287 }
288 
290 {
291  if(status<3)
292  {
293  Log::Warning()<<"Photos::createHistoryEntries: status must be >=3"<<endl;
294  return;
295  }
296 
297  isCreateHistoryEntries = flag;
299  ignoreParticlesOfStatus(status);
300 }
301 
303 {
304  if(status<3)
305  {
306  Log::Warning()<<"Photos::ignoreParticlesOfStatus: status must be >=3"<<endl;
307  return;
308  }
309 
310  if(!ignoreStatusCodeList) ignoreStatusCodeList = new vector<int>();
311 
312  // Do not add duplicate entries to the list
313  for(unsigned int i=0;i<ignoreStatusCodeList->size();i++)
314  if( status==ignoreStatusCodeList->at(i) ) return;
315 
316  ignoreStatusCodeList->push_back(status);
317 }
318 
320 {
321  if(!ignoreStatusCodeList) return;
322 
323  for(unsigned int i=0;i<ignoreStatusCodeList->size();i++)
324  {
325  if( status==ignoreStatusCodeList->at(i) )
326  {
328  return;
329  }
330  }
331 }
332 
334 {
335  if(!ignoreStatusCodeList) return false;
336 
337  for(unsigned int i=0;i<ignoreStatusCodeList->size();i++)
338  if( status==ignoreStatusCodeList->at(i) ) return true;
339 
340  return false;
341 }
342 
343 void Photos::setRandomGenerator( double (*gen)() )
344 {
345  if(gen==NULL) randomDouble = PhotosRandom::randomReal;
346  else randomDouble = gen;
347 }
348 
350 {
351  phokey_.iexp = (int) expo;
352  if(expo)
353  {
354  setDoubleBrem(false);
355  setQuatroBrem(false);
356  setInfraredCutOff(0.0000001);
358  phokey_.expeps=0.0001;
359  }
360 }
361 
363 {
365 }
366 
368 {
370 }
372 {
374 }
375 
377 {
378  phosta_.ifstop=(int)stop;
379  if(!stop)
380  {
381  Log::Info()<<"PHOTOS production mode. Elementary test of data flow from event record disabled. "<<endl
382  <<"Prior checks of the complete configuration "<<endl
383  <<"(for the particular set of input parameters) must have been done! "<<endl;
384  }
385 }
386 
387 
389 {
390  if(!forceMassList) forceMassList = new vector<pair<int,double>* >();
391  forceMassList->push_back( new pair<int,double>(pdgid, -1.0) );
392 }
393 
394 void Photos::forceMass(int pdgid, double mass)
395 {
396  if(mass<0.0)
397  {
398  Log::Warning()<<"Photos::forceMass: Mass must be > 0.0"<<endl;
399  return;
400  }
401 
402  if(!forceMassList) forceMassList = new vector<pair<int,double>* >();
403  forceMassList->push_back( new pair<int,double>(pdgid, mass) );
404 }
405 
406 } // namespace Photospp
static vector< int > * ignoreStatusCodeList
Definition: Photos.h:169
static Photos _instance
Definition: Photos.h:201
Double_t p
Definition: anasim.C:58
static vector< PhotosBranch * > createBranches(vector< PhotosParticle * > particles)
int iphqrk_(int *i)
struct @22 phosta_
static const int DAT_MONTH
Definition: Photos.h:32
static bool meCorrectionWtForZ
Definition: Photos.h:178
static const int VER_MINOR
Definition: Photos.h:31
static void maxWtInterference(double interference)
Definition: Photos.h:82
Int_t i
Definition: run_full.C:25
TTree * b
PndPidCorrelator * corr
struct @23 phpico_
static double randomReal()
static void initialize()
Definition: Photos.cxx:48
static bool isStatusCodeIgnored(int status)
Definition: Photos.cxx:333
static void forceMassFromEventRecord(int pdgid)
Definition: Photos.cxx:388
static vector< vector< int > * > * forceBremList
Definition: Photos.h:163
static void setInfraredCutOff(double cut_off)
Definition: Photos.h:85
static vector< vector< int > * > * supBremList
Definition: Photos.h:160
struct @21 phokey_
static void forceMass(int pdgid, double mass)
Definition: Photos.cxx:394
static void ignoreParticlesOfStatus(int status)
Definition: Photos.cxx:302
static bool meCorrectionWtForScalar
Definition: Photos.h:175
static void suppressBremForDecay(int count, int motherID,...)
Definition: Photos.cxx:225
__m128 v
Definition: P4_F32vec4.h:4
static bool massFrom4Vector
Definition: Photos.h:157
static ostream & Info(bool count=true)
Definition: Log.cxx:38
static vector< pair< int, double > * > * forceMassList
Definition: Photos.h:166
static void forceBremForDecay(int count, int motherID,...)
Definition: Photos.cxx:257
static void initializeKinematicCorrections(int flag)
Definition: Photos.h:125
static const int DAT_YEAR
Definition: Photos.h:32
static double(* randomDouble)()
Definition: Photos.h:190
static void createHistoryEntries(bool flag, int status)
Definition: Photos.cxx:289
static bool isSuppressed
Definition: Photos.h:154
static void setInterference(bool interference)
Definition: Photos.h:91
static void setExponentiation(bool expo)
Definition: Photos.cxx:349
static void setCorrectionWtForW(bool corr)
Definition: Photos.h:100
static void setStopAtCriticalError(bool stop)
Definition: Photos.cxx:376
std::vector< PhotosParticle * > getDecayTree()
static void processParticle(PhotosParticle *p)
Definition: Photos.cxx:212
static void initialize()
Controls the configuration and initialization of Photos.
static void setMeCorrectionWtForW(bool corr)
Definition: Photos.cxx:362
struct @24 pholun_
static void forceBremForBranch(int count, int motherID,...)
Definition: Photos.cxx:273
static double momentum_conservation_threshold
Definition: Photos.h:172
static ostream & Warning(bool count=true)
Definition: Log.cxx:46
static void processBranch(PhotosParticle *p)
Definition: Photos.cxx:218
static void suppressBremForBranch(int count, int motherID,...)
Definition: Photos.cxx:241
static void setMeCorrectionWtForScalar(bool corr)
Definition: Photos.cxx:371
static void setDoubleBrem(bool doub)
Definition: Photos.h:94
static void setMeCorrectionWtForZ(bool corr)
Definition: Photos.cxx:367
static void iniInfo()
Definition: Photos.cxx:170
static void setTopProcessRadiation(bool top)
Definition: Photos.h:115
static void setQuatroBrem(bool quatroBrem)
Definition: Photos.h:97
int count
static bool meCorrectionWtForW
Definition: Photos.h:181
struct @20 phocop_
static void setRandomGenerator(double(*gen)())
Definition: Photos.cxx:343
static int historyEntriesStatus
Definition: Photos.h:187
int iphekl_(int *i)
static const int DAT_DAY
Definition: Photos.h:32
static void deIgnoreParticlesOfStatus(int status)
Definition: Photos.cxx:319
static const int VER_MAJOR
Definition: Photos.h:31
static void setAlphaQED(double alpha)
Definition: Photos.h:88
int status[10]
Definition: f_Init.h:28
static bool isCreateHistoryEntries
Definition: Photos.h:184