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 <TRestDetectorSignalEvent.h>
27#include <TRestEventProcess.h>
28#include <TRestRawSignalEvent.h>
29
32 private:
35
38
39 void Initialize() override;
40
41 protected:
43 Double_t fSampling = 1.0; // ns
44
46 Int_t fNPoints = 512;
47
49 TString fTriggerMode = "firstDeposit";
50
52 Int_t fTriggerDelay = 100;
53
56
59 Double_t fCalibrationGain = 100.0;
60 Double_t fCalibrationOffset = 0.0; // adc units
61
63 Double_t fIntegralThreshold = 1229.0;
64
66 TVector2 fCalibrationEnergy = TVector2(0.0, 0.0);
68 TVector2 fCalibrationRange = TVector2(0.0, 0.0);
72
75 Double_t fShapingTime = 0.0; // us
76
77 Double_t fTimeStart;
78 Double_t fTimeEnd;
79
80 public:
81 inline Double_t GetSampling() const { return fSampling; }
82 inline void SetSampling(Double_t sampling) { fSampling = sampling; }
83
84 inline Int_t GetNPoints() const { return fNPoints; }
85 inline void SetNPoints(Int_t nPoints) { fNPoints = nPoints; }
86
87 inline TString GetTriggerMode() const { return fTriggerMode; }
88 inline void SetTriggerMode(const TString& triggerMode) { fTriggerMode = triggerMode; }
89
90 inline Int_t GetTriggerDelay() const { return fTriggerDelay; }
91 inline void SetTriggerDelay(Int_t triggerDelay) { fTriggerDelay = triggerDelay; }
92
93 inline Double_t GetGain() const { return fCalibrationGain; }
94 inline void SetGain(Double_t gain) { fCalibrationGain = gain; }
95
96 inline Double_t GetCalibrationOffset() const { return fCalibrationOffset; }
97 inline void SetCalibrationOffset(Double_t offset) { fCalibrationOffset = offset; }
98
99 inline Double_t GetIntegralThreshold() const { return fIntegralThreshold; }
100 inline void SetIntegralThreshold(Double_t integralThreshold) { fIntegralThreshold = integralThreshold; }
101
102 inline Double_t GetShapingTime() const { return fShapingTime; }
103 inline void SetShapingTime(Double_t shapingTime) { fShapingTime = shapingTime; }
104
105 inline bool IsShapingEnabled() const { return fShapingTime > 0; }
106
107 inline bool IsLinearCalibration() const {
108 // Will return true if two points have been given for calibration
109 return (fCalibrationEnergy.Mod() != 0 && fCalibrationRange.Mod() != 0);
110 }
111
112 inline TVector2 GetCalibrationEnergy() const { return fCalibrationEnergy; }
113 inline void SetCalibrationEnergy(TVector2 calibrationEnergy) { fCalibrationEnergy = calibrationEnergy; }
114
115 inline TVector2 GetCalibrationRange() const { return fCalibrationRange; }
116 inline void SetCalibrationRange(TVector2 calibrationRange) { fCalibrationRange = calibrationRange; }
117
118 any GetInputEvent() const override { return fInputSignalEvent; }
119 any GetOutputEvent() const override { return fOutputRawSignalEvent; }
120
121 void InitProcess() override;
122
123 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
124
125 void LoadConfig(const std::string& configFilename, const std::string& name = "");
126
128 void PrintMetadata() override {
130
131 RESTMetadata << "Sampling time : " << fSampling << " us" << RESTendl;
132 RESTMetadata << "Points per channel : " << fNPoints << RESTendl;
133 RESTMetadata << "Trigger mode : " << fTriggerMode << RESTendl;
134 RESTMetadata << "Trigger delay : " << fTriggerDelay << " time units" << RESTendl;
135
136 if (IsLinearCalibration()) {
137 RESTMetadata << "Calibration energy : (" << fCalibrationEnergy.X() << ", "
138 << fCalibrationEnergy.Y() << ") keV" << RESTendl;
139 RESTMetadata << "Calibration range : (" << fCalibrationRange.X() << ", " << fCalibrationRange.Y()
140 << ")" << RESTendl;
141 }
142 RESTMetadata << "ADC Gain : " << fCalibrationGain << RESTendl;
143 RESTMetadata << "ADC Offset : " << fCalibrationOffset << RESTendl;
144
145 if (IsShapingEnabled()) {
146 RESTMetadata << "Shaping time : " << fShapingTime << " us" << RESTendl;
147 }
148
149 EndPrintProcess();
150 }
151
154
156 const char* GetProcessName() const override { return "signalToRawSignal"; }
157
158 // Constructor
160 TRestDetectorSignalToRawSignalProcess(const char* configFilename);
161
162 // Destructor
164
165 ClassDefOverride(TRestDetectorSignalToRawSignalProcess, 3);
166};
167#endif
A process to convert a TRestDetectorSignalEvent into a TRestRawSignalEvent.
any GetInputEvent() const override
Get pointer to input event. Must be implemented in the derived class.
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
Some actions taken before start the event data processing.
TRestRawSignalEvent * fOutputRawSignalEvent
A pointer to the specific TRestRawSignalEvent input.
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.
TString fTriggerMode
It is used to define the way the time start will be fixed.
Int_t fNPoints
The number of points of the resulting output signal.
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.
any GetOutputEvent() const override
Get pointer to output 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.
A base class for any REST event process.
void BeginPrintProcess()
[name, cut range]
A base class for any REST event.
Definition: TRestEvent.h:38
endl_t RESTendl
Termination flag object for TRestStringOutput.
An event container for time rawdata signals with fixed length.