ATLAS Offline Software
Loading...
Searching...
No Matches
CscRODReadOutV0.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CscRODReadOutV0.h"
6#include <stdexcept>
7
8// constructor
10 m_cscHelper(nullptr),
11 m_sourceID(0),
12 m_moduleType(0),
13 m_rodId(0),
15 m_amp1(0),
16 m_amp2(0),
17 m_amp3(0),
18 m_amp4(0),
19 m_address(0) {
20 m_TIME_OFFSET = 46.825; // ns
21 m_SIGNAL_WIDTH = 16.08; // ns
22 m_SAMPLING_TIME = 50.0; // ns
23 m_Z0 = 9.394; // time bin at the maximum
24 // obtained by setting the derivative = 0
25 // this gives 2 solutions: Z0=9.394 and 16.606
26 // 9.394 is for positive amplitude
27
29
30 // conversion factor from ee charge to ADC count
31 // assuming for now 1 ADC count = 0.32 femtoCoulomb!
32
33 /* From Valeri Tcherniatine --- April 11, 2004
34 conversion= ( e*G*k*m*d*1.6e-19)/2000
35 e=75 - average number ionization e in CSC
36 G=10^5 - gas gain
37 k=0.15 - factor taking to account electronic time integration (charge
38 deficit) and only one cathode readout
39 m=0.5 - part of induce charge contained in max. strip
40 d=7 - value of dynamic range expressed in average particle ionization
41 deposition in CSC. At this value (7) out of region inefficiency is <2%.
42 1.6e-19 - e charge
43 2000 - max. ADC counts for positive part of signal
44 Collect all numbers together conversion = 0.32 femtoCoulomb per ADC count
45 */
46
47 m_CHARGE_TO_ADC_COUNT = (0.32e-15) / (1.602e-19);
49}
50
51// destructor
52
53
54void CscRODReadOutV0::encodeFragments(const uint16_t* amplitude, const uint32_t& address, std::vector<uint32_t>& v) const {
55 uint16_t amp[2] = {0, 0};
56 uint32_t v32 = 0;
57
58 for (int i = 0; i < 2; i++) amp[i] = (BODY_AMPLITUDE << 12) | *(amplitude + i);
59 set32bits(amp, v32);
60 v[0] = v32;
61 v32 = 0;
62 for (int i = 2; i < 4; i++) amp[i - 2] = (BODY_AMPLITUDE << 12) | *(amplitude + i);
63 set32bits(amp, v32);
64 v[1] = v32;
65
66 v[2] = (BODY_ADDRESS << 28) | address;
67}
68
70 const int N_SAMPLE = 4;
71
72 // the sampling times
73 double time[N_SAMPLE];
74 for (int i = 0; i < N_SAMPLE; i++) time[i] = (i + 1) * m_SAMPLING_TIME + m_TIME_OFFSET;
75
76 // the corresponding amplitudes
77 uint16_t amp[N_SAMPLE];
78 amp[0] = m_amp1;
79 amp[1] = m_amp2;
80 amp[2] = m_amp3;
81 amp[3] = m_amp4;
82
83 // to be replaced by a fitting procedure
84 double adcCount = 0.0;
85 int n = 0;
86 for (int i = 0; i < N_SAMPLE; i++) {
87 if (auto amplitude = signal_amplitude(time[i]); amplitude !=0){
88 //coverity[DIVIDE_BY_ZERO:FALSE]
89 adcCount = adcCount + amp[i] / amplitude;
90 } else {
91 continue;
92 }
93 if (amp[i] > 0) n++;
94 }
95 if (n == 0)[[unlikely]]{
96 throw std::runtime_error("CscRODReadOutV0::findCharge: denominator 'n' is zero.");
97 }
98 adcCount = adcCount / n;
99
100 return adcCount;
101}
static const uint16_t BODY_AMPLITUDE
void encodeFragments(const uint16_t *amplitude, const uint32_t &address, std::vector< uint32_t > &v) const
static const uint32_t BODY_ADDRESS
double signal(double z) const
double signal_amplitude(double samplingTime) const
uint16_t m_subDetectorId
uint32_t address(const Identifier &channelId, int &eta, int &phi) const
const CscIdHelper * m_cscHelper
void set32bits(const uint16_t *v16, uint32_t &v32) const
double m_CHARGE_TO_ADC_COUNT
#define unlikely(x)