2323#ifndef RestCore_TRestDetectorSignalToRawSignalProcess
2424#define RestCore_TRestDetectorSignalToRawSignalProcess
2525
26+ #include < TRestDetectorReadout.h>
2627#include < TRestDetectorSignalEvent.h>
2728#include < TRestEventProcess.h>
2829#include < TRestRawSignalEvent.h>
@@ -36,8 +37,12 @@ class TRestDetectorSignalToRawSignalProcess : public TRestEventProcess {
3637 // / A pointer to the specific TRestRawSignalEvent input
3738 TRestRawSignalEvent* fOutputRawSignalEvent ; // !
3839
40+ TRestDetectorReadout* fReadout = nullptr ; // !
41+
3942 void Initialize () override ;
4043
44+ void InitFromConfigFile () override ;
45+
4146 protected:
4247 // / The sampling time from the binned raw output signal
4348 Double_t fSampling = 1.0 ; // ns
@@ -46,14 +51,17 @@ class TRestDetectorSignalToRawSignalProcess : public TRestEventProcess {
4651 Int_t fNPoints = 512 ;
4752
4853 // / It is used to define the way the time start will be fixed
49- TString fTriggerMode = " firstDeposit" ;
54+ std::string fTriggerMode = " firstDeposit" ;
5055
5156 // / The number of time bins the time start is delayed in the resulting output signal.
5257 Int_t fTriggerDelay = 100 ;
5358
5459 // / The starting time for the "fixed" trigger mode (can be offset by the trigger delay)
5560 Int_t fTriggerFixedStartTime = 0 ;
5661
62+ // / The name of the observable used to define the trigger mode (i.e. g4Ana_sensitiveVolumeFirstHitTime)
63+ std::string fTriggerModeObservableName ;
64+
5765 // / fCalibrationGain and fCalibrationOffset define the linear calibration.
5866 // / output = input * fCalibrationGain + calibrationOffset
5967 Double_t fCalibrationGain = 100.0 ;
@@ -74,80 +82,53 @@ class TRestDetectorSignalToRawSignalProcess : public TRestEventProcess {
7482 // / avoid artifacts in the signal (e.g. signals not getting cut when they should)
7583 Double_t fShapingTime = 0.0 ; // us
7684
77- Double_t fTimeStart ; // !
78- Double_t fTimeEnd ; // !
79-
8085 public:
8186 inline Double_t GetSampling () const { return fSampling ; }
82- inline void SetSampling (Double_t sampling) { fSampling = sampling; }
8387
8488 inline Int_t GetNPoints () const { return fNPoints ; }
85- inline void SetNPoints (Int_t nPoints) { fNPoints = nPoints; }
8689
87- inline TString GetTriggerMode () const { return fTriggerMode ; }
88- inline void SetTriggerMode (const TString& triggerMode) { fTriggerMode = triggerMode; }
90+ inline std::string GetTriggerMode () const { return fTriggerMode ; }
8991
9092 inline Int_t GetTriggerDelay () const { return fTriggerDelay ; }
91- inline void SetTriggerDelay (Int_t triggerDelay) { fTriggerDelay = triggerDelay; }
9293
9394 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; }
9895
9996 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 ; }
10697
10798 inline bool IsLinearCalibration () const {
10899 // Will return true if two points have been given for calibration
109100 return (fCalibrationEnergy .Mod () != 0 && fCalibrationRange .Mod () != 0 );
110101 }
111102
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-
118103 RESTValue GetInputEvent () const override { return fInputSignalEvent ; }
104+
119105 RESTValue GetOutputEvent () const override { return fOutputRawSignalEvent ; }
120106
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+
121124 void InitProcess () override ;
122125
123126 TRestEvent* ProcessEvent (TRestEvent* inputEvent) override ;
124127
125128 void LoadConfig (const std::string& configFilename, const std::string& name = " " );
126129
127130 // / It prints out the process parameters stored in the metadata structure
128- void PrintMetadata () override {
129- BeginPrintProcess ();
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- }
131+ void PrintMetadata () override ;
151132
152133 // / Returns a new instance of this class
153134 TRestEventProcess* Maker () { return new TRestDetectorSignalToRawSignalProcess; }
@@ -157,11 +138,17 @@ class TRestDetectorSignalToRawSignalProcess : public TRestEventProcess {
157138
158139 // Constructor
159140 TRestDetectorSignalToRawSignalProcess ();
141+
160142 TRestDetectorSignalToRawSignalProcess (const char * configFilename);
161143
162144 // Destructor
163145 ~TRestDetectorSignalToRawSignalProcess ();
164146
165- ClassDefOverride (TRestDetectorSignalToRawSignalProcess, 3 );
147+ private:
148+ std::map<std::string, Parameters> fParametersMap ;
149+ std::set<std::string> fReadoutTypes ;
150+
151+ ClassDefOverride (TRestDetectorSignalToRawSignalProcess, 6 );
166152};
153+
167154#endif
0 commit comments