REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorSignalToRawSignalProcess.h
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
23#ifndef RestCore_TRestDetectorSignalToRawSignalProcess
24#define RestCore_TRestDetectorSignalToRawSignalProcess
25
26#include <TRestDetectorReadout.h>
27#include <TRestDetectorSignalEvent.h>
28#include <TRestEventProcess.h>
29#include <TRestRawSignalEvent.h>
30
33 private:
36
39
40 TRestDetectorReadout* fReadout = nullptr;
41
42 void Initialize() override;
43
44 void InitFromConfigFile() override;
45
46 protected:
48 Double_t fSampling = 1.0; // ns
49
51 Int_t fNPoints = 512;
52
54 std::string fTriggerMode = "firstDeposit";
55
57 Int_t fTriggerDelay = 100;
58
61
64
67 Double_t fCalibrationGain = 100.0;
68 Double_t fCalibrationOffset = 0.0; // adc units
69
71 Double_t fIntegralThreshold = 1229.0;
72 Double_t fIntegralThresholdTPCkeV = 0.1;
73
75 TVector2 fCalibrationEnergy = TVector2(0.0, 0.0);
77 TVector2 fCalibrationRange = TVector2(0.0, 0.0);
81
84 Double_t fShapingTime = 0.0; // us
85
86 // Noise level
87 Double_t fNoiseLevel = 0.0;
88
89 public:
90 inline Double_t GetSampling() const { return fSampling; }
91
92 inline Int_t GetNPoints() const { return fNPoints; }
93
94 inline std::string GetTriggerMode() const { return fTriggerMode; }
95
96 inline Int_t GetTriggerDelay() const { return fTriggerDelay; }
97
98 inline Double_t GetGain() const { return fCalibrationGain; }
99
100 inline Double_t GetIntegralThreshold() const { return fIntegralThreshold; }
101
102 inline bool IsLinearCalibration() const {
103 // Will return true if two points have been given for calibration
104 return (fCalibrationEnergy.Mod() != 0 && fCalibrationRange.Mod() != 0);
105 }
106
107 RESTValue GetInputEvent() const override { return fInputSignalEvent; }
108
109 RESTValue GetOutputEvent() const override { return fOutputRawSignalEvent; }
110
111 Double_t GetEnergyFromADC(Double_t adc, const std::string& type = "") const;
112
113 Double_t GetADCFromEnergy(Double_t energy, const std::string& type = "") const;
114
115 Double_t GetTimeFromBin(Double_t bin, const std::string& type = "") const;
116
117 Double_t GetBinFromTime(Double_t time, const std::string& type = "") const;
118
119 struct Parameters {
120 Double_t sampling = 1.0;
121 Double_t shapingTime = 0.0;
122 Double_t calibrationGain = 100;
123 Double_t calibrationOffset = 0;
124 Double_t noiseLevel = 0.0;
125 TVector2 calibrationEnergy = {0, 0};
126 TVector2 calibrationRange = {0, 0};
127 };
128
129 void InitProcess() override;
130
131 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
132
133 void LoadConfig(const std::string& configFilename, const std::string& name = "");
134
136 void PrintMetadata() override;
137
140
142 const char* GetProcessName() const override { return "signalToRawSignal"; }
143
145
146 explicit TRestDetectorSignalToRawSignalProcess(const char* configFilename);
147
149
150 private:
151 std::map<std::string, Parameters> fParametersMap;
152 std::set<std::string> fReadoutTypes;
153
154 ClassDefOverride(TRestDetectorSignalToRawSignalProcess, 8);
155};
156
157#endif
A metadata class to generate/store a readout description.
A process to convert a TRestDetectorSignalEvent into a TRestRawSignalEvent.
TVector2 fCalibrationEnergy
two distinct energy values used for calibration
TRestDetectorSignalEvent * fInputSignalEvent
A pointer to the specific TRestDetectorSignalEvent input.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
Double_t fSampling
The sampling time from the binned raw output signal.
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
TRestRawSignalEvent * fOutputRawSignalEvent
A pointer to the specific TRestRawSignalEvent input.
std::string fTriggerMode
It is used to define the way the time start will be fixed.
void PrintMetadata() override
It prints out the process parameters stored in the metadata structure.
TVector2 fCalibrationRange
position in the range corresponding to the energy in 'fCalibrationEnergy'. Values between 0 and 1
Double_t fIntegralThreshold
This parameter is used by integralWindow trigger mode to define the acquisition window.
TRestEventProcess * Maker()
Returns a new instance of this class.
Int_t fNPoints
The number of points of the resulting output signal.
std::string fTriggerModeObservableName
The name of the observable used to define the trigger mode (i.e. g4Ana_sensitiveVolumeFirstHitTime)
RESTValue GetOutputEvent() const override
Get pointer to output event. Must be implemented in the derived class.
Int_t fTriggerFixedStartTime
The starting time for the "fixed" trigger mode (can be offset by the trigger delay)
const char * GetProcessName() const override
Returns the name of this process.
Int_t fTriggerDelay
The number of time bins the time start is delayed in the resulting output signal.
RESTValue GetInputEvent() const override
Get pointer to input event. Must be implemented in the derived class.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
void InitFromConfigFile() override
Function reading input parameters from the RML TRestDetectorSignalToRawSignalProcess metadata section...
A base class for any REST event process.
A base class for any REST event.
Definition: TRestEvent.h:38
An event container for time rawdata signals with fixed length.