CbmRoot
Loading...
Searching...
No Matches
CbmTrdSpadic.h
Go to the documentation of this file.
1/* Copyright (C) 2021 Goethe-University Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pascal Raisig [committer] */
4
17#ifndef CBMTRDSPADIC_H
18#define CBMTRDSPADIC_H
19
20#include "CbmTrdDefs.h" // for MIP dEdx value
21#include "CbmTrdDigi.h" // for ClockCycle
22#include "CbmTrdParSpadic.h"
23#include "CbmTrddEdxUtils.h" // for MIP dEdx
24
25#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
26#include <RtypesCore.h> // for Double_t, Int_t, Bool_t, Option_t
27#include <TF1.h> // for response functions
28#include <TObject.h> // for TObject inheritence
29
30#include <cstdint>
31#include <vector>
32
33#include <MessageTypes.h>
34#include <cmath>
35
37
38public:
45
50 CbmTrdSpadic(const CbmTrdSpadic&) = delete;
51
58
63 virtual ~CbmTrdSpadic();
64
65
70 enum class eResponsePars : size_t
71 {
72 kShapingTime = 0,
79 };
86 Double_t GetParameter(eResponsePars partype) { return fvecResponsePars[static_cast<size_t>(partype)]; }
87
88 static UInt_t GetNrChannels() { return NSPADICCH; }
89
96 static std::shared_ptr<TF1> GetResponseFunc();
97
103 static constexpr UInt_t GetNrOfAdcSamples() { return fgNrOfAdcSamples; }
104
110 static constexpr UInt_t GetNrOfPresamples() { return fgNrOfPresamples; }
111
117 static constexpr UInt_t GetShapingOrder() { return fgShapingOrder; }
118
124 static Float_t GetShapingTime() { return fgShapingTime; }
125
131 static Double_t GetClockCycle() { return fgClockCycleLength; }
132
138 static Double_t GetChargeToMaxAdcCal() { return fgChargeToMaxAdcCal; }
139
151 static Double_t Response(Double_t* samplenr, Double_t* par);
152
162 std::vector<std::int16_t> GetAnalogResponsePulse(Double_t inputCharge, Double_t binTimeshift = 0.0);
163
170 Int_t GetNoise(Double_t sigmaNoise);
171
177 UInt_t GetBaselineLvl() { return fBaselineLvl; }
178
186 template<class Pulse>
187 void ApplyClipping(Pulse* pulse)
188 {
189 for (auto& sample : *pulse) {
190 if (sample > fClippingStart) sample = fClippingStart;
191 }
192 }
193
202 Double_t GetAnalyticTimeshift(Double_t absolutetime);
203
209 UInt_t GetDynamicRange() { return fDynamicRange; }
210
218 UInt_t GetPeakingSamplePos();
219
226
232 Float_t GetAdcNoiseLevel() { return fNoiseLvl; }
233
240
246 Double_t GetMipCalibration() { return fMaxAdcToMipCal; }
247
248
255
265
273 Float_t MaxAdcToEnergyCal(Float_t maxadc);
274
275
287 template<class precision>
288 CbmTrdDigi::eTriggerType GetTriggerDecision(std::vector<precision>* pulse, UInt_t* sndtriggersample = nullptr)
289 {
290 if (pulse->empty()) return CbmTrdDigi::eTriggerType::kNTrg;
291
292 if (sndtriggersample) *sndtriggersample = 0;
293 Int_t slopeFst = 0;
294 Int_t slopeSnd = 0;
295 bool selftrigger = false;
296 bool falling = false;
297 bool multihit = false;
298
299
300 // Loop from the pulse beginning to last sample which could release a trigger.
301 // Since, we need two positive sloapes in a row, the last two samples can not release a trigger alone
302 for (auto sampleIt = pulse->begin(); sampleIt < pulse->end() - 2; ++sampleIt) {
303 slopeFst = *(sampleIt + 1) - *sampleIt;
304 if (slopeFst < fTriggerSlopeConditionFst && !selftrigger) continue;
305
306 slopeSnd = *(sampleIt + 1) - *sampleIt;
307 if (slopeSnd < 0 && !selftrigger) continue;
308
309 if (!selftrigger) {
310 if (slopeFst >= 2 * fTriggerSlopeConditionFst) selftrigger = true;
311 if (slopeFst >= fTriggerSlopeConditionFst && slopeSnd >= fTriggerSlopeConditionSnd) selftrigger = true;
312 }
313 else {
314 if (falling) {
315 if (slopeFst >= 2 * fTriggerSlopeConditionFst) multihit = true;
316 if (slopeFst >= fTriggerSlopeConditionFst && slopeSnd >= fTriggerSlopeConditionSnd) multihit = true;
317 if (sndtriggersample) *sndtriggersample = sampleIt - pulse->begin();
318 }
319 if (slopeFst < 0 && slopeSnd < 0) falling = true;
320 }
321 if (multihit) break;
322 }
324 if (selftrigger && !multihit) triggerType = CbmTrdDigi::eTriggerType::kSelf;
325 if (selftrigger && multihit) triggerType = CbmTrdDigi::eTriggerType::kMulti;
326
327 return triggerType;
328 }
334 void SetDynamicRange(UInt_t value) { fDynamicRange = value; }
335
341 void SetClippingStart(Int_t value) { fClippingStart = value; }
342
343 void SetNoiseLevel(Double_t value) { fNoiseLvl = value; }
344
351
358
364 void SetMaxAdcToEnergyCal(Double_t value) { fMaxAdcToEnergyCal = value; }
365
371 void SetMipCalibration(Double_t value) { fMaxAdcToMipCal = value; }
372
373
379 void SetModuleThickness(Double_t value) { fModuleThickness = value; }
380
386 void SetBaselineLvl(UInt_t value) { fBaselineLvl = value; }
387
393 void SetUseBaselineAverage(bool value = true) { fDoUseBaselineAvg = value; }
394
404 Double_t Response(UInt_t samplenr);
405
406 void SetParameter(eResponsePars ipar, Double_t value) { fvecResponsePars.at(static_cast<size_t>(ipar)) = value; }
407
408private:
413 static const Double_t fgClockCycleLength;
414
429
436 static constexpr UInt_t fgNrOfAdcSamples = 32;
437
446 static const Double_t fgShapingTime;
447
453 static constexpr UInt_t fgShapingOrder = 1;
454
461 static constexpr UInt_t fgNrOfPresamples = 1;
462
470 static const Double_t fgChargeToMaxAdcCal;
471
476 UInt_t fDynamicRange = std::pow(2, 9);
477
483
495
509
517 Float_t fModuleThickness = 1.20;
518
523 // UInt_t fBaselineLvl = 10;
524 UInt_t fBaselineLvl = 0;
525
537 // Float_t fMaxAdcToMipCal = 1;
538
541
543 Float_t fNoiseLvl = 1;
544
546 bool fDoUseBaselineAvg = false;
547
548public:
550};
551#endif
#define NSPADICCH
Class containing definitions and functions correlated to the dEdx behavior of the CbmTrd.
static Double_t GetChargeToMaxAdcCal()
Get the Charge To Max Adc Calibration value.
static Double_t GetClockCycle()
Get the Clock Cycle.
UInt_t GetPeakingSamplePos()
Get the Peaking Sample Pos.
bool GetUseBaselineAvg()
Get the Use Baseline Avg flag.
ClassDef(CbmTrdSpadic, 2)
eResponsePars
enum for response parameters
CbmTrdDigi::eTriggerType GetTriggerDecision(std::vector< precision > *pulse, UInt_t *sndtriggersample=nullptr)
Get the Trigger Decision Get the trigger decision for the spadic. Currently this is based on the & di...
void SetBaselineLvl(UInt_t value)
Set the Baseline Lvl value.
void SetMaxAdcToEnergyCal(Double_t value)
Set the Max Adc To Energy Cal value.
Float_t GetModuleThickness()
Get the Module Thickness value.
static constexpr UInt_t fgNrOfAdcSamples
Number of ADC samples.
Float_t GetMaxAdcToEnergyCal()
Get the Max Adc To Energy Cal value.
void SetModuleThickness(Double_t value)
Set the Module Thickness value.
Float_t fModuleThickness
Thickness of the module [cm] this spadic is mounted on. Should be setted during runtime from paramete...
Int_t fTriggerSlopeConditionFst
Slope trigger condition for a two stage differential triggger.
Double_t GetMipCalibration()
Get the MaxAdc to Mip Calibration value.
Float_t fMaxAdcToMipCal
Calibration for MIP to 7% of MaxAdc dynamic range. 0.65 = charge from PRF broad distribution on centr...
bool fDoUseBaselineAvg
Flag wether we have n standard presamples or the average baseline in a single presamples.
virtual ~CbmTrdSpadic()
Destroy the Cbm Trd Spadic object.
static constexpr UInt_t GetNrOfAdcSamples()
Get the Nr Of Adc Samples (Spadic default)
void SetDynamicRange(UInt_t value)
Set the Dynamic Range value.
Float_t GetAdcNoiseLevel()
Get the Adc Noise Level value.
Double_t GetAnalyticTimeshift(Double_t absolutetime)
Get the Analytic Timeshift value ns precision Calculate the timeshift within the spadic response base...
static constexpr UInt_t GetShapingOrder()
Get the Shaping Order.
UInt_t fDynamicRange
Dynamic range of the spadic The Spadic uses a 9-Bit ADC.
void SetClippingStart(Int_t value)
Set the Clipping Start value.
void SetNoiseLevel(Double_t value)
static const Double_t fgClockCycleLength
Clockcycle length of SPADIC v2.2.
UInt_t GetBaselineLvl()
Get the Baseline Lvl value.
static const Double_t fgChargeToMaxAdcCal
Calibration factor for input charges.
static std::shared_ptr< TF1 > GetResponseFunc()
Get a TF1 response function object.
std::vector< std::int16_t > GetAnalogResponsePulse(Double_t inputCharge, Double_t binTimeshift=0.0)
Get the Analog Response to a given input charge per adc time bin.
void SetSndTriggerSlopeCondition(Double_t value)
Set the Trigger Slope Condition value.
Float_t fMaxAdcToEnergyCal
Calibration value to calculate energy in keV based on the max adc value. Default = Simulation calibra...
void SetFstTriggerSlopeCondition(Double_t value)
Set the Trigger Slope Condition value.
static Float_t GetShapingTime()
Get the Shaping Time (Spadic default)
Int_t fClippingStart
Value where a analog and or digital clipping appears By default it is set to the dynamic range of Spa...
Int_t GetNoise(Double_t sigmaNoise)
Get a Noise value based on the width of the noise distribution in sigmas.
std::vector< Double_t > fvecResponsePars
Vector for the response parameters. Order based on eResponsePars. The given values here correspond to...
static const Double_t fgShapingTime
Spadic shaping time.
void ApplyClipping(Pulse *pulse)
Check the passed pulse for samples in clipping and reduce the value of those to fClippingStart.
void SetParameter(eResponsePars ipar, Double_t value)
CbmTrdSpadic & operator=(const CbmTrdSpadic &)
Assignment of CbmTrdSpadic objects (not implemented!)
static UInt_t GetNrChannels()
void SetUseBaselineAverage(bool value=true)
Set the Use Baseline Average flag.
Int_t GetClippingStart()
Get the Clipping Start value.
static constexpr UInt_t fgNrOfPresamples
Number of presamples in the ADC signal in front of the actual signal.
static Double_t Response(Double_t *samplenr, Double_t *par)
Response of the SPADIC v2.2 to an input charge, for a given timesample.
CbmTrdSpadic()
Construct a new CbmTrdSpadic object Default and standard c'tor for a CbmTrdSpadic object.
Int_t fTriggerSlopeConditionSnd
Slope trigger condition for a two stage differential triggger.
UInt_t GetDynamicRange()
Get the Dynamic Range value.
Double_t GetParameter(eResponsePars partype)
Get the Parameter value.
UInt_t fBaselineLvl
Baseline level of the current Spadic Used for MaxAdcToMip calibration and baseline placement in Analo...
static constexpr UInt_t GetNrOfPresamples()
Get the Nr Of Preamples.
Float_t MaxAdcToEnergyCal(Float_t maxadc)
Return energy [keV (MC input GeV)] for a given max adc value, based on max adc to energy calibration.
void SetMipCalibration(Double_t value)
Set the max adc to mip calibration value.
static constexpr UInt_t fgShapingOrder
Spadic Shaping order.
Float_t fNoiseLvl
Noise level for signal response simulation [gaus sigmas].
CbmTrdSpadic(const CbmTrdSpadic &)=delete
Copy construct a new CbmTrdSpadic object (not implemented!)
static Double_t MeanChargeCentrPadPRF()
Mean charge fraction on the central pad assuming a flat distrubtion all over the pad.
static Double_t MipDeDx()
Mip De Dx kev/cm for XeC02 8020 see https://cbm-wiki.gsi.de/foswiki/bin/view/TRD/ TrdParameterList.
static Double_t MipCaliTarget()
Target percentage of the dynamic range for the MIP energy deposition on the central pad.