REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawSignalAddNoiseProcess.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
71
72#include "TRestRawSignalAddNoiseProcess.h"
73
74#include <TFile.h>
75
76using namespace std;
77
79
84
98 Initialize();
99 if (LoadConfigFromFile(configFilename) == -1) {
101 }
102}
103
108 delete fOutputSignalEvent;
109 // TRestRawSignalAddNoiseProcess destructor
110}
111
116 SetName("addSignalNoiseProcess-Default");
117 SetTitle("Default config");
118}
119
125 SetSectionName(this->ClassName());
126 SetLibraryVersion(LIBRARY_VERSION);
127
128 fInputSignalEvent = nullptr;
130}
131
144void TRestRawSignalAddNoiseProcess::LoadConfig(const string& configFilename, const string& name) {
145 if (LoadConfigFromFile(configFilename, name) == -1) {
147 }
148}
149
155
156 if (fInputSignalEvent->GetNumberOfSignals() <= 0) {
157 return nullptr;
158 }
159
160 for (int n = 0; n < fInputSignalEvent->GetNumberOfSignals(); n++) {
161 TRestRawSignal noiseSignal;
162
163 // Assign ID and add noise
164 fInputSignalEvent->GetSignal(n)->GetWhiteNoiseSignal(&noiseSignal, fNoiseLevel);
165 noiseSignal.SetSignalID(fInputSignalEvent->GetSignal(n)->GetSignalID());
166
167 fOutputSignalEvent->AddSignal(noiseSignal);
168 }
169
170 return fOutputSignalEvent;
171}
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 add/emulate electronic noise into a TRestRawSignalEvent.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
TRestRawSignalEvent * fOutputSignalEvent
A pointer to the output signal event.
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestRawSignalEvent * fInputSignalEvent
A pointer to the input signal event.
Double_t fNoiseLevel
The noise level to be added to the signal. It is 1-gaussian sigma.
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.
void SetSignalID(Int_t sID)
It sets the id number of the signal.
void GetWhiteNoiseSignal(TRestRawSignal *noiseSignal, Double_t noiseLevel=1.)
It calculates an arbitrary Gaussian noise placing it at the signal pointer given by argument....
Int_t GetSignalID() const
Returns the value of signal ID.