REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawFindResponseSignalProcess.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
67#include "TRestRawFindResponseSignalProcess.h"
68
69using namespace std;
70
71#include <TFile.h>
72
74
79
93 Initialize();
94
95 if (LoadConfigFromFile(configFilename) == -1) LoadDefaultConfig();
96
98 // TRestRawFindResponseSignalProcess default constructor
99}
100
105
110 SetName("findResponseSignal-Default");
111 SetTitle("Default config");
112}
113
119 SetSectionName(this->ClassName());
120 SetLibraryVersion(LIBRARY_VERSION);
121
122 fInputSignalEvent = nullptr;
123 fOutputSignalEvent = new TRestRawSignalEvent();
124}
125
138void TRestRawFindResponseSignalProcess::LoadConfig(const string& configFilename, const string& name) {
139 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
140}
141
147
152 fInputSignalEvent = (TRestRawSignalEvent*)inputEvent;
153
154 // We accept signals that are inside a given condition.
155 // TODO: Now it is also possible to use ApplyCut and <cut definitions?
156 if (fInputSignalEvent->GetNumberOfSignals() <= 0) return nullptr;
157 if (fInputSignalEvent->GetNumberOfSignals() > 8) return nullptr;
158
159 Int_t dominantSignal = -1;
160 Double_t maxPeak = 0;
161 // Double_t maxTime = 0;
162 for (int n = 0; n < fInputSignalEvent->GetNumberOfSignals(); n++) {
163 if (fInputSignalEvent->GetSignal(n)->GetMaxPeakValue() > maxPeak) {
164 maxPeak = fInputSignalEvent->GetSignal(n)->GetMaxPeakValue();
165 // maxTime = fInputSignalEvent->GetSignal(n)->GetMaxPeakBin();
166 dominantSignal = n;
167 }
168 }
169
170 if (maxPeak < 400 || maxPeak > 600) return nullptr;
171
172 TRestRawSignal* sgnl = fInputSignalEvent->GetSignal(dominantSignal);
173 sgnl->Scale(1000. / maxPeak);
174
175 fOutputSignalEvent->AddSignal(*sgnl);
176
177 return fOutputSignalEvent;
178}
179
A base class for any REST event.
Definition: TRestEvent.h:38
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
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
A process to find a representative signal to generate a response signal.
void InitProcess() override
Process initialization. Function to be executed once at the beginning of process (before starting the...
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void EndProcess() override
End of procesing. Function to be executed once at the end of the process. It gets access to all the a...
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void Initialize() override
Function to initialize input/output event members and define the section name.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
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.
Double_t GetMaxPeakValue()
It returns the amplitude of the signal maximum, baseline will be corrected if CalculateBaseLine was c...
void Scale(Double_t value)
This method scales the signal by a given value.