10 #include <FairLogger.h>
12 #include <FairRuntimeDb.h>
14 #include <Math/Point3D.h>
16 #include <TClonesArray.h>
27 using std::max_element;
28 using std::min_element;
33 FairRun *run = FairRun::Instance();
35 LOG(FATAL) <<
"No analysis run!";
37 FairRuntimeDb *db = run->GetRuntimeDb();
39 LOG(FATAL) <<
"No runtime database!";
41 auto fPar = (
AtDigiPar *)db->getContainer(
"AtDigiPar");
43 LOG(FATAL) <<
"AtDigiPar not found!!";
51 fZk = fPar->GetZPadPlane();
52 fEntTB = (Int_t)fPar->GetTBEntrance();
57 std::cout <<
" ==== Parameters for Pulse Shape Analysis Task ==== " << std::endl;
58 std::cout <<
" ==== Magnetic Field : " <<
fBField <<
" T " << std::endl;
59 std::cout <<
" ==== Electric Field : " <<
fEField <<
" V/cm " << std::endl;
60 std::cout <<
" ==== Sampling Rate : " <<
fTBTime <<
" ns " << std::endl;
61 std::cout <<
" ==== Drift Velocity : " <<
fDriftVelocity <<
" cm/us " << std::endl;
62 std::cout <<
" ==== Entrance TB : " <<
fEntTB << std::endl;
63 std::cout <<
" ==== Pad plane TB : " <<
fTB0 << std::endl;
64 std::cout <<
" ==== NumTbs : " <<
fNumTbs << std::endl;
74 fThreshold = threshold;
76 fThresholdlow = threshold;
81 fThresholdlow = thresholdlow;
98 for (
auto it = map.lower_bound(padNum); it != map.upper_bound(padNum); ++it) {
103 AtHit::MCSimPoint mcpoint(it->second, MCPoint->GetTrackID(), MCPoint->GetEIni(), MCPoint->GetEnergyLoss(),
104 MCPoint->GetAIni(), MCPoint->GetMassNum(), MCPoint->GetAtomicNum());
129 Double_t QEventTot = 0.0;
130 Double_t RhoVariance = 0.0;
131 Double_t RhoMean = 0.0;
134 std::map<Int_t, Int_t> PadMultiplicity;
135 std::array<Float_t, 512> mesh{};
138 for (
const auto &pad : rawEvent->
GetPads()) {
140 LOG(debug) <<
"Running PSA on pad " << pad->GetPadNum();
144 PadMultiplicity.insert(std::pair<Int_t, Int_t>(pad->GetPadNum(), hits.size()));
147 if (hits.size() != 0)
148 for (Int_t iTb = 0; iTb <
fNumTbs; iTb++)
149 mesh[iTb] += pad->GetADC(iTb);
152 for (
auto &&hit : hits) {
153 auto pos = hit->GetPosition();
154 QEventTot += hit->GetTraceIntegral();
156 RhoMean += pos.Rho();
159 if (mcPointsMap.size() > 0) {
160 LOG(debug) <<
"MC Simulated points Map size " << mcPointsMap.size();
164 event->AddHit(std::move(hit));
169 RhoVariance = Rho2 - (
event->GetNumHits() * pow((RhoMean / event->
GetNumHits()), 2));
171 for (Int_t iTb = 0; iTb <
fNumTbs; iTb++)
173 event->SortHitArrayTime();
174 event->SetMultiplicityMap(PadMultiplicity);
175 event->SetRhoVariance(RhoVariance);
176 event->SetEventCharge(QEventTot);
182 return fThresholdlow;