ATLAS Offline Software
Loading...
Searching...
No Matches
GenEventValidityChecker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// class header include
7
8// HepMC includes
10
11// CLHEP includes
12#include "CLHEP/Geometry/Point3D.h"
13
14namespace Simulation
15{
18 const std::string& n,
19 const IInterface* p )
20 : base_class(t,n,p)
21 {
22 }
23
26 {
27 ATH_MSG_VERBOSE("Initializing ...");
28 ATH_MSG_VERBOSE("Initialize successful");
29 return StatusCode::SUCCESS;
30 }
31
34 {
35 ATH_MSG_VERBOSE("Finalizing ...");
36 ATH_MSG_VERBOSE("Finalize successful");
37 return StatusCode::SUCCESS;
38 }
39
41 StatusCode GenEventValidityChecker::manipulate(HepMC::GenEvent& ge, const EventContext&) const
42 {
43 bool allOK = true;
44
45 // loop over the vertices in the GenEvent
46#ifdef HEPMC3
47 auto vtxIt = ge.vertices().begin();
48 auto vtxEnd = ge.vertices().end();
49#else
50 auto vtxIt = ge.vertices_begin();
51 auto vtxEnd = ge.vertices_end();
52#endif
53 for( ; vtxIt != vtxEnd; ++vtxIt) {
54 // for quick access:
55 const HepMC::FourVector &curPos = (*vtxIt)->position();
56
57 // check if all position values are in range
58 allOK &= std::isfinite( curPos.x() );
59 allOK &= std::isfinite( curPos.y() );
60 allOK &= std::isfinite( curPos.z() );
61 // in case m_checkTime==false --> always return true here:
62 allOK &= std::isfinite( curPos.t() ) || !m_checkTime;
63 }
64
65 if (allOK) {
66 ATH_MSG_DEBUG("All vertices in the given GenEvent are valid.");
67 return StatusCode::SUCCESS;
68 }
69
70 ATH_MSG_ERROR("At least one vertex in the given GenEvent has an invalid position value (NaN or inf).");
71 return StatusCode::FAILURE;
72 }
73
74}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< bool > m_checkTime
check the time dimension value for validity
StatusCode initialize() override final
Athena algtool's Hooks.
GenEventValidityChecker(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
StatusCode finalize() override final
Athena algtool's Hooks.
StatusCode manipulate(HepMC::GenEvent &ge, const EventContext &ctx) const override final
checks the the validity of the given GenEvent