Skip to content

Commit ba16bf1

Browse files
authored
Merge pull request #37 from rest-for-physics/lobis-working-on-veto-readout
Update TRestDetectorSignalToRawSignalProcess
2 parents cb25071 + a992738 commit ba16bf1

9 files changed

+659
-135
lines changed

inc/TRestDetectorSignalToRawSignalProcess.h

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
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

inc/TRestGeant4ToDetectorHitsProcess.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
#define RestCore_TRestGeant4ToDetectorHitsProcess
2525

2626
#include <TRestDetectorHitsEvent.h>
27+
#include <TRestEventProcess.h>
2728
#include <TRestGeant4Event.h>
2829
#include <TRestGeant4Metadata.h>
2930

30-
#include "TRestEventProcess.h"
31+
#include <string>
32+
#include <vector>
3133

3234
/// A process to transform a *TRestGeant4Event* into a *TRestDetectorHitsEvent*.
3335
class TRestGeant4ToDetectorHitsProcess : public TRestEventProcess {
@@ -47,6 +49,8 @@ class TRestGeant4ToDetectorHitsProcess : public TRestEventProcess {
4749
/// The geometry volume names to be transferred to TRestDetectorHitsEvent
4850
std::vector<TString> fVolumeSelection;
4951

52+
std::map<std::string, REST_HitType> fHitTypes; //!
53+
5054
void InitFromConfigFile() override;
5155

5256
void Initialize() override;

inc/TRestRawReadoutAnalysisProcess.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#define RestCore_TRestRawReadoutAnalysisProcess
1414

1515
#include <TH1D.h>
16-
17-
// #include <TCanvas.h>
18-
1916
#include <TRestDetectorGas.h>
2017
#include <TRestDetectorHitsEvent.h>
2118
#include <TRestDetectorReadout.h>
@@ -44,7 +41,6 @@ class TRestRawReadoutAnalysisProcess : public TRestEventProcess {
4441
std::map<int, TH1D*> fModuleActivityY; //! [MM id, channel activity]
4542
std::map<int, TH2D*> fModuleBSLSigmaX; //! [MM id, channel activity]
4643
std::map<int, TH2D*> fModuleBSLSigmaY; //! [MM id, channel activity]
47-
//
4844

4945
public:
5046
RESTValue GetInputEvent() const override { return fSignalEvent; }
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Created by lobis on 24-Aug-23.
3+
//
4+
5+
#ifndef REST_TRESTRAWREADOUTMETADATAPROCESS_H
6+
#define REST_TRESTRAWREADOUTMETADATAPROCESS_H
7+
8+
#include <TRestDetectorReadout.h>
9+
#include <TRestEventProcess.h>
10+
#include <TRestRawReadoutMetadata.h>
11+
#include <TRestRawSignalEvent.h>
12+
13+
#include <atomic>
14+
15+
class TRestRawReadoutMetadataProcess : public TRestEventProcess {
16+
private:
17+
TRestRawSignalEvent* fSignalEvent = nullptr; //!
18+
TRestDetectorReadout* fReadout; //!
19+
private:
20+
static std::mutex fMetadataMutex; //!
21+
22+
public:
23+
RESTValue GetInputEvent() const override { return fSignalEvent; }
24+
RESTValue GetOutputEvent() const override { return fSignalEvent; }
25+
26+
void InitProcess() override;
27+
TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
28+
void EndProcess() override {}
29+
30+
const char* GetProcessName() const override { return "readoutMetadata"; }
31+
32+
explicit TRestRawReadoutMetadataProcess(const char* configFilename){};
33+
34+
TRestRawReadoutMetadataProcess() = default;
35+
~TRestRawReadoutMetadataProcess() = default;
36+
37+
// this is a workaround
38+
static TRestRawReadoutMetadata* fReadoutMetadata; //! // made static to avoid problems with MT
39+
40+
ClassDefOverride(TRestRawReadoutMetadataProcess, 1);
41+
};
42+
43+
#endif // REST_TRESTRAWREADOUTMETADATAPROCESS_H

inc/TRestRawToDetectorSignalProcess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class TRestRawToDetectorSignalProcess : public TRestEventProcess {
7979

8080
TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
8181

82-
void ZeroSuppresion(TRestRawSignal* rawSignal, TRestDetectorSignal& sgnl);
82+
void ZeroSuppresion(TRestRawSignal* rawSignal, TRestDetectorSignal& signal);
8383

8484
/// It prints out the process parameters stored in the metadata structure
8585
void PrintMetadata() override {

0 commit comments

Comments
 (0)