REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorTriggerAnalysisProcess.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 
87 
88 #include "TRestDetectorTriggerAnalysisProcess.h"
89 
90 using namespace std;
91 
93 
98 
112  Initialize();
113  if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
114 }
115 
120 
124 void TRestDetectorTriggerAnalysisProcess::LoadDefaultConfig() { SetTitle("Default config"); }
125 
131  SetSectionName(this->ClassName());
132  SetLibraryVersion(LIBRARY_VERSION);
133 
134  fSignalEvent = new TRestDetectorSignalEvent();
135 }
136 
149 void TRestDetectorTriggerAnalysisProcess::LoadConfig(const string& configFilename, const string& name) {
150  if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
151 }
152 
157  std::vector<string> fObservables;
158  fObservables = TRestEventProcess::ReadObservables();
159 
160  for (unsigned int i = 0; i < fObservables.size(); i++)
161  if (fObservables[i].find("Integral_Eth") != string::npos)
162  fIntegralObservables.push_back(fObservables[i]);
163 
164  for (unsigned int i = 0; i < fIntegralObservables.size(); i++) {
165  Double_t th = atof(fIntegralObservables[i].substr(12, fIntegralObservables[i].length() - 12).c_str());
166  fThreshold.push_back(th);
167  }
168 }
169 
174  TRestDetectorSignalEvent* fInputSignalEvent = (TRestDetectorSignalEvent*)inputEvent;
175  fSignalEvent->SetEventInfo(fInputSignalEvent);
176  for (int sgnl = 0; sgnl < fInputSignalEvent->GetNumberOfSignals(); sgnl++)
177  fSignalEvent->AddSignal(*fInputSignalEvent->GetSignal(sgnl));
178 
179  vector<Double_t> integral;
180  for (unsigned int i = 0; i < fIntegralObservables.size(); i++) integral.push_back(0);
181 
182  Int_t maxT = fSignalEvent->GetMaxTime() / fSampling; // convert to time bin
183  Int_t minT = fSignalEvent->GetMinTime() / fSampling;
184 
185  Int_t triggerStarts = 0;
186 
187  unsigned int counter = 0;
188  unsigned int nObs = fIntegralObservables.size();
189  for (int i = minT - fADCLength / 2; i <= maxT && counter < nObs; i++) {
190  Double_t en = fSignalEvent->GetIntegralWithTime(i * fSampling, (i + fADCLength / 2) * fSampling);
191 
192  for (unsigned int n = 0; n < nObs; n++)
193  if (integral[n] == 0 && en > fThreshold[n]) {
194  // We define the trigger start only for the first threshold definition
195  if (n == 0) triggerStarts = i;
196  integral[n] = fSignalEvent->GetIntegralWithTime(i * fSampling, (i + fADCLength) * fSampling);
197  }
198 
199  // Break condition
200  counter = 0;
201  for (unsigned int n = 0; n < nObs; n++)
202  if (integral[n] > 0) counter++;
203  }
204 
205  for (unsigned int i = 0; i < nObs; i++) {
206  SetObservableValue(fIntegralObservables[i], integral[i]);
207  }
208 
209  Double_t full = fSignalEvent->GetIntegralWithTime(minT * fSampling - 1, maxT * fSampling + 1);
210 
211  SetObservableValue("RawIntegral", full);
212  SetObservableValue("TriggerStarts", triggerStarts);
213 
214  if (fSignalEvent->GetNumberOfSignals() <= 0) return fSignalEvent;
215 
216  return fSignalEvent;
217 }
A process to generate integral observables for signal ADC windows found above the defined energy thre...
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
Process initialization. Observable names are interpreted here.
A base class for any REST event.
Definition: TRestEvent.h:38
void SetEventInfo(TRestEvent *eve)
Definition: TRestEvent.cxx:137