ATLAS Offline Software
CombinedMuonFeature.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  m_pt(0.), m_sigma_pt(0.), m_charge(0.0), m_flag(0), m_muFastTrack(), m_IDTrack()
23 {}
24 
25 CombinedMuonFeature::CombinedMuonFeature(float ptsign, float sigma_pt,
26  const ElementLink< MuonFeatureContainer>& muFastOutput,
27  const ElementLink< TrigInDetTrackCollection>& IdscanOutput):
30  m_pt(fabs(ptsign)),
31  m_sigma_pt(sigma_pt),
32  m_flag(0),
33  m_muFastTrack(muFastOutput),
34  m_IDTrack(IdscanOutput)
35 {
36  if (ptsign == 0) m_charge = 0.0;
37  else if (ptsign > 0) m_charge = 1.0;
38  else m_charge = -1.0;
39 }
40 
41 CombinedMuonFeature::CombinedMuonFeature(float ptsign, float sigma_pt, int fs, int fe, int fm,
42  const ElementLink< MuonFeatureContainer>& muFastOutput,
43  const ElementLink< TrigInDetTrackCollection>& IdscanOutput):
46  m_pt(fabs(ptsign)),
47  m_sigma_pt(sigma_pt),
48  m_flag(fs*10000+fe*100+fm),
49  m_muFastTrack(muFastOutput),
50  m_IDTrack(IdscanOutput)
51 {
52  if (ptsign == 0) m_charge = 0.0;
53  else if (ptsign > 0) m_charge = 1.0;
54  else m_charge = -1.0;
55 }
56 
57 CombinedMuonFeature::CombinedMuonFeature(float pt, float sigma_pt, float q, int fs, int fe, int fm,
58  const ElementLink< MuonFeatureContainer>& muFastOutput,
59  const ElementLink< TrigInDetTrackCollection>& IdscanOutput):
62  m_pt(pt),
63  m_sigma_pt(sigma_pt),
64  m_charge(q),
65  m_flag(fs*10000+fe*100+fm),
66  m_muFastTrack(muFastOutput),
67  m_IDTrack(IdscanOutput)
68 {}
69 
70 CombinedMuonFeature::CombinedMuonFeature(float pt, float sigma_pt, float q,
71  int flag,
72  const ElementLink< MuonFeatureContainer>& muFastOutput,
73  const ElementLink< TrigInDetTrackCollection>& IdscanOutput):
76  m_pt(pt),
77  m_sigma_pt(sigma_pt),
78  m_charge(q),
79  m_flag(flag),
80  m_muFastTrack(muFastOutput),
81  m_IDTrack(IdscanOutput)
82 {}
83 
84 double CombinedMuonFeature::sigma_pt(void) const {
85  if (m_charge == 0) {//for backward compatibility
86  if (m_sigma_pt < 0) return 0.;
87  else {
88  double ftmp{0};
89  double stmp = modf(m_sigma_pt/10000., &ftmp)*1000000.;
90  return static_cast<float>(stmp);
91  }
92  }
93  else
94  return m_sigma_pt;
95 }
96 
98  if (m_charge == 0) {//for backward compatibility
99  if (m_sigma_pt < 0) return -1;
100  else return static_cast<int>(floor(m_sigma_pt/10000.));
101  }
102  else {
103  int a = static_cast<int>(m_flag/10000);
104  return a;
105  }
106 }
107 
109  int a = static_cast<int>(m_flag/10000);
110  int b = static_cast<int>((m_flag-a*10000)/100);
111  return b;
112 }
113 
115  int a = static_cast<int>(m_flag/10000);
116  int b = static_cast<int>((m_flag-a*10000)/100);
117  int c = static_cast<int>(m_flag-a*10000-b*100);
118  return c;
119 }
120 
122  muon_feature) :
123  I4Momentum( *muon_feature ),
124  INavigable( *muon_feature ),
125  INavigable4Momentum( *muon_feature ),
126  P4PtEtaPhiMBase ( *muon_feature ),
128  m_pt (muon_feature->m_pt),
129  m_sigma_pt (muon_feature->m_sigma_pt),
130  m_charge (muon_feature->m_charge),
131  m_flag (muon_feature->m_flag),
132  m_muFastTrack (muon_feature->m_muFastTrack),
133  m_IDTrack (muon_feature->m_IDTrack)
134 {}
135 
136 
138  muon_feature)
139  : I4Momentum(muon_feature),INavigable(muon_feature),IAthenaBarCode(muon_feature),INavigable4Momentum(muon_feature),
140  P4PtEtaPhiMBase(muon_feature),NavigableTerminalNode( ),
141  m_pt(muon_feature.m_pt),
142  m_sigma_pt(muon_feature.m_sigma_pt),
143  m_charge(muon_feature.m_charge),
144  m_flag (muon_feature.m_flag),
145  m_muFastTrack (muon_feature.m_muFastTrack),
146  m_IDTrack (muon_feature.m_IDTrack)
147 {}
148 
149 
150 
153  m_pt = muon_feature.m_pt;
154  m_sigma_pt = muon_feature.m_sigma_pt;
155  m_charge = muon_feature.m_charge;
156  m_flag = muon_feature.m_flag,
157  m_muFastTrack = muon_feature.m_muFastTrack;
158  m_IDTrack = muon_feature.m_IDTrack;
159 
160  return *this;
161 }
162 
163 double CombinedMuonFeature::eta(void) const {
164  return m_IDTrack.isValid() ? (*m_IDTrack)->param()->eta() : 0.0;
165 }
166 
167 double CombinedMuonFeature::phi(void) const {
168  return m_IDTrack.isValid() ? (*m_IDTrack)->param()->phi0() : 0.0;
169 }
170 
172 // helper operators
173 
174 std::string str ( const CombinedMuonFeature& d ) {
175  std::stringstream ss;
176  ss << "Pt: " << d.pt()
177  << "; sigmaPt: " << d.sigma_pt()
178  << "; charge: " << d.charge()
179  << "; flag: " << d.getFlag()
180  << "; Eta: " << d.eta()
181  << "; Phi: " << d.phi();
182 
183  return ss.str();
184 }
185 
186 MsgStream& operator<< ( MsgStream& m, const CombinedMuonFeature& d ) {
187 
188  return ( m << str( d ) );
189 }
190 
192 
193  if( std::abs( a.pt() - b.pt() ) > DELTA ) return false;
194  if( std::abs( a.charge() - b.charge() ) > DELTA ) return false;
195  if( std::abs( a.sigma_pt() - b.sigma_pt() ) > DELTA ) return false;
196  if( std::abs( a.getFlag() - b.getFlag() ) > DELTA ) return false;
197  if( std::abs( a.eta() - b.eta() ) > DELTA ) return false;
198  if( std::abs( a.phi() - b.phi() ) > DELTA ) return false;
199 
200  return true;
201 }
202 
213  std::map< std::string, double >& variableChange ) {
214 
215  if( std::abs( a.pt() - b.pt() ) > DELTA ) {
216  variableChange[ "Pt" ] = a.pt() - b.pt();
217  }
218  if( std::abs( a.charge() - b.charge() ) > DELTA ) {
219  variableChange[ "Charge" ] = a.charge() - b.charge();
220  }
221  if( std::abs( a.sigma_pt() - b.sigma_pt() ) > DELTA ) {
222  variableChange[ "sigmaPt" ] = a.sigma_pt() - b.sigma_pt();
223  }
224  if( std::abs( a.getFlag() - b.getFlag() ) > DELTA ) {
225  variableChange[ "flag" ] = a.getFlag() - b.getFlag();
226  }
227  if( std::abs( a.eta() - b.eta() ) > DELTA ) {
228  variableChange[ "Eta" ] = a.eta() - b.eta();
229  }
230  if( std::abs( a.phi() - b.phi() ) > DELTA ) {
231  variableChange[ "Phi" ] = a.phi() - b.phi();
232  }
233 
234  return;
235 }
236 
CombinedMuonFeature::comb_strategy
int comb_strategy(void) const
Definition: CombinedMuonFeature.cxx:97
I4Momentum
Definition: I4Momentum.h:31
CombinedMuonFeature::operator=
CombinedMuonFeature & operator=(const CombinedMuonFeature &muon_feature)
Definition: CombinedMuonFeature.cxx:152
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
CombinedMuonFeature::m_IDTrack
ElementLink< TrigInDetTrackCollection > m_IDTrack
Definition: CombinedMuonFeature.h:81
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
operator==
bool operator==(const CombinedMuonFeature &a, const CombinedMuonFeature &b)
Operator comparing two CombinedMuonFeature objects for equality.
Definition: CombinedMuonFeature.cxx:191
CombinedMuonFeature::eta
double eta(void) const
pseudo rapidity
Definition: CombinedMuonFeature.cxx:163
hist_file_dump.d
d
Definition: hist_file_dump.py:137
operator<<
MsgStream & operator<<(MsgStream &m, const CombinedMuonFeature &d)
Helper operator for printing the object.
Definition: CombinedMuonFeature.cxx:186
diff
void diff(const CombinedMuonFeature &a, const CombinedMuonFeature &b, std::map< std::string, double > &variableChange)
Function compares two objects and returns "semi verbose" output in the form of map where there are va...
Definition: CombinedMuonFeature.cxx:212
test_pyathena.pt
pt
Definition: test_pyathena.py:11
NavigableTerminalNode
Dummy type needed fro specialized implementation.
Definition: NavigableTerminalNode.h:19
CombinedMuonFeature::CombinedMuonFeature
CombinedMuonFeature()
Definition: CombinedMuonFeature.cxx:21
CombinedMuonFeature::sigma_pt
double sigma_pt(void) const
Definition: CombinedMuonFeature.cxx:84
CombinedMuonFeature.h
CombinedMuonFeature::m_flag
int m_flag
Definition: CombinedMuonFeature.h:79
str
std::string str(const CombinedMuonFeature &d)
Helper function for printing the object.
Definition: CombinedMuonFeature.cxx:174
master.flag
bool flag
Definition: master.py:29
CombinedMuonFeature::m_muFastTrack
ElementLink< MuonFeatureContainer > m_muFastTrack
Definition: CombinedMuonFeature.h:80
INavigable
Definition: INavigable.h:18
CombinedMuonFeature::m_charge
float m_charge
Definition: CombinedMuonFeature.h:78
IAthenaBarCode
Definition: AthenaKernel/AthenaKernel/IAthenaBarCode.h:48
CombinedMuonFeature
Definition: CombinedMuonFeature.h:30
CombinedMuonFeature::m_pt
float m_pt
Definition: CombinedMuonFeature.h:76
P4PtEtaPhiMBase
Definition: P4PtEtaPhiMBase.h:26
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
INavigable4Momentum
Definition: INavigable4Momentum.h:21
CombinedMuonFeature::comb_errorFlag
int comb_errorFlag(void) const
Definition: CombinedMuonFeature.cxx:108
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
extractSporadic.q
list q
Definition: extractSporadic.py:98
CombinedMuonFeature::comb_matchFlag
int comb_matchFlag(void) const
Definition: CombinedMuonFeature.cxx:114
CombinedMuonFeature::phi
double phi(void) const
phi in [-pi,pi[
Definition: CombinedMuonFeature.cxx:167
python.compressB64.c
def c
Definition: compressB64.py:93
CombinedMuonFeature::m_sigma_pt
float m_sigma_pt
Definition: CombinedMuonFeature.h:77