ATLAS Offline Software
Loading...
Searching...
No Matches
EtaPtFilterTool Class Reference

#include <EtaPtFilterTool.h>

Inheritance diagram for EtaPtFilterTool:
Collaboration diagram for EtaPtFilterTool:

Public Member Functions

 EtaPtFilterTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
virtual ~EtaPtFilterTool ()
 Destructor:
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.
StatusCode initialize ()
 Athena Algorithm's Hooks.
StatusCode execute ()
StatusCode finalize ()
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Inline methods:

Protected Types

using ParticleMap_t
using VertexMap_t
typedef ToolHandle< IMcVtxFilterToolMcVtxFilterTool_t
typedef ToolHandle< ITruthIsolationToolIsolTool_t

Protected Member Functions

 EtaPtFilterTool ()
 Default constructor:
StatusCode buildGenEvent (const HepMC::GenEvent *in, HepMC::GenEvent *out)
 This method will check the validity of the input HepMC::GenEvent and build a filtered one from the strategy implemented by this concrete tool.
bool isAccepted (const HepMC::ConstGenParticlePtr &mcPart) const
 Check if a given particle is within the acceptance (pt+eta)
bool isAccepted (const HepMC::ConstGenVertexPtr &vtx) const
 Check if a given vertex has at least one in-going or out-going particle within the acceptance (pt+eta)
StatusCode addVertex (const HepMC::ConstGenVertexPtr &srcVtx, HepMC::GenEvent *evt, VertexMap_t &vmap, ParticleMap_t &pmap, bool isSignalVertex=false) const
 Helper method to copy a given vertex and add it to a GenEvent.
bool isPartonVertex (const HepMC::ConstGenVertexPtr &vtx) const
bool isFromHardScattering (const HepMC::ConstGenVertexPtr &vtx) const
StatusCode initializeTool ()
 Method to initialize the tool: we need to check the validity of the parameters given for the inner and outer eta regions.
void setupInnerEtaRegionCuts (Gaudi::Details::PropertyBase &innerEtaRegionCuts)
 Callback function to setup the "InnerEtaRegionCuts" property.
void setupOuterEtaRegionCuts (Gaudi::Details::PropertyBase &outerEtaRegionCuts)
 Callback function to setup the "OuterEtaRegionCuts" property.
virtual StatusCode finalizeTool ()
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
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.

Protected Attributes

DoubleArrayProperty m_innerEtaRegionCuts
 vector of cuts parameters for the inner region delimited in |eta| 0-th element is the minimum |eta| of this region 1-st element is the maximum |eta| of this region 2-nd element is the minimum pt for the stable particles to be accepted
DoubleArrayProperty m_outerEtaRegionCuts
 vector of cuts parameters for the outer region delimited in |eta| 0-th element is the minimum |eta| of this region 1-st element is the maximum |eta| of this region 2-nd element is the minimum pt for the stable particles to be accepted
BooleanProperty m_onlyGenerator
 Switch to only include particles from generation and reject particles from detector simulation (Geant4)
BooleanProperty m_butKeepAllGeneratorStable
 Switch to keep all stable generator particles (IsGenStable) regardless what eta or pt cuts are defined.
BooleanProperty m_keepDocumentaries
 Switch to keep all generator particles which are documentaries (statuscode == 3)
BooleanProperty m_keepAllLeptons
 Switch to keep all leptons - i.e.
std::map< int, double > m_isol_energies
McVtxFilterTool_t m_mcVtxFilterTool
 Pointer to the McVtxFilterTool to be able to select additional vertices on some decay pattern criterion.
IsolTool_t m_isolationTool
 Pointer to the TruthIsolationTool to be able to compute transverse energy isolations for various isolation cones cuts.
BooleanProperty m_doEtIsolation
 Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle).
