CbmRoot
Loading...
Searching...
No Matches
CbmTrdRawToDigiFitR.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 "CbmTrdSpadic.h"
8
9#include <RtypesCore.h>
10#include <TH1.h>
11
12#include <algorithm>
13
14//---- CbmTrdRawToDigiFitR ----
16
17// ---- GetCharge ----
18Float_t CbmTrdRawToDigiFitR::GetMaxAdcValue(const std::vector<std::int16_t>* /*samples*/)
19{
20 Double_t charge = fResponseFunc->GetParameter(static_cast<size_t>(CbmTrdSpadic::eResponsePars::kInputCharge));
21
22 return charge > 0 ? charge : 0;
23}
24
25// ---- GetBinTimeShift ----
26ULong64_t CbmTrdRawToDigiFitR::GetBinTimeShift(const std::vector<std::int16_t>* samples)
27{
28
29 fitResponse(samples);
30
31 ULong64_t time = static_cast<ULong64_t>(
32 fResponseFunc->GetParameter(static_cast<size_t>(CbmTrdSpadic::eResponsePars::kBinTimeshift)));
33 return time;
34}
35
36// ---- fixExtractionPars ----
38{
39 // Fix the parameters that are given by the spadic design
40 std::vector<CbmTrdSpadic::eResponsePars> pars = {
43 for (auto ipar : pars)
44 fixExtractionPar(ipar);
45
46 // Limit the bin timeshift parameter to the clock cycle length
47 fResponseFunc->SetParLimits(static_cast<size_t>(CbmTrdSpadic::eResponsePars::kBinTimeshift),
49}
50
51// ---- fixExtractionPar ----
53{
54 fResponseFunc->FixParameter(static_cast<size_t>(ipar), fResponseFunc->GetParameter(static_cast<size_t>(ipar)));
55}
56
57// ---- fitResponse ----
58void CbmTrdRawToDigiFitR::fitResponse(const std::vector<std::int16_t>* samples)
59{
60 fResponseFunc->SetParameter(static_cast<size_t>(CbmTrdSpadic::eResponsePars::kInputCharge), 0.0);
61 fResponseFunc->SetParameter(static_cast<size_t>(CbmTrdSpadic::eResponsePars::kBinTimeshift), 0.0);
62
63 TH1F hsignal("hsignal", "hsignal", samples->size(), 0, samples->size() - 1);
64 Int_t ibin = 0;
65 auto baseline = GetBaseline(samples);
66 for (auto isample : *samples) {
67 if (isample < fSpadic->GetClippingStart()) hsignal.SetBinContent(ibin, (isample - baseline));
68 ibin++;
69 }
70 if (fFitRangeEnd > samples->size()) return;
71 // hsignal.Fit(fResponseFunc.get(), "SNQE I", "goff", fFitRangeStart, fFitRangeEnd);
72
73 // Do not use
74 // E speed improvement
75 // M speed improvement
76 // I it does not make sense to integrate the bin, since, we use discretised values from the adc
77
78 // Use
79 // C do not calculate chi2 to improve speed
80 // S store the result to a TFitResultsPtr
81 // Q we do want only minimal printout
82 // N do not store the graphics function
83 hsignal.Fit(fResponseFunc.get(), "SCNQ", "goff", fFitRangeStart, fFitRangeEnd);
84}
85
ClassImp(CbmConverterManager)
Class for extracting information from raw signals to digi level.
Software representation of the SPADIC v2.2+.
Float_t GetBaseline(const std::vector< std::int16_t > *samples)
Get the Baseline value.
void fixExtractionPars()
Fix the extraction parameters to the default values.
UInt_t fFitRangeStart
First sample that is used for the fit.
ULong64_t GetBinTimeShift(const std::vector< std::int16_t > *)
Get the Bin Time Shift value.
void fitResponse(const std::vector< std::int16_t > *samples)
Perform the fit of the input signal.
UInt_t fFitRangeEnd
Last sample that is used for the fit.
CbmTrdRawToDigiFitR()
default Constructor with messages
std::shared_ptr< TF1 > fResponseFunc
Response function.
void fixExtractionPar(CbmTrdSpadic::eResponsePars ipar)
Fix the passed extraction parameter (wrapper function)
Float_t GetMaxAdcValue(const std::vector< std::int16_t > *)
Get the MaxAdc value.
static Double_t GetClockCycle()
Get the Clock Cycle.
eResponsePars
enum for response parameters