ATLAS Offline Software
Loading...
Searching...
No Matches
TRTElectronicsProcessing.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include "TRTDigit.h"
9
10#include "CLHEP/Random/RandGaussZiggurat.h"
11#include "CLHEP/Random/RandFlat.h"
12#include "CLHEP/Random/RandomEngine.h"
13
14#include "TRTDigSettings.h"
15#include "TRTDigiHelper.h"
16
17#include <iostream>
18#include <limits>
19
20//___________________________________________________________________________
22 TRTElectronicsNoise * electronicsnoise )
23 : AthMessaging("TRTElectronicsProcessing"),
24 m_settings(digset),
25 m_pElectronicsNoise(electronicsnoise)
26{
27 Initialize();
28}
29
30//___________________________________________________________________________
39
40//___________________________________________________________________________
42
43 const int numberOfBins(static_cast<int>(m_settings->numberOfBins())); //returns unsigned int
44 m_numberOfPostZeroBins = numberOfBins; //assigning to int
45 m_timeInterval = m_settings->timeInterval(); // returns double
46 m_binWidth = m_timeInterval / static_cast<double>(numberOfBins); //assigning to double
47 const int numberOfCrossingsBeforeMain(m_settings->numberOfCrossingsBeforeMain()); // returns unsigned int
48 if (m_settings->timeCorrection()) {
49 m_numberOfPreZeroBins = numberOfBins * numberOfCrossingsBeforeMain / 3; //integer division... assigning to int
50 } else {
51 m_numberOfPreZeroBins = 0; // occurs when beamType='cosmics'
52 }
54 m_timeInterval += m_binWidth * static_cast<double>(m_numberOfPreZeroBins); //assigning to double
55
56 m_minDiscriminatorWidthInBinWidths = static_cast<int>(m_settings->minDiscriminatorWidth() / m_binWidth + 0.5);
57 m_discriminatorSettlingTimeInBinWidths = static_cast<int>(m_settings->discriminatorSettlingTime() / m_binWidth + 0.5);
58 m_discriminatorDeadTimeInBinWidths = static_cast<int>(m_settings->discriminatorDeadTime() / m_binWidth + 0.5);
59
61
62 // low threshold settings for Xe, Kr and Ar
63 m_lowThresholdBar[0] = m_settings->lowThresholdBar(0);
64 m_lowThresholdBar[1] = m_settings->lowThresholdBar(1);
65 m_lowThresholdBar[2] = m_settings->lowThresholdBar(2);
66 m_lowThresholdEC[0] = m_settings->lowThresholdEC(0);
67 m_lowThresholdEC[1] = m_settings->lowThresholdEC(1);
68 m_lowThresholdEC[2] = m_settings->lowThresholdEC(2);
69
71 //for (int j=0; j<3; j++) { for (int i=0; i<m_numberOfPostZeroBins; i++) std::cout << "AJBLT " << j << " " << m_lowThresholdSignalShape[j][i] << std::endl; }
72 //for (int j=0; j<3; j++) { for (int i=0; i<m_numberOfPostZeroBins; i++) std::cout << "AJBHT " << j << " " << m_highThresholdSignalShape[j][i] << std::endl; }
73
81
82 // m_maskA = 0x03FC0000;
83 // m_maskB = 0x0001FE00;
84 // m_maskC = 0x000000FF;
85 // m_maskHT = 0x04020100;
86}
87
88//___________________________________________________________________________
90
91 // We have 160 bins each 0.78125 ns
92 // These arrays are cut and paste from the output of TRT_Digitization/share/signalShapes.cpp
93
94 const double pXeLT[160] = {
95 0.039062, 0.117617, 0.197695, 0.296573, 0.419494, 0.557328, 0.698813, 0.826937, 0.927195, 0.984970,
96 0.994847, 0.956566, 0.877094, 0.767477, 0.641157, 0.510111, 0.385189, 0.273973, 0.180531, 0.105891,
97 0.049175, 0.007925, -0.021127, -0.040969, -0.054005, -0.062364, -0.067278, -0.069242, -0.068776, -0.066547,
98 -0.062738, -0.057634, -0.051691, -0.045232, -0.038621, -0.032235, -0.026218, -0.020790, -0.016104, -0.012117,
99 -0.008966, -0.006491, -0.004585, -0.003105, -0.002121, -0.001400, -0.000890, -0.000544, -0.000332, -0.000202,
100 -0.000084, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
101 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
102 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
103 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
104 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
105 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
106 };
107
108 const double pXeHT[160] = { // widened for middle-bit HT fraction tuning
109 0.027700, 0.083200, 0.138700, 0.191900, 0.259700, 0.340300, 0.432000, 0.531200, 0.632900, 0.731400,
110 0.820500, 0.894900, 0.950600, 0.985600, 1.000000, 0.995700, 0.975800, 0.943900, 0.903700, 0.857900,
111 0.808500, 0.756500, 0.702400, 0.646200, 0.588000, 0.527900, 0.466600, 0.405000, 0.344100, 0.285200,
112 0.229400, 0.177700, 0.131000, 0.089700, 0.054000, 0.024000, -0.000800, -0.020600, -0.036000, -0.047600,
113 -0.055800, -0.061400, -0.064700, -0.066200, -0.066200, -0.065200, -0.063300, -0.060700, -0.057700, -0.054400,
114 -0.050800, -0.047200, -0.043500, -0.039800, -0.036200, -0.032800, -0.029400, -0.026300, -0.023300, -0.020600,
115 -0.018000, -0.015700, -0.013600, -0.011700, -0.010000, -0.008500, -0.007200, -0.006000, -0.005000, -0.004200,
116 -0.003400, -0.002800, -0.002300, -0.001900, -0.001500, -0.001200, -0.001000, 0.0, 0.0, 0.0,
117 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
118 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
119 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
120 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
121 };
122
123 const double pKrLT[160] = {
124 0.061537, 0.182727, 0.297239, 0.412757, 0.538228, 0.663099, 0.776969, 0.875428, 0.944050, 0.984161,
125 0.993044, 0.966288, 0.913313, 0.856057, 0.794949, 0.730736, 0.666524, 0.602311, 0.536858, 0.471147,
126 0.406935, 0.342722, 0.286429, 0.232919, 0.180758, 0.134739, 0.093536, 0.054859, 0.021586, -0.003114,
127 -0.020773, -0.032170, -0.040197, -0.046147, -0.050428, -0.052697, -0.054131, -0.054672, -0.054255, -0.052971,
128 -0.051862, -0.050965, -0.050133, -0.049063, -0.047992, -0.046922, -0.045852, -0.044782, -0.043711, -0.042365,
129 -0.040850, -0.039084, -0.036943, -0.034803, -0.032809, -0.030865, -0.028922, -0.026979, -0.025035, -0.023092,
130 -0.021149, -0.019206, -0.017262, -0.015759, -0.014533, -0.013345, -0.011740, -0.010638, -0.009568, -0.008497,
131 -0.007427, -0.006357, -0.005287, -0.004217, -0.003146, -0.002076, -0.001006, 0.0, 0.0, 0.0,
132 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
133 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
134 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
135 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
136 };
137
138 const double pKrHT[160] = {
139 0.027700, 0.083200, 0.138700, 0.191900, 0.259700, 0.340300, 0.432000, 0.531200, 0.632900, 0.731400,
140 0.820500, 0.894900, 0.950600, 0.985600, 1.000000, 0.995700, 0.975800, 0.943900, 0.903700, 0.857900,
141 0.808500, 0.756500, 0.702400, 0.646200, 0.588000, 0.527900, 0.466600, 0.405000, 0.344100, 0.285200,
142 0.229400, 0.177700, 0.131000, 0.089700, 0.054000, 0.024000, -0.000800, -0.020600, -0.036000, -0.047600,
143 -0.055800, -0.061400, -0.064700, -0.066200, -0.066200, -0.065200, -0.063300, -0.060700, -0.057700, -0.054400,
144 -0.050800, -0.047200, -0.043500, -0.039800, -0.036200, -0.032800, -0.029400, -0.026300, -0.023300, -0.020600,
145 -0.018000, -0.015700, -0.013600, -0.011700, -0.010000, -0.008500, -0.007200, -0.006000, -0.005000, -0.004200,
146 -0.003400, -0.002800, -0.002300, -0.001900, -0.001500, -0.001200, -0.001000, 0.0, 0.0, 0.0,
147 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
148 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
149 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
150 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
151 };
152
153 const double pArLT[160] = {
154 0.058594, 0.175781, 0.292969, 0.410156, 0.527344, 0.644531, 0.769031, 0.886891, 0.966388, 0.994571,
155 0.965874, 0.883619, 0.759288, 0.609766, 0.453430, 0.306347, 0.179643, 0.078588, 0.003274, -0.049719,
156 -0.085434, -0.108986, -0.124645, -0.135499, -0.143531, -0.149880, -0.155123, -0.159518, -0.163151, -0.166033,
157 -0.168147, -0.169472, -0.169992, -0.169700, -0.168600, -0.166709, -0.164053, -0.160669, -0.156605, -0.151916,
158 -0.146664, -0.140919, -0.134753, -0.128243, -0.121465, -0.114497, -0.107413, -0.100288, -0.093189, -0.086179,
159 -0.079316, -0.072652, -0.066231, -0.060089, -0.054257, -0.048757, -0.043606, -0.038813, -0.034382, -0.030312,
160 -0.026596, -0.023224, -0.020183, -0.017457, -0.015234, -0.014063, -0.012891, -0.011719, -0.010547, -0.009375,
161 -0.008203, -0.007031, -0.005859, -0.004688, -0.003516, -0.002344, -0.001172, 0.0, 0.0, 0.0,
162 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
163 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
164 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
165 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
166 };
167
168 const double pArHT[160] = { // widened for middle-bit HT fraction tuning
169 0.027700, 0.083200, 0.138700, 0.191900, 0.259700, 0.340300, 0.432000, 0.531200, 0.632900, 0.731400,
170 0.820500, 0.894900, 0.950600, 0.985600, 1.000000, 0.995700, 0.975800, 0.943900, 0.903700, 0.857900,
171 0.808500, 0.756500, 0.702400, 0.646200, 0.588000, 0.527900, 0.466600, 0.405000, 0.344100, 0.285200,
172 0.229400, 0.177700, 0.131000, 0.089700, 0.054000, 0.024000, -0.000800, -0.020600, -0.036000, -0.047600,
173 -0.055800, -0.061400, -0.064700, -0.066200, -0.066200, -0.065200, -0.063300, -0.060700, -0.057700, -0.054400,
174 -0.050800, -0.047200, -0.043500, -0.039800, -0.036200, -0.032800, -0.029400, -0.026300, -0.023300, -0.020600,
175 -0.018000, -0.015700, -0.013600, -0.011700, -0.010000, -0.008500, -0.007200, -0.006000, -0.005000, -0.004200,
176 -0.003400, -0.002800, -0.002300, -0.001900, -0.001500, -0.001200, -0.001000, 0.0, 0.0, 0.0,
177 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
178 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
179 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
180 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
181 };
182
183 // Temporary vectors
184 std::vector<double> vpXeLT(m_numberOfPostZeroBins), vpXeHT(m_numberOfPostZeroBins);
185 std::vector<double> vpKrLT(m_numberOfPostZeroBins), vpKrHT(m_numberOfPostZeroBins);
186 std::vector<double> vpArLT(m_numberOfPostZeroBins), vpArHT(m_numberOfPostZeroBins);
187
188 // Copy arrays elements to the temporary vectors
189 for (int k=0; k<m_numberOfPostZeroBins; ++k) {
190 vpXeLT.at(k)=pXeLT[k]; vpXeHT.at(k)=pXeHT[k];
191 vpKrLT.at(k)=pKrLT[k]; vpKrHT.at(k)=pKrHT[k];
192 vpArLT.at(k)=pArLT[k]; vpArHT.at(k)=pArHT[k];
193 }
194
195 // Build the vectors of shaping amplitudes
196 m_lowThresholdSignalShape[0] = std::move(vpXeLT); m_highThresholdSignalShape[0] = std::move(vpXeHT);
197 m_lowThresholdSignalShape[1] = std::move(vpKrLT); m_highThresholdSignalShape[1] = std::move(vpKrHT);
198 m_lowThresholdSignalShape[2] = std::move(vpArLT); m_highThresholdSignalShape[2] = std::move(vpArHT);
199}
200
201//___________________________________________________________________________
202
203void TRTElectronicsProcessing::ProcessDeposits( const std::vector<TRTElectronicsProcessing::Deposit>& deposits,
204 const int& hitID,
205 TRTDigit& outdigit,
206 double lowthreshold,
207 const double& noiseamplitude,
208 int strawGasType,
209 CLHEP::HepRandomEngine* rndmEngine,
210 CLHEP::HepRandomEngine* elecNoiseRndmEngine,
211 double highthreshold
212 ) {
214 // Process the timed energy deposits at the FE for this straw: //
215 // - Put energy deposits in a fine-time array 0.0 < time < m_timeInterval. //
216 // - Apply signal shaping with a Xenon, Krypton or Argon function. //
217 // - Add noise (LT only) //
218 // - Apply (fine-bin) threshold discrimination; threshold fluctuations are already applied by this point. //
219 // - Turn the fine discriminator array into a 27-bit output digit. //
221
222 if (deposits.empty() && noiseamplitude<std::numeric_limits<double>::epsilon()) {
223 return;
224 }
225
226 if ( lowthreshold < 0 ) { // check if set to -1.0
227 lowthreshold = !(hitID & 0x00200000) ? m_lowThresholdBar[strawGasType] : m_lowThresholdEC[strawGasType];
228 }
229 if ( highthreshold < 0 ) { // check if set to -1.0
230 highthreshold = getHighThreshold(hitID,strawGasType);
231 }
232
233 const double low_threshold_fluctuation(m_settings->relativeLowThresholdFluctuation());
234 if ( low_threshold_fluctuation > 0 ) {
235 lowthreshold = lowthreshold*CLHEP::RandGaussZiggurat::shoot(rndmEngine, 1.0, low_threshold_fluctuation );
236 }
237 const double high_threshold_fluctuation(m_settings->relativeHighThresholdFluctuation());
238 if ( high_threshold_fluctuation > 0 ) {
239 highthreshold = highthreshold*CLHEP::RandGaussZiggurat::shoot(rndmEngine, 1.0, high_threshold_fluctuation );
240 }
241
242 //Null out arrays: m_totalNumberOfBins=160(125ns)
243 for (int i(0); i < m_totalNumberOfBins; ++i) {
244 m_energyDistribution[i] = 0.;
245 m_lowThresholdSignal[i] = 0.;
246 m_highThresholdSignal[i] = 0.;
249 }
250 // Fill cluster energies into relevant time bins: m_energyDistribution[m_totalNumberOfBins] * 1.0e6 eV
251 // With pileup, m_timeInterval=125ns and signal event starting at 50 ns.
252 const unsigned int numberOfDeposits(deposits.size());
253 for (unsigned int i(0); i < numberOfDeposits; ++i) {
254 const double time(deposits[i].time());
255 if (time > 0.0 && time < m_timeInterval) {
256 const int index(static_cast<int>(time / m_binWidth));
257 m_energyDistribution[index] += deposits[i].energy();
258 }
259 }
260
261 // Signal shaping; 4 different shaping functions for: LT, HT, Argon, Xenon
262 // Fills m_lowThresholdSignal[m_totalNumberOfBins] and m_highThresholdSignal[m_totalNumberOfBins]
263 SignalShaping(strawGasType);
264
265 // Add noise; LT only
266 // (though both LT and HT also get fluctuations elsewhere which gives similar effect to noise).
267 if ( m_pElectronicsNoise && noiseamplitude>0 ) {
268 m_pElectronicsNoise->addElectronicsNoise(m_lowThresholdSignal,noiseamplitude, elecNoiseRndmEngine); // LT signal only
269 }
270
271 // Discriminator response (in what fine time bins are the thresholds exceeded)
272 // Fills m_lowThresholdDiscriminator[m_totalNumberOfBins] and m_highThresholdDiscriminator[m_totalNumberOfBins]
273 DiscriminatorResponse(lowthreshold,highthreshold);
274
275 // Apply an independent LT T0 shift to m_lowThresholdDiscriminator[]
276 LTt0Shift(hitID,strawGasType);
277
278 // Apply an independent HT T0 shift to m_highThresholdDiscriminator[]
279 HTt0Shift(hitID);
280
281 // Finally turn the fine discriminator response arrays into an output digit;
282 // for RDO reduction, zero: msb, and first 4 unused bits, first and third HT bits, last 4 LT bits
283 //
284 // bit31 bit0
285 // | leading trailing |
286 // #----HLLLLLLLLHLLLLLLLLHLLLLLLLL
287 // 00000011111111111111111011110000
288
289 unsigned int digit = EncodeDigit() & 0x03FFFEF0;
290
291 // Only attempt this if the digit is non-zero
292 if ( m_settings->isOverlay() && digit ) { //doing overlay
293 digit += (1u<<31);//flag digit a "MC" one
294 if (m_first){
295 m_first=false;
296 ATH_MSG_DEBUG("ACH666: Flagging digits as MC (for overlay)");
297 }
298 }
299
300 // The digit only gets written to disk if it is non-zero
301 if (digit) {
302 outdigit = TRTDigit(hitID, digit);
303 }
304
305} // end of ProcessDeposits
306
307//___________________________________________________________________________
309
310 // Build m_lowThresholdSignal[] and m_highThresholdSignal[] arrays by
311 // convoluting the deposit m_energyDistribution[] with electronics shaping functions.
312
313 int i, j, k;
314 for (i = 0; i < m_totalNumberOfBins; ++i)
315 {
316 if (m_energyDistribution[i] > 0.)
317 {
318 const double energyInBin(m_energyDistribution[i]);
319 for (j = i; j < m_totalNumberOfBins; ++j)
320 {
321 k = j - i;
322 if (k == m_numberOfPostZeroBins) { break; }
323 m_lowThresholdSignal[j] += m_lowThresholdSignalShape[strawGasType][k] * energyInBin;
324 m_highThresholdSignal[j] += m_highThresholdSignalShape[strawGasType][k] * energyInBin;
325 }
326 }
327 }
328
329}
330
331//___________________________________________________________________________
332void TRTElectronicsProcessing::DiscriminatorResponse(const double& lowthreshold, const double& highthreshold) {
333 //Input: m_lowThresholdSignal[],m_highThresholdSignal[]
334 //
335 //Output: m_lowThresholdDiscriminator[], m_highThresholdDiscriminator[]
336 //
337 //Uses internally:m_totalNumberOfBins,
338 // m_minWidthMinusSettlingTimeInBinWidths,
339 // m_minDiscriminatorWidthInBinWidths,
340 // m_discriminatorSettlingTimeInBinWidths,
341 // m_discriminatorDeadTimeInBinWidths
342 // threshold fluctuation variables from m_settings.
343
344 int lowThresholdBins(0);
345 int highThresholdBins(0);
346
347 int lowThresholdAdditionalBins(0);
348 int highThresholdAdditionalBins(0);
349
350 for (int i(0); i < m_totalNumberOfBins; ++i)
351 {
352 // ----- low threshold -----
353 if (lowThresholdBins == 0)
354 {
355 if (m_lowThresholdSignal[i] > lowthreshold)
356 {
358 ++lowThresholdBins;
359 }
360 }
361 else if (lowThresholdBins > 0)
362 {
363 if (m_lowThresholdSignal[i] > lowthreshold)
364 {
366 ++lowThresholdBins;
367 lowThresholdAdditionalBins = 0;
368 }
369 else
370 {
371 if (lowThresholdAdditionalBins == 0)
372 {
373 if (lowThresholdBins < m_minWidthMinusSettlingTimeInBinWidths)
374 {
375 lowThresholdAdditionalBins = m_minDiscriminatorWidthInBinWidths - lowThresholdBins;
376 }
377 else
378 {
379 lowThresholdAdditionalBins = m_discriminatorSettlingTimeInBinWidths;
380 }
381 }
383 ++lowThresholdBins;
384 --lowThresholdAdditionalBins;
385 if (lowThresholdAdditionalBins == 0)
386 {
387 if (!(m_lowThresholdSignal[i] > lowthreshold))
388 {
389 lowThresholdBins = -m_discriminatorDeadTimeInBinWidths;
390 }
391 }
392 }
393 }
394 else
395 {
396 ++lowThresholdBins;
397 }
398
399 //----- high threshold -----
400 if (highThresholdBins == 0)
401 {
402 if (m_highThresholdSignal[i] > highthreshold)
403 {
405 ++highThresholdBins;
406 }
407 }
408 else if (highThresholdBins > 0)
409 {
410 if (m_highThresholdSignal[i] > highthreshold)
411 {
413 ++highThresholdBins;
414 highThresholdAdditionalBins = 0;
415 }
416 else
417 {
418 if (highThresholdAdditionalBins == 0)
419 {
420 if (highThresholdBins < m_minWidthMinusSettlingTimeInBinWidths)
421 {
422 highThresholdAdditionalBins = m_minDiscriminatorWidthInBinWidths - highThresholdBins;
423 }
424 else
425 {
426 highThresholdAdditionalBins = m_discriminatorSettlingTimeInBinWidths;
427 }
428 }
430 ++highThresholdBins;
431 --highThresholdAdditionalBins;
432 if (highThresholdAdditionalBins == 0)
433 {
434 if (!(m_highThresholdSignal[i] > highthreshold))
435 {
436 highThresholdBins = -m_discriminatorDeadTimeInBinWidths;
437 }
438 }
439 }
440 }
441 else
442 {
443 ++highThresholdBins;
444 }
445 }
446 }
447
448//___________________________________________________________________________
450 //Input: m_lowThresholdDiscriminator[], m_highThresholdDiscriminator[]
451 //
452 //Output: digit
453 //
454 //Uses internally:m_numberOfPreZeroBins
455
456 unsigned digit(0);
457 const unsigned one(1);
458 int i, j, k;
459
460 for (i = 0; i < 24; ++i)
461 {
462 j = i * 4 + m_numberOfPreZeroBins;
463 for (k = 0; k < 4; ++k)
464 {
465 if (m_lowThresholdDiscriminator[j + k] == 1)
466 {
467 digit += one << (25 - i - i / 8);
468 break;
469 }
470 }
471 }
472
473 for (i = 0; i < 3; ++i)
474 {
475 j = i * 32 + m_numberOfPreZeroBins;
476 for (k = 0; k < 32; ++k)
477 {
478 if (m_highThresholdDiscriminator[j + k] == 1)
479 {
480 digit += one << (26 - i * 9);
481 break;
482 }
483 }
484 }
485
486 return digit;
487}
488
489//_____________________________________________________________________________
490double TRTElectronicsProcessing::getHighThreshold ( int hitID, int strawGasType ) {
491 double highthreshold(0.);
492 switch ( TRTDigiHelper::getRegion(hitID) ) {
493 case 1: highthreshold = m_settings->highThresholdBarShort(strawGasType); break;
494 case 2: highthreshold = m_settings->highThresholdBarLong(strawGasType); break;
495 case 3: highthreshold = m_settings->highThresholdECAwheels(strawGasType); break;
496 case 4: highthreshold = m_settings->highThresholdECBwheels(strawGasType); break;
497 default:
498 ATH_MSG_WARNING("TRTDigitization::TRTElectronicsProcessing - getRegion is zero!");
499 break;
500 }
501 return highthreshold;
502}
503
504//___________________________________________________________________________
506
507 // Apply a timing shift to m_highThresholdDiscriminator[]
508 // t0Shift tuning is provided by the parameters:
509 // htT0shiftBarShort, htT0shiftBarLong, htT0shiftECAwheels and m_htT0shiftECBwheels
510
511 int t0Shift(0); // in 0.78125 ns steps
512 switch ( TRTDigiHelper::getRegion(hitID) ) {
513 case 1: t0Shift = m_settings->htT0shiftBarShort(); break;
514 case 2: t0Shift = m_settings->htT0shiftBarLong(); break;
515 case 3: t0Shift = m_settings->htT0shiftECAwheels(); break;
516 case 4: t0Shift = m_settings->htT0shiftECBwheels(); break;
517 default:
518 ATH_MSG_WARNING("TRTDigitization::TRTElectronicsProcessing - getRegion is zero!");
519 break;
520 }
521
522 if (!t0Shift) return; // skip this process if there is no shift
523
524 unsigned int vsum=0;
525 for (int i=0; i<m_totalNumberOfBins; ++i) { vsum += m_highThresholdDiscriminator[i]; }
526 if (!vsum) return; // skip this process if there are no HT bits
527
528 if (t0Shift<0) { // for negative shifts
529
530 for (int i=0; i<m_totalNumberOfBins; ++i) {
531 if (i-t0Shift>=m_totalNumberOfBins) break;
533 }
534 for (int i=m_totalNumberOfBins+t0Shift; i<m_totalNumberOfBins; ++i) if (i>=0) m_highThresholdDiscriminator[i]=0; // the last t0Shift bins are set to zero
535
536 } else { // for positive shifts
537
538 for (int i=m_totalNumberOfBins-1; i>0; --i) {
539 if (i-t0Shift<0) break;
541 }
542 for (int i=0; i<t0Shift; ++i) if (i<m_totalNumberOfBins) m_highThresholdDiscriminator[i]=0; // the first t0Shift bins are set to zero
543
544 }
545
546
547}
548
549//_____________________________________________________________________________
550void TRTElectronicsProcessing::LTt0Shift( int hitID, int strawGasType ) {
551
552 // Apply a timing shift to m_lowThresholdDiscriminator[]
553 // t0Shift tuning is provided by the parameters:
554 // ltT0shiftBarShort, ltT0shiftBarLong, ltT0shiftECAwheels and m_ltT0shiftECBwheels
555
556 int t0Shift(0); // in 0.78125 ns steps
557 switch ( TRTDigiHelper::getRegion(hitID) ) {
558 case 1: t0Shift = m_settings->ltT0shiftBarShort(strawGasType); break;
559 case 2: t0Shift = m_settings->ltT0shiftBarLong(strawGasType); break;
560 case 3: t0Shift = m_settings->ltT0shiftECAwheels(strawGasType); break;
561 case 4: t0Shift = m_settings->ltT0shiftECBwheels(strawGasType); break;
562 default:
563 ATH_MSG_WARNING("TRTDigitization::TRTElectronicsProcessing - getRegion is zero!");
564 break;
565 }
566
567 if (!t0Shift) return; // skip this process if there is no shift
568
569 unsigned int vsum=0;
570 for (int i=0; i<m_totalNumberOfBins; ++i) { vsum += m_lowThresholdDiscriminator[i]; }
571 if (!vsum) return; // skip this process if there are no LT bits
572
573 if (t0Shift<0) { // for negative shifts
574
575 for (int i=0; i<m_totalNumberOfBins; ++i) {
576 if (i-t0Shift>=m_totalNumberOfBins) break;
578 }
579 for (int i=m_totalNumberOfBins+t0Shift; i<m_totalNumberOfBins; ++i) if (i>=0) m_lowThresholdDiscriminator[i]=0; // the last t0Shift bins are set to zero
580
581 } else { // for positive shifts
582
583 for (int i=m_totalNumberOfBins-1; i>0; --i) {
584 if (i-t0Shift<0) break;
586 }
587 for (int i=0; i<t0Shift; ++i) if (i<m_totalNumberOfBins) m_lowThresholdDiscriminator[i]=0; // the first t0Shift bins are set to zero
588
589 }
590
591
592}
593//_____________________________________________________________________________
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Class containing parameters and settings used by TRT digitization.
Class for TRT digits.
Definition TRTDigit.h:11
Simulate TRT Electronics Noise For description of metod, see Thomas Kittelmanns PhD thesis chapters ...
void TabulateSignalShape()
Tabulate low and high level signal shapes from functions LowThresholdSignalShape() and HighThresholdS...
double getHighThreshold(int hitID, int strawGasType)
int * m_lowThresholdDiscriminator
Signal after discrimination.
void ProcessDeposits(const std::vector< Deposit > &, const int &hitID, TRTDigit &outdigit, double lowthreshold, const double &noiseamplitude, int strawGasType, CLHEP::HepRandomEngine *rndmEngine, CLHEP::HepRandomEngine *elecNoiseRndmEngine, double highthreshold=-1.0)
Process deposits in a straw.
void Initialize()
Initialize constants.
std::vector< double > m_lowThresholdSignal
void DiscriminatorResponse(const double &lowthreshold, const double &highthreshold)
Simulate discriminator response.
unsigned EncodeDigit() const
Encode 27 bit digit from discriminator response [8 low + 1 high + 8 low + 1 high + 8 low + 1 high]:
double m_binWidth
Time interval corresponding to each internal bin.
TRTElectronicsProcessing(const TRTDigSettings *digset, TRTElectronicsNoise *electronicsnoise)
std::vector< double > m_lowThresholdSignalShape[3]
TRTElectronicsNoise * m_pElectronicsNoise
void LTt0Shift(int hitID, int strawGasType)
double m_timeInterval
Time interval covered by digit [75 ns].
int m_discriminatorSettlingTimeInBinWidths
Discriminator settling time [bins].
void SignalShaping(int strawGasType)
Shape electron drift signal according to appropriate signal shapes.
std::vector< double > m_highThresholdSignal
std::vector< double > m_highThresholdSignalShape[3]
int m_discriminatorDeadTimeInBinWidths
Discriminator dead time [int.
int * m_highThresholdDiscriminator
Signal after discrimination.
const TRTDigSettings * m_settings
unsigned int getRegion(int hitID)
Definition index.py:1