REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawBaseLineCorrectionProcess.cxx
1 /*************************************************************************
2  * This file is part of the REST software framework. *
3  * *
4  * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5  * For more information see http://gifna.unizar.es/trex *
6  * *
7  * REST is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * REST is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have a copy of the GNU General Public License along with *
18  * REST in $REST_PATH/LICENSE. *
19  * If not, see http://www.gnu.org/licenses/. *
20  * For the list of contributors see $REST_PATH/CREDITS. *
21  *************************************************************************/
69 
70 #include "TRestRawBaseLineCorrectionProcess.h"
71 
73 
74 TRestRawBaseLineCorrectionProcess::TRestRawBaseLineCorrectionProcess() { Initialize(); }
75 
76 TRestRawBaseLineCorrectionProcess::~TRestRawBaseLineCorrectionProcess() {
77  delete fInputEvent;
78  delete fOutputEvent;
79 }
80 
82  SetSectionName(this->ClassName());
83  fInputEvent = NULL;
84  fOutputEvent = new TRestRawSignalEvent();
85 }
86 
88  if (fSignalsRange.X() != -1 && fSignalsRange.Y() != -1) fRangeEnabled = true;
89 }
90 
92  fInputEvent = (TRestRawSignalEvent*)evInput;
93 
94  for (int s = 0; s < fInputEvent->GetNumberOfSignals(); s++) {
95  TRestRawSignal* sgnl = fInputEvent->GetSignal(s);
96 
97  if (fRangeEnabled && (sgnl->GetID() < fSignalsRange.X() || sgnl->GetID() > fSignalsRange.Y())) {
98  fOutputEvent->AddSignal(*sgnl);
99  continue;
100  }
101 
102  TRestRawSignal sgnl2;
103  sgnl->GetBaseLineCorrected(&sgnl2, fSmoothingWindow);
104  sgnl2.SetID(sgnl->GetID());
105  fOutputEvent->AddSignal(sgnl2);
106  }
107 
108  return fOutputEvent;
109 }
110 
A base class for any REST event.
Definition: TRestEvent.h:38
void SetSectionName(std::string sName)
set the section name, clear the section content
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
TRestEvent * ProcessEvent(TRestEvent *eventInput) override
Process one event.
void EndProcess() override
To be executed at the end of the run (outside event loop)
TVector2 fSignalsRange
It defines the signals id range where analysis is applied.
void Initialize() override
Making default settings.
Int_t fSmoothingWindow
Time window width in bins for the moving average filter for baseline correction.
Bool_t fRangeEnabled
Just a flag to quickly determine if we have to apply the range filter.
An event container for time rawdata signals with fixed length.
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.
void SetID(Int_t sID)
It sets the id number of the signal.
void GetBaseLineCorrected(TRestRawSignal *smoothedSignal, Int_t averagingPoints)
It applies the moving average filter (GetSignalSmoothed) to the signal, which is then subtracted from...