61#include "TRestRawSignalGeneralFitProcess.h"
141 RESTDebug <<
"TRestRawSignalGeneralFitProcess::ProcessEvent. Event ID : " <<
fRawSignalEvent->GetID()
144 Double_t SigmaMean = 0;
146 Double_t RatioSigmaMaxPeakMean = 0;
147 vector<Double_t> RatioSigmaMaxPeak(
fRawSignalEvent->GetNumberOfSignals());
148 Double_t ChiSquareMean = 0;
167 std::vector<map<int, Double_t>> param(fFitFunc->GetNpar());
168 std::vector<map<int, Double_t>> paramErr(fFitFunc->GetNpar());
195 TH1D* h =
new TH1D(
"histo",
"Signal to histo", nBins, 0, nBins);
197 for (
int i = 0; i < nBins; i++) {
202 h->Fit(fFitFunc,
"NWW",
"", 0, 511);
205 for (
int j = fFunctionRange.X(); j < fFunctionRange.Y(); j++) {
206 sigma += (singleSignal->
GetRawData(j) - fFitFunc->Eval(j)) *
207 (singleSignal->
GetRawData(j) - fFitFunc->Eval(j));
209 Sigma[s] = TMath::Sqrt(sigma / (fFunctionRange.Y() - fFunctionRange.X()));
210 RatioSigmaMaxPeak[s] = Sigma[s] / singleSignal->
GetRawData(MaxPeakBin);
211 RatioSigmaMaxPeakMean += RatioSigmaMaxPeak[s];
212 SigmaMean += Sigma[s];
213 ChiSquare[s] = fFitFunc->GetChisquare();
214 ChiSquareMean += ChiSquare[s];
216 for (
int i = 0; i < fFitFunc->GetNpar(); i++) {
217 param[i][singleSignal->
GetID()] = fFitFunc->GetParameter(i);
218 paramErr[i][singleSignal->
GetID()] = fFitFunc->GetParError(i);
219 RESTDebug <<
"Parameter " << i <<
": " << param[i][singleSignal->
GetID()] <<
RESTendl;
220 RESTDebug <<
"Error parameter " << i <<
": " << paramErr[i][singleSignal->
GetID()] <<
RESTendl;
243 for (
int i = 0; i < fFitFunc->GetNpar(); i++) {
253 Double_t sigmaMeanStdDev = 0;
255 sigmaMeanStdDev += (Sigma[k] - SigmaMean) * (Sigma[k] - SigmaMean);
257 Double_t SigmaMeanStdDev = TMath::Sqrt(sigmaMeanStdDev /
fRawSignalEvent->GetNumberOfSignals());
265 RatioSigmaMaxPeakMean = RatioSigmaMaxPeakMean /
fRawSignalEvent->GetNumberOfSignals();
268 RESTDebug <<
"SigmaMean: " << SigmaMean <<
RESTendl;
269 RESTDebug <<
"SigmaMeanStdDev: " << SigmaMeanStdDev <<
RESTendl;
270 RESTDebug <<
"ChiSquareMean: " << ChiSquareMean <<
RESTendl;
271 RESTDebug <<
"RatioSigmaMaxPeakMean: " << RatioSigmaMaxPeakMean <<
RESTendl;
273 RESTDebug <<
"Standard deviation of signal number " << k <<
": " << Sigma[k] <<
RESTendl;
274 RESTDebug <<
"Chi square of fit signal number " << k <<
": " << ChiSquare[k] <<
RESTendl;
275 RESTDebug <<
"Sandard deviation divided by amplitude of signal number " << k <<
": "
276 << RatioSigmaMaxPeak[k] <<
RESTendl;
303 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.
~TRestRawSignalGeneralFitProcess()
Default destructor.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void EndProcess() override
Function to include required actions after all events have been processed. This method will write the...
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
Process initialization.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
TRestRawSignalGeneralFitProcess()
Default constructor.
TRestRawSignalEvent * fRawSignalEvent
A pointer to the specific TRestRawSignalEvent input.
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.
TF1 * CreateTF1FromString(std::string func, double init, double end)
Reads a function with parameter options from string and returns it as TF1*.