ATLAS Offline Software
PileupFilterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // PileupFilterTool.cxx
7 // Implementation file for class pileupFilterTool
8 // Author: Ketevi.A.Assamagan<ketevi@bnl.gov>
10 
11 
12 // STL includes
13 #include <cmath>
14 
15 // FrameWork includes
16 
17 // HepMC includes
19 #include "GenAccessIO.h"
20 #include "AtlasHepMC/GenEvent.h"
21 #include "AtlasHepMC/GenParticle.h"
22 #include "AtlasHepMC/GenVertex.h"
23 #include "AtlasHepMC/Relatives.h"
25 #include "CLHEP/Units/SystemOfUnits.h"
26 
27 // McParticleKernel includes
29 
30 // McParticleTools includes
31 #include "PileupFilterTool.h"
32 
34 // Public methods:
36 
37 using CLHEP::GeV;
38 
39 // Constructors
42  const std::string& name,
43  const IInterface* parent ) :
45  m_particles ( ),
46  m_tesIO ( nullptr )
47 {
48 
49  declareProperty( "rIsolation",
50  m_rIsol = 0.45,
51  "DeltaR isolation energy cut for electrons, muons, "
52  "taus and photons" );
53 
54  declareProperty( "ptGammaMin",
55  m_ptGamMin = 0.5*GeV,
56  "Minimum threshold for transverse momentum of photons" );
57 
58  declareProperty( "ptMin",
59  m_ptMin = 0.5*GeV,
60  "Minimum threshold for transverse momentum for all particles.\n"
61  "Warning: this cut is applied *before* Pt photon cut !" );
62 
63  declareProperty( "etaRange",
64  m_etaRange = 5.0,
65  "Eta acceptance cut applied on all stable particles" );
66 
67  declareProperty( "rRange",
68  m_rRange = 500.0,
69  "radius acceptance - in milimeters - cut applied on all stable "
70  "particles" );
71 
72  // switches
73 
74  declareProperty( "IncludeSimul",
75  m_includeSimul = true,
76  "Switch to include or not particles from detector simulation "
77  "(Geant 4)" );
78 
79  declareProperty( "IncludePartonShowers",
81  "Switch to include or not parton showers" );
82 
83  declareProperty( "RemoveDecayToSelf",
84  m_removeDecayToSelf = true,
85  "Switch to remove particles which decay into themselves (t->tg) "
86  "*but* only for generated particles, not the ones from the "
87  "Geant4 interactions" );
88 
89 }
90 
91 // Destructor
94 {
95  ATH_MSG_DEBUG("Calling destructor");
96  delete m_tesIO;
97 }
98 
100 // Non-const methods:
102 
105 {
106  if ( nullptr == in || nullptr == out ) {
107  ATH_MSG_ERROR("Invalid pointer to McEventCollection !" << endmsg
108  << " in: " << in << endmsg
109  << " out: " << out);
110  return StatusCode::FAILURE;
111  }
112 
113  // we just copy the input McEventCollection and put it into the output one
114  out->operator=( *in );
115 
116  // select the barcodes of the "special" particles from the input GenEvent
117  if ( selectSpclMcBarcodes().isFailure() ) {
118  ATH_MSG_ERROR("Could not select the \"special\" barcodes !!");
119  return StatusCode::FAILURE;
120  }
121 
122  // remove the not "special" particles from the filtered McEventCollection
123  if ( shapeGenEvent(out).isFailure() ) {
124  ATH_MSG_ERROR("Could not remove the not \"special\" particles from the "\
125  "filtered McEventCollection !!");
126  return StatusCode::FAILURE;
127  }
128 
129  // reconnect the particles
130  if ( reconnectParticles(in, out).isFailure() ) {
131  ATH_MSG_ERROR("Could not reconnect the particles in the filtered "\
132  "McEventCollection !!");
133  return StatusCode::FAILURE;
134  }
135 
136  return StatusCode::SUCCESS;
137 }
138 
140 // Non-const methods:
143 {
144  StatusCode sc = StatusCode::SUCCESS;
145 
146  // Get all of the generated particles (does not have Geant secondaries)
147 
148  std::vector<HepMC::ConstGenParticlePtr> particles;
149  if ( m_includeSimul ) {
151  } else {
153  }
154  if ( sc.isFailure() ) {
155  ATH_MSG_ERROR("Could not get Monte Carlo particles from TDS at : "<< m_mcEventsReadHandleKey.key());
156  return StatusCode::FAILURE;
157  }
158 
159  m_particles.clear();
160 
161  //+++ Get True Vertices from Storegate
162  const McEventCollection* mcTruth(nullptr);
163  sc = evtStore()->retrieve(mcTruth, m_mcEventsReadHandleKey.key());
164  if( sc.isFailure() ) {
165  ATH_MSG_WARNING("MC Event " << m_mcEventsReadHandleKey.key() << " not found.");
166  return StatusCode::SUCCESS;
167  }
168  ATH_MSG_DEBUG("McEventCollection successfully retrieved" << endmsg << "Number of truth particles: " << mcTruth->size());
169 
170  McEventCollection::const_iterator mcEventItr = mcTruth->begin();
171  McEventCollection::const_iterator mcEventItrE = mcTruth->end();
172 
173  for ( ; mcEventItr != mcEventItrE; ++mcEventItr ) {
174 
175  const HepMC::GenEvent* genEvent = (*mcEventItr);
176 
177 #ifdef HEPMC3
178  auto vxp = genEvent->vertices().begin();
179 #else
180  HepMC::GenEvent::vertex_const_iterator vxp = genEvent->vertices_begin();
181 #endif
182  const float xp = (*vxp)->position().x();
183  const float yp = (*vxp)->position().y();
184  const float zp = (*vxp)->position().z();
185 
186  // Loop over all particles, selecting special ones
187  // keep track of them using their barcodes
188  for (const auto& part: *genEvent) {
189  const int id = part->pdg_id();
190  const HepMC::FourVector hlv = part->momentum();
191  const double pt = hlv.perp();
192  const HepMC::ConstGenVertexPtr& decayVtx = part->end_vertex();
193  const HepMC::ConstGenVertexPtr& prodVtx = part->production_vertex();
194  bool isSpcl = false;
196  if( !MC::isStable(part) && !decayVtx ) continue;
197 
198  float xi = (prodVtx->position()).x();
199  float yi = (prodVtx->position()).y();
200  float zi = (prodVtx->position()).z();
201 
202  ATH_MSG_DEBUG("Primary Vertex = " << xp << " " << yp << " " << zp << " " << "Production Vertex = " << xi << " " << yi << " " << zi << " " << "Particle ID = " << id);
203 
204  float deltaR = std::sqrt( (xp-xi)*(xp-xi) + (yp-yi)*(yp-yi) );
205 
206  const bool accept = (pt > m_ptMin) && (deltaR < m_rRange);
208  // Select special particles
211  if (m_includeSimul ) {
212  if ( MC::isSimStable(part) && accept ) isSpcl = true;
213  } else {
214  if ( MC::isGenStable(part) && accept ) isSpcl = true;
215  }
216 
218  // Save special particles and children
220  if( !isSpcl ) continue;
221  m_particles.insert(part); // add it to list
222 
223  // Children
224  if( isSpcl && decayVtx ) {
225  for(const auto& child: *(part->end_vertex())) {
227  m_particles.insert(child);// its not there already
228  }
229  }
230  }
231  }
232  }
233  ATH_MSG_DEBUG("Read " << particles.size() << " and selected " << m_particles.size() << " particles");
234 
235  return StatusCode::SUCCESS;
236 }
237 
239 {
240  //now remove all the particles except those whose barcodes are marked
241  for ( McEventCollection::iterator evt = genAod->begin(); evt != genAod->end();++evt) {
242  std::vector<HepMC::GenParticlePtr> going_out;
243  std::list<int> evtBarcodes;
244 #ifdef HEPMC3
245  const auto &barcodes = (*evt)->attribute<HepMC::GenEventBarcodes> ("barcodes");
246  std::map<int,int> id_to_barcode_map;
247  if (barcodes) id_to_barcode_map = barcodes->id_to_barcode_map();
248  for (const auto& keyval: id_to_barcode_map) evtBarcodes.push_back(keyval.second);
249 #else
250  for ( const auto& p: **evt) {
251  evtBarcodes.push_back( HepMC::barcode(p) );
252  }
253 #endif
254 
255  for ( std::list<int>::const_iterator itrBc = evtBarcodes.begin(); itrBc != evtBarcodes.end(); ++itrBc ) {
256 //AV: We modify the event!
257  HepMC::GenParticlePtr p = HepMC::barcode_to_particle((HepMC::GenEvent*)(*evt),*itrBc);
258  ATH_MSG_DEBUG("[pdg,particle]= " << p->pdg_id() << ", " << p);
259  if ( m_particles.count(p) == 0) {
260  going_out.push_back(p); // list of useless particles
261  HepMC::GenVertexPtr pvtx = p->production_vertex();
262  HepMC::GenVertexPtr evtx = p->end_vertex();
263 
264  std::pair<int,int> bcNext( 0, 0 );
265  if ( msgLvl(MSG::DEBUG) ) {
266  msg(MSG::DEBUG) << "Removing [" <<p << "]" << "\tprod/endVtx: " << pvtx << "/" << evtx << endmsg;
267  std::list<int>::const_iterator pNext = itrBc;
268  ++pNext;
269  if ( pNext != evtBarcodes.end() ) {
270  bcNext.first = HepMC::barcode(HepMC::barcode_to_particle(*evt,*pNext));
271  }
272  }
273 #ifdef HEPMC3
274  if (pvtx) pvtx->remove_particle_out(p); //remove from production vertex from useless particle
275 #else
276  if (pvtx) pvtx->remove_particle(p); //remove from production vertex from useless particle
277 #endif
278  if (evtx) { // if it has end vertex, may need to move the out partilces
279  if(pvtx){ // move the partilces back
280  if ( msgLvl(MSG::DEBUG) ) {
281  msg(MSG::DEBUG) << "\tin endVtx "<< endmsg;
282  }
283 #ifdef HEPMC3
284  while ( evtx->particles_out().begin() != evtx->particles_out().end()) {
285  pvtx->add_particle_out(evtx->particles_out().front());
286  }
287  }//> end if [prod vertex]
288  evtx->remove_particle_out(p); // disconnect from end vertex
289 #else
290  while ( evtx->particles_out_const_begin() != evtx->particles_out_const_end()) {
291  HepMC::GenVertex::particles_out_const_iterator np = evtx->particles_out_const_begin();
292  pvtx->add_particle_out(*np); // note that this really is a MOVE!!! it get taken off evtx by magic
293  }
294  }//> end if [prod vertex]
295  evtx->remove_particle(p); // disconnect from end vertex
296 #endif
297  }//> end if [decay vertex]
298 
299  if ( msgLvl(MSG::DEBUG) ) {
300  std::list<int>::const_iterator pNext = itrBc;
301  ++pNext;
302  if ( pNext != evtBarcodes.end() ) {
303  bcNext.second = HepMC::barcode(HepMC::barcode_to_particle(*evt,*pNext));
304  }
305 
306  if ( bcNext.first != bcNext.second ) {
307  ATH_MSG_WARNING("\tIterator has been CORRUPTED !!" << endmsg << "\tbcNext: " << bcNext.first << " --> " << bcNext.second);
308  } else {
309  ATH_MSG_DEBUG("\tIterator OK:" << endmsg << "\tbcNext: " << bcNext.first << " --> " << bcNext.second);
310  }
311  }
312 
313  }//> particle has to be removed
314  }//> loop over particles
315 
316 
317 #ifdef HEPMC3
318  // there may be a bunch of vertices with no particles connected to them:
319  // ==> Get rid of them
320  std::vector<HepMC::ConstGenVertexPtr> going_out_again;
321  for ( auto& v: (*evt)->vertices() ) {
322  if ( v->particles_in().empty() && v->particles_out().empty() ){
323  going_out_again.push_back(v);
324  }
325  }//> loop over vertices
326 #else
327  // now get rid of all dead particles
328  for ( std::vector<HepMC::GenParticle*>::iterator d = going_out.begin();
329  d != going_out.end();
330  ++d ){
331  delete *d;
332  }
333 
334  // there may be a bunch of vertices with no particles connected to them:
335  // ==> Get rid of them
336  std::vector<HepMC::GenVertex*> going_out_again;
337  for ( HepMC::GenEvent::vertex_const_iterator v = (*evt)->vertices_begin();
338  v != (*evt)->vertices_end(); ++v ) {
339  if ( (*v)->particles_in_size() == 0 && (*v)->particles_out_size() == 0 ){
340  going_out_again.push_back(*v);
341  }
342  }//> loop over vertices
343 
344  // now get rid of all dead vertices
345  for ( std::vector<HepMC::GenVertex*>::iterator d = going_out_again.begin();
346  d != going_out_again.end();
347  ++d ){
348  delete *d;
349  }
350 #endif
351 
352  }//> loop over GenEvents in McEventCollection
353 
354  // Set the signal_process_vertex to NULL if not to be recorded
355  for ( McEventCollection::iterator evt = genAod->begin(); evt != genAod->end(); ++evt) {
356  auto sigProcVtx = HepMC::signal_process_vertex(*evt);
357  if ( !sigProcVtx ) continue;
358  const int sigProcBC = HepMC::barcode(sigProcVtx);
359  bool isInColl = false;
360  if (HepMC::barcode_to_vertex(*evt, sigProcBC)) isInColl = true;
361 #ifdef HEPMC3
362 //AV: We don't set nullptr as signal vertex in HepMC3
363  if ( !isInColl ) {
364  (*evt)->remove_attribute("signal_process_vertex");
365  }
366 #else
367  if ( !isInColl ) {
368  (*evt)->set_signal_process_vertex(0);
369  }
370 #endif
371  }//> loop over GenEvent's
372 
373  return StatusCode::SUCCESS;
374 }
375 
377 {
378  if ( nullptr == in || nullptr == out ) {
379  ATH_MSG_ERROR("Invalid pointer to McEventCollection !!" << endmsg << " in: " << in << endmsg << " out: " << out);
380  return StatusCode::FAILURE;
381  }
382 
383  for ( unsigned int iEvt = 0; iEvt != in->size(); ++iEvt) {
384  const HepMC::GenEvent * evt = (*in)[iEvt];
385  HepMC::GenEvent * outEvt = (*out)[iEvt];
386 
387  // Reconnect the particles
388  ATH_MSG_VERBOSE("Reconnecting particles...");
389  for ( const auto& itrPart: *outEvt) {
390  if ( itrPart->end_vertex() ) {
391  continue;
392  }
393  if ( rebuildLinks( evt, outEvt, itrPart ).isFailure() ) {
394  ATH_MSG_WARNING("Could not rebuild links for this particle [pdgId,particle]= "<< itrPart->pdg_id() << ", " << itrPart);
395  } else if ( msgLvl(MSG::VERBOSE) ) {
396  msg(MSG::VERBOSE)<< "==========================================================="<< endmsg<< "Production vertex for particle " << itrPart << " : ";
397  if ( itrPart->production_vertex() ) {
398  std::stringstream prodVtx("");
399  HepMC::Print::line(prodVtx,itrPart->production_vertex());
400  msg(MSG::VERBOSE) << std::endl<< prodVtx.str()<< endmsg;
401  } else {
402  msg(MSG::VERBOSE) << "[No production vertex]" << endmsg;
403  }
404 
405  msg(MSG::VERBOSE) << "Decay vertex for particle " << itrPart << " : ";
406  if ( itrPart->end_vertex() ) {
407  std::stringstream dcyVtx("");
408  HepMC::Print::line(dcyVtx,itrPart->end_vertex());
409  msg(MSG::VERBOSE) << std::endl<< dcyVtx.str() << endmsg;
410  } else {
411  msg(MSG::VERBOSE) << endmsg << "[No decay vertex]" << endmsg;
412  }
413  }//> end VERBOSE messages
414 
415  }//> loop over particles
416  }//> loop over GenEvents
417 
418  return StatusCode::SUCCESS;
419 }
420 
421 StatusCode PileupFilterTool::rebuildLinks( const HepMC::GenEvent * mcEvt,
422  HepMC::GenEvent * outEvt,
423  const HepMC::GenParticlePtr& mcPart )
424 {
425  if ( !mcPart ) {
426  ATH_MSG_WARNING("Null GenParticle: can not rebuildLinks");
427  return StatusCode::FAILURE;
428  }
429 
430  if ( mcPart->end_vertex() ) {
431  ATH_MSG_VERBOSE("GenParticle has already a decay vertex : nothing to do");
432  return StatusCode::SUCCESS;
433  }
434 
435  if ( !mcEvt ) {
436  ATH_MSG_WARNING("Null input HepMC::GenEvent : can not rebuildLinks");
437  return StatusCode::FAILURE;
438  }
439 
440  if ( !outEvt ) {
441  ATH_MSG_WARNING("Null output HepMC::GenEvent: can not rebuildLinks");
442  return StatusCode::FAILURE;
443  }
444 
445  // Cache some useful infos
446  const int pdgId = mcPart->pdg_id();
447  const int bc = HepMC::barcode(mcPart);
448 #ifdef HEPMC3
450  HepMC::ConstGenVertexPtr dcyVtx = inPart->end_vertex();
451 #else
452 //AV: Const correctness is broken in HepMC2
454  HepMC::GenVertexPtr dcyVtx = inPart->end_vertex();
455 #endif
456 
457  if ( !dcyVtx ) {
458  ATH_MSG_VERBOSE("No decay vertex for the particle #" << bc << " : " << "No link to rebuild...");
459  return StatusCode::SUCCESS;
460  }
461 
462  std::list<int> bcChildPart;
463  std::list<int> bcChildVert;
464 
465  //
466  // Loop over all descendants of the GenParticle
467  // Store the barcode of the GenParticles entering into each GenVertex
468  //
469 #ifdef HEPMC3
470  auto descendants=HepMC::descendant_vertices(dcyVtx);
471  for ( const auto& itrVtx: descendants) {
472  bool foundPdgId = false;
473  for ( const auto& itrPart: itrVtx->particles_in()) {
474  // because the vertices are traversed in POST ORDER !!
475  bcChildPart.push_front( HepMC::barcode(itrPart));
476  if ( itrPart->pdg_id() == pdgId ) {
477  foundPdgId = true;
478  }
479  }//> loop over in-going particles of this vertex
480  if ( foundPdgId ) {
481  bcChildVert.push_front( HepMC::barcode(itrVtx));
482  }
483  }//> loop over descendants of decay vertex
484 #else
485  const HepMC::GenVertex::vertex_iterator endVtx = dcyVtx->vertices_end(HepMC::descendants);
486  for ( HepMC::GenVertex::vertex_iterator itrVtx = dcyVtx->vertices_begin( HepMC::descendants );
487  itrVtx != endVtx;
488  ++itrVtx ) {
489  bool foundPdgId = false;
490  HepMC::GenVertex::particles_in_const_iterator endPart = (*itrVtx)->particles_in_const_end();
491  for ( HepMC::GenVertex::particles_in_const_iterator itrPart = (*itrVtx)->particles_in_const_begin();
492  itrPart != endPart;
493  ++itrPart ) {
494 
495 
496 
497  // because the vertices are traversed in POST ORDER !!
498  bcChildPart.push_front( (*itrPart)->barcode() );
499 
500  if ( (*itrPart)->pdg_id() == pdgId ) {
501  foundPdgId = true;
502  }
503  }//> loop over in-going particles of this vertex
504 
505  if ( foundPdgId ) {
506  bcChildVert.push_front( (*itrVtx)->barcode() );
507  }
508 
509  }//> loop over descendants of decay vertex
510 #endif
511 
512  //
513  // Now we loop over the previously stored barcodes and
514  // we connect our GenParticle to the first found barcode
515  //
516 #ifdef HEPMC3
517  std::list<int>::const_iterator bcVtxEnd = bcChildVert.end();
518  for ( std::list<int>::const_iterator itrBcVtx = bcChildVert.begin(); itrBcVtx != bcVtxEnd; ++itrBcVtx ) {
519  HepMC::GenVertexPtr childVtx = HepMC::barcode_to_vertex(outEvt,*itrBcVtx);
520  if ( childVtx ) {
521  if ( !childVtx->particles_in().empty() ) {
522  for ( const auto& itrPart: childVtx->particles_in()) {
523  if ( itrPart->pdg_id() == pdgId ) {
524  HepMC::GenVertexPtr prodVtx = itrPart->production_vertex();
525  if ( prodVtx ) {
526  if ( !prodVtx->particles_in().empty() ) {
527  // Humm... This is not what we'd have expected
528  // so we skip it
529  if ( msgLvl(MSG::VERBOSE) ) {
530  msg(MSG::VERBOSE)<< "found a particle = "<< itrPart << ", "<< "but its production vertex has incoming particles !" << endmsg;
531  continue;
532  }
533  // create a GenVertex which will be the decay vertex of our
534  // GenParticle and the production vertex of the GenParticle
535  // we just found
537  outEvt->add_vertex( linkVtx );
538  linkVtx->add_particle_in( mcPart );
539  linkVtx->add_particle_out( itrPart );
540 
541  msg(MSG::ERROR)<< "=====================================================" << endmsg << "Created a GenVertex - link !" << std::endl;
542  std::stringstream vtxLink("");
543  HepMC::Print::line(vtxLink,linkVtx);
544  msg(MSG::ERROR)<< vtxLink.str()<< endmsg<< "====================================================="<< endmsg;
545  }
546  }
547  }
548  }//> loop over incoming particles
549  } else {
550  // no incoming particle : so we just add this particle
551  // a bit odd though : FIXME ?
552  childVtx->add_particle_in(mcPart);
553  msg(MSG::WARNING) << "Odd situation:" << std::endl;
554  std::stringstream vtxDump( "" );
555  HepMC::Print::line(vtxDump,childVtx);
556  msg(MSG::WARNING) << vtxDump.str() << endmsg;
557  return StatusCode::SUCCESS;
558  }//> end if incoming particles
559  }//> found a child-vertex
560  }
561 #else
562  std::list<int>::const_iterator bcVtxEnd = bcChildVert.end();
563  for ( std::list<int>::const_iterator itrBcVtx = bcChildVert.begin();
564  itrBcVtx != bcVtxEnd;
565  ++itrBcVtx ) {
566  HepMC::GenVertex * childVtx = outEvt->barcode_to_vertex(*itrBcVtx);
567  if ( childVtx ) {
568  if ( childVtx->particles_in_size() > 0 ) {
569  HepMC::GenVertex::particles_in_const_iterator endPart = childVtx->particles_in_const_end();
570  for ( HepMC::GenVertex::particles_in_const_iterator itrPart = childVtx->particles_in_const_begin();
571  itrPart != endPart;
572  ++itrPart ) {
573  if ( (*itrPart)->pdg_id() == pdgId ) {
574  HepMC::GenVertex * prodVtx = (*itrPart)->production_vertex();
575  if ( prodVtx ) {
576  if ( prodVtx->particles_in_size() > 0 ) {
577  // Humm... This is not what we'd have expected
578  // so we skip it
579  if ( msgLvl(MSG::VERBOSE) ) {
580  msg(MSG::VERBOSE)<< "found a particle [bc,pdgId]= "<< (*itrPart)->barcode() << ", "<< "but its production vertex has incoming particles !" << endmsg;
581  continue;
582  }
583  // create a GenVertex which will be the decay vertex of our
584  // GenParticle and the production vertex of the GenParticle
585  // we just found
587  outEvt->add_vertex( linkVtx );
588  linkVtx->add_particle_in( mcPart );
589  linkVtx->add_particle_out( *itrPart );
590 
591  msg(MSG::ERROR)<< "====================================================="<< endmsg<< "Created a GenVertex - link !"<< std::endl;
592  std::stringstream vtxLink("");
593  linkVtx->print(vtxLink);
594  msg(MSG::ERROR)<< vtxLink.str()<< endmsg<< "=====================================================" << endmsg;
595  }
596  }
597  }
598  }//> loop over incoming particles
599  } else {
600  // no incoming particle : so we just add this particle
601  // a bit odd though : FIXME ?
602  childVtx->add_particle_in(mcPart);
603  msg(MSG::WARNING) << "Odd situation:" << std::endl;
604  std::stringstream vtxDump( "" );
605  childVtx->print(vtxDump);
606  msg(MSG::WARNING) << vtxDump.str() << endmsg;
607  return StatusCode::SUCCESS;
608  }//> end if incoming particles
609  }//> found a child-vertex
610  }//> loop over child-vertex-barcodes
611 #endif
612 
613  return StatusCode::FAILURE;
614 }
615 
617 {
618  ATH_MSG_DEBUG("Calling initializeTool");
619  // accessor for particles
620  delete m_tesIO;
622  if( nullptr == m_tesIO ) {
623  ATH_MSG_ERROR("Unable to retrieve GenAccessIO pointer");
624  return StatusCode::FAILURE;
625  }
626  return StatusCode::SUCCESS;
627 }
628 
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
PileupFilterTool::reconnectParticles
StatusCode reconnectParticles(const McEventCollection *inEvt, McEventCollection *out)
Reconnect the particles of the filtered McEventCollection.
Definition: PileupFilterTool.cxx:376
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
GenEvent.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PileupFilterTool::m_ptGamMin
DoubleProperty m_ptGamMin
Minimum threshold for transverse momentum of photons.
Definition: PileupFilterTool.h:109
PileupFilterTool::selectSpclMcBarcodes
StatusCode selectSpclMcBarcodes()
Retrieve the GenParticles from the GenEvent object (located into the McEventCollection container),...
Definition: PileupFilterTool.cxx:142
PileupFilterTool::buildMcAod
StatusCode buildMcAod(const McEventCollection *in, McEventCollection *out)
This method will check the validity of the input McEventCollection and build a filtered one from the ...
Definition: PileupFilterTool.cxx:103
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
hist_file_dump.d
d
Definition: hist_file_dump.py:137
PileupFilterTool::m_includeSimul
BooleanProperty m_includeSimul
Switch to include or not particles from detector simulation (Geant4)
Definition: PileupFilterTool.h:126
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
GenVertex.h
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
PileupFilterTool::m_rRange
DoubleProperty m_rRange
Radius acceptance cut on all stable particles.
Definition: PileupFilterTool.h:122
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
HepMC::Print::line
void line(std::ostream &os, const GenEvent &e)
Definition: GenEvent.h:554
x
#define x
GenParticle.h
PowhegPy8EG_H2a.pdgId
dictionary pdgId
Definition: PowhegPy8EG_H2a.py:128
PileupFilterTool::m_particles
std::set< HepMC::ConstGenParticlePtr > m_particles
List of particles which have been labelled as "special".
Definition: PileupFilterTool.h:101
MC::isGenStable
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
Definition: HepMCHelpers.h:36
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
GenAccessIO.h
PileupFilterTool::m_tesIO
TruthHelper::GenAccessIO * m_tesIO
Pointer to a StoreGateSvc helper (Mc particle retrieval with predicates)
Definition: PileupFilterTool.h:134
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HepMC::barcode_to_particle
GenParticle * barcode_to_particle(const GenEvent *e, int id)
Definition: GenEvent.h:506
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:299
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
PileupFilterTool::m_includePartonShowers
BooleanProperty m_includePartonShowers
Switch to include or not parton showers.
Definition: PileupFilterTool.h:130
HepMC::newGenVertexPtr
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition: GenVertex.h:64
python.Dumpers.barcodes
def barcodes(beg, end, sz)
Definition: Dumpers.py:2800
z
#define z
TruthParticleFilterBaseTool::m_mcEventsReadHandleKey
SG::ReadHandleKey< McEventCollection > m_mcEventsReadHandleKey
ReadHandleKey for the input McEventCollection one wants to filter.
Definition: TruthParticleFilterBaseTool.h:100
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
PileupFilterTool.h
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
PileupFilterTool::m_etaRange
DoubleProperty m_etaRange
Eta acceptance cut applied on all stable particles.
Definition: PileupFilterTool.h:118
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PileupFilterTool::initializeTool
StatusCode initializeTool()
to get tesIO
Definition: PileupFilterTool.cxx:616
TruthHelper::GenAccessIO::getMC
StatusCode getMC(MCParticleCollection &mcParticles, const bool ifgen=false, const std::string &key="GEN_EVENT") const
Definition: Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h:32
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
TruthParticleFilterBaseTool
Definition: TruthParticleFilterBaseTool.h:33
PileupFilterTool::~PileupFilterTool
virtual ~PileupFilterTool()
Destructor:
Definition: PileupFilterTool.cxx:93
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MagicNumbers.h
TruthHelper::GenAccessIO
Definition: Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h:24
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
python.TrigInDetValidation_AODtoTrkNtuple_CA.mcTruth
mcTruth
Definition: TrigInDetValidation_AODtoTrkNtuple_CA.py:72
python.PyAthena.v
v
Definition: PyAthena.py:157
PileupFilterTool::shapeGenEvent
StatusCode shapeGenEvent(McEventCollection *outEvt)
Build the out McEventCollection by removing all the GenParticles whose barcode is not in the list of ...
Definition: PileupFilterTool.cxx:238
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
y
#define y
PileupFilterTool::m_ptMin
DoubleProperty m_ptMin
Minimum threshold for transverse momentum for all particles.
Definition: PileupFilterTool.h:114
PileupFilterTool::rebuildLinks
StatusCode rebuildLinks(const HepMC::GenEvent *mcEvent, HepMC::GenEvent *outEvt, const HepMC::GenParticlePtr &mcPart)
Rebuild the links between particles which were connected, eg by a long FSR chain.
Definition: PileupFilterTool.cxx:421
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
Relatives.h
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
HepMC::barcode_to_vertex
GenVertex * barcode_to_vertex(const GenEvent *e, int id)
Definition: GenEvent.h:505
IMcVtxFilterTool.h
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
MC::isSimStable
bool isSimStable(const T &p)
Identify if the particle is considered stable at the post-detector-sim stage.
Definition: HepMCHelpers.h:39
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
PileupFilterTool::m_rIsol
DoubleProperty m_rIsol
deltaR isolation energy cut for electrons, muons, taus and photons
Definition: PileupFilterTool.h:105
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HepMCHelpers.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
PileupFilterTool::PileupFilterTool
PileupFilterTool()
Default constructor:
PileupFilterTool::m_removeDecayToSelf
BooleanProperty m_removeDecayToSelf
Switch to remove particles which decay into themselves (t->tg) but only for generated particles,...
Definition: PileupFilterTool.h:139
HepMC::signal_process_vertex
GenVertex * signal_process_vertex(const GenEvent *e)
Definition: GenEvent.h:503