ATLAS Offline Software
MuonFeature.cxx
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 
8 // STL include(s):
9 #include <sstream>
10 #include <cmath>
11 
12 // Gaudi/Athena include(s):
13 #include "GaudiKernel/MsgStream.h"
14 
15 // Local include(s):
17 
18 // "Distance" used by the comparison operator(s):
19 static const double DELTA = 0.001;
20 
22 {
23  m_algoId = NULLID;
24  m_RoIId = -1;
25  m_saddress = 0;
26  m_pt = 0.;
27  m_radius = 0.;
28  m_eta = 0.;
29  m_phi = 0.;
30  m_dir_phi = 0.;
31  m_zeta = 0.;
32  m_dir_zeta = 0.;
33  m_beta = 0.;
34  m_sp1_r = 0.;
35  m_sp1_z = 0.;
36  m_sp1_slope = 0.;
37  m_sp2_r = 0.;
38  m_sp2_z = 0.;
39  m_sp2_slope = 0.;
40  m_sp3_r = 0.;
41  m_sp3_z = 0.;
42  m_sp3_slope = 0.;
43  m_br_radius = 0.;
44  m_br_sagitta = 0.;
45  m_ec_alpha = 0.;
46  m_ec_beta = 0.;
47  m_dq_var1 = 0.;
48  m_dq_var2 = 0.;
49 }
50 
51 // --- keep for backward compartibility
52 MuonFeature::MuonFeature(int saddress, float pt, float radius,
53  float eta, float phi, float dir_phi, float zeta,
54  float dir_zeta, float beta):
55  m_algoId(NULLID), m_RoIId(-1), m_saddress(saddress),
56  m_pt(pt), m_radius(radius), m_eta(eta), m_phi(phi), m_dir_phi(dir_phi),
57  m_zeta(zeta), m_dir_zeta(dir_zeta), m_beta(beta),
58  m_sp1_r(0.), m_sp1_z(0.), m_sp1_slope(0.),
59  m_sp2_r(0.), m_sp2_z(0.), m_sp2_slope(0.),
60  m_sp3_r(0.), m_sp3_z(0.), m_sp3_slope(0.),
61  m_br_radius(0.), m_br_sagitta(0.),
62  m_ec_alpha(0.), m_ec_beta(0.),
63  m_dq_var1(0.), m_dq_var2(0.)
64 {}
65 
66 // --- new constructor
67 MuonFeature::MuonFeature(int saddress, float pt, float radius,
68  float eta, float phi, float dir_phi, float zeta,
69  float dir_zeta, float beta,
70  float sp1_r, float sp1_z, float sp1_slope,
71  float sp2_r, float sp2_z, float sp2_slope,
72  float sp3_r, float sp3_z, float sp3_slope,
73  float br_radius, float br_sagitta, float ec_alpha, float ec_beta,
74  double dq_var1, double dq_var2):
75  m_algoId(NULLID), m_RoIId(-1), m_saddress(saddress),
76  m_pt(pt), m_radius(radius), m_eta(eta), m_phi(phi), m_dir_phi(dir_phi),
77  m_zeta(zeta), m_dir_zeta(dir_zeta), m_beta(beta),
78  m_sp1_r(sp1_r), m_sp1_z(sp1_z), m_sp1_slope(sp1_slope),
79  m_sp2_r(sp2_r), m_sp2_z(sp2_z), m_sp2_slope(sp2_slope),
80  m_sp3_r(sp3_r), m_sp3_z(sp3_z), m_sp3_slope(sp3_slope),
81  m_br_radius(br_radius), m_br_sagitta(br_sagitta),
82  m_ec_alpha(ec_alpha), m_ec_beta(ec_beta),
83  m_dq_var1(dq_var1), m_dq_var2(dq_var2)
84 {}
85 
87 {
88  m_algoId = muon_feature->algoId();
89  m_RoIId = muon_feature->roiId();
90  m_saddress = muon_feature->saddress();
91  m_pt = muon_feature->pt();
92  m_radius = muon_feature->radius();
93  m_eta = muon_feature->eta();
94  m_phi = muon_feature->phi();
95  m_dir_phi = muon_feature->dir_phi();
96  m_zeta = muon_feature->zeta();
97  m_dir_zeta = muon_feature->dir_zeta();
98  m_beta = muon_feature->beta();
99  m_sp1_r = muon_feature->sp1_r();
100  m_sp1_z = muon_feature->sp1_z();
101  m_sp1_slope = muon_feature->sp1_slope();
102  m_sp2_r = muon_feature->sp2_r();
103  m_sp2_z = muon_feature->sp2_z();
104  m_sp2_slope = muon_feature->sp2_slope();
105  m_sp3_r = muon_feature->sp3_r();
106  m_sp3_z = muon_feature->sp3_z();
107  m_sp3_slope = muon_feature->sp3_slope();
108  m_br_radius = muon_feature->br_radius();
109  m_br_sagitta = muon_feature->br_sagitta();
110  m_ec_alpha = muon_feature->ec_alpha();
111  m_ec_beta = muon_feature->ec_beta();
112  m_dq_var1 = muon_feature->dq_var1();
113  m_dq_var2 = muon_feature->dq_var2();
114 }
115 
117 {
118  m_algoId = muon_feature.algoId();
119  m_RoIId = muon_feature.roiId();
120  m_saddress = muon_feature.saddress();
121  m_pt = muon_feature.pt();
122  m_radius = muon_feature.radius();
123  m_eta = muon_feature.eta();
124  m_phi = muon_feature.phi();
125  m_dir_phi = muon_feature.dir_phi();
126  m_zeta = muon_feature.zeta();
127  m_dir_zeta = muon_feature.dir_zeta();
128  m_beta = muon_feature.beta();
129  m_sp1_r = muon_feature.sp1_r();
130  m_sp1_z = muon_feature.sp1_z();
131  m_sp1_slope = muon_feature.sp1_slope();
132  m_sp2_r = muon_feature.sp2_r();
133  m_sp2_z = muon_feature.sp2_z();
134  m_sp2_slope = muon_feature.sp2_slope();
135  m_sp3_r = muon_feature.sp3_r();
136  m_sp3_z = muon_feature.sp3_z();
137  m_sp3_slope = muon_feature.sp3_slope();
138  m_br_radius = muon_feature.br_radius();
139  m_br_sagitta = muon_feature.br_sagitta();
140  m_ec_alpha = muon_feature.ec_alpha();
141  m_ec_beta = muon_feature.ec_beta();
142  m_dq_var1 = muon_feature.dq_var1();
143  m_dq_var2 = muon_feature.dq_var2();
144 }
145 
146 
149 {
150  m_algoId = muon_feature.algoId();
151  m_RoIId = muon_feature.roiId();
152  m_saddress = muon_feature.saddress();
153  m_pt = muon_feature.pt();
154  m_radius = muon_feature.radius();
155  m_eta = muon_feature.eta();
156  m_phi = muon_feature.phi();
157  m_dir_phi = muon_feature.dir_phi();
158  m_zeta = muon_feature.zeta();
159  m_dir_zeta = muon_feature.dir_zeta();
160  m_beta = muon_feature.beta();
161  m_sp1_r = muon_feature.sp1_r();
162  m_sp1_z = muon_feature.sp1_z();
163  m_sp1_slope = muon_feature.sp1_slope();
164  m_sp2_r = muon_feature.sp2_r();
165  m_sp2_z = muon_feature.sp2_z();
166  m_sp2_slope = muon_feature.sp2_slope();
167  m_sp3_r = muon_feature.sp3_r();
168  m_sp3_z = muon_feature.sp3_z();
169  m_sp3_slope = muon_feature.sp3_slope();
170  m_br_radius = muon_feature.br_radius();
171  m_br_sagitta = muon_feature.br_sagitta();
172  m_ec_alpha = muon_feature.ec_alpha();
173  m_ec_beta = muon_feature.ec_beta();
174  m_dq_var1 = muon_feature.dq_var1();
175  m_dq_var2 = muon_feature.dq_var2();
176 
177  return *this;
178 }
179 
180 std::string str( const MuonFeature& muon ) {
181 
182  std::stringstream stream;
183  stream << "RoI ID: " << muon.roiId()
184  << "; saddress: " << muon.saddress()
185  << "; eta: " << muon.eta()
186  << "; phi: " << muon.phi()
187  << "; pt: " << muon.pt();
188 
189  return stream.str();
190 }
191 
192 MsgStream& operator<< ( MsgStream& m, const MuonFeature& muon ) {
193 
194  return ( m << str( muon ) );
195 
196 }
197 
198 bool operator== ( const MuonFeature& left, const MuonFeature& right ) {
199 
200  if( ( left.algoId() != right.algoId() ) ||
201  ( left.saddress() != right.saddress() ) ||
202  ( std::abs( left.pt() - right.pt() ) > DELTA ) ||
203  ( std::abs( left.radius() - right.radius() ) > DELTA ) ||
204  ( std::abs( left.eta() - right.eta() ) > DELTA ) ||
205  ( std::abs( left.phi() - right.phi() ) > DELTA ) ||
206  ( std::abs( left.dir_phi() - right.dir_phi() ) > DELTA ) ||
207  ( std::abs( left.zeta() - right.zeta() ) > DELTA ) ||
208  ( std::abs( left.dir_zeta() - right.dir_zeta() ) > DELTA ) ||
209  ( std::abs( left.beta() - right.beta() ) > DELTA ) ||
210  ( std::abs( left.sp1_r() - right.sp1_r() ) > DELTA ) ||
211  ( std::abs( left.sp1_z() - right.sp1_z() ) > DELTA ) ||
212  ( std::abs( left.sp1_slope() - right.sp1_slope() ) > DELTA ) ||
213  ( std::abs( left.sp2_r() - right.sp2_r() ) > DELTA ) ||
214  ( std::abs( left.sp2_z() - right.sp2_z() ) > DELTA ) ||
215  ( std::abs( left.sp2_slope() - right.sp2_slope() ) > DELTA ) ||
216  ( std::abs( left.sp3_r() - right.sp3_r() ) > DELTA ) ||
217  ( std::abs( left.sp3_z() - right.sp3_z() ) > DELTA ) ||
218  ( std::abs( left.sp3_slope() - right.sp3_slope() ) > DELTA ) ||
219  ( std::abs( left.br_radius() - right.br_radius() ) > DELTA ) ||
220  ( std::abs( left.br_sagitta() - right.br_sagitta() ) > DELTA ) ||
221  ( std::abs( left.ec_alpha() - right.ec_alpha() ) > DELTA ) ||
222  ( std::abs( left.ec_beta() - right.ec_beta() ) > DELTA ) ||
223  ( std::abs( left.dq_var1() - right.dq_var1() ) > DELTA ) ||
224  ( std::abs( left.dq_var2() - right.dq_var2() ) > DELTA ) ) {
225 
226  return false;
227 
228  } else {
229 
230  return true;
231 
232  }
233 
234 }
235 
236 void diff( const MuonFeature& left, const MuonFeature& right,
237  std::map< std::string, double >& varChange ) {
238 
239  if( std::abs( left.algoId() - right.algoId() ) > DELTA ) {
240  varChange[ "algoId" ] = static_cast< double >( left.algoId() - right.algoId() );
241  }
242  if( left.saddress() != right.saddress() ) {
243  varChange[ "saddress" ] = static_cast< double >( left.saddress() - right.saddress() );
244  }
245  if( std::abs( left.pt() - right.pt() ) > DELTA ) {
246  varChange[ "pt" ] = left.pt() - right.pt();
247  }
248  if( std::abs( left.radius() - right.radius() ) > DELTA ) {
249  varChange[ "radius" ] = left.radius() - right.radius();
250  }
251  if( std::abs( left.eta() - right.eta() ) > DELTA ) {
252  varChange[ "eta" ] = left.eta() - right.eta();
253  }
254  if( std::abs( left.phi() - right.phi() ) > DELTA ) {
255  varChange[ "phi" ] = left.phi() - right.phi();
256  }
257  if( std::abs( left.dir_phi() - right.dir_phi() ) > DELTA ) {
258  varChange[ "dir_phi" ] = left.dir_phi() - right.dir_phi();
259  }
260  if( std::abs( left.zeta() - right.zeta() ) > DELTA ) {
261  varChange[ "zeta" ] = left.zeta() - right.zeta();
262  }
263  if( std::abs( left.dir_zeta() - right.dir_zeta() ) > DELTA ) {
264  varChange[ "dir_zeta" ] = left.dir_zeta() - right.dir_zeta();
265  }
266  if( std::abs( left.beta() - right.beta() ) > DELTA ) {
267  varChange[ "beta" ] = left.beta() - right.beta();
268  }
269  if( std::abs( left.sp1_r() - right.sp1_r() ) > DELTA ) {
270  varChange[ "sp1_r" ] = left.sp1_r() - right.sp1_r();
271  }
272  if( std::abs( left.sp1_z() - right.sp1_z() ) > DELTA ) {
273  varChange[ "sp1_z" ] = left.sp1_z() - right.sp1_z();
274  }
275  if( std::abs( left.sp1_slope() - right.sp1_slope() ) > DELTA ) {
276  varChange[ "sp1_slope" ] = left.sp1_slope() - right.sp1_slope();
277  }
278  if( std::abs( left.sp2_r() - right.sp2_r() ) > DELTA ) {
279  varChange[ "sp2_r" ] = left.sp2_r() - right.sp2_r();
280  }
281  if( std::abs( left.sp2_z() - right.sp2_z() ) > DELTA ) {
282  varChange[ "sp2_z" ] = left.sp2_z() - right.sp2_z();
283  }
284  if( std::abs( left.sp2_slope() - right.sp2_slope() ) > DELTA ) {
285  varChange[ "sp2_slope" ] = left.sp2_slope() - right.sp2_slope();
286  }
287  if( std::abs( left.sp3_r() - right.sp3_r() ) > DELTA ) {
288  varChange[ "sp3_r" ] = left.sp3_r() - right.sp3_r();
289  }
290  if( std::abs( left.sp3_z() - right.sp3_z() ) > DELTA ) {
291  varChange[ "sp3_z" ] = left.sp3_z() - right.sp3_z();
292  }
293  if( std::abs( left.sp3_slope() - right.sp3_slope() ) > DELTA ) {
294  varChange[ "sp3_slope" ] = left.sp3_slope() - right.sp3_slope();
295  }
296  if( std::abs( left.br_radius() - right.br_radius() ) > DELTA ) {
297  varChange[ "br_radius" ] = left.br_radius() - right.br_radius();
298  }
299  if( std::abs( left.br_sagitta() - right.br_sagitta() ) > DELTA ) {
300  varChange[ "br_sagitta" ] = left.br_sagitta() - right.br_sagitta();
301  }
302  if( std::abs( left.ec_alpha() - right.ec_alpha() ) > DELTA ) {
303  varChange[ "ec_alpha" ] = left.ec_alpha() - right.ec_alpha();
304  }
305  if( std::abs( left.ec_beta() - right.ec_beta() ) > DELTA ) {
306  varChange[ "ec_beta" ] = left.ec_beta() - right.ec_beta();
307  }
308  if( std::abs( left.dq_var1() - right.dq_var1() ) > DELTA ) {
309  varChange[ "dq_var1" ] = left.dq_var1() - right.dq_var1();
310  }
311  if( std::abs( left.dq_var2() - right.dq_var2() ) > DELTA ) {
312  varChange[ "dq_var2" ] = left.dq_var2() - right.dq_var2();
313  }
314 
315  return;
316 }
MuonFeature::dq_var2
double dq_var2(void) const
Definition: MuonFeature.h:70
MuonFeature::m_sp1_z
float m_sp1_z
Definition: MuonFeature.h:94
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
MuonFeature::MuonFeature
MuonFeature()
Definition: MuonFeature.cxx:21
MuonFeature::m_dq_var1
double m_dq_var1
Definition: MuonFeature.h:106
MuonFeature::dq_var1
double dq_var1(void) const
Definition: MuonFeature.h:69
MuonFeature::m_pt
float m_pt
Definition: MuonFeature.h:85
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
MuonFeature::m_br_sagitta
float m_br_sagitta
Definition: MuonFeature.h:103
MuonFeature::sp3_slope
float sp3_slope(void) const
Definition: MuonFeature.h:64
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
MuonFeature::m_algoId
AlgoId m_algoId
Definition: MuonFeature.h:82
MuonFeature::radius
float radius(void) const
Definition: MuonFeature.h:49
xAOD::L2MuonParameters::NULLID
@ NULLID
Definition: TrigMuonDefs.h:34
MuonFeature::m_radius
float m_radius
Definition: MuonFeature.h:86
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
MuonFeature::m_saddress
int m_saddress
Definition: MuonFeature.h:84
MuonFeature::dir_phi
float dir_phi(void) const
Definition: MuonFeature.h:52
MuonFeature::m_phi
float m_phi
Definition: MuonFeature.h:88
MuonFeature::sp1_r
float sp1_r(void) const
Definition: MuonFeature.h:56
test_pyathena.pt
pt
Definition: test_pyathena.py:11
MuonFeature::eta
float eta(void) const
Definition: MuonFeature.h:50
diff
void diff(const MuonFeature &left, const MuonFeature &right, std::map< std::string, double > &varChange)
Comparison with feedback.
Definition: MuonFeature.cxx:236
MuonFeature::m_sp3_z
float m_sp3_z
Definition: MuonFeature.h:100
operator<<
MsgStream & operator<<(MsgStream &m, const MuonFeature &muon)
Helper operator for printing the object.
Definition: MuonFeature.cxx:192
MuonFeature::m_ec_beta
float m_ec_beta
Definition: MuonFeature.h:105
MuonFeature::ec_alpha
float ec_alpha(void) const
Definition: MuonFeature.h:67
operator==
bool operator==(const MuonFeature &left, const MuonFeature &right)
Operator comparing two MuonFeature objects for equality.
Definition: MuonFeature.cxx:198
MuonFeature::phi
float phi(void) const
Definition: MuonFeature.h:51
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
MuonFeature.h
MuonFeature::NULLID
@ NULLID
Definition: MuonFeature.h:24
MuonFeature::br_radius
float br_radius(void) const
Definition: MuonFeature.h:65
MuonFeature::dir_zeta
float dir_zeta(void) const
Definition: MuonFeature.h:54
MuonFeature::saddress
int saddress(void) const
Definition: MuonFeature.h:47
MuonFeature::roiId
int roiId(void) const
Definition: MuonFeature.h:46
MuonFeature::br_sagitta
float br_sagitta(void) const
Definition: MuonFeature.h:66
MuonFeature::sp3_z
float sp3_z(void) const
Definition: MuonFeature.h:63
MuonFeature::m_dir_phi
float m_dir_phi
Definition: MuonFeature.h:89
MuonFeature::m_sp1_slope
float m_sp1_slope
Definition: MuonFeature.h:95
MuonFeature::m_zeta
float m_zeta
Definition: MuonFeature.h:90
MuonFeature::algoId
AlgoId algoId(void) const
Definition: MuonFeature.h:45
MuonFeature::m_sp2_r
float m_sp2_r
Definition: MuonFeature.h:96
MuonFeature::sp3_r
float sp3_r(void) const
Definition: MuonFeature.h:62
MuonFeature::m_RoIId
int m_RoIId
Definition: MuonFeature.h:83
MuonFeature
Definition: MuonFeature.h:21
MuonFeature::sp1_z
float sp1_z(void) const
Definition: MuonFeature.h:57
MuonFeature::sp2_z
float sp2_z(void) const
Definition: MuonFeature.h:60
MuonFeature::m_dir_zeta
float m_dir_zeta
Definition: MuonFeature.h:91
MuonFeature::m_ec_alpha
float m_ec_alpha
Definition: MuonFeature.h:104
MuonFeature::sp1_slope
float sp1_slope(void) const
Definition: MuonFeature.h:58
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MuonFeature::m_sp2_slope
float m_sp2_slope
Definition: MuonFeature.h:98
MuonFeature::sp2_slope
float sp2_slope(void) const
Definition: MuonFeature.h:61
MuonFeature::operator=
MuonFeature & operator=(const MuonFeature &muon_feature)
Definition: MuonFeature.cxx:148
MuonFeature::m_sp2_z
float m_sp2_z
Definition: MuonFeature.h:97
MuonFeature::m_sp1_r
float m_sp1_r
Definition: MuonFeature.h:93
MuonFeature::m_eta
float m_eta
Definition: MuonFeature.h:87
str
std::string str(const MuonFeature &muon)
Helper function for printing the object.
Definition: MuonFeature.cxx:180
MuonFeature::m_beta
float m_beta
Definition: MuonFeature.h:92
MuonFeature::ec_beta
float ec_beta(void) const
Definition: MuonFeature.h:68
MuonFeature::pt
float pt(void) const
Definition: MuonFeature.h:48
MuonFeature::beta
float beta(void) const
Definition: MuonFeature.h:55
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
MuonFeature::m_sp3_r
float m_sp3_r
Definition: MuonFeature.h:99
MuonFeature::m_sp3_slope
float m_sp3_slope
Definition: MuonFeature.h:101
MuonFeature::m_dq_var2
double m_dq_var2
Definition: MuonFeature.h:107
MuonFeature::sp2_r
float sp2_r(void) const
Definition: MuonFeature.h:59
MuonFeature::m_br_radius
float m_br_radius
Definition: MuonFeature.h:102
MuonFeature::zeta
float zeta(void) const
Definition: MuonFeature.h:53