6 #include <FairLogger.h>
8 #include <Math/Point3D.h>
9 #include <Math/Point3Dfwd.h>
27 if (pos.X() < -9000 || pos.Y() < -9000) {
28 LOG(debug) <<
"Skipping pad, position is invalid";
33 LOG(ERROR) <<
"Pedestal should be subtracted to use this class!";
36 std::array<Double_t, 512> floatADC = pad->
GetADC();
37 auto maxAdcIt = std::max_element(floatADC.begin() + 20, floatADC.end() - 12);
38 Int_t maxAdcIdx = std::distance(floatADC.begin(), maxAdcIt);
44 Double_t timemax = 0.5 * (floatADC[maxAdcIdx - 1] - floatADC[maxAdcIdx + 1]) /
45 (floatADC[maxAdcIdx - 1] + floatADC[maxAdcIdx + 1] - 2 * floatADC[maxAdcIdx]);
46 Double_t TBCorr = getTBCorr(floatADC, maxAdcIdx);
47 Double_t QHitTot = std::accumulate(floatADC.begin(), floatADC.end(), 0);
54 auto hit = std::make_unique<AtHit>(pad->
GetPadNum(), pos, *maxAdcIt);
56 hit->SetTimeStamp(maxAdcIdx);
57 hit->SetTimeStampCorr(TBCorr);
58 hit->SetTimeStampCorrInter(timemax);
59 hit->SetTraceIntegral(QHitTot);
62 ret.push_back(std::move(hit));
65 bool AtPSAMax::shouldSaveHit(
double charge,
double threshold,
int tb)
68 if (threshold > 0 && charge < threshold) {
70 LOG(debug) <<
"Invalid threshold with charge: " << charge <<
" and threshold: " << threshold;
72 if ((tb < 20 || tb > 500)) {
74 LOG(debug) <<
"Peak is outside valid time window (20,500) TBs.";
80 Double_t AtPSAMax::getTBCorr(
AtPad::trace &adc,
int maxAdcIdx)
87 for (Int_t i = 0; i < 11; i++)
88 if (adc[maxAdcIdx - i + 10] > 0 && adc[maxAdcIdx - i + 10] < 4000) {
89 auto tb = maxAdcIdx - i + 5;
91 tbAvg += adc[tb] / qTot * (tb - tbAvg);