ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
PileupFilterTool Class Reference

#include <PileupFilterTool.h>

Inheritance diagram for PileupFilterTool:
Collaboration diagram for PileupFilterTool:

Public Member Functions

 PileupFilterTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters: More...
 
virtual ~PileupFilterTool ()
 Destructor: More...
 
StatusCode buildMcAod (const McEventCollection *in, McEventCollection *out)
 This method will check the validity of the input McEventCollection and build a filtered one from the strategy implemented by this concrete tool. More...
 
StatusCode initialize ()
 Athena Algorithm's Hooks. More...
 
StatusCode execute ()
 
StatusCode finalize ()
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Inline methods:
More...
 

Protected Types

typedef ToolHandle< IMcVtxFilterToolMcVtxFilterTool_t
 
typedef ToolHandle< ITruthIsolationToolIsolTool_t
 

Protected Member Functions

 PileupFilterTool ()
 Default constructor: More...
 
StatusCode selectSpclMcBarcodes ()
 Retrieve the GenParticles from the GenEvent object (located into the McEventCollection container), filter them and store their barcode into the list of barcodes of particles to keep. More...
 
StatusCode shapeGenEvent (McEventCollection *outEvt)
 Build the out McEventCollection by removing all the GenParticles whose barcode is not in the list of barcodes to keep. More...
 
StatusCode reconnectParticles (const McEventCollection *inEvt, McEventCollection *out)
 Reconnect the particles of the filtered McEventCollection. More...
 
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. More...
 
StatusCode initializeTool ()
 to get tesIO More...
 
virtual StatusCode finalizeTool ()
 
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Protected Attributes

std::set< HepMC::ConstGenParticlePtrm_particles
 List of particles which have been labelled as "special". More...
 
DoubleProperty m_rIsol
 deltaR isolation energy cut for electrons, muons, taus and photons More...
 
DoubleProperty m_ptGamMin
 Minimum threshold for transverse momentum of photons. More...
 
DoubleProperty m_ptMin
 Minimum threshold for transverse momentum for all particles. More...
 
DoubleProperty m_etaRange
 Eta acceptance cut applied on all stable particles. More...
 
DoubleProperty m_rRange
 Radius acceptance cut on all stable particles. More...
 
BooleanProperty m_includeSimul
 Switch to include or not particles from detector simulation (Geant4) More...
 
BooleanProperty m_includePartonShowers
 Switch to include or not parton showers. More...
 
TruthHelper::GenAccessIOm_tesIO
 Pointer to a StoreGateSvc helper (Mc particle retrieval with predicates) More...
 
BooleanProperty m_removeDecayToSelf
 Switch to remove particles which decay into themselves (t->tg) but only for generated particles, not the ones from the Geant4 interactions. More...
 
McVtxFilterTool_t m_mcVtxFilterTool
 Pointer to the McVtxFilterTool to be able to select additional vertices on some decay pattern criterion. More...
 
IsolTool_t m_isolationTool
 Pointer to the TruthIsolationTool to be able to compute transverse energy isolations for various isolation cones cuts. More...
 
BooleanProperty m_doEtIsolation
 Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle). More...
 
SG::ReadHandleKey< McEventCollectionm_mcEventsReadHandleKey {this,"McEvents","TruthEvent","ReadHandleKey for input McEventCollection one wants to filter"}
 ReadHandleKey for the input McEventCollection one wants to filter. More...
 
SG::WriteHandleKey< McEventCollectionm_mcEventsOutputWriteHandleKey {this,"McEventsOutput","GEN_AOD","WriteHandleKey for the output McEventCollection which has been filtered"}
 Location of the output McEventCollection which has been filtered. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 28 of file PileupFilterTool.h.

Member Typedef Documentation

◆ IsolTool_t

typedef ToolHandle<ITruthIsolationTool> TruthParticleFilterBaseTool::IsolTool_t
protectedinherited

Definition at line 80 of file TruthParticleFilterBaseTool.h.

◆ McVtxFilterTool_t

typedef ToolHandle<IMcVtxFilterTool> TruthParticleFilterBaseTool::McVtxFilterTool_t
protectedinherited

Definition at line 74 of file TruthParticleFilterBaseTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ PileupFilterTool() [1/2]

PileupFilterTool::PileupFilterTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Constructor with parameters:

Definition at line 41 of file PileupFilterTool.cxx.

43  :
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 }

◆ ~PileupFilterTool()

PileupFilterTool::~PileupFilterTool ( )
virtual

Destructor:

Definition at line 93 of file PileupFilterTool.cxx.

