ATLAS Offline Software
Loading...
Searching...
No Matches
McEtIsolVisitor.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5*/
6
7// McEtIsolVisitor.h
8// Header file for class McEtIsolVisitor
9// Author: S.Binet<binet@cern.ch>
11#ifndef MCPARTICLEEVENTTPCNV_MCETISOLVISITOR_H
12#define MCPARTICLEEVENTTPCNV_MCETISOLVISITOR_H
13
14// STL includes
15#include <stdexcept>
16
17// Gaudi includes
18#include "GaudiKernel/MsgStream.h"
19
20// McParticleKernel includes
22
23// McParticleEvent includes
25
26// Forward declaration
27
28template <class TruthParticleContainer_pX>
30{
31
33 // Public methods:
35 public:
36
41 m_msg ( rhs.m_msg ),
42 m_persObj( rhs.m_persObj ),
43 m_etIsols( rhs.m_etIsols )
44 {}
45
48 McEtIsolVisitor( const TruthParticleContainer_pX& persObj,
49 TruthEtIsolations* etIsols,
50 MsgStream& msg ) :
52 m_msg ( &msg ),
53 m_persObj( persObj ),
54 m_etIsols( etIsols )
55 {}
56
59 virtual ~McEtIsolVisitor();
60
62 // Const methods:
64
68 virtual void visit( TruthParticle* truthParticle ) const;
69
71 // Non-const methods:
73
75 // Protected methods:
77 protected:
78
82
86
88 // Private data:
90 private:
91
92 MsgStream* m_msg;
93 const TruthParticleContainer_pX& m_persObj;
94
96};
97
99// Inline methods:
101
102template<class TruthParticleContainer_pX>
105
106template<class TruthParticleContainer_pX>
107void
109{
110 if ( 0 == mc ) {
111 return;
112 }
113
114 const int barcode = mc->barcode();
115 try {
116 const std::vector<float>& etIsolations = m_persObj.etIsol(barcode);
117 if ( etIsolations.empty() ) {
118 // do nothing: no particle will be registered in the TruthEtIsolations.
119 } else {
120 const HepMC::GenParticle* hepMcPart = mc->genParticle();
121 for ( std::size_t j = 0;
122 j != static_cast<std::size_t>(TruthParticleParameters::NbrOfCones);
123 ++j ) {
124 m_etIsols->setEtIsol( hepMcPart,
125 static_cast<TruthParticleParameters::ConeSize>(j),
126 etIsolations[j] );
127
128 }
129 }
130 } catch (std::out_of_range& e) {
131 *m_msg << MSG::WARNING
132 << "Caught an out of range exception for this barcode: " << barcode
133 << endmsg
134 << e.what() << endmsg
135 << "This particle won't have any et isolation informations !!"
136 << endmsg;
137 // we don't want to have a buggy McTruth, do we ?
138 throw std::runtime_error("Reqested an UNKNOWN TruthParticle/barcode");
139 }
140
141 return;
142}
143
144#endif //> MCPARTICLEEVENTTPCNV_MCETISOLVISITOR_H
#define endmsg
ITruthParticleVisitor()
Default constructor:
const TruthParticleContainer_pX & m_persObj
McEtIsolVisitor(const McEtIsolVisitor &rhs)
Copy constructor:
virtual ~McEtIsolVisitor()
Destructor:
virtual void visit(TruthParticle *truthParticle) const
The method to visit a TruthParticle to apply further modifications to the instance at hand.
McEtIsolVisitor()
Default constructor:
TruthEtIsolations * m_etIsols
McEtIsolVisitor & operator=(const McEtIsolVisitor &rhs)
Assignment operator:
McEtIsolVisitor(const TruthParticleContainer_pX &persObj, TruthEtIsolations *etIsols, MsgStream &msg)
Constructor with parameters:
MsgStream * m_msg
container which holds isolation informations for a given HepMC::GenParticle (labelled by barcode) for...
ConeSize
Enum for Cone size indexes (for isolation)
MsgStream & msg
Definition testRead.cxx:32