Project
Loading...
Searching...
No Matches
MFTAssessment.h
Go to the documentation of this file.
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
15
16#ifndef ALICEO2_MFT_ASSESSMENT
17#define ALICEO2_MFT_ASSESSMENT
18
19#include <TH1F.h>
20#include <TH2F.h>
21#include <TH3F.h>
22#include <TCanvas.h>
23#include <TEfficiency.h>
24#include <TObjArray.h>
33#include <unordered_map>
34#include <vector>
36#include "MFTTracking/IOUtils.h"
40
41namespace o2
42{
43
44namespace mft
45{
46
54
56using TrackLabelsType = std::vector<o2::MCCompLabel>;
58
60{
61 public:
62 MFTAssessment() = delete;
63 MFTAssessment(bool useMC) : mUseMC(useMC){};
64 ~MFTAssessment() = default;
65
66 void init(bool finalizeAnalysis);
67 void setRefOrbit(uint32_t orbit) { mRefOrbit = orbit; }
68 void createHistos();
70 void processTrackables();
72 void processRecoTracks();
74 void addMCParticletoHistos(const MCTrack* mcTr, const int TrackType, const o2::dataformats::MCEventHeader& evH);
75 void reset();
77 {
78 mTrueTracksMap.resize(mMCReader.getNSources());
79 auto src = 0;
80 for (auto& map : mTrueTracksMap) {
81 map.resize(mMCReader.getNEvents(src++));
82 }
83 auto id = 0;
84 for (const auto& trackLabel : mMFTTrackLabels) {
85 if (trackLabel.isCorrect()) {
86 mTrueTracksMap[trackLabel.getSourceID()][trackLabel.getEventID()].push_back(id);
87 } else {
88 mFakeTracksVec.push_back(id);
89 }
90 id++;
91 }
92 }
93
94 bool loadHistos();
95 void finalizeAnalysis();
96
97 void getHistos(TObjArray& objar);
99 void setBz(float bz) { mBz = bz; }
100 void setClusterDictionary(const o2::itsmft::TopologyDictionary* d) { mDictionary = d; }
101 double orbitToSeconds(uint32_t orbit, uint32_t refOrbit)
102 {
103 return (orbit - refOrbit) * o2::constants::lhc::LHCOrbitNS / 1E9;
104 }
105
106 private:
107 const o2::itsmft::TopologyDictionary* mDictionary = nullptr; // cluster patterns dictionary
108
109 gsl::span<const o2::mft::TrackMFT> mMFTTracks;
110 gsl::span<const o2::itsmft::ROFRecord> mMFTTracksROF;
111 gsl::span<const int> mMFTTrackClusIdx;
112 gsl::span<const o2::itsmft::CompClusterExt> mMFTClusters;
113 gsl::span<const o2::itsmft::ROFRecord> mMFTClustersROF;
114 gsl::span<const unsigned char> mMFTClusterPatterns;
115 gsl::span<const unsigned char>::iterator pattIt;
116 std::vector<o2::BaseCluster<float>> mMFTClustersGlobal;
117
118 std::array<bool, 936> mUnusedChips; // 936 chipIDs in total
119 int mNumberTFs = 0;
120 int mLastTrackType;
121
122 // MC Labels
123 bool mUseMC = false;
124
125 std::unique_ptr<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mMFTClusterLabels;
126 gsl::span<const o2::MCCompLabel> mMFTTrackLabels;
127
128 o2::steer::MCKinematicsReader mMCReader; // reader of MC information
129
130 // Histos for reconstructed tracks
131 std::unique_ptr<TH1F> mTrackNumberOfClusters = nullptr;
132 std::unique_ptr<TH1F> mCATrackNumberOfClusters = nullptr;
133 std::unique_ptr<TH1F> mLTFTrackNumberOfClusters = nullptr;
134 std::unique_ptr<TH1F> mTrackInvQPt = nullptr;
135 std::unique_ptr<TH1F> mTrackChi2 = nullptr;
136 std::unique_ptr<TH1F> mTrackCharge = nullptr;
137 std::unique_ptr<TH1F> mTrackPhi = nullptr;
138 std::unique_ptr<TH1F> mPositiveTrackPhi = nullptr;
139 std::unique_ptr<TH1F> mNegativeTrackPhi = nullptr;
140 std::unique_ptr<TH1F> mTrackEta = nullptr;
141 std::unique_ptr<TH2F> mTrackChi2pT = nullptr;
142
143 std::unique_ptr<TH1F> mMFTClsZ = nullptr;
144 std::unique_ptr<TH1F> mMFTClsOfTracksZ = nullptr;
145
146 std::array<std::unique_ptr<TH2F>, 10> mMFTClsXYinLayer = {nullptr};
147 std::array<std::unique_ptr<TH1F>, 10> mMFTClsRinLayer = {nullptr};
148 std::array<std::unique_ptr<TH2F>, 10> mMFTClsOfTracksXYinLayer = {nullptr};
149 std::array<std::unique_ptr<TH2F>, 5> mMFTClsXYRedundantInDisk = {nullptr};
150
151 std::array<std::unique_ptr<TH1F>, 7> mTrackEtaNCls = {nullptr};
152 std::array<std::unique_ptr<TH1F>, 7> mTrackPhiNCls = {nullptr};
153 std::array<std::unique_ptr<TH2F>, 7> mTrackXYNCls = {nullptr};
154 std::array<std::unique_ptr<TH2F>, 7> mTrackEtaPhiNCls = {nullptr};
155 std::unique_ptr<TH1F> mCATrackEta = nullptr;
156 std::unique_ptr<TH1F> mLTFTrackEta = nullptr;
157 std::unique_ptr<TH1F> mTrackCotl = nullptr;
158
159 std::unique_ptr<TH1F> mTrackROFNEntries = nullptr;
160 std::unique_ptr<TH1F> mClusterROFNEntries = nullptr;
161 std::unique_ptr<TH1F> mTracksBC = nullptr;
162
163 std::unique_ptr<TH1F> mNOfTracksTime = nullptr;
164 std::unique_ptr<TH1F> mNOfClustersTime = nullptr;
165
166 std::unique_ptr<TH1F> mClusterSensorIndex = nullptr;
167 std::unique_ptr<TH1F> mClusterPatternIndex = nullptr;
168
169 // Histos and data for MC analysis
170 std::vector<std::string> mNameOfTrackTypes = {"Rec",
171 "Gen",
172 "Trackable",
173 "RecoTrue",
174 "RecoFake",
175 "RecoTrueMC"};
176
177 std::unique_ptr<TH2F> mHistPhiRecVsPhiGen = nullptr;
178 std::unique_ptr<TH2F> mHistEtaRecVsEtaGen = nullptr;
179
180 std::array<std::unique_ptr<TH2F>, kNumberOfTrackTypes> mHistPhiVsEta;
181 std::array<std::unique_ptr<TH2F>, kNumberOfTrackTypes> mHistPtVsEta;
182 std::array<std::unique_ptr<TH2F>, kNumberOfTrackTypes> mHistPhiVsPt;
183 std::array<std::unique_ptr<TH2F>, kNumberOfTrackTypes> mHistZvtxVsEta;
184 std::array<std::unique_ptr<TH2F>, kNumberOfTrackTypes> mHistRVsZ;
185 std::array<std::unique_ptr<TH1F>, kNumberOfTrackTypes> mHistIsPrimary;
186 std::array<std::unique_ptr<TH1F>, kNumberOfTrackTypes> mHistTrackChi2;
187
188 // Histos for reconstruction assessment
189
190 std::unique_ptr<TEfficiency> mChargeMatchEff = nullptr;
191 std::unique_ptr<TH2F> mHistVxtOffsetProjection = nullptr;
192
193 enum TH3HistosCodes {
194 kTH3TrackDeltaXDeltaYEta,
195 kTH3TrackDeltaXDeltaYPt,
196 kTH3TrackDeltaXVertexPtEta,
197 kTH3TrackDeltaYVertexPtEta,
198 kTH3TrackInvQPtResolutionPtEta,
199 kTH3TrackInvQPtResSeedPtEta,
200 kTH3TrackXPullPtEta,
201 kTH3TrackYPullPtEta,
202 kTH3TrackPhiPullPtEta,
203 kTH3TrackCotlPullPtEta,
204 kTH3TrackInvQPtPullPtEta,
205 kTH3TrackReducedChi2PtEta,
206 kNTH3Histos
207 };
208
209 std::map<int, const char*> TH3Names{
210 {kTH3TrackDeltaXDeltaYEta, "TH3TrackDeltaXDeltaYEta"},
211 {kTH3TrackDeltaXDeltaYPt, "TH3TrackDeltaXDeltaYPt"},
212 {kTH3TrackDeltaXVertexPtEta, "TH3TrackDeltaXVertexPtEta"},
213 {kTH3TrackDeltaYVertexPtEta, "TH3TrackDeltaYVertexPtEta"},
214 {kTH3TrackInvQPtResolutionPtEta, "TH3TrackInvQPtResolutionPtEta"},
215 {kTH3TrackInvQPtResSeedPtEta, "TH3TrackInvQPtResSeedPtEta"},
216 {kTH3TrackXPullPtEta, "TH3TrackXPullPtEta"},
217 {kTH3TrackYPullPtEta, "TH3TrackYPullPtEta"},
218 {kTH3TrackPhiPullPtEta, "TH3TrackPhiPullPtEta"},
219 {kTH3TrackCotlPullPtEta, "TH3TrackCotlPullPtEta"},
220 {kTH3TrackInvQPtPullPtEta, "TH3TrackInvQPtPullPtEta"},
221 {kTH3TrackReducedChi2PtEta, "TH3TrackReducedChi2PtEta"}};
222
223 std::map<int, const char*> TH3Titles{
224 {kTH3TrackDeltaXDeltaYEta, "TH3TrackDeltaXDeltaYEta"},
225 {kTH3TrackDeltaXDeltaYPt, "TH3TrackDeltaXDeltaYPt"},
226 {kTH3TrackDeltaXVertexPtEta, "TH3TrackDeltaXVertexPtEta"},
227 {kTH3TrackDeltaYVertexPtEta, "TH3TrackDeltaYVertexPtEta"},
228 {kTH3TrackInvQPtResolutionPtEta, "TH3TrackInvQPtResolutionPtEta"},
229 {kTH3TrackInvQPtResSeedPtEta, "TH3TrackInvQPtResSeedPtEta"},
230 {kTH3TrackXPullPtEta, "TH3TrackXPullPtEta"},
231 {kTH3TrackYPullPtEta, "TH3TrackYPullPtEta"},
232 {kTH3TrackPhiPullPtEta, "TH3TrackPhiPullPtEta"},
233 {kTH3TrackCotlPullPtEta, "TH3TrackCotlPullPtEta"},
234 {kTH3TrackInvQPtPullPtEta, "TH3TrackInvQPtPullPtEta"},
235 {kTH3TrackReducedChi2PtEta, "TH3TrackReducedChi2PtEta"}};
236
237 std::map<int, std::array<double, 9>> TH3Binning{
238 {kTH3TrackDeltaXDeltaYEta, {16, -3.8, -2.2, 1000, -1000, 1000, 1000, -1000, 1000}},
239 {kTH3TrackDeltaXDeltaYPt, {100, 0, 20, 1000, -1000, 1000, 1000, -1000, 1000}},
240 {kTH3TrackDeltaYVertexPtEta, {100, 0, 20, 16, -3.8, -2.2, 1000, -1000, 1000}},
241 {kTH3TrackDeltaXVertexPtEta, {100, 0, 20, 16, -3.8, -2.2, 1000, -1000, 1000}},
242 {kTH3TrackInvQPtResolutionPtEta, {100, 0, 20, 16, -3.8, -2.2, 1000, -50, 50}},
243 {kTH3TrackInvQPtResSeedPtEta, {100, 0, 20, 16, -3.8, -2.2, 1000, -50, 50}},
244 {kTH3TrackXPullPtEta, {100, 0, 20, 16, -3.8, -2.2, 200, -10, 10}},
245 {kTH3TrackYPullPtEta, {100, 0, 20, 16, -3.8, -2.2, 200, -10, 10}},
246 {kTH3TrackPhiPullPtEta, {100, 0, 20, 16, -3.8, -2.2, 200, -10, 10}},
247 {kTH3TrackCotlPullPtEta, {100, 0, 20, 16, -3.8, -2.2, 200, -10, 10}},
248 {kTH3TrackInvQPtPullPtEta, {100, 0, 20, 16, -3.8, -2.2, 1000, -15, 15}},
249 {kTH3TrackReducedChi2PtEta, {100, 0, 20, 16, -3.8, -2.2, 1000, 0, 100}}};
250
251 std::map<int, const char*> TH3XaxisTitles{
252 {kTH3TrackDeltaXDeltaYEta, R"(\\eta)"},
253 {kTH3TrackDeltaXDeltaYPt, R"(p_{t})"},
254 {kTH3TrackDeltaXVertexPtEta, R"(p_{t})"},
255 {kTH3TrackDeltaYVertexPtEta, R"(p_{t})"},
256 {kTH3TrackInvQPtResolutionPtEta, R"(p_{t})"},
257 {kTH3TrackInvQPtResSeedPtEta, R"(p_{t})"},
258 {kTH3TrackXPullPtEta, R"(p_{t})"},
259 {kTH3TrackYPullPtEta, R"(p_{t})"},
260 {kTH3TrackPhiPullPtEta, R"(p_{t})"},
261 {kTH3TrackCotlPullPtEta, R"(p_{t})"},
262 {kTH3TrackInvQPtPullPtEta, R"(p_{t})"},
263 {kTH3TrackReducedChi2PtEta, R"(p_{t})"}};
264
265 std::map<int, const char*> TH3YaxisTitles{
266 {kTH3TrackDeltaXDeltaYEta, R"(X_{residual \rightarrow vtx} (\mu m))"},
267 {kTH3TrackDeltaXDeltaYPt, R"(X_{residual \rightarrow vtx} (\mu m))"},
268 {kTH3TrackDeltaXVertexPtEta, R"(\eta)"},
269 {kTH3TrackDeltaYVertexPtEta, R"(\eta)"},
270 {kTH3TrackInvQPtResolutionPtEta, R"(\eta)"},
271 {kTH3TrackInvQPtResSeedPtEta, R"(\eta)"},
272 {kTH3TrackXPullPtEta, R"(\eta)"},
273 {kTH3TrackYPullPtEta, R"(\eta)"},
274 {kTH3TrackPhiPullPtEta, R"(\eta)"},
275 {kTH3TrackCotlPullPtEta, R"(\eta)"},
276 {kTH3TrackInvQPtPullPtEta, R"(\eta)"},
277 {kTH3TrackReducedChi2PtEta, R"(\eta)"}};
278
279 std::map<int, const char*> TH3ZaxisTitles{
280 {kTH3TrackDeltaXDeltaYEta, R"(Y_{residual \rightarrow vtx} (\mu m))"},
281 {kTH3TrackDeltaXDeltaYPt, R"(Y_{residual \rightarrow vtx} (\mu m))"},
282 {kTH3TrackDeltaXVertexPtEta, R"(X_{residual \rightarrow vtx} (\mu m))"},
283 {kTH3TrackDeltaYVertexPtEta, R"(Y_{residual \rightarrow vtx} (\mu m))"},
284 {kTH3TrackInvQPtResolutionPtEta, R"((q/p_{t})_{residual}/(q/p_{t}))"},
285 {kTH3TrackInvQPtResSeedPtEta, R"((q/p_{t})_{residual}/(q/p_{t}))"},
286 {kTH3TrackXPullPtEta, R"(\Delta X/\sigma_{X})"},
287 {kTH3TrackYPullPtEta, R"(\Delta Y/\sigma_{Y})"},
288 {kTH3TrackPhiPullPtEta, R"(\Delta \phi/\sigma_{\phi})"},
289 {kTH3TrackCotlPullPtEta, R"(\Delta \cot(\lambda)/\sigma_{cot(\lambda)})"},
290 {kTH3TrackInvQPtPullPtEta, R"((\Delta q/p_t)/\sigma_{q/p_{t}})"},
291 {kTH3TrackReducedChi2PtEta, R"(\chi^2/d.f.)"}};
292
293 enum TH3SlicedCodes {
294 kDeltaXVertexVsEta,
295 kDeltaXVertexVsPt,
296 kDeltaYVertexVsEta,
297 kDeltaYVertexVsPt,
298 kXPullVsEta,
299 kXPullVsPt,
300 kYPullVsEta,
301 kYPullVsPt,
302 kInvQPtResVsEta,
303 kInvQPtResVsPt,
304 kInvQPtResSeedVsEta,
305 kInvQPtResSeedVsPt,
306 kPhiPullVsEta,
307 kPhiPullVsPt,
308 kCotlPullVsEta,
309 kCotlPullVsPt,
310 kInvQPtPullVsEta,
311 kInvQPtPullVsPt,
312 kNSlicedTH3
313 };
314
315 std::map<int, const char*> TH3SlicedNames{
316 {kDeltaXVertexVsEta, "DeltaXVertexVsEta"},
317 {kDeltaXVertexVsPt, "DeltaXVertexVsPt"},
318 {kDeltaYVertexVsEta, "DeltaYVertexVsEta"},
319 {kDeltaYVertexVsPt, "DeltaYVertexVsPt"},
320 {kXPullVsEta, "XPullVsEta"},
321 {kXPullVsPt, "XPullVsPt"},
322 {kYPullVsEta, "YPullVsEta"},
323 {kYPullVsPt, "YPullVsPt"},
324 {kInvQPtResVsEta, "InvQPtResVsEta"},
325 {kInvQPtResVsPt, "InvQPtResVsPt"},
326 {kInvQPtResSeedVsEta, "InvQPtResSeedVsEta"},
327 {kInvQPtResSeedVsPt, "InvQPtResSeedVsPt"},
328 {kPhiPullVsEta, "PhiPullVsEta"},
329 {kPhiPullVsPt, "PhiPullVsPt"},
330 {kCotlPullVsEta, "CotlPullVsEta"},
331 {kCotlPullVsPt, "CotlPullVsPt"},
332 {kInvQPtPullVsEta, "InvQPtPullVsEta"},
333 {kInvQPtPullVsPt, "InvQPtPullVsPt"}};
334
335 std::map<int, int> TH3SlicedMap{
336 {kDeltaXVertexVsEta, kTH3TrackDeltaXVertexPtEta},
337 {kDeltaXVertexVsPt, kTH3TrackDeltaXVertexPtEta},
338 {kDeltaYVertexVsEta, kTH3TrackDeltaYVertexPtEta},
339 {kDeltaYVertexVsPt, kTH3TrackDeltaYVertexPtEta},
340 {kXPullVsEta, kTH3TrackXPullPtEta},
341 {kXPullVsPt, kTH3TrackXPullPtEta},
342 {kYPullVsEta, kTH3TrackYPullPtEta},
343 {kYPullVsPt, kTH3TrackYPullPtEta},
344 {kInvQPtResVsEta, kTH3TrackInvQPtResolutionPtEta},
345 {kInvQPtResVsPt, kTH3TrackInvQPtResolutionPtEta},
346 {kInvQPtResSeedVsEta, kTH3TrackInvQPtResSeedPtEta},
347 {kInvQPtResSeedVsPt, kTH3TrackInvQPtResSeedPtEta},
348 {kPhiPullVsEta, kTH3TrackPhiPullPtEta},
349 {kPhiPullVsPt, kTH3TrackPhiPullPtEta},
350 {kCotlPullVsEta, kTH3TrackCotlPullPtEta},
351 {kCotlPullVsPt, kTH3TrackCotlPullPtEta},
352 {kInvQPtPullVsEta, kTH3TrackInvQPtPullPtEta},
353 {kInvQPtPullVsPt, kTH3TrackInvQPtPullPtEta}};
354
355 std::array<std::unique_ptr<TH3F>, kNTH3Histos> mTH3Histos;
356 std::array<TCanvas*, kNSlicedTH3> mSlicedCanvas;
357 void TH3Slicer(TCanvas* canvas, std::unique_ptr<TH3F>& histo3D, std::vector<float> list, double window, int iPar, float marker_size = 1.5);
358
359 std::unordered_map<o2::MCCompLabel, bool> mMFTTrackables;
360 std::vector<std::vector<std::vector<int>>> mTrueTracksMap; // Maps srcIDs and eventIDs to true reco tracks
361 std::vector<int> mFakeTracksVec; // IDs of fake MFT tracks
362 std::vector<std::vector<std::vector<o2::MCCompLabel>>> mTrackableTracksMap; // Maps srcIDs and eventIDs to trackable tracks
363
364 static constexpr std::array<short, 7> sMinNClustersList = {4, 5, 6, 7, 8, 9, 10};
365 uint32_t mRefOrbit = 0; // Reference orbit used in relative time calculation
366 float mBz = 0;
367 bool mFinalizeAnalysis = false;
368
369 o2::itsmft::ChipMappingMFT mMFTChipMapper;
370
371 ClassDefNV(MFTAssessment, 1);
372};
373
374} // namespace mft
375} // namespace o2
376
377#endif
Definition of the ITS/MFT clusterer settings.
Definition of the ITSMFT compact cluster.
Definition of the ClusterTopology class.
Definition of the Names Generator class.
uint64_t orbit
Definition RawEventData.h:6
Load pulled clusters, for a given read-out-frame, in a dedicated container.
Definition of the ITSMFT ROFrame (trigger) record.
Definition of the MCTrack class.
void addMCParticletoHistos(const MCTrack *mcTr, const int TrackType, const o2::dataformats::MCEventHeader &evH)
void runASyncQC(o2::framework::ProcessingContext &ctx)
void init(bool finalizeAnalysis)
double orbitToSeconds(uint32_t orbit, uint32_t refOrbit)
void setRefOrbit(uint32_t orbit)
void setClusterDictionary(const o2::itsmft::TopologyDictionary *d)
void getHistos(TObjArray &objar)
size_t getNEvents(int source) const
Get number of events.
size_t getNSources() const
Get number of sources.
GLenum src
Definition glcorearb.h:1767
constexpr double LHCOrbitNS
@ kNumberOfTrackTypes
std::vector< o2::MCCompLabel > TrackLabelsType
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition list.h:40