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*,
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19

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*,
HepMC3::GenVertexPtr GenVertexPtr
Definition GenVertex.h:23

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 277 of file EtaPtFilterTool.cxx.

281{
282 if ( 0 == srcVtx || 0 == evt ) {
283 ATH_MSG_ERROR("In addVertex(vtx,evt) : INVALID pointer given !!" << endmsg << " vtx: " << srcVtx << endmsg << " evt: " << evt);
284 return StatusCode::FAILURE;
285 }
286 HepMC::GenVertexPtr& vtx = vmap[srcVtx.get()];
287 if ( !vtx ) {
289 evt->add_vertex(vtx);
290 vtx->set_position( srcVtx->position() );
291 vtx->set_status( srcVtx->status() );
293 vtx->add_attribute(HepMCStr::weights,srcVtx->attribute<HepMC3::VectorDoubleAttribute> (HepMCStr::weights));
294 if (isSignalVertex) HepMC::set_signal_process_vertex(evt,vtx);
295 }
298 for ( auto parent: srcVtx->particles_in()) {
299 HepMC::GenParticlePtr& p = pmap[parent.get()];
300 if ( !p ) {
302 vtx->add_particle_in( p );
303 p->set_momentum( parent->momentum() );
304 p->set_generated_mass( parent->generated_mass() );
305 p->set_pdg_id( parent->pdg_id() );
306 p->set_status( parent->status() );
307 HepMC::set_flow(p, HepMC::flow(parent) );
310 }
311 // set the mother's decay to our (new) vertex
312 vtx->add_particle_in( p );
313
314 }//> loop over ingoing particles
315
318 for (auto child: srcVtx->particles_out()) {
319 HepMC::GenParticlePtr& p = pmap[child.get()];
320 if ( !p ) {
322 vtx->add_particle_out( p );
323 p->set_momentum( child->momentum() );
324 p->set_generated_mass( child->generated_mass() );
325 p->set_pdg_id( child->pdg_id() );
326 p->set_status( child->status() );
327 HepMC::set_flow(p, HepMC::flow(child) );
330 }
331 // set the daughter's production vertex to our new vertex
332 vtx->add_particle_out( p );
333 }//> loop over outgoing particles
334
335
336 return StatusCode::SUCCESS;
337}
#define endmsg
#define ATH_MSG_ERROR(x)
const std::string weights
void set_polarization(T &a, const Polarization &b)
void set_flow(T &a, Flow fl)
Definition Flow.h:43
int barcode(const T *p)
Definition Barcode.h:15
void set_signal_process_vertex(GenEvent *e, T &v)
Definition GenEvent.h:591
GenParticlePtr newGenParticlePtr(const HepMC3::FourVector &mom=HepMC3::FourVector::ZERO_VECTOR(), int pid=0, int status=0)
Definition GenParticle.h:21
bool suggest_barcode(T &p, int i)
Definition GenEvent.h:607
Polarization polarization(const T &a)
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
Definition GenVertex.h:25
int flow(const HepMC3::GenParticlePtr &p, int i)
Definition Flow.h:13

◆ 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 for ( auto vtx: in->vertices() ) {
169 bool isSignalVertex = (vtx == spv);
170 if ( !isAccepted(vtx) && !isSignalVertex ) {
171 // no in-going nor out-going particles at this vertex matches
172 // the requirements nor it is a signal process vertex : ==> Skip it
173 continue;
174 }
175
176 if ( addVertex( vtx, out, vmap, pmap, isSignalVertex ).isFailure() )
177 {
178 ATH_MSG_WARNING("Could not add vertex " << vtx );
179 }
180
181 } //> end loop over vertices
182
183 return StatusCode::SUCCESS;
184}
#define ATH_MSG_WARNING(x)
std::unordered_map< const HepMC::GenVertex *, HepMC::GenVertexPtr > VertexMap_t
std::unordered_map< const HepMC::GenParticle *, HepMC::GenParticlePtr > ParticleMap_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.
ConstGenVertexPtr signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:597

◆ 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 }
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:369
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
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 366 of file EtaPtFilterTool.cxx.

