15#include "CLHEP/Vector/LorentzVector.h"
16#include "CLHEP/Units/SystemOfUnits.h"
18#include "CLHEP/Geometry/Point3D.h"
28 return StatusCode::SUCCESS;
35 bool resetProblem(
false);
36 for (
const auto& particle: event) {
38 if (!particle->production_vertex()) {
39 ATH_MSG_ERROR(
"Stable particle without a production vertex!! " << particle);
43 ATH_MSG_ERROR(
"Stable particle with an end vertex!! " << particle);
48 if (!particle->production_vertex()) {
49 ATH_MSG_ERROR(
"Decayed particle without a production vertex!! " << particle);
52 if (!particle->end_vertex()) {
53 ATH_MSG_ERROR(
"Decayed particle without an end vertex!! " << particle);
59 return StatusCode::FAILURE;
62 return StatusCode::SUCCESS;
72 for (
const auto& originalPartIn: origVertex->particles_in())
ATH_MSG_INFO( originalPartIn );
74 for (
const auto& originalPartOut: origVertex->particles_out())
ATH_MSG_INFO( originalPartOut );
79 for (
const auto& resetPartIn: resetVertex->particles_in())
ATH_MSG_INFO( resetPartIn );
81 for (
const auto& resetPartOut: resetVertex->particles_out())
ATH_MSG_INFO( resetPartOut );
89 if (!origVertex && !resetVertex)
return StatusCode::SUCCESS;
90 if (!origVertex || !resetVertex)
return StatusCode::FAILURE;
97 if (origVertex->position() != resetVertex->position()) {
100 ATH_MSG_ERROR(
"vertex position differs! Original: ("<<oP.x()<<
","<<oP.y()<<
","<<oP.z()<<
","<<oP.t()<<
"), Reset: ("<<rP.x()<<
","<<rP.y()<<
","<<rP.z()<<
","<<rP.t()<<
")");
103 if (origVertex->particles_in().size() != resetVertex->particles_in().size() ) {
104 ATH_MSG_ERROR (
"particles_in_size differs! Original: "<<origVertex->particles_in().size()<<
", Reset: "<<resetVertex->particles_in().size());
107 if (origVertex->particles_out().size() != resetVertex->particles_out().size() ) {
108 ATH_MSG_ERROR (
"particles_out_size differs! Original: "<<origVertex->particles_out().size()<<
", Reset: "<<resetVertex->particles_out().size());
111 std::vector<HepMC::ConstGenParticlePtr> OriginalListOfParticlesIn = origVertex->particles_in();
112 std::vector<HepMC::ConstGenParticlePtr> ResetListOfParticlesIn = resetVertex->particles_in();
113 for ( std::vector<HepMC::ConstGenParticlePtr>::iterator originalPartInIter(OriginalListOfParticlesIn.begin()),resetPartInIter(ResetListOfParticlesIn.begin());
114 originalPartInIter != OriginalListOfParticlesIn.end() && resetPartInIter != ResetListOfParticlesIn.end();
115 ++originalPartInIter, ++resetPartInIter
125 std::vector<HepMC::ConstGenParticlePtr> OriginalListOfParticlesOut = origVertex->particles_out();
126 std::vector<HepMC::ConstGenParticlePtr> ResetListOfParticlesOut = resetVertex->particles_out();
128 std::sort(OriginalListOfParticlesOut.begin(), OriginalListOfParticlesOut.end(), [](
auto&
a,
auto& b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
129 std::sort(ResetListOfParticlesOut.begin(), ResetListOfParticlesOut.end(), [](
auto&
a,
auto& b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
131 for ( std::vector<HepMC::ConstGenParticlePtr>::iterator originalPartOutIter(OriginalListOfParticlesOut.begin()), resetPartOutIter(ResetListOfParticlesOut.begin());
132 originalPartOutIter != OriginalListOfParticlesOut.end() && resetPartOutIter != ResetListOfParticlesOut.end();
133 ++originalPartOutIter, ++resetPartOutIter
141 if(!pass) {
return StatusCode::FAILURE; }
142 return StatusCode::SUCCESS;
153 if (
m_momentaLimit<std::abs(origMomenta.px()-resetMomenta.px())) {
156 if (
m_momentaLimit<std::abs(origMomenta.py()-resetMomenta.py())) {
159 if (
m_momentaLimit<std::abs(origMomenta.pz()-resetMomenta.pz())) {
165 if(origMomenta != resetMomenta) {
170 if(!pass) {
return StatusCode::FAILURE; }
171 return StatusCode::SUCCESS;
177 if (!origParticle && !resetParticle)
return StatusCode::SUCCESS;
178 if (!origParticle || !resetParticle)
return StatusCode::FAILURE;
185 if (origParticle->status() != resetParticle->status()) {
186 ATH_MSG_ERROR (
"particle status differs! Original: "<<origParticle->status()<<
", Reset: "<<resetParticle->status());
189 if (origParticle->pdg_id() != resetParticle->pdg_id()) {
190 ATH_MSG_ERROR (
"particle pdg_id differs! Original: "<<origParticle->pdg_id()<<
", Reset: "<<resetParticle->pdg_id());
193 if (
compareMomenta(origParticle->momentum(), resetParticle->momentum()).isFailure()) {
196 ATH_MSG_DEBUG(
"particle momentum differs! Original: ("<<oM.x()<<
","<<oM.y()<<
","<<oM.z()<<
","<<oM.t()<<
"), Reset: ("<<rM.x()<<
","<<rM.y()<<
","<<rM.z()<<
","<<rM.t()<<
")");
199 if(!pass) {
return StatusCode::FAILURE; }
200 return StatusCode::SUCCESS;
210 if (!originalMcEventCollection.
isValid()) {
211 ATH_MSG_ERROR(
"Could not find original McEventCollection called " << originalMcEventCollection.
name() <<
" in store " << originalMcEventCollection.
store() <<
".");
212 return StatusCode::FAILURE;
214 const HepMC::GenEvent& originalEvent(**(originalMcEventCollection->begin()));
217 ATH_MSG_FATAL(
"Problems in original GenEvent - bailing out.");
218 return StatusCode::FAILURE;
222 if (!resetMcEventCollection.
isValid()) {
223 ATH_MSG_ERROR(
"Could not find reset McEventCollection called " << resetMcEventCollection.
name() <<
" in store " << resetMcEventCollection.
store() <<
".");
224 return StatusCode::FAILURE;
226 const HepMC::GenEvent& resetEvent(**(resetMcEventCollection->begin()));
230 return StatusCode::FAILURE;
233 if (originalEvent.event_number() != resetEvent.event_number() ) {
234 ATH_MSG_ERROR (
"event_number differs! Original: "<<originalEvent.event_number()<<
", Reset: "<<resetEvent.event_number());
241 std::vector<HepMC::ConstGenParticlePtr> OriginalBeams = originalEvent.beams();
242 std::vector<HepMC::ConstGenParticlePtr> ResetBeams = resetEvent.beams();
244 for ( std::vector<HepMC::ConstGenParticlePtr>::iterator originalBeamIter(OriginalBeams.begin()), resetBeamIter(ResetBeams.begin());
245 originalBeamIter != OriginalBeams.end() && resetBeamIter != ResetBeams.end();
246 ++originalBeamIter, ++resetBeamIter
252 if (originalEvent.particles().size() != resetEvent.particles().size() ) {
253 ATH_MSG_ERROR (
"particles_size differs! Original: "<<originalEvent.particles().size()<<
", Reset: "<<resetEvent.particles().size());
256 if (originalEvent.vertices().size() != resetEvent.vertices().size() ) {
257 ATH_MSG_ERROR (
"vertices_size differs! Original: "<<originalEvent.vertices().size()<<
", Reset: "<<resetEvent.vertices().size());
262 std::vector<HepMC::ConstGenVertexPtr> OriginalListOfVertices = originalEvent.vertices();
263 std::vector<HepMC::ConstGenVertexPtr> ResetListOfVertices = resetEvent.vertices();
265 for( std::vector<HepMC::ConstGenVertexPtr>::iterator origVertexIter(OriginalListOfVertices.begin()),resetVertexIter(ResetListOfVertices.begin());
266 origVertexIter != OriginalListOfVertices.end() && resetVertexIter != ResetListOfVertices.end();
267 ++origVertexIter, ++resetVertexIter
274 ATH_MSG_INFO(
"Completed Truth reset closure check ..... " );
276 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
ATLAS-specific HepMC functions.
Handle class for reading from StoreGate.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode compareGenVertex(const HepMC::ConstGenVertexPtr &origVertex, const HepMC::ConstGenVertexPtr &resetVertex) const
SG::ReadHandleKey< McEventCollection > m_originalMcEventCollection
virtual StatusCode execute(const EventContext &ctx) const override final
StatusCode compareMomenta(const HepMC::FourVector &origMomenta, const HepMC::FourVector &resetMomenta) const
void printGenVertex(const HepMC::ConstGenVertexPtr &origVertex, const HepMC::ConstGenVertexPtr &resetVertex) const
StatusCode sanityCheck(const HepMC::GenEvent &event) const
virtual StatusCode initialize() override final
Gaudi::Property< bool > m_compareMomenta
StatusCode compareGenParticle(const HepMC::ConstGenParticlePtr &origParticle, const HepMC::ConstGenParticlePtr &resetParticle) const
Gaudi::Property< bool > m_postSimulation
SG::ReadHandleKey< McEventCollection > m_resetMcEventCollection
int signal_process_id(const GenEvent &evt)
HepMC3::FourVector FourVector
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
HepMC3::GenEvent GenEvent
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isDecayed(const T &p)
Identify if the particle decayed.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.