ATLAS Offline Software
PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h
Go to the documentation of this file.
1 
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 
21 #include "AthenaKernel/CLASS_DEF.h"
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 
41 class TruthParticleContainer : public DataVector<TruthParticle>
42 {
43 
44  friend class TruthParticleCnvTool;
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 
216 inline
218 {}
219 
220 inline
221 std::ostream& TruthParticleContainer::dump( std::ostream& out ) const
222 {
223  if ( m_genEvent.isValid() ) {
225  }
226  return out;
227 }
228 
229 inline
230 const HepMC::GenEvent* TruthParticleContainer::genEvent() const
231 {
232  return m_genEvent.isValid() ? (*m_genEvent) : 0;
233 }
234 
235 inline
238 {
239  return m_genEvent;
240 }
241 
242 inline
244 {
245  return m_genEvent.index();
246 }
247 
248 inline
249 const std::string& TruthParticleContainer::genEventName() const
250 {
251  return m_genEvent.dataID();
252 }
253 
254 inline
256 {
257  return m_etIsolations.isValid();
258 }
259 
260 inline
262 {
263  return hasEtIsol() && (*m_etIsolations)->hasEtIsol( barcode );
264 }
265 
266 inline const TruthEtIsolations::EtIsol_t*
268 {
269  return hasEtIsol( barcode )
270  ? (*m_etIsolations)->etIsolations(barcode)
271  : 0;
272 }
273 
276 {
277  return m_etIsolations;
278 }
279 
280 inline double
283 {
284  return hasEtIsol( barcode )
285  ? (*m_etIsolations)->etIsol(barcode, idx)
286  : -999.;
287 }
288 
289 inline void
291 {
293  m_particles.clear();
294 }
295 
296 inline 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 
306 inline void
308 {
310 }
311 
312 inline 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 
322 inline void
324 {
326 }
327 
328 #endif // not __REFLEX__
329 
330 CLASS_DEF(TruthParticleContainer, 77883132, 1)
331 
332 // Tell StoreGate that TruthParticleContainer derives from DV<TP>
334 
335 #endif //> MCPARTICLEEVENT_TRUTHPARTICLECONTAINER_H
SG_BASE
SG_BASE(TruthParticleContainer, DataVector< TruthParticle >)
GenEvent.h
TruthParticleContainer::setEtIsolations
void setEtIsolations(const ElementLink< TruthEtIsolationsContainer > &etIsolations)
Setup the persistent pointer toward the TruthEtIsolations.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:307
TruthParticleContainer::m_particles
Map_t m_particles
Dictionary to ease the extraction of a TruthParticle (contained by this collection) from the HepMC::G...
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:205
TruthParticleContainer::m_genEvent
ElementLink< McEventCollection > m_genEvent
Persistent pointer to the HepMC::GenEvent we are proxying.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:193
TruthEtIsolationsContainer
Definition: TruthEtIsolationsContainer.h:26
TruthParticleContainer::m_etIsolations
ElementLink< TruthEtIsolationsContainer > m_etIsolations
Persistent pointer to the TruthEtIsolations container, holding Et isolations for TruthParticle or Hep...
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:200
TruthParticle
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:58
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
TruthEtIsolations::EtIsol_t
McAod::EtIsolations EtIsol_t
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
Definition: TruthEtIsolations.h:52
TruthParticleContainer::genEventIdx
std::size_t genEventIdx() const
Retrieve the index (within a McEventCollection) of the HepMC::GenEvent this TruthParticleContainer is...
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:243
DATAVECTOR_BASE
DATAVECTOR_BASE(TruthParticle, IParticle)
TruthParticleParameters::ConeSize
ConeSize
Enum for Cone size indexes (for isolation)
Definition: TruthParticleParamDefs.h:20
TruthParticleContainer::TruthParticleContainer
TruthParticleContainer()
Default constructor:
Definition: TruthParticleContainer.cxx:22
HepMC::Print::line
void line(std::ostream &os, const GenEvent &e)
Definition: GenEvent.h:676
TruthParticleContainer::dump
std::ostream & dump(std::ostream &out=std::cout) const
Dump the content of the TruthParticleContainer.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:221
TruthParticleContainer
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:42
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
TruthParticleContainer::etIsolationsLink
const ElementLink< TruthEtIsolationsContainer > & etIsolationsLink() const
return the link to truth Et isolations.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:275
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
TruthParticleContainer::genEvent
const HepMC::GenEvent * genEvent() const
Retrieve the HepMC::GenEvent this TruthParticleContainer is proxying.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:230
TruthEtIsolationsContainer.h
McEventCollection.h
TruthParticle::evtIndex_t
std::size_t evtIndex_t
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:71
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TruthParticleContainer::etIsol
double etIsol(const int barcode, const TruthParticleParameters::ConeSize coneIdx) const
Return the Et isolation for a given particle and a given cone size.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:281
TruthParticleContainer::setGenEvent
void setGenEvent(const ElementLink< McEventCollection > &genEvent)
Setup the persistent pointer toward the HepMC::GenEvent this TruthParticleContainer is proxying.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:290
TruthParticleParamDefs.h
TruthParticleContainer::NoIdx
static const std::size_t NoIdx
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:51
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TruthParticle.h
TruthParticleContainer::truthParticle
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
Definition: TruthParticleContainer.cxx:64
TruthParticleContainer::Map_t
std::unordered_map< long, const TruthParticle * > Map_t
barcode to TruthParticle dictionary
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:59
TruthParticleContainer::~TruthParticleContainer
~TruthParticleContainer()
Destructor:
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:217
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
TruthParticleContainer::setParticles
void setParticles(const Map_t &parts)
Setup the dictionary of barcodes-to-TruthParticle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:323
TruthParticleContainer::genEventName
const std::string & genEventName() const
Retrieve the name (StoreGate location) of the HepMC::GenEvent this TruthParticleContainer is proxying...
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:249
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
TruthParticleContainer::etIsolations
const TruthEtIsolations::EtIsol_t * etIsolations(const int barcode) const
return the container of Truth Et isolations for a given TruthParticle (or a HepMC::GenParticle)
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:267
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TruthParticleContainer::genEventLink
const ElementLink< McEventCollection > & genEventLink() const
Retrieve the HepMC::GenEvent this TruthParticleContainer is proxying, as a link.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:237
IParticleContainer.h
doL1CaloHVCorrections.parts
parts
Definition: doL1CaloHVCorrections.py:334
TruthParticleContainer::evtIndex_t
TruthParticle::evtIndex_t evtIndex_t
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:61
TruthParticleCnvTool
Definition: TruthParticleCnvTool.h:60
TruthParticleContainer::truthParticleIdx
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...
Definition: TruthParticleContainer.cxx:75
IParticle
Definition: Event/EventKernel/EventKernel/IParticle.h:43
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
CLASS_DEF.h
macros to associate a CLID to a type
TruthParticleContainer::hasEtIsol
bool hasEtIsol() const
tell if this TruthParticleContainer has been registered with a TruthEtIsolations container
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:255