SG::ReadHandleKey< McEventCollectionm_mcEventsReadHandleKey {this,"McEvents","TruthEvent","ReadHandleKey for input McEventCollection one wants to filter"}
 ReadHandleKey for the input McEventCollection one wants to filter.
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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

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

Detailed Description

Definition at line 23 of file EtaPtFilterTool.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.

◆ ParticleMap_t

Initial value:
std::unordered_map<const HepMC::GenParticle*,
GenParticle * GenParticlePtr
Definition GenParticle.h:37

Definition at line 53 of file EtaPtFilterTool.h.

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

◆ VertexMap_t

Initial value:
std::unordered_map<const HepMC::GenVertex*,
HepMC::GenVertex * GenVertexPtr
Definition GenVertex.h:59

Definition at line 55 of file EtaPtFilterTool.h.

Constructor & Destructor Documentation

◆ EtaPtFilterTool() [1/2]

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

Constructor with parameters:

Constructors.

Definition at line 34 of file EtaPtFilterTool.cxx.

36 :
37 TruthParticleFilterBaseTool( type, name, parent )
38{
39 //
40 // Property declaration
41 //
42 //declareProperty( "Property", m_nProperty );
43
44 declareProperty( "InnerEtaRegionCuts",
46 "Vector of cuts parameters for the inner region.\n"
47 "Two first elements are minimum and maximum |eta| values "
48 "for this inner region.\n"
49 "Third element is the minimum pT for the stable particles "
50 "to be accepted." );
51 // defaults
52 std::vector<double> innerEtaRegionCuts;
53 innerEtaRegionCuts.push_back( 0.0 ); // minimum |eta|
54 innerEtaRegionCuts.push_back( 3.5 ); // maximum |eta|
55 innerEtaRegionCuts.push_back( 0.3*GeV ); // minimum pT of particles
56 m_innerEtaRegionCuts.set( innerEtaRegionCuts );
57
59 this );
60
61 declareProperty( "OuterEtaRegionCuts",
63 "Vector of cuts parameters for the outer region.\n"
64 "Two first elements are minimum and maximum |eta| values "
65 "for this outer region.\n"
66 "Third element is the minimum pT for the stable particles "
67 "to be accepted." );
68 // defaults
69 std::vector<double> outerEtaRegionCuts;
70 outerEtaRegionCuts.push_back( 3.5 ); // minimum |eta|
71 outerEtaRegionCuts.push_back( 5.5 ); // maximum |eta|
72 outerEtaRegionCuts.push_back( 1.0*GeV ); // minimum pT of particles
73 m_outerEtaRegionCuts.set( outerEtaRegionCuts );
74
76 this );
77
78 // switches
79 declareProperty( "OnlyGenerator",
80 m_onlyGenerator = false,
81 "Switch to only include particles from generation and "
82 "reject particles from detector simulation (Geant4)" );
83
84
85 declareProperty( "ButKeepAllGeneratorStable",
87 "Switch to keep all generated stable particles (they sum to "
88 "14 TeV) regardless of the eta and pt cuts defined for the "
89 "remaining particles" );
90
91
92 declareProperty( "KeepDocumentaries",
94 "Switch to keep *all* generator particles which are "
95 "documentaries (statuscode == 3)" );
96
97 declareProperty( "KeepAllLeptons",
98 m_keepAllLeptons = true,
99 "Switch to keep *all* leptons - i.e. do not apply kinematic cuts on them");
100
101}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
BooleanProperty m_keepDocumentaries
Switch to keep all generator particles which are documentaries (statuscode == 3)
BooleanProperty m_onlyGenerator
Switch to only include particles from generation and reject particles from detector simulation (Geant...
BooleanProperty m_keepAllLeptons
Switch to keep all leptons - i.e.
BooleanProperty m_butKeepAllGeneratorStable
Switch to keep all stable generator particles (IsGenStable) regardless what eta or pt cuts are define...
void setupOuterEtaRegionCuts(Gaudi::Details::PropertyBase &outerEtaRegionCuts)
Callback function to setup the "OuterEtaRegionCuts" property.
void setupInnerEtaRegionCuts(Gaudi::Details::PropertyBase &innerEtaRegionCuts)
Callback function to setup the "InnerEtaRegionCuts" property.
DoubleArrayProperty m_outerEtaRegionCuts
vector of cuts parameters for the outer region delimited in |eta| 0-th element is the minimum |eta| o...
DoubleArrayProperty m_innerEtaRegionCuts
vector of cuts parameters for the inner region delimited in |eta| 0-th element is the minimum |eta| o...
TruthParticleFilterBaseTool()
Default constructor:

◆ ~EtaPtFilterTool()

EtaPtFilterTool::~EtaPtFilterTool ( )
virtual

Destructor:

Destructor.

Definition at line 105 of file EtaPtFilterTool.cxx.

106{
107 ATH_MSG_DEBUG("Calling destructor");
108}
#define ATH_MSG_DEBUG(x)

◆ EtaPtFilterTool() [2/2]

EtaPtFilterTool::EtaPtFilterTool ( )
protected

Default constructor:

Member Function Documentation

◆ addVertex()

StatusCode EtaPtFilterTool::addVertex ( const HepMC::ConstGenVertexPtr & srcVtx,
HepMC::GenEvent * evt,
VertexMap_t & vmap,
ParticleMap_t & pmap,
bool isSignalVertex = false ) const
protected

Helper method to copy a given vertex and add it to a GenEvent.

Fill the parent branch

Fill the children branch

Definition at line 295 of file EtaPtFilterTool.cxx.

299{
300 if ( 0 == srcVtx || 0 == evt ) {
301 ATH_MSG_ERROR("In addVertex(vtx,evt) : INVALID pointer given !!" << endmsg << " vtx: " << srcVtx << endmsg << " evt: " << evt);
302 return StatusCode::FAILURE;
303 }
304#ifdef HEPMC3
305 HepMC::GenVertexPtr& vtx = vmap[srcVtx.get()];
306 if ( !vtx ) {
308 evt->add_vertex(vtx);
309 vtx->set_position( srcVtx->position() );
310 vtx->set_status( srcVtx->status() );
312 vtx->add_attribute("weights",srcVtx->attribute<HepMC3::VectorDoubleAttribute> ("weights"));
313 if (isSignalVertex) HepMC::set_signal_process_vertex(evt,vtx);
314 }
317 for ( auto parent: srcVtx->particles_in()) {
318 HepMC::GenParticlePtr& p = pmap[parent.get()];
319 if ( !p ) {
321 vtx->add_particle_in( p );
322 p->set_momentum( parent->momentum() );
323 p->set_generated_mass( parent->generated_mass() );
324 p->set_pdg_id( parent->pdg_id() );
325 p->set_status( parent->status() );
326 HepMC::set_flow(p, HepMC::flow(parent) );
329 }
330 // set the mother's decay to our (new) vertex
331 vtx->add_particle_in( p );
332
333 }//> loop over ingoing particles
334
337 for (auto child: srcVtx->particles_out()) {
338 HepMC::GenParticlePtr& p = pmap[child.get()];
339 if ( !p ) {
341 vtx->add_particle_out( p );
342 p->set_momentum( child->momentum() );
343 p->set_generated_mass( child->generated_mass() );
344 p->set_pdg_id( child->pdg_id() );
345 p->set_status( child->status() );
346 HepMC::set_flow(p, HepMC::flow(child) );
349 }
350 // set the daughter's production vertex to our new vertex
351 vtx->add_particle_out( p );
352 }//> loop over outgoing particles
353#else
354
355 HepMC::GenVertexPtr& vtx = vmap[srcVtx];
356 if ( !vtx ) {
357 vtx = new HepMC::GenVertex();
358 vtx->set_position( srcVtx->position() );
359 vtx->set_id( srcVtx->id() );
360 vtx->suggest_barcode( srcVtx->barcode() );
361 vtx->weights() = srcVtx->weights();
362 evt->add_vertex(vtx);
363 if (isSignalVertex) evt->set_signal_process_vertex(vtx);
364 }
365
368 for ( HepMC::GenVertex::particles_in_const_iterator
369 parent = srcVtx->particles_in_const_begin(),
370 parentEnd = srcVtx->particles_in_const_end();
371 parent != parentEnd;
372 ++parent ) {
374 if ( !p ) {
375 p = new HepMC::GenParticle;
376 p->set_momentum( (*parent)->momentum() );
377 p->set_generated_mass( (*parent)->generated_mass() );
378 p->set_pdg_id( (*parent)->pdg_id() );
379 p->set_status( (*parent)->status() );
380 p->set_flow( (*parent)->flow() );
381 p->set_polarization( (*parent)->polarization() );
382 p->suggest_barcode( (*parent)->barcode() );
383 }
384 // set the mother's decay to our (new) vertex
385 vtx->add_particle_in( p );
386
387 }//> loop over ingoing particles
388
391 for ( HepMC::GenVertex::particles_out_const_iterator
392 child = srcVtx->particles_out_const_begin(),
393 childEnd = srcVtx->particles_out_const_end();
394 child != childEnd;
395 ++child ) {
396 HepMC::GenParticlePtr& p = pmap[*child];
397 if ( !p ) {
398 p = new HepMC::GenParticle;
399 p->set_momentum( (*child)->momentum() );
400 p->set_generated_mass( (*child)->generated_mass() );
401 p->set_pdg_id( (*child)->pdg_id() );
402 p->set_status( (*child)->status() );
403 p->set_flow( (*child)->flow() );
404 p->set_polarization( (*child)->polarization() );
405 p->suggest_barcode( (*child)->barcode() );
406 }
407
408 // set the daughter's production vertex to our new vertex
409 vtx->add_particle_out( p );
410
411 }//> loop over outgoing particles
412#endif
413
414 return StatusCode::SUCCESS;
415}
#define endmsg
#define ATH_MSG_ERROR(x)
void set_polarization(T &a, const Polarization &b)
void set_signal_process_vertex(GenEvent *e, T v)
Definition GenEvent.h:652
int barcode(const T *p)
Definition Barcode.h:16
bool suggest_barcode(T &p, int i)
Definition GenEvent.h:672
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition GenVertex.h:64
Polarization polarization(const T &a)
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
Definition GenParticle.h:39
int flow(const T &a, int i)
Definition Flow.h:51

◆ buildGenEvent()

StatusCode EtaPtFilterTool::buildGenEvent ( const HepMC::GenEvent * in,
HepMC::GenEvent * out )
protected

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

Const methods:

Definition at line 155 of file EtaPtFilterTool.cxx.

156{
157 if ( nullptr == in || nullptr == out ) {
158 ATH_MSG_ERROR("Invalid pointer to GenEvent !!" << endmsg
159 << " in: " << in << endmsg
160 << " out: " << out);
161 return StatusCode::FAILURE;
162 }
163
164 // loop over vertices
165 VertexMap_t vmap;
166 ParticleMap_t pmap;
167 auto spv = HepMC::signal_process_vertex(in); //AV To be removed in the future
168#ifdef HEPMC3
169 for ( auto vtx: in->vertices() ) {
170#else
171 for ( HepMC::GenEvent::vertex_const_iterator vtxit = in->vertices_begin(); vtxit != in->vertices_end(); ++vtxit ) {
172 auto vtx=*vtxit;
173#endif
174 bool isSignalVertex = (vtx == spv);
175 if ( !isAccepted(vtx) && !isSignalVertex ) {
176 // no in-going nor out-going particles at this vertex matches
177 // the requirements nor it is a signal process vertex : ==> Skip it
178 continue;
179 }
180
181 if ( addVertex( vtx, out, vmap, pmap, isSignalVertex ).isFailure() )
182 {
183 ATH_MSG_WARNING("Could not add vertex " << vtx );
184 }
185
186 } //> end loop over vertices
187
188 return StatusCode::SUCCESS;
189}
#define ATH_MSG_WARNING(x)
std::unordered_map< const HepMC::GenParticle *, HepMC::GenParticlePtr > ParticleMap_t
std::unordered_map< const HepMC::GenVertex *, HepMC::GenVertexPtr > VertexMap_t
bool isAccepted(const HepMC::ConstGenParticlePtr &mcPart) const
Check if a given particle is within the acceptance (pt+eta)
StatusCode addVertex(const HepMC::ConstGenVertexPtr &srcVtx, HepMC::GenEvent *evt, VertexMap_t &vmap, ParticleMap_t &pmap, bool isSignalVertex=false) const
Helper method to copy a given vertex and add it to a GenEvent.
GenVertex * signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:627

◆ buildMcAod()

StatusCode EtaPtFilterTool::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 111 of file EtaPtFilterTool.cxx.

112{
113 if ( !in || !out ) {
114 ATH_MSG_ERROR("Invalid pointer to McEventCollection !" << endmsg
115 << " in: " << in << endmsg
116 << " out: " << out);
117 return StatusCode::FAILURE;
118 }
119
120 for ( unsigned int iEvt = 0; iEvt != in->size(); ++iEvt ) {
121 const HepMC::GenEvent * inEvt = (*in)[iEvt];
122 if ( 0 == inEvt ) {
124 ("Could not launch filtering procedure for GenEvent number ["
125 << iEvt << "] from McEventCollection ["
126 << m_mcEventsReadHandleKey.key() << " !!"
127 << endmsg
128 << " inEvt: " << inEvt);
129 continue;
130 }
131 HepMC::GenEvent* outEvt = HepMC::copyemptyGenEvent( inEvt);
132
133 if ( buildGenEvent( inEvt, outEvt ).isFailure() ) {
134 ATH_MSG_ERROR("Could filter GenEvent number [" << iEvt
135 << "] from McEventCollection [" << m_mcEventsReadHandleKey.key()
136 << "] !!");
137 delete outEvt;
138 outEvt = 0;
139 continue;
140 }
141
142 TruthHelper::copyBeamParticles (*inEvt, *outEvt);
143
144 out->push_back( outEvt );
145 }
146
147 return StatusCode::SUCCESS;
148}
size_type size() const noexcept
Returns the number of elements in the collection.
StatusCode buildGenEvent(const HepMC::GenEvent *in, HepMC::GenEvent *out)
This method will check the validity of the input HepMC::GenEvent and build a filtered one from the st...
SG::ReadHandleKey< McEventCollection > m_mcEventsReadHandleKey
ReadHandleKey for the input McEventCollection one wants to filter.
GenEvent * copyemptyGenEvent(const GenEvent *inEvt)
Definition GenEvent.h:655
void copyBeamParticles(const HepMC::GenEvent &inEvt, HepMC::GenEvent &outEvt)

◆ declareGaudiProperty()

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

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

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

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

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ 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.

◆ evtStore()

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.

◆ 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
125 SG::ReadHandle<McEventCollection> mcEventsReadHandle(m_mcEventsReadHandleKey);
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.
133 SG::WriteHandle<McEventCollection> mcEventsOutputWriteHandle(m_mcEventsOutputWriteHandleKey);
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() &&
160 !m_isolationTool->registerAlias( m_mcEventsOutputWriteHandleKey.key(),
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
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 ...
BooleanProperty m_doEtIsolation
Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle...
SG::WriteHandleKey< McEventCollection > m_mcEventsOutputWriteHandleKey
Location of the output McEventCollection which has been filtered.
IsolTool_t m_isolationTool
Pointer to the TruthIsolationTool to be able to compute transverse energy isolations for various isol...

◆ 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}
#define ATH_MSG_INFO(x)
McVtxFilterTool_t m_mcVtxFilterTool
Pointer to the McVtxFilterTool to be able to select additional vertices on some decay pattern criteri...

◆ 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}
virtual StatusCode initializeTool()
I/O operators.

◆ initializeTool()

StatusCode EtaPtFilterTool::initializeTool ( )
protectedvirtual

Method to initialize the tool: we need to check the validity of the parameters given for the inner and outer eta regions.

Non-const methods:

Reimplemented from TruthParticleFilterBaseTool.

Definition at line 459 of file EtaPtFilterTool.cxx.

460{
461 ATH_MSG_INFO("Initializing " << name() << "...");
462
463 // make sure the properties are synchronised
466
467 if ( m_innerEtaRegionCuts.value().size() != 3 ||
468 m_outerEtaRegionCuts.value().size() != 3 ) {
470 ("Wrong size for eta regions cut :" << endmsg
471 << "\tinner region: " << m_innerEtaRegionCuts.value().size()
472 << endmsg
473 << "\touter region: " << m_outerEtaRegionCuts.value().size()
474 << endmsg
475 << "You have to provide a list of cuts of the form : " << endmsg
476 << " |etaMin| |etaMax| ptMin");
477 return StatusCode::FAILURE;
478 }
479
481 ("Inner Eta region cuts : nCuts = "
482 << m_innerEtaRegionCuts.value().size()
483 << endmsg
484 << "\tetaMin = " << m_innerEtaRegionCuts.value()[0] << endmsg
485 << "\tetaMax = " << m_innerEtaRegionCuts.value()[1] << endmsg
486 << "\tPtMin = " << m_innerEtaRegionCuts.value()[2] << endmsg
487 << "Outer Eta region cuts : nCuts = "
488 << m_outerEtaRegionCuts.value().size()
489 << endmsg
490 << "\tetaMin = " << m_outerEtaRegionCuts.value()[0] << endmsg
491 << "\tetaMax = " << m_outerEtaRegionCuts.value()[1] << endmsg
492 << "\tPtMin = " << m_outerEtaRegionCuts.value()[2]);
493
494 return StatusCode::SUCCESS;
495}

◆ 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{
73}
static const InterfaceID IID_ITruthParticleFilterTool("ITruthParticleFilterTool", 1, 0)

◆ isAccepted() [1/2]

bool EtaPtFilterTool::isAccepted ( const HepMC::ConstGenParticlePtr & mcPart) const
protected

Check if a given particle is within the acceptance (pt+eta)

Definition at line 191 of file EtaPtFilterTool.cxx.

192{
193 if ( ! mc ) {
194 return false;
195 }
196
197 if ( m_butKeepAllGeneratorStable.value() ) {
198 // static IsGenStable isStable;
199 if ( MC::isStable(mc) ) {
200 return true;
201 }
202 }
203
204 if ( m_onlyGenerator.value() ) {
205 // helper class to know if a GenParticle has been produced at Generator
206 // level. ie: not at simulation level (Geant4)
207
209 return false;
210 }
211 }
212
213 if ( m_keepDocumentaries.value() ) {
214 if ( !MC::isPhysical(mc) ) {
215 return true;
216 }
217 }
218
219 // Skip kinematic cuts for leptons
220 if ( m_keepAllLeptons.value() ) {
221 if ( MC::isLepton(mc) ) {
222 return true;
223 }
224 }
225
226 const HepMC::FourVector hlv = mc->momentum();
227 const double pt = hlv.perp();
228 const double eta = hlv.pseudoRapidity();
229 if ( ( std::abs( eta ) >= m_innerEtaRegionCuts.value()[0] &&
230 std::abs( eta ) < m_innerEtaRegionCuts.value()[1] &&
231 pt > m_innerEtaRegionCuts.value()[2] )
232
233 ||
234
235 ( std::abs( eta ) >= m_outerEtaRegionCuts.value()[0] &&
236 std::abs( eta ) < m_outerEtaRegionCuts.value()[1] &&
237 pt > m_outerEtaRegionCuts.value()[2] ) ) {
238 return true;
239 } else {
240 return false;
241 }
242}
Scalar eta() const
pseudorapidity method
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...
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isLepton(const T &p)
APID: the fourth generation leptons are leptons.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.

