ATLAS Offline Software
TruthEtIsolationsCnv_p1.cxx
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 // TruthEtIsolationsCnv_p1.cxx
8 // Implementation file for class TruthEtIsolationsCnv_p1
9 // Author: S.Binet<binet@cern.ch>
11 
12 
13 // STL includes
14 
15 // Framework includes
16 #include "GaudiKernel/MsgStream.h"
17 
18 // HepMc includes
20 
21 // McParticleEvent includes
23 
24 // McParticleEventTPCnv includes
26 
27 
32 
33 void
35  TruthEtIsolations* trans,
36  MsgStream& msg ) const
37 {
38  msg << MSG::DEBUG
39  << "Loading TruthEtIsolations from persistent state..."
40  << endmsg;
41 
42  if (0==pers || 0==trans) {
43  msg << MSG::WARNING
44  << "null pointer(s) received ! trans=[" << trans << "] pers=["
45  << pers << "]"
46  << endmsg;
47  return;
48  }
49 
50  // convert the ElementLink<McEventCollection>
52  &trans->m_genEvtLink,
53  msg );
54 
56  if ( 0 == evt ) {
57  const std::string error("NULL pointer to McEventCollection !!");
58  msg << MSG::ERROR << error
59  << endmsg;
60  throw std::runtime_error(error);
61  }
62 
63  for ( EtIsolMap_p::const_iterator
64  i = pers->m_etIsolations.begin(),
65  iEnd = pers->m_etIsolations.end();
66  i != iEnd;
67  ++i ) {
68  McAod::EtIsolations& etIsols = trans->m_etIsolations[i->first];
69  std::copy( i->second.begin(), i->second.end(),
70  etIsols.begin() );
71  }
72 
73  msg << MSG::DEBUG
74  << "Loaded TruthEtIsolations from persistent state [OK]"
75  << endmsg;
76  return;
77 }
78 
79 void
81  TruthEtIsolations_p1* pers,
82  MsgStream& msg ) const
83 {
84  msg << MSG::DEBUG
85  << "Creating persistent state of TruthEtIsolations..."
86  << endmsg;
87 
88  // convert the ElementLink<McEventCollection>
90  &pers->m_genEvent,
91  msg );
92 
93  if ( !trans->m_genEvtLink.isValid() ) {
94  msg << MSG::WARNING
95  << "Transient ElementLink to McEventCollection is NOT valid !!"
96  << endmsg;
97  }
98 
99  pers->m_etIsolations.reserve( trans->size() );
100  for ( EtIsolMap_t::const_iterator
101  i = trans->m_etIsolations.begin(),
102  iEnd = trans->m_etIsolations.end();
103  i != iEnd;
104  ++i ) {
105  pers->m_etIsolations.push_back( EtIsolBc_p( i->first, EtIsolations_p() ) );
106  EtIsolations_p& etIsols = pers->m_etIsolations.back().second;
107  std::copy( i->second.begin(),
108  i->second.end(),
109  etIsols.begin() );
110  }
111  return;
112 }
TruthEtIsolations::EtIsolMap_t
std::unordered_map< int, EtIsol_t > EtIsolMap_t
The map of barcode-to-Et isolations.
Definition: TruthEtIsolations.h:55
TruthEtIsolations::m_genEvtLink
GenEventLink_t m_genEvtLink
ElementLink to the HepMC::GenEvent from which the Et isolations have been (or will be) computed
Definition: TruthEtIsolations.h:200
TruthEtIsolations_p1
Definition: TruthEtIsolations_p1.h:31
EtIsolations_p
TruthEtIsolations_p1::EtIsolations_t EtIsolations_p
Definition: TruthEtIsolationsCnv_p1.cxx:30
TruthEtIsolations::m_etIsolations
EtIsolMap_t m_etIsolations
Holds transverse energy isolations for different isolation cones The key of this map is the barcode o...
Definition: TruthEtIsolations.h:205
EtIsolMap_p
TruthEtIsolations_p1::EtIsolMap_t EtIsolMap_p
Definition: TruthEtIsolationsCnv_p1.cxx:28
TruthEtIsolations_p1::EtIsolBc_t
std::pair< int, EtIsolations_t > EtIsolBc_t
Definition: TruthEtIsolations_p1.h:47
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
TruthEtIsolations.h
McAod::EtIsolations
std::array< double, TruthParticleParameters::NbrOfCones > EtIsolations
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
Definition: TruthParticleParamDefs.h:60
TruthEtIsolationsCnv_p1::m_genEvtCnv
ElementLinkCnv_p1< ElementLink< McEventCollection > > m_genEvtCnv
Converter for the ElementLink<McEventCollection> data member.
Definition: TruthEtIsolationsCnv_p1.h:62
McEventCollection.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
ElementLinkCnv_p1::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
TruthEtIsolations::size
std::size_t size() const
Return the number of HepMC::GenParticle for which Et isolations have been stored into this TruthEtIso...
Definition: TruthEtIsolations.h:223
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TruthEtIsolationsCnv_p1::persToTrans
virtual void persToTrans(const TruthEtIsolations_p1 *persObj, TruthEtIsolations *transObj, MsgStream &msg) const override
Method creating the transient representation of TruthEtIsolations from its persistent representation ...
Definition: TruthEtIsolationsCnv_p1.cxx:34
TruthEtIsolations_p1::EtIsolMap_t
std::vector< EtIsolBc_t > EtIsolMap_t
Definition: TruthEtIsolations_p1.h:48
TruthEtIsolations_p1::m_genEvent
ElementLinkInt_p1 m_genEvent
The persistent pointer toward the McEventCollection the (transient) TruthEtIsolations has been comput...
Definition: TruthEtIsolations_p1.h:79
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
ElementLinkCnv_p1::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
TruthEtIsolations_p1::EtIsolations_t
std::array< float, TruthParticleParameters::NbrOfCones > EtIsolations_t
Definition: TruthEtIsolations_p1.h:45
EtIsolBc_p
TruthEtIsolations_p1::EtIsolBc_t EtIsolBc_p
Definition: TruthEtIsolationsCnv_p1.cxx:29
TruthEtIsolations
Definition: TruthEtIsolations.h:40
DEBUG
#define DEBUG
Definition: page_access.h:11
EtIsolMap_t
TruthEtIsolations::EtIsolMap_t EtIsolMap_t
Definition: TruthEtIsolationsCnv_p1.cxx:31
TruthEtIsolationsCnv_p1::transToPers
virtual void transToPers(const TruthEtIsolations *transObj, TruthEtIsolations_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation TruthEtIsolations_p1 from its transient representation ...
Definition: TruthEtIsolationsCnv_p1.cxx:80
calibdata.copy
bool copy
Definition: calibdata.py:27
get_generator_info.error
error
Definition: get_generator_info.py:40
error
Definition: IImpactPoint3dEstimator.h:70
TruthEtIsolations_p1::m_etIsolations
EtIsolMap_t m_etIsolations
The persistent representation of Et-isolations: a vector pairs (barcode, array-of-Et-isols)
Definition: TruthEtIsolations_p1.h:83
TruthEtIsolationsCnv_p1.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7