4 using std::stringstream;
13 void (*PHOERR)(int,
const char*,double) =
Log::PHOERR;
16 list<Log::Pointer*> *Log::PointerList = NULL;
18 streambuf *Log::bCout=cout.rdbuf(),*Log::bCerr=cerr.rdbuf();
19 ostream *Log::out=&cout;
20 stringstream Log::buf;
21 int Log::warnLimit=100;
22 int Log::decays[4] = {0};
23 int Log::dCount =0,Log::dRangeS =65535,Log::dRangeE =65534;
24 int Log::faCount=0,Log::faRangeS=65535,Log::faRangeE=65534;
25 int Log::iCount =0,Log::wCount =0,Log::eCount =0,Log::asCount=0, Log::asFailedCount=0;
26 bool Log::iAction=1,Log::wAction=1,Log::eAction=1,Log::asAction=1,Log::rAction=1;
36 if(code>=dRangeS && code<=dRangeE )
return *out<<
"DEBUG("<<code<<
") from PHOTOS:"<<endl;
41 ostream& Log::Info(
bool count)
44 if(iAction)
return *out<<
"INFO from PHOTOS:"<<endl;
49 ostream& Log::Warning(
bool count)
52 if(warnLimit>0 && wCount>=warnLimit)
56 *out<<
"WARNING from PHOTOS:"<<endl<<
"Limit reached ("<<warnLimit<<
"). Warnings suppressed."<<endl;
61 if(wAction && count)
return *out<<
"WARNING from PHOTOS:"<<endl;
62 if(wAction)
return *out;
67 ostream& Log::Error(
bool count)
70 if(eAction)
return *out<<
"ERROR from PHOTOS:"<<endl;
80 if(text==NULL) *out<<
"ASSERT from PHOTOS:"<<endl<<
"Assertion failed. "<<endl;
81 else *out<<
"ASSERT from PHOTOS:"<<endl<<
"Assertion failed: "<<text<<endl;
82 if(asAction) exit(-1);
85 void Log::Fatal(
string text,
unsigned short code)
88 if(text.size()==0) *out<<
"FATAL ERROR from PHOTOS:"<<endl<<
"Terminated by a call to Log::Exit();"<<endl;
89 else *out<<
"FATAL ERROR from PHOTOS: "<<endl<<text<<endl;
90 if(code<faRangeS || code>faRangeE) exit(-1);
96 if(!rAction) { func();
return; }
97 cout.rdbuf(where.rdbuf());
98 cerr.rdbuf(where.rdbuf());
108 cout.rdbuf(where.rdbuf());
109 cerr.rdbuf(where.rdbuf());
115 *out<<
"---------------------------- Photos Log Summary ------------------------------"<<endl;
117 if(dRangeS>dRangeE) *out<<
"(OFF)";
118 *out<<
"\t\t"<<dCount<<
"\t";
119 if(dRangeS<=dRangeE) *out<<
"Debug range: "<<dRangeS<<
" - "<<dRangeE;
122 if(!iAction) *out<<
"(OFF)";
123 *out<<
"\t\t"<<iCount<<
"\t"<<endl;
124 *out<<
" Warnings:\t";
125 if(!wAction) {
if(warnLimit>0 && wCount>warnLimit) *out<<
"(SUPP.)";
else *out<<
"(OFF)"; }
126 *out<<
"\t\t"<<wCount<<
"\t"<<endl;
128 if(!eAction) *out<<
"(OFF)";
129 *out<<
"\t\t"<<eCount<<
"\t"<<endl;
130 if(asCount || !asAction || faRangeS<faRangeE) cout<<
"-----------------------------------"<<endl;
131 if(asCount>0) *out<<
" Asserts:\t\t\t"<<asCount<<endl;
132 if(!asAction) *out<<
" Failed asserts ignored:\t"<<asFailedCount<<endl;
133 if(faRangeS<=faRangeE) *out<<
" Fatal errors ignored: \t"<<faCount<<endl;
134 cout<<
"-----------------------------------"<<endl;
135 if(decays[3]) cout<<
" Normal decays: "<<decays[3]<<endl;
136 if(decays[2]) cout<<
" Decays without mother: "<<decays[2]<<endl;
137 if(decays[1]) cout<<
" Decays without mother & grandmothers: "<<decays[1]<<endl;
138 if(decays[0]) cout<<
" Decayed using Tauola gun: "<<decays[0]<<endl;
139 *out<<
"------------------------------------------------------------------------------"<<endl;
162 static int PHOMES=10;
164 char star80[81]=
"********************************************************************************";
166 if (IMES<=PHOMES) phosta.status[IMES-i]=phosta.status[IMES-i]+1;
169 if ((IMES == 6) && (phosta.status[IMES-i]>=2))
return;
170 if ((IMES == 10) && (phosta.status[IMES-i]>=2))
return;
173 bool IFSTOP=phosta.ifstop;
174 FILE *PHLUN = stdout;
176 fprintf(PHLUN,
"%s\n",star80);
177 fprintf(PHLUN,
"*\n");
182 fprintf(PHLUN,
"* %s: Too many charged Particles, NCHARG = %6i\n", TEXT,(
int)SDATA);
186 fprintf(PHLUN,
"* %s: Too much Bremsstrahlung required, PRSOFT = %15.6f\n", TEXT,SDATA);
190 fprintf(PHLUN,
"* %s: Combined Weight is exceeding 1., Weight = %15.6f\n", TEXT,SDATA);
194 fprintf(PHLUN,
"* %s: Error in Rescaling charged and neutral Vectors\n", TEXT);
198 fprintf(PHLUN,
"* %s: Non matching charged Particle Pointer, NCHARG = %5i\n", TEXT,(
int)SDATA);
202 fprintf(PHLUN,
"* %s: Do you really work with a Particle of Spin: %4.1f\n", TEXT,SDATA);
206 fprintf(PHLUN,
"* %s: Stack Length exceeded, NSTACK = %5i\n", TEXT,(
int)(SDATA));
210 fprintf(PHLUN,
"* %s: Random Number Generator Seed(1) out of Range: %8i\n", TEXT,(
int)SDATA);
214 fprintf(PHLUN,
"* %s: Random Number Generator Seed(2) out of Range: %8i\n", TEXT,(
int)SDATA);
218 fprintf(PHLUN,
"* %s: Available Phase Space below Cut-off: %15.6f GeV/c^2\n", TEXT,SDATA);
222 fprintf(PHLUN,
"* Funny Error Message: %4i ! What to do ?\n", IMES);
229 fprintf(PHLUN,
"* Fatal Error Message, I stop this Run !\n");
230 fprintf(PHLUN,
"*\n");
231 fprintf(PHLUN,
"%s\n",star80);
236 fprintf(PHLUN,
"*\n");
237 fprintf(PHLUN,
"%s\n",star80);
243 fprintf(PHLUN,
"* 10 Error Messages generated, I stop this Run !\n");
244 fprintf(PHLUN,
"*\n");
245 fprintf(PHLUN,
"%s\n",star80);
250 fprintf(PHLUN,
"*\n");
251 fprintf(PHLUN,
"%s\n",star80);
256 fprintf(PHLUN,
"*\n");
257 fprintf(PHLUN,
"%s\n",star80);
286 static int PHOMES=10;
290 char star80[81]=
"********************************************************************************";
292 char EQ25[26]=
"=========================";
297 FILE *PHLUN = stdout;
298 fprintf(PHLUN,
" \n");
299 fprintf(PHLUN,
"%s\n",star80);
300 fprintf(PHLUN,
"*\n");
301 fprintf(PHLUN,
"* %s %s\n",X26,EQ25);
302 fprintf(PHLUN,
"* %s PHOTOS Run Summary\n",X30);
303 fprintf(PHLUN,
"* %s %s\n",X26,EQ25);
304 fprintf(PHLUN,
"*\n");
305 for(I=1;I<=PHOMES;I++){
307 if (phosta.status[I-1] == 0)
break;
308 if ((I == 6)|| (I == 10)){
309 fprintf(PHLUN,
"* %s Warning # %2i occured %6i times\n",X22, I,phosta.status[I-1]);
313 fprintf(PHLUN,
"* %s Error # %2i occured %6i times\n",X23, I,phosta.status[I-1]);
317 if (!ERROR) fprintf(PHLUN,
"* %s PHOTOS Execution has successfully terminated\n",X16);
318 fprintf(PHLUN,
"*\n");
319 fprintf(PHLUN,
"%s\n",star80);
static void Assert(bool check, char *text=NULL)
static void AddDecay(int type)
static ostream & Debug(unsigned short int code=0, bool count=true)
static void Fatal(string text, unsigned short int code=0)
static void RedirectOutput(void(*func)(), ostream &where=*out)
static void PHOERR(int IMES, const char *TEXT, double DATA)