REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
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
74 TVector2 fCalibrationEnergy = TVector2(0.0, 0.0);
76 TVector2 fCalibrationRange = TVector2(0.0, 0.0);
80
83 Double_t fShapingTime = 0.0; // us
84
85 public:
86 inline Double_t GetSampling() const { return fSampling; }
87
88 inline Int_t GetNPoints() const { return fNPoints; }
89
90 inline std::string GetTriggerMode() const { return fTriggerMode; }
91
92 inline Int_t GetTriggerDelay() const { return fTriggerDelay; }
93
94 inline Double_t GetGain() const { return fCalibrationGain; }
95
96 inline Double_t GetIntegralThreshold() const { return fIntegralThreshold; }
97
98 inline bool IsLinearCalibration() const {
99 // Will return true if two points have been given for calibration
100 return (fCalibrationEnergy.Mod() != 0 && fCalibrationRange.Mod() != 0);
101 }
102
103 RESTValue GetInputEvent() const override { return fInputSignalEvent; }
104
105 RESTValue GetOutputEvent() const override { return fOutputRawSignalEvent; }
106
107 Double_t GetEnergyFromADC(Double_t adc, const std::string& type = "") const;
108
109 Double_t GetADCFromEnergy(Double_t energy, const std::string& type = "") const;
110
111 Double_t GetTimeFromBin(Double_t bin, const std::string& type = "") const;
112
113 Double_t GetBinFromTime(Double_t time, const std::string& type = "") const;
114
115 struct Parameters {
116 Double_t sampling = 1.0;
117 Double_t shapingTime = 0.0;
118 Double_t calibrationGain = 100;
119 Double_t calibrationOffset = 0;
120 TVector2 calibrationEnergy = {0, 0};
121 TVector2 calibrationRange = {0, 0};
122 };
123
124 void InitProcess() override;
125
126 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
127
128 void LoadConfig(const std::string& configFilename, const std::string& name = "");
129
131 void PrintMetadata() override;
132
135
137 const char* GetProcessName() const override { return "signalToRawSignal"; }
138
139 // Constructor
141
142 TRestDetectorSignalToRawSignalProcess(const char* configFilename);
143
144 // Destructor
146
147 private:
148 std::map<std::string, Parameters> fParametersMap;
149 std::set<std::string> fReadoutTypes;
150
151 ClassDefOverride(TRestDetectorSignalToRawSignalProcess, 6);
152};
153
154#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.