ATLAS Offline Software
Loading...
Searching...
No Matches
TruthParticleFilterBaseTool Class Referenceabstract

#include <TruthParticleFilterBaseTool.h>

Inheritance diagram for TruthParticleFilterBaseTool:
Collaboration diagram for TruthParticleFilterBaseTool:

Public Member Functions

 TruthParticleFilterBaseTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
virtual ~TruthParticleFilterBaseTool ()
 Destructor:
StatusCode initialize ()
 Athena Algorithm's Hooks.
StatusCode execute ()
StatusCode finalize ()
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 strategy implemented by the concrete tool.
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

typedef ToolHandle< IMcVtxFilterToolMcVtxFilterTool_t
typedef ToolHandle< ITruthIsolationToolIsolTool_t

Protected Member Functions

 TruthParticleFilterBaseTool ()
 Default constructor:
virtual StatusCode initializeTool ()
 I/O operators.
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

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 31 of file TruthParticleFilterBaseTool.h.

Member Typedef Documentation

◆ IsolTool_t

Definition at line 80 of file TruthParticleFilterBaseTool.h.

◆ McVtxFilterTool_t

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

◆ TruthParticleFilterBaseTool() [1/2]

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

Constructor with parameters:

Public methods:

Constructors

Definition at line 25 of file TruthParticleFilterBaseTool.cxx.

27 :
28 AthAlgTool( type, name, parent )
29{
30 //
31 // Property declaration
32 //
33
34 declareProperty( "McVtxFilterTool",
35 m_mcVtxFilterTool = McVtxFilterTool_t( "McVtxFilterTool",
36 this ),
37 "Pointer to the McVtxFilterTool to be able to select additional "
38 "vertices on some decay pattern(s) criterion(s)" );
39
40 declareProperty( "TruthIsolationTool",
41 m_isolationTool = IsolTool_t( "TruthIsolationTool" ),
42 "Pointer to the TruthIsolationTool to be able to compute "
43 "transverse energy isolations for various isolation cones cuts. "
44 "See McParticleEvent/TruthParticleParameters.h for cone cuts." );
45
46
47 declareProperty( "DoEtIsolations",
48 m_doEtIsolation = false,
49 "Switch to compute or not the Et-isolations for TruthParticle "
50 "(and their underlying @c HepMC::GenParticle).\n"
51 "Default is to not compute these Et-isolations (and save CPU)." );
52
53 declareInterface<ITruthParticleFilterTool>(this);
54}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
McVtxFilterTool_t m_mcVtxFilterTool
Pointer to the McVtxFilterTool to be able to select additional vertices on some decay pattern criteri...
ToolHandle< ITruthIsolationTool > IsolTool_t
BooleanProperty m_doEtIsolation
Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle...
ToolHandle< IMcVtxFilterTool > McVtxFilterTool_t
IsolTool_t m_isolationTool
Pointer to the TruthIsolationTool to be able to compute transverse energy isolations for various isol...

◆ ~TruthParticleFilterBaseTool()

TruthParticleFilterBaseTool::~TruthParticleFilterBaseTool ( )
virtual

Destructor:

Destructor.

Definition at line 58 of file TruthParticleFilterBaseTool.cxx.

59{
60 ATH_MSG_DEBUG("Calling destructor");
61}
#define ATH_MSG_DEBUG(x)

◆ TruthParticleFilterBaseTool() [2/2]

TruthParticleFilterBaseTool::TruthParticleFilterBaseTool ( )
protected

Default constructor:

Member Function Documentation

◆ buildMcAod()

virtual StatusCode ITruthParticleFilterTool::buildMcAod ( const McEventCollection * in,
McEventCollection * filtered )
pure virtualinherited

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

It is not const to allow derived tools to build statistics during the filtering process.

Implemented in EtaPtFilterTool, NoopFilterTool, OldSpclMcFilterTool, and PileupFilterTool.

◆ 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 ( )
virtual

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_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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 ...
SG::ReadHandleKey< McEventCollection > m_mcEventsReadHandleKey
ReadHandleKey for the input McEventCollection one wants to filter.
SG::WriteHandleKey< McEventCollection > m_mcEventsOutputWriteHandleKey
Location of the output McEventCollection which has been filtered.

◆ 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 ( )
virtual

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)

◆ finalizeTool()

StatusCode TruthParticleFilterBaseTool::finalizeTool ( )
inlineprotectedvirtual

Definition at line 124 of file TruthParticleFilterBaseTool.h.

125{
126 return StatusCode::SUCCESS;
127}

◆ initialize()

StatusCode TruthParticleFilterBaseTool::initialize ( )
virtual

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

◆ initializeTool()

StatusCode TruthParticleFilterBaseTool::initializeTool ( )
inlineprotectedvirtual

I/O operators.

Inline methods:

Reimplemented in EtaPtFilterTool, OldSpclMcFilterTool, and PileupFilterTool.

Definition at line 117 of file TruthParticleFilterBaseTool.h.

118{
119 return StatusCode::SUCCESS;
120}

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

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

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

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_isolationTool

IsolTool_t TruthParticleFilterBaseTool::m_isolationTool
protected

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"}
protected

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"}
protected

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
protected

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