ATLAS Offline Software
Loading...
Searching...
No Matches
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
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);
37}
38
39CscRODReadOut::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);
51}
52
53void CscRODReadOut::encodeFragments(const std::vector<uint16_t>& amplitude, std::vector<uint32_t>& v) const {
54 int numberOfFragments = amplitude.size();
55
56 // now the data
58
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
70int 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}
double charge(const T &p)
Definition AtlasPID.h:997
static Double_t a
#define max(a, b)
Definition cfImp.cxx:41
uint32_t m_chamberBitValue
void set32bits(const uint16_t *v16, uint32_t &v32) const
void encodeFragments(const std::vector< uint16_t > &amplitude, std::vector< uint32_t > &v) const
double m_TIME_OFFSET
static const uint16_t BODY_AMPLITUDE
static int findCharge(double samplingTime, const std::vector< uint16_t > &amplitude, double &time)
int m_NUMBER_OF_INTEGRATION
double m_SIGNAL_WIDTH
double m_CHARGE_TO_ADC_COUNT
const CscIdHelper * m_cscIdHelper
double signal(double z) const