ATLAS Offline Software
Loading...
Searching...
No Matches
egDetailContainerCnv_p2.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// egDetailContainerCnv_p2.cxx
8// Implementation file for class egDetailContainerCnv_p2
10
11
13
14// egammaEventTPCnv includes
16
23
24#include <cfloat>
25
26#ifdef MSG_DEBUG
27#undef MSG_DEBUG
28#endif
29#define MSG_DEBUG(log, x) \
30 do { if (log.level()<=MSG::DEBUG) { log << MSG::DEBUG << x << endmsg; } } while (0)
31
32
34 egDetailContainer *trans,
35 MsgStream &msg )
36{
37 trans->clear();
38 egDetailContainer_p2::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 trans->push_back(tmpEMShower);
61
62 }
63 else if ( it->m_className == "EMTrackMatch" ) {
64
65 EMTrackMatch *tmpEMTrackMatch = new EMTrackMatch();
66 for ( unsigned int i=0; i< egEnum.size(); i++ ) {
68 static_cast<egammaParameters::ParamDef> (egEnum[i]);
69 if (key == egammaParameters::EoverP) continue;
72 if ( tmpEMTrackMatch->hasParameter( key ) ) {
73 tmpEMTrackMatch->set_parameter(key, egParams[i]);
74 }
75 else {
76 msg << MSG::ERROR << "Read unknown parameter for "
77 << it->m_className << " Index " << key << endmsg;
78 continue;
79 }
80 }
81 trans->push_back(tmpEMTrackMatch);
82
83 }
84 else if ( it->m_className == "EMConvert" ) {
85
86 EMConvert *tmpEMConvert = new EMConvert();
87 for ( unsigned int i=0; i< egEnum.size(); i++ ) {
88 if ( tmpEMConvert->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
89 tmpEMConvert->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
90 }
91 else {
92 msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
93 << " Index " << egEnum[i] << endmsg;
94 continue;
95 }
96 }
97 trans->push_back(tmpEMConvert);
98
99 }
100 else if ( it->m_className == "EMBremFit" ) {
101
102 EMBremFit *tmpEMBremFit = new EMBremFit();
103 for ( unsigned int i=0; i< egEnum.size(); i++ ) {
104 if ( tmpEMBremFit->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
105 tmpEMBremFit->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
106 }
107 else {
108 msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
109 << " Index " << egEnum[i] << endmsg;
110 continue;
111 }
112 }
113 trans->push_back(tmpEMBremFit);
114 }
115 else if ( it->m_className == "EMTrackFit" ) {
116
117 EMTrackFit *tmpEMTrackFit = new EMTrackFit();
118 for ( unsigned int i=0; i< egEnum.size(); i++ ) {
119 if ( tmpEMTrackFit->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
120 tmpEMTrackFit->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
121 }
122 else {
123 msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
124 << " Index " << egEnum[i] << endmsg;
125 continue;
126 }
127 }
128 trans->push_back(tmpEMTrackFit);
129
130 }
131 else if ( it->m_className == "EMErrorDetail" ) {
132
133 EMErrorDetail *tmpEMErrorDetail = new EMErrorDetail();
134 for ( unsigned int i=0; i< egEnum.size(); i++ ) {
135 if ( tmpEMErrorDetail->hasParameter( (egammaParameters::ParamDef) egEnum[i]) ) {
136 tmpEMErrorDetail->set_parameter((egammaParameters::ParamDef) egEnum[i],egParams[i]);
137 }
138 else {
139 msg << MSG::ERROR << "Read unknown parameter for " << it->m_className
140 << " Index " << egEnum[i] << endmsg;
141 continue;
142 }
143 }
144 trans->push_back(tmpEMErrorDetail);
145
146 }
147 else {
148 msg << MSG::ERROR << "Read unknown egDetail type: " << it->m_className << endmsg;
149 continue;
150 }
151 // trans = (dynamic_cast<EMShower*>(trans));
152
153 }
154
155 MSG_DEBUG(msg, "finished egDetailContainer perstoTrans");
156}
157
160 MsgStream &msg )
161{
163 for( ; it != trans->end(); ++it ){
164
166 std::vector<float>& egParam = detail.m_egDetailFloatParams;
167 std::vector<unsigned int>& egEnum = detail.m_egDetailEnumParams;
168
169 unsigned int nbOfEgammaParams = (int) egammaParameters::lastEgammaParam;
170 // first we need to cast
171 const EMShower *tmpEMShower = dynamic_cast<const EMShower*> (*it);
172 const EMTrackMatch *tmpEMTrackMatch = dynamic_cast<const EMTrackMatch*> (*it);
173 const EMConvert *tmpEMConvert = dynamic_cast<const EMConvert*> (*it);
174 const EMBremFit *tmpEMBremFit = dynamic_cast<const EMBremFit*> (*it);
175 const EMTrackFit *tmpEMTrackFit = dynamic_cast<const EMTrackFit*> (*it);
176 const EMErrorDetail *tmpEMErrorDetail = dynamic_cast<const EMErrorDetail*> (*it);
177 if ( !tmpEMShower &&
178 !tmpEMTrackMatch &&
179 !tmpEMConvert &&
180 !tmpEMBremFit &&
181 !tmpEMTrackFit &&
182 !tmpEMErrorDetail ) {
183 msg << MSG::ERROR << "Unknown egDetail type will not write its data" << endmsg;
184 continue;
185 }
186
187 double tmpParam;
188 if ( tmpEMShower ) {
189 MSG_DEBUG(msg, "decoded detail as " << tmpEMShower->className());
190 detail.m_className = tmpEMShower->className();
191 for ( unsigned int i=0; i<nbOfEgammaParams; i++ ) {
192 tmpParam = tmpEMShower->parameter( (egammaParameters::ParamDef)i);
193 if ( tmpParam != egammaParameters::EgParamUndefined ) {
194 if (tmpParam > FLT_MAX) tmpParam = FLT_MAX;
195 if (tmpParam < - FLT_MAX) tmpParam = - FLT_MAX;
196 egEnum.push_back(i);
197 egParam.push_back(tmpParam);
198 }
199 }
200 }
201 else if ( tmpEMTrackMatch ) {
202 MSG_DEBUG(msg, "decoded detail as " << tmpEMTrackMatch->className());
203 detail.m_className = tmpEMTrackMatch->className();
204 for ( unsigned int i=0; i<nbOfEgammaParams; i++ ) {
205 tmpParam = tmpEMTrackMatch->parameter( (egammaParameters::ParamDef)i);
206 if ( tmpParam != egammaParameters::EgParamUndefined ) {
207 if (tmpParam > FLT_MAX) tmpParam = FLT_MAX;
208 if (tmpParam < - FLT_MAX) tmpParam = - FLT_MAX;
209 egEnum.push_back(i);
210 egParam.push_back(tmpParam);
211 }
212 }
213 }
214 else if ( tmpEMConvert ) {
215 MSG_DEBUG(msg, "decoded detail as " << tmpEMConvert->className());
216 detail.m_className = tmpEMConvert->className();
217 for ( unsigned int i=0; i<nbOfEgammaParams; i++ ) {
218 tmpParam = tmpEMConvert->parameter( (egammaParameters::ParamDef)i);
219 if ( tmpParam != egammaParameters::EgParamUndefined ) {
220 if (tmpParam > FLT_MAX) tmpParam = FLT_MAX;
221 if (tmpParam < - FLT_MAX) tmpParam = - FLT_MAX;
222 egEnum.push_back(i);
223 egParam.push_back(tmpParam);
224 }
225 }
226 }
227 else if ( tmpEMBremFit ) {
228 MSG_DEBUG(msg, "decoded detail as " << tmpEMBremFit->className());
229 detail.m_className = tmpEMBremFit->className();
230 for ( unsigned int i=0; i<nbOfEgammaParams; i++ ) {
231 tmpParam = tmpEMBremFit->parameter( (egammaParameters::ParamDef)i);
232 if ( tmpParam != egammaParameters::EgParamUndefined ) {
233 if (tmpParam > FLT_MAX) tmpParam = FLT_MAX;
234 if (tmpParam < - FLT_MAX) tmpParam = - FLT_MAX;
235 egEnum.push_back(i);
236 egParam.push_back(tmpParam);
237 }
238 }
239 }
240 else if ( tmpEMTrackFit ) {
241 MSG_DEBUG(msg, "decoded detail as " << tmpEMTrackFit->className());
242 detail.m_className = tmpEMTrackFit->className();
243 for ( unsigned int i=0; i<nbOfEgammaParams; i++ ) {
244 tmpParam = tmpEMTrackFit->parameter( (egammaParameters::ParamDef)i);
245 if ( tmpParam != egammaParameters::EgParamUndefined ) {
246 if (tmpParam > FLT_MAX) tmpParam = FLT_MAX;
247 if (tmpParam < - FLT_MAX) tmpParam = - FLT_MAX;
248 egEnum.push_back(i);
249 egParam.push_back(tmpParam);
250 }
251 }
252 }
253 else if ( tmpEMErrorDetail ) {
254 MSG_DEBUG(msg, "decoded detail as " << tmpEMErrorDetail->className());
255 detail.m_className = tmpEMErrorDetail->className();
256 for ( unsigned int i=0; i<nbOfEgammaParams; i++ ) {
257 tmpParam = tmpEMErrorDetail->parameter( (egammaParameters::ParamDef)i);
258 if ( tmpParam != egammaParameters::EgParamUndefined ) {
259 if (tmpParam > FLT_MAX) tmpParam = FLT_MAX;
260 if (tmpParam < - FLT_MAX) tmpParam = - FLT_MAX;
261 egEnum.push_back(i);
262 egParam.push_back(tmpParam);
263 }
264 }
265 }
266
267 pers->push_back( detail );
268 }
269
270}
#define endmsg
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:15
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void clear()
Erase all the elements in the collection.
EMBremFit is made by EMBremsstrahlungBuilder.
Definition EMBremFit.h:27
virtual bool hasParameter(egammaParameters::ParamDef) const
virtual const std::string & className() const
Definition EMBremFit.cxx:40
virtual double parameter(egammaParameters::ParamDef) const
Definition EMBremFit.cxx:45
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
Definition EMBremFit.cxx:66
EM convert property class data class.
Definition EMConvert.h:35
virtual const std::string & className() const
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general parameter setting
virtual double parameter(egammaParameters::ParamDef) const
general parameter retrieval
virtual bool hasParameter(egammaParameters::ParamDef) const
Definition EMConvert.cxx:65
virtual const std::string & className() const
virtual double parameter(egammaParameters::ParamDef) const
virtual bool hasParameter(egammaParameters::ParamDef) const
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
EM shower property class data class.
Definition EMShower.h:24
virtual bool hasParameter(egammaParameters::ParamDef) const
Definition EMShower.cxx:227
virtual double parameter(egammaParameters::ParamDef) const
Definition EMShower.cxx:71
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
Definition EMShower.cxx:90
virtual const std::string & className() const
Definition EMShower.cxx:65
Contains the fit result with addtional brem information EMTrackFit is made by EMTrkRefitter.
Definition EMTrackFit.h:35
virtual bool hasParameter(egammaParameters::ParamDef) const
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
virtual double parameter(egammaParameters::ParamDef) const
virtual const std::string & className() const
Track match property data class.
virtual double parameter(egammaParameters::ParamDef) const override
virtual const std::string & className() const override
interface methods
virtual bool hasParameter(egammaParameters::ParamDef) const override
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
virtual void transToPers(const egDetailContainer *transObj, egDetailContainer_p2 *persObj, MsgStream &msg)
virtual void persToTrans(const egDetailContainer_p2 *persObj, egDetailContainer *transObj, MsgStream &msg)
Container for detailed egamma information.
@ etaSampling1
eta position at sampling 1 for track extrapolated from the last hit.
@ EoverP
ratio of the cluster energy and the track momentum
@ EtaCorrMag
eta of the track extrapolated to the first sampling (NB : should be equivalent to etaSampling1
const double EgParamUndefined
MsgStream & msg
Definition testRead.cxx:32