7 #include <FairLogger.h>
20 void AtRemovePulser::addPulserInfo(
AtPad *pad)
23 auto pulserInfo =
dynamic_cast<AtPulserInfo *
>(pad->
AddAugment(
"pulserInfo", std::make_unique<AtPulserInfo>()));
25 for (
int i = 1; i < adc.size(); ++i) {
26 if (std::abs(adc.at(i) - adc.at(i - 1)) > fThreshold) {
27 auto [start, stop, mag] = getTransitionAround(pad, i);
30 pulserInfo->SetRiseBegin(start);
31 pulserInfo->SetRiseEnd(stop);
32 pulserInfo->SetRiseMag(mag);
34 pulserInfo->SetFallBegin(start);
35 pulserInfo->SetFallEnd(stop);
36 pulserInfo->SetFallMag(-mag);
42 std::tuple<double, double, double> AtRemovePulser::getTransitionAround(
AtPad *pad,
int idx)
48 for (; start > 0; start--) {
49 if (std::abs(adc[start] - adc[start - 1]) < fThresholdLow)
54 for (; end < 512; end++)
55 if (std::abs(adc[end] - adc[end - 1]) < fThresholdLow)
58 LOG(debug) << start <<
" " << end <<
" " << adc[end] - adc[start];
60 return {start, end, adc[end] - adc[start]};
63 void AtRemovePulser::removePulser(
AtPad *pad)
67 std::accumulate(pulserInfo->GetMag().begin(), pulserInfo->GetMag().end(), 0.0) / pulserInfo->
GetMag().size();
70 auto zeroRise = pad->
GetADC(pulserInfo->GetBegin()[0] - 2) + pad->
GetADC(pulserInfo->GetBegin()[0] - 1);
72 auto zeroFall = pad->
GetADC(pulserInfo->GetEnd()[1] + 1) + pad->
GetADC(pulserInfo->GetEnd()[1]);
75 for (
int i = pulserInfo->GetBegin()[0]; i < pulserInfo->GetEnd()[1]; ++i) {
77 if (i < pulserInfo->GetEnd()[0]) {
81 if (i < pulserInfo->GetBegin()[1]) {