ATLAS Offline Software
Loading...
Searching...
No Matches
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
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);
39
40 // trigger info : TDC, time, etc
41 for (int i = 0; i < 3; i++) m_TRIGGER_INFO[i] = 0;
42}
43
44CscRODReadOutV1::CscRODReadOutV1(double startTime, uint16_t samplingTime, double signalWidth, uint16_t numIntegration) :
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);
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
66void CscRODReadOutV1::encodeFragments(const std::vector<uint16_t>& amplitude, std::vector<uint32_t>& v) const {
67 int numberOfFragments = amplitude.size();
68
69 // now the data
71
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
83int 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}
double charge(const T &p)
Definition AtlasPID.h:997
static Double_t a
#define max(a, b)
Definition cfImp.cxx:41
uint32_t m_TRIGGER_INFO[3]
int findCharge(const std::vector< uint16_t > &amplitude, double &time)
void encodeFragments(const std::vector< uint16_t > &amplitude, std::vector< uint32_t > &v) const
double signal(double z) const
static const uint16_t BODY_AMPLITUDE
uint16_t m_subDetectorId
void set32bits(const uint16_t *v16, uint32_t &v32) const
const CscIdHelper * m_cscHelper