REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawToDetectorSignalProcess.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 *************************************************************************/
22
121#include "TRestRawToDetectorSignalProcess.h"
122using namespace std;
123
125
130
135
141 SetSectionName(this->ClassName());
142 SetLibraryVersion(LIBRARY_VERSION);
143
144 fInputSignalEvent = nullptr;
146}
147
153
154 Int_t rejectedSignal = 0;
155
156 if (fZeroSuppression) {
159 }
160
161 for (int n = 0; n < fInputSignalEvent->GetNumberOfSignals(); n++) {
162 TRestDetectorSignal signal;
163 TRestRawSignal* rawSignal = fInputSignalEvent->GetSignal(n);
164 signal.SetID(rawSignal->GetID());
165
166 if (fZeroSuppression) {
167 ZeroSuppresion(rawSignal, signal);
168 } else {
169 for (int p = 0; p < rawSignal->GetNumberOfPoints(); p++)
170 if (rawSignal->GetData(p) > fThreshold)
171 signal.NewPoint(fTriggerStarts + fSampling * p, fGain * rawSignal->GetData(p));
172 }
173
174 if (signal.GetNumberOfPoints() > 0)
175 fOutputSignalEvent->AddSignal(signal);
176 else
177 rejectedSignal++;
178 }
179
180 SetObservableValue("NSignalsRejected", rejectedSignal);
181
182 if (fOutputSignalEvent->GetNumberOfSignals() <= 0) return nullptr;
183
184 return fOutputSignalEvent;
185}
186
187void TRestRawToDetectorSignalProcess::ZeroSuppresion(TRestRawSignal* rawSignal, TRestDetectorSignal& sgnl) {
190
191 std::vector<Int_t> pOver = rawSignal->GetPointsOverThreshold();
192 for (unsigned int n = 0; n < pOver.size(); n++) {
193 int j = pOver[n];
194 sgnl.NewPoint(fTriggerStarts + fSampling * j, fGain * rawSignal->GetData(j));
195 }
196}
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
Definition: TRestEvent.h:38
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
void SetSectionName(std::string sName)
set the section name, clear the section content
An event container for time rawdata signals with fixed length.
void SetBaseLineRange(TVector2 blRange, std::string option="")
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.
std::vector< Int_t > GetPointsOverThreshold() const
Returns a std::vector containing the indexes of data points over threshold.
void InitializePointsOverThreshold(const TVector2 &thrPar, Int_t nPointsOver, Int_t nPointsFlat=512)
It initializes the fPointsOverThreshold array with the indexes of data points that are found over thr...
Double_t GetData(Int_t n) const
It returns the data value of point n including baseline correction.
Int_t GetNumberOfPoints() const
Returns the actual number of points, or size of the signal.
A process to convert a TRestRawSignalEvent into a TRestDetectorSignalEvent.
Double_t fSignalThreshold
A threshold parameter to accept or reject a pre-identified signal. See process description.
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
Double_t fPointThreshold
Number of sigmas over baseline fluctuation to accept a point is over threshold.
Double_t fTriggerStarts
The corresponding time of the first bin inside the raw signal.
Int_t fNPointsOverThreshold
Number of consecutive points over threshold required to accept a signal.
Double_t fGain
A factor the data values will be multiplied by at the output signal.
TVector2 fBaseLineRange
The ADC range used for baseline offset definition.
TRestRawSignalEvent * fInputSignalEvent
A pointer to the specific TRestRawSignalEvent input.
TRestDetectorSignalEvent * fOutputSignalEvent
A pointer to the specific TRestDetectorSignalEvent input.
Double_t fThreshold
A factor the data values will be multiplied by at the output signal.
TVector2 fIntegralRange
The ADC range used for integral definition and signal identification.
Double_t fSampling
The sampling time used to transform the binned data to time information.