Skip to content

Commit 14510f9

Browse files
committed
IT3 som2
1 parent ef4a2ac commit 14510f9

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

Detectors/Upgrades/ITS3/study/macros/PlotPulls.C

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
/// \file PlotDCA.C
12+
/// \file PlotPulls.C
1313
/// \brief Simple macro to plot ITS3 pulls
1414

1515
#if !defined(__CLING__) || defined(__ROOTCLING__)
16+
#include <array>
17+
#include <cmath>
1618
#include <memory>
19+
#include <vector>
1720

1821
#include <TROOT.h>
1922
#include <TCanvas.h>
@@ -48,7 +51,13 @@ void PlotPulls(const char* fName = "its3TrackStudy.root")
4851
{
4952
TH1::SetDefaultSumw2();
5053
std::unique_ptr<TFile> inFile(TFile::Open(fName));
54+
if (!inFile || inFile->IsZombie()) {
55+
return;
56+
}
5157
auto tree = inFile->Get<TTree>("pull");
58+
if (!tree) {
59+
return;
60+
}
5261

5362
uint8_t src; // track type
5463
tree->SetBranchAddress("src", &src);
@@ -132,13 +141,13 @@ void PlotPulls(const char* fName = "its3TrackStudy.root")
132141
std::vector<TH1D*> projs;
133142
const char* fitOpt{"QWMERSB"};
134143
for (int i{0}; i < o2::track::kNParams; ++i) {
135-
for (auto iPt{0}; iPt < nPtBins; ++iPt) {
144+
for (auto iPt{0}; iPt < nPtBins - 1; ++iPt) {
136145
auto hProj = pulls[i]->ProjectionY(Form("%s_%d", pulls[i]->GetName(), iPt), iPt + 1, iPt + 1);
137146
hProj->SetName(Form("p%s_pt%d", pNames[i], iPt));
138147
hProj->SetTitle(Form("Pull %s #it{p}_{T}#in[%.2f, %.2f)", pNames[i], ptLimits[iPt], ptLimits[iPt + 1]));
139148
projs.push_back(hProj);
140149
if (hProj->GetEntries() < 100) {
141-
return;
150+
continue;
142151
}
143152
fGaus->SetParameter(1, 0);
144153
fGaus->SetParameter(2, 1);
@@ -152,14 +161,18 @@ void PlotPulls(const char* fName = "its3TrackStudy.root")
152161
}
153162
}
154163

155-
hMahDist2->Scale(1. / hMahDist2->Integral("width"));
156164
TF1* fchi2Fit = new TF1("fchi2_fit", chi2_pdf, 0.1, 6, 3);
157165
fchi2Fit->SetParNames("A", "k", "s");
158166
fchi2Fit->SetParameter(0, 1);
159167
fchi2Fit->SetParameter(1, 5);
160168
fchi2Fit->SetParameter(2, 1);
161-
auto fitres = hMahDist2->Fit(fchi2Fit, "RMQS");
162-
fitres->Print();
169+
if (hMahDist2->Integral("width") > 0.) {
170+
hMahDist2->Scale(1. / hMahDist2->Integral("width"));
171+
auto fitres = hMahDist2->Fit(fchi2Fit, "RMQS");
172+
if (fitres.Get()) {
173+
fitres->Print();
174+
}
175+
}
163176

164177
TFile outFile("plotPulls.root", "RECREATE");
165178
for (int i{0}; i < o2::track::kNParams; ++i) {

0 commit comments

Comments
 (0)