15 #include "CLHEP/Vector/LorentzVector.h"
16 #include "CLHEP/Units/SystemOfUnits.h"
18 #include "CLHEP/Geometry/Point3D.h"
38 return StatusCode::SUCCESS;
45 bool resetProblem(
false);
48 if (!
particle->production_vertex()) {
58 if (!
particle->production_vertex()) {
69 return StatusCode::FAILURE;
72 return StatusCode::SUCCESS;
83 for (
const auto& originalPartIn: origVertex->particles_in())
ATH_MSG_INFO( originalPartIn );
85 for (
const auto& originalPartOut: origVertex->particles_out())
ATH_MSG_INFO( originalPartOut );
90 for (
const auto& resetPartIn: resetVertex->particles_in())
ATH_MSG_INFO( resetPartIn );
92 for (
const auto& resetPartOut: resetVertex->particles_out())
ATH_MSG_INFO( resetPartOut );
99 const HepMC::GenVertex& resetVertex)
const
105 HepMC::GenVertex::particles_in_const_iterator originalPartInIter(origVertex.particles_in_const_begin());
106 const HepMC::GenVertex::particles_in_const_iterator endOfOriginalListOfParticlesIn(origVertex.particles_in_const_end());
107 while( originalPartInIter!=endOfOriginalListOfParticlesIn ) {
109 ++originalPartInIter;
112 HepMC::GenVertex::particles_out_const_iterator originalPartOutIter(origVertex.particles_out_const_begin());
113 const HepMC::GenVertex::particles_out_const_iterator endOfOriginalListOfParticlesOut(origVertex.particles_out_const_end());
114 while( originalPartOutIter!=endOfOriginalListOfParticlesOut) {
116 ++originalPartOutIter;
122 HepMC::GenVertex::particles_in_const_iterator resetPartInIter(resetVertex.particles_in_const_begin());
123 const HepMC::GenVertex::particles_in_const_iterator endOfResetListOfParticlesIn(resetVertex.particles_in_const_end());
124 while( resetPartInIter!=endOfResetListOfParticlesIn ) {
129 HepMC::GenVertex::particles_out_const_iterator resetPartOutIter(resetVertex.particles_out_const_begin());
130 const HepMC::GenVertex::particles_out_const_iterator endOfResetListOfParticlesOut(resetVertex.particles_out_const_end());
131 while( resetPartOutIter!=endOfResetListOfParticlesOut) {
144 if (!origVertex && !resetVertex)
return StatusCode::SUCCESS;
145 if (!origVertex || !resetVertex)
return StatusCode::FAILURE;
152 if (origVertex->position() != resetVertex->position()) {
153 const HepMC::FourVector& oP = origVertex->position();
154 const HepMC::FourVector& rP = resetVertex->position();
155 ATH_MSG_ERROR(
"vertex position differs! Original: ("<<oP.x()<<
","<<oP.y()<<
","<<oP.z()<<
","<<oP.t()<<
"), Reset: ("<<rP.x()<<
","<<rP.y()<<
","<<rP.z()<<
","<<rP.t()<<
")");
158 if (origVertex->particles_in().size() != resetVertex->particles_in().size() ) {
159 ATH_MSG_ERROR (
"particles_in_size differs! Original: "<<origVertex->particles_in().size()<<
", Reset: "<<resetVertex->particles_in().size());
162 if (origVertex->particles_out().size() != resetVertex->particles_out().size() ) {
163 ATH_MSG_ERROR (
"particles_out_size differs! Original: "<<origVertex->particles_out().size()<<
", Reset: "<<resetVertex->particles_out().size());
166 std::vector<HepMC::ConstGenParticlePtr> OriginalListOfParticlesIn = origVertex->particles_in();
167 std::vector<HepMC::ConstGenParticlePtr> ResetListOfParticlesIn = resetVertex->particles_in();
169 originalPartInIter != OriginalListOfParticlesIn.end() && resetPartInIter != ResetListOfParticlesIn.end();
170 ++originalPartInIter, ++resetPartInIter
180 std::vector<HepMC::ConstGenParticlePtr> OriginalListOfParticlesOut = origVertex->particles_out();
181 std::vector<HepMC::ConstGenParticlePtr> ResetListOfParticlesOut = resetVertex->particles_out();
183 std::sort(OriginalListOfParticlesOut.begin(), OriginalListOfParticlesOut.end(), [](
auto&
a,
auto&
b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
184 std::sort(ResetListOfParticlesOut.begin(), ResetListOfParticlesOut.end(), [](
auto&
a,
auto&
b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
187 originalPartOutIter != OriginalListOfParticlesOut.end() && resetPartOutIter != ResetListOfParticlesOut.end();
188 ++originalPartOutIter, ++resetPartOutIter
196 if(!pass) {
return StatusCode::FAILURE; }
197 return StatusCode::SUCCESS;
203 const HepMC::GenVertex& resetVertex)
const
211 if (origVertex.position() != resetVertex.position()) {
212 const HepMC::FourVector& oP = origVertex.position();
213 const HepMC::FourVector& rP = resetVertex.position();
214 ATH_MSG_ERROR(
"vertex position differs! Original: ("<<oP.x()<<
","<<oP.y()<<
","<<oP.z()<<
","<<oP.t()<<
"), Reset: ("<<rP.x()<<
","<<rP.y()<<
","<<rP.z()<<
","<<rP.t()<<
")");
217 if (origVertex.particles_in_size() != resetVertex.particles_in_size() ) {
218 ATH_MSG_ERROR (
"particles_in_size differs! Original: "<<origVertex.particles_in_size()<<
", Reset: "<<resetVertex.particles_in_size());
221 if (origVertex.particles_out_size() != resetVertex.particles_out_size() ) {
222 ATH_MSG_ERROR (
"particles_out_size differs! Original: "<<origVertex.particles_out_size()<<
", Reset: "<<resetVertex.particles_out_size());
225 HepMC::GenVertex::particles_in_const_iterator originalPartInIter(origVertex.particles_in_const_begin());
226 const HepMC::GenVertex::particles_in_const_iterator endOfOriginalListOfParticlesIn(origVertex.particles_in_const_end());
227 HepMC::GenVertex::particles_in_const_iterator resetPartInIter(resetVertex.particles_in_const_begin());
228 const HepMC::GenVertex::particles_in_const_iterator endOfResetListOfParticlesIn(resetVertex.particles_in_const_end());
229 while( originalPartInIter!=endOfOriginalListOfParticlesIn &&
230 resetPartInIter!=endOfResetListOfParticlesIn ) {
237 ++originalPartInIter;
240 HepMC::GenVertex::particles_out_const_iterator originalPartOutIter(origVertex.particles_out_const_begin());
241 const HepMC::GenVertex::particles_out_const_iterator endOfOriginalListOfParticlesOut(origVertex.particles_out_const_end());
243 const HepMC::GenVertex::particles_out_const_iterator endOfResetListOfParticlesOut(resetVertex.particles_out_const_end());
244 while( originalPartOutIter!=endOfOriginalListOfParticlesOut) {
246 HepMC::GenVertex::particles_out_const_iterator resetPartOutIter(resetVertex.particles_out_const_begin());
247 HepMC::GenVertex::particles_in_const_iterator matchingResetParticleIter{endOfResetListOfParticlesOut};
248 while(resetPartOutIter!=endOfResetListOfParticlesOut) {
250 matchingResetParticleIter = resetPartOutIter;
255 if (matchingResetParticleIter==endOfResetListOfParticlesOut ||
261 ++originalPartOutIter;
264 if(!pass) {
return StatusCode::FAILURE; }
265 return StatusCode::SUCCESS;
271 const HepMC::FourVector& resetMomenta)
const
275 if (
m_momentaLimit<std::abs(origMomenta.px()-resetMomenta.px())) {
278 if (
m_momentaLimit<std::abs(origMomenta.py()-resetMomenta.py())) {
281 if (
m_momentaLimit<std::abs(origMomenta.pz()-resetMomenta.pz())) {
287 if(origMomenta != resetMomenta) {
292 if(!pass) {
return StatusCode::FAILURE; }
293 return StatusCode::SUCCESS;
300 if (!origParticle && !resetParticle)
return StatusCode::SUCCESS;
301 if (!origParticle || !resetParticle)
return StatusCode::FAILURE;
308 if (origParticle->status() != resetParticle->status()) {
309 ATH_MSG_ERROR (
"particle status differs! Original: "<<origParticle->status()<<
", Reset: "<<resetParticle->status());
312 if (origParticle->pdg_id() != resetParticle->pdg_id()) {
313 ATH_MSG_ERROR (
"particle pdg_id differs! Original: "<<origParticle->pdg_id()<<
", Reset: "<<resetParticle->pdg_id());
316 if (
compareMomenta(origParticle->momentum(), resetParticle->momentum()).isFailure()) {
317 const HepMC::FourVector& oM = origParticle->momentum();
318 const HepMC::FourVector& rM = resetParticle->momentum();
319 ATH_MSG_DEBUG(
"particle momentum differs! Original: ("<<oM.x()<<
","<<oM.y()<<
","<<oM.z()<<
","<<oM.t()<<
"), Reset: ("<<rM.x()<<
","<<rM.y()<<
","<<rM.z()<<
","<<rM.t()<<
")");
322 if(!pass) {
return StatusCode::FAILURE; }
323 return StatusCode::SUCCESS;
335 if (origParticle.status() != resetParticle.status()) {
336 ATH_MSG_ERROR (
"particle status differs! Original: "<<origParticle.status()<<
", Reset: "<<resetParticle.status());
339 if (origParticle.pdg_id() != resetParticle.pdg_id()) {
340 ATH_MSG_ERROR (
"particle pdg_id differs! Original: "<<origParticle.pdg_id()<<
", Reset: "<<resetParticle.pdg_id());
343 if (
compareMomenta(origParticle.momentum(), resetParticle.momentum()).isFailure()) {
344 const HepMC::FourVector& oM = origParticle.momentum();
345 const HepMC::FourVector& rM = resetParticle.momentum();
346 ATH_MSG_DEBUG(
"particle momentum differs! Original: ("<<oM.x()<<
","<<oM.y()<<
","<<oM.z()<<
","<<oM.t()<<
"), Reset: ("<<rM.x()<<
","<<rM.y()<<
","<<rM.z()<<
","<<rM.t()<<
")");
349 if(!pass) {
return StatusCode::FAILURE; }
350 return StatusCode::SUCCESS;
361 if (!originalMcEventCollection.isValid()) {
362 ATH_MSG_ERROR(
"Could not find original McEventCollection called " << originalMcEventCollection.name() <<
" in store " << originalMcEventCollection.store() <<
".");
363 return StatusCode::FAILURE;
365 const HepMC::GenEvent& originalEvent(**(originalMcEventCollection->begin()));
368 ATH_MSG_FATAL(
"Problems in original GenEvent - bailing out.");
369 return StatusCode::FAILURE;
373 if (!resetMcEventCollection.isValid()) {
374 ATH_MSG_ERROR(
"Could not find reset McEventCollection called " << resetMcEventCollection.name() <<
" in store " << resetMcEventCollection.store() <<
".");
375 return StatusCode::FAILURE;
377 const HepMC::GenEvent& resetEvent(**(resetMcEventCollection->begin()));
381 return StatusCode::FAILURE;
384 if (originalEvent.event_number() != resetEvent.event_number() ) {
385 ATH_MSG_ERROR (
"event_number differs! Original: "<<originalEvent.event_number()<<
", Reset: "<<resetEvent.event_number());
392 std::vector<HepMC::ConstGenParticlePtr> OriginalBeams = originalEvent.beams();
393 std::vector<HepMC::ConstGenParticlePtr> ResetBeams = resetEvent.beams();
396 originalBeamIter != OriginalBeams.end() && resetBeamIter != ResetBeams.end();
397 ++originalBeamIter, ++resetBeamIter
403 if (originalEvent.particles().size() != resetEvent.particles().size() ) {
404 ATH_MSG_ERROR (
"particles_size differs! Original: "<<originalEvent.particles().size()<<
", Reset: "<<resetEvent.particles().size());
407 if (originalEvent.vertices().size() != resetEvent.vertices().size() ) {
408 ATH_MSG_ERROR (
"vertices_size differs! Original: "<<originalEvent.vertices().size()<<
", Reset: "<<resetEvent.vertices().size());
413 std::vector<HepMC::ConstGenVertexPtr> OriginalListOfVertices = originalEvent.vertices();
414 std::vector<HepMC::ConstGenVertexPtr> ResetListOfVertices = resetEvent.vertices();
417 origVertexIter != OriginalListOfVertices.end() && resetVertexIter != ResetListOfVertices.end();
418 ++origVertexIter, ++resetVertexIter
425 ATH_MSG_INFO(
"Completed Truth reset closure check ..... " );
427 return StatusCode::SUCCESS;
440 if (!originalMcEventCollection.
isValid()) {
441 ATH_MSG_ERROR(
"Could not find original McEventCollection called " << originalMcEventCollection.
name() <<
" in store " << originalMcEventCollection.
store() <<
".");
442 return StatusCode::FAILURE;
444 const HepMC::GenEvent& originalEvent(**(originalMcEventCollection->
begin()));
447 ATH_MSG_FATAL(
"Problems in original GenEvent - bailing out.");
448 return StatusCode::FAILURE;
452 if (!resetMcEventCollection.
isValid()) {
453 ATH_MSG_ERROR(
"Could not find reset McEventCollection called " << resetMcEventCollection.
name() <<
" in store " << resetMcEventCollection.
store() <<
".");
454 return StatusCode::FAILURE;
456 const HepMC::GenEvent& resetEvent(**(resetMcEventCollection->
begin()));
460 return StatusCode::FAILURE;
463 if (originalEvent.event_number() != resetEvent.event_number() ) {
464 ATH_MSG_ERROR (
"event_number differs! Original: "<<originalEvent.event_number()<<
", Reset: "<<resetEvent.event_number());
467 if (originalEvent.signal_process_id() != resetEvent.signal_process_id() ) {
468 ATH_MSG_ERROR (
"signal_process_id differs! Original: "<<originalEvent.signal_process_id()<<
", Reset: "<<resetEvent.signal_process_id());
471 if (originalEvent.valid_beam_particles() != resetEvent.valid_beam_particles() ) {
472 ATH_MSG_ERROR (
"valid_beam_particles differs! Original: "<<originalEvent.valid_beam_particles()<<
", Reset: "<<resetEvent.valid_beam_particles());
474 else if (originalEvent.valid_beam_particles() && resetEvent.valid_beam_particles()) {
475 std::pair<HepMC::GenParticle*,HepMC::GenParticle*> originalBP = originalEvent.beam_particles();
476 std::pair<HepMC::GenParticle*,HepMC::GenParticle*> resetBP = resetEvent.beam_particles();
477 if ( ( !originalBP.first && resetBP.first ) ||
478 ( originalBP.first && !resetBP.first ) ||
479 ( originalBP.first && resetBP.first &&
compareGenParticle(*(originalBP.first), *(resetBP.first)).isFailure() ) ) {
482 if ( ( !originalBP.second && resetBP.second ) ||
483 ( originalBP.second && !resetBP.second ) ||
484 ( originalBP.second && resetBP.second &&
compareGenParticle(*(originalBP.second), *(resetBP.second)).isFailure() ) ) {
488 if (originalEvent.particles_size() != resetEvent.particles_size() ) {
489 ATH_MSG_ERROR (
"particles_size differs! Original: "<<originalEvent.particles_size()<<
", Reset: "<<resetEvent.particles_size());
492 if (originalEvent.vertices_size() != resetEvent.vertices_size() ) {
493 ATH_MSG_ERROR (
"vertices_size differs! Original: "<<originalEvent.vertices_size()<<
", Reset: "<<resetEvent.vertices_size());
498 HepMC::GenEvent::vertex_const_iterator origVertexIter(originalEvent.vertices_begin());
499 const HepMC::GenEvent::vertex_const_iterator endOfOriginalListOfVertices(originalEvent.vertices_end());
500 HepMC::GenEvent::vertex_const_iterator resetVertexIter(resetEvent.vertices_begin());
501 const HepMC::GenEvent::vertex_const_iterator endOfResetListOfVertices(resetEvent.vertices_end());
502 while( origVertexIter!=endOfOriginalListOfVertices &&
503 resetVertexIter!=endOfResetListOfVertices) {
511 ATH_MSG_INFO(
"Completed Truth reset closure check ..... " );
513 return StatusCode::SUCCESS;