Project
Loading...
Searching...
No Matches
SAMPAProcessing.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_TPC_SAMPAProcessing_H_
17#define ALICEO2_TPC_SAMPAProcessing_H_
18
19#include <Vc/Vc>
20
21#include "TPCBase/PadPos.h"
22#include "TPCBase/CalDet.h"
23#include "TPCBase/CRU.h"
28
29#include "TSpline.h"
30
31namespace o2
32{
33namespace tpc
34{
35
39
41{
42 public:
44 {
45 static SAMPAProcessing sampaProcessing;
46 return sampaProcessing;
47 }
50 explicit SAMPAProcessing(TRandom* rng = nullptr);
51
53 ~SAMPAProcessing() = default;
54
56 void setRandomRingPositions(TRandom& rng) { mRandomNoiseRing.setRandomPosition(rng); }
57
59 void updateParameters(float vdrift = 0);
60
64 template <typename T>
65 T getADCvalue(T nElectrons) const;
66
70 float getADCSaturation(const float signal) const;
71
78 template <DigitzationMode MODE>
79 float makeSignal(float ADCcounts, const int sector, const int globalPadInSector, const float commonMode, float& pedestal, float& noise, float tot = 0);
80
87 void getShapedSignal(float ADCsignal, float driftTime, std::vector<float>& signalArray) const;
88
93 template <typename T>
94 T getGamma4(T time, T startTime, T ADC) const;
95
99 TimeBin getTimeBin(float zPos) const;
100
105 float getZfromTimeBin(float timeBin, Side s) const;
106
110 TimeBin getTimeBinFromTime(float time) const;
111
115 float getTimeFromBin(TimeBin timeBin) const;
116
120 float getTimeBinTime(float time) const;
121
126 float getNoise(const int sector, const int globalPadInSector);
127
129 float getZeroSuppression(const int sector, const int globalPadInSector) const;
130
135 float getPedestal(const int sector, const int globalPadInSector) const;
136
141 float getPedestalCRU(const int sector, const int globalPadInSector) const;
142
143 private:
144 const ParameterGas* mGasParam;
145 const ParameterDetector* mDetParam;
146 const ParameterElectronics* mEleParam;
147 const CalPad* mNoiseMap;
148 const CalPad* mPedestalMap;
149 const CalPad* mPedestalMapCRU;
150 const CalPad* mZeroSuppression;
151 math_utils::RandomRing<> mRandomNoiseRing;
152 float mVDrift = 0;
153};
154
155template <typename T>
156inline T SAMPAProcessing::getADCvalue(T nElectrons) const
157{
158 T conversion = mEleParam->ElectronCharge * 1.e15 * mEleParam->ChipGain * mEleParam->ADCsaturation /
159 mEleParam->ADCdynamicRange; // 1E-15 is to convert Coulomb in fC
160 return nElectrons * conversion;
161}
162
163template <DigitzationMode MODE>
164inline float SAMPAProcessing::makeSignal(float ADCcounts, const int sector, const int globalPadInSector, const float commonMode,
165 float& pedestal, float& noise, float tot)
166{
167 pedestal = getPedestal(sector, globalPadInSector);
168 noise = getNoise(sector, globalPadInSector);
169
170 const float signal = ADCcounts;
171 const float pedestalCRU = getPedestalCRU(sector, globalPadInSector);
172 const float fullSignal = signal - commonMode + noise + pedestal + (tot > 0 ? 80 : 0); // TODO: improve to also add tail
173
174 switch (MODE) {
176 return getADCSaturation(fullSignal);
177 break;
178 }
180 const float signalSubtractPedestal = getADCSaturation(signal) - pedestalCRU;
181 const float zeroSuppression = getZeroSuppression(sector, globalPadInSector);
182 if (signalSubtractPedestal < zeroSuppression) {
183 return 0.f;
184 }
185 return signalSubtractPedestal;
186 break;
187 }
189 // TODO: this is not really a common mode correction, since the common mode is simply not treated.
190 // Instead, the full common mode algorithm should be implemented and used
191 const float signalNoCM = signal + noise + pedestal + (tot > 0 ? 80 : 0); // TODO: improve to also add tail
192 const float signalSubtractPedestal = getADCSaturation(signalNoCM) - pedestalCRU;
193 const float zeroSuppression = getZeroSuppression(sector, globalPadInSector);
194 if (signalSubtractPedestal < zeroSuppression) {
195 return 0.f;
196 }
197 return signalSubtractPedestal;
198 break;
199 }
201 const float signalSubtractPedestal = getADCSaturation(fullSignal) - pedestalCRU;
202 return signalSubtractPedestal;
203 break;
204 }
206 return fullSignal;
207 break;
208 }
210 return signal;
211 break;
212 }
213 }
214 return signal;
215}
216
217inline float SAMPAProcessing::getADCSaturation(const float signal) const
218{
219 const float adcSaturation = mEleParam->ADCsaturation;
220 if (signal > adcSaturation - 1) {
221 return adcSaturation - 1;
222 }
223 return signal;
224}
225
226template <typename T>
227inline T SAMPAProcessing::getGamma4(T time, T startTime, T ADC) const
228{
229 const auto tmp0 = (time - startTime) / mEleParam->PeakingTime;
230 const auto cond = (tmp0 > 0);
231 T tmp{};
232 if constexpr (std::is_floating_point_v<T>) {
233 if (!cond) {
234 return T{};
235 }
236 tmp = tmp0;
237 } else {
238 tmp(cond) = tmp0;
239 }
240 const auto tmp2 = tmp * tmp;
241 return 55.f * ADC * std::exp(-4.f * tmp) * tmp2 * tmp2;
242}
243
244inline TimeBin SAMPAProcessing::getTimeBin(float zPos) const
245{
246 return static_cast<TimeBin>((mDetParam->TPClength - std::abs(zPos)) / (mVDrift * mEleParam->ZbinWidth));
247}
248
249inline float SAMPAProcessing::getZfromTimeBin(float timeBin, Side s) const
250{
251 const float zSign = (s == 0) ? 1 : -1;
252 return zSign * (mDetParam->TPClength - (timeBin * mVDrift * mEleParam->ZbinWidth));
253}
254
256{
257 if (time < 0.f) {
258 // protection and convention for negative times (otherwise overflow)
259 return 0;
260 }
261 return static_cast<TimeBin>(time / mEleParam->ZbinWidth);
262}
263
264inline float SAMPAProcessing::getTimeFromBin(TimeBin timeBin) const
265{
266 return static_cast<float>(timeBin) * mEleParam->ZbinWidth;
267}
268
269inline float SAMPAProcessing::getTimeBinTime(float time) const
270{
272}
273
274inline float SAMPAProcessing::getNoise(const int sector, const int globalPadInSector)
275{
276 return mRandomNoiseRing.getNextValue() * mNoiseMap->getValue(sector, globalPadInSector);
277}
278
279inline float SAMPAProcessing::getZeroSuppression(const int sector, const int globalPadInSector) const
280{
281 return mZeroSuppression->getValue(sector, globalPadInSector);
282}
283
284inline float SAMPAProcessing::getPedestal(const int sector, const int globalPadInSector) const
285{
286 return mPedestalMap->getValue(sector, globalPadInSector);
287}
288
289inline float SAMPAProcessing::getPedestalCRU(const int sector, const int globalPadInSector) const
290{
291 return mPedestalMapCRU->getValue(sector, globalPadInSector);
292}
293} // namespace tpc
294} // namespace o2
295
296#endif // ALICEO2_TPC_SAMPAProcessing_H_
int16_t time
Definition RawEventData.h:4
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Definition of the parameter class for the detector.
Definition of the parameter class for the detector electronics.
Definition of the parameter class for the detector gas.
const T getValue(const int sec, const int globalPadInSector) const
Definition CalDet.h:160
void setRandomRingPositions(TRandom &rng)
Move the random ring to a new position drawn from rng.
float getZeroSuppression(const int sector, const int globalPadInSector) const
Get the zero suppression threshold for a given channel.
float getNoise(const int sector, const int globalPadInSector)
void getShapedSignal(float ADCsignal, float driftTime, std::vector< float > &signalArray) const
T getADCvalue(T nElectrons) const
static SAMPAProcessing & instance()
float getTimeBinTime(float time) const
float getTimeFromBin(TimeBin timeBin) const
float makeSignal(float ADCcounts, const int sector, const int globalPadInSector, const float commonMode, float &pedestal, float &noise, float tot=0)
float getZfromTimeBin(float timeBin, Side s) const
void updateParameters(float vdrift=0)
Update the OCDB parameters cached in the class. To be called once per event.
float getPedestalCRU(const int sector, const int globalPadInSector) const
TimeBin getTimeBin(float zPos) const
~SAMPAProcessing()=default
Destructor.
float getADCSaturation(const float signal) const
T getGamma4(T time, T startTime, T ADC) const
TimeBin getTimeBinFromTime(float time) const
float getPedestal(const int sector, const int globalPadInSector) const
@ ZeroSuppressionCMCorr
Apply noise, pedestal and saturation and then from that subtract the pedestal and apply zero suppress...
@ ZeroSuppression
Apply noise, pedestal, common mode and saturation and then from that subtract the pedestal and apply ...
@ PropagateADC
Just propagate the bare ADC value.
@ FullMode
Apply noise, pedestal and saturation.
@ SubtractPedestal
Apply noise, pedestal and saturation and then from that subtract the pedestal.
@ NoSaturation
Apply only noise and pedestal.
Side
TPC readout sidE.
Definition Defs.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
float TPClength
Length of the TPC [cm].
float ADCdynamicRange
Dynamic range of the ADC [mV].
float ADCsaturation
ADC saturation [ADC counts].
float ZbinWidth
Width of a z bin [us].
float PeakingTime
Peaking time of the SAMPA [us].
float ElectronCharge
Electron charge [C].
float ChipGain
Gain of the SAMPA [mV/fC] - may be either 20 or 30.