ATLAS Offline Software
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
9 #include "AtlasHepMC/GenEvent.h"
10 
11 // CLHEP includes
12 #include "CLHEP/Geometry/Point3D.h"
13 
14 namespace 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 }
GenEvent.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Simulation::GenEventValidityChecker::initialize
StatusCode initialize() override final
Athena algtool's Hooks.
Definition: GenEventValidityChecker.cxx:25
Simulation::GenEventValidityChecker::m_checkTime
Gaudi::Property< bool > m_checkTime
check the time dimension value for validity
Definition: GenEventValidityChecker.h:35
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Simulation::GenEventValidityChecker::finalize
StatusCode finalize() override final
Athena algtool's Hooks.
Definition: GenEventValidityChecker.cxx:33
Simulation::GenEventValidityChecker::manipulate
StatusCode manipulate(HepMC::GenEvent &ge, const EventContext &ctx) const override final
checks the the validity of the given GenEvent
Definition: GenEventValidityChecker.cxx:41
Simulation::GenEventValidityChecker::GenEventValidityChecker
GenEventValidityChecker(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: GenEventValidityChecker.cxx:17
GenEventValidityChecker.h
Simulation
Definition: BeamEffectsAlg.cxx:21