Skip to content

Commit 7b71064

Browse files
committed
ITS: staggered tracking + new vertexer
1 parent e30ce92 commit 7b71064

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5481
-6806
lines changed

DataFormats/Detectors/ITSMFT/ITS/include/DataFormatsITS/TrackITS.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#ifndef ALICEO2_ITS_TRACKITS_H
1717
#define ALICEO2_ITS_TRACKITS_H
1818

19+
#include <cstdint>
1920
#include <vector>
2021

2122
#include "GPUCommonDef.h"
2223
#include "ReconstructionDataFormats/Track.h"
2324
#include "CommonDataFormat/RangeReference.h"
25+
#include "CommonDataFormat/TimeStamp.h"
2426

2527
namespace o2
2628
{
@@ -35,12 +37,12 @@ namespace its
3537
class TrackITS : public o2::track::TrackParCov
3638
{
3739
enum UserBits {
38-
kNextROF = 1 << 28,
3940
kSharedClusters = 1 << 29
4041
};
4142

4243
using Cluster = o2::itsmft::Cluster;
4344
using ClusRefs = o2::dataformats::RangeRefComp<4>;
45+
using Timestamp = o2::dataformats::TimeStampWithError<uint32_t, uint16_t>;
4446

4547
public:
4648
using o2::track::TrackParCov::TrackParCov; // inherit base constructors
@@ -93,6 +95,9 @@ class TrackITS : public o2::track::TrackParCov
9395

9496
bool isBetter(const TrackITS& best, float maxChi2) const;
9597

98+
auto& getTimeStamp() { return mTime; }
99+
const auto& getTimeStamp() const { return mTime; }
100+
96101
GPUhdi() o2::track::TrackParCov& getParamIn() { return *this; }
97102
GPUhdi() const o2::track::TrackParCov& getParamIn() const { return *this; }
98103

@@ -122,8 +127,6 @@ class TrackITS : public o2::track::TrackParCov
122127
}
123128
int getNFakeClusters() const;
124129

125-
void setNextROFbit(bool toggle = true) { mClusterSizes = toggle ? (mClusterSizes | kNextROF) : (mClusterSizes & ~kNextROF); }
126-
bool hasHitInNextROF() const { return mClusterSizes & kNextROF; }
127130
void setSharedClusters(bool toggle = true) { mClusterSizes = toggle ? (mClusterSizes | kSharedClusters) : (mClusterSizes & ~kSharedClusters); }
128131
bool hasSharedClusters() const { return mClusterSizes & kSharedClusters; }
129132

@@ -157,9 +160,10 @@ class TrackITS : public o2::track::TrackParCov
157160
ClusRefs mClusRef; ///< references on clusters
158161
float mChi2 = 0.; ///< Chi2 for this track
159162
uint32_t mPattern = 0; ///< layers pattern
160-
unsigned int mClusterSizes = 0u;
163+
uint32_t mClusterSizes = 0u; ///< packed clamped cluster size
164+
Timestamp mTime; ///< track time stamp with error in BC, defined asymmetrical start + range in BCs
161165

162-
ClassDefNV(TrackITS, 6);
166+
ClassDefNV(TrackITS, 7);
163167
};
164168

165169
class TrackITSExt : public TrackITS
@@ -169,15 +173,13 @@ class TrackITSExt : public TrackITS
169173
static constexpr int MaxClusters = 16; /// Prepare for overlaps and new detector configurations
170174
using TrackITS::TrackITS; // inherit base constructors
171175

172-
GPUh() TrackITSExt(o2::track::TrackParCov&& parCov, short ncl, float chi2,
173-
o2::track::TrackParCov&& outer, std::array<int, MaxClusters> cls)
176+
GPUh() TrackITSExt(o2::track::TrackParCov&& parCov, short ncl, float chi2, o2::track::TrackParCov&& outer, std::array<int, MaxClusters> cls)
174177
: TrackITS(parCov, chi2, outer), mIndex{cls}
175178
{
176179
setNumberOfClusters(ncl);
177180
}
178181