367{
368 ATH_MSG_INFO("Initializing " << name() << "...");
369
370 // make sure the properties are synchronised
373
374 if ( m_innerEtaRegionCuts.value().size() != 3 ||
375 m_outerEtaRegionCuts.value().size() != 3 ) {
377 ("Wrong size for eta regions cut :" << endmsg
378 << "\tinner region: " << m_innerEtaRegionCuts.value().size()
379 << endmsg
380 << "\touter region: " << m_outerEtaRegionCuts.value().size()
381 << endmsg
382 << "You have to provide a list of cuts of the form : " << endmsg
383 << " |etaMin| |etaMax| ptMin");
384 return StatusCode::FAILURE;
385 }
386
388 ("Inner Eta region cuts : nCuts = "
389 << m_innerEtaRegionCuts.value().size()
390 << endmsg
391 << "\tetaMin = " << m_innerEtaRegionCuts.value()[0] << endmsg
392 << "\tetaMax = " << m_innerEtaRegionCuts.value()[1] << endmsg
393 << "\tPtMin = " << m_innerEtaRegionCuts.value()[2] << endmsg
394 << "Outer Eta region cuts : nCuts = "
395 << m_outerEtaRegionCuts.value().size()
396 << endmsg
397 << "\tetaMin = " << m_outerEtaRegionCuts.value()[0] << endmsg
398 << "\tetaMax = " << m_outerEtaRegionCuts.value()[1] << endmsg
399 << "\tPtMin = " << m_outerEtaRegionCuts.value()[2]);
400
401 return StatusCode::SUCCESS;
402}

◆ 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 186 of file EtaPtFilterTool.cxx.

187{
188 if ( ! mc ) {
189 return false;
190 }
191
192 if ( m_butKeepAllGeneratorStable.value() ) {
193 // static IsGenStable isStable;
194 if ( MC::isStable(mc) ) {
195 return true;
196 }
197 }
198
199 if ( m_onlyGenerator.value() ) {
200 // helper class to know if a GenParticle has been produced at Generator
201 // level. ie: not at simulation level (Geant4)
202
204 return false;
205 }
206 }
207
208 if ( m_keepDocumentaries.value() ) {
209 if ( !MC::isPhysical(mc) ) {
210 return true;
211 }
212 }
213
214 // Skip kinematic cuts for leptons
215 if ( m_keepAllLeptons.value() ) {
216 if ( MC::isLepton(mc) ) {
217 return true;
218 }
219 }
220
221 const HepMC::FourVector hlv = mc->momentum();
222 const double pt = hlv.perp();
223 const double eta = hlv.pseudoRapidity();
224 if ( ( std::abs( eta ) >= m_innerEtaRegionCuts.value()[0] &&
225 std::abs( eta ) < m_innerEtaRegionCuts.value()[1] &&
226 pt > m_innerEtaRegionCuts.value()[2] )
227
228 ||
229
230 ( std::abs( eta ) >= m_outerEtaRegionCuts.value()[0] &&
231 std::abs( eta ) < m_outerEtaRegionCuts.value()[1] &&
232 pt > m_outerEtaRegionCuts.value()[2] ) ) {
233 return true;
234 } else {
235 return false;
236 }
237}
Scalar eta() const
pseudorapidity method
HepMC3::FourVector FourVector
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 239 of file EtaPtFilterTool.cxx.

240{
241 if ( !vtx ) {
242 return false;
243 }
244
245 // check if this vertex looks like a vertex from the hard-scattering
246 if ( isFromHardScattering(vtx) ) {
247 return true;
248 }
249
250 // check if this vertex matches some decay pattern given
251 // to the McVtxFilterTool
252 if ( m_mcVtxFilterTool->isAccepted(vtx) ) {
253 return true;
254 }
255
256 // ///////////////////////////////////////////////////////////////////////
257 // Now we check if at least one in- or out-going particle can be accepted.
258 // If yes, then we accept the entire vertex
259 //
260 // check the parent branch
261 for ( const auto& p: vtx->particles_in() ) {
262 if ( isAccepted(p) ) {
263 return true;
264 }
265 }//> end loop over parents
266
267 // check the child branch
268 for ( auto p : *vtx) {
269 if ( isAccepted(p) ) {
270 return true;
271 }
272 }//> end loop over children
273
274 return false;
275}
bool isFromHardScattering(const HepMC::ConstGenVertexPtr &vtx) const

◆ isFromHardScattering()

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

Definition at line 352 of file EtaPtFilterTool.cxx.

353{
354 int partonsin = 0;
355 int showerout = 0;
356 for (auto& p: vtx->particles_in()) if (MC::isQuark(p) || MC::isGluon(p)) partonsin++;
357 for (auto& p: *vtx) if (p->pdg_id() == 91||p->pdg_id() == 92||p->pdg_id() == 94) showerout++;
358
359 return isPartonVertex(vtx) && (partonsin >= 2) && (showerout == 0);
360}
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 339 of file EtaPtFilterTool.cxx.

340{
341 if (!vtx) return false;
342 for (auto& p: vtx->particles_in()) {
343 if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
344 auto pv = p->production_vertex();
345 if (pv && !isPartonVertex(pv)) return false;
346 }
347 for (auto& p: vtx->particles_out()) {
348 if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
349 }
350 return true;
351}
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 404 of file EtaPtFilterTool.cxx.

405{
406 return;
407}

◆ setupOuterEtaRegionCuts()

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

Callback function to setup the "OuterEtaRegionCuts" property.

Definition at line 409 of file EtaPtFilterTool.cxx.

410{
411 return;
412}

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

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