ATLAS Offline Software
CscRODReadOutV1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CscRODReadOutV1.h"
6 
7 // constructor
9  m_cscHelper(nullptr), m_sourceID(0), m_moduleType(0), m_rodId(0), m_subDetectorId(0), m_amp1(0), m_amp2(0), m_address(0) {
10  m_TIME_OFFSET = 46.825; // ns
11  m_SIGNAL_WIDTH = 16.08; // ns
12  m_SAMPLING_TIME = 50.0; // ns
14  m_Z0 = (m_NUMBER_OF_INTEGRATION + 1) - sqrt(m_NUMBER_OF_INTEGRATION + 1); // time bin at the maximum
15  // obtained by setting the derivative = 0
16  // this gives 2 solutions:
17  // Z0=9.394 and 16.606
18  // 9.394 is for positive amplitude
19 
20  // conversion factor from ee charge to ADC count
21  // assuming for now 1 ADC count = 0.32 femtoCoulomb!
22 
23  /* From Valeri Tcherniatine --- April 11, 2004
24  conversion= ( e*G*k*m*d*1.6e-19)/2000
25  e=75 - average number ionization e in CSC
26  G=10^5 - gas gain
27  k=0.15 - factor taking to account electronic time integration (charge
28  deficit) and only one cathode readout
29  m=0.5 - part of induce charge contained in max. strip
30  d=7 - value of dynamic range expressed in average particle ionization
31  deposition in CSC. At this value (7) out of region inefficiency is <2%.
32  1.6e-19 - e charge
33  2000 - max. ADC counts for positive part of signal
34  Collect all numbers together conversion = 0.32 femtoCoulomb per ADC count
35  */
36 
37  m_CHARGE_TO_ADC_COUNT = (0.32e-15) / (1.602e-19);
38  m_norm = signal(m_Z0);
39 
40  // trigger info : TDC, time, etc
41  for (int i = 0; i < 3; i++) m_TRIGGER_INFO[i] = 0;
42 }
43 
44 CscRODReadOutV1::CscRODReadOutV1(double startTime, uint16_t samplingTime, double signalWidth, uint16_t numIntegration) :
45  m_cscHelper(nullptr), m_sourceID(0), m_moduleType(0), m_rodId(0), m_subDetectorId(0), m_amp1(0), m_amp2(0), m_address(0) {
46  m_TIME_OFFSET = startTime; // ns
47  m_SIGNAL_WIDTH = signalWidth; // ns
48  m_SAMPLING_TIME = samplingTime; // ns
49  m_NUMBER_OF_INTEGRATION = numIntegration;
50  m_Z0 = (m_NUMBER_OF_INTEGRATION + 1) - sqrt(m_NUMBER_OF_INTEGRATION + 1); // time bin at the maximum
51  // obtained by setting the derivative = 0
52  // this gives 2 solutions:
53  // Z0=9.394 and 16.606
54  // 9.394 is for positive amplitude
55 
56  m_CHARGE_TO_ADC_COUNT = (0.32e-15) / (1.602e-19);
57  m_norm = signal(m_Z0);
58 
59  // trigger info : TDC, time, etc
60  for (int i = 0; i < 3; i++) m_TRIGGER_INFO[i] = 0;
61 }
62 
63 // destructor
64 
65 
66 void CscRODReadOutV1::encodeFragments(const std::vector<uint16_t>& amplitude, std::vector<uint32_t>& v) const {
67  int numberOfFragments = amplitude.size();
68 
69  // now the data
72  int j = 0;
73  while (j < numberOfFragments) {
74  uint32_t v32 = 0;
75  uint16_t amp[2] = {0, 0};
76  for (int i = 0; i < 2; i++) { amp[i] = (BODY_AMPLITUDE << 12) | amplitude[i + j]; }
77  set32bits(amp, v32);
78  v.push_back(v32);
79  j += 2;
80  }
81 }
82 
83 int CscRODReadOutV1::findCharge(const std::vector<uint16_t>& amplitude, double& time) {
84  // very crude - to be done better
85 
86  int charge = 0;
87  time = 0.0;
88 
89  int numberOfSamplings = amplitude.size();
90 
91  uint16_t max = 0;
92  int maxIndex = -1;
93  for (int i = 0; i < numberOfSamplings; i++) {
94  if (amplitude[i] > max) {
95  max = amplitude[i];
96  maxIndex = i;
97  }
98  }
99 
100  if (max == 0) return charge;
101  if (maxIndex < 0 || maxIndex >= numberOfSamplings) return charge;
102 
104  if (maxIndex == 0)
105  return amplitude[0];
106  else if (maxIndex == (numberOfSamplings - 1))
107  return amplitude[numberOfSamplings - 1];
108  else {
109  double a, b, c;
110  double y1 = amplitude[maxIndex - 1];
111  double y2 = amplitude[maxIndex];
112  double y3 = amplitude[maxIndex + 1];
113  a = 0.5 * (y3 + y1 - 2 * y2);
114  b = 0.5 * (y3 - y1);
115  c = y2;
116 
119  double offset = (a == 0) ? 0 : -b / (2 * a);
120  charge = static_cast<int>(a * offset * offset + b * offset + c - amplitude[0]);
121  time = (maxIndex + offset) * m_SAMPLING_TIME;
122  return charge;
123  }
124 }
CscRODReadOutV1::m_TRIGGER_INFO
uint32_t m_TRIGGER_INFO[3]
Definition: CscRODReadOutV1.h:106
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
CscRODReadOutV1::m_CHARGE_TO_ADC_COUNT
double m_CHARGE_TO_ADC_COUNT
Definition: CscRODReadOutV1.h:103
CscRODReadOutV1.h
lumiFormat.startTime
startTime
Definition: lumiFormat.py:95
CscRODReadOutV1::findCharge
int findCharge(const std::vector< uint16_t > &amplitude, double &time)
Definition: CscRODReadOutV1.cxx:83
CscRODReadOutV1::encodeFragments
void encodeFragments(const std::vector< uint16_t > &amplitude, std::vector< uint32_t > &v) const
Definition: CscRODReadOutV1.cxx:66
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
CscRODReadOutV1::m_norm
double m_norm
Definition: CscRODReadOutV1.h:97
CscRODReadOutV1::CscRODReadOutV1
CscRODReadOutV1()
Definition: CscRODReadOutV1.cxx:8
CscRODReadOutV1::BODY_AMPLITUDE
static const uint16_t BODY_AMPLITUDE
Definition: CscRODReadOutV1.h:115
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
CscRODReadOutV1::m_Z0
double m_Z0
Definition: CscRODReadOutV1.h:104
CscRODReadOutV1::signal
double signal(double z) const
Definition: CscRODReadOutV1.h:260
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
CscRODReadOutV1::m_SIGNAL_WIDTH
double m_SIGNAL_WIDTH
Definition: CscRODReadOutV1.h:100
CscRODReadOutV1::m_NUMBER_OF_INTEGRATION
int m_NUMBER_OF_INTEGRATION
Definition: CscRODReadOutV1.h:102
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
charge
double charge(const T &p)
Definition: AtlasPID.h:756
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
CscRODReadOutV1::set32bits
void set32bits(const uint16_t *v16, uint32_t &v32) const
Definition: CscRODReadOutV1.h:153
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
python.compressB64.c
def c
Definition: compressB64.py:93
CscRODReadOutV1::m_SAMPLING_TIME
double m_SAMPLING_TIME
Definition: CscRODReadOutV1.h:101
CscRODReadOutV1::m_TIME_OFFSET
double m_TIME_OFFSET
Definition: CscRODReadOutV1.h:99