179-
GPUh() TrackITSExt(o2::track::TrackParCov& parCov, short ncl, float chi2, std::uint32_t rof,
180-
o2::track::TrackParCov& outer, std::array<int, MaxClusters> cls)
182+
GPUh() TrackITSExt(o2::track::TrackParCov& parCov, short ncl, float chi2, o2::track::TrackParCov& outer, std::array<int, MaxClusters> cls)
181183
: TrackITS(parCov, chi2, outer), mIndex{cls}
182184
{
183185
setNumberOfClusters(ncl);
@@ -212,7 +214,7 @@ class TrackITSExt : public TrackITS
212214

213215
private:
214216
std::array<int, MaxClusters> mIndex = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; ///< Indices of associated clusters
215-
ClassDefNV(TrackITSExt, 2);
217+
ClassDefNV(TrackITSExt, 3);
216218
};
217219
} // namespace its
218220
} // namespace o2

Detectors/ITSMFT/ITS/macros/test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,8 @@ o2_add_test_root_macro(CheckDROF.C
118118
PUBLIC_LINK_LIBRARIES O2::DataFormatsITS
119119
O2::DataFormatsITSMFT
120120
LABELS its)
121+
122+
o2_add_test_root_macro(CheckSeeding.C
123+
PUBLIC_LINK_LIBRARIES O2::DataFormatsITS
124+
O2::DataFormatsITSMFT
125+
LABELS its)
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#if !defined(__CLING__) || defined(__ROOTCLING__)
13+
#include <vector>
14+
#include <unistd.h>
15+
16+
#include <TF1.h>
17+
#include <TLatex.h>
18+
#include <TSystem.h>
19+
#include <TFile.h>
20+
#include <TTree.h>
21+
#include <TCanvas.h>
22+
#include <TH1F.h>
23+
#include <TH2F.h>
24+
25+
#include "Framework/Logger.h"
26+
#include "ITStracking/Definitions.h"
27+
#include "SimulationDataFormat/MCEventHeader.h"
28+
#include "SimulationDataFormat/MCTrack.h"
29+
#include "SimulationDataFormat/MCCompLabel.h"
30+
#include "SimulationDataFormat/MCTruthContainer.h"
31+
#include "Steer/MCKinematicsReader.h"
32+
#endif
33+
34+
namespace fs = std::filesystem;
35+
void fitGaus(TH1*);
36+
37+
void CheckSeeding(const std::string& trkFileName = "o2trac_its.root", const std::string& colFileName = "collisioncontext.root")
38+
{
39+
fs::path base = fs::current_path();
40+
std::vector<fs::path> dirs;
41+
for (auto& entry : fs::recursive_directory_iterator(base)) {
42+
if (!entry.is_regular_file()) {
43+
continue;
44+
}
45+
if (entry.path().filename() == trkFileName) {
46+
dirs.push_back(entry.path().parent_path());
47+
}
48+
}
49+
std::sort(dirs.begin(), dirs.end());
50+
dirs.erase(std::unique(dirs.begin(), dirs.end()), dirs.end());
51+
52+
LOG(info) << "Found " << dirs.size() << " directories containing " << trkFileName << "\n";
53+
if (dirs.empty()) {
54+
return;
55+
}
56+
57+
const int nBins{100};
58+
const float yRange{0.5}, zRange{18};
59+
auto hVtxX = new TH1F("hVtxX", ";x (cm)", nBins, -yRange, yRange);
60+
auto hVtxY = new TH1F("hVtxY", ";y (cm)", nBins, -yRange, yRange);
61+
auto hVtxZ = new TH1F("hVtxZ", ";z (cm)", nBins, -zRange, zRange);
62+
const float resRange{0.1};
63+
auto hVtxResX = new TH1F("hVtxResX", ";x (cm)", nBins, -resRange, resRange);
64+
auto hVtxResY = new TH1F("hVtxResY", ";y (cm)", nBins, -resRange, resRange);
65+
auto hVtxResZ = new TH1F("hVtxResZ", ";z (cm)", nBins, -resRange, resRange);
66+
const float pullRange{5};
67+
auto hVtxPullX = new TH1F("hVtxPullX", "pull x", nBins, -pullRange, pullRange);
68+
auto hVtxPullY = new TH1F("hVtxPullY", "pull y", nBins, -pullRange, pullRange);
69+
auto hVtxPullZ = new TH1F("hVtxPullZ", "pull z", nBins, -pullRange, pullRange);
70+
71+
auto hVtxEffNumZ = new TH1F("hVtxEffNumZ", ";z (cm);efficiency", nBins, -zRange, zRange);
72+
auto hVtxEffDenZ = new TH1F("hVtxEffDenZ", ";z (cm)", nBins, -zRange, zRange);
73+
auto hVtxPurity = new TH1F("hVtxPurity", ";purity", nBins, 0, 1);
74+
auto hVtxPurityVsNContrib = new TH2F("hVtxPurityVsNContrib", ";purity;contributors", nBins, 0, 1, 150, 0, 150);
75+
auto hVtxNContribVsNPrim = new TH2F("hVtxNContribVsNPrim", ";contributors;nprim", 150, 0, 150, 150, 0, 150);
76+
77+
std::vector<o2::its::Vertex>* vertices{nullptr};
78+
std::vector<o2::MCCompLabel>* verticesLbl{nullptr};
79+
std::vector<float>* verticesPurity{nullptr};
80+
o2::steer::MCKinematicsReader* mcReader{nullptr};
81+
82+
for (const auto& dirPath : dirs) {
83+
std::string dirStr = dirPath.string();
84+
LOG(info) << "Processing directory: " << dirStr << "\n";
85+
86+
// switch working directory to the directory containing the files
87+
if (chdir(dirStr.c_str()) != 0) {
88+
perror("chdir failed");
89+
LOG(info) << "Skipping directory " << dirStr << " due to chdir failure\n";
90+
continue;
91+
}
92+
93+
// open the track ROOT file from this directory
94+
fs::path trkPath = dirPath / trkFileName;
95+
if (!fs::exists(trkPath)) {
96+
LOG(info) << "Missing track file " << trkPath.string() << " (skipping)\n";
97+
continue;
98+
}
99+
100+
TFile* f = TFile::Open(trkPath.string().c_str(), "READ");
101+
if (!f || f->IsZombie()) {
102+
LOG(info) << "Failed to open " << trkPath.string() << " (skipping)\n";
103+
if (f) {
104+
f->Close();
105+
delete f;
106+
}
107+
continue;
108+
}
109+
110+
TTree* trkTree = dynamic_cast<TTree*>(f->Get("o2sim"));
111+
if (!trkTree) {
112+
LOG(info) << "Tree 'o2sim' not found in " << trkPath.string() << " (skipping)\n";
113+
f->Close();
114+
delete f;
115+
continue;
116+
}
117+
118+
vertices = nullptr;
119+
verticesLbl = nullptr;
120+
verticesPurity = nullptr;
121+
trkTree->SetBranchAddress("ITSVertices", &vertices);
122+
trkTree->SetBranchAddress("ITSVertexMCTruth", &verticesLbl);
123+
trkTree->SetBranchAddress("ITSVertexMCPurity", &verticesPurity);
124+
fs::path colPath = dirPath / colFileName;
125+
if (!fs::exists(colPath)) {
126+
LOG(info) << "Collision file not found: " << colPath.string() << " (mcReader will be nullptr)\n";
127+
mcReader = nullptr;
128+
} else {
129+
delete mcReader;
130+
mcReader = new o2::steer::MCKinematicsReader(colPath.string().c_str());
131+
}
132+
133+
Long64_t nEntries = trkTree->GetEntries();
134+
LOG(info) << "Entries in file: " << nEntries << "\n";
135+
136+
for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
137+
trkTree->GetEntry(iEntry);
138+
139+
for (size_t iVtx{0}; iVtx < vertices->size(); ++iVtx) {
140+
const auto& vtx = vertices->at(iVtx);
141+
const auto& vtxLbl = verticesLbl->at(iVtx);
142+
const auto& purity = verticesPurity->at(iVtx);
143+
LOGP(info, "{}: {}", iVtx, vtx.asString());
144+
if (vtxLbl.isValid() && vtxLbl.isCorrect() && mcReader) {
145+
const auto& head = mcReader->getMCEventHeader(vtxLbl.getSourceID(), vtxLbl.getEventID());
146+
LOGP(info, "\t-{}", vtxLbl.asString());
147+
LOGP(info, "\t-Purity:{}", purity);
148+
LOGP(info, "\t-MC: x={} y={} z={} prim={}", head.GetX(), head.GetY(), head.GetZ(), head.GetNPrim());
149+
150+
hVtxX->Fill(vtx.getX());
151+
hVtxY->Fill(vtx.getY());
152+
hVtxZ->Fill(vtx.getZ());
153+
154+
hVtxResX->Fill(vtx.getX() - head.GetX());
155+
hVtxResY->Fill(vtx.getY() - head.GetY());
156+
hVtxResZ->Fill(vtx.getZ() - head.GetZ());
157+
158+
hVtxPullX->Fill((vtx.getX() - head.GetX()) / vtx.getSigmaX());
159+
hVtxPullY->Fill((vtx.getY() - head.GetY()) / vtx.getSigmaY());
160+
hVtxPullZ->Fill((vtx.getZ() - head.GetZ()) / vtx.getSigmaZ());
161+
162+
hVtxEffNumZ->Fill(head.GetZ());
163+
164+
hVtxNContribVsNPrim->Fill(vtx.getNContributors(), head.GetNPrim());
165+
166+
} else {
167+
LOGP(info, "\t-FAKE");
168+
}
169+
170+
hVtxPurity->Fill(purity);
171+
hVtxPurityVsNContrib->Fill(purity, vtx.getNContributors());
172+
}
173+
}
174+
175+
// fill den
176+
for (int iEve{0}; iEve < (int)mcReader->getNEvents(0); ++iEve) {
177+
const auto& head = mcReader->getMCEventHeader(0, iEve);
178+
hVtxEffDenZ->Fill(head.GetZ());
179+
}
180+
181+
if (mcReader) {
182+
delete mcReader;
183+
mcReader = nullptr;
184+
}
185+
trkTree = nullptr;
186+
f->Close();
187+
delete f;
188+
189+
if (chdir(base.string().c_str()) != 0) {
190+
perror("chdir back failed");
191+
}
192+
}
193+
194+
auto c = new TCanvas();
195+
c->Divide(3, 3);
196+
c->cd(1);
197+
hVtxX->Draw();
198+
fitGaus(hVtxX);
199+
gPad->SetLogy();
200+
c->cd(2);
201+
hVtxY->Draw();
202+
fitGaus(hVtxY);
203+
gPad->SetLogy();
204+
c->cd(3);
205+
hVtxZ->Draw();
206+
fitGaus(hVtxZ);
207+
gPad->SetLogy();
208+
c->cd(4);
209+
hVtxResX->Draw();
210+
c->cd(5);
211+
hVtxResY->Draw();
212+
c->cd(6);
213+
hVtxResZ->Draw();
214+
c->cd(7);
215+
hVtxPullX->Draw();
216+
fitGaus(hVtxPullX);
217+
gPad->SetLogy();
218+
c->cd(8);
219+
hVtxPullY->Draw();
220+
fitGaus(hVtxPullY);
221+
gPad->SetLogy();
222+
c->cd(9);
223+
hVtxPullZ->Draw();
224+
fitGaus(hVtxPullZ);
225+
gPad->SetLogy();
226+
c->Draw();
227+
228+
hVtxEffNumZ->Divide(hVtxEffNumZ, hVtxEffDenZ, 1., 1., "B");
229+
c = new TCanvas();
230+
c->Divide(2, 2);
231+
c->cd(1);
232+
hVtxEffNumZ->Draw();
233+
c->cd(2);
234+
hVtxPurity->Draw();
235+
c->cd(3);
236+
hVtxPurityVsNContrib->Draw("colz");
237+
c->cd(4);
238+
hVtxNContribVsNPrim->Draw("colz");
239+
c->Draw();
240+
}
241+
242+
void fitGaus(TH1* h)
243+
{
244+
if (!h) {
245+
return;
246+
}
247+
248+
// fit
249+
TF1* f = new TF1("fG", "gaus");
250+
h->Fit(f, "QMS"); // quiet fit
251+
252+
// draw histogram
253+
h->Draw();
254+
255+
// get parameters
256+
double mean = f->GetParameter(1);
257+
double sigma = f->GetParameter(2);
258+
double chi2 = f->GetChisquare();
259+
double ndf = f->GetNDF();
260+
261+
// add text box
262+
auto t = new TLatex();
263+
t->SetNDC();
264+
t->SetTextSize(0.04);
265+
t->DrawLatex(0.15, 0.85, Form("mean = %.4f", mean));
266+
t->DrawLatex(0.15, 0.80, Form("sigma = %.4f", sigma));
267+
t->DrawLatex(0.15, 0.75, Form("#chi^{2}/ndf = %.2f / %.0f", chi2, ndf));
268+
}

0 commit comments

Comments
 (0)