◆ isAccepted() [2/2]

bool EtaPtFilterTool::isAccepted ( const HepMC::ConstGenVertexPtr & vtx) const
protected

Check if a given vertex has at least one in-going or out-going particle within the acceptance (pt+eta)

Definition at line 244 of file EtaPtFilterTool.cxx.

245{
246 if ( !vtx ) {
247 return false;
248 }
249
250 // check if this vertex looks like a vertex from the hard-scattering
251 if ( isFromHardScattering(vtx) ) {
252 return true;
253 }
254
255 // check if this vertex matches some decay pattern given
256 // to the McVtxFilterTool
257 if ( m_mcVtxFilterTool->isAccepted(vtx) ) {
258 return true;
259 }
260
261 // ///////////////////////////////////////////////////////////////////////
262 // Now we check if at least one in- or out-going particle can be accepted.
263 // If yes, then we accept the entire vertex
264 //
265#ifdef HEPMC3
266 // check the parent branch
267 for ( const auto& p: vtx->particles_in() ) {
268 if ( isAccepted(p) ) {
269 return true;
270 }
271 }//> end loop over parents
272#else
273 // check the parent branch
274 for ( HepMC::GenVertex::particles_in_const_iterator
275 p = vtx->particles_in_const_begin(),
276 pEnd = vtx->particles_in_const_end();
277 p != pEnd;
278 ++p ) {
279 if ( isAccepted(*p) ) {
280 return true;
281 }
282 }//> end loop over parents
283#endif
284
285 // check the child branch
286 for ( auto p : *vtx) {
287 if ( isAccepted(p) ) {
288 return true;
289 }
290 }//> end loop over children
291
292 return false;
293}
bool isFromHardScattering(const HepMC::ConstGenVertexPtr &vtx) const

