ATLAS Offline Software
egDetailContainerCnv_p1.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // egDetailContainerCnv_p1.cxx
8 // Implementation file for class egDetailContainerCnv_p1
9 // Author: K.Cranmer<cranmer@cern.ch>
10 // Author: S.Binet<binet@cern.ch>
12 
13 
15 
16 // egammaEventTPCnv includes
18 
19 #include "egammaEvent/EMShower.h"
21 #include "egammaEvent/EMConvert.h"
22 #include "egammaEvent/EMBremFit.h"
23 #include "egammaEvent/EMTrackFit.h"
25 #include "GaudiKernel/GaudiException.h"
26 
27 #ifdef MSG_DEBUG
28 #undef MSG_DEBUG
29 #endif
30 #define MSG_DEBUG(log, x) \
31  do { if (log.level()<=MSG::DEBUG) { log << MSG::DEBUG << x << endmsg; } } while (0)
32 
34  egDetailContainer *trans,
35  MsgStream &msg )
36 {
37  trans->clear();
38  egDetailContainer_p1::const_iterator it = pers->begin();
39 
40  for( ; it != pers->end(); ++it ){
41 
42  const std::vector<float>& egParams = it->m_egDetailFloatParams;
43  const std::vector<unsigned int>& egEnum = it->m_egDetailEnumParams;
44  // if you crash here, then there is a data corruption...
45  assert( egEnum.size() == egParams.size() );
46 
47  if ( it->m_className == "EMShower" ) {
48 
49  EMShower *tmpEMShower = new EMShower();
50  for ( unsigned int i=0; i< egEnum.size(); i++ ) {
51  if ( tmpEMShower->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
52  tmpEMShower->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
53  }
54  else {
55  msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
56  << " Index " << egEnum[i] << endmsg;
57  continue;
58  }
59  }
60  tmpEMShower->set_linkIndex(0);
61  trans->push_back(tmpEMShower);
62 
63  }
64  else if ( it->m_className == "EMTrackMatch" ) {
65 
66  EMTrackMatch *tmpEMTrackMatch = new EMTrackMatch();
67  for ( unsigned int i=0; i< egEnum.size(); i++ ) {
69  static_cast<egammaParameters::ParamDef> (egEnum[i]);
70  if (key == egammaParameters::EoverP) continue;
73  if ( tmpEMTrackMatch->hasParameter( key ) ) {
74  tmpEMTrackMatch->set_parameter(key,egParams[i]);
75  }
76  else {
77  msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
78  << " Index " << key << endmsg;
79  continue;
80  }
81  }
82  tmpEMTrackMatch->set_linkIndex(0);
83  trans->push_back(tmpEMTrackMatch);
84 
85  }
86  else if ( it->m_className == "EMConvert" ) {
87 
88  EMConvert *tmpEMConvert = new EMConvert();
89  for ( unsigned int i=0; i< egEnum.size(); i++ ) {
90  if ( tmpEMConvert->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
91  tmpEMConvert->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
92  }
93  else {
94  msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
95  << " Index " << egEnum[i] << endmsg;
96  continue;
97  }
98  }
99  tmpEMConvert->set_linkIndex(0);
100  trans->push_back(tmpEMConvert);
101 
102  }
103  else if ( it->m_className == "EMBremFit" ) {
104 
105  EMBremFit *tmpEMBremFit = new EMBremFit();
106  for ( unsigned int i=0; i< egEnum.size(); i++ ) {
107  if ( tmpEMBremFit->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
108  tmpEMBremFit->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
109  }
110  else {
111  msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
112  << " Index " << egEnum[i] << endmsg;
113  continue;
114  }
115  }
116  tmpEMBremFit->set_linkIndex(0);
117  trans->push_back(tmpEMBremFit);
118  }
119  else if ( it->m_className == "EMTrackFit" ) {
120 
121  EMTrackFit *tmpEMTrackFit = new EMTrackFit();
122  for ( unsigned int i=0; i< egEnum.size(); i++ ) {
123  if ( tmpEMTrackFit->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
124  tmpEMTrackFit->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
125  }
126  else {
127  msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
128  << " Index " << egEnum[i] << endmsg;
129  continue;
130  }
131  }
132  tmpEMTrackFit->set_linkIndex(0);
133  trans->push_back(tmpEMTrackFit);
134 
135  }
136  else if ( it->m_className == "EMErrorDetail" ) {
137 
138  EMErrorDetail *tmpEMErrorDetail = new EMErrorDetail();
139  for ( unsigned int i=0; i< egEnum.size(); i++ ) {
140  if ( tmpEMErrorDetail->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
141  tmpEMErrorDetail->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
142  }
143  else {
144  msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
145  << " Index " << egEnum[i] << endmsg;
146  continue;
147  }
148  }
149  tmpEMErrorDetail->set_linkIndex(0);
150  trans->push_back(tmpEMErrorDetail);
151 
152  }
153  else {
154  msg << MSG::ERROR << "Read unknown egDetail type: " << it->m_className << endmsg;
155  continue;
156  }
157  // trans = (dynamic_cast<EMShower*>(trans));
158 
159  }
160 
161  MSG_DEBUG(msg, "finished egDetailContainer perstoTrans");
162 }
163 
164 
166  egDetailContainer_p1* /*pers*/,
167  MsgStream& /*msg*/)
168 {
169  throw GaudiException("Deprecated method, we have evolved to use egDetail_p2.Please migrate to use egDetailContainerCnv_p2::transToPers","egDetailContainerCnv_p1::transToPers", StatusCode::FAILURE);
170 }
EMConvert
Definition: EMConvert.h:35
EMTrackMatch
Definition: EMTrackMatch.h:20
egDetailContainerCnv_p1::persToTrans
virtual void persToTrans(const egDetailContainer_p1 *persObj, egDetailContainer *transObj, MsgStream &msg)
Definition: egDetailContainerCnv_p1.cxx:33
EMBremFit::set_parameter
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
Definition: EMBremFit.cxx:66
EMConvert::set_linkIndex
void set_linkIndex(int)
Definition: EMConvert.cxx:591
EMBremFit::set_linkIndex
void set_linkIndex(int)
Definition: EMBremFit.cxx:199
EMShower::set_linkIndex
void set_linkIndex(int)
skel.it
it
Definition: skel.GENtoEVGEN.py:396
EMConvert::hasParameter
virtual bool hasParameter(egammaParameters::ParamDef) const
Definition: EMConvert.cxx:65
egammaParameters::ParamDef
ParamDef
Definition: egammaParamDefs.h:99
egDetailContainer.h
EMTrackMatch::hasParameter
virtual bool hasParameter(egammaParameters::ParamDef) const override
Definition: EMTrackMatch.cxx:445
EMErrorDetail::hasParameter
virtual bool hasParameter(egammaParameters::ParamDef) const
EMErrorDetail::set_parameter
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
Definition: EMErrorDetail.cxx:98
EMBremFit::hasParameter
virtual bool hasParameter(egammaParameters::ParamDef) const
Definition: EMBremFit.cxx:201
EMTrackFit::hasParameter
virtual bool hasParameter(egammaParameters::ParamDef) const
EMTrackFit
Definition: EMTrackFit.h:35
EMShower
Definition: EMShower.h:24
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EMTrackFit.h
egDetailContainerCnv_p1::transToPers
virtual void transToPers(const egDetailContainer *transObj, egDetailContainer_p1 *persObj, MsgStream &msg)
Definition: egDetailContainerCnv_p1.cxx:165
EMErrorDetail.h
EMTrackFit::set_linkIndex
void set_linkIndex(int)
Index of track this EMTrackFit is associated with.
Definition: EMTrackFit.cxx:484
EMErrorDetail
Definition: EMErrorDetail.h:30
EMTrackMatch::set_parameter
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
Definition: EMTrackMatch.cxx:132
DataVector::clear
void clear()
Erase all the elements in the collection.
egDetailContainer_p1
Definition: egDetailContainer_p1.h:23
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
EMShower.h
EMTrackFit::set_parameter
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
Definition: EMTrackFit.cxx:76
MSG_DEBUG
#define MSG_DEBUG(log, x)
Definition: egDetailContainerCnv_p1.cxx:30
EMBremFit
Definition: EMBremFit.h:27
egammaParameters::EtaCorrMag
@ EtaCorrMag
eta of the track extrapolated to the first sampling (NB : should be equivalent to etaSampling1
Definition: egammaParamDefs.h:197
EMTrackMatch::set_linkIndex
virtual void set_linkIndex(int value) override
Definition: EMTrackMatch.cxx:652
EMShower::set_parameter
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
Definition: EMShower.cxx:90
egDetailContainerCnv_p1.h
EMShower::hasParameter
virtual bool hasParameter(egammaParameters::ParamDef) const
Definition: EMShower.cxx:227
EMErrorDetail::set_linkIndex
void set_linkIndex(int)
Set link index.
Definition: EMErrorDetail.cxx:632
egammaParameters::etaSampling1
@ etaSampling1
eta position at sampling 1 for track extrapolated from the last hit.
Definition: egammaParamDefs.h:599
egammaParameters::EoverP
@ EoverP
ratio of the cluster energy and the track momentum
Definition: egammaParamDefs.h:199
EMTrackMatch.h
egDetailContainer
Definition: egDetailContainer.h:18
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
EMConvert.h
EMConvert::set_parameter
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general parameter setting
Definition: EMConvert.cxx:222
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
EMBremFit.h