50 std::ifstream in(filename.c_str());
53 printf(
"ValidationControl: error reading config file: %s\n",filename.c_str());
57 else printf(
"ValidationControl: parsing config file: %s\n",filename.c_str());
69 if( strlen(buf) < 3 || buf[0] ==
' ' || buf[0] ==
'#' ) {
75 if( strncmp(buf,
"EVENTS",6)==0 ) {
79 else if( strncmp(buf,
"INPUT",5)==0 ) {
86 if( strncmp(buf,
"tool",4)==0 ) {
90 status = UNAVAILABLE_TOOL;
93 else if( strncmp(buf,
"pythia8",7)==0) {
98 status = UNAVAILABLE_TOOL;
101 else status = UNRECOGNIZED_INPUT;
110 else if( strncmp(buf,
"TOOL",3)==0 ) {
113 if ( strncmp(buf,
"tauola",6)==0 ) {
117 status = UNAVAILABLE_TOOL;
120 else if( strncmp(buf,
"photos",6)==0 ) {
124 status = UNAVAILABLE_TOOL;
127 else if( strncmp(buf,
"mctester",8)==0 ) {
131 status = UNAVAILABLE_TOOL;
134 else status = UNRECOGNIZED_TOOL;
137 else if( strncmp(buf,
"SET",3)==0 ) {
140 if ( strncmp(buf,
"print_events",12)==0 ) {
144 if( strncmp(buf,
"ALL",3)==0 ) events = -1;
145 else events = atoi(buf);
149 else if( strncmp(buf,
"check_momentum",14)==0 ) {
153 if( strncmp(buf,
"ALL",3)==0 ) events = -1;
154 else events = atoi(buf);
158 else status = UNRECOGNIZED_OPTION;
160 else status = UNRECOGNIZED_COMMAND;
163 if(status != PARSING_OK) printf(
"ValidationControl: config file line %i: ",line);
166 case UNRECOGNIZED_COMMAND:
167 printf(
"skipping unrecognised command: '%s'\n",buf);
169 case UNRECOGNIZED_OPTION:
170 printf(
"skipping unrecognised option: '%s'\n",buf);
172 case UNRECOGNIZED_INPUT:
173 printf(
"skipping unrecognised input source: '%s'\n",buf);
175 case UNRECOGNIZED_TOOL:
176 printf(
"skipping unrecognised tool: '%s'\n",buf);
178 case UNAVAILABLE_TOOL:
179 printf(
"skipping unavailable tool: '%s'\n",buf);
181 case ADDITIONAL_INPUT:
182 printf(
"skipping additional input source: '%s'\n",buf);
184 case CANNOT_OPEN_FILE:
185 printf(
"skipping input file: '%s'\n",buf);
197 else printf(
"ValidationControl: no valid input source\n");
255 Timer *timer = (*tool)->timer();
257 if(timer) timer->
start();
259 if(timer) timer->
stop();
265 printf(
"--------------------------------------------------------------\n");
266 printf(
" Print event: %s\n",(*tool)->name().c_str());
267 printf(
"--------------------------------------------------------------\n");
269 HEPMC2CODE( hepmc.print(); )
278 for ( GenEvent::particle_const_iterator p = hepmc.particles_begin();
279 p != hepmc.particles_end(); ++p ) {
280 if( (*p)->status() != 1 ) continue;
282 FourVector m = (*p)->momentum();
283 sum.setPx( sum.px() + m.px() );
284 sum.setPy( sum.py() + m.py() );
285 sum.setPz( sum.pz() + m.pz() );
286 sum.setE ( sum.e() + m.e() );
289 double momentum = input_momentum.
px() + input_momentum.
py() + input_momentum.
pz() + input_momentum.
e();
290 if( fabs(momentum) > 10e-12 ) {
291 double px = input_momentum.
px() - sum.
px();
292 double py = input_momentum.
py() - sum.
py();
293 double pz = input_momentum.
pz() - sum.
pz();
294 double e = input_momentum.
e() - sum.
e();
295 delta = sqrt(px*px + py*py + pz*pz + e*e);
301 for (
auto p: hepmc.
particles())
if( p->status() != 1 )
continue;
else sum += p->momentum();
302 if(!input_momentum.
is_zero()) delta = (input_momentum - sum).
length();
305 printf(
"Momentum sum: %+15.8e %+15.8e %+15.8e %+15.8e (evt: %7i, %s)",sum.
px(),sum.
py(),sum.
pz(),sum.
e(),
m_event_counter,(*tool)->name().c_str());
308 else printf(
" - WARNING! Difference = %+15.8e\n",delta);
310 input_momentum = sum;