94 {
95  ATH_MSG_DEBUG("Calling destructor");
96  delete m_tesIO;
97 }

◆ PileupFilterTool() [2/2]

PileupFilterTool::PileupFilterTool ( )
protected

Default constructor:

Member Function Documentation

◆ buildMcAod()

StatusCode PileupFilterTool::buildMcAod ( const McEventCollection in,
McEventCollection out 
)
virtual

This method will check the validity of the input McEventCollection and build a filtered one from the strategy implemented by this concrete tool.

Implements ITruthParticleFilterTool.

Definition at line 103 of file PileupFilterTool.cxx.

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 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute()

StatusCode TruthParticleFilterBaseTool::execute ( )
virtualinherited

Implements ITruthParticleFilterTool.

Definition at line 120 of file TruthParticleFilterBaseTool.cxx.

121 {
122  ATH_MSG_DEBUG("Executing " << name() << "...");
123 
124  //Setup Handle to read input container
126 
127  if (!mcEventsReadHandle.isValid()){
128  ATH_MSG_ERROR("Invalid ReadHandle to McEventColleciton with key: " << m_mcEventsReadHandleKey.key());
129  return StatusCode::FAILURE;
130  }
131 
132  //Setup WriteHandle, and then record new McEventCollection.
134  ATH_CHECK(mcEventsOutputWriteHandle.record(std::make_unique<McEventCollection>()));
135 
136  if (!mcEventsOutputWriteHandle.isValid()){
137  ATH_MSG_ERROR("Invalid WriteHamdle for McEventCollection with key ["
138  <<m_mcEventsOutputWriteHandleKey.key() << "] !!");
139  return StatusCode::FAILURE;
140  }
141 
142  // Compute isolation for gamma/lepton.
143  if ( m_doEtIsolation.value() ) {
144  ATH_MSG_VERBOSE("Computing Et isolations...");
145  if ( m_isolationTool->buildEtIsolations(m_mcEventsReadHandleKey.key()).isFailure() ) {
146  ATH_MSG_ERROR("Could not compute Et isolations !!");
147  return StatusCode::FAILURE;
148  }
149  } //> end do Et-isolation
150 
151  if ( this->buildMcAod( mcEventsReadHandle.ptr(), mcEventsOutputWriteHandle.ptr() ).isFailure() ) {
152  ATH_MSG_ERROR("Could not buildMcAod(in,out) !!");
153  return StatusCode::FAILURE;
154  }
155 
156  // We have slimmed the mcEventsOutputWriteHandle.
157  // To not bias the map of isolation energies for this GenEvent, we alias
158  // it to its original one
159  if ( m_doEtIsolation.value() &&
162  ).isSuccess() ) {
163  ATH_MSG_WARNING("Could not create an alias in the map of "\
164  "isolation energies !");
165  }
166 
167  return StatusCode::SUCCESS;
168 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode TruthParticleFilterBaseTool::finalize ( )
virtualinherited

Implements ITruthParticleFilterTool.

Definition at line 105 of file TruthParticleFilterBaseTool.cxx.

106 {
107  ATH_MSG_INFO("Finalizing " << name() << "...");
108 
109  m_mcVtxFilterTool->stats();
110 
111  // Give the concrete (derived) tool a chance to finalize itself
112  if ( finalizeTool().isFailure() ) {
113  ATH_MSG_ERROR("Could not finalize concrete tool !");
114  return StatusCode::FAILURE;
115  }
116 
117  return StatusCode::SUCCESS;
118 }

◆ finalizeTool()

StatusCode TruthParticleFilterBaseTool::finalizeTool ( )
inlineprotectedvirtualinherited

Definition at line 124 of file TruthParticleFilterBaseTool.h.

125 {
126  return StatusCode::SUCCESS;
127 }

◆ initialize()

StatusCode TruthParticleFilterBaseTool::initialize ( )
virtualinherited

Athena Algorithm's Hooks.

Retrieves a private AlgTool to filter a McEventCollection

Retrieves the isolation tool (public, to be used also in TruthParticleCnvTool)

Implements ITruthParticleFilterTool.

Definition at line 65 of file TruthParticleFilterBaseTool.cxx.

