99#include "TRestRawSignalFittingProcess.h"
179 RESTDebug <<
"TRestRawSignalFittingProcess::ProcessEvent. Event ID : " <<
fRawSignalEvent->GetID()
182 Double_t SigmaMean = 0;
184 Double_t RatioSigmaMaxPeakMean = 0;
185 vector<Double_t> RatioSigmaMaxPeak(
fRawSignalEvent->GetNumberOfSignals());
186 Double_t ChiSquareMean = 0;
189 map<int, Double_t> baselineFit;
190 map<int, Double_t> amplitudeFit;
191 map<int, Double_t> shapingTimeFit;
192 map<int, Double_t> peakPositionFit;
195 amplitudeFit.clear();
196 shapingTimeFit.clear();
197 peakPositionFit.clear();
205 TF1* f =
new TF1(
"fit",
206 "[0]+[1]*TMath::Exp(-3. * (x-[3])/[2]) * "
207 "(x-[3])/[2] * (x-[3])/[2] * (x-[3])/[2] * "
208 "sin((x-[3])/[2])/(1+TMath::Exp(-10000*(x-[3])))",
210 f->SetParameters(0, 2000, 70, 80);
219 f->SetParNames(
"Baseline",
"Amplitude",
"ShapingTime",
"PeakPosition");
223 TH1D* h =
new TH1D(
"histo",
"Signal to histo", nBins, 0, nBins);
225 for (
int i = 0; i < nBins; i++) {
230 h->Fit(f,
"NWW",
"", 0, 511);
233 for (
int j = MaxPeakBin - 145; j < MaxPeakBin + 165; j++) {
234 sigma += (singleSignal->
GetRawData(j) - f->Eval(j)) * (singleSignal->
GetRawData(j) - f->Eval(j));
236 Sigma[s] = TMath::Sqrt(sigma / (145 + 165));
237 RatioSigmaMaxPeak[s] = Sigma[s] / singleSignal->
GetRawData(MaxPeakBin);
238 RatioSigmaMaxPeakMean += RatioSigmaMaxPeak[s];
239 SigmaMean += Sigma[s];
240 ChiSquare[s] = f->GetChisquare();
241 ChiSquareMean += ChiSquare[s];
243 baselineFit[singleSignal->
GetID()] = f->GetParameter(0);
244 amplitudeFit[singleSignal->
GetID()] = f->GetParameter(1);
245 shapingTimeFit[singleSignal->
GetID()] = f->GetParameter(2);
246 peakPositionFit[singleSignal->
GetID()] = f->GetParameter(3);
248 fShaping = f->GetParameter(2);
249 fStartPosition = f->GetParameter(3);
250 fBaseline = f->GetParameter(0);
251 fAmplitude = f->GetParameter(1);
267 Double_t sigmaMeanStdDev = 0;
269 sigmaMeanStdDev += (Sigma[k] - SigmaMean) * (Sigma[k] - SigmaMean);
271 Double_t SigmaMeanStdDev = TMath::Sqrt(sigmaMeanStdDev /
fRawSignalEvent->GetNumberOfSignals());
279 RatioSigmaMaxPeakMean = RatioSigmaMaxPeakMean /
fRawSignalEvent->GetNumberOfSignals();
282 RESTDebug <<
"SigmaMean: " << SigmaMean <<
RESTendl;
283 RESTDebug <<
"SigmaMeanStdDev: " << SigmaMeanStdDev <<
RESTendl;
284 RESTDebug <<
"ChiSquareMean: " << ChiSquareMean <<
RESTendl;
285 RESTDebug <<
"RatioSigmaMaxPeakMean: " << RatioSigmaMaxPeakMean <<
RESTendl;
287 RESTDebug <<
"Standard deviation of signal number " << k <<
": " << Sigma[k] <<
RESTendl;
288 RESTDebug <<
"Chi square of fit signal number " << k <<
": " << ChiSquare[k] <<
RESTendl;
289 RESTDebug <<
"Sandard deviation divided by amplitude of signal number " << k <<
": "
290 << RatioSigmaMaxPeak[k] <<
RESTendl;
317 if (ApplyCut())
return nullptr;
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
An event container for time rawdata signals with fixed length.
void InitProcess() override
Process initialization.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
void EndProcess() override
Function to include required actions after all events have been processed. This method will write the...
TRestRawSignalEvent * fRawSignalEvent
A pointer to the specific TRestRawSignalEvent input.
~TRestRawSignalFittingProcess()
Default destructor.
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestRawSignalFittingProcess()
Default constructor.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
Int_t GetID() const
Returns the value of signal ID.
Double_t GetRawData(Int_t n) const
It returns the original data value of point n without baseline correction.
Int_t GetMaxPeakBin()
It returns the bin at which the maximum peak amplitude happens.
Int_t GetNumberOfPoints() const
Returns the actual number of points, or size of the signal.