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 auto vtxIt = ge.vertices().begin();
47 auto vtxEnd = ge.vertices().end();
48 for( ; vtxIt != vtxEnd; ++vtxIt) {
49 // for quick access:
50 const HepMC::FourVector &curPos = (*vtxIt)->position();
51
52 // check if all position values are in range
53 allOK &= std::isfinite( curPos.x() );
54 allOK &= std::isfinite( curPos.y() );
55 allOK &= std::isfinite( curPos.z() );
56 // in case m_checkTime==false --> always return true here:
57 allOK &= std::isfinite( curPos.t() ) || !m_checkTime;
58 }
59
60 if (allOK) {
61 ATH_MSG_DEBUG("All vertices in the given GenEvent are valid.");
62 return StatusCode::SUCCESS;
63 }
64
65 ATH_MSG_ERROR("At least one vertex in the given GenEvent has an invalid position value (NaN or inf).");
66 return StatusCode::FAILURE;
67 }
68
69}
#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
HepMC3::FourVector FourVector
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39