4 using std::stringstream;
12 void (*PHOERR)(int,
const char*, double) =
Log::PHOERR;
15 list<Log::Pointer*>* Log::PointerList = NULL;
17 streambuf* Log::bCout = cout.rdbuf(), *Log::bCerr = cerr.rdbuf();
18 ostream* Log::out = &cout;
19 stringstream Log::buf;
20 int Log::warnLimit = 100;
21 int Log::decays[4] = {0};
22 int Log::dCount = 0, Log::dRangeS = 65535, Log::dRangeE = 65534;
23 int Log::faCount = 0, Log::faRangeS = 65535, Log::faRangeE = 65534;
24 int Log::iCount = 0, Log::wCount = 0, Log::eCount = 0, Log::asCount = 0, Log::asFailedCount = 0;
25 bool Log::iAction = 1, Log::wAction = 1, Log::eAction = 1, Log::asAction = 1, Log::rAction = 1;
35 if (code >= dRangeS && code <= dRangeE)
return *out <<
"DEBUG(" << code <<
") from PHOTOS:" << endl;
40 ostream& Log::Info(
bool count)
43 if (iAction)
return *out <<
"INFO from PHOTOS:" << endl;
48 ostream& Log::Warning(
bool count)
51 if (warnLimit > 0 && wCount >= warnLimit) {
53 *out <<
"WARNING from PHOTOS:" << endl <<
"Limit reached (" << warnLimit <<
"). Warnings suppressed." << endl;
58 if (wAction && count)
return *out <<
"WARNING from PHOTOS:" << endl;
59 if (wAction)
return *out;
64 ostream& Log::Error(
bool count)
67 if (eAction)
return *out <<
"ERROR from PHOTOS:" << endl;
77 if (text == NULL) *out <<
"ASSERT from PHOTOS:" << endl <<
"Assertion failed. " << endl;
78 else *out <<
"ASSERT from PHOTOS:" << endl <<
"Assertion failed: " << text << endl;
79 if (asAction) exit(-1);
82 void Log::Fatal(
string text,
unsigned short code)
85 if (text.size() == 0) *out <<
"FATAL ERROR from PHOTOS:" << endl <<
"Terminated by a call to Log::Exit();" << endl;
86 else *out <<
"FATAL ERROR from PHOTOS: " << endl << text << endl;
87 if (code < faRangeS || code > faRangeE) exit(-1);
93 if (!rAction) { func();
return; }
94 cout.rdbuf(where.rdbuf());
95 cerr.rdbuf(where.rdbuf());
104 if (!rAction)
return;
105 cout.rdbuf(where.rdbuf());
106 cerr.rdbuf(where.rdbuf());
112 *out <<
"---------------------------- Photos Log Summary ------------------------------" << endl;
113 *out <<
" Debug: \t";
114 if (dRangeS > dRangeE) *out <<
"(OFF)";
115 *out <<
"\t\t" << dCount <<
"\t";
116 if (dRangeS <= dRangeE) *out <<
"Debug range: " << dRangeS <<
" - " << dRangeE;
119 if (!iAction) *out <<
"(OFF)";
120 *out <<
"\t\t" << iCount <<
"\t" << endl;
121 *out <<
" Warnings:\t";
122 if (!wAction) {
if (warnLimit > 0 && wCount > warnLimit) *out <<
"(SUPP.)";
else *out <<
"(OFF)"; }
123 *out <<
"\t\t" << wCount <<
"\t" << endl;
124 *out <<
" Errors: \t";
125 if (!eAction) *out <<
"(OFF)";
126 *out <<
"\t\t" << eCount <<
"\t" << endl;
127 if (asCount || !asAction || faRangeS < faRangeE) cout <<
"-----------------------------------" << endl;
128 if (asCount > 0) *out <<
" Asserts:\t\t\t" << asCount << endl;
129 if (!asAction) *out <<
" Failed asserts ignored:\t" << asFailedCount << endl;
130 if (faRangeS <= faRangeE) *out <<
" Fatal errors ignored: \t" << faCount << endl;
131 cout <<
"-----------------------------------" << endl;
132 if (decays[3]) cout <<
" Normal decays: " << decays[3] << endl;
133 if (decays[2]) cout <<
" Decays without mother: " << decays[2] << endl;
134 if (decays[1]) cout <<
" Decays without mother & grandmothers: " << decays[1] << endl;
135 if (decays[0]) cout <<
" Decayed using Tauola gun: " << decays[0] << endl;
136 *out <<
"------------------------------------------------------------------------------" << endl;
158 static int IERROR = 0;
160 static int PHOMES = 10;
162 char star80[81] =
"********************************************************************************";
164 if (IMES <= PHOMES) phosta.status[IMES - i] = phosta.status[IMES - i] + 1;
167 if ((IMES == 2) && (phosta.status[IMES - i] >= 2))
return;
168 if ((IMES == 3) && (phosta.status[IMES - i] >= 2))
return;
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);
235 fprintf(PHLUN,
"*\n");
236 fprintf(PHLUN,
"%s\n", star80);
242 fprintf(PHLUN,
"* 10 Error Messages generated, I stop this Run !\n");
243 fprintf(PHLUN,
"*\n");
244 fprintf(PHLUN,
"%s\n", star80);
248 fprintf(PHLUN,
"*\n");
249 fprintf(PHLUN,
"%s\n", star80);
254 fprintf(PHLUN,
"*\n");
255 fprintf(PHLUN,
"%s\n", star80);
285 static int PHOMES = 10;
289 char star80[81] =
"********************************************************************************";
291 char EQ25[26] =
"=========================";
296 FILE* PHLUN = stdout;
297 fprintf(PHLUN,
" \n");
298 fprintf(PHLUN,
"%s\n", star80);
299 fprintf(PHLUN,
"*\n");
300 fprintf(PHLUN,
"* %s %s\n", X26, EQ25);
301 fprintf(PHLUN,
"* %s PHOTOS Run Summary\n", X30);
302 fprintf(PHLUN,
"* %s %s\n", X26, EQ25);
303 fprintf(PHLUN,
"*\n");
304 for (I = 1; I <= PHOMES; I++) {
306 if (phosta.status[I - 1] == 0)
break;
307 if ((I == 6) || (I == 10)) {
308 fprintf(PHLUN,
"* %s Warning # %2i occured %6i times\n", X22, I, phosta.status[I - 1]);
311 fprintf(PHLUN,
"* %s Error # %2i occured %6i times\n", X23, I, phosta.status[I - 1]);
315 if (!ERROR) fprintf(PHLUN,
"* %s PHOTOS Execution has successfully terminated\n", X16);
316 fprintf(PHLUN,
"*\n");
317 fprintf(PHLUN,
"%s\n", star80);
static ostream & Debug(unsigned short int code=0, bool count=true)
Four logging entries.
static void AddDecay(int type)
Adds the decay to the counter.
static void Assert(bool check, char *text=NULL)
Asserts logical value.
static void RedirectOutput(void(*func)(), ostream &where= *out)
Redirects output to log.
static void Fatal(string text, unsigned short int code=0)
Terminates the program with added default message or 'text'.
static void PHOREP()
Final report of warnings from internal part of PHOTOS (originally in F77)
static void PHOERR(int IMES, const char *TEXT, double DATA)
Warnings on errors from internal part of PHOTOS (originally in F77)
static void Summary()
Shows the summary of all messages.