REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorSignal.cxx
1
66
67#include "TRestDetectorSignal.h"
68
69#include <TCanvas.h>
70#include <TF1.h>
71#include <TFitResult.h>
72#include <TH1.h>
73#include <TMath.h>
74#include <TRandom3.h>
75
76#include <algorithm>
77#include <limits>
78
79using namespace std;
80
81ClassImp(TRestDetectorSignal);
82
83TRestDetectorSignal::TRestDetectorSignal() {
84 // TRestDetectorSignal default constructor
85 fGraph = nullptr;
86 fSignalID = -1;
87 fSignalTime.clear();
88 fSignalCharge.clear();
89
90 fPointsOverThreshold.clear();
91}
92
93TRestDetectorSignal::~TRestDetectorSignal() = default;
94
95void TRestDetectorSignal::NewPoint(Double_t time, Double_t data) {
96 fSignalTime.push_back(time);
97 fSignalCharge.push_back(data);
98}
99
104void TRestDetectorSignal::IncreaseAmplitude(Double_t t, Double_t d) { IncreaseAmplitude({t, d}); }
105
113 Double_t x = p.X();
114 Double_t y = p.Y();
115 Int_t index = GetTimeIndex(x);
116
117 if (index >= 0) {
118 fSignalTime[index] = x;
119 fSignalCharge[index] += y;
120 } else {
121 fSignalTime.push_back(x);
122 fSignalCharge.push_back(y);
123 }
124}
125
133void TRestDetectorSignal::SetPoint(const TVector2& p) {
134 Int_t index = GetTimeIndex(p.X());
135 Double_t x = p.X();
136 Double_t y = p.Y();
137
138 if (index >= 0) {
139 fSignalTime[index] = x;
140 fSignalCharge[index] = y;
141 } else {
142 fSignalTime.push_back(x);
143 fSignalCharge.push_back(y);
144 }
145}
146
154void TRestDetectorSignal::SetPoint(Double_t t, Double_t d) {
155 TVector2 p(t, d);
156 SetPoint(p);
157}
158
163void TRestDetectorSignal::SetPoint(Int_t index, Double_t t, Double_t d) {
164 fSignalTime[index] = t;
165 fSignalCharge[index] = d;
166}
167
168Double_t TRestDetectorSignal::GetIntegral(Int_t startBin, Int_t endBin) const {
169 if (startBin < 0) {
170 startBin = 0;
171 }
172 if (endBin <= 0 || endBin > GetNumberOfPoints()) {
173 endBin = GetNumberOfPoints();
174 }
175
176 Double_t sum = 0;
177 for (int i = startBin; i < endBin; i++) {
178 sum += GetData(i);
179 }
180
181 return sum;
182}
183
184void TRestDetectorSignal::Normalize(Double_t scale) {
185 Double_t sum = GetIntegral();
186 for (int i = 0; i < GetNumberOfPoints(); i++) {
187 fSignalCharge[i] = scale * GetData(i) / sum;
188 }
189}
190
191Double_t TRestDetectorSignal::GetIntegralWithTime(Double_t startTime, Double_t endTime) const {
192 Double_t sum = 0;
193 for (int i = 0; i < GetNumberOfPoints(); i++) {
194 const auto time = GetTime(i);
195 if (time >= startTime && time <= endTime) {
196 sum += GetData(i);
197 }
198 }
199 return sum;
200}
201
202Double_t TRestDetectorSignal::GetMaxPeakWithTime(Double_t startTime, Double_t endTime) const {
203 Double_t max = std::numeric_limits<double>::min();
204 for (int i = 0; i < GetNumberOfPoints(); i++) {
205 if (GetTime(i) >= startTime && GetTime(i) < endTime) {
206 if (this->GetData(i) > max) max = GetData(i);
207 }
208 }
209 return max;
210}
211
212/* {{{
213Double_t TRestDetectorSignal::GetIntegralWithThreshold(Int_t from, Int_t to, Int_t startBaseline, Int_t
214endBaseline,
215 Double_t nSigmas, Int_t nPointsOverThreshold,
216 Double_t nMinSigmas) {
217 if (startBaseline < 0) startBaseline = 0;
218 if (endBaseline <= 0 || endBaseline > GetNumberOfPoints()) endBaseline = GetNumberOfPoints();
219
220 Double_t baseLine = GetBaseLine(startBaseline, endBaseline);
221
222 Double_t pointThreshold = nSigmas * GetBaseLineSigma(startBaseline, endBaseline);
223 Double_t signalThreshold = nMinSigmas * GetBaseLineSigma(startBaseline, endBaseline);
224
225 return GetIntegralWithThreshold(from, to, baseLine, pointThreshold, nPointsOverThreshold,
226 signalThreshold);
227}
228
229Double_t TRestDetectorSignal::GetIntegralWithThreshold(Int_t from, Int_t to, Double_t baseline,
230 Double_t pointThreshold, Int_t nPointsOverThreshold,
231 Double_t signalThreshold) {
232 Double_t sum = 0;
233 Int_t nPoints = 0;
234 fPointsOverThreshold.clear();
235
236 if (to > GetNumberOfPoints()) to = GetNumberOfPoints();
237
238 Float_t maxValue = 0;
239 for (int i = from; i < to; i++) {
240 if (GetData(i) > baseline + pointThreshold) {
241 if (GetData(i) > maxValue) maxValue = GetData(i);
242 nPoints++;
243 } else {
244 if (nPoints >= nPointsOverThreshold) {
245 Double_t sig = GetStandardDeviation(i - nPoints, i);
246 if (sig > signalThreshold) {
247 for (int j = i - nPoints; j < i; j++) {
248 sum += this->GetData(j);
249 fPointsOverThreshold.push_back(j);
250 }
251 }
252 }
253 nPoints = 0;
254 maxValue = 0;
255 }
256 }
257
258 if (nPoints >= nPointsOverThreshold) {
259 Double_t sig = GetStandardDeviation(to - nPoints, to);
260 if (sig > signalThreshold) {
261 for (int j = to - nPoints; j < to; j++) {
262 sum += this->GetData(j);
263 fPointsOverThreshold.push_back(j);
264 }
265 }
266 }
267
268 return sum;
269}
270}}} */
271
272Double_t TRestDetectorSignal::GetAverage(Int_t start, Int_t end) {
273 this->Sort();
274
275 if (end == 0) end = this->GetNumberOfPoints();
276
277 Double_t sum = 0;
278 for (int i = start; i <= end; i++) {
279 sum += this->GetData(i);
280 }
281 return sum / (end - start + 1);
282}
283
284Int_t TRestDetectorSignal::GetMaxPeakWidth() {
285 this->Sort();
286
287 Int_t mIndex = this->GetMaxIndex();
288 Double_t maxValue = this->GetData(mIndex);
289
290 Double_t value = maxValue;
291 Int_t rightIndex = mIndex;
292 while (value > maxValue / 2) {
293 value = this->GetData(rightIndex);
294 rightIndex++;
295 }
296 Int_t leftIndex = mIndex;
297 value = maxValue;
298 while (value > maxValue / 2) {
299 value = this->GetData(leftIndex);
300 leftIndex--;
301 }
302
303 return rightIndex - leftIndex;
304}
305
306Double_t TRestDetectorSignal::GetMaxPeakValue() { return GetData(GetMaxIndex()); }
307
308Int_t TRestDetectorSignal::GetMaxIndex(Int_t from, Int_t to) {
309 Double_t max = std::numeric_limits<double>::min();
310 Int_t index = 0;
311
312 if (from < 0) {
313 from = 0;
314 }
315 if (to > GetNumberOfPoints()) {
316 to = GetNumberOfPoints();
317 }
318
319 if (to == 0) {
320 to = GetNumberOfPoints();
321 }
322
323 for (int i = from; i < to; i++) {
324 if (this->GetData(i) > max) {
325 max = GetData(i);
326 index = i;
327 }
328 }
329
330 return index;
331}
332
333// z position by gaussian fit
334
335optional<pair<Double_t, Double_t>>
336TRestDetectorSignal::GetPeakGauss() // returns a 2vector with the time of the peak time in us and the energy
337{
338 const auto indexMax =
339 std::distance(fSignalCharge.begin(), std::max_element(fSignalCharge.begin(), fSignalCharge.end()));
340 const auto timeMax = fSignalTime[indexMax];
341 const auto signalMax = fSignalCharge[indexMax];
342
343 // Define fit limits
344 Double_t threshold = signalMax * 0.9; // 90% of the maximum value
345
346 Double_t lowerLimit = timeMax, upperLimit = timeMax;
347
348 // Find the lower limit: time when signal drops to 90% of the max before the peak
349 for (auto i = indexMax; i >= 0; --i) {
350 if (fSignalCharge[i] <= threshold) {
351 lowerLimit = fSignalTime[i];
352 break;
353 }
354 }
355 // Find the upper limit: time when signal drops to 90% of the max after the peak
356 for (auto i = indexMax; i < GetNumberOfPoints(); ++i) {
357 if (fSignalCharge[i] <= threshold) {
358 lowerLimit = fSignalTime[i];
359 break;
360 }
361 }
362
363 TF1 gauss("gaus", "gaus", lowerLimit, upperLimit);
364
365 auto signal_graph = std::unique_ptr<TGraph>(GetGraph());
366
367 TFitResultPtr fitResult =
368 signal_graph->Fit(&gauss, "QNRS"); // Q = quiet, no info in screen; N = no plot; R = fit in
369 // the function range; S = save and return the fit result
370
371 if (!fitResult->IsValid()) {
372 return nullopt;
373 }
374
375 double energy = gauss.GetParameter(0);
376 double time = gauss.GetParameter(1);
377
378 return make_pair(time, energy);
379}
380
381// z position by landau fit
382
383optional<pair<Double_t, Double_t>>
384TRestDetectorSignal::GetPeakLandau() // returns a 2vector with the time of the peak time in us and the energy
385{
386 Int_t maxRaw = GetMaxIndex(); // The bin where the maximum of the raw signal is found
387 Double_t maxRawTime =
388 GetTime(maxRaw); // The time of the bin where the maximum of the raw signal is found
389
390 // Define fit limits
391 Double_t threshold = GetData(maxRaw) * 0.9; // 90% of the maximum value
392
393 Double_t lowerLimit = maxRawTime, upperLimit = maxRawTime;
394
395 // Find the lower limit: time when signal drops to 90% of the max before the peak
396 for (int i = maxRaw; i >= 0; --i) {
397 if (GetData(i) <= threshold) {
398 lowerLimit = GetTime(i);
399 break;
400 }
401 }
402
403 // Find the upper limit: time when signal drops to 90% of the max after the peak
404 for (int i = maxRaw; i < GetNumberOfPoints(); ++i) {
405 if (GetData(i) <= threshold) {
406 upperLimit = GetTime(i);
407 break;
408 }
409 }
410
411 TF1 landau("landau", "landau", lowerLimit, upperLimit);
412
413 auto signal_graph = std::unique_ptr<TGraph>(GetGraph());
414
415 TFitResultPtr fitResult =
416 signal_graph->Fit(&landau, "QNRS"); // Q = quiet, no info in screen; N = no plot; R = fit in the
417 // function range; S = save and return the fit result
418 if (!fitResult->IsValid()) {
419 return nullopt;
420 }
421
422 double energy = landau.GetParameter(0);
423 double time = landau.GetParameter(1);
424
425 return make_pair(time, energy);
426}
427
428// z position by aget fit
429
430Double_t agetResponseFunction(Double_t* x, Double_t* par) { // x contains as many elements as the number of
431 // dimensions (in this case 1, i.e. x[0]), and
432 // par contains as many elements as the number of free parameters in my function.
433
434 Double_t arg =
435 (x[0] - par[1] + 1.1664) /
436 par[2]; // 1.1664 is the x value where the maximum of the base function (i.e. without parameters) is.
437 Double_t f = par[0] / 0.0440895 * exp(-3 * (arg)) * (arg) * (arg) *
438 (arg)*sin(arg); // to rescale the Y axis and get amplitude.
439 return f;
440}
441
442optional<pair<Double_t, Double_t>>
443TRestDetectorSignal::GetPeakAget() // returns a 2vector with the time of the peak time in us and the energy
444{
445 Int_t maxRaw = GetMaxIndex(); // The bin where the maximum of the raw signal is found
446 Double_t maxRawTime =
447 GetTime(maxRaw); // The time of the bin where the maximum of the raw signal is found
448
449 // Define fit limits
450 Double_t threshold = GetData(maxRaw) * 0.9; // 90% of the maximum value
451
452 Double_t lowerLimit = maxRawTime, upperLimit = maxRawTime;
453
454 // Find the lower limit: time when signal drops to 90% of the max before the peak
455 for (int i = maxRaw; i >= 0; --i) {
456 if (GetData(i) <= threshold) {
457 lowerLimit = GetTime(i);
458 break;
459 }
460 }
461
462 // Find the upper limit: time when signal drops to 90% of the max after the peak
463 for (int i = maxRaw; i < GetNumberOfPoints(); ++i) {
464 if (GetData(i) <= threshold) {
465 upperLimit = GetTime(i);
466 break;
467 }
468 }
469
470 TF1 aget("aget", agetResponseFunction, lowerLimit, upperLimit, 3); //
471 aget.SetParameters(500, maxRawTime, 1.2);
472
473 auto signal_graph = std::unique_ptr<TGraph>(GetGraph());
474
475 TFitResultPtr fitResult =
476 signal_graph->Fit(&aget, "QNRS"); // Q = quiet, no info in screen; N = no plot; R = fit in
477 // the function range; S = save and return the fit result
478
479 if (!fitResult->IsValid()) {
480 return nullopt;
481 }
482
483 double energy = aget.GetParameter(0);
484 double time = aget.GetParameter(1);
485
486 return make_pair(time, energy);
487}
488
489Double_t TRestDetectorSignal::GetMaxPeakTime(Int_t from, Int_t to) { return GetTime(GetMaxIndex(from, to)); }
490
491Double_t TRestDetectorSignal::GetMinPeakValue() { return GetData(GetMinIndex()); }
492
493Int_t TRestDetectorSignal::GetMinIndex() const {
494 Double_t min = numeric_limits<Double_t>::max();
495 Int_t index = 0;
496
497 for (int i = 0; i < GetNumberOfPoints(); i++) {
498 if (this->GetData(i) < min) {
499 min = GetData(i);
500 index = i;
501 }
502 }
503
504 return index;
505}
506
507Double_t TRestDetectorSignal::GetMinTime() const {
508 if (GetNumberOfPoints() == 0) {
509 return 0;
510 }
511 Double_t minTime = numeric_limits<Double_t>::max();
512 for (int i = 0; i < GetNumberOfPoints(); i++) {
513 const Double_t time = GetTime(i);
514 if (time < minTime) {
515 minTime = time;
516 }
517 }
518 return minTime;
519}
520
521Double_t TRestDetectorSignal::GetMaxTime() const {
522 if (GetNumberOfPoints() == 0) {
523 return 0;
524 }
525 Double_t maxTime = numeric_limits<Double_t>::min();
526 for (int i = 0; i < GetNumberOfPoints(); i++) {
527 const auto time = GetTime(i);
528 if (time > maxTime) {
529 maxTime = time;
530 }
531 }
532 return maxTime;
533}
534
535Int_t TRestDetectorSignal::GetTimeIndex(Double_t t) {
536 Double_t time = t;
537
538 for (int n = 0; n < GetNumberOfPoints(); n++) {
539 if (time == fSignalTime[n]) {
540 return n;
541 }
542 }
543 return -1;
544}
545
546Bool_t TRestDetectorSignal::isSorted() const {
547 for (int i = 0; i < GetNumberOfPoints() - 1; i++) {
548 if (GetTime(i + 1) < GetTime(i)) {
549 return false;
550 }
551 }
552 return true;
553}
554
555void TRestDetectorSignal::Sort() {
556 while (!isSorted()) {
557 for (int i = 0; i < GetNumberOfPoints(); i++) {
558 for (int j = i; j < GetNumberOfPoints(); j++) {
559 if (GetTime(i) > GetTime(j)) {
560 iter_swap(fSignalTime.begin() + i, fSignalTime.begin() + j);
561 iter_swap(fSignalCharge.begin() + i, fSignalCharge.begin() + j);
562 }
563 }
564 }
565 }
566}
567
568void TRestDetectorSignal::GetDifferentialSignal(TRestDetectorSignal* diffSignal, Int_t smearPoints) {
569 this->Sort();
570
571 for (int i = 0; i < smearPoints; i++) diffSignal->IncreaseAmplitude(GetTime(i), 0);
572
573 for (int i = smearPoints; i < this->GetNumberOfPoints() - smearPoints; i++) {
574 Double_t value = (this->GetData(i + smearPoints) - GetData(i - smearPoints)) /
575 (GetTime(i + smearPoints) - GetTime(i - smearPoints));
576 Double_t time = (GetTime(i + smearPoints) + GetTime(i - smearPoints)) / 2.;
577
578 diffSignal->IncreaseAmplitude(time, value);
579 }
580
581 for (int i = GetNumberOfPoints() - smearPoints; i < GetNumberOfPoints(); i++) {
582 diffSignal->IncreaseAmplitude(GetTime(i), 0);
583 }
584}
585
586void TRestDetectorSignal::GetSignalDelayed(TRestDetectorSignal* delayedSignal, Int_t delay) {
587 this->Sort();
588
589 for (int i = 0; i < delay; i++) delayedSignal->IncreaseAmplitude(GetTime(i), GetData(i));
590
591 for (int i = delay; i < GetNumberOfPoints(); i++) {
592 delayedSignal->IncreaseAmplitude(GetTime(i), GetData(i - delay));
593 }
594}
595
596void TRestDetectorSignal::GetSignalSmoothed(TRestDetectorSignal* smthSignal, Int_t averagingPoints) {
597 this->Sort();
598
599 averagingPoints = (averagingPoints / 2) * 2 + 1; // make it odd >= averagingPoints
600
601 Double_t sum = GetIntegral(0, averagingPoints);
602 for (int i = 0; i <= averagingPoints / 2; i++)
603 smthSignal->IncreaseAmplitude(GetTime(i), sum / averagingPoints);
604
605 for (int i = averagingPoints / 2 + 1; i < GetNumberOfPoints() - averagingPoints / 2; i++) {
606 sum -= this->GetData(i - (averagingPoints / 2 + 1));
607 sum += this->GetData(i + averagingPoints / 2);
608 smthSignal->IncreaseAmplitude(this->GetTime(i), sum / averagingPoints);
609 }
610
611 for (int i = GetNumberOfPoints() - averagingPoints / 2; i < GetNumberOfPoints(); i++)
612 smthSignal->IncreaseAmplitude(GetTime(i), sum / averagingPoints);
613}
614
615Double_t TRestDetectorSignal::GetBaseLine(Int_t startBin, Int_t endBin) {
616 if (endBin - startBin <= 0) return 0.;
617
618 Double_t baseLine = 0;
619 for (int i = startBin; i < endBin; i++) baseLine += fSignalCharge[i];
620
621 return baseLine / (endBin - startBin);
622}
623
624Double_t TRestDetectorSignal::GetStandardDeviation(Int_t startBin, Int_t endBin) {
625 Double_t bL = GetBaseLine(startBin, endBin);
626 return GetBaseLineSigma(startBin, endBin, bL);
627}
628
629Double_t TRestDetectorSignal::GetBaseLineSigma(Int_t startBin, Int_t endBin, Double_t baseline) {
630 Double_t bL = baseline;
631 if (bL == 0) bL = GetBaseLine(startBin, endBin);
632
633 Double_t baseLineSigma = 0;
634 for (int i = startBin; i < endBin; i++)
635 baseLineSigma += (bL - fSignalCharge[i]) * (bL - fSignalCharge[i]);
636
637 return TMath::Sqrt(baseLineSigma / (endBin - startBin));
638}
639
640Double_t TRestDetectorSignal::SubstractBaseline(Int_t startBin, Int_t endBin) {
641 Double_t bL = GetBaseLine(startBin, endBin);
642
643 AddOffset(-bL);
644
645 return bL;
646}
647
648void TRestDetectorSignal::AddOffset(Double_t offset) {
649 for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] = fSignalCharge[i] + offset;
650}
651
652void TRestDetectorSignal::MultiplySignalBy(Double_t factor) {
653 for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] = factor * fSignalCharge[i];
654}
655
656void TRestDetectorSignal::ExponentialConvolution(Double_t fromTime, Double_t decayTime, Double_t offset) {
657 for (int i = 0; i < GetNumberOfPoints(); i++) {
658 if (fSignalTime[i] > fromTime) {
659 fSignalCharge[i] =
660 (fSignalCharge[i] - offset) * exp(-(fSignalTime[i] - fromTime) / decayTime) + offset;
661 }
662 }
663}
664
665void TRestDetectorSignal::SignalAddition(TRestDetectorSignal* inSignal) {
666 if (this->GetNumberOfPoints() != inSignal->GetNumberOfPoints()) {
667 cout << "ERROR : I cannot add two signals with different number of points" << endl;
668 return;
669 }
670
671 Int_t badSignalTimes = 0;
672
673 for (int i = 0; i < GetNumberOfPoints(); i++)
674 if (GetTime(i) != inSignal->GetTime(i)) {
675 cout << "Time : " << GetTime(i) << " != " << inSignal->GetTime(i) << endl;
676 badSignalTimes++;
677 }
678
679 if (badSignalTimes) {
680 cout << "ERROR : The times of signal addition must be the same" << endl;
681 return;
682 }
683
684 for (int i = 0; i < GetNumberOfPoints(); i++) fSignalCharge[i] += inSignal->GetData(i);
685}
686
687void TRestDetectorSignal::AddGaussianSignal(Double_t amp, Double_t sigma, Double_t time, Int_t N,
688 Double_t fromTime, Double_t toTime) {
689 for (int i = 0; i < N; i++) {
690 Double_t tme = fromTime + (double)i / (N - 1) * (toTime - fromTime);
691
692 Double_t dta = 300 + amp * TMath::Exp(-0.5 * (tme - time) * (tme - time) / sigma / sigma);
693
694 cout << "T : " << tme << " D : " << dta << endl;
695 IncreaseAmplitude(tme, dta);
696 }
697}
698
699void TRestDetectorSignal::GetWhiteNoiseSignal(TRestDetectorSignal* noiseSignal, Double_t noiseLevel) {
700 this->Sort();
701
702 for (int i = 0; i < GetNumberOfPoints(); i++) {
703 TRandom3* fRandom = new TRandom3(0);
704
705 noiseSignal->IncreaseAmplitude(GetTime(i), GetData(i) + fRandom->Gaus(0, noiseLevel));
706
707 delete fRandom;
708 }
709}
710
711void TRestDetectorSignal::GetSignalGaussianConvolution(TRestDetectorSignal* convSignal, Double_t sigma,
712 Int_t nSigmas) {
713 this->Sort();
714
715 Int_t nPoints = GetMaxTime() - GetMinTime();
716 TF1* fGaus = new TF1("fGauss", "exp(-0.5*((x-[1])/[2])**2)", -nPoints, nPoints);
717 sigma = sigma * 1000.; // conversion to nanoseconds
718 fGaus->SetParameter(2, sigma); // the width of the gaussian is set
719
720 Double_t totChargeInitial = 0.;
721 Double_t totChargeFinal = 0.;
722
723 Double_t sum;
724
725 // We calculate the charge of the event before convolution
726 for (int i = 0; i < GetNumberOfPoints(); i++) totChargeInitial += fSignalCharge[i];
727
728 // The gaussian convolution of the initial signal is performed
729 for (int i = GetMinTime() - nSigmas * sigma; i < GetMaxTime() + nSigmas * sigma; i++) {
730 for (int j = 0; j < GetNumberOfPoints(); j++) {
731 if (TMath::Abs(i - GetTime(j)) > nSigmas * sigma) continue;
732 if (TMath::Abs(i - GetTime(j)) > nSigmas * sigma && i < GetTime(j)) break;
733
734 fGaus->SetParameter(1, GetTime(j));
735 sum = fSignalCharge[j] / TMath::Sqrt(2. * TMath::Pi()) / sigma * fGaus->Integral(i, i + 1);
736
737 convSignal->IncreaseAmplitude(i, sum);
738 totChargeFinal += sum;
739 }
740 }
741
742 cout << "Initial charge of the pulse " << totChargeInitial << endl;
743 cout << "Final charge of the pulse " << totChargeFinal << endl;
744}
745
746void TRestDetectorSignal::WriteSignalToTextFile(const TString& filename) const {
747 FILE* fff = fopen(filename.Data(), "w");
748 for (int i = 0; i < GetNumberOfPoints(); i++) {
749 fprintf(fff, "%e\t%e\n", GetTime(i), GetData(i));
750 }
751 fclose(fff);
752}
753
754void TRestDetectorSignal::Print() const {
755 cout << "Signal ID : " << GetSignalID() << endl;
756 cout << "Integral : " << GetIntegral() << endl;
757 if (!GetSignalName().empty()) {
758 cout << "Name: " << GetSignalName() << endl;
759 }
760 if (!GetSignalType().empty()) {
761 cout << "Type: " << GetSignalType() << endl;
762 }
763
764 cout << "------------------------------------------------" << endl;
765 for (int i = 0; i < GetNumberOfPoints(); i++) {
766 cout << "Time : " << GetTime(i) << " Charge : " << GetData(i) << endl;
767 }
768
769 cout << "================================================" << endl;
770}
771
772TGraph* TRestDetectorSignal::GetGraph(Int_t color) {
773 if (fGraph != nullptr) {
774 delete fGraph;
775 fGraph = nullptr;
776 }
777
778 fGraph = new TGraph();
779
780 // cout << "Signal ID " << this->GetSignalID( ) << " points " <<
781 // this->GetNumberOfPoints() << endl;
782
783 fGraph->SetLineWidth(2);
784 fGraph->SetLineColor(color);
785 fGraph->SetMarkerStyle(7);
786
787 int points = 0;
788 for (int n = 0; n < GetNumberOfPoints(); n++) {
789 fGraph->SetPoint(points, GetTime(n), GetData(n));
790 points++;
791 }
792
793 return fGraph;
794}
void IncreaseAmplitude(const TVector2 &p)
If the point already exists inside the detector signal event, the amplitude value will be added to th...
void SetPoint(const TVector2 &p)
If the point already exists inside the detector signal event, it will be overwritten....