◆ isFromHardScattering()

bool EtaPtFilterTool::isFromHardScattering ( const HepMC::ConstGenVertexPtr & vtx) const
protected

Definition at line 441 of file EtaPtFilterTool.cxx.

442{
443 int partonsin = 0;
444 int showerout = 0;
445#ifdef HEPMC3
446 for (auto& p: vtx->particles_in()) if (MC::isQuark(p) || MC::isGluon(p)) partonsin++;
447#else
448 for (auto p = vtx->particles_in_const_begin();p!=vtx->particles_in_const_end();++p ) if (MC::isQuark(*p) || MC::isGluon(*p)) partonsin++;
449#endif
450 for (auto& p: *vtx) if (p->pdg_id() == 91||p->pdg_id() == 92||p->pdg_id() == 94) showerout++;
451
452 return isPartonVertex(vtx) && (partonsin >= 2) && (showerout == 0);
453}
bool isPartonVertex(const HepMC::ConstGenVertexPtr &vtx) const
bool isQuark(const T &p)
PDG rule 2: Quarks and leptons are numbered consecutively starting from 1 and 11 respectively; to do ...
bool isGluon(const T &p)

◆ isPartonVertex()

bool EtaPtFilterTool::isPartonVertex ( const HepMC::ConstGenVertexPtr & vtx) const
protected