66 {
67  ATH_MSG_INFO("Initializing " << name() << "...");
68 
70  if ( !m_mcVtxFilterTool.retrieve().isSuccess() ) {
71  ATH_MSG_ERROR("Creation of algTool IMcVtxFilterTool FAILED !");
72  return StatusCode::FAILURE;
73  }
74 
76  if( m_doEtIsolation.value()) {
77  ATH_CHECK(m_isolationTool.retrieve());
78  }
79  else {
80  m_isolationTool.disable();
81  }
82 
83  //initialize DataHandleKeys
86 
88  (" DoEtIsolations: [" << std::boolalpha << m_doEtIsolation.value()
89  << "]" << endmsg
90  << " McEvents: [" << m_mcEventsReadHandleKey.key() << "]" << endmsg
91  << " McEventsOutput: [" << m_mcEventsOutputWriteHandleKey.key() << "]");
92 
93  // Give the concrete (derived) tool a chance to initialize itself
94  if ( initializeTool().isFailure() ) {
95  ATH_MSG_ERROR("Could not initialize concrete tool !");
96  return StatusCode::FAILURE;
97  }
98 
99  ATH_MSG_INFO("Options of the McVtxFilterTool:");
100  m_mcVtxFilterTool->displayOptions();
101 
102  return StatusCode::SUCCESS;
103 }

◆ initializeTool()

StatusCode PileupFilterTool::initializeTool ( )
protectedvirtual

to get tesIO

Reimplemented from TruthParticleFilterBaseTool.

Definition at line 616 of file PileupFilterTool.cxx.

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 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITruthParticleFilterTool::interfaceID ( )
inlinestaticinherited

Inline methods:

Definition at line 70 of file ITruthParticleFilterTool.h.

71 {
72  return IID_ITruthParticleFilterTool;
73 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ rebuildLinks()

StatusCode PileupFilterTool::rebuildLinks ( const HepMC::GenEvent *  mcEvent,
HepMC::GenEvent *  outEvt,
const HepMC::GenParticlePtr mcPart 
)
protected

Rebuild the links between particles which were connected, eg by a long FSR chain.

Definition at line 421 of file PileupFilterTool.cxx.

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 }

◆ reconnectParticles()

StatusCode PileupFilterTool::reconnectParticles ( const McEventCollection inEvt,
McEventCollection out 
)
protected

Reconnect the particles of the filtered McEventCollection.

We need the original McEventCollection to know if 2 particles were connected

Definition at line 376 of file PileupFilterTool.cxx.

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 }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ selectSpclMcBarcodes()

StatusCode PileupFilterTool::selectSpclMcBarcodes ( )
protected

Retrieve the GenParticles from the GenEvent object (located into the McEventCollection container), filter them and store their barcode into the list of barcodes of particles to keep.

skip stuff with no end-vertex

stable particles

Definition at line 142 of file PileupFilterTool.cxx.

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 }

◆ shapeGenEvent()

StatusCode PileupFilterTool::shapeGenEvent ( McEventCollection outEvt)
protected

Build the out McEventCollection by removing all the GenParticles whose barcode is not in the list of barcodes to keep.

Remove also the dead vertices.

Definition at line 238 of file PileupFilterTool.cxx.

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 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doEtIsolation

BooleanProperty TruthParticleFilterBaseTool::m_doEtIsolation
protectedinherited

Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle).

Default is to not compute these Et-isolations (and save CPU)

Definition at line 94 of file TruthParticleFilterBaseTool.h.

◆ m_etaRange

DoubleProperty PileupFilterTool::m_etaRange
protected

Eta acceptance cut applied on all stable particles.

Definition at line 118 of file PileupFilterTool.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_includePartonShowers

BooleanProperty PileupFilterTool::m_includePartonShowers
protected

Switch to include or not parton showers.

Definition at line 130 of file PileupFilterTool.h.

◆ m_includeSimul

BooleanProperty PileupFilterTool::m_includeSimul
protected

Switch to include or not particles from detector simulation (Geant4)

Definition at line 126 of file PileupFilterTool.h.

◆ m_isolationTool

IsolTool_t TruthParticleFilterBaseTool::m_isolationTool
protectedinherited

Pointer to the TruthIsolationTool to be able to compute transverse energy isolations for various isolation cones cuts.

See McParticleEvent/TruthParticleParameters.h for cone cuts.

Definition at line 85 of file TruthParticleFilterBaseTool.h.

◆ m_mcEventsOutputWriteHandleKey

SG::WriteHandleKey<McEventCollection> TruthParticleFilterBaseTool::m_mcEventsOutputWriteHandleKey {this,"McEventsOutput","GEN_AOD","WriteHandleKey for the output McEventCollection which has been filtered"}
protectedinherited

Location of the output McEventCollection which has been filtered.

Definition at line 104 of file TruthParticleFilterBaseTool.h.

◆ m_mcEventsReadHandleKey

