ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5*/
6
7// TruthParticleContainer.h
8// Header file for class TruthParticleContainer
9// Author: S.Binet<binet@cern.ch>
11#ifndef MCPARTICLEEVENT_TRUTHPARTICLECONTAINER_H
12#define MCPARTICLEEVENT_TRUTHPARTICLECONTAINER_H
13
14// STL includes
15#include <iosfwd>
16#include <unordered_map>
17
19#include "AthLinks/ElementLink.h"
20
22
23// GeneratorObjects includes
25
26// NavFourMom includes
28
29// McParticleEvent includes
33
34#include "AtlasHepMC/GenEvent.h"
35// Forward declaration
36
37// Needed for constructing the mirror container hierarchy
38// This tells StoreGate that DV<TP> derives from DV<IP>
40
41class TruthParticleContainer : public DataVector<TruthParticle>
42{
43
46 // Public members:
48 public:
49 // NB: This is an unsigned type, and thus represents the maximum
50 // size that the allocator can hold. (modeled after std::string::npos)
51 static const std::size_t NoIdx = static_cast<std::size_t>(-1);
52
54 // Public typedefs:
56 public:
57
59 typedef std::unordered_map<long,const TruthParticle*> Map_t;
62
64 // Public methods:
66 public:
67
71
74 //TruthParticleContainer( const TruthParticleContainer& rhs );
75
78 //TruthParticleContainer& operator=( const TruthParticleContainer& rhs );
79
83
87
89 // Const methods:
91
94 std::ostream& dump( std::ostream& out = std::cout ) const;
95
99 const HepMC::GenEvent* genEvent() const;
100
105
109 const std::string& genEventName() const;
110
114 std::size_t genEventIdx() const;
115
119 const TruthParticle* truthParticle( const int barcode, std::size_t genEventIdx = 0 ) const;
120
125 std::size_t truthParticleIdx( const int barcode, std::size_t genEventIdx = 0 ) const;
126
131 bool hasEtIsol() const;
132
137 bool hasEtIsol( const int barcode ) const;
138
143 const TruthEtIsolations::EtIsol_t* etIsolations( const int barcode ) const;
144
149
153 double etIsol( const int barcode,
154 const TruthParticleParameters::ConeSize coneIdx ) const;
155
157 // Non-const methods:
159
164
168 void setGenEvent( const McEventCollection* mcColl,
169 const std::size_t genEventIdx,
170 IProxyDict* sg = nullptr);
171
175
179 const std::size_t etIsolationsIdx,
180 IProxyDict* sg = nullptr);
181
184 void setParticles( const Map_t& parts );
185
187 // Protected data:
189 protected:
190
194
201
206
207};
208
212
213// These functions are really not needed inside the dictionary...
214#ifndef __REFLEX__
215
216inline
219
220inline
221std::ostream& TruthParticleContainer::dump( std::ostream& out ) const
222{
223 if ( m_genEvent.isValid() ) {
225 }
226 return out;
227}
228
229inline
230const HepMC::GenEvent* TruthParticleContainer::genEvent() const
231{
232 return m_genEvent.isValid() ? (*m_genEvent) : 0;
233}
234
235inline
241
242inline
244{
245 return m_genEvent.index();
246}
247
248inline
249const std::string& TruthParticleContainer::genEventName() const
250{
251 return m_genEvent.dataID();
252}
253
254inline
256{
257 return m_etIsolations.isValid();
258}
259
260inline
261bool TruthParticleContainer::hasEtIsol( const int barcode ) const
262{
263 return hasEtIsol() && (*m_etIsolations)->hasEtIsol( barcode );
264}
265
266inline const TruthEtIsolations::EtIsol_t*
267TruthParticleContainer::etIsolations( const int barcode ) const
268{
269 return hasEtIsol( barcode )
270 ? (*m_etIsolations)->etIsolations(barcode)
271 : 0;
272}
273
279
280inline double
282 const TruthParticleParameters::ConeSize idx ) const
283{
284 return hasEtIsol( barcode )
285 ? (*m_etIsolations)->etIsol(barcode, idx)
286 : -999.;
287}
288
289inline void
295
296inline void
298 const std::size_t genEvtIdx,
299 IProxyDict* sg /*= nullptr*/)
300{
301 if ( 0 != mcColl && mcColl->size() > genEvtIdx ) {
302 m_genEvent.toIndexedElement( *mcColl, genEvtIdx, sg );
303 }
304}
305
306inline void
311
312inline void
314 const std::size_t etIsolationsIdx,
315 IProxyDict* sg /*= nullptr*/)
316{
317 if ( 0 != etIsolations && etIsolations->size() > etIsolationsIdx ) {
318 m_etIsolations.toIndexedElement( *etIsolations, etIsolationsIdx, sg );
319 }
320}
321
322inline void
327
328#endif // not __REFLEX__
329
331
332// Tell StoreGate that TruthParticleContainer derives from DV<TP>
334
335#endif //> MCPARTICLEEVENT_TRUTHPARTICLECONTAINER_H
#define SG_BASE(D, B)
Declare that class D derives from class B.
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
An STL vector of pointers that by default owns its pointed-to elements.
#define DATAVECTOR_BASE(T, BASE)
Declare base class info to DataVector.
Definition DataVector.h:649
Derived DataVector<T>.
Definition DataVector.h:795
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
size_type size() const noexcept
Returns the number of elements in the collection.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
McAod::EtIsolations EtIsol_t
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
ElementLink< TruthEtIsolationsContainer > m_etIsolations
Persistent pointer to the TruthEtIsolations container, holding Et isolations for TruthParticle or Hep...
ElementLink< McEventCollection > m_genEvent
Persistent pointer to the HepMC::GenEvent we are proxying.
const ElementLink< McEventCollection > & genEventLink() const
Retrieve the HepMC::GenEvent this TruthParticleContainer is proxying, as a link.
double etIsol(const int barcode, const TruthParticleParameters::ConeSize coneIdx) const
Return the Et isolation for a given particle and a given cone size.
std::ostream & dump(std::ostream &out=std::cout) const
Dump the content of the TruthParticleContainer.
const TruthEtIsolations::EtIsol_t * etIsolations(const int barcode) const
return the container of Truth Et isolations for a given TruthParticle (or a HepMC::GenParticle)
Map_t m_particles
Dictionary to ease the extraction of a TruthParticle (contained by this collection) from the HepMC::G...
std::size_t genEventIdx() const
Retrieve the index (within a McEventCollection) of the HepMC::GenEvent this TruthParticleContainer is...
std::unordered_map< long, const TruthParticle * > Map_t
barcode to TruthParticle dictionary
const TruthParticle * truthParticle(const int barcode, std::size_t genEventIdx=0) const
return a const pointer to an TruthParticle given the barcode of the HepMC::GenParticle it is wrapping
std::size_t truthParticleIdx(const int barcode, std::size_t genEventIdx=0) const
return the index to an TruthParticle given the barcode of the HepMC::GenParticle it is wrapping retur...
void setGenEvent(const ElementLink< McEventCollection > &genEvent)
Setup the persistent pointer toward the HepMC::GenEvent this TruthParticleContainer is proxying.
TruthParticleContainer()
Default constructor:
const HepMC::GenEvent * genEvent() const
Retrieve the HepMC::GenEvent this TruthParticleContainer is proxying.
void setEtIsolations(const ElementLink< TruthEtIsolationsContainer > &etIsolations)
Setup the persistent pointer toward the TruthEtIsolations.
const ElementLink< TruthEtIsolationsContainer > & etIsolationsLink() const
return the link to truth Et isolations.
bool hasEtIsol() const
tell if this TruthParticleContainer has been registered with a TruthEtIsolations container
void setParticles(const Map_t &parts)
Setup the dictionary of barcodes-to-TruthParticle.
const std::string & genEventName() const
Retrieve the name (StoreGate location) of the HepMC::GenEvent this TruthParticleContainer is proxying...
void line(std::ostream &os, const GenEvent &e)
Definition GenEvent.h:677
OwnershipPolicy
ConeSize
Enum for Cone size indexes (for isolation)
-event-from-file