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