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:

Public methods:

Constructors

Definition at line 34 of file McVtxFilterTool.cxx.

36 :
37 AthAlgTool( type, name, parent )
38{
39 //
40 // Property declaration
41 //
42 //declareProperty( "Property", m_nProperty );
43
44 declareProperty( "McEvents",
45 m_mcEventsName = "TruthEvent",
46 "Location of the McEventCollection to be filtered" );
47
48 declareProperty( "McEventsOutput",
49 m_mcEventsOutputName = "GEN_AOD",
50 "Output McEventCollection location (filtered from the "
51 "McEventCollection)" );
52
53 declareProperty( "DecayPatterns",
55 "List of decay patterns the tool will try to match. \n\t"
56 "ex: 23 -> -5 + 5 to select Z bosons into bbbar pairs" );
57
58 m_decayPatterns.declareUpdateHandler( &McVtxFilterTool::setupFilters,
59 this );
60
61 declareProperty( "MatchSigns",
63 "List of booleans with which the tool will setup "
64 "McVtxFilters. This will setup the McVtxFilter::matchSign "
65 "data member." );
66 m_matchSigns.declareUpdateHandler( &McVtxFilterTool::setupFilters,
67 this );
68
69 declareProperty( "MatchBranches",
71 "List of booleans with which the tool will setup "
72 "McVtxFilters. This will setup the "
73 "McVtxFilter::matchBranches data member." );
74
75 m_matchBranches.declareUpdateHandler( &McVtxFilterTool::setupFilters,
76 this );
77
78 declareProperty( "DoSignalProcessVtx",
80 "Switch to include or not the signal_process_vertex into "
81 "the McEventCollection (default = true).\n"
82 "Note that this is close to useless as the HEPEVT structure"
83 " does not hold this kind of informations..." );
84
85 declareProperty( "FillTree",
86 m_fillTree = false,
87 "Switch to fill the entire decay tree from a decay "
88 "vertex.\n"
89 "This can be usefull to record for example the whole shower "
90 "from a gluon or a quark. In that case, you may want to add "
91 "the according PDG ids into the list of particles to keep" );
92
93 declareProperty( "ParticlesToKeep",
95 "List of outgoing particles from the decay vertex to "
96 "include. This property has to be configured in sync. with "
97 "the 'FillTree' one." );
98
99 declareInterface<IMcVtxFilterTool>(this);
100}
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 104 of file McVtxFilterTool.cxx.

105{
106 ATH_MSG_DEBUG("Calling destructor");
107}
#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.

Const methods:

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 271 of file McVtxFilterTool.cxx.

274{
275 ATH_MSG_VERBOSE("In McVtxFilterTool::addVertex( vtxType= "<<vtxType<< " )");
276 HepMC::GenVertexPtr vtx = (evt == srcVtx->parent_event()) ? std::const_pointer_cast<HepMC3::GenVertex>(srcVtx) : nullptr ;
277 if ( !vtx ) {
279 evt->add_vertex(vtx);
280 vtx->set_position( srcVtx->position() );
281 vtx->set_status( srcVtx->status() );
283 vtx->add_attribute(HepMCStr::weights,srcVtx->attribute<HepMC3::VectorDoubleAttribute> (HepMCStr::weights));
284 }
285 if (isSignal) HepMC::set_signal_process_vertex(evt, vtx );
287 for ( const auto& parent: srcVtx->particles_in()) {
288 HepMC::GenParticlePtr mother = (evt == parent->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(parent) : nullptr ;
289 if ( ! mother ) {
290 mother = HepMC::newGenParticlePtr();
291 vtx->add_particle_in( mother );
292 mother->set_momentum( parent->momentum() );
293 mother->set_generated_mass( parent->generated_mass() );
294 mother->set_pdg_id( parent->pdg_id() );
295 mother->set_status( parent->status() );
296 HepMC::set_flow(mother, HepMC::flow(parent) );
298 HepMC::suggest_barcode(mother,HepMC::barcode(parent) );
299
300 } else {
301 // set the mother's decay to our (new) vertex
302 vtx->add_particle_in( std::move(mother) );
303 }
304 }//> loop over ingoing particles
305
307 for ( const auto& child: srcVtx->particles_out()) {
308 HepMC::GenParticlePtr daughter = (evt == child->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(child) : nullptr ;
309 if ( !daughter ) {
310 if ( !keepParticle( vtxType, child ) ) {
311 // only include selected particles via the "ParticlesToKeep" property
312 ATH_MSG_VERBOSE("Skipping outgoing particle id|particle: ["
313 << child->pdg_id() << "|"
314 << child << "]");
315 } else {
316 daughter = HepMC::newGenParticlePtr();
317 // set the daughter's production vertex to our new vertex
318 vtx->add_particle_out( daughter );
319 daughter->set_momentum( child->momentum() );
320 daughter->set_generated_mass( child->generated_mass() );
321 daughter->set_pdg_id( child->pdg_id() );
322 daughter->set_status( child->status() );
323 HepMC::set_flow(daughter, HepMC::flow(child) );
325 HepMC::suggest_barcode(daughter,HepMC::barcode(child) );
326
327 }
328 }
329
330 if ( m_fillTree && keepParticle( vtxType, child ) ) {
331 auto decayVertex = child->end_vertex();
332 if ( decayVertex ) {
333 // recursively fill the tree with all decay vertices and final state
334 // particles of selected outgoing particles lines
335 // => We are no longer sitting at the decay vertex so we tell it
336 // via the IsNotRootVertex flag
337 addVertex( decayVertex, evt, VtxType::IsNotRootVertex );
338 }
339 }
340 }//> loop over outgoing particles
341
342
343 }
#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...
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)
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
int flow(const HepMC3::GenParticlePtr &p, int i)
Definition Flow.h:13

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

Const methods:

Implements IMcVtxFilterTool.

Definition at line 162 of file McVtxFilterTool.cxx.

163{
164 msg(MSG::INFO)
165 << "Options for " << name() << " :" << endmsg
166 << "\tDecay Patterns: [ ";
167 for (const auto & itr : m_decayPatterns.value()) {
168 msg(MSG::INFO) << itr << "; ";
169 }
170 msg(MSG::INFO) << "]" << endmsg;
171
172 msg(MSG::INFO) << "Particles to keep: [";
173 for (long itr : m_particles.value()) {
174 msg(MSG::INFO) << itr << ", ";
175 }
176 msg(MSG::INFO) << "]" << endmsg;
177}
#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 126 of file McVtxFilterTool.cxx.

127{
128 StatusCode sc = StatusCode::SUCCESS;
129
130 ATH_MSG_DEBUG("Executing " << name() << "...");
131
132 ATH_MSG_VERBOSE("Retrieve the McEventCollection to be filtered for");
133 const McEventCollection * mcColl = nullptr;
134 sc = evtStore()->retrieve( mcColl, m_mcEventsName );
135
136 if ( sc.isFailure() || nullptr == mcColl ) {
137 msg(MSG::ERROR)
138 << "Failed to retrieve McEventCollection at : "
140 << endmsg
141 << "because : sc= " << ( sc.isFailure() ? "FAILURE" : "OK" )
142 << " and mcEvent= " << mcColl
143 << endmsg;
144 return StatusCode::SUCCESS;
145 }
146
147 ATH_MSG_VERBOSE("Create a new McEventCollection which will hold the "\
148 "filtered GenEvent");
149 McEventCollection * filteredColl = new McEventCollection;
150 sc = evtStore()->record(filteredColl, m_mcEventsOutputName, true);
151 sc = evtStore()->setConst(filteredColl);
152 ATH_MSG_VERBOSE("Recorded and locked in StoreGate");
153
154 filterMcEventCollection( mcColl, filteredColl );
155 return sc;
156}
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.

Non-const methods:

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 205 of file McVtxFilterTool.cxx.

207{
208 if ( nullptr == mcColl ) {
209 ATH_MSG_ERROR("McEventCollection is NULL pointer !!");
210 return;
211 }
212
214 std::set<int> bcToFullVtx;
215
217 const HepMC::GenEvent * evtSrc = (*mcColl->begin());
218
222 for ( const auto& itrPart: *evtSrc) {
223 auto dcyVtx = itrPart->end_vertex();
224 if ( !dcyVtx ) continue;
225 int vtxBC = HepMC::barcode_or_id(dcyVtx);
226 if (bcToFullVtx.count(vtxBC)!=0) continue;
227 ATH_MSG_VERBOSE("Doing vtx: " << dcyVtx);
228
229 int i = 0;
230 for( DataVector<McVtxFilter>::const_iterator filter = m_filters.begin(); filter != m_filters.end(); ++filter,++i ) {
231 ATH_MSG_VERBOSE("Processing with filter[" << i << "]...");
232 if ( !(*filter)->isAccepted( dcyVtx ) ) continue;
233 m_counter[i] += 1;
234 ATH_MSG_VERBOSE("Filter[" << i << "] accepted this vtx : " << dcyVtx);
235 bcToFullVtx.insert(vtxBC);
236 addVertex( dcyVtx, evt, VtxType::IsRootVertex );
237 break;
238 }//> end loop over filters
239 }//> loop over particles
240
241 if ( m_doSignalProcessVtx ) {
249 auto sigProcVtx = HepMC::signal_process_vertex(evtSrc);
250 if ( sigProcVtx ) {
251 if ( bcToFullVtx.count(HepMC::barcode_or_id(sigProcVtx)) == 0) {
252 addVertex( sigProcVtx, evt,VtxType::IsNotRootVertex, true );
253 }//> signal process vertex has to be added
254 } else {
255 //> Original GenEvent has a NO signal process vertex set-up
256 ATH_MSG_DEBUG("You asked to record signal_process_vertex but :" << endmsg << " there is NO signal_process_vertex in this event !!");
257 }
258
259 } //> end do SignalProcessVtx
260
261 TruthHelper::copyBeamParticles (*evtSrc, *evt);
262
263 filterColl->push_back(evt);
264}
#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.
ConstGenVertexPtr signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:597
int barcode_or_id(const ConstGenParticlePtr &p)
Definition GenParticle.h:27
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 111 of file McVtxFilterTool.cxx.

112{
113 ATH_MSG_DEBUG("Initializing " << name() << "...");
114
115 if ( msgLvl(MSG::DEBUG) ) {
117 }
118
119 // configure the filters with the provided DecayPatterns (from
120 // jobO or via the property interface
122
123 return StatusCode::SUCCESS;
124}
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 189 of file McVtxFilterTool.cxx.

190{
191 for(const auto *filter : m_filters) {
192 if ( filter->isAccepted( vtx ) ) {
193 return true;
194 }
195 }//> end loop over McVtxFilters
196
197 return false;
198}

◆ 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 345 of file McVtxFilterTool.cxx.

347{
348 // no particle, so no particle to keep. Simple, isn't ?
349 if ( nullptr == part ) {
350 return false;
351 }
352
353 // By default, we keep all particles
354 if ( m_particles.value().empty() ) {
355 return true;
356 }
357
358 // only filter decay particles of the root vertex
359 // ie: the vertex which matches a decay pattern setup by the
360 // "DecayPatterns" property.
361 if ( vtxType == VtxType::IsNotRootVertex ) {
362 return true;
363
364 } else if ( vtxType == VtxType::IsRootVertex ) {
365 // we are at a Root vertex.
366 // And we only keep the outgoing particles which are in our list
367 const int pdgId = part->pdg_id();
368 return std::find( m_particles.value().begin(),
369 m_particles.value().end(),
370 pdgId ) != m_particles.value().end();
371 } else {
372
373 // Humm.. we don't know anything about this VtxType...
374 // by default we keep all particles
375 // But we tell user that something is wrong !
376 msg(MSG::WARNING)
377 << "In keepParticle: Don't know anything about this VtxType ["
378 << vtxType << "] !!"
379 << endmsg
380 << "We'll keep this particle [ " << part
381 << "] but : Check your jobOption !!"
382 << endmsg;
383 return true;
384 }
385}

◆ 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 391 of file McVtxFilterTool.cxx.

392{
393 m_filters.clear();
394 m_counter.clear();
395
396 const std::vector<std::string>& decayPatterns = m_decayPatterns.value();
397 std::vector<bool> matchSigns = m_matchSigns.value();
398 std::vector<bool> matchBranches = m_matchBranches.value();
399
400 // Normally, using the Configurables, the lengths of properties should
401 // be the same... but who knows. Better test it.
402 // On the other hand, for compatibility reasons, we allow the situation
403 // where *both* matchSigns and matchBranches are empty.
404 // Only after having removed the "old-style" case we can raise an exception.
405 const bool oldCfg = ( m_matchSigns.value().empty() &&
406 m_matchBranches.value().empty() );
407 if ( !oldCfg &&
408 ( decayPatterns.size() != matchSigns.size() ||
409 decayPatterns.size() != matchBranches.size() ||
410 matchSigns.size() != matchBranches.size() ) ) {
411 std::string error;
412 error = "Lengths of ArrayProperty configuring McVtxFilters ";
413 error += "are DIFFERING !!";
414 msg(MSG::WARNING)
415 << "In setupFilter: " << error
416 << endmsg
417 << "\t# decayPatterns: " << decayPatterns.size() << endmsg
418 << "\t# matchSigns: " << matchSigns.size() << endmsg
419 << "\t# matchBranches: " << matchBranches.size() << endmsg
420 << "Reference size is 'decayPatterns':" << endmsg
421 << "\t==> Will fill holes with default values !" << endmsg
422 << "\t==> Will drop extra values !"
423 << endmsg;
424 //throw std::runtime_error(error);
425 }
426
427 const unsigned int nDecayPatterns = decayPatterns.size();
428 m_filters.resize( nDecayPatterns );
429 m_counter.resize( nDecayPatterns, 0 );
430
431 if ( nDecayPatterns > matchSigns.size() ) {
432 // fill it with default values
433 const unsigned int nCount = nDecayPatterns - matchSigns.size();
434 std::fill_n( std::back_inserter(matchSigns),
435 nCount, // number of times we fill it
436 false );// default value
437 }
438
439 if ( nDecayPatterns > matchBranches.size() ) {
440 // fill it with default values
441 const unsigned int nCount = nDecayPatterns - matchBranches.size();
442 std::fill_n( std::back_inserter(matchBranches),
443 nCount, // number of times we fill it
444 false );// default value
445 }
446
447 for ( unsigned int i = 0; i != nDecayPatterns; ++i ) {
448 m_filters[i] = new McVtxFilter( decayPatterns[i],
449 bool(matchSigns[i]),
450 bool(matchBranches[i]) );
451 }
452
453 }
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 179 of file McVtxFilterTool.cxx.

180{
181 msg(MSG::INFO) << "Statistics for each filter : " << endmsg;
182 for( unsigned int i = 0; i < m_counter.size(); ++i ) {
183 msg(MSG::INFO)
184 << "\t==> [" << m_decayPatterns.value()[i] << "] accepted "
185 << m_counter[i] << " vertices" << endmsg;
186 }
187 }

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