Definition at line 417 of file EtaPtFilterTool.cxx.

418{
419 if (!vtx) return false;
420#ifdef HEPMC3
421 for (auto& p: vtx->particles_in()) {
422 if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
423 auto pv = p->production_vertex();
424 if (pv && !isPartonVertex(pv)) return false;
425 }
426 for (auto& p: vtx->particles_out()) {
427 if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
428 }
429#else
430 for ( auto p = vtx->particles_in_const_begin(), parentEnd = vtx->particles_in_const_end(); p != parentEnd; ++p ) {
431 if (MC::isHadron(*p)&&!MC::isBeam(*p)) return false;
432 auto pv = (*p)->production_vertex();
433 if (pv && !isPartonVertex(pv)) return false;
434}
435for ( auto p = vtx->particles_out_const_begin(), parentEnd = vtx->particles_out_const_end(); p != parentEnd; ++p ) {
436 if (MC::isHadron(*p)&&!MC::isBeam(*p)) return false;
437 }
438#endif
439 return true;
440}
bool isBeam(const T &p)
Identify if the particle is beam particle.
bool isHadron(const T &p)

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ 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.

◆ 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();
384 }
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)

◆ 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 {
366 }

◆ setupInnerEtaRegionCuts()

void EtaPtFilterTool::setupInnerEtaRegionCuts ( Gaudi::Details::PropertyBase & innerEtaRegionCuts)
protected

Callback function to setup the "InnerEtaRegionCuts" property.

Definition at line 497 of file EtaPtFilterTool.cxx.

498{
499 return;
500}

◆ setupOuterEtaRegionCuts()

void EtaPtFilterTool::setupOuterEtaRegionCuts ( Gaudi::Details::PropertyBase & outerEtaRegionCuts)
protected

Callback function to setup the "OuterEtaRegionCuts" property.

Definition at line 502 of file EtaPtFilterTool.cxx.

503{
504 return;
505}

◆ 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 asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_butKeepAllGeneratorStable

BooleanProperty EtaPtFilterTool::m_butKeepAllGeneratorStable
protected

Switch to keep all stable generator particles (IsGenStable) regardless what eta or pt cuts are defined.

Definition at line 136 of file EtaPtFilterTool.h.

◆ 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_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_innerEtaRegionCuts

DoubleArrayProperty EtaPtFilterTool::m_innerEtaRegionCuts
protected

vector of cuts parameters for the inner region delimited in |eta| 0-th element is the minimum |eta| of this region 1-st element is the maximum |eta| of this region 2-nd element is the minimum pt for the stable particles to be accepted

Definition at line 119 of file EtaPtFilterTool.h.

◆ m_isol_energies

std::map<int,double> EtaPtFilterTool::m_isol_energies
protected

