REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorSignalChannelActivityProcess.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
79#include "TRestDetectorSignalChannelActivityProcess.h"
80
81using namespace std;
82
84
89
103 const char* configFilename) {
104 Initialize();
105
106 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
107}
108
113 delete fSignalEvent;
114}
115
120
126 SetSectionName(this->ClassName());
127 SetLibraryVersion(LIBRARY_VERSION);
128
130}
131
144void TRestDetectorSignalChannelActivityProcess::LoadConfig(const string& configFilename, const string& name) {
145 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
146}
147
156 fReadout = GetMetadata<TRestDetectorReadout>();
157
158 RESTDebug << "TRestDetectorSignalChannelActivityProcess::InitProcess. Readout pointer : " << fReadout
159 << RESTendl;
162
163 if (!fReadOnly) {
164 fDaqChannelsHisto = new TH1D("daqChannelActivity", "daqChannelActivity", fDaqHistogramChannels,
166 if (fReadout) {
168 new TH1D("rChannelActivity", "readoutChannelActivity", fReadoutHistogramChannels,
171 new TH1D("rChannelActivity_1", "readoutChannelActivity", fReadoutHistogramChannels,
174 new TH1D("rChannelActivity_1H", "readoutChannelActivity", fReadoutHistogramChannels,
177 new TH1D("rChannelActivity_2", "readoutChannelActivity", fReadoutHistogramChannels,
180 new TH1D("rChannelActivity_2H", "readoutChannelActivity", fReadoutHistogramChannels,
183 new TH1D("rChannelActivity_3", "readoutChannelActivity", fReadoutHistogramChannels,
186 new TH1D("rChannelActivity_3H", "readoutChannelActivity", fReadoutHistogramChannels,
189 new TH1D("rChannelActivity_M", "readoutChannelActivity", fReadoutHistogramChannels,
192 new TH1D("rChannelActivity_MH", "readoutChannelActivity", fReadoutHistogramChannels,
194 }
195 }
196}
197
202 TString obsName;
203
204 TRestDetectorSignalEvent* fInputSignalEvent = (TRestDetectorSignalEvent*)inputEvent;
205
207
208 fSignalEvent->SetID(fInputSignalEvent->GetID());
209 fSignalEvent->SetSubID(fInputSignalEvent->GetSubID());
210 fSignalEvent->SetTimeStamp(fInputSignalEvent->GetTimeStamp());
211 fSignalEvent->SetSubEventTag(fInputSignalEvent->GetSubEventTag());
212
213 Int_t N = fInputSignalEvent->GetNumberOfSignals();
214 for (int sgnl = 0; sgnl < N; sgnl++) fSignalEvent->AddSignal(*fInputSignalEvent->GetSignal(sgnl));
216
217 Int_t Nlow = 0;
218 Int_t Nhigh = 0;
219 for (int s = 0; s < fSignalEvent->GetNumberOfSignals(); s++) {
220 TRestDetectorSignal* sgnl = fSignalEvent->GetSignal(s);
221 if (sgnl->GetMaxValue() > fHighThreshold) Nhigh++;
222 if (sgnl->GetMaxValue() > fLowThreshold) Nlow++;
223 }
224
225 for (int s = 0; s < fSignalEvent->GetNumberOfSignals(); s++) {
226 TRestDetectorSignal* sgnl = fSignalEvent->GetSignal(s);
227 // Adding signal to the channel activity histogram
228 if (!fReadOnly && fReadout) {
229 Int_t signalID = fSignalEvent->GetSignal(s)->GetID();
230
231 Int_t p, m, readoutChannel;
232 fReadout->GetPlaneModuleChannel(signalID, p, m, readoutChannel);
233
234 fReadoutChannelsHisto->Fill(readoutChannel);
235
236 if (sgnl->GetMaxValue() > fLowThreshold) {
237 if (Nlow == 1) fReadoutChannelsHisto_OneSignal->Fill(readoutChannel);
238 if (Nlow == 2) fReadoutChannelsHisto_TwoSignals->Fill(readoutChannel);
239 if (Nlow == 3) fReadoutChannelsHisto_ThreeSignals->Fill(readoutChannel);
240 if (Nlow > 3 && Nlow < 10) fReadoutChannelsHisto_MultiSignals->Fill(readoutChannel);
241 }
242
243 if (sgnl->GetMaxValue() > fHighThreshold) {
244 if (Nhigh == 1) fReadoutChannelsHisto_OneSignal_High->Fill(readoutChannel);
245 if (Nhigh == 2) fReadoutChannelsHisto_TwoSignals_High->Fill(readoutChannel);
246 if (Nhigh == 3) fReadoutChannelsHisto_ThreeSignals_High->Fill(readoutChannel);
247 if (Nhigh > 3 && Nhigh < 10) fReadoutChannelsHisto_MultiSignals_High->Fill(readoutChannel);
248 }
249 }
250
251 if (!fReadOnly) {
252 Int_t daqChannel = fSignalEvent->GetSignal(s)->GetID();
253 fDaqChannelsHisto->Fill(daqChannel);
254 }
255 }
256
258 fAnalysisTree->PrintObservables();
259
260 return fSignalEvent;
261}
262
269 if (!fReadOnly) {
270 fDaqChannelsHisto->Write();
271 if (fReadout) {
272 fReadoutChannelsHisto->Write();
273
278
283 }
284 }
285}
286
292 fLowThreshold = StringToDouble(GetParameter("lowThreshold", "25"));
293 fHighThreshold = StringToDouble(GetParameter("highThreshold", "50"));
294
295 fDaqHistogramChannels = StringToInteger(GetParameter("daqChannels", "300"));
296 fDaqStartChannel = StringToInteger(GetParameter("daqStartCh", "4320"));
297 fDaqEndChannel = StringToInteger(GetParameter("daqEndCh", "4620"));
298 fReadoutHistogramChannels = StringToInteger(GetParameter("readoutChannels", "128"));
299 fReadoutStartChannel = StringToInteger(GetParameter("readoutStartCh", "0"));
300 fReadoutEndChannel = StringToInteger(GetParameter("readoutEndCh", "128"));
301}
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
A pure analysis process to generate histograms with detector channels activity.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
TH1D * fReadoutChannelsHisto_TwoSignals
The readout channels histogram built with 2-signal events (low threshold)
TRestDetectorReadout * fReadout
A pointer to the readout metadata information accessible to TRestRun.
TRestDetectorSignalEvent * fSignalEvent
A pointer to the specific TRestDetectorSignalEvent input.
Int_t fReadoutHistogramChannels
The number of bins at the readout channels histogram.
TH1D * fReadoutChannelsHisto_MultiSignals
The readout channels histogram built more than 3-signal events (low threshold)
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.
TH1D * fReadoutChannelsHisto_TwoSignals_High
The readout channels histogram built with 2-signal events (high threshold)
Int_t fReadoutEndChannel
The last channel at the readout channels histogram.
void Initialize() override
Function to initialize input/output event members and define the section name.
TH1D * fReadoutChannelsHisto_MultiSignals_High
The readout channels histogram built more than 3-signal events (high threshold)
void InitFromConfigFile() override
Function to read input parameters from the RML TRestDetectorSignalChannelActivityProcess metadata sec...
Int_t fDaqHistogramChannels
The number of bins at the daq channels histogram.
Int_t fReadoutStartChannel
The first channel at the readout channels histogram.
TH1D * fReadoutChannelsHisto_OneSignal_High
The readout channels histogram built with 1-signal events (high threshold)
void EndProcess() override
Function to include required actions after all events have been processed. In this process it will ta...
Int_t fDaqStartChannel
The first channel at the daq channels histogram.
TH1D * fReadoutChannelsHisto_OneSignal
The readout channels histogram built with 1-signal events (low threshold)
Double_t fHighThreshold
The value of the higher signal threshold to add it to the histogram.
Double_t fLowThreshold
The value of the lower signal threshold to add it to the histogram.
TH1D * fReadoutChannelsHisto_ThreeSignals_High
The readout channels histogram built with 3-signal events (high threshold)
void InitProcess() override
Process initialization. The ROOT TH1 histograms are created here using the limits defined in the proc...
TH1D * fReadoutChannelsHisto_ThreeSignals
The readout channels histogram built with 3-signal events (low threshold)
Int_t fDaqEndChannel
The last channel at the daq channels histogram.
TRestAnalysisTree * fAnalysisTree
bool fReadOnly
not used, keep for compatibility
A base class for any REST event.
Definition: TRestEvent.h:38
endl_t RESTendl
Termination flag object for TRestStringOutput.
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.
TRestStringOutput::REST_Verbose_Level GetVerboseLevel()
returns the verboselevel in type of REST_Verbose_Level enumerator
void SetSectionName(std::string sName)
set the section name, clear the section content
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.
@ REST_Info
+show most of the information for each steps
@ REST_Debug
+show the defined debug messages
Double_t StringToDouble(std::string in)
Gets a double from a string.
Int_t StringToInteger(std::string in)
Gets an integer from a string.