Skip to content

Commit 781060e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9ff1ba4 commit 781060e

2 files changed

+36
-29
lines changed

inc/TRestRawSignalRecoverSaturationProcess.h

+10-8
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ class TRestRawSignalRecoverSaturationProcess : public TRestEventProcess {
3838
// You can set their default values here together.
3939
// Note: add "//!" mark at the end of the member definition
4040
// if you don't want to save them to disk.
41-
Size_t fMinSaturatedBins; //< ///< Minimum number of saturated bins to consider a signal as saturated
41+
Size_t fMinSaturatedBins; //< ///< Minimum number of saturated bins to consider a signal as saturated
4242

43-
Bool_t fProcessAllSignals; //< ///< Process all signals in the event
44-
Size_t fNBinsIfNotSaturated; //< ///< Number of bins to consider if the signal is not saturated
45-
Short_t fMinSaturationValue; //< ///< Threshold to consider a bin as saturated
43+
Bool_t fProcessAllSignals; //< ///< Process all signals in the event
44+
Size_t fNBinsIfNotSaturated; //< ///< Number of bins to consider if the signal is not saturated
45+
Short_t fMinSaturationValue; //< ///< Threshold to consider a bin as saturated
4646

47-
TVector2 fBaseLineRange; //< ///< Range of bins to calculate the baseline and fix that parameter in the fit
48-
TVector2 fFitRange; //< ///< Range of bins to fit the signal
49-
TCanvas *fC; //! ///< Canvas to draw the signals
47+
TVector2
48+
fBaseLineRange; //< ///< Range of bins to calculate the baseline and fix that parameter in the fit
49+
TVector2 fFitRange; //< ///< Range of bins to fit the signal
50+
TCanvas* fC; //! ///< Canvas to draw the signals
5051

5152
public:
5253
RESTValue GetInputEvent() const override { return fAnaEvent; }
@@ -70,7 +71,8 @@ class TRestRawSignalRecoverSaturationProcess : public TRestEventProcess {
7071
RESTMetadata << "ProcessAllSignals: " << strProcessAllSignals << RESTendl;
7172
RESTMetadata << "NBinsIfNotSaturated: " << fNBinsIfNotSaturated << RESTendl;
7273
RESTMetadata << "MinSaturationValue: " << fMinSaturationValue << RESTendl;
73-
RESTMetadata << "BaseLineRange: (" << fBaseLineRange.X() << ", " << fBaseLineRange.Y() << ")" << RESTendl;
74+
RESTMetadata << "BaseLineRange: (" << fBaseLineRange.X() << ", " << fBaseLineRange.Y() << ")"
75+
<< RESTendl;
7476
RESTMetadata << "FitRange: (" << fFitRange.X() << ", " << fFitRange.Y() << ")" << RESTendl;
7577

7678
EndPrintProcess();

src/TRestRawSignalRecoverSaturationProcess.cxx

+26-21
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ void TRestRawSignalRecoverSaturationProcess::Initialize() {
9090
fProcessAllSignals = false;
9191
fNBinsIfNotSaturated = 20;
9292
fMinSaturationValue = 0;
93-
fBaseLineRange = TVector2(-1, -1); // -1 means no baseline range
94-
fFitRange = TVector2(-1, -1); // -1 means no fit range
95-
93+
fBaseLineRange = TVector2(-1, -1); // -1 means no baseline range
94+
fFitRange = TVector2(-1, -1); // -1 means no fit range
9695
}
9796

9897
///////////////////////////////////////////////
@@ -132,7 +131,8 @@ TRestEvent* TRestRawSignalRecoverSaturationProcess::ProcessEvent(TRestEvent* evI
132131

133132
// Set the baseline range if it has been provided
134133
if (fBaseLineRange.X() != -1 && fBaseLineRange.Y() != -1)
135-
fAnaEvent->SetBaseLineRange(fBaseLineRange.X(), fBaseLineRange.Y()); // this will also calculate the baseline
134+
fAnaEvent->SetBaseLineRange(fBaseLineRange.X(),
135+
fBaseLineRange.Y()); // this will also calculate the baseline
136136

137137
// process each signal in the event
138138
for (int s = 0; s < fAnaEvent->GetNumberOfSignals(); s++) {
@@ -168,14 +168,15 @@ TRestEvent* TRestRawSignalRecoverSaturationProcess::ProcessEvent(TRestEvent* evI
168168
if (fProcessAllSignals && saturatedBins.size() < fMinSaturatedBins) {
169169
saturatedBins.clear();
170170
// set saturated bins around maxPeakBin
171-
for (size_t i = maxPeakBin-fNBinsIfNotSaturated/2; i < maxPeakBin+fNBinsIfNotSaturated/2 && i<(size_t)signal->GetNumberOfPoints(); i++) {
171+
for (size_t i = maxPeakBin - fNBinsIfNotSaturated / 2;
172+
i < maxPeakBin + fNBinsIfNotSaturated / 2 && i < (size_t)signal->GetNumberOfPoints(); i++) {
172173
saturatedBins.push_back(i);
173174
}
174175
}
175176

176177
if (!saturatedBins.empty()) {
177-
RESTDebug << " Saturated bins:" << saturatedBins.front() << " to " << saturatedBins.back() <<
178-
" at " << maxValue << RESTendl;
178+
RESTDebug << " Saturated bins:" << saturatedBins.front() << " to " << saturatedBins.back()
179+
<< " at " << maxValue << RESTendl;
179180
}
180181

181182
// Create TGraph with the not saturated bins for the fit
@@ -202,13 +203,13 @@ TRestEvent* TRestRawSignalRecoverSaturationProcess::ProcessEvent(TRestEvent* evI
202203
"[0]+[1]*TMath::Exp(-3. * (x-[3])/[2]) * "
203204
"(x-[3])/[2] * (x-[3])/[2] * (x-[3])/[2] / "
204205
"(1+TMath::Exp(-10000*(x-[3])))",
205-
startFitRange, endFitRange);
206+
startFitRange, endFitRange);
206207
RESTDebug << " nPoints" << signal->GetNumberOfPoints() << RESTendl;
207208
RESTDebug << " Function created" << RESTendl;
208209
// First estimation of the parameters
209210
auto peakposEstimate = maxPeakBin + saturatedBins.size() / 2;
210211
Double_t amplEstimate = maxValue;
211-
Double_t widthEstimate = (endFitRange - startFitRange)*0.2;
212+
Double_t widthEstimate = (endFitRange - startFitRange) * 0.2;
212213
Double_t baselineEstimate = 250;
213214

214215
// Second (and better) estimation of the parameters
@@ -223,30 +224,34 @@ TRestEvent* TRestRawSignalRecoverSaturationProcess::ProcessEvent(TRestEvent* evI
223224
// the amplitude estimate should be at least the maximum value of the signal
224225
if (amplEstimate < maxValue) amplEstimate = maxValue;
225226
}
226-
//signal->CalculateBaseLine(20,150);
227+
// signal->CalculateBaseLine(20,150);
227228
if (signal->isBaseLineInitialized()) {
228229
baselineEstimate = signal->GetBaseLine();
229230
}
230231
RESTDebug << " Estimations: ampl=" << amplEstimate << " width=" << widthEstimate
231232
<< " baseline=" << baselineEstimate << " peakpos=" << peakposEstimate << RESTendl;
232233
// Configure the fit parameters
233234
f->SetParNames("Baseline", "Amplitude", "ShapingTime", "PeakPosition");
234-
//f->SetParameters(baselineEstimate, amplEstimate / 0.0498, widthEstimate, peakposEstimate - widthEstimate);
235-
// Baseline
235+
// f->SetParameters(baselineEstimate, amplEstimate / 0.0498, widthEstimate, peakposEstimate -
236+
// widthEstimate);
237+
// Baseline
236238
f->SetParameter(0, baselineEstimate);
237-
f->SetParLimits(0, 0, maxValue); // baseline should be positive and less than the saturation value
238-
if (signal->isBaseLineInitialized()) { // fix the baseline to make it faster and more reliable
239+
f->SetParLimits(0, 0, maxValue); // baseline should be positive and less than the saturation value
240+
if (signal->isBaseLineInitialized()) { // fix the baseline to make it faster and more reliable
239241
f->FixParameter(0, baselineEstimate);
240-
}//*/
242+
} //*/
241243
// Amplitude
242-
f->SetParameter(1, amplEstimate / 0.0498); // 0.0498=e^{-3}
243-
f->SetParLimits(1, 0, maxValue / 0.0498 * 100); // max allowed amplitude is 100 times the saturation value
244+
f->SetParameter(1, amplEstimate / 0.0498); // 0.0498=e^{-3}
245+
f->SetParLimits(1, 0,
246+
maxValue / 0.0498 * 100); // max allowed amplitude is 100 times the saturation value
244247
// Width or shaping time
245248
f->SetParameter(2, widthEstimate);
246-
f->SetParLimits(2, 0, signal->GetNumberOfPoints()); // width should be positive and less than the window
249+
f->SetParLimits(2, 0,
250+
signal->GetNumberOfPoints()); // width should be positive and less than the window
247251
// Peak position
248252
f->SetParameter(3, peakposEstimate - widthEstimate);
249-
f->SetParLimits(3, 0, signal->GetNumberOfPoints()); // peak position should be positive and less than the window
253+
f->SetParLimits(
254+
3, 0, signal->GetNumberOfPoints()); // peak position should be positive and less than the window
250255

251256
std::string fitOptions = "R";
252257
if (GetVerboseLevel() < TRestStringOutput::REST_Verbose_Level::REST_Debug) {
@@ -263,7 +268,7 @@ TRestEvent* TRestRawSignalRecoverSaturationProcess::ProcessEvent(TRestEvent* evI
263268
for (size_t i = 0; i < (size_t)signal->GetNumberOfPoints(); i++) {
264269
if (std::find(saturatedBins.begin(), saturatedBins.end(), i) != saturatedBins.end()) {
265270
Double_t value = f->Eval(i) - maxValue;
266-
if (value > 0 || fProcessAllSignals) {
271+
if (value > 0 || fProcessAllSignals) {
267272
toAddSignal.AddPoint(value);
268273
anyBinRecovered = true;
269274
addedIntegral += value;
@@ -272,7 +277,7 @@ TRestEvent* TRestRawSignalRecoverSaturationProcess::ProcessEvent(TRestEvent* evI
272277
continue;
273278
}
274279
}
275-
toAddSignal.AddPoint((Short_t) 0);
280+
toAddSignal.AddPoint((Short_t)0);
276281
}
277282

278283
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Extreme) {

0 commit comments

Comments
 (0)