REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorSignal.h
1
21
22#ifndef RestCore_TRestDetectorSignal
23#define RestCore_TRestDetectorSignal
24
25#include <TGraph.h>
26#include <TString.h>
27#include <TVector2.h>
28
29#include <iostream>
30
32 private:
33 Int_t GetMinIndex();
34 Int_t GetTimeIndex(Double_t t);
35
36 protected:
37 Int_t fSignalID = -1;
38
39 std::vector<Float_t> fSignalTime; // Vector with the time of the signal
40 std::vector<Float_t> fSignalCharge; // Vector with the charge of the signal
41
42 public:
43 TGraph* fGraph;
44
45 std::vector<Int_t> fPointsOverThreshold;
46
47 void IncreaseAmplitude(TVector2 p);
48 void SetPoint(TVector2 p);
49
50 // TODO other objects should probably skip using GetMaxIndex direclty
51 Int_t GetMaxIndex(Int_t from = 0, Int_t to = 0);
52
53 TVector2 GetMaxGauss();
54 TVector2 GetMaxLandau();
55 TVector2 GetMaxAget();
56
57 // Getters
58 TVector2 GetPoint(Int_t n) {
59 TVector2 vector2(GetTime(n), GetData(n));
60
61 return vector2;
62 }
63
64 inline Int_t GetSignalID() const { return fSignalID; }
65 inline Int_t GetID() const { return fSignalID; }
66
67 void IncreaseTimeBinBy(Int_t bin, Double_t data) {
68 if (bin >= GetNumberOfPoints()) {
69 std::cout << "Increase time bin: outside limits" << std::endl;
70 return;
71 }
72
73 fSignalCharge[bin] += data;
74 }
75
76 Int_t GetNumberOfPoints() {
77 if (fSignalTime.size() != fSignalCharge.size()) {
78 std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
79 std::cout << "WARNING, the two std::vector sizes did not match" << std::endl;
80 std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
81 }
82 return fSignalTime.size();
83 }
84
85 Double_t GetIntegralWithTime(Double_t startTime, Double_t endTime);
86 Double_t GetIntegral(Int_t startBin = 0, Int_t endBin = 0);
87
88 void Normalize(Double_t scale = 1.);
89
90 std::vector<Int_t> GetPointsOverThreshold() { return fPointsOverThreshold; }
91
92 Double_t GetAverage(Int_t start = 0, Int_t end = 0);
93 Int_t GetMaxPeakWidth();
94 Double_t GetMaxPeakWithTime(Double_t startTime, Double_t endTime);
95
96 Double_t GetMaxPeakValue();
97 Double_t GetMinPeakValue();
98
99 Double_t GetMaxPeakTime(Int_t from = 0, Int_t to = 0);
100
101 Double_t GetMaxValue() { return GetMaxPeakValue(); }
102 Double_t GetMinValue() { return GetMinPeakValue(); }
103
104 Double_t GetMinTime();
105 Double_t GetMaxTime();
106
107 Double_t GetData(Int_t index) { return (double)fSignalCharge[index]; }
108 Double_t GetTime(Int_t index) { return (double)fSignalTime[index]; }
109
110 // Setters
111 void SetSignalID(Int_t sID) { fSignalID = sID; }
112 void SetID(Int_t sID) { fSignalID = sID; }
113
114 void NewPoint(Float_t time, Float_t data);
115 void IncreaseAmplitude(Double_t t, Double_t d);
116
117 void SetPoint(Double_t t, Double_t d);
118 void SetPoint(Int_t index, Double_t t, Double_t d);
119
120 Double_t GetStandardDeviation(Int_t startBin, Int_t endBin);
121 Double_t GetBaseLine(Int_t startBin, Int_t endBin);
122 Double_t GetBaseLineSigma(Int_t startBin, Int_t endBin, Double_t baseline = 0);
123
124 Double_t SubstractBaseline(Int_t startBin, Int_t endBin);
125 void AddOffset(Double_t offset);
126
127 void MultiplySignalBy(Double_t factor);
128 void ExponentialConvolution(Double_t fromTime, Double_t decayTime, Double_t offset = 0);
129 void SignalAddition(TRestDetectorSignal* inSgnl);
130
131 Bool_t isSorted();
132 void Sort();
133
134 void GetDifferentialSignal(TRestDetectorSignal* diffSgnl, Int_t smearPoints = 5);
135 void GetSignalDelayed(TRestDetectorSignal* delayedSignal, Int_t delay);
136 void GetSignalSmoothed(TRestDetectorSignal* smthSignal, Int_t averagingPoints = 3);
137
138 void GetWhiteNoiseSignal(TRestDetectorSignal* noiseSgnl, Double_t noiseLevel = 1.);
139 void GetSignalGaussianConvolution(TRestDetectorSignal* convSgnl, Double_t sigma = 100.,
140 Int_t nSigmas = 5);
141
142 void AddGaussianSignal(Double_t amp, Double_t sigma, Double_t time, Int_t N, Double_t fromTime,
143 Double_t toTime);
144
145 void Reset() {
146 fSignalTime.clear();
147 fSignalCharge.clear();
148 }
149
150 void WriteSignalToTextFile(TString filename);
151 void Print();
152
153 TGraph* GetGraph(Int_t color = 1);
154
155 // Constructor
157 // Destructor
159
160 ClassDef(TRestDetectorSignal, 2);
161};
162#endif
void IncreaseAmplitude(TVector2 p)
If the point already exists inside the detector signal event, the amplitude value will be added to th...
void SetPoint(TVector2 p)
If the point already exists inside the detector signal event, it will be overwritten....