8 #include <FairLogger.h>
10 #include <Math/Vector3D.h>
11 #include <Math/Vector3Dfwd.h>
13 #include <TClonesArray.h>
25 constexpr
auto cRED =
"\033[1;31m";
28 constexpr
auto cGREEN =
"\033[1;32m";
32 LOG(debug) <<
"Constructor of AtPulseLineTask";
37 Int_t AtPulseLineTask::throwRandomAndGetBinAfterDiffusion(
const ROOT::Math::XYZVector &loc, Double_t diffusionSigma)
39 auto r = gRandom->Gaus(0, diffusionSigma);
40 auto phi = gRandom->Uniform(0, TMath::TwoPi());
41 Double_t propX = loc.x() + r * TMath::Cos(phi);
42 Double_t propY = loc.y() + r * TMath::Sin(phi);
43 return fPadPlane->FindBin(propX, propY);
49 fXYintegrationMap.clear();
51 Int_t validPoints = 0;
54 for (
int i = 0; i < fNumIntegrationPoints; ++i) {
60 auto padNumber = fMap->BinToPad(binNumber);
61 fXYintegrationMap[padNumber]++;
65 for (
auto &elem : fXYintegrationMap)
66 elem.second /= (double)validPoints;
69 bool AtPulseLineTask::gatherElectronsFromSimulatedPoint(
AtSimulatedPoint *point)
72 if (line ==
nullptr) {
73 LOG(fatal) <<
"Data in branch AtSimulatedPoint is not of type AtSimulatedLine!";
77 generateIntegrationMap(*line);
78 std::vector<double> zIntegration;
79 auto binMin = integrateTimebuckets(zIntegration, line);
82 for (
const auto &pad : fXYintegrationMap) {
86 for (
int i = 0; i < zIntegration.size(); ++i) {
87 auto zLoc = eleAccumulated[0]->GetXaxis()->GetBinCenter(i + binMin);
88 auto charge = line->
GetCharge() * zIntegration[i] * pad.second;
89 auto gAvg = getAvgGETgain(charge);
90 eleAccumulated[pad.first]->Fill(zLoc, gAvg * charge);
91 electronsMap[pad.first] = eleAccumulated[pad.first].get();
96 auto trackID = mcPoint->GetTrackID();
105 Int_t AtPulseLineTask::integrateTimebuckets(std::vector<double> &zIntegral,
AtSimulatedLine *line)
112 auto dT = (tMax - tMin);
114 LOG(warn) <<
"This line charge spans multiple TB widths from " << tMin <<
" us to " << tMax <<
" us.";
115 LOG(warn) <<
" The time distribution is likely widder than will be calculated. dT: " << dT
116 <<
"ns TB width: " << fTBTime <<
"ns";
119 auto tMean = (tMax + tMin) / 2.;
123 const TAxis *axis = eleAccumulated[0]->GetXaxis();
124 auto binMin = axis->FindBin(tIntegrationMinimum);
125 auto binMax = axis->FindBin(tIntegrationMaximum);
126 if (binMin < fTBPadPlane)
127 binMin = fTBPadPlane;
128 if (binMax > fTBEntrance)
129 binMax = fTBEntrance;
134 double lowerBound = TMath::Erf((axis->GetBinLowEdge(binMin) - tMean) / denominator);
135 for (
int i = binMin; i <= binMax; ++i) {
136 auto upperBound = TMath::Erf((axis->GetBinUpEdge(i) - tMean) / denominator);
137 auto integral = 0.5 * (upperBound - lowerBound);
138 zIntegral.emplace_back(integral);
139 lowerBound = upperBound;
143 if (binMin == fTBPadPlane || binMax == fTBEntrance) {
144 auto sum = std::accumulate(zIntegral.begin(), zIntegral.end(), 0.);
145 for (
auto &elem : zIntegral)