SG::ReadHandleKey<McEventCollection> TruthParticleFilterBaseTool::m_mcEventsReadHandleKey {this,"McEvents","TruthEvent","ReadHandleKey for input McEventCollection one wants to filter"}
protectedinherited

ReadHandleKey for the input McEventCollection one wants to filter.

Definition at line 100 of file TruthParticleFilterBaseTool.h.

◆ m_mcVtxFilterTool

McVtxFilterTool_t TruthParticleFilterBaseTool::m_mcVtxFilterTool
protectedinherited

Pointer to the McVtxFilterTool to be able to select additional vertices on some decay pattern criterion.

Definition at line 78 of file TruthParticleFilterBaseTool.h.

◆ m_particles

std::set<HepMC::ConstGenParticlePtr> PileupFilterTool::m_particles
protected

List of particles which have been labelled as "special".

Definition at line 101 of file PileupFilterTool.h.

◆ m_ptGamMin

DoubleProperty PileupFilterTool::m_ptGamMin
protected

Minimum threshold for transverse momentum of photons.

Definition at line 109 of file PileupFilterTool.h.

◆ m_ptMin

DoubleProperty PileupFilterTool::m_ptMin
protected

Minimum threshold for transverse momentum for all particles.

Warning: this cut is applied before Pt photon cut !

Definition at line 114 of file PileupFilterTool.h.

◆ m_removeDecayToSelf

BooleanProperty PileupFilterTool::m_removeDecayToSelf
protected

Switch to remove particles which decay into themselves (t->tg) but only for generated particles, not the ones from the Geant4 interactions.

Definition at line 139 of file PileupFilterTool.h.

◆ m_rIsol

DoubleProperty PileupFilterTool::m_rIsol
protected

deltaR isolation energy cut for electrons, muons, taus and photons

Definition at line 105 of file PileupFilterTool.h.

◆ m_rRange

DoubleProperty PileupFilterTool::m_rRange
protected

Radius acceptance cut on all stable particles.

Definition at line 122 of file PileupFilterTool.h.

◆ m_tesIO

TruthHelper::GenAccessIO* PileupFilterTool::m_tesIO
protected

Pointer to a StoreGateSvc helper (Mc particle retrieval with predicates)

Definition at line 134 of file PileupFilterTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
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
TruthParticleFilterBaseTool::m_doEtIsolation
BooleanProperty m_doEtIsolation
Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle...
Definition: TruthParticleFilterBaseTool.h:94
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle< McEventCollection >
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
ITruthParticleFilterTool::buildMcAod
virtual StatusCode buildMcAod(const McEventCollection *in, McEventCollection *filtered)=0
This method will check the validity of the input McEventCollection and build a filtered one from the ...
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
TruthParticleFilterBaseTool::finalizeTool
virtual StatusCode finalizeTool()
Definition: TruthParticleFilterBaseTool.h:124
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
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
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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
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
TruthParticleFilterBaseTool::initializeTool
virtual StatusCode initializeTool()
I/O operators.
Definition: TruthParticleFilterBaseTool.h:117
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
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
AthCommonDataStore
Definition: AthCommonDataStore.h:52
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
TruthParticleFilterBaseTool::m_mcVtxFilterTool
McVtxFilterTool_t m_mcVtxFilterTool
Pointer to the McVtxFilterTool to be able to select additional vertices on some decay pattern criteri...
Definition: TruthParticleFilterBaseTool.h:78
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TruthParticleFilterBaseTool::m_isolationTool
IsolTool_t m_isolationTool
Pointer to the TruthIsolationTool to be able to compute transverse energy isolations for various isol...
Definition: TruthParticleFilterBaseTool.h:85
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
TruthParticleFilterBaseTool::TruthParticleFilterBaseTool
TruthParticleFilterBaseTool()
Default constructor:
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TruthHelper::GenAccessIO
Definition: Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h:24
python.TrigInDetValidation_AODtoTrkNtuple_CA.mcTruth
mcTruth
Definition: TrigInDetValidation_AODtoTrkNtuple_CA.py:72
python.PyAthena.v
v
Definition: PyAthena.py:157
SG::WriteHandle< McEventCollection >
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
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
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
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
HepMC::barcode_to_vertex
GenVertex * barcode_to_vertex(const GenEvent *e, int id)
Definition: GenEvent.h:505
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
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
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
TruthParticleFilterBaseTool::m_mcEventsOutputWriteHandleKey
SG::WriteHandleKey< McEventCollection > m_mcEventsOutputWriteHandleKey
Location of the output McEventCollection which has been filtered.
Definition: TruthParticleFilterBaseTool.h:104
fitman.k
k
Definition: fitman.py:528
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