Skip to content

Commit 4c3df67

Browse files
committed
ITS3: fix and extend some QA macros
Signed-off-by: Felix Schlepper <[email protected]>
1 parent a6e9258 commit 4c3df67

File tree

4 files changed

+212
-189
lines changed

4 files changed

+212
-189
lines changed

Detectors/ITSMFT/ITS/macros/test/CheckTracksCA.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ void CheckTracksCA(bool doEffStud = true,
335335
multiFak->Write("multiFake");
336336
clone->Write("clones");
337337
}
338+
c1->SaveAs("efficiency.png");
339+
c2->SaveAs("vertex.png");
338340
std::cout << " done." << std::endl;
339341
}
340342

@@ -639,6 +641,7 @@ void CheckTracksCA(bool doEffStud = true,
639641
c->cd(25);
640642
doPullCalc(hQoPtPull);
641643
c->Draw();
644+
c->SaveAs("pulls.png");
642645
std::cout << " done\n";
643646
}
644647

Detectors/Upgrades/ITS3/macros/test/CheckClustersITS3.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void CheckClustersITS3(const std::string& clusfile = "o2clus_its.root",
283283
nt.Draw("cgy:cgx>>h_cgy_vs_cgx_OB(1000, -50, 50, 1000, -50, 50)", "id >= 3456", "colz");
284284
canvCgXCgY->cd(4);
285285
nt.Draw("cgy:cgz>>h_cgy_vs_cgz_OB(1000, -100, 100, 1000, -50, 50)", "id >= 3456", "colz");
286-
canvCgXCgY->SaveAs("it3clusters_y_vs_x_vs_z.pdf");
286+
canvCgXCgY->SaveAs("it3clusters_y_vs_x_vs_z.png");
287287

288288
auto canvdXdZ = new TCanvas("canvdXdZ", "", 1600, 800);
289289
canvdXdZ->Divide(2, 2);
@@ -295,7 +295,7 @@ void CheckClustersITS3(const std::string& clusfile = "o2clus_its.root",
295295
nt.Draw("dx:dz>>h_dx_vs_dz_IB_z(1000, -0.01, 0.01, 1000, -0.01, 0.01)", "id < 3456 && abs(cgz) < 2", "colz");
296296
canvdXdZ->cd(4)->SetLogz();
297297
nt.Draw("dx:dz>>h_dx_vs_dz_OB_z(1000, -0.01, 0.01, 1000, -0.01, 0.01)", "id >= 3456 && abs(cgz) < 2", "colz");
298-
canvdXdZ->SaveAs("it3clusters_dx_vs_dz.pdf");
298+
canvdXdZ->SaveAs("it3clusters_dx_vs_dz.png");
299299

300300
auto canvCHXZ = new TCanvas("canvCHXZ", "", 1600, 1600);
301301
canvCHXZ->Divide(2, 2);
@@ -307,7 +307,7 @@ void CheckClustersITS3(const std::string& clusfile = "o2clus_its.root",
307307
nt.Draw("(cgz-hgz)*10000:eta>>h_chz_IB(101,-1.4,1.4,101,-50,50)", "id<3456", "prof");
308308
canvCHXZ->cd(4);
309309
nt.Draw("(cgz-hgz)*10000:eta>>h_chz_OB(101,-1.4,1.4,101,-50,50)", "id>=3456", "prof");
310-
canvCgXCgY->SaveAs("it3clusters_xz_eta.pdf");
310+
canvCgXCgY->SaveAs("it3clusters_xz_eta.png");
311311

312312
auto c1 = new TCanvas("p1", "pullX");
313313
c1->cd();

Detectors/Upgrades/ITS3/macros/test/CheckDCA.C

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
namespace fs = std::filesystem;
5656

57-
constexpr auto mMatCorr{o2::base::Propagator::MatCorrType::USEMatCorrNONE};
57+
constexpr auto mMatCorr{o2::base::Propagator::MatCorrType::USEMatCorrTGeo};
5858
constexpr float mMaxStep{2};
5959

6060
constexpr float rapMax{0.9};
@@ -79,6 +79,7 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
7979
const std::string& tpcTracksFileName = "tpctracks.root",
8080
const std::string& itsTracksFileName = "o2trac_its.root",
8181
const std::string& itstpcTracksFileName = "o2match_itstpc.root",
82+
const std::string& geomFileName = "o2sim_geometry.root",
8283
const std::string& magFileName = "o2sim_grp.root")
8384
{
8485
gROOT->SetBatch();
@@ -88,28 +89,12 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
8889
gStyle->SetPadTickX(1);
8990
gStyle->SetPadTickY(1);
9091
gErrorIgnoreLevel = 2001; // suppress warnings
91-
ProcInfo_t procInfo;
9292

9393
const int nPtBins = 35;
9494
const int nPtBinsEff = 39;
9595
double ptLimits[nPtBins] = {0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2., 2.2, 2.5, 3., 4., 5., 6., 8., 10., 15., 20.};
9696
double ptLimitsEff[nPtBinsEff] = {0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2., 2.2, 2.5, 3., 4., 5., 6., 8., 10., 15., 20.};
9797

98-
const std::regex tf_pattern(R"(tf\d+)");
99-
auto tf_matcher = [&tf_pattern](fs::path const& p) -> bool {
100-
return std::regex_search(p.string(), tf_pattern);
101-
};
102-
auto tf_sorter = [&tf_pattern](fs::path const& a, fs::path const& b) -> bool {
103-
const auto &as = a.string(), &bs = b.string();
104-
std::smatch am, bm;
105-
if (std::regex_search(as, am, tf_pattern) && std::regex_search(bs, bm, tf_pattern)) {
106-
return std::stoi(am.str().substr(2)) < std::stoi(bm.str().substr(2));
107-
} else {
108-
LOGP(fatal, "TF Regex matching failed");
109-
return false;
110-
}
111-
};
112-
11398
const int nSpecies = 4;
11499
std::array<int, nSpecies> pdgCodes{11, 211, 321, 2212};
115100
auto fGaus = new TF1("fGaus", "gaus", -200., 200.);
@@ -119,6 +104,7 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
119104
{321, "Kaons"},
120105
{2212, "Protons"}};
121106
std::map<int, int> colors{{11, kOrange + 7}, {211, kRed + 1}, {321, kAzure + 4}, {2212, kGreen + 2}};
107+
122108
/// ITS
123109
std::map<int, TH1F*> hDcaxyResAllLayersITS = {
124110
{11, new TH1F("hDcaxyResElectronsAllLayersITS", "ITS;#it{p}_{T} (GeV/#it{c});#sigma(DCA_{#it{xy}}) (#mum)", nPtBins - 1, ptLimits)},
@@ -287,6 +273,21 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
287273
o2::dataformats::VertexBase collision;
288274
o2::dataformats::DCA impactParameter;
289275

276+
const std::regex tf_pattern(R"(tf\d+)");
277+
auto tf_matcher = [&tf_pattern](fs::path const& p) -> bool {
278+
return std::regex_search(p.string(), tf_pattern);
279+
};
280+
auto tf_sorter = [&tf_pattern](fs::path const& a, fs::path const& b) -> bool {
281+
const auto &as = a.string(), &bs = b.string();
282+
std::smatch am, bm;
283+
if (std::regex_search(as, am, tf_pattern) && std::regex_search(bs, bm, tf_pattern)) {
284+
return std::stoi(am.str().substr(2)) < std::stoi(bm.str().substr(2));
285+
} else {
286+
LOGP(fatal, "TF Regex matching failed");
287+
return false;
288+
}
289+
};
290+
290291
const auto origWD{fs::current_path()};
291292
const auto tfDirs = find_dirs(fs::current_path(), tf_matcher, tf_sorter);
292293
for (const auto& tfDir : tfDirs) {
@@ -305,16 +306,17 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
305306
static bool initOnce{false};
306307
if (!initOnce) {
307308
initOnce = true;
309+
o2::base::GeometryManager::loadGeometry(geomFileName);
308310
o2::base::Propagator::initFieldFromGRP(magFileName);
309311
bz = o2::base::Propagator::Instance()->getNominalBz();
310312
}
311313

312314
LOGP(info, "Loading ITS Tracks");
313-
auto fITSTracks = TFile::Open(itsTracksFileName.c_str(), "READ");
315+
std::unique_ptr<TFile> fITSTracks(TFile::Open(itsTracksFileName.c_str(), "READ"));
314316
auto tITSTracks = fITSTracks->Get<TTree>("o2sim");
315-
std::vector<o2::its::TrackITS>* itsTracks{nullptr};
317+
auto itsTracks = new std::vector<o2::its::TrackITS>();
316318
tITSTracks->SetBranchAddress("ITSTrack", &itsTracks);
317-
std::vector<o2::MCCompLabel>* itsTrkLab{nullptr};
319+
auto itsTrkLab = new std::vector<o2::MCCompLabel>();
318320
tITSTracks->SetBranchAddress("ITSTrackMCTruth", &itsTrkLab);
319321

320322
for (Long64_t iEntry{0}; tITSTracks->LoadTree(iEntry) >= 0; ++iEntry) {
@@ -367,18 +369,19 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
367369
}
368370

369371
LOGP(info, "Loading ITS-TPC Tracks");
370-
auto fITSTPCTracks = TFile::Open(itstpcTracksFileName.c_str(), "READ");
372+
std::unique_ptr<TFile> fITSTPCTracks(TFile::Open(itstpcTracksFileName.c_str(), "READ"));
371373
auto tITSTPCTracks = fITSTPCTracks->Get<TTree>("matchTPCITS");
372-
std::vector<o2::dataformats::TrackTPCITS>* itstpcTracks{nullptr};
374+
auto itstpcTracks = new std::vector<o2::dataformats::TrackTPCITS>();
373375
tITSTPCTracks->SetBranchAddress("TPCITS", &itstpcTracks);
374-
std::vector<o2::MCCompLabel>* itstpcTrkLab{nullptr};
376+
auto itstpcTrkLab = new std::vector<o2::MCCompLabel>();
375377
tITSTPCTracks->SetBranchAddress("MatchMCTruth", &itstpcTrkLab);
378+
376379
// TPC Tracks
377-
auto fTPCTracks = TFile::Open(tpcTracksFileName.c_str(), "READ");
380+
std::unique_ptr<TFile> fTPCTracks(TFile::Open(tpcTracksFileName.c_str(), "READ"));
378381
auto tTPCTracks = fTPCTracks->Get<TTree>("tpcrec");
379-
std::vector<o2::tpc::TrackTPC>* tpcTracks{nullptr};
382+
auto tpcTracks = new std::vector<o2::tpc::TrackTPC>();
380383
tTPCTracks->SetBranchAddress("TPCTracks", &tpcTracks);
381-
std::vector<o2::MCCompLabel>* tpcTrkLab{nullptr};
384+
auto tpcTrkLab = new std::vector<o2::MCCompLabel>();
382385
tTPCTracks->SetBranchAddress("TPCTracksMCTruth", &tpcTrkLab);
383386
for (Long64_t iEntry{0}; tITSTPCTracks->LoadTree(iEntry) >= 0; ++iEntry) {
384387
tITSTPCTracks->GetEntry(iEntry);
@@ -436,26 +439,10 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
436439
}
437440
}
438441
}
439-
440-
delete itsTracks;
441-
delete itsTrkLab;
442-
delete tpcTracks;
443-
delete tpcTrkLab;
444-
delete itstpcTracks;
445-
delete itstpcTrkLab;
446-
delete tITSTracks;
447-
delete tTPCTracks;
448-
delete tITSTPCTracks;
449-
delete fITSTracks;
450-
delete fTPCTracks;
451-
delete fITSTPCTracks;
452-
453-
gSystem->GetProcInfo(&procInfo);
454-
LOGF(info, "MemVirtual (%ld), MemResident (%ld)", procInfo.fMemVirtual, procInfo.fMemResident);
455-
LOGP(info, "Done with {:?}", tfDir.c_str());
456-
if (procInfo.fMemResident > 200'000'000) {
457-
LOGP(error, "Exceeding 200GBs stopping!");
458-
break;
442+
for (size_t src{0}; src < mcReader.getNSources(); ++src) {
443+
for (size_t eve{0}; eve < mcReader.getNEvents(src); ++eve) {
444+
mcReader.releaseTracksForSourceAndEvent(src, eve);
445+
}
459446
}
460447
}
461448
LOGP(info, "Restoring original CWD to {:?}", origWD.c_str());

0 commit comments

Comments
 (0)