6 #include <FairLogger.h>
8 #include <Math/Point3D.h>
9 #include <Math/Point3Dfwd.h>
10 #include <TSpectrum.h>
25 LOG(debug) <<
"Running PSA on pad " << pad->
GetPadNum();
32 if (pos.X() < -9000 || pos.Y() < -9000) {
33 LOG(debug) <<
"Skipping pad, position is invalid";
38 LOG(ERROR) <<
"Pedestal should be subtracted to use this class!";
42 std::array<double, 512> floatADC = adc;
43 std::array<double, 512> dummy{};
47 double traceIntegral = std::accumulate(adc.begin(), adc.end(), 0.0);
49 auto PeakFinder = std::make_unique<TSpectrum>();
51 PeakFinder->SearchHighRes(floatADC.data(), dummy.data(),
fNumTbs, 4.7, 5, fBackGroundSuppression, 3, kTRUE, 3);
53 if (fBackGroundInterp) {
58 for (Int_t iPeak = 0; iPeak < numPeaks; iPeak++) {
60 auto maxAdcIdx = (Int_t)(ceil((PeakFinder->GetPositionX())[iPeak]));
61 if (maxAdcIdx < 3 || maxAdcIdx > 509)
64 auto charge = floatADC[maxAdcIdx];
65 if (padThreshold > 0 && charge < padThreshold) {
66 LOG(debug) <<
"Invalid threshold with charge: " << charge <<
" and threshold: " << padThreshold;
71 Double_t timemax = 0.5 * (floatADC[maxAdcIdx - 1] - floatADC[maxAdcIdx + 1]) /
72 (floatADC[maxAdcIdx - 1] + floatADC[maxAdcIdx + 1] - 2 * floatADC[maxAdcIdx]);
81 auto hit = std::make_unique<AtHit>(PadNum, pos, charge);
83 hit->SetTimeStamp(maxAdcIdx);
84 hit->SetTimeStampCorr(TBCorr);
85 hit->SetTimeStampCorrInter(timemax);
86 hit->SetTraceIntegral(traceIntegral);
90 hits.push_back(std::move(hit));
101 auto BGInter = std::make_unique<TSpectrum>();
102 BGInter->Background(bg.data(),
fNumTbs, 6, TSpectrum::kBackDecreasingWindow, TSpectrum::kBackOrder2, kTRUE,
103 TSpectrum::kBackSmoothing7, kTRUE);
105 for (Int_t iTb = 1; iTb <
fNumTbs; iTb++) {
106 adc[iTb] = adc[iTb] - bg[iTb];
115 if (maxAdcIdx > 11) {
116 for (Int_t i = 0; i < 11; i++) {
118 if (floatADC[maxAdcIdx - i + 10] > 0 && floatADC[maxAdcIdx - i + 10] < 4000) {
119 TBCorr += (floatADC[maxAdcIdx - i + 5]) * (maxAdcIdx - i + 5);
120 qTot += floatADC[maxAdcIdx - i + 5];
124 return TBCorr / qTot;