ATLAS Offline Software
Loading...
Searching...
No Matches
TestHepMC.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef XAOD_ANALYSIS
5
7#include "GaudiKernel/DataSvc.h"
8#include "GaudiKernel/SystemOfUnits.h"
11
12// For find
13#include <algorithm>
14
15
16
17TestHepMC::TestHepMC(const std::string& name, ISvcLocator* pSvcLocator)
18 : GenBase(name, pSvcLocator),
19 m_thistSvc("THistSvc", name)
20{
21 declareProperty("MaxLoops", m_maxloops = -1); //< Maximal number of particles allowed in the loops. -1 == any number
22 declareProperty("PdgToSearch", m_pdg = 15); //< @todo This test is a bit weirdly specific to taus
23 declareProperty("CmEnergy", m_cm_energy = -1); // in MeV, -1 = get from event
24 declareProperty("MinTransVtxDisp", m_min_dist_trans = 0.); // mm
25 declareProperty("MaxTransVtxDisp", m_max_dist_trans = 100.); // mm
26 declareProperty("MaxVtxDisp", m_max_dist = 1000.); // mm;
27 declareProperty("EnergyDifference", m_energy_diff = 1000.); // MeV
28 declareProperty("EnergyDifferenceError", m_max_energy_diff = 100000.); // MeV
29 declareProperty("CmeDifference", m_cme_diff = 1.); // MeV
30 declareProperty("DumpEvent", m_dumpEvent = false);
31 declareProperty("MinTau", m_min_tau = 1/300.); // ns; corresponds to 1mm
32 declareProperty("MaxNonG4Energy", m_nonG4_energy_threshold = 100.); //MeV
33 declareProperty("TauEffThreshold", m_tau_eff_threshold = 0.1); // fraction
34 declareProperty("EffWarnThreshold", m_eff_warn_threshold=0.99); // fraction
35 declareProperty("EffFailThreshold", m_eff_fail_threshold=0.98); // fraction
36 declareProperty("AccuracyMargin", m_accur_margin=0.); //MeV
37
38 declareProperty("G4ExtraWhiteFile", m_paramFile = "g4_extrawhite.param" );
39 // a list of allowed pdgid which however might not follow the official rules
40 declareProperty("UnknownPDGIDFile", m_unknownPDGIDFile = "pdgid_extras.txt" );
41
42 declareProperty("NoDecayVertexStatuses", m_vertexStatuses );
43
44 declareProperty("BeamEnergyTest", m_beamEnergyTest = true); //switching off inactive
45 declareProperty("VtxNaNTest", m_vtxNaNTest = true);
46 declareProperty("VtxDisplacedTest", m_vtxDisplacedTest = true);
47 declareProperty("MomNaNTest", m_momNaNTest = true);
48 declareProperty("LifeTimeTest", m_lifeTimeTest = true);
49 declareProperty("EnergyG4Test", m_energyG4Test = true);
50 declareProperty("EnergyImbalanceTest", m_energyImbalanceTest = true);
51 declareProperty("MomImbalanceTest", m_momImbalanceTest = true);
52 declareProperty("NegativeEnergyTest", m_negativeEnergyTest = true);
53 declareProperty("TachyonsTest", m_tachyonsTest = true);
54 declareProperty("UnstableNoVtxTest", m_unstableNoVtxTest = true);
55 declareProperty("Pi0NoVtxTest", m_pi0NoVtxTest = true);
56 declareProperty("UndisplacedDaughtersTest", m_undisplacedDaughtersTest = true);
57 declareProperty("UknownPDGIDTest", m_unknownPDGIDTest = true);
58 declareProperty("AllowMissingCrossSection", m_allowMissingXSec = false);
59
60 m_vertexStatuses.push_back( 1 );
61 m_vertexStatuses.push_back( 3 );
62 m_vertexStatuses.push_back( 4 );
63
64
65 declareProperty("THistSvc", m_thistSvc);
66
67 declareProperty("DoHist", m_doHist=false); //histograming yes/no true/false
68
69 m_nPass = 0;
70 m_nFail = 0;
71
72 m_TotalTaus = 0;
74
75 // Check counters
101 m_noXSECset = 0;
102
118 m_h_photon_mass = 0;
128}
129
130
133 m_gendata = std::make_shared<GenData>();
134
135 if (m_doHist){
136 CHECK(m_thistSvc.retrieve());
137
138 m_h_energy_dispVtxCheck = new TH1F("h_energy_dispVtxCheck", "h_energy_dispVtxCheck", 2000, 0., 2000.);
139 m_h_energy_dispVtxCheck_lt10 = new TH1F("h_energy_dispVtxCheck_lt10", "h_energy_dispVtxCheck_lt10", 1000, 0., 10.);
140 m_h_pdgid_dispVtxCheck = new TH1F("h_pdgid_dispVtxCheck", "h_pdgid_dispVtxCheck", 10000, 0., 10000.);
141 m_h_status_dispVtxCheck = new TH1F("h_status_dispVtxCheck", "h_status_dispVtxCheck", 10000, 0., 10000.);
142 m_h_px_dispVtxCheck = new TH1F("h_px_dispVtxCheck", "h_px_dispVtxCheck", 4000, -2000., 2000.);
143 m_h_py_dispVtxCheck = new TH1F("h_py_dispVtxCheck", "h_py_dispVtxCheck", 4000, -2000., 2000.);
144 m_h_pz_dispVtxCheck = new TH1F("h_pz_dispVtxCheck", "h_pz_dispVtxCheck", 4000, -2000., 2000.);
145 m_h_vx_dispVtxCheck = new TH1F("h_vx_dispVtxCheck", "h_vx_dispVtxCheck", 40000, -200., 200);
146 m_h_vy_dispVtxCheck = new TH1F("h_vy_dispVtxCheck", "h_vy_dispVtxCheck", 40000, -200., 200);
147 m_h_vz_dispVtxCheck = new TH1F("h_vz_dispVtxCheck", "h_vz_dispVtxCheck", 40000, -200., 200);
148 m_h_vxprod_dispVtxCheck = new TH1F("h_vxprod_dispVtxCheck", "h_vxprod_dispVtxCheck", 40000, -200., 200.);
149 m_h_vyprod_dispVtxCheck = new TH1F("h_vyprod_dispVtxCheck", "h_vyprod_dispVtxCheck", 40000, -200., 200.);
150 m_h_vzprod_dispVtxCheck = new TH1F("h_vzprod_dispVtxCheck", "h_vzprod_dispVtxCheck", 40000, -200., 200.);
151 m_h_vtxprod_dispVtxCheck = new TH1F("h_vtxprod_dispVtxCheck", "h_vtxprod_dispVtxCheck", 20000, 0., 200.);
152 m_h_vtxend_dispVtxCheck = new TH1F("h_vtxend_dispVtxCheck", "h_vtxend_dispVtxCheck", 20000, 0., 200.);
153 m_h_photon_mass = new TH1F("h_photon_mass", "h_photon_mass", 20000, -10000., 10000);
154 m_h_photon_energy = new TH1F("h_photon_energy", "h_photon_energy", 20000, -10000., 10000);
155 m_h_photon_e2_p2_e2 = new TH1F("h_photon_e2_p2_e2", "h_photon_e2_p2_e2", 20000, -10., 10);
156 m_h_energyImbalance = new TH1F("h_energyImbalance", "h_energyImbalance", 2000, 0., 2000.);
157 m_h_momentumImbalance_px = new TH1F("h_momentumImbalance_px", "h_momentumImbalance_px", 2000,0., 2000.);
158 m_h_momentumImbalance_py = new TH1F("h_momentumImbalance_py", "h_momentumImbalance_py", 2000,0., 2000.);
159 m_h_momentumImbalance_pz = new TH1F("h_momentumImbalance_pz", "h_momentumImbalance_pz", 2000,0., 2000.);
160 m_h_beamparticle1_Energy = new TH1F("h_beamparticle1_Energy", "h_beamparticle1_Energy", 14000,0., 14000.);
161 m_h_beamparticle2_Energy = new TH1F("h_beamparticle2_Energy", "h_beamparticle2_Energy", 14000,0., 14000.);
162 m_h_cmEnergyDiff = new TH1F("h_cmEnergyDiff", "h_cmEnergyDiff", 8000, -4000., 4000.);
163
164 CHECK(m_thistSvc->regHist("/TestHepMCname/h_energy_dispVtxCheck", m_h_energy_dispVtxCheck));
165 CHECK(m_thistSvc->regHist("/TestHepMCname/h_energy_dispVtxCheck_lt10", m_h_energy_dispVtxCheck_lt10));
166 CHECK(m_thistSvc->regHist("/TestHepMCname/h_pdgid_dispVtxCheck", m_h_pdgid_dispVtxCheck));
167 CHECK(m_thistSvc->regHist("/TestHepMCname/h_status_dispVtxCheck", m_h_status_dispVtxCheck));
168 CHECK(m_thistSvc->regHist("/TestHepMCname/h_px_dispVtxCheck", m_h_px_dispVtxCheck));
169 CHECK(m_thistSvc->regHist("/TestHepMCname/h_py_dispVtxCheck", m_h_py_dispVtxCheck));
170 CHECK(m_thistSvc->regHist("/TestHepMCname/h_pz_dispVtxCheck", m_h_pz_dispVtxCheck));
171 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vx_dispVtxCheck", m_h_vx_dispVtxCheck));
172 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vy_dispVtxCheck", m_h_vy_dispVtxCheck));
173 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vz_dispVtxCheck", m_h_vz_dispVtxCheck));
174 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vxprod_dispVtxCheck", m_h_vxprod_dispVtxCheck));
175 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vyprod_dispVtxCheck", m_h_vyprod_dispVtxCheck));
176 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vzprod_dispVtxCheck", m_h_vzprod_dispVtxCheck));
177 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vtxprod_dispVtxCheck", m_h_vtxprod_dispVtxCheck));
178 CHECK(m_thistSvc->regHist("/TestHepMCname/h_vtxend_dispVtxCheck", m_h_vtxend_dispVtxCheck));
179 CHECK(m_thistSvc->regHist("/TestHepMCname/h_photon_mass", m_h_photon_mass));
180 CHECK(m_thistSvc->regHist("/TestHepMCname/h_photon_energy", m_h_photon_energy));
181 CHECK(m_thistSvc->regHist("/TestHepMCname/h_photon_e2_p2_e2", m_h_photon_e2_p2_e2));
182 CHECK(m_thistSvc->regHist("/TestHepMCname/h_energyImbalance", m_h_energyImbalance));
183 CHECK(m_thistSvc->regHist("/TestHepMCname/h_momentumImbalance_px", m_h_momentumImbalance_px));
184 CHECK(m_thistSvc->regHist("/TestHepMCname/h_momentumImbalance_py", m_h_momentumImbalance_py));
185 CHECK(m_thistSvc->regHist("/TestHepMCname/h_momentumImbalance_pz", m_h_momentumImbalance_pz));
186 CHECK(m_thistSvc->regHist("/TestHepMCname/h_beamparticle1_Energy", m_h_beamparticle1_Energy));
187 CHECK(m_thistSvc->regHist("/TestHepMCname/h_beamparticle2_Energy", m_h_beamparticle2_Energy));
188 CHECK(m_thistSvc->regHist("/TestHepMCname/h_cmEnergyDiff", m_h_cmEnergyDiff));
189
190 ATH_MSG_INFO("No decay vertex - is ignored for particles with status (list):" );
191 for ( unsigned int i = 0; i < m_vertexStatuses.size(); i++ ) ATH_MSG_INFO(" : " << m_vertexStatuses.at(i) );
192 ATH_MSG_INFO("Vertex statuses finished");
193
194 } // End of histogramming setup
195
196 // open the files and read G4particle_acceptlist.txt
197
198 const std::string& fileLocation = PathResolverFindDataFile ( "G4particle_acceptlist.txt" );
199 std::ifstream G4file;
200 G4file.open(fileLocation);
201 std::string line;
202 int G4pdgID;
203 if (!G4file.fail()){
204 while(std::getline(G4file,line)){
205 std::stringstream ss(line);
206 ss >> G4pdgID;
207 m_G4pdgID_tab.push_back(G4pdgID);
208 }
209 G4file.close();
210 }
211 else {
212 ATH_MSG_WARNING("Failed to open G4particle_acceptlist.txt, checking that all particles are known by Genat4 cannot be performed");
213 }
214
215 // Open the param file (G4 accept list)
216 G4file.open(m_paramFile.c_str());
217 if (!G4file.fail()){
218 ATH_MSG_INFO("extra accept list for G4 found " << m_paramFile.c_str());
219 while(std::getline(G4file,line)){
220 std::stringstream ss(line);
221 ss >> G4pdgID;
222 m_G4pdgID_tab.push_back(G4pdgID);
223 }
224 G4file.close();
225 }
226 else {
227 ATH_MSG_INFO("extra accept list for G4 not provided ");
228 }
229
230 // Open the files and read susyParticlePdgid.txt
231 std::ifstream susyFile;
232 susyFile.open("susyParticlePdgid.txt");
233 int susyPdgID;
234 if (!susyFile.fail()){
235 while(getline(susyFile,line)){
236 std::stringstream ss1(line);
237 ss1 >> susyPdgID;
238 m_SusyPdgID_tab.push_back(susyPdgID);
239 }
240 susyFile.close();
241 }
242 else{
243 ATH_MSG_WARNING("Failed to open susyParticlePdgid.txt, listing particles not present in PDTTable");
244 }
245
246 // Open the file of extra PDG IDs that don't need to obey the rules
247 std::ifstream pdgFile;
248 pdgFile.open(m_unknownPDGIDFile.c_str());
249 int pdgID;
250 if (!pdgFile.fail()){
251 ATH_MSG_INFO("extra accept list for PDG IDs found " << m_unknownPDGIDFile.c_str());
252 while(std::getline(pdgFile,line)){
253 std::stringstream ss(line);
254 ss >> pdgID;
255 m_uknownPDGID_tab.push_back(pdgID);
256 }
257 pdgFile.close();
258 }
259 else {
260 ATH_MSG_INFO("extra accept list for PDG IDs not provided");
261 }
262
263 // Print Efficiency warning and error thresholds
264 ATH_MSG_INFO("EffWarnThreshold = " << m_eff_warn_threshold * 100 << " %");
265 ATH_MSG_INFO("EffFailThreshold = " << m_eff_fail_threshold * 100 << " %");
266
267 return StatusCode::SUCCESS;
268}
269
270
271StatusCode TestHepMC::execute(const EventContext& ctx) {
272
273 // Holder for filter outcome; allows us to check all filters on each event and diagnose multiple problems at once
274 bool filter_pass = true;
275
276 // Loop over all events in McEventCollection
277 for(const HepMC::GenEvent* evt : *events_const(ctx)) {
278 double totalPx = 0;
279 double totalPy = 0;
280 double totalPz = 0;
281 double totalE = 0;
282 double nonG4_energy = 0;
283 std::vector<HepMC::ConstGenParticlePtr> negEnPart;
284 std::vector<HepMC::ConstGenParticlePtr> tachyons;
285 std::vector<HepMC::ConstGenParticlePtr> unstNoEnd;
286 std::vector<HepMC::ConstGenParticlePtr> unDecPi0;
287 std::vector<HepMC::ConstGenParticlePtr> undisplaceds;
288
289 m_looper.findLoops(evt,true);
290 if (!m_looper.loop_particles().empty() || !m_looper.loop_vertices().empty()) {
291 ATH_MSG_DEBUG("Found " << m_looper.loop_vertices().size() << " vertices in loops");
292 ATH_MSG_DEBUG("Found " << m_looper.loop_particles().size() << " particles in loops");
293 ATH_MSG_DEBUG("Please use MC::Loops::findLoops for this event to obtain all particles and vertices in the loops");
294 if (m_maxloops > 0 && m_looper.loop_particles().size() > static_cast<std::size_t>(m_maxloops) ) filter_pass = false;
295 }
296
297 const auto xsec = evt->cross_section();
298 if (!xsec) {
299 ATH_MSG_WARNING("WATCH OUT: event is missing the generator cross-section!");
300 ++m_noXSECset;
301 if (m_allowMissingXSec) {
302 ATH_MSG_WARNING("-> Adding a dummy cross-section for debugging purposes.");
303 // for debugging purposes only -> set a dummy cross-section to make TestHepMC happy
304 std::shared_ptr<HepMC3::GenCrossSection> dummy_xsec = std::make_shared<HepMC3::GenCrossSection>();
305 dummy_xsec->set_cross_section(1.0,0.0);
306 HepMC::GenEvent* evt_nonconst = const_cast<HepMC::GenEvent*>(evt);
307 evt_nonconst->set_cross_section(std::move(dummy_xsec));
308 }
309 else {
310 ATH_MSG_WARNING("-> Will report this as failure.");
311 }
312 }
313
314 // Check beams and work out per-event beam energy
315 std::vector<std::shared_ptr<const HepMC3::GenParticle>> beams_t;
316 for (auto p : evt->beams()) { if (p->status() == 4) beams_t.push_back(std::move(p)); }
317 std::pair<std::shared_ptr<const HepMC3::GenParticle>,std::shared_ptr<const HepMC3::GenParticle>> beams;
318 if (beams_t.size() == 2) {
319 beams.first=beams_t.at(0);
320 beams.second=beams_t.at(1);
321 } else {
322 ATH_MSG_WARNING("Invalid number of beam particles " << beams_t.size() << " this generator interface should be fixed");
324 for (const auto& part: beams_t) HepMC3::Print::line(part);
325 }
326 double cmenergy = m_cm_energy;
327 if (!HepMC::valid_beam_particles(evt)) {
328 ATH_MSG_WARNING("Invalid beam particle pointers -- this generator interface should be fixed");
329 if (cmenergy < 0) ATH_MSG_WARNING("Invalid expected beam energy: " << cmenergy << " MeV");
331 } else {
332 if (!MC::isBeam(beams.first) || !MC::isBeam(beams.second)) {
333 ATH_MSG_WARNING("Beam particles have incorrectly set status -- this generator interface should be fixed");
335 }
336 const double sumE = beams.first->momentum().e() + beams.second->momentum().e();
337 const double sumP = beams.first->momentum().pz() + beams.second->momentum().pz();
338 cmenergy = std::sqrt(sumE*sumE - sumP*sumP);
339
340 const int beam1PdgId = beams.first->pdg_id();
341 const int beam2PdgId = beams.second->pdg_id();
342
343 //Correct the CM energy for nuclear beams, since HepMC3 does not do this automatically
344 //Ion-Ion systems (even)
345 if (MC::isNucleus(beam1PdgId) && MC::isNucleus(beam2PdgId)) {
346 const double a1 = MC::baryonNumber(beam1PdgId);
347 const double a2 = MC::baryonNumber(beam2PdgId);
348 cmenergy /= std::sqrt(a1 * a2);
349 }
350 const bool nucleusProton =
351 MC::isNucleus(beam1PdgId) && beam2PdgId == MC::PROTON;
352 const bool protonNucleus =
353 beam1PdgId == MC::PROTON && MC::isNucleus(beam2PdgId);
354
355 if (nucleusProton || protonNucleus) {
356 const int nucleusPdgId = nucleusProton ? beam1PdgId : beam2PdgId;
357 const auto& protonBeam = nucleusProton ? beams.second : beams.first;
358 const double direction = nucleusProton ? -1.0 : 1.0;
359
360 cmenergy =
361 direction * 2.0 * protonBeam->momentum().pz() *
362 std::sqrt(
363 static_cast<double>(MC::numberOfProtons(nucleusPdgId)) /
364 MC::baryonNumber(nucleusPdgId)
365 );
366 }
367
368 if (m_cm_energy > 0 && std::abs(cmenergy - m_cm_energy) > m_cme_diff) {
369 ATH_MSG_FATAL("Beam particles have incorrect energy: " << m_cm_energy/Gaudi::Units::GeV << " GeV expected, vs. " << cmenergy/Gaudi::Units::GeV << " GeV found");
370 setFilterPassed(false, ctx);
371 if (m_doHist){
372 m_h_beamparticle1_Energy->Fill(beams.first->momentum().e()/Gaudi::Units::GeV);
373 m_h_beamparticle2_Energy->Fill(beams.second->momentum().e()/Gaudi::Units::GeV);
374 m_h_cmEnergyDiff->Fill((cmenergy-m_cm_energy)/Gaudi::Units::GeV);
375 }
377 // Special case: this is so bad that we immediately fail out
378 return StatusCode::FAILURE;
379 }
380 }
381
382 // Check vertices
383 int vtxDisplacedstatuscode12CheckRateCnt=0;
384 int vtxDisplacedstatuscodenot12CheckRateCnt=0;
385 int vtxDisplacedMoreThan_1m_CheckRateCnt=0;
386 for (const auto& vtx: evt->vertices()) {
387 const HepMC::FourVector pos = vtx->position();
388
389 // Check for NaNs and infs in vertex position components
390 if ( std::isnan(pos.x()) || std::isinf(pos.x()) ||
391 std::isnan(pos.y()) || std::isinf(pos.y()) ||
392 std::isnan(pos.z()) || std::isinf(pos.z()) ) {
393 ATH_MSG_WARNING("NaN (Not A Number) or inf found in the event record vertex positions");
394
396 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
397 if (m_vtxNaNTest) {
398 filter_pass = false;
399 }
400 } // Done of checking for nans and infinities
401
402 // Check for too-far-displaced vertices
403 // Anything which propagates macroscopically should be set stable in evgen for G4 to handle
404 const double dist_trans2 = pos.x()*pos.x() + pos.y()*pos.y(); // in mm2
405 const double dist2 = dist_trans2 + pos.z()*pos.z(); // in mm2
406 const double dist_trans = std::sqrt(dist_trans2); // in mm
407 const double dist = std::sqrt(dist2); // in mm
408 if (dist2 > m_max_dist*m_max_dist) {
409 ATH_MSG_WARNING("Found vertex position displaced by more than " << m_max_dist << "mm: " << dist << "mm");
410 ++vtxDisplacedMoreThan_1m_CheckRateCnt;
411
412 if (m_vtxDisplacedTest) {
413 filter_pass = false;
414 }
415 }
416 if (dist_trans2 < m_min_dist_trans*m_min_dist_trans) {
417 ATH_MSG_WARNING("Found vertex position displaced by less than " << m_min_dist_trans
418 << "mm in transverse distance: " << dist_trans << "mm");
419
420 for (const auto& part: vtx->particles_in()) {
421 if (m_dumpEvent){
422 ATH_MSG_WARNING("Incoming particle : ");
423 HepMC::Print::line(msg( MSG::WARNING ).stream(), part);
424 }
425 }
426
427 if (m_vtxDisplacedTest) {
428 filter_pass = false;
429 }
430 }
431
432 if (dist_trans2 > m_max_dist_trans*m_max_dist_trans) {
433 ATH_MSG_WARNING("Found vertex position displaced by more than " << m_max_dist_trans << "mm in transverse distance: " << dist_trans << "mm");
434
435 for (const auto& part: vtx->particles_in()) {
436 if (m_dumpEvent){
437 ATH_MSG_WARNING("Outgoing particle : ");
438 HepMC::Print::line(msg( MSG::WARNING ).stream(),part);
439 }
440 ATH_MSG_WARNING("production vertex = " << part->production_vertex()->position().x() << ", " << part->production_vertex()->position().y() << ", " << part->production_vertex()->position().z());
441 ATH_MSG_WARNING("end vertex = " << part->end_vertex()->position().x() << ", " << part->end_vertex()->position().y() << ", " << part->end_vertex()->position().z());
442 if (m_dumpEvent) ATH_MSG_WARNING("parents info: ");
443 if (part->production_vertex()) {
444 for(const auto& p_parents: part->production_vertex()->particles_in()) {
445 if (m_dumpEvent){
446 msg(MSG::WARNING) << "\t";
447 HepMC::Print::line( msg( MSG::WARNING ).stream() , p_parents );
448 }
449 }
450 } // Done with fancy print
451
452 if (part->status() == 1 || part->status() == 2){
453 vtxDisplacedstatuscode12CheckRateCnt += 1;
454 } else {
455 vtxDisplacedstatuscodenot12CheckRateCnt += 1;
456 }
457
458 if (m_doHist){
459 m_h_energy_dispVtxCheck->Fill(part->momentum().e()/Gaudi::Units::GeV);
460 if (part->momentum().e()/Gaudi::Units::GeV < 10.) {
461 m_h_energy_dispVtxCheck_lt10->Fill(part->momentum().e()/Gaudi::Units::GeV);
462 }
463 m_h_pdgid_dispVtxCheck->Fill(part->pdg_id());
464 m_h_status_dispVtxCheck->Fill(part->status());
465 m_h_px_dispVtxCheck->Fill(part->momentum().px()/Gaudi::Units::GeV);
466 m_h_py_dispVtxCheck->Fill(part->momentum().py()/Gaudi::Units::GeV);
467 m_h_pz_dispVtxCheck->Fill(part->momentum().pz()/Gaudi::Units::GeV);
468 m_h_vx_dispVtxCheck->Fill(part->end_vertex()->position().x());
469 m_h_vy_dispVtxCheck->Fill(part->end_vertex()->position().y());
470 m_h_vz_dispVtxCheck->Fill(part->end_vertex()->position().z());
471 m_h_vxprod_dispVtxCheck->Fill(part->production_vertex()->position().x());
472 m_h_vyprod_dispVtxCheck->Fill(part->production_vertex()->position().y());
473 m_h_vzprod_dispVtxCheck->Fill(part->production_vertex()->position().z());
474 double endvx = part->end_vertex()->position().x();
475 double endvy = part->end_vertex()->position().y();
476 double endvz = part->end_vertex()->position().z();
477 double prodvx = part->production_vertex()->position().x();
478 double prodvy = part->production_vertex()->position().y();
479 double prodvz = part->production_vertex()->position().z();
480 double enddis = std::sqrt(endvx*endvx + endvy*endvy + endvz*endvz);
481 double proddis = std::sqrt(prodvx*prodvx + prodvy*prodvy + prodvz*prodvz);
482 m_h_vtxend_dispVtxCheck->Fill(enddis);
483 m_h_vtxprod_dispVtxCheck->Fill(proddis);
484 } // End of the filling of histograms for bad vertices
485 } // End of a loop over theparents of the bad vertex
486 } // Found a bad vertex
487 } // Loop over all vertices
488 if (vtxDisplacedstatuscode12CheckRateCnt>0) ++m_vtxDisplacedstatuscode12CheckRate;
489 if (vtxDisplacedstatuscodenot12CheckRateCnt>0) ++m_vtxDisplacedstatuscodenot12CheckRate;
490 if (vtxDisplacedMoreThan_1m_CheckRateCnt>0) ++m_vtxDisplacedMoreThan_1m_CheckRate;
491
492 // Check particles
493 for (auto pitr: *evt) {
494
495 // Local loop variables to clean up the check code
496 const HepMC::FourVector pmom = pitr->momentum();
497 const int pstatus = pitr->status();
498 const int ppdgid = pitr->pdg_id();
499 // Check for NaNs and infs in momentum components
500 if ( std::isnan(pmom.px()) || std::isinf(pmom.px()) ||
501 std::isnan(pmom.py()) || std::isinf(pmom.py()) ||
502 std::isnan(pmom.pz()) || std::isinf(pmom.pz()) ||
503 std::isnan(pmom.e()) || std::isinf(pmom.e()) ) {
504 ATH_MSG_WARNING("NaN (Not A Number) or inf found in the event record momenta");
506
507 if (m_dumpEvent) HepMC::Print::line(std::cout,pitr);
508 if (m_momNaNTest) {
509 filter_pass = false;
510 }
511 } // End of check for NaNs and infinities
512
513 // Check for undecayed pi0s
514 if (MC::isStable(pstatus) || MC::isDecayed(pstatus)) {
515 if (ppdgid == 111 && !pitr->end_vertex() ) {
516 unDecPi0.push_back( pitr);
518 }
519 } // End of check for undecayed pi0s
520
521 //check stable particle lifetimes
522 if (MC::isStable(pstatus)) {
523 const auto plifetime = m_gendata->particleLifetime(ppdgid);
524 if (plifetime) {
525 double lifetime = plifetime.value()*1e+12; // why lifetime doesn't come in common units???
526 if (lifetime != 0 && lifetime < m_min_tau) { // particles with infinite lifetime get a 0 in the PDT
527 ATH_MSG_WARNING("Stable particle found with lifetime = " << lifetime << "~ns!!");
528 if (m_dumpEvent) HepMC::Print::line(std::cout,pitr);
529
531
532 if (m_lifeTimeTest) {
533 filter_pass = false;
534 }
535 } // Particle did not have infinite lifetime
536 } // The particle has a data table (so a lifetime)
537 else{
538 int susyPart = 0;
539 std::vector<int>::size_type count = 0;
540 while (susyPart==0 && (count < m_SusyPdgID_tab.size() )){
541 // no warning for SUSY particles from the list susyParticlePdgid.txt
542 if (m_SusyPdgID_tab[count] == std::abs(ppdgid)) {
543 susyPart=1;
544 }
545 count++;
546 } // Look through the SUSY table to see if this one should be counted
547 if (susyPart==0){
548 ATH_MSG_WARNING("Stable particle not found in PDT, no lifetime check done");
549 if (m_dumpEvent) HepMC::Print::line(std::cout,pitr);
550 } // It's a SUSY particle -- skip the lifetime check
551 } // The particle has no data table
552 } // Test if the particle is stable
553
554 //Check that stable particles are known by G4 or they are non-interacting
555 const MC::DecodedPID decodedPID(ppdgid);
556 const int first_dig = decodedPID(0);
557
558 if (MC::isStable(pstatus) && (!pitr->end_vertex()) && (MC::isSimInteracting(pitr)) && (!MC::isNucleus(ppdgid)) && (first_dig != 9) ) {
559
560 int known_byG4 = 0;
561 std::vector<int>::size_type count =0;
562
563 while (known_byG4==0 && count < m_G4pdgID_tab.size()){
564 if(ppdgid == m_G4pdgID_tab[count]) known_byG4=1;
565 count++;
566 }
567 if(known_byG4==0){
568 nonG4_energy += pmom.e();
569 ATH_MSG_WARNING("Interacting particle not known by Geant4 with ID " << ppdgid);
570 }
571 } // End of check that stable particles are known to G4 or are non-interacting
572
573 // Check for bad PDG IDs
574 if (!MC::isValid(ppdgid)){
575 ATH_MSG_DEBUG("Invalid PDG ID found: " << ppdgid);
576 if (m_unknownPDGIDTest && std::find(m_uknownPDGID_tab.begin(),m_uknownPDGID_tab.end(),ppdgid)==m_uknownPDGID_tab.end()){
577 ATH_MSG_WARNING("Invalid and unmasked PDG ID found: " << ppdgid);
578 filter_pass = false;
580 }
581 } // End of check for invalid PDG IDs
582
583 // Check for unstables with no end vertex,
584 if (!pitr->end_vertex() && MC::isDecayed(pstatus)) {
585 unstNoEnd.push_back(pitr);
587 } // End of check for unstable with no end vertex
588
589 // Sum final state mom/energy, and note negative energy / tachyonic particles
590 // std::cout << "status " << pstatus << " e " << pmom.e() << " pz " << pmom.pz()<< std::endl;
591 if ( MC::isStable(pstatus) && !pitr->end_vertex() ) {
592 totalPx += pmom.px();
593 totalPy += pmom.py();
594 totalPz += pmom.pz();
595 totalE += pmom.e();
596 if (pmom.e() < 0) {
597 negEnPart.push_back(pitr);
599 }
600 const double aener = std::abs(pmom.e());
601 if ( aener+m_accur_margin < std::abs(pmom.px()) || aener+m_accur_margin < std::abs(pmom.py()) || aener+m_accur_margin < std::abs(pmom.pz()) ) {
602 tachyons.push_back(pitr);
604 }
605 } // End of sums for momentum and energy conservation
606
607 // Decay checks (uses PdgToSearch attr value, for tau by default)
609 int tau_child = 0;
610 if (std::abs(ppdgid) == m_pdg && (MC::isStable(pstatus) || MC::isDecayed(pstatus))) {
611 ++m_TotalTaus;
612 auto vtx = pitr->end_vertex();
613 if (vtx) {
614 double p_energy = 0;
615 for (auto desc: HepMC::descendant_particles(vtx)) {
616 if (std::abs(desc->pdg_id()) == m_pdg) tau_child = 1;
617 if ( MC::isStable(desc) ) p_energy += desc->momentum().e();
618 }
619 if (std::abs( p_energy - pmom.e()) > m_energy_diff && !tau_child) {
620 ATH_MSG_WARNING("Energy sum (decay products): "
621 << "Energy (original particle) > " << m_energy_diff << " MeV, "
622 << "Event #" << evt->event_number() << ", "
623 << "The original particle = " << pitr);
625 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
626 }
627 //most taus should not decay immediately
628 const HepMC::FourVector tau_decaypos = vtx->position();
629 const double tau_displacement = tau_decaypos.x()*tau_decaypos.x() + tau_decaypos.y()*tau_decaypos.y() + tau_decaypos.z()*tau_decaypos.z();
630 //tau_child != 1 exclude cases in which a tau is copied to another vertex or emits a photon
631 if ((tau_displacement < 1.e-6) && (tau_child!=1)) ++m_FastDecayedTau;
632 } else {
633 ATH_MSG_WARNING("UNDECAYED PARTICLE WITH PDG_ID = " << m_pdg);
635 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
636 }
637 } // End of checks for specific particle (tau by default)
638
639 // Check for undisplaced decay daughters from long-lived hadrons
640 if (pitr->end_vertex()) {
641 auto decayvtx = pitr->end_vertex();
642 const HepMC::FourVector decaypos = decayvtx->position();
643 const double displacement = decaypos.x()*decaypos.x() + decaypos.y()*decaypos.y() + decaypos.z()*decaypos.z();
644 if (displacement > 1e-6) {
645 for (auto ip: *decayvtx) {
646 const HepMC::FourVector pos2 = ip->production_vertex()->position();
647 const double displacement2 = pos2.x()*pos2.x() + pos2.y()*pos2.y() + pos2.z()*pos2.z();
648 if (displacement2 < 1e-6) {
649 ATH_MSG_WARNING("Decay child " << ip << " from " << pitr
650 << " has undisplaced vertex (" << ip->production_vertex()
651 << " @ " << displacement2 << "mm) "
652 << " but parent vertex is displaced (" << decayvtx
653 << " @ " << displacement << "mm)");
654 undisplaceds.push_back(std::move(ip));
656 } // Check for displacement below 1 um
657 } // Loop over all particles coming from the decay vertex
658 } // Displacement of greater than 1 um
659 } // End of check for undisplaced decay daughters from long-lived hadrons
660
661 // Check for photons with non-zero masses
663 if (MC::isPhoton(ppdgid) && MC::isStable(pstatus)) {
664 const double mass = pitr->generated_mass();
665 if (std::abs(mass) > 1.0) { // in MeV
666 ATH_MSG_WARNING("Photon with non-zero mass found! Mass: " << mass << " MeV" << pitr);
668 }
669 } // End check for photons with too-large a mass
670
671 } // End of loop over particles in the event
672
673 // Energy of interacting particles not known by Geant4
674 if(nonG4_energy > m_nonG4_energy_threshold) {
675 ATH_MSG_WARNING("The energy of interacting particles not known by Geant4 is = " << nonG4_energy << " MeV");
676 if (m_energyG4Test) {
677 filter_pass = false;
678 }
680 } // End of check for interacting particles not known by G4
681
682 // Energy balance
683 double lostE = std::abs(totalE - cmenergy);
684 if (lostE > m_energy_diff) {
685 ATH_MSG_WARNING("ENERGY BALANCE FAILED : E-difference = " << lostE << " MeV");
686
687 ATH_MSG_WARNING("balance " << totalPx << " " << totalPy << " " << totalPz << " " << totalE);
688
689 if (m_doHist){
690 m_h_energyImbalance->Fill(lostE/Gaudi::Units::GeV);
691 }
692 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
694 filter_pass = false;
695 }
697 } // End of energy balance check
698
699 // Momentum balance
700 if ( std::abs(totalPx) > m_energy_diff || std::abs(totalPy) > m_energy_diff || std::abs(totalPz) > m_energy_diff ) {
701 ATH_MSG_WARNING("MOMENTUM BALANCE FAILED : SumPx = " << totalPx << " SumPy = " << totalPy << " SumPz = " << totalPz << " MeV");
702 if (m_doHist){
703 m_h_momentumImbalance_px->Fill(std::abs(totalPx)/Gaudi::Units::GeV);
704 m_h_momentumImbalance_py->Fill(std::abs(totalPy)/Gaudi::Units::GeV);
705 m_h_momentumImbalance_pz->Fill(std::abs(totalPz)/Gaudi::Units::GeV);
706 }
707 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
708 if (m_momImbalanceTest) {
709 filter_pass = false;
710 }
712 } // End of momentum balance check
713
714 // Negative energy particles
715 if (!negEnPart.empty()) {
716 std::stringstream ss;
717 ss << "NEGATIVE ENERGY PARTICLES FOUND :";
718 for (const auto &b: negEnPart){
719 ss << " " << b;
720 }
721 ATH_MSG_WARNING(ss.str());
722 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
724 filter_pass = false;
725 }
727 } // End of negative energy particle chedk
728
729 // Tachyons
730 if (!tachyons.empty()) {
731 std::stringstream ss;
732 ss << "PARTICLES WITH |E| < |Pi| (i=x,y,z) FOUND :";
733 for (auto b: tachyons){
734 ss << " " << b;
735 }
736 ATH_MSG_WARNING(ss.str());
737 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
738 if (m_tachyonsTest) {
739 filter_pass = false;
740 }
742 } // End of tachyon check
743
744 // Unstable particles with no decay vertex
745 if (!unstNoEnd.empty()) {
746 std::stringstream ss;
747 ss << "Unstable particle with no decay vertex found: ";
748 for (auto b: unstNoEnd){
749 ss << " " << b;
750 }
751 ATH_MSG_WARNING(ss.str());
752 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
754 filter_pass = false;
755 }
757 } // End of unstable particle with no decay vertex check
758
759 // Undecayed pi0
760 if (!unDecPi0.empty()) {
761 std::stringstream ss;
762 ss << "pi0 with no decay vertex found:";
763 for (auto b: unDecPi0){
764 ss << " " << b;
765 }
766 ATH_MSG_WARNING(ss.str());
767 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
768 if (m_pi0NoVtxTest) {
769 filter_pass = false;
770 }
772 } // End of undecayed pi0 check
773
774 // Undisplaced decay daughters of displaced vertices
775 if (!undisplaceds.empty()) {
776 std::stringstream ss{"Undisplaced decay vertices from displaced particle: "};
777 for (HepMC::ConstGenParticlePtr b: undisplaceds){
778 // coverity[COPY_INSTEAD_OF_MOVE]
779 ss << " " << b;
780 }
781 ATH_MSG_WARNING(ss.str());
782 if (m_dumpEvent) HepMC::Print::content(std::cout,*evt);
784 filter_pass = false;
785 }
787 } // End of undisplaced decay daughter of displaced vertices check
788
789 } // End of loop over MCEventCollection
790
791 // End of execution for each event - update filter value
792 if (!filter_pass){
793 setFilterPassed(false, ctx);
794 ++m_nFail;
795 } else {
796 ++m_nPass;
797 }
798
799 // If the efficiency after 100 events is below 10%, there is an important bug going on:
800 // we fail the job immediately so it doesn't run for ever
801 const double tmp_efficiency = double(m_nPass) / double(m_nPass + m_nFail);
802 if ((m_nPass + m_nFail) > 100 && tmp_efficiency < 0.1) {
803 ATH_MSG_FATAL("The efficiency after " << m_nPass + m_nFail << " events is " << tmp_efficiency*100. << "% !!!");
804 return StatusCode::FAILURE;
805 }
806
807 return StatusCode::SUCCESS;
808}
809
810
812
813 ATH_MSG_INFO("Events passed = " << m_nPass << ", Events Failed = " << m_nFail);
814 // Keep a denominator for all the fractions, to ensure we don't get a bunch of nans.
815 // If nothing passed or failed, all the other counters should be zero; this is just avoiding FPEs etc.
816 double denom = m_nPass + m_nFail > 0. ? m_nPass + m_nFail : 1.;
817
818 ATH_MSG_INFO(" Event rate with invalid Beam Particles = " << m_invalidBeamParticlesCheckRate*100.0/denom << "% (not included in test efficiency)");
819 ATH_MSG_INFO(" Event rate with beam particles and status not equal to 4 = " << m_beamParticleswithStatusNotFourCheckRate*100.0/double(m_nPass + m_nFail) << "% (not included in test efficiency)");
820 ATH_MSG_INFO(" Event rate with incorrect beam particle energies = " << m_beamEnergyCheckRate*100.0/denom << "% (not included in test efficiency)");
821 ATH_MSG_INFO(" Configured minimum transverse vertex displacement = " << m_min_dist_trans << "~mm");
822 ATH_MSG_INFO(" Event rate with NaN (Not A Number) or inf found in the event record vertex positions = " << m_vtxNANandINFCheckRate*100.0/denom << "%");
823 if (!m_vtxNaNTest) ATH_MSG_INFO(" The check for NaN or inf in vtx. record is switched off, so is not included in the final TestHepMC efficiency ");
824 ATH_MSG_INFO(" Event rate with vertices displaced more than " << m_max_dist_trans << "~mm in transverse direction for particles with status code other than 1 and 2 = " << m_vtxDisplacedstatuscodenot12CheckRate*100.0/denom << "% (not included in test efficiency)");
825 ATH_MSG_INFO(" Event rate with vertices displaced more than " << m_max_dist << "~mm = " << m_vtxDisplacedMoreThan_1m_CheckRate*100.0/denom << "%");
826 if (!m_vtxDisplacedTest) ATH_MSG_INFO(" The check for displaced vertices is switched off, so is not included in the final TestHepMC efficiency ");
827 ATH_MSG_INFO(" Event rate with NAN (Not A Number) or inf found in particle momentum values = " << m_partMomentumNANandINFCheckRate*100.0/denom << "%");
828 if (!m_momNaNTest) ATH_MSG_INFO(" The check for NaN/inf in momentum record is switched off, so is not included in the final TestHepMC efficiency ");
829 ATH_MSG_INFO(" Event rate with undecayed pi0's with status 1 or 2 = " << m_undecayedPi0statuscode12CheckRate*100.0/denom << "% (not included in test efficiency)");
830 ATH_MSG_INFO(" Event rate with unstable particles with no end vertex = " << m_unstableNoEndVtxCheckRate*100.0/denom << "% (not included in test efficiency)");
831 ATH_MSG_INFO(" Event rate with negative total energy like for tachyonic particles = " << m_negativeEnergyTachyonicCheckRate*100.0/denom << "% (not included in test efficiency)");
832 ATH_MSG_INFO(" Event rate with particles with improper decay properties = " << m_decayCheckRate*100.0/denom << "% (not included in test efficiency)");
833 ATH_MSG_INFO(" Event rate with undisplaced daughters of long lived hadrons = " << m_undisplacedLLHdaughtersCheckRate*100.0/denom << "% (not included in test efficiency)");
834 ATH_MSG_INFO(" Event rate with non zero photon mass = " << m_nonZeroPhotonMassCheckRate*100.0/denom << "% (not included in test efficiency)");
835 ATH_MSG_INFO(" Event rate with no energy balance = " << m_energyBalanceCheckRate*100.0/denom << "%");
836 if (!m_energyImbalanceTest) ATH_MSG_INFO(" The check for energy imbalance is switched off, so is not included in the final TestHepMC efficiency ");
837 ATH_MSG_INFO(" Event rate with no momentum balance = " << m_momentumBalanceCheckRate*100.0/denom << "%");
838 if (!m_momImbalanceTest) ATH_MSG_INFO(" The check for momentum imbalance is switched off, so is not included in the final TestHepMC efficiency ");
839 ATH_MSG_INFO(" Event rate with negative energy particles = " << m_negativeEnergyCheckRate*100.0/denom << "%");
840 if (!m_negativeEnergyTest) ATH_MSG_INFO(" The check for particles with negative energy is switched off, so is not included in the final TestHepMC efficiency ");
841 ATH_MSG_INFO(" Event rate with tachyons = " << m_tachyonCheckRate*100.0/denom << "%");
842 if (!m_tachyonsTest) ATH_MSG_INFO(" The check for tachyons is switched off, so is not included in the final TestHepMC efficiency ");
843 ATH_MSG_INFO(" Event rate with stable or unstable particles with no parents = " << m_stableUnstableNoParentCheckRate*100.0/denom << "%");
844 ATH_MSG_INFO(" Event rate with unstable particle with no decay vertex = " << m_unstablePartNoDecayVtxCheckRate*100.0/denom << "%");
845 if (!m_unstableNoVtxTest) ATH_MSG_INFO(" The check for unstable part. without end vertex is switched off, so is not included in the final TestHepMC efficiency ");
846 ATH_MSG_INFO(" Event rate with undecayed Pi0's = " << m_undecayedPi0CheckRate*100.0/denom << "%");
847 if (!m_pi0NoVtxTest) ATH_MSG_INFO(" The check for undecayed pi0's is switched off, so is not included in the final TestHepMC efficiency ");
848 ATH_MSG_INFO(" Event rate with undisplaced decay daughters of displaced vertices = " << m_undisplacedDecayDaughtersOfDisplacedVtxCheckRate*100.0/denom << "%");
849 if (!m_undisplacedDaughtersTest) ATH_MSG_INFO(" The check for undisplaced daughters is switched off, so is not included in the final TestHepMC efficiency ");
850 ATH_MSG_INFO(" Event rate with particles with status 1 but lifetime < " << m_min_tau << "~ns = " << m_Status1ShortLifetime*100.0/denom << "%");
851 if (!m_lifeTimeTest) ATH_MSG_INFO(" The check for status 1 particles with too short lifetime is switched off, so is not included in the final TestHepMC efficiency ");
852 ATH_MSG_INFO(" Event rate with energy sum of interacting particles non known by Geant4 above " << m_nonG4_energy_threshold << " MeV = " << m_nonG4_energyCheckRate*100.0/denom << "%");
853 if (!m_energyG4Test) ATH_MSG_INFO(" The check for energy not known by G4 is switched off, so is not included in the final TestHepMC efficiency ");
854 ATH_MSG_INFO(" Event rate with unknown PDG IDs = " << m_unknownPDGIDCheckRate*100.0/denom << "%");
855 if (!m_unknownPDGIDTest) ATH_MSG_INFO(" The check for unknown PDG IDs is sitched off, so it is not included in the final TestHepMC efficiency ");
856
857 const double tau_fastDrate = double(m_FastDecayedTau) / double(m_TotalTaus);
858 if(tau_fastDrate > m_tau_eff_threshold){
859 ATH_MSG_FATAL("MORE THAN " << 100.*m_tau_eff_threshold << "% OF TAUS DECAYING IMMEDIATELY! " << m_FastDecayedTau << " found, out of: " << m_TotalTaus);
860 return StatusCode::FAILURE;
861 }
862
863 if (m_noXSECset) {
864 if (m_allowMissingXSec) {
865 ATH_MSG_WARNING(m_noXSECset << " EVENTS WITHOUT CROSS-SECTION!!! Added dummy cross-section instead.");
866 }
867 else {
868 ATH_MSG_FATAL(m_noXSECset << " EVENTS WITHOUT CROSS-SECTION!! Check the setup before production!");
869 return StatusCode::FAILURE;
870 }
871 }
872
873 const double efficiency = double(m_nPass) / double(m_nPass + m_nFail);
874 ATH_MSG_INFO("Efficiency = " << efficiency * 100 << "%");
875
876 // Check efficiency, and fail (to kill production jobs) if the pass rate is too low
878 ATH_MSG_FATAL("EFFICIENCY ABOVE ERROR THRESHOLD! " << 100*efficiency << "% found, but at least: " << 100*m_eff_fail_threshold << "% required");
879 return StatusCode::FAILURE;
880 } else if (efficiency <= m_eff_warn_threshold) {
881 ATH_MSG_WARNING("EFFICIENCY ABOVE WARNING THRESHOLD! " << 100*efficiency << "% found, but at least: " << 100*m_eff_warn_threshold << "% expected");
882 }
883
884 return StatusCode::SUCCESS;
885}
886
887
888#endif
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
ATLAS-specific HepMC functions.
static Double_t ss
std::string PathResolverFindDataFile(const std::string &logical_file_name)
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode initialize() override
Definition GenBase.cxx:17
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenBase.cxx:11
const McEventCollection * events_const(const EventContext &ctx) const
Access the current event's McEventCollection (const).
Definition GenBase.h:93
Implementation of classification functions according to PDG2022.
int m_momentumBalanceCheckRate
Definition TestHepMC.h:81
int m_tachyonCheckRate
Definition TestHepMC.h:83
bool m_energyImbalanceTest
Definition TestHepMC.h:54
double m_cm_energy
Definition TestHepMC.h:46
TH1F * m_h_py_dispVtxCheck
Definition TestHepMC.h:107
int m_nFail
Definition TestHepMC.h:60
int m_stableUnstableNoParentCheckRate
Definition TestHepMC.h:84
int m_nonZeroPhotonMassCheckRate
Definition TestHepMC.h:79
TH1F * m_h_vyprod_dispVtxCheck
Definition TestHepMC.h:113
TH1F * m_h_energyImbalance
Definition TestHepMC.h:122
int m_vtxDisplacedMoreThan_1m_CheckRate
Definition TestHepMC.h:72
ServiceHandle< ITHistSvc > m_thistSvc
Definition TestHepMC.h:100
TH1F * m_h_vz_dispVtxCheck
Definition TestHepMC.h:111
int m_unknownPDGIDCheckRate
Definition TestHepMC.h:90
double m_nonG4_energy_threshold
Definition TestHepMC.h:49
int m_vtxDisplacedstatuscodenot12CheckRate
Definition TestHepMC.h:71
int m_beamParticleswithStatusNotFourCheckRate
Definition TestHepMC.h:67
bool m_dumpEvent
Definition TestHepMC.h:48
TH1F * m_h_beamparticle1_Energy
Definition TestHepMC.h:127
int m_nPass
Definition TestHepMC.h:59
double m_eff_fail_threshold
Definition TestHepMC.h:50
TH1F * m_h_momentumImbalance_py
Definition TestHepMC.h:124
TH1F * m_h_vxprod_dispVtxCheck
Definition TestHepMC.h:112
int m_unstablePartNoDecayVtxCheckRate
Definition TestHepMC.h:85
StatusCode execute(const EventContext &ctx)
Execute method.
std::string m_unknownPDGIDFile
Definition TestHepMC.h:93
double m_min_dist_trans
Definition TestHepMC.h:49
int m_vtxDisplacedstatuscode12CheckRate
Definition TestHepMC.h:70
TH1F * m_h_vx_dispVtxCheck
Definition TestHepMC.h:109
TH1F * m_h_pz_dispVtxCheck
Definition TestHepMC.h:108
double m_max_dist_trans
Definition TestHepMC.h:49
TH1F * m_h_pdgid_dispVtxCheck
Definition TestHepMC.h:104
bool m_doHist
Definition TestHepMC.h:52
int m_maxloops
Definition TestHepMC.h:44
int m_undisplacedLLHdaughtersCheckRate
Definition TestHepMC.h:78
bool m_tachyonsTest
Definition TestHepMC.h:54
std::vector< int > m_vertexStatuses
Definition TestHepMC.h:57
TH1F * m_h_vy_dispVtxCheck
Definition TestHepMC.h:110
StatusCode finalize()
bool m_momImbalanceTest
Definition TestHepMC.h:54
int m_beamEnergyCheckRate
Definition TestHepMC.h:68
TH1F * m_h_photon_mass
Definition TestHepMC.h:118
int m_Status1ShortLifetime
Definition TestHepMC.h:87
double m_eff_warn_threshold
Definition TestHepMC.h:50
int m_noXSECset
Definition TestHepMC.h:61
std::vector< int > m_uknownPDGID_tab
Definition TestHepMC.h:97
bool m_allowMissingXSec
Definition TestHepMC.h:48
double m_tau_eff_threshold
Definition TestHepMC.h:50
int m_undecayedPi0statuscode12CheckRate
Definition TestHepMC.h:74
bool m_undisplacedDaughtersTest
Definition TestHepMC.h:55
bool m_vtxNaNTest
Definition TestHepMC.h:53
int m_unstableNoEndVtxCheckRate
Definition TestHepMC.h:75
double m_energy_diff
Definition TestHepMC.h:47
MC::Loops< HepMC::GenEvent, HepMC::ConstGenParticlePtr, HepMC::ConstGenVertexPtr > m_looper
member to detect loops
Definition TestHepMC.h:131
double m_accur_margin
Definition TestHepMC.h:51
bool m_lifeTimeTest
Definition TestHepMC.h:53
TH1F * m_h_energy_dispVtxCheck_lt10
Definition TestHepMC.h:103
TH1F * m_h_momentumImbalance_pz
Definition TestHepMC.h:125
bool m_negativeEnergyTest
Definition TestHepMC.h:54
TH1F * m_h_vtxprod_dispVtxCheck
Definition TestHepMC.h:116
std::vector< int > m_G4pdgID_tab
Definition TestHepMC.h:95
int m_pdg
Definition TestHepMC.h:45
TH1F * m_h_vzprod_dispVtxCheck
Definition TestHepMC.h:114
int m_partMomentumNANandINFCheckRate
Definition TestHepMC.h:73
bool m_momNaNTest
Definition TestHepMC.h:53
int m_negativeEnergyCheckRate
Definition TestHepMC.h:82
TH1F * m_h_photon_energy
Definition TestHepMC.h:119
int m_undecayedPi0CheckRate
Definition TestHepMC.h:86
TH1F * m_h_energy_dispVtxCheck
Definition TestHepMC.h:102
TH1F * m_h_momentumImbalance_px
Definition TestHepMC.h:123
int m_energyBalanceCheckRate
Definition TestHepMC.h:80
bool m_unknownPDGIDTest
Definition TestHepMC.h:55
int m_TotalTaus
Definition TestHepMC.h:63
bool m_energyG4Test
Definition TestHepMC.h:53
TH1F * m_h_vtxend_dispVtxCheck
Definition TestHepMC.h:115
int m_FastDecayedTau
Definition TestHepMC.h:64
TestHepMC(const std::string &name, ISvcLocator *pSvcLocator)
Definition TestHepMC.cxx:17
TH1F * m_h_beamparticle2_Energy
Definition TestHepMC.h:128
std::shared_ptr< GenData > m_gendata
Definition TestHepMC.h:133
int m_decayCheckRate
Definition TestHepMC.h:77
double m_max_dist
Definition TestHepMC.h:49
double m_min_tau
Definition TestHepMC.h:49
int m_vtxNANandINFCheckRate
Definition TestHepMC.h:69
bool m_vtxDisplacedTest
Definition TestHepMC.h:53
std::vector< int > m_SusyPdgID_tab
Definition TestHepMC.h:96
int m_invalidBeamParticlesCheckRate
Definition TestHepMC.h:66
TH1F * m_h_status_dispVtxCheck
Definition TestHepMC.h:105
bool m_pi0NoVtxTest
Definition TestHepMC.h:55
double m_cme_diff
Definition TestHepMC.h:46
TH1F * m_h_px_dispVtxCheck
Definition TestHepMC.h:106
TH1F * m_h_cmEnergyDiff
Definition TestHepMC.h:129
TH1F * m_h_photon_e2_p2_e2
Definition TestHepMC.h:120
double m_max_energy_diff
Definition TestHepMC.h:47
int m_undisplacedDecayDaughtersOfDisplacedVtxCheckRate
Definition TestHepMC.h:88
bool m_unstableNoVtxTest
Definition TestHepMC.h:54
int m_negativeEnergyTachyonicCheckRate
Definition TestHepMC.h:76
int m_nonG4_energyCheckRate
Definition TestHepMC.h:89
StatusCode initialize()
std::string m_paramFile
Definition TestHepMC.h:92
bool m_beamEnergyTest
Definition TestHepMC.h:53
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
HepMC3::FourVector FourVector
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
bool valid_beam_particles(const GenEvent *e)
Definition GenEvent.h:599
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
int numberOfProtons(const T &p)
bool isPhoton(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
bool isDecayed(const T &p)
Identify if the particle decayed.
bool isBeam(const T &p)
Identify if the particle is beam particle.
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
bool isNucleus(const T &p)
PDG rule 16 Nuclear codes are given as 10-digit numbers ±10LZZZAAAI.
double baryonNumber(const T &p)
static const int PROTON