ATLAS Offline Software
Loading...
Searching...
No Matches
TruthClosureCheck.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TruthClosureCheck.h"
6//
11
12
14
15#include "CLHEP/Vector/LorentzVector.h"
16#include "CLHEP/Units/SystemOfUnits.h"
17//
18#include "CLHEP/Geometry/Point3D.h"
20#include <climits>
21
22//----------------------------------------------------
24 //----------------------------------------------------
25
28 return StatusCode::SUCCESS;
29
30}
31
32
33StatusCode TruthClosureCheck::sanityCheck(const HepMC::GenEvent& event) const {
34 //Sanity check
35 bool resetProblem(false);
36 for (const auto& particle: event) {
37 if (MC::isStable(particle)) {
38 if (!particle->production_vertex()) {
39 ATH_MSG_ERROR("Stable particle without a production vertex!! " << particle);
40 resetProblem = true;
41 }
42 if (!m_postSimulation && particle->end_vertex()) {
43 ATH_MSG_ERROR("Stable particle with an end vertex!! " << particle);
44 resetProblem = true;
45 }
46 }
47 else if (MC::isDecayed(particle)) {
48 if (!particle->production_vertex()) {
49 ATH_MSG_ERROR("Decayed particle without a production vertex!! " << particle);
50 resetProblem = true;
51 }
52 if (!particle->end_vertex()) {
53 ATH_MSG_ERROR("Decayed particle without an end vertex!! " << particle);
54 resetProblem = true;
55 }
56 }
57 }
58 if (resetProblem) {
59 return StatusCode::FAILURE;
60 }
61
62 return StatusCode::SUCCESS;
63}
64
65#ifdef HEPMC3
67 const HepMC::ConstGenVertexPtr& resetVertex) const
68{
69 ATH_MSG_INFO("----------------------------------");
70 ATH_MSG_INFO("Original Vertex:");
71 ATH_MSG_INFO( origVertex );
72 ATH_MSG_INFO("Particles In:");
73 for (const auto& originalPartIn: origVertex->particles_in()) ATH_MSG_INFO( originalPartIn );
74 ATH_MSG_INFO("Particles Out:");
75 for (const auto& originalPartOut: origVertex->particles_out()) ATH_MSG_INFO( originalPartOut );
76 ATH_MSG_INFO("----------------------------------");
77 ATH_MSG_INFO("Reset Vertex:");
78 ATH_MSG_INFO( resetVertex );
79 ATH_MSG_INFO("Particles In:");
80 for (const auto& resetPartIn: resetVertex->particles_in()) ATH_MSG_INFO( resetPartIn );
81 ATH_MSG_INFO("Particles Out:");
82 for (const auto& resetPartOut: resetVertex->particles_out()) ATH_MSG_INFO( resetPartOut );
83 ATH_MSG_INFO("----------------------------------");
84 return;
85}
86#else
87
88void TruthClosureCheck::printGenVertex(const HepMC::GenVertex& origVertex,
89 const HepMC::GenVertex& resetVertex) const
90{
91 ATH_MSG_INFO("----------------------------------");
92 ATH_MSG_INFO("Original Vertex:");
93 ATH_MSG_INFO( origVertex );
94 ATH_MSG_INFO("Particles In:");
95 HepMC::GenVertex::particles_in_const_iterator originalPartInIter(origVertex.particles_in_const_begin());
96 const HepMC::GenVertex::particles_in_const_iterator endOfOriginalListOfParticlesIn(origVertex.particles_in_const_end());
97 while( originalPartInIter!=endOfOriginalListOfParticlesIn ) {
98 ATH_MSG_INFO( **originalPartInIter );
99 ++originalPartInIter;
100 }
101 ATH_MSG_INFO("Particles Out:");
102 HepMC::GenVertex::particles_out_const_iterator originalPartOutIter(origVertex.particles_out_const_begin());
103 const HepMC::GenVertex::particles_out_const_iterator endOfOriginalListOfParticlesOut(origVertex.particles_out_const_end());
104 while( originalPartOutIter!=endOfOriginalListOfParticlesOut) {
105 ATH_MSG_INFO( **originalPartOutIter );
106 ++originalPartOutIter;
107 }
108 ATH_MSG_INFO("----------------------------------");
109 ATH_MSG_INFO("Reset Vertex:");
110 ATH_MSG_INFO( resetVertex );
111 ATH_MSG_INFO("Particles In:");
112 HepMC::GenVertex::particles_in_const_iterator resetPartInIter(resetVertex.particles_in_const_begin());
113 const HepMC::GenVertex::particles_in_const_iterator endOfResetListOfParticlesIn(resetVertex.particles_in_const_end());
114 while( resetPartInIter!=endOfResetListOfParticlesIn ) {
115 ATH_MSG_INFO( **resetPartInIter );
116 ++resetPartInIter;
117 }
118 ATH_MSG_INFO("Particles Out:");
119 HepMC::GenVertex::particles_out_const_iterator resetPartOutIter(resetVertex.particles_out_const_begin());
120 const HepMC::GenVertex::particles_out_const_iterator endOfResetListOfParticlesOut(resetVertex.particles_out_const_end());
121 while( resetPartOutIter!=endOfResetListOfParticlesOut) {
122 ATH_MSG_INFO( **resetPartOutIter );
123 ++resetPartOutIter;
124 }
125 ATH_MSG_INFO("----------------------------------");
126 return;
127}
128#endif
129
130#ifdef HEPMC3
132 const HepMC::ConstGenVertexPtr& resetVertex) const
133{
134 if (!origVertex && !resetVertex) return StatusCode::SUCCESS;
135 if (!origVertex || !resetVertex) return StatusCode::FAILURE;
136 bool pass{true};
137
138 if (HepMC::barcode(origVertex) != HepMC::barcode(resetVertex)) { // FIXME barcode-based
139 ATH_MSG_ERROR ("vertex barcode differs! Original: "<<HepMC::barcode(origVertex)<<", Reset: "<<HepMC::barcode(resetVertex));
140 pass = false;
141 }
142 if (origVertex->position() != resetVertex->position()) {
143 const HepMC::FourVector& oP = origVertex->position();
144 const HepMC::FourVector& rP = resetVertex->position();
145 ATH_MSG_ERROR("vertex position differs! Original: ("<<oP.x()<<","<<oP.y()<<","<<oP.z()<<","<<oP.t()<<"), Reset: ("<<rP.x()<<","<<rP.y()<<","<<rP.z()<<","<<rP.t()<<")");
146 pass = false;
147 }
148 if (origVertex->particles_in().size() != resetVertex->particles_in().size() ) {
149 ATH_MSG_ERROR ("particles_in_size differs! Original: "<<origVertex->particles_in().size()<<", Reset: "<<resetVertex->particles_in().size());
150 pass = false;
151 }
152 if (origVertex->particles_out().size() != resetVertex->particles_out().size() ) {
153 ATH_MSG_ERROR ("particles_out_size differs! Original: "<<origVertex->particles_out().size()<<", Reset: "<<resetVertex->particles_out().size());
154 pass = false;
155 }
156 std::vector<HepMC::ConstGenParticlePtr> OriginalListOfParticlesIn = origVertex->particles_in();
157 std::vector<HepMC::ConstGenParticlePtr> ResetListOfParticlesIn = resetVertex->particles_in();
158 for ( std::vector<HepMC::ConstGenParticlePtr>::iterator originalPartInIter(OriginalListOfParticlesIn.begin()),resetPartInIter(ResetListOfParticlesIn.begin());
159 originalPartInIter != OriginalListOfParticlesIn.end() && resetPartInIter != ResetListOfParticlesIn.end();
160 ++originalPartInIter, ++resetPartInIter
161 ) {
162 if (compareGenParticle(*originalPartInIter,*resetPartInIter).isFailure()) {
163 ATH_MSG_ERROR ( "input particle properties differ!" );
164 pass &= false;
165 }
166 ATH_MSG_VERBOSE ( "particles match!" );
167 }
168
169
170 std::vector<HepMC::ConstGenParticlePtr> OriginalListOfParticlesOut = origVertex->particles_out();
171 std::vector<HepMC::ConstGenParticlePtr> ResetListOfParticlesOut = resetVertex->particles_out();
172 //AV: please remember that the best quantities to compare particles are physical quantities.
173 std::sort(OriginalListOfParticlesOut.begin(), OriginalListOfParticlesOut.end(), [](auto& a, auto& b) -> bool{return a->momentum().pz() > b->momentum().pz(); });
174 std::sort(ResetListOfParticlesOut.begin(), ResetListOfParticlesOut.end(), [](auto& a, auto& b) -> bool{return a->momentum().pz() > b->momentum().pz(); });
175
176 for ( std::vector<HepMC::ConstGenParticlePtr>::iterator originalPartOutIter(OriginalListOfParticlesOut.begin()), resetPartOutIter(ResetListOfParticlesOut.begin());
177 originalPartOutIter != OriginalListOfParticlesOut.end() && resetPartOutIter != ResetListOfParticlesOut.end();
178 ++originalPartOutIter, ++resetPartOutIter
179 ) {
180 if (compareGenParticle(*originalPartOutIter,*resetPartOutIter).isFailure()) {
181 ATH_MSG_ERROR ( "output particle properties differ!" );
182 pass &= false;
183 }
184 ATH_MSG_VERBOSE ( "particles match!" );
185 }
186 if(!pass) { return StatusCode::FAILURE; }
187 return StatusCode::SUCCESS;
188}
189
190
191#else
192StatusCode TruthClosureCheck::compareGenVertex(const HepMC::GenVertex& origVertex,
193 const HepMC::GenVertex& resetVertex) const
194{
195 bool pass{true};
196
197 if (HepMC::barcode(origVertex) != HepMC::barcode(resetVertex)) { // FIXME HepMC::barcode
198 ATH_MSG_ERROR ("vertex barcode differs! Original: " << HepMC::barcode(origVertex) << ", Reset: " << HepMC::barcode(resetVertex));
199 pass = false;
200 }
201 if (origVertex.position() != resetVertex.position()) {
202 const HepMC::FourVector& oP = origVertex.position();
203 const HepMC::FourVector& rP = resetVertex.position();
204 ATH_MSG_ERROR("vertex position differs! Original: ("<<oP.x()<<","<<oP.y()<<","<<oP.z()<<","<<oP.t()<<"), Reset: ("<<rP.x()<<","<<rP.y()<<","<<rP.z()<<","<<rP.t()<<")");
205 pass = false;
206 }
207 if (origVertex.particles_in_size() != resetVertex.particles_in_size() ) {
208 ATH_MSG_ERROR ("particles_in_size differs! Original: "<<origVertex.particles_in_size()<<", Reset: "<<resetVertex.particles_in_size());
209 pass = false;
210 }
211 if (origVertex.particles_out_size() != resetVertex.particles_out_size() ) {
212 ATH_MSG_ERROR ("particles_out_size differs! Original: "<<origVertex.particles_out_size()<<", Reset: "<<resetVertex.particles_out_size());
213 pass = false;
214 }
215 HepMC::GenVertex::particles_in_const_iterator originalPartInIter(origVertex.particles_in_const_begin());
216 const HepMC::GenVertex::particles_in_const_iterator endOfOriginalListOfParticlesIn(origVertex.particles_in_const_end());
217 HepMC::GenVertex::particles_in_const_iterator resetPartInIter(resetVertex.particles_in_const_begin());
218 const HepMC::GenVertex::particles_in_const_iterator endOfResetListOfParticlesIn(resetVertex.particles_in_const_end());
219 while( originalPartInIter!=endOfOriginalListOfParticlesIn &&
220 resetPartInIter!=endOfResetListOfParticlesIn ) {
221 if (compareGenParticle(**originalPartInIter,**resetPartInIter).isFailure()) {
222 ATH_MSG_ERROR ( "input particle properties differ!" );
223 pass &= false;
224 }
225 ATH_MSG_VERBOSE ( "particles match!" );
226 ++resetPartInIter;
227 ++originalPartInIter;
228 }
229
230 HepMC::GenVertex::particles_out_const_iterator originalPartOutIter(origVertex.particles_out_const_begin());
231 const HepMC::GenVertex::particles_out_const_iterator endOfOriginalListOfParticlesOut(origVertex.particles_out_const_end());
232 // ordering of particles may differ in each case - sigh..
233 const HepMC::GenVertex::particles_out_const_iterator endOfResetListOfParticlesOut(resetVertex.particles_out_const_end());
234 while( originalPartOutIter!=endOfOriginalListOfParticlesOut) {
235 const int barcodeOrig{HepMC::barcode(*originalPartOutIter)}; // FIXME barcode-based
236 HepMC::GenVertex::particles_out_const_iterator resetPartOutIter(resetVertex.particles_out_const_begin());
237 HepMC::GenVertex::particles_in_const_iterator matchingResetParticleIter{endOfResetListOfParticlesOut};
238 while(resetPartOutIter!=endOfResetListOfParticlesOut) {
239 if ( barcodeOrig == HepMC::barcode(*resetPartOutIter) ) {
240 matchingResetParticleIter = resetPartOutIter;
241 break;
242 }
243 ++resetPartOutIter;
244 }
245 if (matchingResetParticleIter==endOfResetListOfParticlesOut ||
246 compareGenParticle(**originalPartOutIter,**matchingResetParticleIter).isFailure()) {
247 ATH_MSG_ERROR ( "output particle properties differ!" );
248 pass &= false;
249 }
250 ATH_MSG_VERBOSE ( "particles match!" );
251 ++originalPartOutIter;
252 }
253
254 if(!pass) { return StatusCode::FAILURE; }
255 return StatusCode::SUCCESS;
256}
257#endif
258
259
260StatusCode TruthClosureCheck::compareMomenta(const HepMC::FourVector& origMomenta,
261 const HepMC::FourVector& resetMomenta) const
262{
263 bool pass{true};
264 if (m_compareMomenta) {
265 if (m_momentaLimit<std::abs(origMomenta.px()-resetMomenta.px())) {
266 pass &= false;
267 }
268 if (m_momentaLimit<std::abs(origMomenta.py()-resetMomenta.py())) {
269 pass &= false;
270 }
271 if (m_momentaLimit<std::abs(origMomenta.pz()-resetMomenta.pz())) {
272 pass &= false;
273 }
274 if (m_momentaLimit<std::abs(origMomenta.e()-resetMomenta.e())) {
275 pass &= false;
276 }
277 if(origMomenta != resetMomenta) {
278 ATH_MSG_ERROR ("Exact momenta agreement check failed.");
279 pass &= false;
280 }
281 }
282 if(!pass) { return StatusCode::FAILURE; }
283 return StatusCode::SUCCESS;
284}
285
286#ifdef HEPMC3
288 const HepMC::ConstGenParticlePtr& resetParticle) const
289{
290 if (!origParticle && !resetParticle) return StatusCode::SUCCESS;
291 if (!origParticle || !resetParticle) return StatusCode::FAILURE;
292
293 bool pass{true};
294 if (HepMC::barcode(origParticle) != HepMC::barcode(resetParticle)) { // FIXME barcode-based
295 ATH_MSG_ERROR ("particle barcode differs! Original: "<<HepMC::barcode(origParticle)<<", Reset: "<<HepMC::barcode(resetParticle));
296 pass &= false;
297 }
298 if (origParticle->status() != resetParticle->status()) {
299 ATH_MSG_ERROR ("particle status differs! Original: "<<origParticle->status()<<", Reset: "<<resetParticle->status());
300 pass &= false;
301 }
302 if (origParticle->pdg_id() != resetParticle->pdg_id()) {
303 ATH_MSG_ERROR ("particle pdg_id differs! Original: "<<origParticle->pdg_id()<<", Reset: "<<resetParticle->pdg_id());
304 pass &= false;
305 }
306 if (compareMomenta(origParticle->momentum(), resetParticle->momentum()).isFailure()) {
307 const HepMC::FourVector& oM = origParticle->momentum();
308 const HepMC::FourVector& rM = resetParticle->momentum();
309 ATH_MSG_DEBUG("particle momentum differs! Original: ("<<oM.x()<<","<<oM.y()<<","<<oM.z()<<","<<oM.t()<<"), Reset: ("<<rM.x()<<","<<rM.y()<<","<<rM.z()<<","<<rM.t()<<")");
310 pass &= false;
311 }
312 if(!pass) { return StatusCode::FAILURE; }
313 return StatusCode::SUCCESS;
314}
315
316#else
317StatusCode TruthClosureCheck::compareGenParticle(const HepMC::GenParticle& origParticle,
318 const HepMC::GenParticle& resetParticle) const
319{
320 bool pass{true};
321 if (HepMC::barcode(origParticle) != HepMC::barcode(resetParticle)) { // FIXME barcode-based
322 ATH_MSG_ERROR ("particle barcode differs! Original: "<<HepMC::barcode(origParticle)<<", Reset: "<<HepMC::barcode(resetParticle));
323 pass &= false;
324 }
325 if (origParticle.status() != resetParticle.status()) {
326 ATH_MSG_ERROR ("particle status differs! Original: "<<origParticle.status()<<", Reset: "<<resetParticle.status());
327 pass &= false;
328 }
329 if (origParticle.pdg_id() != resetParticle.pdg_id()) {
330 ATH_MSG_ERROR ("particle pdg_id differs! Original: "<<origParticle.pdg_id()<<", Reset: "<<resetParticle.pdg_id());
331 pass &= false;
332 }
333 if (compareMomenta(origParticle.momentum(), resetParticle.momentum()).isFailure()) {
334 const HepMC::FourVector& oM = origParticle.momentum();
335 const HepMC::FourVector& rM = resetParticle.momentum();
336 ATH_MSG_DEBUG("particle momentum differs! Original: ("<<oM.x()<<","<<oM.y()<<","<<oM.z()<<","<<oM.t()<<"), Reset: ("<<rM.x()<<","<<rM.y()<<","<<rM.z()<<","<<rM.t()<<")");
337 pass &= false;
338 }
339 if(!pass) { return StatusCode::FAILURE; }
340 return StatusCode::SUCCESS;
341}
342#endif
343
344#ifdef HEPMC3
345//-------------------------------------------------
346StatusCode TruthClosureCheck::execute(const EventContext& ctx) const {
347 //-------------------------------------------------
348
349 ATH_MSG_DEBUG( " execute..... " );
351 if (!originalMcEventCollection.isValid()) {
352 ATH_MSG_ERROR("Could not find original McEventCollection called " << originalMcEventCollection.name() << " in store " << originalMcEventCollection.store() << ".");
353 return StatusCode::FAILURE;
354 }
355 const HepMC::GenEvent& originalEvent(**(originalMcEventCollection->begin()));
356
357 if (sanityCheck(originalEvent).isFailure()) {
358 ATH_MSG_FATAL("Problems in original GenEvent - bailing out.");
359 return StatusCode::FAILURE;
360 }
361
362 SG::ReadHandle<McEventCollection> resetMcEventCollection(m_resetMcEventCollection,ctx);
363 if (!resetMcEventCollection.isValid()) {
364 ATH_MSG_ERROR("Could not find reset McEventCollection called " << resetMcEventCollection.name() << " in store " << resetMcEventCollection.store() << ".");
365 return StatusCode::FAILURE;
366 }
367 const HepMC::GenEvent& resetEvent(**(resetMcEventCollection->begin()));
368
369 if (sanityCheck(resetEvent).isFailure()) {
370 ATH_MSG_FATAL("Problems in reset GenEvent - bailing out.");
371 return StatusCode::FAILURE;
372 }
373
374 if (originalEvent.event_number() != resetEvent.event_number() ) {
375 ATH_MSG_ERROR ("event_number differs! Original: "<<originalEvent.event_number()<<", Reset: "<<resetEvent.event_number());
376 }
377
378 if (HepMC::signal_process_id(originalEvent) != HepMC::signal_process_id(resetEvent) ) {
379 ATH_MSG_ERROR ("signal_process_id differs! Original: "<<HepMC::signal_process_id(originalEvent)<<", Reset: "<<HepMC::signal_process_id(resetEvent));
380 }
382 std::vector<HepMC::ConstGenParticlePtr> OriginalBeams = originalEvent.beams();
383 std::vector<HepMC::ConstGenParticlePtr> ResetBeams = resetEvent.beams();
384
385 for ( std::vector<HepMC::ConstGenParticlePtr>::iterator originalBeamIter(OriginalBeams.begin()), resetBeamIter(ResetBeams.begin());
386 originalBeamIter != OriginalBeams.end() && resetBeamIter != ResetBeams.end();
387 ++originalBeamIter, ++resetBeamIter
388 ) {
389 if (compareGenParticle(*originalBeamIter,*resetBeamIter).isFailure()) {
390 ATH_MSG_ERROR ( "Beam particle properties differ!" );
391 }
393 if (originalEvent.particles().size() != resetEvent.particles().size() ) {
394 ATH_MSG_ERROR ("particles_size differs! Original: "<<originalEvent.particles().size()<<", Reset: "<<resetEvent.particles().size());
395 }
396
397 if (originalEvent.vertices().size() != resetEvent.vertices().size() ) {
398 ATH_MSG_ERROR ("vertices_size differs! Original: "<<originalEvent.vertices().size()<<", Reset: "<<resetEvent.vertices().size());
399 }
400 }
401
402 //loop over vertices in Background GenEvent
403 std::vector<HepMC::ConstGenVertexPtr> OriginalListOfVertices = originalEvent.vertices();
404 std::vector<HepMC::ConstGenVertexPtr> ResetListOfVertices = resetEvent.vertices();
405
406 for( std::vector<HepMC::ConstGenVertexPtr>::iterator origVertexIter(OriginalListOfVertices.begin()),resetVertexIter(ResetListOfVertices.begin());
407 origVertexIter != OriginalListOfVertices.end() && resetVertexIter != ResetListOfVertices.end();
408 ++origVertexIter, ++resetVertexIter
409 ) {
410 if (compareGenVertex(*origVertexIter,*resetVertexIter).isFailure()) {
411 ATH_MSG_ERROR ( "vertices differ!" );
412 printGenVertex(*origVertexIter,*resetVertexIter);
413 }
414 }
415 ATH_MSG_INFO( "Completed Truth reset closure check ..... " );
416
417 return StatusCode::SUCCESS;
418
419}
420
421#else
422
423
424//-------------------------------------------------
425StatusCode TruthClosureCheck::execute(const EventContext& ctx) const {
426 //-------------------------------------------------
427
428 ATH_MSG_DEBUG( " execute..... " );
430 if (!originalMcEventCollection.isValid()) {
431 ATH_MSG_ERROR("Could not find original McEventCollection called " << originalMcEventCollection.name() << " in store " << originalMcEventCollection.store() << ".");
432 return StatusCode::FAILURE;
433 }
434 const HepMC::GenEvent& originalEvent(**(originalMcEventCollection->begin()));
435
436 if (sanityCheck(originalEvent).isFailure()) {
437 ATH_MSG_FATAL("Problems in original GenEvent - bailing out.");
438 return StatusCode::FAILURE;
439 }
440
442 if (!resetMcEventCollection.isValid()) {
443 ATH_MSG_ERROR("Could not find reset McEventCollection called " << resetMcEventCollection.name() << " in store " << resetMcEventCollection.store() << ".");
444 return StatusCode::FAILURE;
445 }
446 const HepMC::GenEvent& resetEvent(**(resetMcEventCollection->begin()));
447
448 if (sanityCheck(resetEvent).isFailure()) {
449 ATH_MSG_FATAL("Problems in reset GenEvent - bailing out.");
450 return StatusCode::FAILURE;
451 }
452
453 if (originalEvent.event_number() != resetEvent.event_number() ) {
454 ATH_MSG_ERROR ("event_number differs! Original: "<<originalEvent.event_number()<<", Reset: "<<resetEvent.event_number());
455 }
456
457 if (originalEvent.signal_process_id() != resetEvent.signal_process_id() ) {
458 ATH_MSG_ERROR ("signal_process_id differs! Original: "<<originalEvent.signal_process_id()<<", Reset: "<<resetEvent.signal_process_id());
459 }
460
461 if (originalEvent.valid_beam_particles() != resetEvent.valid_beam_particles() ) {
462 ATH_MSG_ERROR ("valid_beam_particles differs! Original: "<<originalEvent.valid_beam_particles()<<", Reset: "<<resetEvent.valid_beam_particles());
463 }
464 else if (originalEvent.valid_beam_particles() && resetEvent.valid_beam_particles()) {
465 std::pair<HepMC::GenParticle*,HepMC::GenParticle*> originalBP = originalEvent.beam_particles();
466 std::pair<HepMC::GenParticle*,HepMC::GenParticle*> resetBP = resetEvent.beam_particles();
467 if ( ( !originalBP.first && resetBP.first ) ||
468 ( originalBP.first && !resetBP.first ) ||
469 ( originalBP.first && resetBP.first && compareGenParticle(*(originalBP.first), *(resetBP.first)).isFailure() ) ) {
470 ATH_MSG_ERROR ( "First beam particle does not match" );
471 }
472 if ( ( !originalBP.second && resetBP.second ) ||
473 ( originalBP.second && !resetBP.second ) ||
474 ( originalBP.second && resetBP.second && compareGenParticle(*(originalBP.second), *(resetBP.second)).isFailure() ) ) {
475 ATH_MSG_ERROR ( "Second beam particle does not match" );
476 }
477
478 if (originalEvent.particles_size() != resetEvent.particles_size() ) {
479 ATH_MSG_ERROR ("particles_size differs! Original: "<<originalEvent.particles_size()<<", Reset: "<<resetEvent.particles_size());
480 }
481
482 if (originalEvent.vertices_size() != resetEvent.vertices_size() ) {
483 ATH_MSG_ERROR ("vertices_size differs! Original: "<<originalEvent.vertices_size()<<", Reset: "<<resetEvent.vertices_size());
484 }
485 }
486
487 //loop over vertices in Background GenEvent
488 HepMC::GenEvent::vertex_const_iterator origVertexIter(originalEvent.vertices_begin());
489 const HepMC::GenEvent::vertex_const_iterator endOfOriginalListOfVertices(originalEvent.vertices_end());
490 HepMC::GenEvent::vertex_const_iterator resetVertexIter(resetEvent.vertices_begin());
491 const HepMC::GenEvent::vertex_const_iterator endOfResetListOfVertices(resetEvent.vertices_end());
492 while( origVertexIter!=endOfOriginalListOfVertices &&
493 resetVertexIter!=endOfResetListOfVertices) {
494 if (compareGenVertex(**origVertexIter,**resetVertexIter).isFailure()) {
495 ATH_MSG_ERROR ( "vertices differ!" );
496 printGenVertex(**origVertexIter,**resetVertexIter);
497 }
498 ++origVertexIter;
499 ++resetVertexIter;
500 }
501 ATH_MSG_INFO( "Completed Truth reset closure check ..... " );
502
503 return StatusCode::SUCCESS;
504
505}
506#endif
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
ATLAS-specific HepMC functions.
static Double_t a
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.
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
StatusCode compareGenVertex(const HepMC::GenVertex &origVertex, const HepMC::GenVertex &resetVertex) const
StatusCode sanityCheck(const HepMC::GenEvent &event) const
StatusCode compareGenParticle(const HepMC::GenParticle &origParticle, const HepMC::GenParticle &resetParticle) const
void printGenVertex(const HepMC::GenVertex &origVertex, const HepMC::GenVertex &resetVertex) const
virtual StatusCode initialize() override final
Gaudi::Property< bool > m_compareMomenta
Gaudi::Property< bool > m_postSimulation
SG::ReadHandleKey< McEventCollection > m_resetMcEventCollection
int signal_process_id(const GenEvent &e)
Definition GenEvent.h:635
int barcode(const T *p)
Definition Barcode.h:16
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60
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.