CbmRoot
Loading...
Searching...
No Matches
CbmTrdRawToDigiMaxAdcR.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 <Logger.h>
8
9#include <algorithm>
10#include <iostream>
11#include <iterator>
12
13//---- CbmTrdRawToDigiMaxAdcR ----
15
16// --- GetCharge ----
17Float_t CbmTrdRawToDigiMaxAdcR::GetMaxAdcValue(const std::vector<std::int16_t>* samples)
18{
19 // Safety for corrupted input samples
20 if (samples->size() < fPeakingBinMin) {
21 LOG(error) << "CbmTrdRawToDigiMaxAdcR::GetCharge samples.size() = " << samples->size()
22 << " fPeakingBinMin = " << fPeakingBinMin;
23 return 0;
24 }
25
26 // The signal should peak at the shaping time.
27 // The corresponding sample is the peaking time divided by the sample length.
28 auto itbegin = std::next(samples->begin(), fPeakingBinMin);
29
30 // Check if the expected maximum position of the peaking bin exceeds the size of the vector
31 auto nsamples = samples->size();
32 auto peakingBinMax = (nsamples - 1) > fPeakingBinMax ? fPeakingBinMax : nsamples;
33 auto itend = std::next(samples->begin(), peakingBinMax);
34
35 // Get the maximum element
36 auto itmax = std::max_element(itbegin, itend);
37
38 Float_t charge = static_cast<Float_t>(*itmax);
39
40 // Correct for the baseline
41 charge -= GetBaseline(samples);
42
43
44 // Remark: Due to the fact, that we store the charge UInt_t in the Digi values below 0 are not allowed.
45 // In this case the above only appears if the baseline fluctuated above all values in the applied peaking range. This can only happen for forced neighbor triggers with a deposited charged that can not be separated from the baseline.
46 return charge > 0 ? charge : 0;
47}
48
49
ClassImp(CbmConverterManager)
Class for extracting information from raw signals to digi level.
Float_t GetBaseline(const std::vector< std::int16_t > *samples)
Get the Baseline value.
Float_t GetMaxAdcValue(const std::vector< std::int16_t > *samples)
Get the MaxAdc value.
size_t fPeakingBinMax
Last sample to look for the max adc Default value is set based on the Shaping time + 5 samples safety...
CbmTrdRawToDigiMaxAdcR()
default Constructor with messages
size_t fPeakingBinMin
First sample to look for the max adc.