12 #include <FairLogger.h>
29 void AtTabEnergyLoss::SetStyle(std::array<TH1Ptr, 2> &hists, THStack &stack)
31 for (
int i = 0; i < hists.size(); ++i) {
34 hists[i]->SetMarkerStyle(21);
35 hists[i]->SetDirectory(
nullptr);
37 stack.Add(hists[i].get());
43 fFissionEvent(fissionBranch), fEntry(
AtViewerManager::Instance()->GetCurrentEntry()), fBinWidth(100),
44 fSigmaFromHit(2), fTBtoAvg(10), fRatioFunc(std::make_unique<TF1>(
"ratioFunc",
"pol0", 0, 1, TF1::EAddToList::kNo)),
45 fProxyFunc(std::make_unique<TF1>(
"proxyFunc",
"pol0", 0, 1, TF1::EAddToList::kNo)),
46 fZFunc(std::make_unique<TF1>(
"zFunc",
"pol0", 0, 1, TF1::EAddToList::kNo))
49 double maxLength = TMath::Sqrt(TMath::Sq(1000) + TMath::Sq(25));
50 int nBins = TMath::CeilNint(maxLength /
fBinWidth.
Get());
57 dEdx[0] = std::make_unique<TH1F>(
"dEdx1",
"dEdX Frag 1", nBins, 0, maxLength);
58 dEdx[1] = std::make_unique<TH1F>(
"dEdx2",
"dEdX Frag 2", nBins, 0, maxLength);
61 dEdxZ[0] = std::make_unique<TH1F>(
"dEdxZ1",
"dEdX Frag 1", nBins, 0, maxLength);
62 dEdxZ[1] = std::make_unique<TH1F>(
"dEdxZ2",
"dEdX Frag 2", nBins, 0, maxLength);
68 fSumQ[0] = std::make_unique<TH1F>(
"qSum_0",
"Q Sum Frag 1", numBins, minBin, maxBin);
69 fSumQ[1] = std::make_unique<TH1F>(
"qSum_1",
"Q Sum Frag 2", numBins, minBin, maxBin);
72 fSumFit[0] = std::make_unique<TH1F>(
"fitSum_0",
"Fit Sum Frag 1", numBins, minBin, maxBin);
73 fSumFit[1] = std::make_unique<TH1F>(
"fitSum_1",
"Fit Sum Frag 2", numBins, minBin, maxBin);
76 fRatioQ = std::make_unique<TH1F>(
"ratioQ",
"Ratio of Q Sum", numBins, minBin, maxBin);
77 fRatioFit = std::make_unique<TH1F>(
"ratioFit",
"Ratio of Fit Sum", numBins, minBin, maxBin);
78 fProxy = std::make_unique<TH1F>(
"proxy",
"Z Proxy", numBins, minBin, maxBin);
79 fZHist = std::make_unique<TH1F>(
"zHist",
"Z of light fragment", numBins, minBin, maxBin);
81 fVetoPads = {{0, 1, 1, 6}, {0, 1, 1, 7}, {0, 1, 1, 9}, {0, 1, 1, 10}, {0, 1, 1, 12}, {0, 1, 1, 39},
82 {0, 1, 1, 40}, {0, 1, 1, 41}, {0, 1, 1, 44}, {0, 1, 1, 43}, {0, 1, 1, 46}, {0, 1, 3, 13}};
84 std::ifstream file(
"/mnt/projects/hira/e12014/tpcSharedInfo/e12014_zap.csv");
86 LOG(fatal) <<
"File not open";
89 std::getline(file, header);
92 fVetoPads.push_back({row[0], row[1], row[2], row[3]});
113 void AtTabEnergyLoss::Update()
115 for (
auto &hist :
dEdx)
117 for (
auto &hist :
dEdxZ)
119 for (
auto &hist :
fSumQ)
159 return Zcn / (2 * R) * (R - 1 + std::sqrt(1 - R * R));
161 void AtTabEnergyLoss::FillRatio()
168 LOG(info) <<
"Starting ratio from " <<
fTrackStart[index] <<
"(mm) " << tbFinal <<
"(TB)";
171 int trackInd =
fSumQ[0]->GetBinContent(tbIni + 1) >
fSumQ[1]->GetBinContent(tbIni + 1) ? 0 : 1;
177 for (
int i = 0; i <
fSumFit[0]->GetNbinsX(); ++i) {
178 auto de1 =
fSumFit[0]->GetBinContent(i);
179 auto de2 =
fSumFit[1]->GetBinContent(i);
182 auto proxy = std::abs(de1 - de2) / (de1 + de2);
183 fProxy->SetBinContent(i, proxy);
188 double ratioAvg = 0, proxyAvg = 0;
190 for (
int i = tbIni; i < tbFinal; ++i) {
191 ratioAvg +=
fRatioFit->GetBinContent(i + 1);
192 proxyAvg +=
fProxy->GetBinContent(i + 1);
197 LOG(info) <<
"Average ratio: " << ratioAvg <<
" Z avg: " <<
GetZ(85, proxyAvg) <<
"/" << 85 -
GetZ(85, proxyAvg);
201 fZFunc->SetRange(tbIni, tbFinal);
211 void AtTabEnergyLoss::FillSums(
float threshold)
215 for (
int i = 0; i < 2; ++i) {
231 auto hitLocation = hit->GetPosition().Z() -
fSigmaFromHit.
Get() * hit->GetPositionSigma().Z();
234 }
else if (hitLocation <
242 LOG(debug) <<
"Setting start of " << i <<
" to " << hit->GetPosition() <<
" at " << hit->GetPadNum();
248 void AtTabEnergyLoss::setdEdX()
250 for (
int i = 0; i < 2; ++i) {
254 dEdx[i]->Fill(getHitDistanceFromVertex(*hit), hit->GetCharge());
255 dEdxZ[i]->Fill(getHitDistanceFromVertexAlongZ(*hit), hit->GetCharge());
258 for (
int bin = 0; bin <
dEdx[i]->GetNbinsX(); ++bin) {
259 dEdx[i]->SetBinError(bin, TMath::Sqrt(
dEdx[i]->GetBinContent(bin)));
260 dEdxZ[i]->SetBinError(bin, TMath::Sqrt(
dEdxZ[i]->GetBinContent(bin)));
265 double AtTabEnergyLoss::getHitDistanceFromVertex(
const AtHit &hit)
268 auto position =
XYZPoint(p.x(), p.y(), p.z());
270 return TMath::Sqrt(diff.Mag2());
273 double AtTabEnergyLoss::getHitDistanceFromVertexAlongZ(
const AtHit &hit)