Definition at line 149 of file EtaPtFilterTool.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_keepAllLeptons

BooleanProperty EtaPtFilterTool::m_keepAllLeptons
protected

Switch to keep all leptons - i.e.

do not apply kinematic cuts on them

Definition at line 145 of file EtaPtFilterTool.h.

◆ m_keepDocumentaries

BooleanProperty EtaPtFilterTool::m_keepDocumentaries
protected

Switch to keep all generator particles which are documentaries (statuscode == 3)

Definition at line 141 of file EtaPtFilterTool.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.

104{this,"McEventsOutput","GEN_AOD","WriteHandleKey for the output McEventCollection which has been filtered"};

◆ 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.

100{this,"McEvents","TruthEvent","ReadHandleKey for input McEventCollection one wants to filter"};

◆ 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_onlyGenerator

BooleanProperty EtaPtFilterTool::m_onlyGenerator
protected

Switch to only include particles from generation and reject particles from detector simulation (Geant4)

Definition at line 131 of file EtaPtFilterTool.h.

◆ m_outerEtaRegionCuts

DoubleArrayProperty EtaPtFilterTool::m_outerEtaRegionCuts
protected

vector of cuts parameters for the outer region delimited in |eta| 0-th element is the minimum |eta| of this region 1-st element is the maximum |eta| of this region 2-nd element is the minimum pt for the stable particles to be accepted

Definition at line 126 of file EtaPtFilterTool.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: