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#ifdef HEPMC3
277 HepMC::GenVertexPtr vtx = (evt == srcVtx->parent_event()) ? std::const_pointer_cast<HepMC3::GenVertex>(srcVtx) : nullptr ;
278 if ( !vtx ) {
280 evt->add_vertex(vtx);
281 vtx->set_position( srcVtx->position() );
282 vtx->set_status( srcVtx->status() );
284 vtx->add_attribute("weights",srcVtx->attribute<HepMC3::VectorDoubleAttribute> ("weights"));
285 }
286 if (isSignal) HepMC::set_signal_process_vertex(evt, vtx );
288 for ( const auto& parent: srcVtx->particles_in()) {
289 HepMC::GenParticlePtr mother = (evt == parent->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(parent) : nullptr ;
290 if ( ! mother ) {
291 mother = HepMC::newGenParticlePtr();
292 vtx->add_particle_in( mother );
293 mother->set_momentum( parent->momentum() );
294 mother->set_generated_mass( parent->generated_mass() );
295 mother->set_pdg_id( parent->pdg_id() );
296 mother->set_status( parent->status() );
297 HepMC::set_flow(mother, HepMC::flow(parent) );
299 HepMC::suggest_barcode(mother,HepMC::barcode(parent) );
300
301 } else {
302 // set the mother's decay to our (new) vertex
303 vtx->add_particle_in( std::move(mother) );
304 }
305 }//> loop over ingoing particles
306
308 for ( const auto& child: srcVtx->particles_out()) {
309 HepMC::GenParticlePtr daughter = (evt == child->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(child) : nullptr ;
310 if ( !daughter ) {
311 if ( !keepParticle( vtxType, child ) ) {
312 // only include selected particles via the "ParticlesToKeep" property
313 ATH_MSG_VERBOSE("Skipping outgoing particle id|particle: ["
314 << child->pdg_id() << "|"
315 << child << "]");
316 } else {
317 daughter = HepMC::newGenParticlePtr();
318 // set the daughter's production vertex to our new vertex
319 vtx->add_particle_out( daughter );
320 daughter->set_momentum( child->momentum() );
321 daughter->set_generated_mass( child->generated_mass() );
322 daughter->set_pdg_id( child->pdg_id() );
323 daughter->set_status( child->status() );
324 HepMC::set_flow(daughter, HepMC::flow(child) );
326 HepMC::suggest_barcode(daughter,HepMC::barcode(child) );
327
328 }
329 }
330
331 if ( m_fillTree && keepParticle( vtxType, child ) ) {
332 auto decayVertex = child->end_vertex();
333 if ( decayVertex ) {
334 // recursively fill the tree with all decay vertices and final state
335 // particles of selected outgoing particles lines
336 // => We are no longer sitting at the decay vertex so we tell it
337 // via the IsNotRootVertex flag
338 addVertex( decayVertex, evt, VtxType::IsNotRootVertex );
339 }
340 }
341 }//> loop over outgoing particles
342#else
343 HepMC::GenVertex * vtx = evt->barcode_to_vertex(srcVtx->barcode());
344 if ( 0 == vtx ) {
346 vtx->set_position( srcVtx->position() );
347 vtx->set_id( srcVtx->id() );
348 vtx->suggest_barcode( srcVtx->barcode() );
349 vtx->weights() = srcVtx->weights();
350 evt->add_vertex(vtx);
351 }
352 if (isSignal) HepMC::set_signal_process_vertex(evt, vtx );
354 for ( HepMC::GenVertex::particles_in_const_iterator parent = srcVtx->particles_in_const_begin();
355 parent != srcVtx->particles_in_const_end();
356 ++parent ) {
357 HepMC::GenParticle * mother = evt->barcode_to_particle( (*parent)->barcode() );
358 if ( 0 == mother ) {
359 mother = HepMC::newGenParticlePtr();
360 mother->set_momentum( (*parent)->momentum() );
361 mother->set_generated_mass( (*parent)->generated_mass() );
362 mother->set_pdg_id( (*parent)->pdg_id() );
363 mother->set_status( (*parent)->status() );
364 mother->set_flow( (*parent)->flow() );
365 mother->set_polarization( (*parent)->polarization() );
366 mother->suggest_barcode( (*parent)->barcode() );
367
368 }
369 // set the mother's decay to our (new) vertex
370 vtx->add_particle_in( mother );
371
372 }//> loop over ingoing particles
373
375 for ( HepMC::GenVertex::particles_out_const_iterator child = srcVtx->particles_out_const_begin();
376 child != srcVtx->particles_out_const_end();
377 ++child ) {
378 HepMC::GenParticle * daughter = evt->barcode_to_particle( (*child)->barcode() );
379 if ( 0 == daughter ) {
380 if ( !keepParticle( vtxType, *child ) ) {
381 // only include selected particles via the "ParticlesToKeep" property
382 ATH_MSG_VERBOSE("Skipping outgoing particle : "<< (*child));
383 } else {
384 daughter = HepMC::newGenParticlePtr();
385 daughter->set_momentum( (*child)->momentum() );
386 daughter->set_generated_mass( (*child)->generated_mass() );
387 daughter->set_pdg_id( (*child)->pdg_id() );
388 daughter->set_status( (*child)->status() );
389 daughter->set_flow( (*child)->flow() );
390 daughter->set_polarization( (*child)->polarization() );
391 daughter->suggest_barcode( (*child)->barcode() );
392
393 }
394 }
395 if ( daughter ) {
396 // set the daughter's production vertex to our new vertex
397 vtx->add_particle_out( daughter );
398 }
399
400 if ( m_fillTree && keepParticle( vtxType, *child ) ) {
401 const HepMC::GenVertex * decayVertex = (*child)->end_vertex();
402 if ( 0 != decayVertex ) {
403 // recursively fill the tree with all decay vertices and final state
404 // particles of selected outgoing particles lines
405 // => We are no longer sitting at the decay vertex so we tell it
406 // via the IsNotRootVertex flag
407 addVertex( decayVertex, evt, VtxType::IsNotRootVertex );
408 }
409 }
410 }//> loop over outgoing particles
411#endif
412
413 }
#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...
void set_polarization(T &a, const Polarization &b)
void set_signal_process_vertex(GenEvent *e, T v)
Definition GenEvent.h:652
int barcode(const T *p)
Definition Barcode.h:16
HepMC::GenVertex * GenVertexPtr
Definition GenVertex.h:59
bool suggest_barcode(T &p, int i)
Definition GenEvent.h:672
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition GenVertex.h:64
Polarization polarization(const T &a)
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
Definition GenParticle.h:39
int flow(const T &a, int i)
Definition Flow.h:51
GenParticle * GenParticlePtr
Definition GenParticle.h:37

◆ 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
221 HepMC::GenEvent * evt = HepMC::copyemptyGenEvent(evtSrc);
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.
int barcode_or_id(const ConstGenParticlePtr &p)
Definition GenParticle.h:42
GenEvent * copyemptyGenEvent(const GenEvent *inEvt)
Definition GenEvent.h:655
GenVertex * signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:627
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 415 of file McVtxFilterTool.cxx.

417{
418 // no particle, so no particle to keep. Simple, isn't ?
419 if ( nullptr == part ) {
420 return false;
421 }
422
423 // By default, we keep all particles
424 if ( m_particles.value().empty() ) {
425 return true;
426 }
427
428 // only filter decay particles of the root vertex
429 // ie: the vertex which matches a decay pattern setup by the
430 // "DecayPatterns" property.
431 if ( vtxType == VtxType::IsNotRootVertex ) {
432 return true;
433
434 } else if ( vtxType == VtxType::IsRootVertex ) {
435 // we are at a Root vertex.
436 // And we only keep the outgoing particles which are in our list
437 const int pdgId = part->pdg_id();
438 return std::find( m_particles.value().begin(),
439 m_particles.value().end(),
440 pdgId ) != m_particles.value().end();
441 } else {
442
443 // Humm.. we don't know anything about this VtxType...
444 // by default we keep all particles
445 // But we tell user that something is wrong !
446 msg(MSG::WARNING)
447 << "In keepParticle: Don't know anything about this VtxType ["
448 << vtxType << "] !!"
449 << endmsg
450 << "We'll keep this particle [ " << part
451 << "] but : Check your jobOption !!"
452 << endmsg;
453 return true;
454 }
455}

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

462{
463 m_filters.clear();
464 m_counter.clear();
465
466 const std::vector<std::string>& decayPatterns = m_decayPatterns.value();
467 std::vector<bool> matchSigns = m_matchSigns.value();
468 std::vector<bool> matchBranches = m_matchBranches.value();
469
470 // Normally, using the Configurables, the lengths of properties should
471 // be the same... but who knows. Better test it.
472 // On the other hand, for compatibility reasons, we allow the situation
473 // where *both* matchSigns and matchBranches are empty.
474 // Only after having removed the "old-style" case we can raise an exception.
475 const bool oldCfg = ( m_matchSigns.value().empty() &&
476 m_matchBranches.value().empty() );
477 if ( !oldCfg &&
478 ( decayPatterns.size() != matchSigns.size() ||
479 decayPatterns.size() != matchBranches.size() ||
480 matchSigns.size() != matchBranches.size() ) ) {
481 std::string error;
482 error = "Lengths of ArrayProperty configuring McVtxFilters ";
483 error += "are DIFFERING !!";
484 msg(MSG::WARNING)
485 << "In setupFilter: " << error
486 << endmsg
487 << "\t# decayPatterns: " << decayPatterns.size() << endmsg
488 << "\t# matchSigns: " << matchSigns.size() << endmsg
489 << "\t# matchBranches: " << matchBranches.size() << endmsg
490 << "Reference size is 'decayPatterns':" << endmsg
491 << "\t==> Will fill holes with default values !" << endmsg
492 << "\t==> Will drop extra values !"
493 << endmsg;
494 //throw std::runtime_error(error);
495 }
496
497 const unsigned int nDecayPatterns = decayPatterns.size();
498 m_filters.resize( nDecayPatterns );
499 m_counter.resize( nDecayPatterns, 0 );
500
501 if ( nDecayPatterns > matchSigns.size() ) {
502 // fill it with default values
503 const unsigned int nCount = nDecayPatterns - matchSigns.size();
504 std::fill_n( std::back_inserter(matchSigns),
505 nCount, // number of times we fill it
506 false );// default value
507 }
508
509 if ( nDecayPatterns > matchBranches.size() ) {
510 // fill it with default values
511 const unsigned int nCount = nDecayPatterns - matchBranches.size();
512 std::fill_n( std::back_inserter(matchBranches),
513 nCount, // number of times we fill it
514 false );// default value
515 }
516
517 for ( unsigned int i = 0; i != nDecayPatterns; ++i ) {
518 m_filters[i] = new McVtxFilter( decayPatterns[i],
519 bool(matchSigns[i]),
520 bool(matchBranches[i]) );
521 }
522
523 }
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 >, 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_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: