61 #include "TRestRawSignalGeneralFitProcess.h"
87 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
105 SetSectionName(this->ClassName());
106 SetLibraryVersion(LIBRARY_VERSION);
108 fRawSignalEvent =
nullptr;
124 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
141 RESTDebug <<
"TRestRawSignalGeneralFitProcess::ProcessEvent. Event ID : " << fRawSignalEvent->GetID()
144 Double_t SigmaMean = 0;
145 vector<Double_t> Sigma(fRawSignalEvent->GetNumberOfSignals());
146 Double_t RatioSigmaMaxPeakMean = 0;
147 vector<Double_t> RatioSigmaMaxPeak(fRawSignalEvent->GetNumberOfSignals());
148 Double_t ChiSquareMean = 0;
149 vector<Double_t> ChiSquare(fRawSignalEvent->GetNumberOfSignals());
167 std::vector<map<int, Double_t>> param(fFitFunc->GetNpar());
168 std::vector<map<int, Double_t>> paramErr(fFitFunc->GetNpar());
170 for (
int s = 0; s < fRawSignalEvent->GetNumberOfSignals(); s++) {
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++) {
244 SetObservableValue(
"Param_" + to_string(i) +
"_map", param[i]);
245 SetObservableValue(
"ParamErr_" + to_string(i) +
"_map", paramErr[i]);
249 SigmaMean = SigmaMean / (fRawSignalEvent->GetNumberOfSignals());
250 SetObservableValue(
"FitSigmaMean", SigmaMean);
253 Double_t sigmaMeanStdDev = 0;
254 for (
int k = 0; k < fRawSignalEvent->GetNumberOfSignals(); k++) {
255 sigmaMeanStdDev += (Sigma[k] - SigmaMean) * (Sigma[k] - SigmaMean);
257 Double_t SigmaMeanStdDev = TMath::Sqrt(sigmaMeanStdDev / fRawSignalEvent->GetNumberOfSignals());
258 SetObservableValue(
"FitSigmaStdDev", SigmaMeanStdDev);
261 ChiSquareMean = ChiSquareMean / fRawSignalEvent->GetNumberOfSignals();
262 SetObservableValue(
"FitChiSquareMean", ChiSquareMean);
265 RatioSigmaMaxPeakMean = RatioSigmaMaxPeakMean / fRawSignalEvent->GetNumberOfSignals();
266 SetObservableValue(
"FitRatioSigmaMaxPeakMean", RatioSigmaMaxPeakMean);
268 RESTDebug <<
"SigmaMean: " << SigmaMean << RESTendl;
269 RESTDebug <<
"SigmaMeanStdDev: " << SigmaMeanStdDev << RESTendl;
270 RESTDebug <<
"ChiSquareMean: " << ChiSquareMean << RESTendl;
271 RESTDebug <<
"RatioSigmaMaxPeakMean: " << RatioSigmaMaxPeakMean << RESTendl;
272 for (
int k = 0; k < fRawSignalEvent->GetNumberOfSignals(); k++) {
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;
305 return fRawSignalEvent;
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.
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*.