CbmRoot
Loading...
Searching...
No Matches
CbmTrdRawToDigiBaseR.cxx
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
6
7#include "CbmTrdDigi.h"
9
10#include <Rtypes.h>
11
12
13//---- CbmTrdRawToDigiBaseR ----
15
16// ---- GetBaseline ----
17Float_t CbmTrdRawToDigiBaseR::GetBaseline(const std::vector<std::int16_t>* samples)
18{
19 // The spadic 2.2 has a functionality that an average baseline can be written to the first sample. So first we have to check if this is active.
20 if (fSpadic->GetUseBaselineAvg())
21 return samples->at(0);
22 else {
23 Float_t baseline = 0.0;
24 auto itend = samples->begin() + fNrOfPresamples;
25 if (itend > samples->end()) itend = samples->end();
26 for (auto isample = samples->begin(); isample < itend; isample++) {
27 baseline += *isample;
28 }
29 baseline /= fNrOfPresamples;
30
31 return baseline;
32 }
33}
34
35// ---- GetDigiTriggerType ----
37{
38 auto digiTriggerType = CbmTrdDigi::eTriggerType::kNTrg;
39 // Shift self trigger to digi selftrigger
40 // Shift neighbour trigger to digi neighbour
41 // Hide spadic kSandN in Self
42 switch (tt) {
47 }
48 return digiTriggerType;
49}
50
51// ---- MakeDigi ----
52std::unique_ptr<CbmTrdDigi> CbmTrdRawToDigiBaseR::MakeDigi(const std::vector<std::int16_t>* samples, Int_t padChNr,
53 Int_t uniqueModuleId, ULong64_t time,
54 CbmTrdDigi::eTriggerType triggerType, Int_t errClass)
55{
56 // Get the timeshift and set the member, which is required for some of the rtd methods
58
59 // In this case of CbmTrdRawToDigi GetCharge calls GetBinTimeshift, since the information is needed. The shift is stored in fCurrentTimeshift
60 // Hence, the order of charge and time assignement here makes a difference!
61 auto maxadc = GetMaxAdcValue(samples);
62
63 // Get energy from maxadc value
64 auto energy = fSpadic->MaxAdcToEnergyCal(maxadc);
65
66 // In simulation since we often start at time = 0 there is a non negligible chance that a time < 0 is extracted. Since, this is not allowed in the code we set it to 0 for these cases
67 time = time > fCurrentTimeshift ? time - fCurrentTimeshift : 0;
68
69 auto digi = std::unique_ptr<CbmTrdDigi>(new CbmTrdDigi(padChNr, uniqueModuleId, energy, time, triggerType, errClass));
70 return digi;
71}
72
ClassImp(CbmConverterManager)
Base class for extracting of information from raw signals to digi level.
virtual Float_t GetMaxAdcValue(const std::vector< std::int16_t > *samples)=0
Get the MaxAdc value.
UInt_t fNrOfPresamples
Number of presamples before the signal starts (SPADIC default 2)
static CbmTrdDigi::eTriggerType GetDigiTriggerType(Spadic::eTriggerType tt)
Get the Digi Trigger Type from the raw message triggertype.
virtual ULong64_t GetBinTimeShift(const std::vector< std::int16_t > *samples)=0
Get the Bin Time Shift value.
std::shared_ptr< CbmTrdSpadic > fSpadic
CbmTrdRawToDigiBaseR()
Construct a new CbmTrdRawToDigiBaseR object.
Float_t GetBaseline(const std::vector< std::int16_t > *samples)
Get the Baseline value.
ULong64_t fCurrentTimeshift
Bin timeshift for the current sample set in [ns].
std::unique_ptr< CbmTrdDigi > MakeDigi(const std::vector< std::int16_t > *samples, Int_t padChNr, Int_t uniqueModuleId, ULong64_t time, CbmTrdDigi::eTriggerType triggerType, Int_t errClass)
Get digi from input values. Implemented in the derived classes.
@ kNeigh
Neighbor trigger.
@ kGlobal
global trigger.
@ kSelf
Self trigger.
@ kSandN
Self and neighbor trigger at the same time.