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

AlgTool which filters an input McEventCollection and outputs a new one from the decay patterns it has been setup with. More...

#include <McVtxFilterTool.h>

Inheritance diagram for McVtxFilterTool:
Collaboration diagram for McVtxFilterTool:

Classes

struct  VtxType

Public Member Functions

 McVtxFilterTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
virtual ~McVtxFilterTool ()
 Destructor:
virtual StatusCode initialize ()
 Athena Algorithm's Hooks.
virtual StatusCode execute ()
void displayOptions () const
 Display the decay pattern of each McVtxFilter this Tool is embedding.
void stats () const
 Display the statistics for each McVtxFilter this Tool is embedding.
virtual bool isAccepted (const HepMC::ConstGenVertexPtr &vtx) const
 Return true if one of the McVtxFilters accept this GenVertex.
virtual void filterMcEventCollection (const McEventCollection *mcCollection, McEventCollection *filterColl)
 Filter the McEventCollection according to the list of McVtxFilter embedded in this AlgTool, and fill the output McEventCollection.
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 ()
 I/O operators.

Protected Member Functions

 McVtxFilterTool ()
 Default constructor:
void addVertex (const HepMC::ConstGenVertexPtr &vtx, HepMC::GenEvent *evt, const VtxType::Flag vtxType=VtxType::IsNotRootVertex, bool isSignal=false) const
 Add the vertex to the event : nothing very special, just to factorize code Input GenVertex is const because we add a copy of it to the GenEvent.
bool keepParticle (const VtxType::Flag vtxType, const HepMC::ConstGenParticlePtr &p) const
 Helper function: return true if we are at a root vertex (i.e., a vertex that satisfies one of the chosen decay modes) and if the PDG of the particle is in the m_particles list (or the m_particle list is empty).
void setupFilters (Gaudi::Details::PropertyBase &decayPatterns)
 Callback method to ensure consistency of filters.
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

StringProperty m_mcEventsName
 Location of the McEventCollection to be filtered.
StringProperty m_mcEventsOutputName
 Output McEventCollection location (filtered from the McEventCollection).
StringArrayProperty m_decayPatterns
 Patterns of the decays to look for (ex: "23 -> -5 + 5" ).
BooleanArrayProperty m_matchSigns
 Booleans to setup each of the McVtxFilter::matchSign.
BooleanArrayProperty m_matchBranches
 Booleans to setup each of the McVtxFilter::matchBranch.
DataVector< McVtxFilterm_filters
 Filters.
std::vector< double > m_counter
 Stores the total number of filtered vertices for each McVtxFilter.
BooleanProperty m_doSignalProcessVtx
 Switch to include or not the signal_process_vertex into the McEventCollection (default = true).
BooleanProperty m_fillTree
 Switch to fill the entire tree from a decay vertex.
LongArrayProperty m_particles
 List of outgoing particles from the decay vertex to include.

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

AlgTool which filters an input McEventCollection and outputs a new one from the decay patterns it has been setup with.

The decay patterns describe the decay vertices one is looking for and are modeled via a simple std::string. One can specify multiple decay patterns and modify them at the jobOption level via the property "DecayPatterns". One can also explicitly specify to record the signal process vertex of the input McEventCollection into the new one, even if it does not satisfy a single decay pattern in the list of decay vertices to look for.

Note that the real work of the filtering is performed by the McVtxFilter class which is located in the AnalysisUtils package.

Added new properties:

  • "FillTree" jobOption allows one to save the HepMC tree of outgoing
    particles from decay vertices chosen by the "DecayPatterns" jobOption.
  • "KeepParticles" specifies PDG codes of outgoing particles to keep from
    decay vertices specified by "DecayPatterns".

ex. suppose have processes like:
u + ubar -> gluon(->jet(s)) + photon(->e+/e- + bremsstrahlung photons)

and want to filter out only the jet(s) from the gluon. Use these jobOptions

DecayPatterns = [ "-2+2 -> 21 + 22" ] # select the process
ParticlesToKeep = [ 21 ] # only keep outgoing gluon
FillTree = True # keep all decay products of the gluon
#define True
const std::string process

Definition at line 71 of file McVtxFilterTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ McVtxFilterTool() [1/2]

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

Constructor with parameters:

Constructors.

Definition at line 30 of file McVtxFilterTool.cxx.

32 :
33 AthAlgTool( type, name, parent )
34{
35 //
36 // Property declaration
37 //
38
39 declareProperty( "McEvents",
40 m_mcEventsName = "TruthEvent",
41 "Location of the McEventCollection to be filtered" );
42
43 declareProperty( "McEventsOutput",
44 m_mcEventsOutputName = "GEN_AOD",
45 "Output McEventCollection location (filtered from the "
46 "McEventCollection)" );
47
48 declareProperty( "DecayPatterns",
50 "List of decay patterns the tool will try to match. \n\t"
51 "ex: 23 -> -5 + 5 to select Z bosons into bbbar pairs" );
52
53 m_decayPatterns.declareUpdateHandler( &McVtxFilterTool::setupFilters,
54 this );
55
56 declareProperty( "MatchSigns",
58 "List of booleans with which the tool will setup "
59 "McVtxFilters. This will setup the McVtxFilter::matchSign "
60 "data member." );
61 m_matchSigns.declareUpdateHandler( &McVtxFilterTool::setupFilters,
62 this );
63
64 declareProperty( "MatchBranches",
66 "List of booleans with which the tool will setup "
67 "McVtxFilters. This will setup the "
68 "McVtxFilter::matchBranches data member." );
69
70 m_matchBranches.declareUpdateHandler( &McVtxFilterTool::setupFilters,
71 this );
72
73 declareProperty( "DoSignalProcessVtx",
75 "Switch to include or not the signal_process_vertex into "
76 "the McEventCollection (default = true).\n"
77 "Note that this is close to useless as the HEPEVT structure"
78 " does not hold this kind of informations..." );
79
80 declareProperty( "FillTree",
81 m_fillTree = false,
82 "Switch to fill the entire decay tree from a decay "
83 "vertex.\n"
84 "This can be usefull to record for example the whole shower "
85 "from a gluon or a quark. In that case, you may want to add "
86 "the according PDG ids into the list of particles to keep" );
87
88 declareProperty( "ParticlesToKeep",
90 "List of outgoing particles from the decay vertex to "
91 "include. This property has to be configured in sync. with "
92 "the 'FillTree' one." );
93
94 declareInterface<IMcVtxFilterTool>(this);
95}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StringProperty m_mcEventsName
Location of the McEventCollection to be filtered.
BooleanArrayProperty m_matchSigns
Booleans to setup each of the McVtxFilter::matchSign.
StringArrayProperty m_decayPatterns
Patterns of the decays to look for (ex: "23 -> -5 + 5" ).
void setupFilters(Gaudi::Details::PropertyBase &decayPatterns)
Callback method to ensure consistency of filters.
BooleanProperty m_doSignalProcessVtx
Switch to include or not the signal_process_vertex into the McEventCollection (default = true).
LongArrayProperty m_particles
List of outgoing particles from the decay vertex to include.
BooleanArrayProperty m_matchBranches
Booleans to setup each of the McVtxFilter::matchBranch.
BooleanProperty m_fillTree
Switch to fill the entire tree from a decay vertex.
StringProperty m_mcEventsOutputName
Output McEventCollection location (filtered from the McEventCollection).

◆ ~McVtxFilterTool()

McVtxFilterTool::~McVtxFilterTool ( )
virtual

Destructor:

Destructor.

Definition at line 99 of file McVtxFilterTool.cxx.

100{
101 ATH_MSG_DEBUG("Calling destructor");
102}
#define ATH_MSG_DEBUG(x)

◆ McVtxFilterTool() [2/2]

McVtxFilterTool::McVtxFilterTool ( )
protected

Default constructor:

Member Function Documentation

◆ addVertex()

void McVtxFilterTool::addVertex ( const HepMC::ConstGenVertexPtr & vtx,
HepMC::GenEvent * evt,
const VtxType::Flag vtxType = VtxType::IsNotRootVertex,
bool isSignal = false ) const
protected

Add the vertex to the event : nothing very special, just to factorize code Input GenVertex is const because we add a copy of it to the GenEvent.

The last parameter is used here to add (or not) the whole decay tree at a given vertex. (Default: just add the vertex, not the whole tree of children)

Fill the parent branch

Fill the children branch

Definition at line 253 of file McVtxFilterTool.cxx.

256{
257 ATH_MSG_VERBOSE("In McVtxFilterTool::addVertex( vtxType= "<<vtxType<< " )");
258 HepMC::GenVertexPtr vtx = (evt == srcVtx->parent_event()) ? std::const_pointer_cast<HepMC3::GenVertex>(srcVtx) : nullptr ;
259 if ( !vtx ) {
261 evt->add_vertex(vtx);
262 vtx->set_position( srcVtx->position() );
263 vtx->set_status( srcVtx->status() );
265 vtx->add_attribute(HepMCStr::weights,srcVtx->attribute<HepMC3::VectorDoubleAttribute> (HepMCStr::weights));
266 }
267 if (isSignal) HepMC::set_signal_process_vertex(evt, vtx );
269 for ( const auto& parent: srcVtx->particles_in()) {
270 HepMC::GenParticlePtr mother = (evt == parent->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(parent) : nullptr ;
271 if ( ! mother ) {
272 mother = HepMC::newGenParticlePtr();
273 vtx->add_particle_in( mother );
274 mother->set_momentum( parent->momentum() );
275 mother->set_generated_mass( parent->generated_mass() );
276 mother->set_pdg_id( parent->pdg_id() );
277 mother->set_status( parent->status() );
278 HepMC::set_flow(mother, HepMC::flow(parent) );
280 HepMC::suggest_barcode(mother,HepMC::barcode(parent) );
281
282 } else {
283 // set the mother's decay to our (new) vertex
284 vtx->add_particle_in( std::move(mother) );
285 }
286 }//> loop over ingoing particles
287
289 for ( const auto& child: srcVtx->particles_out()) {
290 HepMC::GenParticlePtr daughter = (evt == child->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(child) : nullptr ;
291 if ( !daughter ) {
292 if ( !keepParticle( vtxType, child ) ) {
293 // only include selected particles via the "ParticlesToKeep" property
294 ATH_MSG_VERBOSE("Skipping outgoing particle id|particle: ["
295 << child->pdg_id() << "|"
296 << child << "]");
297 } else {
298 daughter = HepMC::newGenParticlePtr();
299 // set the daughter's production vertex to our new vertex
300 vtx->add_particle_out( daughter );
301 daughter->set_momentum( child->momentum() );
302 daughter->set_generated_mass( child->generated_mass() );
303 daughter->set_pdg_id( child->pdg_id() );
304 daughter->set_status( child->status() );
305 HepMC::set_flow(daughter, HepMC::flow(child) );
307 HepMC::suggest_barcode(daughter,HepMC::barcode(child) );
308
309 }
310 }
311
312 if ( m_fillTree && keepParticle( vtxType, child ) ) {
313 auto decayVertex = child->end_vertex();
314 if ( decayVertex ) {
315 // recursively fill the tree with all decay vertices and final state
316 // particles of selected outgoing particles lines
317 // => We are no longer sitting at the decay vertex so we tell it
318 // via the IsNotRootVertex flag
319 addVertex( decayVertex, evt, VtxType::IsNotRootVertex );
320 }
321 }
322 }//> loop over outgoing particles
323
324
325 }
#define ATH_MSG_VERBOSE(x)
bool keepParticle(const VtxType::Flag vtxType, const HepMC::ConstGenParticlePtr &p) const
Helper function: return true if we are at a root vertex (i.e., a vertex that satisfies one of the cho...
void addVertex(const HepMC::ConstGenVertexPtr &vtx, HepMC::GenEvent *evt, const VtxType::Flag vtxType=VtxType::IsNotRootVertex, bool isSignal=false) const
Add the vertex to the event : nothing very special, just to factorize code Input GenVertex is const b...
int flow(const T &p, int i)
Definition Flow.h:15
void set_polarization(T &a, const Polarization &b)
void set_flow(T &a, Flow fl)
Definition Flow.h:31
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)
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
Definition GenVertex.h:25
HepMC3::GenVertexPtr GenVertexPtr
Definition GenVertex.h:23

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

◆ displayOptions()

void McVtxFilterTool::displayOptions ( ) const
virtual

Display the decay pattern of each McVtxFilter this Tool is embedding.

Implements IMcVtxFilterTool.

Definition at line 153 of file McVtxFilterTool.cxx.

154{
155 msg(MSG::INFO)
156 << "Options for " << name() << " :" << endmsg
157 << "\tDecay Patterns: [ ";
158 for (const auto & itr : m_decayPatterns.value()) {
159 msg(MSG::INFO) << itr << "; ";
160 }
161 msg(MSG::INFO) << "]" << endmsg;
162
163 msg(MSG::INFO) << "Particles to keep: [";
164 for (long itr : m_particles.value()) {
165 msg(MSG::INFO) << itr << ", ";
166 }
167 msg(MSG::INFO) << "]" << endmsg;
168}
#define endmsg
MsgStream & msg() const

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

Implements IMcVtxFilterTool.

Definition at line 121 of file McVtxFilterTool.cxx.

122{
123 StatusCode sc = StatusCode::SUCCESS;
124
125 ATH_MSG_DEBUG("Executing " << name() << "...");
126
127 ATH_MSG_VERBOSE("Retrieve the McEventCollection to be filtered for");
128 const McEventCollection * mcColl = nullptr;
129 sc = evtStore()->retrieve( mcColl, m_mcEventsName );
130
131 if ( sc.isFailure() || nullptr == mcColl ) {
132 msg(MSG::ERROR)
133 << "Failed to retrieve McEventCollection at : "
135 << endmsg
136 << "because : sc= " << ( sc.isFailure() ? "FAILURE" : "OK" )
137 << " and mcEvent= " << mcColl
138 << endmsg;
139 return StatusCode::SUCCESS;
140 }
141
142 ATH_MSG_VERBOSE("Create a new McEventCollection which will hold the "\
143 "filtered GenEvent");
144 McEventCollection * filteredColl = new McEventCollection;
145 sc = evtStore()->record(filteredColl, m_mcEventsOutputName, true);
146 sc = evtStore()->setConst(filteredColl);
147 ATH_MSG_VERBOSE("Recorded and locked in StoreGate");
148
149 filterMcEventCollection( mcColl, filteredColl );
150 return sc;
151}
static Double_t sc
ServiceHandle< StoreGateSvc > & evtStore()
virtual void filterMcEventCollection(const McEventCollection *mcCollection, McEventCollection *filterColl)
Filter the McEventCollection according to the list of McVtxFilter embedded in this AlgTool,...
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ 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

◆ filterMcEventCollection()

void McVtxFilterTool::filterMcEventCollection ( const McEventCollection * mcCollection,
McEventCollection * filterColl )
virtual

Filter the McEventCollection according to the list of McVtxFilter embedded in this AlgTool, and fill the output McEventCollection.

Create a set with ids of copied vertices.

Local copy of the GenEvent from StoreGate

Create the event container, with Signal Process and event number from the GenEvent source

Handling the signal_process_vertex stuff Signal_process_vertex pointer is not set by all generators, but in case it has been set up, one should keep this usefull information, shouldn't we ? So first we check it is present in the original GenEvent, and then we check if it as not already added by any previous McVtxFilter (by chance or because it was just meant to be)

Implements IMcVtxFilterTool.

Definition at line 192 of file McVtxFilterTool.cxx.

194{
195 if ( nullptr == mcColl ) {
196 ATH_MSG_ERROR("McEventCollection is NULL pointer !!");
197 return;
198 }
199
201 std::set<int> bcToFullVtx;
202
204 const HepMC::GenEvent * evtSrc = (*mcColl->begin());
205
209 for ( const auto& itrPart: *evtSrc) {
210 auto dcyVtx = itrPart->end_vertex();
211 if ( !dcyVtx ) continue;
212 int vtxBC = HepMC::uniqueID(dcyVtx);
213 if (bcToFullVtx.count(vtxBC)!=0) continue;
214 ATH_MSG_VERBOSE("Doing vtx: " << dcyVtx);
215
216 int i = 0;
217 for( DataVector<McVtxFilter>::const_iterator filter = m_filters.begin(); filter != m_filters.end(); ++filter,++i ) {
218 ATH_MSG_VERBOSE("Processing with filter[" << i << "]...");
219 if ( !(*filter)->isAccepted( dcyVtx ) ) continue;
220 m_counter[i] += 1;
221 ATH_MSG_VERBOSE("Filter[" << i << "] accepted this vtx : " << dcyVtx);
222 bcToFullVtx.insert(vtxBC);
223 addVertex( dcyVtx, evt, VtxType::IsRootVertex );
224 break;
225 }//> end loop over filters
226 }//> loop over particles
227
228 if ( m_doSignalProcessVtx ) {
236 auto sigProcVtx = HepMC::signal_process_vertex(evtSrc);
237 if ( sigProcVtx ) {
238 if ( bcToFullVtx.count(HepMC::uniqueID(sigProcVtx)) == 0) {
239 addVertex( sigProcVtx, evt,VtxType::IsNotRootVertex, true );
240 }//> signal process vertex has to be added
241 } else {
242 //> Original GenEvent has a NO signal process vertex set-up
243 ATH_MSG_DEBUG("You asked to record signal_process_vertex but :" << endmsg << " there is NO signal_process_vertex in this event !!");
244 }
245
246 } //> end do SignalProcessVtx
247
248 TruthHelper::copyBeamParticles (*evtSrc, *evt);
249
250 filterColl->push_back(evt);
251}
#define ATH_MSG_ERROR(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector< McVtxFilter > m_filters
Filters.
std::vector< double > m_counter
Stores the total number of filtered vertices for each McVtxFilter.
int uniqueID(const T &p)
ConstGenVertexPtr signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:597
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)

◆ initialize()

StatusCode McVtxFilterTool::initialize ( )
virtual

Athena Algorithm's Hooks.

Implements IMcVtxFilterTool.

Definition at line 106 of file McVtxFilterTool.cxx.

107{
108 ATH_MSG_DEBUG("Initializing " << name() << "...");
109
110 if ( msgLvl(MSG::DEBUG) ) {
112 }
113
114 // configure the filters with the provided DecayPatterns (from
115 // jobO or via the property interface
117
118 return StatusCode::SUCCESS;
119}
bool msgLvl(const MSG::Level lvl) const
void displayOptions() const
Display the decay pattern of each McVtxFilter this Tool is embedding.

◆ 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 & IMcVtxFilterTool::interfaceID ( )
inlinestaticinherited

I/O operators.

Inline methods:

Definition at line 82 of file IMcVtxFilterTool.h.

83{
85}
static const InterfaceID IID_IMcVtxFilterTool("IMcVtxFilterTool", 1, 0)

◆ isAccepted()

bool McVtxFilterTool::isAccepted ( const HepMC::ConstGenVertexPtr & vtx) const
virtual

Return true if one of the McVtxFilters accept this GenVertex.

Implements IMcVtxFilterTool.

Definition at line 180 of file McVtxFilterTool.cxx.

181{
182 for(const auto *filter : m_filters) {
183 if ( filter->isAccepted( vtx ) ) {
184 return true;
185 }
186 }//> end loop over McVtxFilters
187
188 return false;
189}

◆ keepParticle()

bool McVtxFilterTool::keepParticle ( const VtxType::Flag vtxType,
const HepMC::ConstGenParticlePtr & p ) const
protected

Helper function: return true if we are at a root vertex (i.e., a vertex that satisfies one of the chosen decay modes) and if the PDG of the particle is in the m_particles list (or the m_particle list is empty).

Definition at line 327 of file McVtxFilterTool.cxx.

329{
330 // no particle, so no particle to keep. Simple, isn't ?
331 if ( nullptr == part ) {
332 return false;
333 }
334
335 // By default, we keep all particles
336 if ( m_particles.value().empty() ) {
337 return true;
338 }
339
340 // only filter decay particles of the root vertex
341 // ie: the vertex which matches a decay pattern setup by the
342 // "DecayPatterns" property.
343 if ( vtxType == VtxType::IsNotRootVertex ) {
344 return true;
345
346 } else if ( vtxType == VtxType::IsRootVertex ) {
347 // we are at a Root vertex.
348 // And we only keep the outgoing particles which are in our list
349 const int pdgId = part->pdg_id();
350 return std::find( m_particles.value().begin(),
351 m_particles.value().end(),
352 pdgId ) != m_particles.value().end();
353 } else {
354
355 // Humm.. we don't know anything about this VtxType...
356 // by default we keep all particles
357 // But we tell user that something is wrong !
358 msg(MSG::WARNING)
359 << "In keepParticle: Don't know anything about this VtxType ["
360 << vtxType << "] !!"
361 << endmsg
362 << "We'll keep this particle [ " << part
363 << "] but : Check your jobOption !!"
364 << endmsg;
365 return true;
366 }
367}

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

◆ setupFilters()

void McVtxFilterTool::setupFilters ( Gaudi::Details::PropertyBase & decayPatterns)
protected

Callback method to ensure consistency of filters.

Method to ensure the synchronisation between the filters and the decay patterns they are supposed to match. This is to cope with the case where this tool is called by some parent AlgTool/Algorithm which wants to override the DecayPatterns property given by the JobOptionSvc. We ensure the consistency between those 2 entities by defining a callback function (@setupFilters) to perform the job.

Definition at line 369 of file McVtxFilterTool.cxx.

370{
371 m_filters.clear();
372 m_counter.clear();
373
374 const std::vector<std::string>& decayPatterns = m_decayPatterns.value();
375 std::vector<bool> matchSigns = m_matchSigns.value();
376 std::vector<bool> matchBranches = m_matchBranches.value();
377
378 // Normally, using the Configurables, the lengths of properties should
379 // be the same... but who knows. Better test it.
380 // On the other hand, for compatibility reasons, we allow the situation
381 // where *both* matchSigns and matchBranches are empty.
382 // Only after having removed the "old-style" case we can raise an exception.
383 const bool oldCfg = ( m_matchSigns.value().empty() &&
384 m_matchBranches.value().empty() );
385 if ( !oldCfg &&
386 ( decayPatterns.size() != matchSigns.size() ||
387 decayPatterns.size() != matchBranches.size() ||
388 matchSigns.size() != matchBranches.size() ) ) {
389 std::string error;
390 error = "Lengths of ArrayProperty configuring McVtxFilters ";
391 error += "are DIFFERING !!";
392 msg(MSG::WARNING)
393 << "In setupFilter: " << error
394 << endmsg
395 << "\t# decayPatterns: " << decayPatterns.size() << endmsg
396 << "\t# matchSigns: " << matchSigns.size() << endmsg
397 << "\t# matchBranches: " << matchBranches.size() << endmsg
398 << "Reference size is 'decayPatterns':" << endmsg
399 << "\t==> Will fill holes with default values !" << endmsg
400 << "\t==> Will drop extra values !"
401 << endmsg;
402 //throw std::runtime_error(error);
403 }
404
405 const unsigned int nDecayPatterns = decayPatterns.size();
406 m_filters.resize( nDecayPatterns );
407 m_counter.resize( nDecayPatterns, 0 );
408
409 if ( nDecayPatterns > matchSigns.size() ) {
410 // fill it with default values
411 const unsigned int nCount = nDecayPatterns - matchSigns.size();
412 std::fill_n( std::back_inserter(matchSigns),
413 nCount, // number of times we fill it
414 false );// default value
415 }
416
417 if ( nDecayPatterns > matchBranches.size() ) {
418 // fill it with default values
419 const unsigned int nCount = nDecayPatterns - matchBranches.size();
420 std::fill_n( std::back_inserter(matchBranches),
421 nCount, // number of times we fill it
422 false );// default value
423 }
424
425 for ( unsigned int i = 0; i != nDecayPatterns; ++i ) {
426 m_filters[i] = new McVtxFilter( decayPatterns[i],
427 bool(matchSigns[i]),
428 bool(matchBranches[i]) );
429 }
430
431 }
static const Attributes_t empty

◆ stats()

void McVtxFilterTool::stats ( ) const
virtual

Display the statistics for each McVtxFilter this Tool is embedding.

Implements IMcVtxFilterTool.

Definition at line 170 of file McVtxFilterTool.cxx.

171{
172 msg(MSG::INFO) << "Statistics for each filter : " << endmsg;
173 for( unsigned int i = 0; i < m_counter.size(); ++i ) {
174 msg(MSG::INFO)
175 << "\t==> [" << m_decayPatterns.value()[i] << "] accepted "
176 << m_counter[i] << " vertices" << endmsg;
177 }
178 }

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

std::vector<double> McVtxFilterTool::m_counter
protected

Stores the total number of filtered vertices for each McVtxFilter.

Definition at line 201 of file McVtxFilterTool.h.

◆ m_decayPatterns

StringArrayProperty McVtxFilterTool::m_decayPatterns
protected

Patterns of the decays to look for (ex: "23 -> -5 + 5" ).

Definition at line 185 of file McVtxFilterTool.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_doSignalProcessVtx

BooleanProperty McVtxFilterTool::m_doSignalProcessVtx
protected

Switch to include or not the signal_process_vertex into the McEventCollection (default = true).

Definition at line 206 of file McVtxFilterTool.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_fillTree

BooleanProperty McVtxFilterTool::m_fillTree
protected

Switch to fill the entire tree from a decay vertex.

Definition at line 210 of file McVtxFilterTool.h.

◆ m_filters

DataVector<McVtxFilter> McVtxFilterTool::m_filters
protected

Filters.

Definition at line 197 of file McVtxFilterTool.h.

◆ m_matchBranches

BooleanArrayProperty McVtxFilterTool::m_matchBranches
protected

Booleans to setup each of the McVtxFilter::matchBranch.

Definition at line 193 of file McVtxFilterTool.h.

◆ m_matchSigns

BooleanArrayProperty McVtxFilterTool::m_matchSigns
protected

Booleans to setup each of the McVtxFilter::matchSign.

Definition at line 189 of file McVtxFilterTool.h.

◆ m_mcEventsName

StringProperty McVtxFilterTool::m_mcEventsName
protected

Location of the McEventCollection to be filtered.

Definition at line 177 of file McVtxFilterTool.h.

◆ m_mcEventsOutputName

StringProperty McVtxFilterTool::m_mcEventsOutputName
protected

Output McEventCollection location (filtered from the McEventCollection).

Definition at line 181 of file McVtxFilterTool.h.

◆ m_particles

LongArrayProperty McVtxFilterTool::m_particles
protected

List of outgoing particles from the decay vertex to include.

Definition at line 214 of file McVtxFilterTool.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: