ATLAS Offline Software
RPCdigit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <math.h>
6 #include <iomanip>
7 
9 
10 using namespace std;
11 
13  RPCtrigDataObject(0,"RPC digit")
14 {
15  m_coding(0);
16 
17  m_time = 0.0;
18 
19  m_x = 0.0;
20  m_y = 0.0;
21  m_z = 0.0;
22 
23  m_station_radius = 0;
24  m_station_phi = -1.;
25 
26  //m_rpcgeo = 0;
27  m_codes.clear();
28 }
29 
30 
31 RPCdigit::RPCdigit(const std::string& name,int number,unsigned int code,float vec[4]):
33  m_coding(code),
34  m_x(vec[1]),
35  m_y(vec[2]),
36  m_z(vec[3]),
37  m_time(vec[0]),
38  m_station_radius(0.),
39  m_station_phi(-1.)
40 {
41 }
42 
43 /*
44 RPCdigit::RPCdigit(std::string name,int number,unsigned int code,float vec[4],
45  const RPCGeometry* rpcgeo):
46  RPCtrigDataObject(number,name)
47 {
48  while (code%100 && !rpcgeo->existCode(code)) {code -= 1;}
49  m_coding(code);
50 
51  m_time = vec[0];
52 
53  m_x = vec[1];
54  m_y = vec[2];
55  m_z = vec[3];
56 
57  m_rpcgeo = rpcgeo;
58 
59  if(!m_rpcgeo->give_station_radius(m_coding.code(),m_station_radius))
60  m_station_radius = 0.;
61  if(!m_rpcgeo->give_station_phi(m_coding.code(),m_station_phi))
62  m_station_phi = -1.;
63 
64  m_codes.clear();
65 }
66 
67 RPCdigit::RPCdigit(std::string name,int number,std::list<unsigned int> code,
68  float time, const RPCGeometry* rpcgeo):
69  RPCtrigDataObject(number,name)
70 {
71  unsigned int Code = code.front();
72  while (Code%100 && !rpcgeo->existCode(Code)) {Code -= 1;}
73 
74  m_coding(Code);
75 
76  m_time = time;
77 
78  m_rpcgeo = rpcgeo;
79  m_codes = code;
80 
81  float xyz[3] = {0.,0.,0.};
82  m_rpcgeo->give_strip_coordinates(m_coding.code(),xyz);
83  m_x = xyz[0];
84  m_y = xyz[1];
85  m_z = xyz[2];
86 
87  if(!m_rpcgeo->give_station_radius(m_coding.code(),m_station_radius))
88  m_station_radius = 0.;
89  if(!m_rpcgeo->give_station_phi(m_coding.code(),m_station_phi))
90  m_station_phi = -1.;
91 }
92 
93 
94 bool
95 RPCdigit::set_to_chamber(const int rpc_index)
96 {
97  if(m_coding.rpc_z_index() == rpc_index) return true;
98  if(!m_rpcgeo) return false;
99 
100  std::list<unsigned int>::const_iterator it = m_codes.begin();
101 
102  while(it != m_codes.end())
103  {
104  unsigned int code = *it;
105  while (code%100 && !m_rpcgeo->existCode(code)) {code -= 1;}
106  RPCdecoder tmp(code);
107  if(tmp.rpc_z_index() == rpc_index)
108  {
109  m_coding = tmp;
110  float xyz[3] = {0.,0.,0.};
111  m_rpcgeo->give_strip_coordinates(m_coding.code(),xyz);
112  m_x = xyz[0];
113  m_y = xyz[1];
114  m_z = xyz[2];
115 
116  if(!m_rpcgeo->give_station_radius(m_coding.code(),m_station_radius))
117  m_station_radius = 0.;
118  if(!m_rpcgeo->give_station_phi(m_coding.code(),m_station_phi))
119  m_station_phi = -1.;
120 
121  return true;
122  }
123  ++it;
124  }
125  return false;
126 }
127 */
128 
131  m_coding(digit.decoding()),
132  m_x(digit.x()),
133  m_y(digit.y()),
134  m_z(digit.z()),
135  m_time(digit.time()),
136  m_codes(digit.codes())
137 {
138  if(!digit.station_radius(m_station_radius)) m_station_radius = 0.;
139  if(!digit.station_phi(m_station_phi)) m_station_phi = 0.;
140 }
141 
143 {
144  static_cast<RPCtrigDataObject&>(*this) =
145  static_cast<const RPCtrigDataObject&>(digit);
146  m_coding = digit.decoding();
147 
148  m_time = digit.time();
149 
150  m_x = digit.x();
151  m_y = digit.y();
152  m_z = digit.z();
153 
154  //m_rpcgeo=0;
155 
156  // m_rpcgeo = digit.rpcgeo();
157 
158 
159  if(!digit.station_radius(m_station_radius)) m_station_radius = 0.;
160  if(!digit.station_phi(m_station_phi)) m_station_phi = 0.;
161 
162  m_codes = digit.codes();
163 
164  return *this;
165 }
166 
167 
168 bool
170 {
171  if(m_coding.code() == digit.decoding().code()) return true;
172  else return false;
173 }
174 
175 void RPCdigit::xyz(float vec[3]) const
176 {
177  vec[0] = m_x;
178  vec[1] = m_y;
179  vec[2] = m_z;
180 }
181 
182 bool RPCdigit::radius(float& rad) const
183 {
184  if(m_x != 0. || m_y != 0.)
185  {
186  rad = std::sqrt( std::pow(m_x,2) + std::pow(m_y,2) );
187  return true;
188  }
189  return false;
190 }
191 
192 
193 bool RPCdigit::theta(float& theta) const
194 {
195  float radius;
196  if(this->radius(radius))
197  {
198  if(m_z != 0.) theta = std::atan( radius/ std::abs(m_z) );
199  else theta = M_PI_2;
200  return true;
201  }
202  return false;
203 }
204 
205 bool RPCdigit::eta(float& eta) const
206 {
207  float theta;
208  if(this->theta(theta))
209  {
210  eta = -std::log(std::tan(theta/2.f));
211  if(m_z < 0.) eta = -eta;
212  return true;
213  }
214  return false;
215 }
216 
217 bool RPCdigit::phi(float& phi) const
218 {
219  if(m_x != 0. || m_y != 0.)
220  {
221  phi = std::atan2(m_y,m_x);
222  return true;
223  }
224  return false;
225 }
226 
227 bool RPCdigit::station_eta(float& eta) const
228 {
229  if(m_station_radius)
230  {
231  if(m_z != 0.) eta = -std::log(std::tan(std::atan(m_station_radius/std::abs(m_z))/2.f));
232  if(m_z < 0. ) eta = -eta;
233  return true;
234  }
235  return false;
236 }
237 
238 void RPCdigit::Print(ostream& stream,bool detail) const
239 {
240  //unsigned int upper = 19;
241  //unsigned int lower = 17;
242 
243  unsigned int upper = 95;
244  unsigned int lower = 45;
245 
246 
247  std::string type = (decoding().view() == Eta)? "ETA " : "PHI ";
248 
249  for(int i=0;i<61;++i) stream << (char) upper;
250  stream << endl;
251 
252  stream << type << name() << " number " << number() << ", time = "
253  << time() << " ns" << endl;
254  if (particle_code())
255  {
256  stream << "particle code = " << particle_code() << ","
257  << " physics process = " << process_type() << ","
258  << " track number = " << track_number() << endl;
259  }
260  stream << setiosflags(ios::fixed);
261 
262  stream << "GlobalPosition (cm): "
263  << setiosflags(ios::fixed) << setprecision(3) << setw(12) << x() << ","
264  << setiosflags(ios::fixed) << setprecision(3) << setw(12) << y() << ","
265  << setiosflags(ios::fixed) << setprecision(3) << setw(12) << z()
266  << endl;
267 
268  stream.unsetf(ios::fixed);
269 
270  if(detail)
271  {
273  }
274 
275  for(int i=0;i<61;++i) stream << (char) lower;
276  stream << endl;
277 }
RPCdigit::track_number
virtual int track_number(void) const
Definition: RPCdigit.h:72
RPCdigit::eta
bool eta(float &) const
Definition: RPCdigit.cxx:205
RPCdigit::operator=
RPCdigit operator=(const RPCdigit &)
Definition: RPCdigit.cxx:142
BaseObject::name
const std::string & name() const
Definition: BaseObject.h:23
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
RPCdigit::m_z
float m_z
Definition: RPCdigit.h:22
RPCdigit::operator==
bool operator==(const RPCdigit &) const
Definition: RPCdigit.cxx:169
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
RPCdigit::time
float time(void) const
Definition: RPCdigit.h:52
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
RPCdigit::m_codes
std::list< unsigned int > m_codes
Definition: RPCdigit.h:29
RPCdigit::m_y
float m_y
Definition: RPCdigit.h:21
detail
Definition: extract_histogram_tag.cxx:14
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
RPCdigit::phi
bool phi(float &) const
Definition: RPCdigit.cxx:217
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
x
#define x
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
RPCdecoder::code
unsigned int code(void) const
Definition: RPCdecoder.h:64
python.ExitCodes.codes
dictionary codes
helper to get a human-readable string
Definition: ExitCodes.py:49
histSizes.code
code
Definition: histSizes.py:129
RPCdigit::m_time
float m_time
Definition: RPCdigit.h:24
RPCdigit::Print
void Print(std::ostream &, bool) const
Definition: RPCdigit.cxx:238
RPCdecoder::Print
void Print(std::ostream &, bool) const
Definition: RPCdecoder.cxx:165
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
RPCdigit.h
RPCdigit::m_coding
RPCdecoder m_coding
Definition: RPCdigit.h:18
RPCdigit::process_type
virtual int process_type(void) const
Definition: RPCdigit.h:71
hist_file_dump.f
f
Definition: hist_file_dump.py:135
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
RPCdigit::radius
bool radius(float &) const
Definition: RPCdigit.cxx:182
python.selection.number
number
Definition: selection.py:20
RPCdigit::theta
bool theta(float &) const
Definition: RPCdigit.cxx:193
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RPCtrigDataObject
Definition: RPCtrigDataObject.h:15
RPCdigit::y
float y(void) const
Definition: RPCdigit.h:54
RPCdigit
Definition: RPCdigit.h:16
RPCdigit::RPCdigit
RPCdigit()
Definition: RPCdigit.cxx:12
RPCdigit::m_x
float m_x
Definition: RPCdigit.h:20
y
#define y
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
RPCdecoder::view
ViewType view(void) const
Definition: RPCdecoder.cxx:150
RPCtrigDataObject::number
int number(void) const
Definition: RPCtrigDataObject.h:29
RPCdigit::m_station_radius
float m_station_radius
Definition: RPCdigit.h:26
RPCdigit::m_station_phi
float m_station_phi
Definition: RPCdigit.h:27
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RPCdigit::decoding
const RPCdecoder & decoding(void) const
Definition: RPCdigit.h:48
RPCdigit::x
float x(void) const
Definition: RPCdigit.h:53
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
RPCdigit::z
float z(void) const
Definition: RPCdigit.h:55
RPCdigit::particle_code
virtual int particle_code(void) const
Definition: RPCdigit.h:70
Eta
@ Eta
Definition: RPCdef.h:8
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
RPCdigit::station_eta
bool station_eta(float &) const
Definition: RPCdigit.cxx:227
RPCdigit::xyz
void xyz(float vec[3]) const
Definition: RPCdigit.cxx:175