Project
Loading...
Searching...
No Matches
Efficiency.cxx
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#include "TGeoGlobalMagField.h"
22#include "Framework/Task.h"
24#include "ITStracking/IOUtils.h"
29
30#include <TEfficiency.h>
31#include <TH1.h>
32#include <TH1D.h>
33#include <TH1I.h>
34#include <TH2D.h>
35#include <TH3D.h>
36#include <TCanvas.h>
37#include <TEfficiency.h>
38#include <TStyle.h>
39#include <TLegend.h>
40#include <TGraphErrors.h>
41#include <TGraphAsymmErrors.h>
42#include <TF1.h>
43#include <TObjArray.h>
44#include <THStack.h>
45#include <TString.h>
46#include <numeric>
47
48#define NLAYERS 3
49
50namespace o2::its::study
51{
52using namespace o2::framework;
53using namespace o2::globaltracking;
54
56
57class EfficiencyStudy : public Task
58{
59 public:
60 EfficiencyStudy(std::shared_ptr<DataRequest> dr,
61 mask_t src,
62 bool useMC,
63 std::shared_ptr<o2::steer::MCKinematicsReader> kineReader,
64 std::shared_ptr<o2::base::GRPGeomRequest> gr) : mDataRequest(dr), mTracksSrc(src), mUseMC(useMC), mKineReader(kineReader), mGGCCDBRequest(gr){};
65
66 ~EfficiencyStudy() final = default;
67 void init(InitContext&) final;
68 void run(ProcessingContext&) final;
70 void finaliseCCDB(ConcreteDataMatcher&, void*) final;
71 void initialiseRun(o2::globaltracking::RecoContainer&);
72 void stileEfficiencyGraph(std::unique_ptr<TEfficiency>& eff, const char* name, const char* title, bool bidimensional, const int markerStyle, const double markersize, const int markercolor, const int linercolor);
73 int getDCAClusterTrackMC(int countDuplicated);
74 void studyDCAcutsMC();
77 void getEfficiency(bool isMC);
78 void getEfficiencyAndTrackInfo(bool isMC);
79 void saveDataInfo();
80 void process(o2::globaltracking::RecoContainer&);
81 void setClusterDictionary(const o2::itsmft::TopologyDictionary* d) { mDict = d; }
82
83 private:
84 void updateTimeDependentParams(ProcessingContext& pc);
85 bool mVerboseOutput = false;
86 bool mUseMC;
87 std::string mOutFileName;
88 double b;
89 std::shared_ptr<o2::steer::MCKinematicsReader> mKineReader;
90 GeometryTGeo* mGeometry;
91 const o2::itsmft::TopologyDictionary* mDict = nullptr;
92 float mrangesPt[NLAYERS][2] = {{0., 0.5}, {0.5, 2.}, {2., 7.5}};
93
94 // Spans
95 gsl::span<const o2::itsmft::ROFRecord> mTracksROFRecords;
96 gsl::span<const o2::itsmft::ROFRecord> mClustersROFRecords;
97 gsl::span<const o2::its::TrackITS> mTracks;
98 gsl::span<const o2::MCCompLabel> mTracksMCLabels;
99 gsl::span<const o2::itsmft::CompClusterExt> mClusters;
100 gsl::span<const unsigned char> mClusPatterns;
101 gsl::span<const int> mInputITSidxs;
102 const o2::dataformats::MCLabelContainer* mClustersMCLCont;
103 std::vector<o2::BaseCluster<float>> mITSClustersArray;
104
105 // Data
106 GTrackID::mask_t mTracksSrc{};
107 std::shared_ptr<DataRequest> mDataRequest;
108 unsigned short mMask = 0x7f;
109
110 // Utils
111 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
112 std::unique_ptr<TFile> mOutFile;
113 int mDuplicated_layer[NLAYERS] = {0};
114 const o2::parameters::GRPMagField* mGRPMagField = nullptr;
115
117 // Distance betweeen original and duplicated clusters
118 std::unique_ptr<TH1D> mDistanceClustersX[NLAYERS];
119 std::unique_ptr<TH1D> mDistanceClustersY[NLAYERS];
120 std::unique_ptr<TH1D> mDistanceClustersZ[NLAYERS];
121 std::unique_ptr<TH1D> mDistanceClusters[NLAYERS];
122 // DCA betweeen track and original cluster
123 std::unique_ptr<TH1D> mDCAxyOriginal[NLAYERS];
124 std::unique_ptr<TH1D> mDCAzOriginal[NLAYERS];
125 // DCA betweeen track and duplicated cluster
126 std::unique_ptr<TH1D> mDCAxyDuplicated;
127 std::unique_ptr<TH1D> mDCAzDuplicated;
128
129 // DCA betweeen track and duplicated cluster per layer
130 std::unique_ptr<TH1D> mDCAxyDuplicated_layer[NLAYERS];
131 std::unique_ptr<TH1D> mDCAzDuplicated_layer[NLAYERS];
132
133 // phi, eta, pt of the cluster
134 std::unique_ptr<TH1D> mPhiOriginal[NLAYERS];
135 std::unique_ptr<TH1D> mPhiTrackOriginal[NLAYERS];
136 std::unique_ptr<TH1D> mEtaOriginal[NLAYERS];
137 std::unique_ptr<TH1D> mPtOriginal[NLAYERS];
138 TH1D* mPtDuplicated[NLAYERS];
139 TH1D* mEtaDuplicated[NLAYERS];
140 TH1D* mPhiDuplicated[NLAYERS];
141 TH1D* mPhiTrackDuplicated[NLAYERS];
142 TH2D* mPhiTrackDuplicatedvsphiDuplicated[NLAYERS];
143 TH2D* mPhiTrackoriginalvsphioriginal[NLAYERS];
144 TH1D* mPhiOriginalIfDuplicated[NLAYERS];
145
146 std::unique_ptr<TH2D> mZvsPhiDUplicated[NLAYERS];
147
148 // position of the clusters
149 std::unique_ptr<TH3D> m3DClusterPositions;
150 std::unique_ptr<TH3D> m3DDuplicatedClusterPositions;
151 std::unique_ptr<TH2D> m2DClusterOriginalPositions;
152 std::unique_ptr<TH2D> m2DClusterDuplicatedPositions;
153
154 std::unique_ptr<TH1D> mXoriginal;
155 std::unique_ptr<TH1D> mYoriginal;
156 std::unique_ptr<TH1D> mZoriginal;
157 std::unique_ptr<TH1D> mXduplicated;
158 std::unique_ptr<TH1D> mYduplicated;
159 std::unique_ptr<TH1D> mZduplicated;
160
161 // Efficiency histos
162 std::unique_ptr<TH1D> mEfficiencyGoodMatch;
163 std::unique_ptr<TH1D> mEfficiencyFakeMatch;
164 std::unique_ptr<TH1D> mEfficiencyTotal;
165 std::unique_ptr<TH1D> mEfficiencyGoodMatch_layer[NLAYERS];
166 std::unique_ptr<TH1D> mEfficiencyFakeMatch_layer[NLAYERS];
167 std::unique_ptr<TH1D> mEfficiencyTotal_layer[NLAYERS];
168 TH2D* mEfficiencyGoodMatchPt_layer[NLAYERS];
169 TH2D* mEfficiencyFakeMatchPt_layer[NLAYERS];
170 TH2D* mEfficiencyGoodMatchEta_layer[NLAYERS];
171 TH2D* mEfficiencyFakeMatchEta_layer[NLAYERS];
172 TH2D* mEfficiencyGoodMatchPhi_layer[NLAYERS];
173 TH2D* mEfficiencyGoodMatchPhiTrack_layer[NLAYERS];
174 TH2D* mEfficiencyGoodMatchPhiOriginal_layer[NLAYERS];
175 TH2D* mEfficiencyFakeMatchPhi_layer[NLAYERS];
176 TH2D* mEfficiencyFakeMatchPhiTrack_layer[NLAYERS];
177
178 // phi, eta, pt of the duplicated cluster per layer
179 TH2D* mPt_EtaDupl[NLAYERS];
180
181 // duplicated per layer and per cut
182 std::unique_ptr<TH1D> mDuplicatedEtaAllPt[NLAYERS];
183 std::unique_ptr<TH1D> mDuplicatedEta[NLAYERS][3];
184 std::unique_ptr<TH1D> mDuplicatedPhiAllPt[NLAYERS];
185 std::unique_ptr<TH1D> mDuplicatedPhi[NLAYERS][3];
186 TH1D* mDuplicatedPt[NLAYERS];
187 TH1D* mDuplicatedRow[NLAYERS];
188 TH2D* mDuplicatedPtEta[NLAYERS];
189 TH2D* mDuplicatedPtPhi[NLAYERS];
190 TH2D* mDuplicatedEtaPhi[NLAYERS];
191
192 // matches per layer and per cut
193 std::unique_ptr<TH1D> mNGoodMatchesEtaAllPt[NLAYERS];
194 std::unique_ptr<TH1D> mNGoodMatchesEta[NLAYERS][3];
195 std::unique_ptr<TH1D> mNGoodMatchesPhiAllPt[NLAYERS];
196 std::unique_ptr<TH1D> mNGoodMatchesPhi[NLAYERS][3];
197
198 std::unique_ptr<TH1D> mNFakeMatchesEtaAllPt[NLAYERS];
199 std::unique_ptr<TH1D> mNFakeMatchesEta[NLAYERS][3];
200 std::unique_ptr<TH1D> mNFakeMatchesPhiAllPt[NLAYERS];
201 std::unique_ptr<TH1D> mNFakeMatchesPhi[NLAYERS][3];
202
203 TH1D* mNGoodMatchesPt[NLAYERS];
204 TH1D* mNFakeMatchesPt[NLAYERS];
205
206 TH1D* mNGoodMatchesRow[NLAYERS];
207 TH1D* mNFakeMatchesRow[NLAYERS];
208
209 TH2D* mNGoodMatchesPtEta[NLAYERS];
210 TH2D* mNFakeMatchesPtEta[NLAYERS];
211
212 TH2D* mNGoodMatchesPtPhi[NLAYERS];
213 TH2D* mNFakeMatchesPtPhi[NLAYERS];
214
215 TH2D* mNGoodMatchesEtaPhi[NLAYERS];
216 TH2D* mNFakeMatchesEtaPhi[NLAYERS];
217
218 // calculating the efficiency with TEfficiency class
219 std::unique_ptr<TEfficiency> mEffPtGood[NLAYERS];
220 std::unique_ptr<TEfficiency> mEffPtFake[NLAYERS];
221 std::unique_ptr<TEfficiency> mEffRowGood[NLAYERS];
222 std::unique_ptr<TEfficiency> mEffRowFake[NLAYERS];
223 std::unique_ptr<TEfficiency> mEffPtEtaGood[NLAYERS];
224 std::unique_ptr<TEfficiency> mEffPtEtaFake[NLAYERS];
225 std::unique_ptr<TEfficiency> mEffPtPhiGood[NLAYERS];
226 std::unique_ptr<TEfficiency> mEffPtPhiFake[NLAYERS];
227 std::unique_ptr<TEfficiency> mEffEtaPhiGood[NLAYERS];
228 std::unique_ptr<TEfficiency> mEffEtaPhiFake[NLAYERS];
229
230 std::unique_ptr<TEfficiency> mEffEtaGoodAllPt[NLAYERS];
231 std::unique_ptr<TEfficiency> mEffEtaGood[NLAYERS][3];
232 std::unique_ptr<TEfficiency> mEffEtaFakeAllPt[NLAYERS];
233 std::unique_ptr<TEfficiency> mEffEtaFake[NLAYERS][3];
234
235 std::unique_ptr<TEfficiency> mEffPhiGoodAllPt[NLAYERS];
236 std::unique_ptr<TEfficiency> mEffPhiGood[NLAYERS][3];
237 std::unique_ptr<TEfficiency> mEffPhiFakeAllPt[NLAYERS];
238 std::unique_ptr<TEfficiency> mEffPhiFake[NLAYERS][3];
239
240 TH2D* mnGoodMatchesPt_layer[NLAYERS];
241 TH2D* mnFakeMatchesPt_layer[NLAYERS];
242
243 TH2D* mnGoodMatchesEta_layer[NLAYERS];
244 TH2D* mnFakeMatchesEta_layer[NLAYERS];
245
246 TH2D* mnGoodMatchesPhi_layer[NLAYERS];
247 TH2D* mnGoodMatchesPhiTrack_layer[NLAYERS];
248 TH2D* mnGoodMatchesPhiOriginal_layer[NLAYERS];
249 TH2D* mnFakeMatchesPhi_layer[NLAYERS];
250 TH2D* mnFakeMatchesPhiTrack_layer[NLAYERS];
251
252 std::unique_ptr<TH1D> DCAxyData[NLAYERS];
253 std::unique_ptr<TH1D> DCAzData[NLAYERS];
254
255 std::unique_ptr<TH1D> DCAxyRejected[NLAYERS];
256 std::unique_ptr<TH1D> DCAzRejected[NLAYERS];
257
258 std::unique_ptr<TH1D> DistanceClustersX[NLAYERS];
259 std::unique_ptr<TH1D> DistanceClustersY[NLAYERS];
260 std::unique_ptr<TH1D> DistanceClustersZ[NLAYERS];
261 std::unique_ptr<TH1D> DistanceClustersXAftercuts[NLAYERS];
262 std::unique_ptr<TH1D> DistanceClustersYAftercuts[NLAYERS];
263 std::unique_ptr<TH1D> DistanceClustersZAftercuts[NLAYERS];
264
265 TH1D* denPt[NLAYERS];
266 TH1D* numPt[NLAYERS];
267 TH1D* numPtGood[NLAYERS];
268 TH1D* numPtFake[NLAYERS];
269
270 TH1D* denPhi[NLAYERS];
271 TH1D* numPhi[NLAYERS];
272 TH1D* numPhiGood[NLAYERS];
273 TH1D* numPhiFake[NLAYERS];
274
275 TH1D* denEta[NLAYERS];
276 TH1D* numEta[NLAYERS];
277 TH1D* numEtaGood[NLAYERS];
278 TH1D* numEtaFake[NLAYERS];
279
280 int nDuplicatedClusters[NLAYERS] = {0};
281 int nTracksSelected[NLAYERS] = {0}; // denominator fot the efficiency calculation
282
283 TH2D* diffPhivsPt[NLAYERS];
284 TH1D* diffTheta[NLAYERS];
285
286 TH1D* thetaOriginal[NLAYERS];
287 TH1D* thetaOriginalCalc[NLAYERS];
288 TH1D* thetaDuplicated[NLAYERS];
289 TH1D* thetaOriginalCalcWhenDuplicated[NLAYERS];
290 TH1D* thetaOriginalWhenDuplicated[NLAYERS];
291
292 std::unique_ptr<TH1D> IPOriginalxy[NLAYERS];
293 std::unique_ptr<TH1D> IPOriginalz[NLAYERS];
294 std::unique_ptr<TH1D> IPOriginalifDuplicatedxy[NLAYERS];
295 std::unique_ptr<TH1D> IPOriginalifDuplicatedz[NLAYERS];
296
297 std::unique_ptr<TH1D> chipRowDuplicated[NLAYERS];
298 std::unique_ptr<TH1D> chipRowOriginalIfDuplicated[NLAYERS];
299
300 std::unique_ptr<TH1D> chi2track;
301 std::unique_ptr<TH1D> chi2trackAccepted;
302};
303
305{
306 LOGP(info, "--------------- init");
307
309
311 mOutFileName = pars.outFileName;
312 b = pars.b;
313
314 int nbPt = 75;
315 double xbins[nbPt + 1], ptcutl = 0.05, ptcuth = 7.5;
316 double a = std::log(ptcuth / ptcutl) / nbPt;
317 for (int i = 0; i <= nbPt; i++) {
318 xbins[i] = ptcutl * std::exp(i * a);
319 }
320
321 mOutFile = std::make_unique<TFile>(mOutFileName.c_str(), "recreate");
322
323 mXoriginal = std::make_unique<TH1D>("xoriginal", "x original ;x (cm); ", 200, 0, 0);
324 mYoriginal = std::make_unique<TH1D>("yoriginal", "y original ;y (cm); ", 200, 0, 0);
325 mZoriginal = std::make_unique<TH1D>("zoriginal", "z original ;z (cm); ", 300, 0, 0);
326 mXduplicated = std::make_unique<TH1D>("xduplicated", "x duplicated ;x (cm); ", 200, -10, 10);
327 mYduplicated = std::make_unique<TH1D>("yduplicated", "y duplicated ;y (cm); ", 200, -10, 10);
328 mZduplicated = std::make_unique<TH1D>("zduplicated", "z duplicated ;z (cm); ", 300, -30, 30);
329
330 mDCAxyDuplicated = std::make_unique<TH1D>("dcaXYDuplicated", "Distance between track and duplicated cluster ;DCA xy (cm); ", 400, -0.2, 0.2);
331 mDCAzDuplicated = std::make_unique<TH1D>("dcaZDuplicated", "Distance between track and duplicated cluster ;DCA z (cm); ", 400, -0.2, 0.2);
332
333 m3DClusterPositions = std::make_unique<TH3D>("3DClusterPositions", ";x (cm);y (cm);z (cm)", 200, -10, 10, 200, -10, 10, 400, -20, 20);
334 m3DDuplicatedClusterPositions = std::make_unique<TH3D>("3DDuplicatedClusterPositions", ";x (cm);y (cm);z (cm)", 200, -10, 10, 200, -10, 10, 500, -30, 30);
335 m2DClusterOriginalPositions = std::make_unique<TH2D>("m2DClusterOriginalPositions", ";x (cm);y (cm)", 400, -10, 10, 400, -6, 6);
336 m2DClusterDuplicatedPositions = std::make_unique<TH2D>("m2DClusterDuplicatedPositions", ";x (cm);y (cm)", 400, -10, 10, 400, -6, 6);
337
338 mEfficiencyGoodMatch = std::make_unique<TH1D>("mEfficiencyGoodMatch", ";#sigma(DCA) cut;Efficiency;", 20, 0.5, 20.5);
339 mEfficiencyFakeMatch = std::make_unique<TH1D>("mEfficiencyFakeMatch", ";#sigma(DCA) cut;Efficiency;", 20, 0.5, 20.5);
340 mEfficiencyTotal = std::make_unique<TH1D>("mEfficiencyTotal", ";#sigma(DCA) cut;Efficiency;", 20, 0.5, 20.5);
341
342 chi2track = std::make_unique<TH1D>("chi2track", "; $chi^{2}", 500, 0, 100);
343 chi2trackAccepted = std::make_unique<TH1D>("chi2trackAccepted", "; $chi^{2}", 500, 0, 100);
344
345 for (int i = 0; i < NLAYERS; i++) {
346
347 chipRowDuplicated[i] = std::make_unique<TH1D>(Form("chipPosDuplicated_L%d", i), Form("L%d; row", i), 512, -0.5, 511.5);
348 chipRowOriginalIfDuplicated[i] = std::make_unique<TH1D>(Form("chipPosOriginalIfDuplicated%d", i), Form("L%d; row", i), 512, -0.5, 511.5);
349
350 DCAxyData[i] = std::make_unique<TH1D>(Form("dcaXYData_L%d", i), "Distance between track and original cluster ;DCA xy (cm); ", 4000, -2, 2);
351 DCAzData[i] = std::make_unique<TH1D>(Form("dcaZData_L%d", i), "Distance between track and original cluster ;DCA z (cm); ", 4000, -2, 2);
352 DCAxyRejected[i] = std::make_unique<TH1D>(Form("DCAxyRejected%d", i), "Distance between track and original cluster (rejected) ;DCA xy (cm); ", 30000, -30, 30);
353 DCAzRejected[i] = std::make_unique<TH1D>(Form("DCAzRejected%d", i), "Distance between track and original cluster (rejected) ;DCA z (cm); ", 30000, -30, 30);
354
355 DistanceClustersX[i] = std::make_unique<TH1D>(Form("distanceClustersX_L%d", i), ";Distance x (cm); ", 100, 0, 1);
356 DistanceClustersY[i] = std::make_unique<TH1D>(Form("distanceClustersY_L%d", i), ";Distance y (cm); ", 100, 0, 1);
357 DistanceClustersZ[i] = std::make_unique<TH1D>(Form("distanceClustersZ_L%d", i), ";Distance z (cm); ", 100, 0, 1);
358 DistanceClustersXAftercuts[i] = std::make_unique<TH1D>(Form("distanceClustersXAftercuts_L%d", i), ";Distance x (cm); ", 100, 0, 1);
359 DistanceClustersYAftercuts[i] = std::make_unique<TH1D>(Form("distanceClustersYAftercuts_L%d", i), ";Distance y (cm); ", 100, 0, 1);
360 DistanceClustersZAftercuts[i] = std::make_unique<TH1D>(Form("distanceClustersZAftercuts_L%d", i), ";Distance z (cm); ", 100, 0, 1);
361
362 mDistanceClustersX[i] = std::make_unique<TH1D>(Form("distanceClustersX_L%d", i), ";Distance x (cm); ", 100, 0, 1);
363 mDistanceClustersY[i] = std::make_unique<TH1D>(Form("distanceClustersY_L%d", i), ";Distance y (cm); ", 100, 0, 1);
364 mDistanceClustersZ[i] = std::make_unique<TH1D>(Form("distanceClustersZ_L%d", i), ";Distance z (cm); ", 100, 0, 1);
365 mDistanceClusters[i] = std::make_unique<TH1D>(Form("distanceClusters_L%d", i), ";Distance (cm); ", 100, 0, 1);
366
367 mDCAxyOriginal[i] = std::make_unique<TH1D>(Form("dcaXYOriginal_L%d", i), "Distance between track and original cluster ;DCA xy (cm); ", 400, -0.2, 0.2);
368 mDCAzOriginal[i] = std::make_unique<TH1D>(Form("dcaZOriginal_L%d", i), "Distance between track and original cluster ;DCA z (cm); ", 400, -0.2, 0.2);
369
370 mPhiOriginal[i] = std::make_unique<TH1D>(Form("phiOriginal_L%d", i), ";phi (deg); ", 1440, -180, 180);
371 mPhiTrackOriginal[i] = std::make_unique<TH1D>(Form("phiTrackOriginal_L%d", i), ";phi Track (deg); ", 1440, 0, 360);
372 mEtaOriginal[i] = std::make_unique<TH1D>(Form("etaOriginal_L%d", i), ";eta (deg); ", 100, -2, 2);
373 mPtOriginal[i] = std::make_unique<TH1D>(Form("ptOriginal_L%d", i), ";pt (GeV/c); ", 100, 0, 10);
374
375 mZvsPhiDUplicated[i] = std::make_unique<TH2D>(Form("zvsphiDuplicated_L%d", i), ";z (cm);phi (deg)", 400, -20, 20, 1440, -180, 180);
376
377 mPtDuplicated[i] = new TH1D(Form("ptDuplicated_L%d", i), ";pt (GeV/c); ", nbPt, 0, 7.5); // xbins);
378 mEtaDuplicated[i] = new TH1D(Form("etaDuplicated_L%d", i), ";eta; ", 40, -2, 2);
379 mPhiDuplicated[i] = new TH1D(Form("phiDuplicated_L%d", i), ";phi (deg); ", 1440, -180, 180);
380 mPhiTrackDuplicated[i] = new TH1D(Form("phiTrackDuplicated_L%d", i), ";phi Track (deg); ", 1440, 0, 360);
381 mPhiOriginalIfDuplicated[i] = new TH1D(Form("phiOriginalIfDuplicated_L%d", i), ";phi (deg); ", 1440, -180, 180);
382 mPhiTrackDuplicatedvsphiDuplicated[i] = new TH2D(Form("phiTrackDuplicatedvsphiDuplicated_L%d", i), ";phi track (deg);phi oridinal if duplicated (deg); ", 1440, 0, 360, 1440, -180, 180);
383 mPhiTrackoriginalvsphioriginal[i] = new TH2D(Form("phiTrackoriginalvsphioriginal_L%d", i), ";phi track (deg);phi original (deg); ", 1440, 0, 360, 1440, -180, 180);
384 mDCAxyDuplicated_layer[i] = std::make_unique<TH1D>(Form("dcaXYDuplicated_layer_L%d", i), "Distance between track and duplicated cluster ;DCA xy (cm); ", 400, -0.2, 0.2);
385 mDCAzDuplicated_layer[i] = std::make_unique<TH1D>(Form("dcaZDuplicated_layer_L%d", i), "Distance between track and duplicated cluster ;DCA z (cm); ", 400, -0.2, 0.2);
386
387 mEfficiencyGoodMatch_layer[i] = std::make_unique<TH1D>(Form("mEfficiencyGoodMatch_layer_L%d", i), ";#sigma(DCA) cut;Efficiency;", 20, 0.5, 20.5);
388 mEfficiencyFakeMatch_layer[i] = std::make_unique<TH1D>(Form("mEfficiencyFakeMatch_layer_L%d", i), ";#sigma(DCA) cut;Efficiency;", 20, 0.5, 20.5);
389 mEfficiencyTotal_layer[i] = std::make_unique<TH1D>(Form("mEfficiencyTotal_layer_L%d", i), ";#sigma(DCA) cut;Efficiency;", 20, 0.5, 20.5);
390
391 mEfficiencyGoodMatchPt_layer[i] = new TH2D(Form("mEfficiencyGoodMatchPt_layer_L%d", i), ";#it{p}_{T} (GeV/c);#sigma(DCA) cut;Efficiency;", nbPt, 0, 7.5, /* xbins*/ 20, 0.5, 20.5);
392 mEfficiencyFakeMatchPt_layer[i] = new TH2D(Form("mEfficiencyFakeMatchPt_layer_L%d", i), ";#it{p}_{T} (GeV/c);#sigma(DCA) cut;Efficiency;", nbPt, 0, 7.5, /* xbins*/ 20, 0.5, 20.5);
393
394 mEfficiencyGoodMatchEta_layer[i] = new TH2D(Form("mEfficiencyGoodMatchEta_layer_L%d", i), ";#eta;#sigma(DCA) cut;Efficiency;", 40, -2, 2, 20, 0.5, 20.5);
395 mEfficiencyFakeMatchEta_layer[i] = new TH2D(Form("mEfficiencyFakeMatchEta_layer_L%d", i), ";#eta;#sigma(DCA) cut;Efficiency;", 40, -2, 2, 20, 0.5, 20.5);
396
397 mEfficiencyGoodMatchPhi_layer[i] = new TH2D(Form("mEfficiencyGoodMatchPhi_layer_L%d", i), ";#phi;#sigma(DCA) cut;Efficiency;", 1440, -180, 180, 20, 0.5, 20.5);
398 mEfficiencyGoodMatchPhiTrack_layer[i] = new TH2D(Form("mEfficiencyGoodMatchPhiTrack_layer_L%d", i), ";#phi track;#sigma(DCA) cut;Efficiency;", 1440, 0, 360, 20, 0.5, 20.5);
399 mEfficiencyGoodMatchPhiOriginal_layer[i] = new TH2D(Form("mEfficiencyGoodMatchPhiOriginal_layer_L%d", i), ";#phi Original;#sigma(DCA) cut;Efficiency;", 1440, -180, 180, 20, 0.5, 20.5);
400 mEfficiencyFakeMatchPhi_layer[i] = new TH2D(Form("mEfficiencyFakeMatchPhi_layer_L%d", i), ";#phi;#sigma(DCA) cut;Efficiency;", 1440, -180, 180, 20, 0.5, 20.5);
401 mEfficiencyFakeMatchPhiTrack_layer[i] = new TH2D(Form("mEfficiencyFakeMatchPhiTrack_layer_L%d", i), ";#phi Track;#sigma(DCA) cut;Efficiency;", 1440, 0, 360, 20, 0.5, 20.5);
402
403 mPt_EtaDupl[i] = new TH2D(Form("mPt_EtaDupl_L%d", i), ";#it{p}_{T} (GeV/c);#eta; ", 100, 0, 10, 100, -2, 2);
404
405 mDuplicatedPt[i] = new TH1D(Form("mDuplicatedPt_log_L%d", i), Form("; #it{p}_{T} (GeV/c); Number of duplciated clusters L%d", i), nbPt, 0, 7.5 /* xbins*/);
406 mDuplicatedPt[i]->Sumw2();
407 mNGoodMatchesPt[i] = new TH1D(Form("mNGoodMatchesPt_L%d", i), Form("; #it{p}_{T} (GeV/c); Number of good matches L%d", i), nbPt, 0, 7.5 /* xbins*/);
408 mNGoodMatchesPt[i]->Sumw2();
409 mNFakeMatchesPt[i] = new TH1D(Form("mNFakeMatchesPt_L%d", i), Form("; #it{p}_{T} (GeV/c); Number of fake matches L%d", i), nbPt, 0, 7.5 /* xbins*/);
410 mNFakeMatchesPt[i]->Sumw2();
411
412 mDuplicatedRow[i] = new TH1D(Form("mDuplicatedRow_L%d", i), Form("; Row; Number of duplciated clusters L%d", i), 512, -0.5, 511.5);
413 mDuplicatedRow[i]->Sumw2();
414 mNGoodMatchesRow[i] = new TH1D(Form("mNGoodMatchesRow_L%d", i), Form("; Row; Number of good matches L%d", i), 512, -0.5, 511.5);
415 mNGoodMatchesRow[i]->Sumw2();
416 mNFakeMatchesRow[i] = new TH1D(Form("mNFakeMatchesRow_L%d", i), Form(";Row; Number of fake matches L%d", i), 512, -0.5, 511.5);
417 mNFakeMatchesRow[i]->Sumw2();
418
419 mDuplicatedPtEta[i] = new TH2D(Form("mDuplicatedPtEta_log_L%d", i), Form("; #it{p}_{T} (GeV/c);#eta; Number of duplciated clusters L%d", i), nbPt, 0, 7.5 /* xbins*/, 40, -2, 2);
420 mDuplicatedPtEta[i]->Sumw2();
421 mNGoodMatchesPtEta[i] = new TH2D(Form("mNGoodMatchesPtEta_L%d", i), Form("; #it{p}_{T} (GeV/c);#eta; Number of good matches L%d", i), nbPt, 0, 7.5 /* xbins*/, 40, -2, 2);
422 mNGoodMatchesPtEta[i]->Sumw2();
423 mNFakeMatchesPtEta[i] = new TH2D(Form("mNFakeMatchesPtEta_L%d", i), Form("; #it{p}_{T} (GeV/c);#eta; Number of good matches L%d", i), nbPt, 0, 7.5 /* xbins*/, 40, -2, 2);
424 mNFakeMatchesPtEta[i]->Sumw2();
425
426 mDuplicatedPtPhi[i] = new TH2D(Form("mDuplicatedPtPhi_log_L%d", i), Form("; #it{p}_{T} (GeV/c);#phi (deg); Number of duplciated clusters L%d", i), nbPt, 0, 7.5 /* xbins*/, 1440, -180, 180);
427 mDuplicatedPtPhi[i]->Sumw2();
428 mNGoodMatchesPtPhi[i] = new TH2D(Form("mNGoodMatchesPtPhi_L%d", i), Form("; #it{p}_{T} (GeV/c);#phi (deg); Number of good matches L%d", i), nbPt, 0, 7.5 /* xbins*/, 1440, -180, 180);
429 mNGoodMatchesPtPhi[i]->Sumw2();
430 mNFakeMatchesPtPhi[i] = new TH2D(Form("mNFakeMatchesPtPhi_L%d", i), Form("; #it{p}_{T} (GeV/c);#phi (deg); Number of good matches L%d", i), nbPt, 0, 7.5 /* xbins*/, 1440, -180, 180);
431 mNFakeMatchesPtPhi[i]->Sumw2();
432
433 mDuplicatedEtaPhi[i] = new TH2D(Form("mDuplicatedEtaPhi_L%d", i), Form("; #eta;#phi (deg); Number of duplciated clusters L%d", i), 40, -2, 2, 1440, -180, 180);
434 mDuplicatedEtaPhi[i]->Sumw2();
435 mNGoodMatchesEtaPhi[i] = new TH2D(Form("mNGoodMatchesEtaPhi_L%d", i), Form("; #eta;#phi (deg); Number of good matches L%d", i), 40, -2, 2, 1440, -180, 180);
436 mNGoodMatchesEtaPhi[i]->Sumw2();
437 mNFakeMatchesEtaPhi[i] = new TH2D(Form("mNFakeMatchesEtaPhi_L%d", i), Form("; #eta;#phi (deg); Number of good matches L%d", i), 40, -2, 2, 1440, -180, 180);
438 mNFakeMatchesEtaPhi[i]->Sumw2();
439
440 mDuplicatedEtaAllPt[i] = std::make_unique<TH1D>(Form("mDuplicatedEtaAllPt_L%d", i), Form("; #eta; Number of duplicated clusters L%d", i), 40, -2, 2);
441 mNGoodMatchesEtaAllPt[i] = std::make_unique<TH1D>(Form("mNGoodMatchesEtaAllPt_L%d", i), Form("; #eta; Number of good matches L%d", i), 40, -2, 2);
442 mNFakeMatchesEtaAllPt[i] = std::make_unique<TH1D>(Form("mNFakeMatchesEtaAllPt_L%d", i), Form("; #eta; Number of fake matches L%d", i), 40, -2, 2);
443
444 mDuplicatedPhiAllPt[i] = std::make_unique<TH1D>(Form("mDuplicatedPhiAllPt_L%d", i), Form("; #phi (deg); Number of duplicated clusters L%d", i), 1440, -180, 180);
445 mNGoodMatchesPhiAllPt[i] = std::make_unique<TH1D>(Form("mNGoodMatchesPhiAllPt_L%d", i), Form("; #phi (deg); Number of good matches L%d", i), 1440, -180, 180);
446 mNFakeMatchesPhiAllPt[i] = std::make_unique<TH1D>(Form("mNFakeMatchesPhiAllPt_L%d", i), Form("; #phi (deg); Number of fake matches L%d", i), 1440, -180, 180);
447
448 mnGoodMatchesPt_layer[i] = new TH2D(Form("mnGoodMatchesPt_layer_L%d", i), ";pt; nGoodMatches", nbPt, 0, 7.5 /* xbins*/, 20, 0.5, 20.5);
449 mnFakeMatchesPt_layer[i] = new TH2D(Form("mnFakeMatchesPt_layer_L%d", i), ";pt; nFakeMatches", nbPt, 0, 7.5 /* xbins*/, 20, 0.5, 20.5);
450 mnGoodMatchesEta_layer[i] = new TH2D(Form("mnGoodMatchesEta_layer_L%d", i), ";#eta; nGoodMatches", 40, -2, 2, 20, 0.5, 20.5);
451 mnFakeMatchesEta_layer[i] = new TH2D(Form("mnFakeMatchesEta_layer_L%d", i), ";#eta; nFakeMatches", 40, -2, 2, 20, 0.5, 20.5);
452 mnGoodMatchesPhi_layer[i] = new TH2D(Form("mnGoodMatchesPhi_layer_L%d", i), ";#Phi; nGoodMatches", 1440, -180, 180, 20, 0.5, 20.5);
453 mnGoodMatchesPhiTrack_layer[i] = new TH2D(Form("mnGoodMatchesPhiTrack_layer_L%d", i), ";#Phi track; nGoodMatches", 1440, 0, 360, 20, 0.5, 20.5);
454 mnGoodMatchesPhiOriginal_layer[i] = new TH2D(Form("mnGoodMatchesPhiOriginal_layer_L%d", i), ";#Phi of the original Cluster; nGoodMatches", 1440, -180, 180, 20, 0.5, 20.5);
455 mnFakeMatchesPhi_layer[i] = new TH2D(Form("mnFakeMatchesPhi_layer_L%d", i), ";#Phi; nFakeMatches", 1440, -180, 180, 20, 0.5, 20.5);
456 mnFakeMatchesPhiTrack_layer[i] = new TH2D(Form("mnFakeMatchesPhiTrack_layer_L%d", i), ";#Phi track; nFakeMatches", 1440, 0, 360, 20, 0.5, 20.5);
457
458 denPt[i] = new TH1D(Form("denPt_L%d", i), Form("denPt_L%d", i), nbPt, 0, 7.5 /* xbins*/);
459 numPt[i] = new TH1D(Form("numPt_L%d", i), Form("numPt_L%d", i), nbPt, 0, 7.5 /* xbins*/);
460 numPtGood[i] = new TH1D(Form("numPtGood_L%d", i), Form("numPtGood_L%d", i), nbPt, 0, 7.5 /* xbins*/);
461 numPtFake[i] = new TH1D(Form("numPtFake_L%d", i), Form("numPtFake_L%d", i), nbPt, 0, 7.5 /* xbins*/);
462
463 denPhi[i] = new TH1D(Form("denPhi_L%d", i), Form("denPhi_L%d", i), 1440, -180, 180);
464 numPhi[i] = new TH1D(Form("numPhi_L%d", i), Form("numPhi_L%d", i), 1440, -180, 180);
465 numPhiGood[i] = new TH1D(Form("numPhiGood_L%d", i), Form("numPhiGood_L%d", i), 1440, -180, 180);
466 numPhiFake[i] = new TH1D(Form("numPhiFake_L%d", i), Form("numPhiFake_L%d", i), 1440, -180, 180);
467
468 denEta[i] = new TH1D(Form("denEta_L%d", i), Form("denEta_L%d", i), 200, -2, 2);
469 numEta[i] = new TH1D(Form("numEta_L%d", i), Form("numEta_L%d", i), 200, -2, 2);
470 numEtaGood[i] = new TH1D(Form("numEtaGood_L%d", i), Form("numEtaGood_L%d", i), 200, -2, 2);
471 numEtaFake[i] = new TH1D(Form("numEtaFake_L%d", i), Form("numEtaFake_L%d", i), 200, -2, 2);
472
473 diffPhivsPt[i] = new TH2D(Form("diffPhivsPt_L%d", i), Form("diffPhivsPt_L%d", i), nbPt, 0, 7.5 /* xbins*/, 50, 0, 5);
474
475 IPOriginalxy[i] = std::make_unique<TH1D>(Form("IPOriginalxy_L%d", i), Form("IPOriginalxy_L%d", i), 500, -0.002, 0.002);
476 IPOriginalz[i] = std::make_unique<TH1D>(Form("IPOriginalz_L%d", i), Form("IPOriginalz_L%d", i), 200, -10, 10);
477 IPOriginalifDuplicatedxy[i] = std::make_unique<TH1D>(Form("IPOriginalifDuplicatedxy_L%d", i), Form("IPOriginalifDuplicatedxy_L%d", i), 1000, -0.005, 0.005);
478 IPOriginalifDuplicatedz[i] = std::make_unique<TH1D>(Form("IPOriginalifDuplicatedz_L%d", i), Form("IPOriginalifDuplicatedz_L%d", i), 200, -10, 10);
479
480 for (int j = 0; j < 3; j++) {
481 mDuplicatedEta[i][j] = std::make_unique<TH1D>(Form("mDuplicatedEta_L%d_pt%d", i, j), Form("%f < #it{p}_{T} < %f GeV/c; #eta; Number of duplicated clusters L%d", mrangesPt[j][0], mrangesPt[j][1], i), 40, -2, 2);
482 mNGoodMatchesEta[i][j] = std::make_unique<TH1D>(Form("mNGoodMatchesEta_L%d_pt%d", i, j), Form("%f < #it{p}_{T} < %f GeV/c; #eta; Number of good matches L%d", mrangesPt[j][0], mrangesPt[j][1], i), 40, -2, 2);
483 mNFakeMatchesEta[i][j] = std::make_unique<TH1D>(Form("mNFakeMatchesEta_L%d_pt%d", i, j), Form("%f < #it{p}_{T} < %f GeV/c; #eta; Number of fake matches L%d", mrangesPt[j][0], mrangesPt[j][1], i), 40, -2, 2);
484
485 mDuplicatedPhi[i][j] = std::make_unique<TH1D>(Form("mDuplicatedPhi_L%d_pt%d", i, j), Form("%f < #it{p}_{T} < %f GeV/c; #phi; Number of duplicated clusters L%d", mrangesPt[j][0], mrangesPt[j][1], i), 1440, -180, 180);
486 mNGoodMatchesPhi[i][j] = std::make_unique<TH1D>(Form("mNGoodMatchesPhi_L%d_pt%d", i, j), Form("%f < #it{p}_{T} < %f GeV/c; #phi; Number of good matches L%d", mrangesPt[j][0], mrangesPt[j][1], i), 1440, -180, 180);
487 mNFakeMatchesPhi[i][j] = std::make_unique<TH1D>(Form("mNFakeMatchesPhi_L%d_pt%d", i, j), Form("%f < #it{p}_{T} < %f GeV/c; #phi; Number of fake matches L%d", mrangesPt[j][0], mrangesPt[j][1], i), 1440, -180, 180);
488 }
489 }
490 gStyle->SetPalette(55);
491}
492
494{
495 LOGP(info, "--------------- run");
497 recoData.collectData(pc, *mDataRequest.get());
498
499 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
500 initialiseRun(recoData);
501 process(recoData);
502}
503
505{
506 LOGP(info, "--------------- initialiseRun");
507 if (mUseMC) {
508 mTracksMCLabels = recoData.getITSTracksMCLabels();
509 mClustersMCLCont = recoData.getITSClustersMCLabels();
510 }
511
512 mITSClustersArray.clear();
513 mTracksROFRecords = recoData.getITSTracksROFRecords();
514 mTracks = recoData.getITSTracks();
515 mClusters = recoData.getITSClusters();
516 mClustersROFRecords = recoData.getITSClustersROFRecords();
517 mClusPatterns = recoData.getITSClustersPatterns();
518 mInputITSidxs = recoData.getITSTracksClusterRefs();
519 mITSClustersArray.reserve(mClusters.size());
520 auto pattIt = mClusPatterns.begin();
521 o2::its::ioutils::convertCompactClusters(mClusters, pattIt, mITSClustersArray, mDict); // clusters converted to 3D spacepoints
522}
523
524void EfficiencyStudy::stileEfficiencyGraph(std::unique_ptr<TEfficiency>& eff, const char* name, const char* title, bool bidimensional = false, const int markerStyle = kFullCircle, const double markersize = 1, const int markercolor = kBlack, const int linecolor = kBlack)
525{
526 eff->SetName(name);
527 eff->SetTitle(title);
528 if (!bidimensional) {
529 eff->SetMarkerStyle(markerStyle);
530 eff->SetMarkerSize(markersize);
531 eff->SetMarkerColor(markercolor);
532 eff->SetLineColor(linecolor);
533 }
534}
535
536int EfficiencyStudy::getDCAClusterTrackMC(int countDuplicated = 0)
537{
538 // get the DCA between the clusters and the track from MC and fill histograms: distance between original and duplicated cluster, DCA, phi, clusters
539 // used to study the DCA cut to be applied
540 LOGP(info, "--------------- getDCAClusterTrackMC");
541
542 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
543 o2::gpu::gpustd::array<float, 2> clusOriginalDCA, clusDuplicatedDCA;
544 auto propagator = o2::base::Propagator::Instance();
545
546 auto bz = o2::base::Propagator::Instance()->getNominalBz();
547 LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz;
548
549 unsigned int rofIndexTrack = 0;
550 unsigned int rofNEntriesTrack = 0;
551 unsigned int rofIndexClus = 0;
552 unsigned int rofNEntriesClus = 0;
553 int nLabels = 0;
554 unsigned int totClus = 0;
555
556 int duplicated = 0;
557
558 std::unordered_map<o2::MCCompLabel, std::vector<int>> label_vecClus[mClustersROFRecords.size()][NLAYERS]; // array of maps nRofs x Nlayers -> {label, vec(iClus)} where vec(iClus) are the clusters that share the same label
559
560 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
561 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
562 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
563
564 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
565 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
566
567 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
568 auto track = mTracks[iTrack];
569 o2::track::TrackParCov trackParCov = mTracks[iTrack];
570 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
571 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
572
573 if (ncl < 7) {
574 continue;
575 }
576
577 float ip[2];
578 track.getImpactParams(0, 0, 0, 0, ip);
579
580 // if (abs(ip[0])>0.001 ) continue; ///pv not in (0,0,0)
581
582 auto& tracklab = mTracksMCLabels[iTrack];
583 if (tracklab.isFake()) {
584 continue;
585 }
586
587 auto pt = trackParCov.getPt();
588 auto eta = trackParCov.getEta();
589
590 float phiTrack = trackParCov.getPhi() * 180 / M_PI;
591
592 if (pt < mPtCuts[0] || pt > mPtCuts[1]) {
593 continue;
594 }
595 if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) {
596 continue;
597 }
598
599 float phioriginal = 0;
600 float phiduplicated = 0;
601
602 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track
603 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
604 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]]; // cluster spacepoint in the tracking system
605 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
606 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
607
608 UShort_t rowOriginal = clusOriginal.getRow();
609 UShort_t colOriginal = clusOriginal.getCol();
610
611 auto layer = mGeometry->getLayer(clusOriginal.getSensorID());
612 if (layer >= NLAYERS) {
613 continue; // checking only selected layers
614 }
615 auto labsTrack = mClustersMCLCont->getLabels(mInputITSidxs[iclTrack]); // get labels of the cluster associated to the track
616
617 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
618 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
619
620 phioriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
621 mPhiTrackoriginalvsphioriginal[layer]->Fill(phiTrack, phioriginal);
622
623 mPhiOriginal[layer]->Fill(phioriginal);
624 mPtOriginal[layer]->Fill(pt);
625 mEtaOriginal[layer]->Fill(eta);
626 m3DClusterPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y(), clusOriginalPointGlob.z());
627 m2DClusterOriginalPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y());
628
629 for (auto& labT : labsTrack) { // for each valid label iterate over ALL the clusters in the ROF to see if there are duplicates
630 if (labT != tracklab) {
631 continue;
632 }
633 nLabels++;
634 if (labT.isValid()) {
635 for (unsigned int iClus = rofIndexClus; iClus < rofIndexClus + rofNEntriesClus; iClus++) { // iteration over ALL the clusters in the ROF
636
637 auto clusDuplicated = mClusters[iClus];
638 auto clusDuplicatedPoint = mITSClustersArray[iClus];
639
640 auto layerClus = mGeometry->getLayer(clusDuplicated.getSensorID());
641 if (layerClus != layer) {
642 continue;
643 }
644
645 o2::math_utils::Point3D<float> clusDuplicatedPointTrack = {clusDuplicatedPoint.getX(), clusDuplicatedPoint.getY(), clusDuplicatedPoint.getZ()};
646 o2::math_utils::Point3D<float> clusDuplicatedPointGlob = mGeometry->getMatrixT2G(clusDuplicated.getSensorID()) * clusDuplicatedPointTrack;
647 // phiduplicated = std::atan2(clusDuplicatedPointGlob.y(), clusDuplicatedPointGlob.x()) * 180 / M_PI + 180;
648 phiduplicated = clusDuplicatedPointGlob.phi() * 180 / M_PI;
649
650 auto labsClus = mClustersMCLCont->getLabels(iClus); // ideally I can have more than one label per cluster
651 for (auto labC : labsClus) {
652 if (labC == labT) {
653 label_vecClus[iROF][layerClus][labT].push_back(iClus); // same cluster: label from the track = label from the cluster
654 // if a duplicate cluster is found, propagate the track to the duplicate cluster and compute the distance from the original cluster
655 // if (clusOriginalPointGlob != clusDuplicatedPointGlob) { /// check that the duplicated cluster is not the original one just counted twice
656 // if (clusDuplicated.getSensorID() != clusOriginal.getSensorID()) { /// check that the duplicated cluster is not the original one just counted twice
657
658 // applying constraints: the cluster should be on the same layer, should be on an adjacent stave and on the same or adjacent chip position
659 if (clusDuplicated.getSensorID() == clusOriginal.getSensorID()) {
660 continue;
661 }
662 auto layerDuplicated = mGeometry->getLayer(clusDuplicated.getSensorID());
663 if (layerDuplicated != layerClus) {
664 continue;
665 }
666 auto staveDuplicated = mGeometry->getStave(clusDuplicated.getSensorID());
667 if (abs(staveDuplicated - staveOriginal) != 1) {
668 continue;
669 }
670 auto chipDuplicated = mGeometry->getChipIdInStave(clusDuplicated.getSensorID());
671 if (abs(chipDuplicated - chipOriginal) > 1) {
672 continue;
673 }
674
675 duplicated++;
676
677 if (countDuplicated == 0) {
678 UShort_t rowDuplicated = clusDuplicated.getRow();
679 UShort_t colDuplicated = clusDuplicated.getCol();
680
681 chipRowDuplicated[layerDuplicated]->Fill(rowDuplicated);
682 chipRowOriginalIfDuplicated[layerDuplicated]->Fill(rowOriginal);
683
684 mDuplicated_layer[layerDuplicated]++; // This has to be incremented at the first call
685 mPtDuplicated[layerClus]->Fill(pt);
686 mEtaDuplicated[layerClus]->Fill(eta);
687 mPhiDuplicated[layerClus]->Fill(phiduplicated);
688 mZvsPhiDUplicated[layerClus]->Fill(clusDuplicatedPointGlob.Z(), phiduplicated);
689 mPhiTrackDuplicated[layerClus]->Fill(phiTrack);
690 mPhiTrackDuplicatedvsphiDuplicated[layerClus]->Fill(phiTrack, phioriginal);
691 mPhiOriginalIfDuplicated[layerClus]->Fill(phioriginal);
692 }
693
694 if (countDuplicated == 1) {
695 for (int ipt = 0; ipt < 3; ipt++) {
696 if (pt >= mrangesPt[ipt][0] && pt < mrangesPt[ipt][1]) {
697 mDuplicatedEta[layerDuplicated][ipt]->Fill(eta);
698 mDuplicatedPhi[layerDuplicated][ipt]->Fill(phiduplicated);
699 }
700 }
701 UShort_t rowDuplicated = clusDuplicated.getRow();
702 mDuplicatedRow[layerDuplicated]->Fill(rowOriginal);
703 mDuplicatedPt[layerDuplicated]->Fill(pt);
704 mDuplicatedPtEta[layerDuplicated]->Fill(pt, eta);
705 mDuplicatedPtPhi[layerDuplicated]->Fill(pt, phiduplicated);
706 mDuplicatedEtaPhi[layerDuplicated]->Fill(eta, phiduplicated);
707
708 mDuplicatedEtaAllPt[layerDuplicated]->Fill(eta);
709 mDuplicatedPhiAllPt[layerDuplicated]->Fill(phiduplicated);
710 mPt_EtaDupl[layerClus]->Fill(pt, eta);
711 }
712
713 m3DClusterPositions->Fill(clusDuplicatedPointGlob.x(), clusDuplicatedPointGlob.y(), clusDuplicatedPointGlob.z());
714 m2DClusterDuplicatedPositions->Fill(clusDuplicatedPointGlob.x(), clusDuplicatedPointGlob.y());
715
717 mDistanceClustersX[layerClus]->Fill(abs(clusOriginalPointGlob.x() - clusDuplicatedPointGlob.x()));
718 mDistanceClustersY[layerClus]->Fill(abs(clusOriginalPointGlob.y() - clusDuplicatedPointGlob.y()));
719 mDistanceClustersZ[layerClus]->Fill(abs(clusOriginalPointGlob.z() - clusDuplicatedPointGlob.z()));
720 mDistanceClusters[layerClus]->Fill(std::hypot(clusOriginalPointGlob.x() - clusDuplicatedPointGlob.x(), clusOriginalPointGlob.y() - clusDuplicatedPointGlob.y(), clusOriginalPointGlob.z() - clusDuplicatedPointGlob.z()));
721
723
725 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusOriginal.getSensorID()));
726 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusOriginal.getSensorID()));
727 if (propagator->propagateToDCA(clusOriginalPointGlob, trackParCov, b, 2.f, matCorr, &clusOriginalDCA)) {
728 mDCAxyOriginal[layerClus]->Fill(clusOriginalDCA[0]);
729 mDCAzOriginal[layerClus]->Fill(clusOriginalDCA[1]);
730 }
732 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusDuplicated.getSensorID()));
733 if (propagator->propagateToDCA(clusDuplicatedPointGlob, trackParCov, b, 2.f, matCorr, &clusDuplicatedDCA)) {
734 mDCAxyDuplicated->Fill(clusDuplicatedDCA[0]);
735 mDCAzDuplicated->Fill(clusDuplicatedDCA[1]);
736 mDCAxyDuplicated_layer[layerDuplicated]->Fill(clusDuplicatedDCA[0]);
737 mDCAzDuplicated_layer[layerDuplicated]->Fill(clusDuplicatedDCA[1]);
738 }
740 }
741 }
742 }
743 }
744 }
745 } // end loop on clusters
746 totClus += NLAYERS; // summing only the number of clusters in the considered layers. Since the imposition of 7-clusters tracks, if the track is valid should release as clusters as the number of considered layers
747 } // end loop on tracks per ROF
748 } // end loop on ROFRecords array
749 LOGP(info, "Total number of clusters: {} ", totClus);
750 LOGP(info, "total nLabels: {}", nLabels);
751 LOGP(info, "Number of duplicated clusters: {}", duplicated);
752
753 if (mVerboseOutput && mUseMC) {
754 // printing the duplicates
755 for (unsigned int iROF = 0; iROF < mClustersROFRecords.size(); iROF++) {
756 LOGP(info, "°°°°°°°°°°°°°°°°°°°°°°°° ROF {} °°°°°°°°°°°°°°°°°°°°°°°°", iROF);
757 for (unsigned int lay = 0; lay < NLAYERS; lay++) {
758 LOGP(info, "°°°°°°°°°°°°°°°°°°°°°°°° LAYER {} °°°°°°°°°°°°°°°°°°°°°°°°", lay);
759 for (auto& it : label_vecClus[iROF][lay]) {
760 if (it.second.size() <= 1) {
761 continue; // printing only duplicates
762 }
763 std::cout << " \n++++++++++++ Label: ";
764 auto label = it.first;
765 it.first.print();
766 for (auto iClus : it.second) {
767 auto name = mGeometry->getSymbolicName(mClusters[iClus].getSensorID());
768 auto chipid = mClusters[iClus].getChipID();
769 auto clus = mClusters[iClus];
770 auto clusPoint = mITSClustersArray[iClus];
771
772 o2::math_utils::Point3D<float> clusPointTrack = {clusPoint.getX(), clusPoint.getY(), clusPoint.getZ()};
773 o2::math_utils::Point3D<float> clusPointGlob = mGeometry->getMatrixT2G(clus.getSensorID()) * clusPointTrack;
774 std::cout << "ROF: " << iROF << ", iClus: " << iClus << " -> chip: " << chipid << " = " << name << std::endl;
775 LOGP(info, "LOCtrack: {} {} {}", clusPointTrack.x(), clusPointTrack.y(), clusPointTrack.z());
776 LOGP(info, "LOCglob {} {} {}", clusPointGlob.x(), clusPointGlob.y(), clusPointGlob.z());
777 }
778 }
779 }
780 }
781 }
782 return duplicated;
783}
784
786{
787 // count the effective number of duplicated cluster good matches after applying the pt eta and phi cuts on the track
788 // to check the applied cuts
789 LOGP(info, "--------------- countDuplicatedAfterCuts");
790
791 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
792 o2::gpu::gpustd::array<float, 2> clusOriginalDCA, clusDuplicatedDCA;
793 auto propagator = o2::base::Propagator::Instance();
794
795 unsigned int rofIndexTrack = 0;
796 unsigned int rofNEntriesTrack = 0;
797 unsigned int rofIndexClus = 0;
798 unsigned int rofNEntriesClus = 0;
799 int nLabels = 0;
800 unsigned int totClus = 0;
801
802 int duplicated[3] = {0};
803 int possibleduplicated[3] = {0};
804
805 std::cout << "Track candidates: " << std::endl;
806
807 std::unordered_map<o2::MCCompLabel, std::vector<int>> label_vecClus[mClustersROFRecords.size()][NLAYERS]; // array of maps nRofs x Nlayers -> {label, vec(iClus)} where vec(iClus) are the clusters that share the same label
808
809 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
810 std::cout << "ROF number: " << iROF << std::endl;
811 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
812 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
813
814 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
815 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
816
817 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
818 // std::cout<<"Track number: "<<iTrack<<std::endl;
819
820 auto track = mTracks[iTrack];
821 o2::track::TrackParCov trackParCov = mTracks[iTrack];
822 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
823 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
824
825 if (ncl < 7) {
826 continue;
827 }
828
829 auto& tracklab = mTracksMCLabels[iTrack];
830 if (tracklab.isFake()) {
831 continue;
832 }
833
834 auto pt = trackParCov.getPt();
835 auto eta = trackParCov.getEta();
836
837 // applying the cuts on the track - only pt and eta cuts since for phi the layer is needed
838 if (pt < mPtCuts[0] || pt > mPtCuts[1]) {
839 continue;
840 }
841 if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) {
842 continue;
843 }
844
845 float phi = -999.;
846 float phiOriginal = -999.;
847
848 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track
849 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
850 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]]; // cluster spacepoint in the tracking system
851 auto layerOriginal = mGeometry->getLayer(clusOriginal.getSensorID());
852 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
853 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
854
855 auto layer = mGeometry->getLayer(clusOriginal.getSensorID());
856 if (layer >= NLAYERS) {
857 continue; // checking only selected layers
858 }
859 auto labsTrack = mClustersMCLCont->getLabels(mInputITSidxs[iclTrack]); // get labels of the cluster associated to the track
860
861 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
862 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
863 phiOriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
864
866 bool keepTrack = false;
867
868 if (layerOriginal == 0) {
869 for (int i = 0; i < 10; i++) {
870 if ((phiOriginal >= mPhiCutsL0[i][0] && phiOriginal <= mPhiCutsL0[i][1])) {
871 possibleduplicated[0]++;
872 keepTrack = true;
873 }
874 }
875 }
876 if (layerOriginal == 1) {
877 for (int i = 0; i < 12; i++) {
878 if ((phiOriginal >= mPhiCutsL1[i][0] && phiOriginal <= mPhiCutsL1[i][1])) {
879 possibleduplicated[1]++;
880 keepTrack = true;
881 }
882 }
883 }
884 if (layerOriginal == 2) {
885 for (int i = 0; i < 17; i++) {
886 if ((phiOriginal >= mPhiCutsL2[i][0] && phiOriginal <= mPhiCutsL2[i][1])) {
887 possibleduplicated[2]++;
888 keepTrack = true;
889 }
890 }
891 }
892
893 if (!keepTrack) {
894 continue;
895 }
896
897 for (auto& labT : labsTrack) { // for each valid label iterate over ALL the clusters in the ROF to see if there are duplicates
898 if (labT != tracklab) {
899 continue;
900 }
901
902 if (labT.isValid()) {
903 for (unsigned int iClus = rofIndexClus; iClus < rofIndexClus + rofNEntriesClus; iClus++) { // iteration over ALL the clusters in the ROF
904
905 auto clusDuplicated = mClusters[iClus];
906 auto clusDuplicatedPoint = mITSClustersArray[iClus];
907
908 auto layerClus = mGeometry->getLayer(clusDuplicated.getSensorID());
909 if (layerClus != layer) {
910 continue;
911 }
912
913 o2::math_utils::Point3D<float> clusDuplicatedPointTrack = {clusDuplicatedPoint.getX(), clusDuplicatedPoint.getY(), clusDuplicatedPoint.getZ()};
914 o2::math_utils::Point3D<float> clusDuplicatedPointGlob = mGeometry->getMatrixT2G(clusDuplicated.getSensorID()) * clusDuplicatedPointTrack;
915 phi = clusDuplicatedPointGlob.phi() * 180 / M_PI;
916
917 auto labsClus = mClustersMCLCont->getLabels(iClus); // ideally I can have more than one label per cluster
918 for (auto labC : labsClus) {
919 if (labC == labT) {
920 label_vecClus[iROF][layerClus][labT].push_back(iClus); // same cluster: label from the track = label from the cluster
921 // if a duplicate cluster is found, propagate the track to the duplicate cluster and compute the distance from the original cluster
922 // if (clusOriginalPointGlob != clusDuplicatedPointGlob) { /// check that the duplicated cluster is not the original one just counted twice
923 // if (clusDuplicated.getSensorID() != clusOriginal.getSensorID()) { /// check that the duplicated cluster is not the original one just counted twice
924
925 // applying constraints: the cluster should be on the same layer, should be on an adjacent stave and on the same or adjacent chip position
926 if (clusDuplicated.getSensorID() == clusOriginal.getSensorID()) {
927 continue;
928 }
929 auto layerDuplicated = mGeometry->getLayer(clusDuplicated.getSensorID());
930 if (layerDuplicated != layerClus) {
931 continue;
932 }
933 auto staveDuplicated = mGeometry->getStave(clusDuplicated.getSensorID());
934 if (abs(staveDuplicated - staveOriginal) != 1) {
935 continue;
936 }
937 auto chipDuplicated = mGeometry->getChipIdInStave(clusDuplicated.getSensorID());
938 if (abs(chipDuplicated - chipOriginal) > 1) {
939 continue;
940 }
941
942 duplicated[layer]++;
943 std::cout << "Taken L" << layer << " # " << duplicated[layer] << " : pt, eta, phi = " << pt << " , " << eta << " , " << phiOriginal << " Label: " << std::endl;
944 labC.print();
945 }
946 }
947 }
948 }
949 }
950 } // end loop on clusters
951 totClus += ncl;
952 } // end loop on tracks per ROF
953 } // end loop on ROFRecords array
954
955 LOGP(info, "Total number of possible cluster duplicated in L0: {} ", possibleduplicated[0]);
956 LOGP(info, "Total number of possible cluster duplicated in L1: {} ", possibleduplicated[1]);
957 LOGP(info, "Total number of possible cluster duplicated in L2: {} ", possibleduplicated[2]);
958
959 LOGP(info, "Total number of cluster duplicated in L0: {} ", duplicated[0]);
960 LOGP(info, "Total number of cluster duplicated in L1: {} ", duplicated[1]);
961 LOGP(info, "Total number of cluster duplicated in L2: {} ", duplicated[2]);
962}
963
965{
967
968 LOGP(info, "--------------- studyDCAcutsMC");
969
970 int duplicated = getDCAClusterTrackMC(0);
971
972 double meanDCAxyDuplicated[NLAYERS] = {0};
973 double meanDCAzDuplicated[NLAYERS] = {0};
974 double sigmaDCAxyDuplicated[NLAYERS] = {0};
975 double sigmaDCAzDuplicated[NLAYERS] = {0};
976
977 std::ofstream ofs("dcaValues.csv", std::ofstream::out);
978 ofs << "layer,dcaXY,dcaZ,sigmaDcaXY,sigmaDcaZ" << std::endl;
979
980 for (int l = 0; l < NLAYERS; l++) {
981 meanDCAxyDuplicated[l] = mDCAxyDuplicated_layer[l]->GetMean();
982 meanDCAzDuplicated[l] = mDCAzDuplicated_layer[l]->GetMean();
983 sigmaDCAxyDuplicated[l] = mDCAxyDuplicated_layer[l]->GetRMS();
984 sigmaDCAzDuplicated[l] = mDCAzDuplicated_layer[l]->GetRMS();
985 ofs << l << "," << meanDCAxyDuplicated[l] << "," << meanDCAzDuplicated[l] << "," << sigmaDCAxyDuplicated[l] << "," << sigmaDCAzDuplicated[l] << std::endl;
986 }
987
988 for (int l = 0; l < NLAYERS; l++) {
989 LOGP(info, "meanDCAxyDuplicated L{}: {}, meanDCAzDuplicated: {}, sigmaDCAxyDuplicated: {}, sigmaDCAzDuplicated: {}", l, meanDCAxyDuplicated[l], meanDCAzDuplicated[l], sigmaDCAxyDuplicated[l], sigmaDCAzDuplicated[l]);
990 }
991 // now we have the DCA distribution:
992 // ->iterate again over tracks and over duplicated clusters and find the matching ones basing on DCA cuts (1 sigma, 2 sigma,...)
993 // then control if the matching ones according to the DCA matches have the same label
994 // if yes, then we have a good match -> increase the good match counter
995 // if not, keep it as a fake match -> increase the fake match counter
996 // the efficiency of each one will be match counter / total of the duplicated clusters
997 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
998 o2::gpu::gpustd::array<float, 2> clusOriginalDCA, clusDuplicatedDCA;
999 auto propagator = o2::base::Propagator::Instance();
1000
1001 unsigned int rofIndexTrack = 0;
1002 unsigned int rofNEntriesTrack = 0;
1003 unsigned int rofIndexClus = 0;
1004 unsigned int rofNEntriesClus = 0;
1005 int nLabels = 0;
1006 unsigned int totClus = 0;
1007
1008 unsigned int nDCAMatches[20] = {0};
1009 unsigned int nGoodMatches[20] = {0};
1010 unsigned int nFakeMatches[20] = {0};
1011
1012 unsigned int nGoodMatches_layer[NLAYERS][20] = {0};
1013 unsigned int nFakeMatches_layer[NLAYERS][20] = {0};
1014
1015 int nbPt = 75;
1016 double xbins[nbPt + 1], ptcutl = 0.05, ptcuth = 7.5;
1017 double a = std::log(ptcuth / ptcutl) / nbPt;
1018 for (int i = 0; i <= nbPt; i++) {
1019 xbins[i] = ptcutl * std::exp(i * a);
1020 }
1021
1022 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
1023 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
1024 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
1025
1026 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
1027 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
1028
1029 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
1030 auto track = mTracks[iTrack];
1031 o2::track::TrackParCov trackParCov = mTracks[iTrack];
1032 auto pt = trackParCov.getPt();
1033 auto eta = trackParCov.getEta();
1034
1035 float ip[2];
1036 track.getImpactParams(0, 0, 0, 0, ip);
1037
1038 if (pt < mPtCuts[0] || pt > mPtCuts[1]) {
1039 continue;
1040 }
1041 if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) {
1042 continue;
1043 }
1044
1045 float phiTrack = trackParCov.getPhi() * 180 / M_PI;
1046
1047 float phi = -999.;
1048 float phiOriginal = -999.;
1049 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
1050 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
1051
1052 if (ncl < 7) {
1053 continue;
1054 }
1055
1056 auto& tracklab = mTracksMCLabels[iTrack];
1057 if (tracklab.isFake()) {
1058 continue;
1059 }
1060
1061 if (mVerboseOutput) {
1062 LOGP(info, "--------- track Label: ");
1063 tracklab.print();
1064 }
1065
1066 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track to extract layer, stave and chip to restrict the possible matches to be searched with the DCA cut
1067 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
1068 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]]; // cluster spacepoint in the tracking system
1069 auto layerOriginal = mGeometry->getLayer(clusOriginal.getSensorID());
1070 if (layerOriginal >= NLAYERS) {
1071 continue;
1072 }
1073 auto labsOriginal = mClustersMCLCont->getLabels(mInputITSidxs[iclTrack]); // get labels of the cluster associated to the track (original)
1074 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
1075 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
1076
1077 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
1078 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
1079
1080 phiOriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
1081
1082 for (auto& labT : labsOriginal) { // for each valid label iterate over ALL the clusters in the ROF to see if there are duplicates
1083 if (labT != tracklab) {
1084 continue;
1085 }
1086 if (!labT.isValid()) {
1087 continue;
1088 }
1089
1091 for (unsigned int iClus = rofIndexClus; iClus < rofIndexClus + rofNEntriesClus; iClus++) { // iteration over ALL the clusters in the ROF
1092 auto clusDuplicated = mClusters[iClus];
1094 if (clusDuplicated.getSensorID() == clusOriginal.getSensorID()) {
1095 continue;
1096 }
1097 auto layerDuplicated = mGeometry->getLayer(clusDuplicated.getSensorID());
1098 if (layerDuplicated != layerOriginal) {
1099 continue;
1100 }
1101 auto staveDuplicated = mGeometry->getStave(clusDuplicated.getSensorID());
1102 if (abs(staveDuplicated - staveOriginal) != 1) {
1103 continue;
1104 }
1105 auto chipDuplicated = mGeometry->getChipIdInStave(clusDuplicated.getSensorID());
1106 if (abs(chipDuplicated - chipOriginal) > 1) {
1107 continue;
1108 }
1109
1110 auto labsDuplicated = mClustersMCLCont->getLabels(iClus);
1111
1113 auto clusDuplicatedPoint = mITSClustersArray[iClus];
1114
1115 o2::math_utils::Point3D<float> clusDuplicatedPointTrack = {clusDuplicatedPoint.getX(), clusDuplicatedPoint.getY(), clusDuplicatedPoint.getZ()};
1116 o2::math_utils::Point3D<float> clusDuplicatedPointGlob = mGeometry->getMatrixT2G(clusDuplicated.getSensorID()) * clusDuplicatedPointTrack;
1117 phi = clusDuplicatedPointGlob.phi() * 180 / M_PI;
1118
1120 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusDuplicated.getSensorID()));
1121 if (propagator->propagateToDCA(clusDuplicatedPointGlob, trackParCov, b, 2.f, matCorr, &clusDuplicatedDCA)) { // check if the propagation fails
1122 if (mVerboseOutput) {
1123 LOGP(info, "Propagation ok");
1124 }
1126 for (int i = 0; i < 20; i++) {
1127 if (abs(dcaXY[layerDuplicated] - clusDuplicatedDCA[0]) < (i + 1) * sigmaDcaXY[layerDuplicated] && abs(dcaZ[layerDuplicated] - clusDuplicatedDCA[1]) < (i + 1) * sigmaDcaZ[layerDuplicated]) { // check if the DCA is within the cut i*sigma
1128
1129 if (mVerboseOutput) {
1130 LOGP(info, "Check DCA ok: {} < {}; {} < {}", abs(meanDCAxyDuplicated[layerDuplicated] - clusDuplicatedDCA[0]), (i + 1) * sigmaDCAxyDuplicated[layerDuplicated], abs(meanDCAzDuplicated[layerDuplicated] - clusDuplicatedDCA[1]), (i + 1) * sigmaDCAzDuplicated[layerDuplicated]);
1131 }
1132 nDCAMatches[i]++;
1133 bool isGoodMatch = false;
1134
1135 for (auto labD : labsDuplicated) { // at this point the track has been matched with a duplicated cluster based on the DCA cut. Now we check if the matching is good ore not based on the label
1136 if (mVerboseOutput) {
1137 LOGP(info, "tracklab, labD:");
1138 tracklab.print();
1139 labD.print();
1140 }
1141 if (labD == tracklab) {
1142 isGoodMatch = true;
1143 continue;
1144 }
1145 }
1146
1147 if (isGoodMatch) {
1148 nGoodMatches[i]++;
1149 nGoodMatches_layer[layerDuplicated][i]++;
1150 mnGoodMatchesPt_layer[layerDuplicated]->Fill(pt, i);
1151 mnGoodMatchesEta_layer[layerDuplicated]->Fill(eta, i);
1152 mnGoodMatchesPhi_layer[layerDuplicated]->Fill(phi, i);
1153 mnGoodMatchesPhiTrack_layer[layerDuplicated]->Fill(phiTrack, i);
1154 mnGoodMatchesPhiOriginal_layer[layerDuplicated]->Fill(phiOriginal, i);
1155 } else {
1156
1157 nFakeMatches[i]++;
1158 nFakeMatches_layer[layerDuplicated][i]++;
1159 mnFakeMatchesPt_layer[layerDuplicated]->Fill(pt, i);
1160 mnFakeMatchesEta_layer[layerDuplicated]->Fill(eta, i);
1161 mnFakeMatchesPhi_layer[layerDuplicated]->Fill(phi, i);
1162 mnFakeMatchesPhiTrack_layer[layerDuplicated]->Fill(phiTrack, i);
1163 }
1164 } else if (mVerboseOutput) {
1165 LOGP(info, "Check DCA failed");
1166 }
1167 }
1168 } else if (mVerboseOutput) {
1169 LOGP(info, "Propagation failed");
1170 }
1171 } // end loop on all the clusters in the rof
1172 }
1173 } // end loop on clusters associated to the track
1174 } // end loop on tracks per ROF
1175 } // end loop on ROFRecords array
1176
1177 for (int i = 0; i < 20; i++) {
1178 LOGP(info, "Cut: {} sigma -> number of duplicated clusters: {} nDCAMatches: {} nGoodMatches: {} nFakeMatches: {}", i + 1, duplicated, nDCAMatches[i], nGoodMatches[i], nFakeMatches[i]);
1179 mEfficiencyGoodMatch->SetBinContent(i + 1, nGoodMatches[i]);
1180 mEfficiencyFakeMatch->SetBinContent(i + 1, nFakeMatches[i]);
1181 mEfficiencyTotal->SetBinContent(i + 1, double(nGoodMatches[i] + nFakeMatches[i]));
1182
1183 for (int l = 0; l < NLAYERS; l++) {
1184 mEfficiencyGoodMatch_layer[l]->SetBinContent(i + 1, nGoodMatches_layer[l][i]);
1185 mEfficiencyFakeMatch_layer[l]->SetBinContent(i + 1, nFakeMatches_layer[l][i]);
1186 mEfficiencyTotal_layer[l]->SetBinContent(i + 1, double(nGoodMatches_layer[l][i] + nFakeMatches_layer[l][i]));
1187
1188 for (int ipt = 0; ipt < mPtDuplicated[l]->GetNbinsX(); ipt++) {
1189 if (mPtDuplicated[l]->GetBinContent(ipt + 1) != 0) {
1190 mEfficiencyGoodMatchPt_layer[l]->SetBinContent(ipt + 1, i + 1, mnGoodMatchesPt_layer[l]->GetBinContent(ipt + 1, i + 1) / mPtDuplicated[l]->GetBinContent(ipt + 1));
1191 }
1192 mEfficiencyFakeMatchPt_layer[l]->SetBinContent(ipt + 1, i + 1, mnFakeMatchesPt_layer[l]->GetBinContent(ipt + 1, i + 1) / mPtDuplicated[l]->GetBinContent(ipt + 1));
1193 }
1194
1195 for (int ieta = 0; ieta < mEtaDuplicated[l]->GetNbinsX(); ieta++) {
1196 if (mEtaDuplicated[l]->GetBinContent(ieta + 1) != 0) {
1197 mEfficiencyGoodMatchEta_layer[l]->SetBinContent(ieta + 1, i + 1, mnGoodMatchesEta_layer[l]->GetBinContent(ieta + 1, i + 1) / mEtaDuplicated[l]->GetBinContent(ieta + 1));
1198 }
1199 mEfficiencyFakeMatchEta_layer[l]->SetBinContent(ieta + 1, i + 1, mnFakeMatchesEta_layer[l]->GetBinContent(ieta + 1, i + 1) / mEtaDuplicated[l]->GetBinContent(ieta + 1));
1200 }
1201
1202 for (int iphi = 0; iphi < mPhiDuplicated[l]->GetNbinsX(); iphi++) {
1203 if (mPhiDuplicated[l]->GetBinContent(iphi + 1) != 0) {
1204 mEfficiencyGoodMatchPhi_layer[l]->SetBinContent(iphi + 1, i + 1, mnGoodMatchesPhi_layer[l]->GetBinContent(iphi + 1, i + 1) / mPhiDuplicated[l]->GetBinContent(iphi + 1));
1205 }
1206 mEfficiencyFakeMatchPhi_layer[l]->SetBinContent(iphi + 1, i + 1, mnFakeMatchesPhi_layer[l]->GetBinContent(iphi + 1, i + 1) / mPhiDuplicated[l]->GetBinContent(iphi + 1));
1207 }
1208
1209 for (int iphi = 0; iphi < mPhiOriginalIfDuplicated[l]->GetNbinsX(); iphi++) {
1210 if (mPhiOriginalIfDuplicated[l]->GetBinContent(iphi + 1) != 0) {
1211 mEfficiencyGoodMatchPhiOriginal_layer[l]->SetBinContent(iphi + 1, i + 1, mnGoodMatchesPhiOriginal_layer[l]->GetBinContent(iphi + 1, i + 1) / mPhiOriginalIfDuplicated[l]->GetBinContent(iphi + 1));
1212 }
1213 }
1214
1215 for (int iphi = 0; iphi < mPhiTrackDuplicated[l]->GetNbinsX(); iphi++) {
1216 if (mPhiTrackDuplicated[l]->GetBinContent(iphi + 1) != 0) {
1217 mEfficiencyGoodMatchPhiTrack_layer[l]->SetBinContent(iphi + 1, i + 1, mnGoodMatchesPhiTrack_layer[l]->GetBinContent(iphi + 1, i + 1) / mPhiTrackDuplicated[l]->GetBinContent(iphi + 1));
1218 }
1219 mEfficiencyFakeMatchPhiTrack_layer[l]->SetBinContent(iphi + 1, i + 1, mnFakeMatchesPhiTrack_layer[l]->GetBinContent(iphi + 1, i + 1) / mPhiTrackDuplicated[l]->GetBinContent(iphi + 1));
1220 }
1221 }
1222 }
1223 for (int i = 0; i < NLAYERS; i++) {
1224 std::cout << "+++++++++ Duplicated in layer L" << i << ": " << mDuplicated_layer[i] << std::endl;
1225 }
1226
1227 for (int l = 0; l < NLAYERS; l++) {
1228 mEfficiencyGoodMatch_layer[l]->Scale(1. / double(mDuplicated_layer[l]), "b");
1229 mEfficiencyFakeMatch_layer[l]->Scale(1. / double(mDuplicated_layer[l]), "b");
1230 mEfficiencyTotal_layer[l]->Scale(1. / double(mDuplicated_layer[l]), "b");
1231 }
1232
1233 mEfficiencyGoodMatch->Scale(1. / double(duplicated), "b");
1234 mEfficiencyFakeMatch->Scale(1. / double(duplicated), "b");
1235 mEfficiencyTotal->Scale(1. / double(duplicated), "b");
1236
1237 mOutFile->mkdir("EffVsDCA2D/");
1238 mOutFile->cd("EffVsDCA2D/");
1239 for (int l = 0; l < NLAYERS; l++) {
1240 mEfficiencyGoodMatchPt_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1241 mEfficiencyGoodMatchPt_layer[l]->Write();
1242 mEfficiencyGoodMatchEta_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1243 mEfficiencyGoodMatchEta_layer[l]->Write();
1244 mEfficiencyGoodMatchPhi_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1245 mEfficiencyGoodMatchPhi_layer[l]->Write();
1246 mEfficiencyGoodMatchPhiTrack_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1247 mEfficiencyGoodMatchPhiTrack_layer[l]->Write();
1248 mEfficiencyGoodMatchPhiOriginal_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1249 mEfficiencyGoodMatchPhiOriginal_layer[l]->Write();
1250 mEfficiencyFakeMatchPt_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1251 mEfficiencyFakeMatchPt_layer[l]->Write();
1252 mEfficiencyFakeMatchEta_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1253 mEfficiencyFakeMatchEta_layer[l]->Write();
1254 mEfficiencyFakeMatchPhi_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1255 mEfficiencyFakeMatchPhi_layer[l]->Write();
1256 mEfficiencyFakeMatchPhiTrack_layer[l]->GetZaxis()->SetRangeUser(0, 1);
1257 mEfficiencyFakeMatchPhiTrack_layer[l]->Write();
1258 }
1259
1260 mOutFile->mkdir("Efficiency/");
1261 mOutFile->cd("Efficiency/");
1262 mEfficiencyGoodMatch->Write();
1263 mEfficiencyFakeMatch->Write();
1264 mEfficiencyTotal->Write();
1265 for (int l = 0; l < NLAYERS; l++) {
1266
1267 mEfficiencyGoodMatch_layer[l]->Write();
1268 mEfficiencyFakeMatch_layer[l]->Write();
1269 mEfficiencyTotal_layer[l]->Write();
1270
1271 mEfficiencyGoodMatch_layer[l]->GetYaxis()->SetRangeUser(-0.1, 1.1);
1272 mEfficiencyFakeMatch_layer[l]->GetYaxis()->SetRangeUser(-0.1, 1.1);
1273 mEfficiencyTotal_layer[l]->GetYaxis()->SetRangeUser(-0.1, 1.1);
1274 }
1275
1276 mEfficiencyGoodMatch->GetYaxis()->SetRangeUser(-0.1, 1.1);
1277 mEfficiencyFakeMatch->GetYaxis()->SetRangeUser(-0.1, 1.1);
1278 mEfficiencyTotal->GetYaxis()->SetRangeUser(-0.1, 1.1);
1279
1280 TCanvas c;
1281 c.SetName("EffVsDCA_allLayers");
1282 auto leg = std::make_unique<TLegend>(0.75, 0.45, 0.89, 0.65);
1283 leg->AddEntry(mEfficiencyGoodMatch.get(), "#frac{# good matches}{# tot duplicated clusters}", "p");
1284 leg->AddEntry(mEfficiencyFakeMatch.get(), "#frac{# fake matches}{# tot duplicated clusters}", "p");
1285 leg->AddEntry(mEfficiencyTotal.get(), "#frac{# tot matches}{# tot duplicated clusters}", "p");
1286
1287 mEfficiencyGoodMatch->Draw("P l E1_NOSTAT PLC PMC ");
1288 mEfficiencyFakeMatch->Draw("same P l E1_NOSTAT PLC PMC");
1289 mEfficiencyTotal->Draw("same P l E1_NOSTAT PLC PMC");
1290 leg->Draw("same");
1291 c.Write();
1292 c.SaveAs("prova.png");
1293
1294 TCanvas cc[NLAYERS];
1295 for (int l = 0; l < NLAYERS; l++) {
1296 cc[l].cd();
1297 cc[l].SetName(Form("EffVsDCA_layer_L%d", l));
1298
1299 auto leg = std::make_unique<TLegend>(0.75, 0.45, 0.89, 0.65);
1300 leg->AddEntry(mEfficiencyGoodMatch_layer[l].get(), "#frac{# good matches}{# tot duplicated clusters}", "p");
1301 leg->AddEntry(mEfficiencyFakeMatch_layer[l].get(), "#frac{# fake matches}{# tot duplicated clusters}", "p");
1302 leg->AddEntry(mEfficiencyTotal_layer[l].get(), "#frac{# tot matches}{# tot duplicated clusters}", "p");
1303
1304 mEfficiencyGoodMatch_layer[l]->SetLineColor(kBlue + 3);
1305 mEfficiencyGoodMatch_layer[l]->SetMarkerColor(kBlue + 3);
1306 mEfficiencyGoodMatch_layer[l]->Draw("P l E1_NOSTAT");
1307 mEfficiencyFakeMatch_layer[l]->SetLineColor(kAzure + 7);
1308 mEfficiencyFakeMatch_layer[l]->SetMarkerColor(kAzure + 7);
1309 mEfficiencyFakeMatch_layer[l]->Draw("same P l E1_NOSTAT");
1310 mEfficiencyTotal_layer[l]->SetLineColor(kGreen + 1);
1311 mEfficiencyTotal_layer[l]->SetMarkerColor(kGreen + 1);
1312 mEfficiencyTotal_layer[l]->Draw("same P l E1_NOSTAT");
1313 leg->Draw("same");
1314 cc[l].Write();
1315 cc[l].SaveAs(Form("provaLayer%d.png", l));
1316 }
1317}
1318
1320{
1321 // study to find a good selection method for the duplicated cluster, to be used for non-MC data
1322 // iterate over tracks an associated clusters, and find the closer cluster that is not the original one applying cuts on staveID and chipID
1323 // fix the DCA < 10 sigma, then compute the efficiency for each bin of pt, eta and phi and also in the rows
1324
1325 LOGP(info, "--------------- studyClusterSelection");
1326
1327 int duplicated = getDCAClusterTrackMC(1);
1328
1329 std::cout << "duplicated: " << duplicated << std::endl;
1330
1331 double meanDCAxyDuplicated[NLAYERS] = {0};
1332 double meanDCAzDuplicated[NLAYERS] = {0};
1333 double sigmaDCAxyDuplicated[NLAYERS] = {0};
1334 double sigmaDCAzDuplicated[NLAYERS] = {0};
1335
1336 for (int l = 0; l < NLAYERS; l++) {
1337 meanDCAxyDuplicated[l] = mDCAxyDuplicated_layer[l]->GetMean();
1338 meanDCAzDuplicated[l] = mDCAzDuplicated_layer[l]->GetMean();
1339 sigmaDCAxyDuplicated[l] = mDCAxyDuplicated_layer[l]->GetRMS();
1340 sigmaDCAzDuplicated[l] = mDCAzDuplicated_layer[l]->GetRMS();
1341 }
1342
1343 for (int l = 0; l < NLAYERS; l++) {
1344 LOGP(info, "meanDCAxyDuplicated L{}: {}, meanDCAzDuplicated: {}, sigmaDCAxyDuplicated: {}, sigmaDCAzDuplicated: {}", l, meanDCAxyDuplicated[l], meanDCAzDuplicated[l], sigmaDCAxyDuplicated[l], sigmaDCAzDuplicated[l]);
1345 }
1346
1347 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
1348 o2::gpu::gpustd::array<float, 2> clusOriginalDCA, clusDuplicatedDCA;
1349 auto propagator = o2::base::Propagator::Instance();
1350
1351 unsigned int rofIndexTrack = 0;
1352 unsigned int rofNEntriesTrack = 0;
1353 unsigned int rofIndexClus = 0;
1354 unsigned int rofNEntriesClus = 0;
1355 int nLabels = 0;
1356 unsigned int totClus = 0;
1357
1358 unsigned int nDCAMatches[15] = {0};
1359 unsigned int nGoodMatches[15] = {0};
1360 unsigned int nFakeMatches[15] = {0};
1361
1362 std::map<std::tuple<int, double, o2::MCCompLabel>, bool> clusterMatchesPtEta[100][100] = {};
1363
1364 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
1365 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
1366 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
1367
1368 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
1369 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
1370
1372 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
1373 auto track = mTracks[iTrack];
1374 o2::track::TrackParCov trackParCov = mTracks[iTrack];
1375
1377 float ip[2];
1378 track.getImpactParams(0, 0, 0, 0, ip);
1379
1380 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
1381 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
1382
1383 if (ncl < 7) {
1384 continue;
1385 }
1386
1387 auto& tracklab = mTracksMCLabels[iTrack];
1388 if (tracklab.isFake()) {
1389 continue;
1390 }
1391
1392 auto pt = trackParCov.getPt();
1393 auto eta = trackParCov.getEta();
1394
1395 if (pt < mPtCuts[0] || pt > mPtCuts[1]) {
1396 continue;
1397 }
1398 if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) {
1399 continue;
1400 }
1401
1402 // auto phi = trackParCov.getPhi()*180/M_PI;
1403 float phi = -999.;
1404 float phiOriginal = -999.;
1405 float phiDuplicated = -999.;
1406 UShort_t row = -999;
1407
1408 if (mVerboseOutput) {
1409 LOGP(info, "--------- track Label: ");
1410 tracklab.print();
1411 }
1412 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track to extract layer, stave and chip to restrict the possible matches to be searched with the DCA cut
1413 // LOGP(info, "New cluster");
1414 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
1415 auto layerOriginal = mGeometry->getLayer(clusOriginal.getSensorID());
1416 if (layerOriginal >= NLAYERS) {
1417 continue;
1418 }
1419
1420 IPOriginalxy[layerOriginal]->Fill(ip[0]);
1421 IPOriginalz[layerOriginal]->Fill(ip[1]);
1422
1423 UShort_t rowOriginal = clusOriginal.getRow();
1424
1425 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]];
1426 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
1427 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
1428
1429 auto phiOriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
1430
1431 auto labsOriginal = mClustersMCLCont->getLabels(mInputITSidxs[iclTrack]); // get labels of the cluster associated to the track (original)
1432 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
1433 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
1434
1435 std::tuple<int, double, gsl::span<const o2::MCCompLabel>> clusID_rDCA_label = {0, 999., gsl::span<const o2::MCCompLabel>()}; // inizializing tuple with dummy values
1436
1437 bool adjacentFound = 0;
1439 for (unsigned int iClus = rofIndexClus; iClus < rofIndexClus + rofNEntriesClus; iClus++) { // iteration over ALL the clusters in the ROF
1440 auto clusDuplicated = mClusters[iClus];
1441
1443 if (clusDuplicated.getSensorID() == clusOriginal.getSensorID()) {
1444 continue;
1445 }
1446 auto layerDuplicated = mGeometry->getLayer(clusDuplicated.getSensorID());
1447 if (layerDuplicated != layerOriginal) {
1448 continue;
1449 }
1450 auto staveDuplicated = mGeometry->getStave(clusDuplicated.getSensorID());
1451 if (abs(staveDuplicated - staveOriginal) != 1) {
1452 continue;
1453 }
1454 auto chipDuplicated = mGeometry->getChipIdInStave(clusDuplicated.getSensorID());
1455 if (abs(chipDuplicated - chipOriginal) > 1) {
1456 continue;
1457 }
1458
1459 auto labsDuplicated = mClustersMCLCont->getLabels(iClus);
1460
1462 auto clusDuplicatedPoint = mITSClustersArray[iClus];
1463
1464 o2::math_utils::Point3D<float> clusDuplicatedPointTrack = {clusDuplicatedPoint.getX(), clusDuplicatedPoint.getY(), clusDuplicatedPoint.getZ()};
1465 o2::math_utils::Point3D<float> clusDuplicatedPointGlob = mGeometry->getMatrixT2G(clusDuplicated.getSensorID()) * clusDuplicatedPointTrack;
1466
1467 auto phiDuplicated = clusDuplicatedPointGlob.phi() * 180 / M_PI;
1468
1470 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusDuplicated.getSensorID()));
1471 if (!propagator->propagateToDCA(clusDuplicatedPointGlob, trackParCov, b, 2.f, matCorr, &clusDuplicatedDCA)) { // check if the propagation fails
1472 continue;
1473 }
1474
1475 // Imposing that the distance between the original cluster and the duplicated one is less than x sigma
1476 if (!(abs(meanDCAxyDuplicated[layerDuplicated] - clusDuplicatedDCA[0]) < 8 * sigmaDCAxyDuplicated[layerDuplicated] && abs(meanDCAzDuplicated[layerDuplicated] - clusDuplicatedDCA[1]) < 8 * sigmaDCAzDuplicated[layerDuplicated])) {
1477 continue;
1478 }
1479
1480 if (mVerboseOutput) {
1481 LOGP(info, "Propagation ok");
1482 }
1483 double rDCA = std::hypot(clusDuplicatedDCA[0], clusDuplicatedDCA[1]);
1484
1485 // taking the closest cluster within x sigma
1486 if (rDCA < std::get<1>(clusID_rDCA_label)) { // updating the closest cluster
1487 clusID_rDCA_label = {iClus, rDCA, labsDuplicated};
1488 phi = phiDuplicated;
1489 row = rowOriginal;
1490 }
1491 adjacentFound = 1;
1492
1493 } // end loop on all the clusters in the rof
1494
1495 // here clusID_rDCA_label is updated with the closest cluster to the track other than the original one
1496 // checking if it is a good or fake match looking at the labels
1497
1498 if (!adjacentFound) {
1499 continue;
1500 }
1501
1502 bool isGood = false;
1503 for (auto lab : std::get<2>(clusID_rDCA_label)) {
1504 if (lab == tracklab) {
1505 isGood = true;
1506 diffPhivsPt[layerOriginal]->Fill(pt, abs(phi - phiOriginal));
1507 IPOriginalifDuplicatedxy[layerOriginal]->Fill(ip[0]);
1508 IPOriginalifDuplicatedz[layerOriginal]->Fill(ip[1]);
1509
1510 mNGoodMatchesPt[layerOriginal]->Fill(pt);
1511 mNGoodMatchesRow[layerOriginal]->Fill(row);
1512 mNGoodMatchesPtEta[layerOriginal]->Fill(pt, eta);
1513 mNGoodMatchesPtPhi[layerOriginal]->Fill(pt, phi);
1514 mNGoodMatchesEtaPhi[layerOriginal]->Fill(eta, phi);
1515
1516 mNGoodMatchesEtaAllPt[layerOriginal]->Fill(eta);
1517 mNGoodMatchesPhiAllPt[layerOriginal]->Fill(phi);
1518 for (int ipt = 0; ipt < 3; ipt++) {
1519 if (pt >= mrangesPt[ipt][0] && pt < mrangesPt[ipt][1]) {
1520 mNGoodMatchesEta[layerOriginal][ipt]->Fill(eta);
1521 mNGoodMatchesPhi[layerOriginal][ipt]->Fill(phi);
1522 }
1523 }
1524
1525 break;
1526 }
1527 }
1528 if (!isGood) {
1529
1530 mNFakeMatchesPt[layerOriginal]->Fill(pt);
1531 mNFakeMatchesRow[layerOriginal]->Fill(row);
1532 mNFakeMatchesPtEta[layerOriginal]->Fill(pt, eta);
1533 mNFakeMatchesPtPhi[layerOriginal]->Fill(pt, phi);
1534 mNFakeMatchesEtaPhi[layerOriginal]->Fill(eta, phi);
1535 mNFakeMatchesEtaAllPt[layerOriginal]->Fill(eta);
1536 mNFakeMatchesPhiAllPt[layerOriginal]->Fill(phi);
1537
1538 for (int ipt = 0; ipt < 3; ipt++) {
1539 if (pt >= mrangesPt[ipt][0] && pt < mrangesPt[ipt][1]) {
1540 mNFakeMatchesEta[layerOriginal][ipt]->Fill(eta);
1541 mNFakeMatchesPhi[layerOriginal][ipt]->Fill(phi);
1542 }
1543 }
1544 }
1545 } // end loop on clusters associated to the track
1546 } // end loop on tracks per ROF
1547 } // end loop on ROFRecords array
1548
1549 mOutFile->mkdir("EfficiencyCuts/");
1550 mOutFile->cd("EfficiencyCuts/");
1551
1552 std::cout << "------Calculatin efficiency..." << std::endl;
1553 TH1D* axpt = new TH1D("axpt", "", 1, 0.05, 7.5);
1554 TH1D* axRow = new TH1D("axRow", "", 1, -0.5, 511.5);
1555 TH2D* axptetaGood = new TH2D("axptetaGood", "", 1, 0.05, 7.5, 1, -2, 2);
1556 TH2D* axptetaFake = new TH2D("axptetaFake", "", 1, 0.05, 7.5, 1, -2, 2);
1557 TH2D* axptphiGood = new TH2D("axptphiGood", "", 1, 0.05, 7.5, 1, -180, 180);
1558 TH2D* axptphiFake = new TH2D("axptphiFake", "", 1, 0.05, 7.5, 1, -180, 180);
1559 TH2D* axetaphiGood = new TH2D("axetaphiGood", "", 1, -2, 2, 1, -180, 180);
1560 TH2D* axetaphiFake = new TH2D("axetaphiFake", "", 1, -2, 2, 1, -180, 180);
1561 TH1D* axetaAllPt = new TH1D("axetaAllPt", "", 1, -2, 2);
1562 TH1D* axeta[NLAYERS];
1563 TH1D* axphi[NLAYERS];
1564 for (int ipt = 0; ipt < 3; ipt++) {
1565 axeta[ipt] = new TH1D(Form("axeta%d", ipt), Form("axeta%d", ipt), 1, -2, 2);
1566 axphi[ipt] = new TH1D(Form("axphi%d", ipt), Form("axphi%d", ipt), 1, -180, 180);
1567 }
1568 TH1D* axphiAllPt = new TH1D("axphi", "", 1, -180, 180);
1569
1570 TCanvas* effPt[NLAYERS];
1571 TCanvas* effRow[NLAYERS];
1572 TCanvas* effPtEta[NLAYERS][2];
1573 TCanvas* effPtPhi[NLAYERS][2];
1574 TCanvas* effEtaPhi[NLAYERS][2];
1575 TCanvas* effEtaAllPt[NLAYERS];
1576 TCanvas* effEta[NLAYERS][3];
1577 TCanvas* effPhiAllPt[NLAYERS];
1578 TCanvas* effPhi[NLAYERS][3];
1579
1581 for (int l = 0; l < 3; l++) {
1582 if (mVerboseOutput) {
1583 std::cout << "Pt L" << l << "\n\n";
1584 }
1585
1586 diffPhivsPt[l]->Write();
1587 IPOriginalifDuplicatedxy[l]->Write();
1588 IPOriginalifDuplicatedz[l]->Write();
1589
1590 // Pt
1591 effPt[l] = new TCanvas(Form("effPt_L%d", l));
1592
1593 mEffPtGood[l] = std::make_unique<TEfficiency>(*mNGoodMatchesPt[l], *mDuplicatedPt[l]);
1594 stileEfficiencyGraph(mEffPtGood[l], Form("mEffPtGood_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});Efficiency", l), false, kFullDiamond, 1, kGreen + 3, kGreen + 3);
1595
1596 for (int ibin = 1; ibin <= mNFakeMatchesPt[l]->GetNbinsX(); ibin++) {
1597 if (mNFakeMatchesPt[l]->GetBinContent(ibin) > mDuplicatedPt[l]->GetBinContent(ibin)) {
1598 std::cout << "--- Pt: Npass = " << mNFakeMatchesPt[l]->GetBinContent(ibin) << ", Nall = " << mDuplicatedPt[l]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1599 mNFakeMatchesPt[l]->SetBinContent(ibin, mDuplicatedPt[l]->GetBinContent(ibin));
1600 }
1601 }
1602 mEffPtFake[l] = std::make_unique<TEfficiency>(*mNFakeMatchesPt[l], *mDuplicatedPt[l]);
1603 stileEfficiencyGraph(mEffPtFake[l], Form("mEffPtFake_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});Efficiency", l), false, kFullDiamond, 1, kRed + 1, kRed + 1);
1604
1605 axpt->SetTitle(Form("L%d;#it{p}_{T} (GeV/#it{c});Efficiency", l));
1606 axpt->GetYaxis()->SetRangeUser(-0.1, 1.1);
1607 axpt->GetXaxis()->SetRangeUser(0.05, 7.5);
1608 axpt->Draw();
1609 mEffPtGood[l]->Draw("same p");
1610 mEffPtFake[l]->Draw("same p");
1611
1612 auto legpt = std::make_unique<TLegend>(0.70, 0.15, 0.89, 0.35);
1613 legpt->AddEntry(mEffPtGood[l].get(), "#frac{# good matches}{# tot duplicated clusters}", "pl");
1614 legpt->AddEntry(mEffPtFake[l].get(), "#frac{# fake matches}{# tot duplicated clusters}", "pl");
1615 legpt->Draw("same");
1616 effPt[l]->Write();
1617
1618 // PtEtaGood
1619 effPtEta[l][0] = new TCanvas(Form("effPtEtaGood_L%d", l));
1620
1621 mEffPtEtaGood[l] = std::make_unique<TEfficiency>(*mNGoodMatchesPtEta[l], *mDuplicatedPtEta[l]);
1622 stileEfficiencyGraph(mEffPtEtaGood[l], Form("mEffPtEtaGood_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});#eta;Efficiency", l), true);
1623
1624 axptetaGood->SetTitle(Form("L%d;#it{p}_{T} (GeV/#it{c});#eta;Efficiency", l));
1625 axptetaGood->GetZaxis()->SetRangeUser(-0.1, 1.1);
1626 axptetaGood->GetYaxis()->SetRangeUser(-2., 2.);
1627 axptetaGood->GetXaxis()->SetRangeUser(0.05, 7.5);
1628 axptetaGood->Draw();
1629 mEffPtEtaGood[l]->Draw("same colz");
1630 effPtEta[l][0]->Update();
1631 effPtEta[l][0]->Write();
1632
1633 if (mVerboseOutput) {
1634 std::cout << "Underflow (bin 0,0): " << mNFakeMatchesPtEta[l]->GetBinContent(0, 0) << " " << mDuplicatedPtEta[l]->GetBinContent(0, 0) << std::endl;
1635 std::cout << "Overflow (bin nbinsx,nbinsy): " << mNFakeMatchesPtEta[l]->GetNbinsX() << " " << mNFakeMatchesPtEta[l]->GetNbinsY() << " -> " << mNFakeMatchesPtEta[l]->GetBinContent(mNFakeMatchesPtEta[l]->GetNbinsX(), mNFakeMatchesPtEta[l]->GetNbinsY()) << " " << mDuplicatedPtEta[l]->GetBinContent(mNFakeMatchesPtEta[l]->GetNbinsX(), mNFakeMatchesPtEta[l]->GetNbinsY()) << std::endl;
1636 }
1637
1638 for (int ibin = 1; ibin <= mNFakeMatchesPtEta[l]->GetNbinsX(); ibin++) {
1639 for (int jbin = 1; jbin <= mNFakeMatchesPtEta[l]->GetNbinsY(); jbin++) {
1640 if (mNFakeMatchesPtEta[l]->GetBinContent(ibin, jbin) > mDuplicatedPtEta[l]->GetBinContent(ibin, jbin)) {
1641 if (mVerboseOutput) {
1642 std::cout << "--- PtEta fakematches : Npass = " << mNFakeMatchesPtEta[l]->GetBinContent(ibin, jbin) << ", Nall = " << mDuplicatedPtEta[l]->GetBinContent(ibin, jbin) << " for ibin = " << ibin << ", jbin = " << jbin << std::endl;
1643 }
1644 mNFakeMatchesPtEta[l]->SetBinContent(ibin, jbin, mDuplicatedPtEta[l]->GetBinContent(ibin, jbin));
1645 }
1646 }
1647 }
1648
1649 // Row
1650 effRow[l] = new TCanvas(Form("effRow_L%d", l));
1651
1652 for (int ibin = 1; ibin <= mNGoodMatchesRow[l]->GetNbinsX(); ibin++) {
1653 std::cout << "--- Good Row: Npass = " << mNGoodMatchesRow[l]->GetBinContent(ibin) << ", Nall = " << mDuplicatedRow[l]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1654 }
1655
1656 mEffRowGood[l] = std::make_unique<TEfficiency>(*mNGoodMatchesRow[l], *mDuplicatedRow[l]);
1657 stileEfficiencyGraph(mEffRowGood[l], Form("mEffRowGood_L%d", l), Form("L%d;Row;Efficiency", l), false, kFullDiamond, 1, kGreen + 3, kGreen + 3);
1658
1659 for (int ibin = 1; ibin <= mNFakeMatchesRow[l]->GetNbinsX(); ibin++) {
1660 if (mNFakeMatchesRow[l]->GetBinContent(ibin) > mDuplicatedRow[l]->GetBinContent(ibin)) {
1661 std::cout << "--- Row: Npass = " << mNFakeMatchesRow[l]->GetBinContent(ibin) << ", Nall = " << mDuplicatedRow[l]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1662 mNFakeMatchesRow[l]->SetBinContent(ibin, mDuplicatedRow[l]->GetBinContent(ibin));
1663 }
1664 }
1665 mEffRowFake[l] = std::make_unique<TEfficiency>(*mNFakeMatchesRow[l], *mDuplicatedRow[l]);
1666 stileEfficiencyGraph(mEffRowFake[l], Form("mEffRowFake_L%d", l), Form("L%d;Row;Efficiency", l), false, kFullDiamond, 1, kRed + 1, kRed + 1);
1667
1668 axRow->SetTitle(Form("L%d;Row;Efficiency", l));
1669 axRow->GetYaxis()->SetRangeUser(-0.1, 1.1);
1670 axRow->GetXaxis()->SetRangeUser(0.05, 7.5);
1671 axRow->Draw();
1672 mEffRowGood[l]->Draw("same p");
1673 mEffRowFake[l]->Draw("same p");
1674
1675 auto legRow = std::make_unique<TLegend>(0.70, 0.15, 0.89, 0.35);
1676 legRow->AddEntry(mEffRowGood[l].get(), "#frac{# good matches}{# tot duplicated clusters}", "pl");
1677 legRow->AddEntry(mEffRowFake[l].get(), "#frac{# fake matches}{# tot duplicated clusters}", "pl");
1678 legRow->Draw("same");
1679 effRow[l]->Write();
1680
1681 // PtEtaGood
1682 effPtEta[l][0] = new TCanvas(Form("effPtEtaGood_L%d", l));
1683
1684 mEffPtEtaGood[l] = std::make_unique<TEfficiency>(*mNGoodMatchesPtEta[l], *mDuplicatedPtEta[l]);
1685 stileEfficiencyGraph(mEffPtEtaGood[l], Form("mEffPtEtaGood_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});#eta;Efficiency", l), true);
1686
1687 axptetaGood->SetTitle(Form("L%d;#it{p}_{T} (GeV/#it{c});#eta;Efficiency", l));
1688 axptetaGood->GetZaxis()->SetRangeUser(-0.1, 1.1);
1689 axptetaGood->GetYaxis()->SetRangeUser(-2., 2.);
1690 axptetaGood->GetXaxis()->SetRangeUser(0.05, 7.5);
1691 axptetaGood->Draw();
1692 mEffPtEtaGood[l]->Draw("same colz");
1693 effPtEta[l][0]->Update();
1694 effPtEta[l][0]->Write();
1695
1696 if (mVerboseOutput) {
1697 std::cout << "Underflow (bin 0,0): " << mNFakeMatchesPtEta[l]->GetBinContent(0, 0) << " " << mDuplicatedPtEta[l]->GetBinContent(0, 0) << std::endl;
1698 std::cout << "Overflow (bin nbinsx,nbinsy): " << mNFakeMatchesPtEta[l]->GetNbinsX() << " " << mNFakeMatchesPtEta[l]->GetNbinsY() << " -> " << mNFakeMatchesPtEta[l]->GetBinContent(mNFakeMatchesPtEta[l]->GetNbinsX(), mNFakeMatchesPtEta[l]->GetNbinsY()) << " " << mDuplicatedPtEta[l]->GetBinContent(mNFakeMatchesPtEta[l]->GetNbinsX(), mNFakeMatchesPtEta[l]->GetNbinsY()) << std::endl;
1699 }
1700
1701 for (int ibin = 1; ibin <= mNFakeMatchesPtEta[l]->GetNbinsX(); ibin++) {
1702 for (int jbin = 1; jbin <= mNFakeMatchesPtEta[l]->GetNbinsY(); jbin++) {
1703 if (mNFakeMatchesPtEta[l]->GetBinContent(ibin, jbin) > mDuplicatedPtEta[l]->GetBinContent(ibin, jbin)) {
1704 if (mVerboseOutput) {
1705 std::cout << "--- PtEta fakematches : Npass = " << mNFakeMatchesPtEta[l]->GetBinContent(ibin, jbin) << ", Nall = " << mDuplicatedPtEta[l]->GetBinContent(ibin, jbin) << " for ibin = " << ibin << ", jbin = " << jbin << std::endl;
1706 }
1707 mNFakeMatchesPtEta[l]->SetBinContent(ibin, jbin, mDuplicatedPtEta[l]->GetBinContent(ibin, jbin));
1708 }
1709 }
1710 }
1711
1712 // PtEtaFake
1713 effPtEta[l][1] = new TCanvas(Form("effPtEtaFake_L%d", l));
1714
1715 mEffPtEtaFake[l] = std::make_unique<TEfficiency>(*mNFakeMatchesPtEta[l], *mDuplicatedPtEta[l]);
1716 stileEfficiencyGraph(mEffPtEtaFake[l], Form("mEffPtEtaFake_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});#eta;Efficiency", l), true);
1717 axptetaFake->SetTitle(Form("L%d;#it{p}_{T} (GeV/#it{c});#eta;Efficiency", l));
1718 axptetaFake->GetZaxis()->SetRangeUser(-0.1, 1.1);
1719 axptetaFake->GetYaxis()->SetRangeUser(-2., 2.);
1720 axptetaFake->GetXaxis()->SetRangeUser(0.05, 7.5);
1721 axptetaFake->Draw();
1722 mEffPtEtaFake[l]->Draw("same colz");
1723 effPtEta[l][1]->Update();
1724 effPtEta[l][1]->Write();
1725
1726 // PtPhiGood
1727 effPtPhi[l][0] = new TCanvas(Form("effPtPhiGood_L%d", l));
1728
1729 mEffPtPhiGood[l] = std::make_unique<TEfficiency>(*mNGoodMatchesPtPhi[l], *mDuplicatedPtPhi[l]);
1730 stileEfficiencyGraph(mEffPtPhiGood[l], Form("mEffPtPhiGood_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});#phi (deg);Efficiency", l), true);
1731
1732 axptphiGood->SetTitle(Form("L%d;#it{p}_{T} (GeV/#it{c});#phi (deg);Efficiency", l));
1733 axptphiGood->GetZaxis()->SetRangeUser(-0.1, 1.1);
1734 axptphiGood->GetYaxis()->SetRangeUser(-180, 180);
1735 axptphiGood->GetXaxis()->SetRangeUser(0.05, 7.5);
1736 axptphiGood->Draw();
1737 mEffPtPhiGood[l]->Draw("same colz");
1738 effPtPhi[l][0]->Update();
1739 effPtPhi[l][0]->Write();
1740
1741 for (int ibin = 1; ibin <= mNFakeMatchesPtPhi[l]->GetNbinsX(); ibin++) {
1742 for (int jbin = 1; jbin <= mNFakeMatchesPtPhi[l]->GetNbinsY(); jbin++) {
1743 if (mNFakeMatchesPtPhi[l]->GetBinContent(ibin, jbin) > mDuplicatedPtPhi[l]->GetBinContent(ibin, jbin)) {
1744 if (mVerboseOutput) {
1745 std::cout << "--- Pt: Npass = " << mNFakeMatchesPtPhi[l]->GetBinContent(ibin, jbin) << ", Nall = " << mDuplicatedPtPhi[l]->GetBinContent(ibin, jbin) << " for ibin = " << ibin << ", jbin = " << jbin << std::endl;
1746 }
1747 mNFakeMatchesPtPhi[l]->SetBinContent(ibin, jbin, mDuplicatedPtPhi[l]->GetBinContent(ibin, jbin));
1748 }
1749 }
1750 }
1751
1752 // PtPhiFake
1753 effPtPhi[l][1] = new TCanvas(Form("effPtPhiFake_L%d", l));
1754
1755 mEffPtPhiFake[l] = std::make_unique<TEfficiency>(*mNFakeMatchesPtPhi[l], *mDuplicatedPtPhi[l]);
1756 stileEfficiencyGraph(mEffPtPhiFake[l], Form("mEffPtPhiFake_L%d", l), Form("L%d;#it{p}_{T} (GeV/#it{c});#phi (deg);Efficiency", l), true);
1757 axptphiFake->SetTitle(Form("L%d;#it{p}_{T} (GeV/#it{c});#phi (deg);Efficiency", l));
1758 axptphiFake->GetZaxis()->SetRangeUser(-0.1, 1.1);
1759 axptphiFake->GetYaxis()->SetRangeUser(-180, 180);
1760 axptphiFake->GetXaxis()->SetRangeUser(0.05, 7.5);
1761 axptphiFake->Draw();
1762 mEffPtPhiFake[l]->Draw("same colz");
1763 effPtPhi[l][1]->Update();
1764 effPtPhi[l][1]->Write();
1765
1766 // EtaPhiGood
1767 effEtaPhi[l][0] = new TCanvas(Form("effEtaPhiGood_L%d", l));
1768
1769 mEffEtaPhiGood[l] = std::make_unique<TEfficiency>(*mNGoodMatchesEtaPhi[l], *mDuplicatedEtaPhi[l]);
1770 stileEfficiencyGraph(mEffEtaPhiGood[l], Form("mEffEtaPhiGood_L%d", l), Form("L%d;#eta;#phi (deg);Efficiency", l), true);
1771
1772 axetaphiGood->SetTitle(Form("L%d;#eta;#phi (deg);Efficiency", l));
1773 axetaphiGood->GetZaxis()->SetRangeUser(-0.1, 1.1);
1774 axetaphiGood->GetYaxis()->SetRangeUser(-180, 180);
1775 axetaphiGood->GetXaxis()->SetRangeUser(-2, 2);
1776 axetaphiGood->Draw();
1777 mEffEtaPhiGood[l]->Draw("same colz");
1778 effEtaPhi[l][0]->Update();
1779 effEtaPhi[l][0]->Write();
1780
1781 for (int ibin = 1; ibin <= mNFakeMatchesEtaPhi[l]->GetNbinsX(); ibin++) {
1782 for (int jbin = 1; jbin <= mNFakeMatchesEtaPhi[l]->GetNbinsY(); jbin++) {
1783 if (mNFakeMatchesEtaPhi[l]->GetBinContent(ibin, jbin) > mDuplicatedEtaPhi[l]->GetBinContent(ibin, jbin)) {
1784 if (mVerboseOutput) {
1785 std::cout << "--- Eta: Npass = " << mNFakeMatchesEtaPhi[l]->GetBinContent(ibin, jbin) << ", Nall = " << mDuplicatedEtaPhi[l]->GetBinContent(ibin, jbin) << " for ibin = " << ibin << ", jbin = " << jbin << std::endl;
1786 }
1787 mNFakeMatchesEtaPhi[l]->SetBinContent(ibin, jbin, mDuplicatedEtaPhi[l]->GetBinContent(ibin, jbin));
1788 }
1789 }
1790 }
1791
1792 // EtaPhiFake
1793 effEtaPhi[l][1] = new TCanvas(Form("effEtaPhiFake_L%d", l));
1794
1795 mEffEtaPhiFake[l] = std::make_unique<TEfficiency>(*mNFakeMatchesEtaPhi[l], *mDuplicatedEtaPhi[l]);
1796 stileEfficiencyGraph(mEffEtaPhiFake[l], Form("mEffEtaPhiFake_L%d", l), Form("L%d;#eta;#phi (deg);Efficiency", l), true);
1797 axetaphiFake->SetTitle(Form("L%d;#eta;#phi (deg);Efficiency", l));
1798 axetaphiFake->GetZaxis()->SetRangeUser(-0.1, 1.1);
1799 axetaphiFake->GetYaxis()->SetRangeUser(-180, 180);
1800 axetaphiFake->GetXaxis()->SetRangeUser(-2, 2);
1801 axetaphiFake->Draw();
1802 mEffEtaPhiFake[l]->Draw("same colz");
1803 effEtaPhi[l][1]->Update();
1804 effEtaPhi[l][1]->Write();
1805
1806 // EtaAllPt
1807 if (mVerboseOutput) {
1808 std::cout << "Eta L" << l << "\n\n";
1809 }
1810
1811 effEtaAllPt[l] = new TCanvas(Form("effEtaAllPt_L%d", l));
1812
1813 mEffEtaGoodAllPt[l] = std::make_unique<TEfficiency>(*mNGoodMatchesEtaAllPt[l], *mDuplicatedEtaAllPt[l]);
1814 stileEfficiencyGraph(mEffEtaGoodAllPt[l], Form("mEffEtaGoodAllPt_L%d", l), Form("L%d;#eta;Efficiency", l), false, kFullDiamond, 1, kGreen + 3, kGreen + 3);
1815
1816 for (int ibin = 1; ibin <= mNFakeMatchesEtaAllPt[l]->GetNbinsX(); ibin++) {
1817 if (mNFakeMatchesEtaAllPt[l]->GetBinContent(ibin) > mDuplicatedEtaAllPt[l]->GetBinContent(ibin)) {
1818 if (mVerboseOutput) {
1819 std::cout << "--- EtaAllPt: Npass = " << mNFakeMatchesEtaAllPt[l]->GetBinContent(ibin) << ", Nall = " << mDuplicatedEtaAllPt[l]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1820 }
1821 mNFakeMatchesEtaAllPt[l]->SetBinContent(ibin, mDuplicatedEtaAllPt[l]->GetBinContent(ibin));
1822 }
1823 }
1824 mEffEtaFakeAllPt[l] = std::make_unique<TEfficiency>(*mNFakeMatchesEtaAllPt[l], *mDuplicatedEtaAllPt[l]);
1825 stileEfficiencyGraph(mEffEtaFakeAllPt[l], Form("mEffEtaFakeAllPt_L%d", l), Form("L%d;#eta;Efficiency", l), false, kFullDiamond, 1, kRed + 1, kRed + 1);
1826
1827 axetaAllPt->SetTitle(Form("L%d;#eta;Efficiency", l));
1828 axetaAllPt->GetYaxis()->SetRangeUser(-0.1, 1.1);
1829
1830 axetaAllPt->Draw();
1831 mEffEtaGoodAllPt[l]->Draw("same p");
1832 mEffEtaFakeAllPt[l]->Draw("same p");
1833
1834 auto legEta = std::make_unique<TLegend>(0.70, 0.15, 0.89, 0.35);
1835 legEta->AddEntry(mEffEtaGoodAllPt[l].get(), "#frac{# good matches}{# tot duplicated clusters}", "pl");
1836 legEta->AddEntry(mEffEtaFakeAllPt[l].get(), "#frac{# fake matches}{# tot duplicated clusters}", "pl");
1837 legEta->Draw("same");
1838 effEtaAllPt[l]->Write();
1839
1841 for (int ipt = 0; ipt < 3; ipt++) {
1842 // eta
1843 effEta[l][ipt] = new TCanvas(Form("effEta_L%d_pt%d", l, ipt));
1844
1845 mEffEtaGood[l][ipt] = std::make_unique<TEfficiency>(*mNGoodMatchesEta[l][ipt], *mDuplicatedEta[l][ipt]);
1846 stileEfficiencyGraph(mEffEtaGood[l][ipt], Form("mEffEtaGood_L%d_pt%d", l, ipt), Form("L%d %.1f #leq #it{p}_{T} < %.1f GeV/#it{c};#eta;Efficiency", l, mrangesPt[ipt][0], mrangesPt[ipt][1]), false, kFullDiamond, 1, kGreen + 3, kGreen + 3);
1847
1848 for (int ibin = 1; ibin <= mNFakeMatchesEta[l][ipt]->GetNbinsX(); ibin++) {
1849 if (mNFakeMatchesEta[l][ipt]->GetBinContent(ibin) > mDuplicatedEta[l][ipt]->GetBinContent(ibin)) {
1850 if (mVerboseOutput) {
1851 std::cout << "--- Eta : Npass = " << mNFakeMatchesEta[l][ipt]->GetBinContent(ibin) << ", Nall = " << mDuplicatedEta[l][ipt]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1852 }
1853 mNFakeMatchesEta[l][ipt]->SetBinContent(ibin, mDuplicatedEta[l][ipt]->GetBinContent(ibin));
1854 }
1855 }
1856
1857 mEffEtaFake[l][ipt] = std::make_unique<TEfficiency>(*mNFakeMatchesEta[l][ipt], *mDuplicatedEta[l][ipt]);
1858 stileEfficiencyGraph(mEffEtaFake[l][ipt], Form("mEffEtaFake_L%d_pt%d", l, ipt), Form("L%d %.1f #leq #it{p}_{T} < %.1f GeV/#it{c};#eta;Efficiency", l, mrangesPt[ipt][0], mrangesPt[ipt][1]), false, kFullDiamond, 1, kRed + 1, kRed + 1);
1859
1860 axeta[ipt]->SetTitle(Form("L%d %.1f #leq #it{p}_{T} < %.1f GeV/#it{c};#eta;Efficiency", l, mrangesPt[ipt][0], mrangesPt[ipt][1]));
1861 axeta[ipt]->GetYaxis()->SetRangeUser(-0.1, 1.1);
1862
1863 axeta[ipt]->Draw();
1864 mEffEtaGood[l][ipt]->Draw("same p");
1865 mEffEtaFake[l][ipt]->Draw("same p");
1866
1867 auto legEta = std::make_unique<TLegend>(0.70, 0.15, 0.89, 0.35);
1868 legEta->AddEntry(mEffEtaGood[l][ipt].get(), "#frac{# good matches}{# tot duplicated clusters}", "pl");
1869 legEta->AddEntry(mEffEtaFake[l][ipt].get(), "#frac{# fake matches}{# tot duplicated clusters}", "pl");
1870 legEta->Draw("same");
1871 effEta[l][ipt]->Write();
1872
1873 // phi
1874 effPhi[l][ipt] = new TCanvas(Form("effPhi_L%d_pt%d", l, ipt));
1875
1876 for (int ibin = 1; ibin <= mNGoodMatchesPhi[l][ipt]->GetNbinsX(); ibin++) {
1877 if (mNGoodMatchesPhi[l][ipt]->GetBinContent(ibin) > mDuplicatedPhi[l][ipt]->GetBinContent(ibin)) {
1878 if (mVerboseOutput) {
1879 std::cout << "--- Phi L: Npass = " << mNGoodMatchesPhi[l][ipt]->GetBinContent(ibin) << ", Nall = " << mDuplicatedPhi[l][ipt]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1880 }
1881 mNGoodMatchesPhi[l][ipt]->SetBinContent(ibin, 0);
1882 }
1883 }
1884
1885 mEffPhiGood[l][ipt] = std::make_unique<TEfficiency>(*mNGoodMatchesPhi[l][ipt], *mDuplicatedPhi[l][ipt]);
1886 stileEfficiencyGraph(mEffPhiGood[l][ipt], Form("mEffPhiGood_L%d_pt%d", l, ipt), Form("L%d %.1f #leq #it{p}_{T} < %.1f GeV/#it{c};#phi (deg);Efficiency", l, mrangesPt[ipt][0], mrangesPt[ipt][1]), false, kFullDiamond, 1, kGreen + 3, kGreen + 3);
1887
1888 for (int ibin = 1; ibin <= mNFakeMatchesPhi[l][ipt]->GetNbinsX(); ibin++) {
1889 if (mNFakeMatchesPhi[l][ipt]->GetBinContent(ibin) > mDuplicatedPhi[l][ipt]->GetBinContent(ibin)) {
1890 if (mVerboseOutput) {
1891 std::cout << "--- Phi L: Npass = " << mNFakeMatchesPhi[l][ipt]->GetBinContent(ibin) << ", Nall = " << mDuplicatedPhi[l][ipt]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1892 }
1893 mNFakeMatchesPhi[l][ipt]->SetBinContent(ibin, mDuplicatedPhi[l][ipt]->GetBinContent(ibin));
1894 }
1895 }
1896
1897 mEffPhiFake[l][ipt] = std::make_unique<TEfficiency>(*mNFakeMatchesPhi[l][ipt], *mDuplicatedPhi[l][ipt]);
1898 stileEfficiencyGraph(mEffPhiFake[l][ipt], Form("mEffPhiFake_L%d_pt%d", l, ipt), Form("L%d %.1f #leq #it{p}_{T} < %.1f GeV/#it{c};#phi (deg);Efficiency", l, mrangesPt[ipt][0], mrangesPt[ipt][1]), false, kFullDiamond, 1, kRed + 1, kRed + 1);
1899
1900 axphi[ipt]->SetTitle(Form("L%d %.1f #leq #it{p}_{T} < %.1f GeV/#it{c};#phi (deg);Efficiency", l, mrangesPt[ipt][0], mrangesPt[ipt][1]));
1901 axphi[ipt]->GetYaxis()->SetRangeUser(-0.1, 1.1);
1902
1903 axphi[ipt]->Draw();
1904 mEffPhiGood[l][ipt]->Draw("same p");
1905 mEffPhiFake[l][ipt]->Draw("same p");
1906
1907 auto legPhi = std::make_unique<TLegend>(0.70, 0.15, 0.89, 0.35);
1908 legPhi->AddEntry(mEffPhiGood[l][ipt].get(), "#frac{# good matches}{# tot duplicated clusters}", "pl");
1909 legPhi->AddEntry(mEffPhiFake[l][ipt].get(), "#frac{# fake matches}{# tot duplicated clusters}", "pl");
1910 legPhi->Draw("same");
1911 effPhi[l][ipt]->Write();
1912 }
1913
1914 // PhiAllPt
1915 if (mVerboseOutput) {
1916 std::cout << "Phi L" << l << "\n\n";
1917 }
1918
1919 effPhiAllPt[l] = new TCanvas(Form("effPhiAllPt_L%d", l));
1920
1921 for (int ibin = 1; ibin <= mNGoodMatchesPhiAllPt[l]->GetNbinsX(); ibin++) {
1922 if (mNGoodMatchesPhiAllPt[l]->GetBinContent(ibin) > mDuplicatedPhiAllPt[l]->GetBinContent(ibin)) {
1923 if (mVerboseOutput) {
1924 std::cout << "--- phi all good Npass = " << mNGoodMatchesPhiAllPt[l]->GetBinContent(ibin) << ", Nall = " << mDuplicatedPhiAllPt[l]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1925 }
1926 mNGoodMatchesPhiAllPt[l]->SetBinContent(ibin, 0);
1927 }
1928 }
1929
1930 mEffPhiGoodAllPt[l] = std::make_unique<TEfficiency>(*mNGoodMatchesPhiAllPt[l], *mDuplicatedPhiAllPt[l]);
1931 stileEfficiencyGraph(mEffPhiGoodAllPt[l], Form("mEffPhiGoodAllPt_L%d", l), Form("L%d;#phi;Efficiency", l), false, kFullDiamond, 1, kGreen + 3, kGreen + 3);
1932
1933 for (int ibin = 1; ibin <= mNFakeMatchesPhiAllPt[l]->GetNbinsX(); ibin++) {
1934 if (mNFakeMatchesPhiAllPt[l]->GetBinContent(ibin) > mDuplicatedPhiAllPt[l]->GetBinContent(ibin)) {
1935 if (mVerboseOutput) {
1936 std::cout << "--- phi all fake Npass = " << mNFakeMatchesPhiAllPt[l]->GetBinContent(ibin) << ", Nall = " << mDuplicatedPhiAllPt[l]->GetBinContent(ibin) << " for ibin = " << ibin << std::endl;
1937 }
1938 mNFakeMatchesPhiAllPt[l]->SetBinContent(ibin, mDuplicatedPhiAllPt[l]->GetBinContent(ibin));
1939 }
1940 }
1941 mEffPhiFakeAllPt[l] = std::make_unique<TEfficiency>(*mNFakeMatchesPhiAllPt[l], *mDuplicatedPhiAllPt[l]);
1942 stileEfficiencyGraph(mEffPhiFakeAllPt[l], Form("mEffPhiFakeAllPt_L%d", l), Form("L%d;#phi;Efficiency", l), false, kFullDiamond, 1, kRed + 1, kRed + 1);
1943
1944 axphiAllPt->SetTitle(Form("L%d;#phi;Efficiency", l));
1945 axphiAllPt->GetYaxis()->SetRangeUser(-0.1, 1.1);
1946 axphiAllPt->Draw();
1947 mEffPhiGoodAllPt[l]->Draw("same p");
1948 mEffPhiFakeAllPt[l]->Draw("same p");
1949
1950 auto legPhi = std::make_unique<TLegend>(0.70, 0.15, 0.89, 0.35);
1951 legPhi->AddEntry(mEffPhiGoodAllPt[l].get(), "#frac{# good matches}{# tot duplicated clusters}", "pl");
1952 legPhi->AddEntry(mEffPhiFakeAllPt[l].get(), "#frac{# fake matches}{# tot duplicated clusters}", "pl");
1953 legPhi->Draw("same");
1954 effPhiAllPt[l]->Write();
1955 }
1956}
1957
1959{
1960 // save histograms for data (phi, eta, pt,...)
1961 LOGP(info, "--------------- saveDataInfo");
1962
1963 unsigned int rofIndexTrack = 0;
1964 unsigned int rofNEntriesTrack = 0;
1965 unsigned int rofIndexClus = 0;
1966 unsigned int rofNEntriesClus = 0;
1967 unsigned int totClus = 0;
1968
1969 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
1970 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
1971 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
1972
1973 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
1974 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
1975
1976 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
1977 auto track = mTracks[iTrack];
1978 o2::track::TrackParCov trackParCov = mTracks[iTrack];
1979 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
1980 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
1981
1982 if (ncl < 7) {
1983 continue;
1984 }
1985 float ip[2];
1986 track.getImpactParams(0, 0, 0, 0, ip);
1987
1988 auto pt = trackParCov.getPt();
1989 auto eta = trackParCov.getEta();
1990
1991 float phiTrack = trackParCov.getPhi() * 180 / M_PI;
1992
1993 // if (pt < mPtCuts[0] || pt > mPtCuts[1]) continue;
1994 // if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) continue;
1995
1996 float phioriginal = 0;
1997 float phiduplicated = 0;
1998
1999 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track
2000 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
2001 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]]; // cluster spacepoint in the tracking system
2002 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
2003 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
2004
2005 auto layer = mGeometry->getLayer(clusOriginal.getSensorID());
2006 if (layer >= NLAYERS) {
2007 continue; // checking only selected layers
2008 }
2009
2010 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
2011 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
2012
2013 phioriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
2014
2015 mPhiOriginal[layer]->Fill(phioriginal);
2016 mPhiTrackOriginal[layer]->Fill(phiTrack);
2017 mPtOriginal[layer]->Fill(pt);
2018 mEtaOriginal[layer]->Fill(eta);
2019 m3DClusterPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y(), clusOriginalPointGlob.z());
2020 m2DClusterOriginalPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y());
2021 } // end loop on clusters
2022 totClus += ncl;
2023 } // end loop on tracks per ROF
2024 } // end loop on ROFRecords array
2025 LOGP(info, "Total number of clusters: {} ", totClus);
2026}
2027
2029{
2030 // Extract the efficiency for the IB, exploiting the staves overlaps and the duplicated clusters for the tracks passing through the overlaps
2031 // The denominator for the efficiency calculation will be the number of tracks per layer fulfilling some cuts (DCA, phi, eta, pt)
2032 // The numerator will be the number of duplicated clusters for the tracks passing through the overlaps
2033
2034 LOGP(info, "--------------- getEfficiency");
2035
2036 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
2037 o2::gpu::gpustd::array<float, 2> clusOriginalDCA, clusDuplicatedDCA;
2038 auto propagator = o2::base::Propagator::Instance();
2039
2040 unsigned int rofIndexTrack = 0;
2041 unsigned int rofNEntriesTrack = 0;
2042 unsigned int rofIndexClus = 0;
2043 unsigned int rofNEntriesClus = 0;
2044 int nLabels = 0;
2045 unsigned int totClus = 0;
2046
2047 int nbPt = 75;
2048 double xbins[nbPt + 1], ptcutl = 0.05, ptcuth = 7.5;
2049 double a = std::log(ptcuth / ptcutl) / nbPt;
2050 for (int i = 0; i <= nbPt; i++) {
2051 xbins[i] = ptcutl * std::exp(i * a);
2052 }
2053
2054 int totNClusters;
2055 int nDuplClusters;
2056
2057 // denominator fot the efficiency calculation
2058 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
2059
2060 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
2061 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
2062
2063 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
2064 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
2065
2067 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
2068 auto track = mTracks[iTrack];
2069 o2::track::TrackParCov trackParCov = mTracks[iTrack];
2070
2071 auto pt = trackParCov.getPt();
2072 auto eta = trackParCov.getEta();
2073 float phi = -999.;
2074 float phiOriginal = -999.;
2075
2076 float chi2 = track.getChi2();
2077
2078 float ip[2];
2079 track.getImpactParams(0, 0, 0, 0, ip);
2080
2081 float phiTrack = trackParCov.getPhi() * 180 / M_PI;
2082
2083 // applying the cuts on the track - only pt and eta, and chi2 cuts since for phi(cluster) the layer is needed
2084 if (pt < mPtCuts[0] || pt > mPtCuts[1]) {
2085 continue;
2086 }
2087 if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) {
2088 continue;
2089 }
2090 if (chi2 > mChi2cut) {
2091 continue;
2092 }
2093
2095
2096 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
2097 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
2098
2099 if (ncl < 7) {
2100 continue;
2101 }
2102
2103 o2::MCCompLabel tracklab;
2104 if (isMC) {
2105 tracklab = mTracksMCLabels[iTrack];
2106 if (tracklab.isFake()) {
2107 continue;
2108 }
2109 }
2110
2111 if (mVerboseOutput && isMC) {
2112 LOGP(info, "--------- track Label: ");
2113 tracklab.print();
2114 }
2115
2116 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track to extract layer, stave and chip to restrict the possible matches to be searched with the DCA cut
2117 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
2118 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]];
2119 auto layerOriginal = mGeometry->getLayer(clusOriginal.getSensorID());
2120
2121 UShort_t rowOriginal = clusOriginal.getRow();
2122
2123 if (layerOriginal >= NLAYERS) {
2124 continue;
2125 }
2126
2127 IPOriginalxy[layerOriginal]->Fill(ip[0]);
2128 IPOriginalz[layerOriginal]->Fill(ip[1]);
2129
2130 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
2131 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
2132 // phiOriginal = std::(clusOriginalPointGlob.y(), clusOriginalPointGlob.x()) * 180 / M_PI + 180;
2133 phiOriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
2134
2135 mXoriginal->Fill(clusOriginalPointGlob.x());
2136 mYoriginal->Fill(clusOriginalPointGlob.y());
2137 mZoriginal->Fill(clusOriginalPointGlob.z());
2138
2139 // std::cout<<" Layer: "<<layerOriginal<<" chipid: "<<clusOriginal.getChipID()<<" x: "<<clusOriginalPointGlob.x()<<" y: "<<clusOriginalPointGlob.y()<<" z: "<<clusOriginalPointGlob.z()<<std::endl;
2140
2141 m2DClusterOriginalPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y());
2142 m3DClusterPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y(), clusOriginalPointGlob.z());
2143
2145 bool keepTrack = false;
2146 if (layerOriginal == 0) {
2147
2148 for (int i = 0; i < 10; i++) {
2149 if ((phiOriginal >= mPhiCutsL0[i][0] && phiOriginal <= mPhiCutsL0[i][1])) {
2150 keepTrack = true;
2151 }
2152 }
2153 }
2154 if (layerOriginal == 1) {
2155 for (int i = 0; i < 12; i++) {
2156 if ((phiOriginal >= mPhiCutsL1[i][0] && phiOriginal <= mPhiCutsL1[i][1])) {
2157 keepTrack = true;
2158 }
2159 }
2160 }
2161 if (layerOriginal == 2) {
2162 for (int i = 0; i < 17; i++) {
2163 if ((phiOriginal >= mPhiCutsL2[i][0] && phiOriginal <= mPhiCutsL2[i][1])) {
2164 keepTrack = true;
2165 }
2166 }
2167 }
2168
2170 if (!(keepTrack)) {
2171 continue;
2172 } else {
2173 chi2trackAccepted->Fill(chi2);
2174 denPt[layerOriginal]->Fill(pt);
2175 denPhi[layerOriginal]->Fill(phiOriginal);
2176 denEta[layerOriginal]->Fill(eta);
2177 nTracksSelected[layerOriginal]++;
2178 }
2179
2181 gsl::span<const o2::MCCompLabel> labsOriginal = {};
2182 if (isMC) {
2183 labsOriginal = mClustersMCLCont->getLabels(mInputITSidxs[iclTrack]); // get labels of the cluster associated to the track (original)
2184 }
2185
2186 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
2187 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
2188
2189 std::tuple<int, double, gsl::span<const o2::MCCompLabel>> clusID_rDCA_label = {0, 999., gsl::span<const o2::MCCompLabel>()}; // inizializing tuple with dummy values (if data, ignore the third value)
2190
2191 bool adjacentFound = 0;
2192 float phiDuplicated = -999.;
2193 float ptDuplicated = -999.;
2194 float etaDuplicated = -999.;
2195 float clusZ = -999.;
2198 // std::cout<<"Loop on clusters 2"<<std::endl;
2199 for (unsigned int iClus = rofIndexClus; iClus < rofIndexClus + rofNEntriesClus; iClus++) { // iteration over ALL the clusters in the ROF
2200 auto clusDuplicated = mClusters[iClus];
2201
2202 auto clusDuplicatedPoint = mITSClustersArray[iClus];
2203
2204 o2::math_utils::Point3D<float> clusDuplicatedPointTrack = {clusDuplicatedPoint.getX(), clusDuplicatedPoint.getY(), clusDuplicatedPoint.getZ()};
2205 o2::math_utils::Point3D<float> clusDuplicatedPointGlob = mGeometry->getMatrixT2G(clusDuplicated.getSensorID()) * clusDuplicatedPointTrack;
2206 phi = clusDuplicatedPointGlob.phi() * 180 / M_PI;
2207
2209 if (clusDuplicated.getSensorID() == clusOriginal.getSensorID()) {
2210 continue;
2211 }
2212 auto layerDuplicated = mGeometry->getLayer(clusDuplicated.getSensorID());
2213 if (layerDuplicated != layerOriginal) {
2214 continue;
2215 }
2216 auto staveDuplicated = mGeometry->getStave(clusDuplicated.getSensorID());
2217 if (abs(staveDuplicated - staveOriginal) != 1) {
2218 continue;
2219 }
2220 auto chipDuplicated = mGeometry->getChipIdInStave(clusDuplicated.getSensorID());
2221 if (abs(chipDuplicated - chipOriginal) > 1) {
2222 continue;
2223 }
2224
2225 gsl::span<const o2::MCCompLabel> labsDuplicated = {};
2226 if (isMC) {
2227 labsDuplicated = mClustersMCLCont->getLabels(iClus);
2228 }
2229
2232 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusDuplicated.getSensorID()));
2233 if (!propagator->propagateToDCA(clusDuplicatedPointGlob, trackParCov, b, 2.f, matCorr, &clusDuplicatedDCA)) { // check if the propagation fails
2234 continue;
2235 }
2236
2237 DCAxyData[layerDuplicated]->Fill(clusDuplicatedDCA[0]);
2238 DCAzData[layerDuplicated]->Fill(clusDuplicatedDCA[1]);
2239 // std::cout<<"DCA: "<<clusDuplicatedDCA[0]<<" "<<clusDuplicatedDCA[1]<<" (should be within ["<<mDCACutsXY[layerDuplicated][0]<<","<<mDCACutsXY[layerDuplicated][1]<<"] and ["<<mDCACutsZ[layerDuplicated][0]<<","<<mDCACutsZ[layerDuplicated][1]<<"])"<<std::endl;
2240 // std::cout<<"Point Duplicated (x,y,z): "<<clusDuplicatedPointGlob.x()<<" "<<clusDuplicatedPointGlob.y()<<" "<<clusDuplicatedPointGlob.z()<<std::endl;
2241 // std::cout<<"Point Original (x,y,z): "<<clusOriginalPointGlob.x()<<" "<<clusOriginalPointGlob.y()<<" "<<clusOriginalPointGlob.z()<<std::endl;
2242 // std::cout<<"Layer, chipid, stave : "<<layerDuplicated<<" "<<chipDuplicated<<" "<<staveDuplicated<<std::endl;
2243 // std::cout<<"Track position: "<<trackParCov.getX()<<" "<<trackParCov.getY()<<" "<<trackParCov.getZ()<<std::endl;
2244 DistanceClustersX[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.x() - clusOriginalPointGlob.x()));
2245 DistanceClustersY[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.y() - clusOriginalPointGlob.y()));
2246 DistanceClustersZ[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.z() - clusOriginalPointGlob.z()));
2247
2248 // Imposing that the distance between the duplicated cluster and the track is less than x sigma
2249 if (!(clusDuplicatedDCA[0] > mDCACutsXY[layerDuplicated][0] && clusDuplicatedDCA[0] < mDCACutsXY[layerDuplicated][1] && clusDuplicatedDCA[1] > mDCACutsZ[layerDuplicated][0] && clusDuplicatedDCA[1] < mDCACutsZ[layerDuplicated][1])) {
2250 DCAxyRejected[layerDuplicated]->Fill(clusDuplicatedDCA[0]);
2251 DCAzRejected[layerDuplicated]->Fill(clusDuplicatedDCA[1]);
2252 continue;
2253 }
2254
2255 m2DClusterDuplicatedPositions->Fill(clusDuplicatedPointGlob.x(), clusDuplicatedPointGlob.y());
2256 m3DDuplicatedClusterPositions->Fill(clusDuplicatedPointGlob.x(), clusDuplicatedPointGlob.y(), clusDuplicatedPointGlob.z());
2257
2258 mXduplicated->Fill(clusDuplicatedPointGlob.x());
2259 mYduplicated->Fill(clusDuplicatedPointGlob.y());
2260 mZduplicated->Fill(clusDuplicatedPointGlob.z());
2261
2262 IPOriginalifDuplicatedxy[layerOriginal]->Fill(ip[0]);
2263 IPOriginalifDuplicatedz[layerOriginal]->Fill(ip[1]);
2264
2265 DistanceClustersXAftercuts[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.x() - clusOriginalPointGlob.x()));
2266 DistanceClustersYAftercuts[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.y() - clusOriginalPointGlob.y()));
2267 DistanceClustersZAftercuts[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.z() - clusOriginalPointGlob.z()));
2268
2269 if (mVerboseOutput) {
2270 LOGP(info, "Propagation ok");
2271 }
2272 double rDCA = std::hypot(clusDuplicatedDCA[0], clusDuplicatedDCA[1]);
2273
2274 // taking the closest cluster within x sigma
2275 if (rDCA < std::get<1>(clusID_rDCA_label)) { // updating the closest cluster
2276 if (isMC) {
2277 clusID_rDCA_label = {iClus, rDCA, labsDuplicated};
2278 } else {
2279 clusID_rDCA_label = {iClus, rDCA, gsl::span<const o2::MCCompLabel>()};
2280 }
2281 phiDuplicated = phiOriginal;
2282 ptDuplicated = pt;
2283 etaDuplicated = eta;
2284 clusZ = clusOriginalPointGlob.z();
2285 }
2286 adjacentFound = 1;
2287 } // end loop on all the clusters in the rof -> at this point we have the information on the closest cluster (if there is one)
2288
2289 // here clusID_rDCA_label is updated with the closest cluster to the track other than the original one
2290
2291 if (!adjacentFound) {
2292 continue;
2293 }
2294 nDuplClusters++;
2295 nDuplicatedClusters[layerOriginal]++;
2296 numPt[layerOriginal]->Fill(ptDuplicated);
2297 numPhi[layerOriginal]->Fill(phiDuplicated);
2298 numEta[layerOriginal]->Fill(etaDuplicated);
2299 mZvsPhiDUplicated[layerOriginal]->Fill(clusZ, phiDuplicated);
2300
2301 // checking if it is a good or fake match looking at the labels (only if isMC)
2302 if (isMC) {
2303 bool isGood = false;
2304 for (auto lab : std::get<2>(clusID_rDCA_label)) {
2305 if (lab == tracklab) {
2306 isGood = true;
2307 numPtGood[layerOriginal]->Fill(ptDuplicated);
2308 numPhiGood[layerOriginal]->Fill(phiDuplicated);
2309 numEtaGood[layerOriginal]->Fill(etaDuplicated);
2310 continue;
2311 }
2312 }
2313 if (!isGood) {
2314 numPtFake[layerOriginal]->Fill(ptDuplicated);
2315 numPhiFake[layerOriginal]->Fill(phiDuplicated);
2316 numEtaFake[layerOriginal]->Fill(etaDuplicated);
2317 }
2318 }
2319 } // end loop on clusters associated to the track
2320 totNClusters += NLAYERS;
2321 } // end loop on tracks per ROF
2322 } // end loop on ROFRecords array
2323
2324 std::cout << " Num of duplicated clusters L0: " << nDuplicatedClusters[0] << " N tracks selected: " << nTracksSelected[0] << std::endl;
2325 std::cout << " Num of duplicated clusters L1: " << nDuplicatedClusters[1] << " N tracks selected: " << nTracksSelected[1] << std::endl;
2326 std::cout << " Num of duplicated clusters L2: " << nDuplicatedClusters[2] << " N tracks selected: " << nTracksSelected[2] << std::endl;
2327
2328 std::cout << " --------- N total clusters: " << totNClusters << std::endl;
2329 std::cout << " --------- N duplicated clusters: " << nDuplClusters << std::endl;
2330}
2331
2333{
2334 // Extract the efficiency for the IB, exploiting the staves overlaps and the duplicated clusters for the tracks passing through the overlaps
2335 // The denominator for the efficiency calculation will be the number of tracks per layer fulfilling some cuts (DCA, phi, eta, pt)
2336 // The numerator will be the number of duplicated clusters for the tracks passing through the overlaps
2337 // additionally, print/save info (to be used in MC)
2338
2339 LOGP(info, "--------------- getEfficiency");
2340
2341 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
2342 o2::gpu::gpustd::array<float, 2> clusOriginalDCA, clusDuplicatedDCA;
2343 auto propagator = o2::base::Propagator::Instance();
2344
2345 unsigned int rofIndexTrack = 0;
2346 unsigned int rofNEntriesTrack = 0;
2347 unsigned int rofIndexClus = 0;
2348 unsigned int rofNEntriesClus = 0;
2349 int nLabels = 0;
2350 unsigned int totClus = 0;
2351
2352 int nbPt = 75;
2353 double xbins[nbPt + 1], ptcutl = 0.05, ptcuth = 7.5;
2354 double a = std::log(ptcuth / ptcutl) / nbPt;
2355 for (int i = 0; i <= nbPt; i++) {
2356 xbins[i] = ptcutl * std::exp(i * a);
2357 }
2358
2359 int totNClusters;
2360 int nDuplClusters;
2361
2362 // denominator fot the efficiency calculation
2363 for (unsigned int iROF = 0; iROF < mTracksROFRecords.size(); iROF++) { // loop on ROFRecords array
2364
2365 rofIndexTrack = mTracksROFRecords[iROF].getFirstEntry();
2366 rofNEntriesTrack = mTracksROFRecords[iROF].getNEntries();
2367
2368 rofIndexClus = mClustersROFRecords[iROF].getFirstEntry();
2369 rofNEntriesClus = mClustersROFRecords[iROF].getNEntries();
2370
2372 for (unsigned int iTrack = rofIndexTrack; iTrack < rofIndexTrack + rofNEntriesTrack; iTrack++) { // loop on tracks per ROF
2373 auto track = mTracks[iTrack];
2374 o2::track::TrackParCov trackParCov = mTracks[iTrack];
2375
2376 auto pt = trackParCov.getPt();
2377 auto eta = trackParCov.getEta();
2378 float phi = -999.;
2379 float phiOriginal = -999.;
2380
2381 float chi2 = track.getChi2();
2382
2383 chi2track->Fill(chi2);
2384
2385 float phiTrack = trackParCov.getPhi() * 180 / M_PI;
2386
2387 // applying the cuts on the track - only pt and eta cuts since for phi(cluster) the layer is needed
2388 if (pt < mPtCuts[0] || pt > mPtCuts[1]) {
2389 continue;
2390 }
2391 if (eta < mEtaCuts[0] || eta > mEtaCuts[1]) {
2392 continue;
2393 }
2394 if (chi2 > mChi2cut) {
2395 continue;
2396 }
2398
2399 int firstClus = track.getFirstClusterEntry(); // get the first cluster of the track
2400 int ncl = track.getNumberOfClusters(); // get the number of clusters of the track
2401
2402 if (ncl < 7) {
2403 continue;
2404 }
2405
2406 o2::MCCompLabel tracklab;
2407 if (isMC) {
2408 tracklab = mTracksMCLabels[iTrack];
2409 if (tracklab.isFake()) {
2410 continue;
2411 }
2412 }
2413
2414 if (mVerboseOutput && isMC) {
2415 LOGP(info, "--------- track Label: ");
2416 tracklab.print();
2417 }
2418
2419 for (int iclTrack = firstClus; iclTrack < firstClus + ncl; iclTrack++) { // loop on clusters associated to the track to extract layer, stave and chip to restrict the possible matches to be searched with the DCA cut
2420 auto& clusOriginal = mClusters[mInputITSidxs[iclTrack]];
2421 auto clusOriginalPoint = mITSClustersArray[mInputITSidxs[iclTrack]];
2422 auto layerOriginal = mGeometry->getLayer(clusOriginal.getSensorID());
2423
2424 UShort_t rowOriginal = clusOriginal.getRow();
2425
2426 if (layerOriginal >= NLAYERS) {
2427 continue;
2428 }
2429
2430 o2::math_utils::Point3D<float> clusOriginalPointTrack = {clusOriginalPoint.getX(), clusOriginalPoint.getY(), clusOriginalPoint.getZ()};
2431 o2::math_utils::Point3D<float> clusOriginalPointGlob = mGeometry->getMatrixT2G(clusOriginal.getSensorID()) * clusOriginalPointTrack;
2432 phiOriginal = clusOriginalPointGlob.phi() * 180 / M_PI;
2433
2434 mXoriginal->Fill(clusOriginalPointGlob.x());
2435 mYoriginal->Fill(clusOriginalPointGlob.y());
2436 mZoriginal->Fill(clusOriginalPointGlob.z());
2437
2438 m2DClusterOriginalPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y());
2439 m3DClusterPositions->Fill(clusOriginalPointGlob.x(), clusOriginalPointGlob.y(), clusOriginalPointGlob.z());
2440
2442 bool keepTrack = false;
2443
2444 if (layerOriginal == 0) {
2445 for (int i = 0; i < 10; i++) {
2446 if ((phiOriginal >= mPhiCutsL0[i][0] && phiOriginal <= mPhiCutsL0[i][1])) {
2447 keepTrack = true;
2448 }
2449 }
2450 }
2451 if (layerOriginal == 1) {
2452 for (int i = 0; i < 12; i++) {
2453 if ((phiOriginal >= mPhiCutsL1[i][0] && phiOriginal <= mPhiCutsL1[i][1])) {
2454 keepTrack = true;
2455 }
2456 }
2457 }
2458 if (layerOriginal == 2) {
2459 for (int i = 0; i < 17; i++) {
2460 if ((phiOriginal >= mPhiCutsL2[i][0] && phiOriginal <= mPhiCutsL2[i][1])) {
2461 keepTrack = true;
2462 }
2463 }
2464 }
2465 if (!(keepTrack)) {
2466 continue;
2467 } else {
2468 chi2trackAccepted->Fill(chi2);
2469 denPt[layerOriginal]->Fill(pt);
2470 denPhi[layerOriginal]->Fill(phiOriginal);
2471 denEta[layerOriginal]->Fill(eta);
2472 nTracksSelected[layerOriginal]++;
2473 }
2474 gsl::span<const o2::MCCompLabel> labsOriginal = {};
2475 if (isMC) {
2476 labsOriginal = mClustersMCLCont->getLabels(mInputITSidxs[iclTrack]); // get labels of the cluster associated to the track (original)
2477 }
2478
2479 auto staveOriginal = mGeometry->getStave(clusOriginal.getSensorID());
2480 auto chipOriginal = mGeometry->getChipIdInStave(clusOriginal.getSensorID());
2481
2482 std::tuple<int, double, gsl::span<const o2::MCCompLabel>> clusID_rDCA_label = {0, 999., gsl::span<const o2::MCCompLabel>()}; // inizializing tuple with dummy values (if data, ignore the third value)
2483
2484 bool adjacentFound = 0;
2485 float phiDuplicated = -999.;
2486 float ptDuplicated = -999.;
2487 float etaDuplicated = -999.;
2488 float clusZ = -999.;
2489
2490 o2::MCCompLabel labelCandidateDuplicated;
2491 bool duplExists = false;
2492
2495 for (unsigned int iClus = rofIndexClus; iClus < rofIndexClus + rofNEntriesClus; iClus++) { // iteration over ALL the clusters in the ROF
2496 auto clusDuplicated = mClusters[iClus];
2497
2498 auto clusDuplicatedPoint = mITSClustersArray[iClus];
2499
2500 o2::math_utils::Point3D<float> clusDuplicatedPointTrack = {clusDuplicatedPoint.getX(), clusDuplicatedPoint.getY(), clusDuplicatedPoint.getZ()};
2501 o2::math_utils::Point3D<float> clusDuplicatedPointGlob = mGeometry->getMatrixT2G(clusDuplicated.getSensorID()) * clusDuplicatedPointTrack;
2502 phi = clusDuplicatedPointGlob.phi() * 180 / M_PI;
2503
2505 if (clusDuplicated.getSensorID() == clusOriginal.getSensorID()) {
2506 continue;
2507 }
2508 auto layerDuplicated = mGeometry->getLayer(clusDuplicated.getSensorID());
2509 if (layerDuplicated != layerOriginal) {
2510 continue;
2511 }
2512 labelCandidateDuplicated = mClustersMCLCont->getLabels(iClus)[0];
2513 if (labelCandidateDuplicated == tracklab) {
2514 duplExists = true;
2515 std::cout << "Duplicated should exist with label: " << labelCandidateDuplicated.asString() << " , phi = " << phi << " and be: ";
2516 clusDuplicated.print();
2517 }
2518 auto staveDuplicated = mGeometry->getStave(clusDuplicated.getSensorID());
2519 if (abs(staveDuplicated - staveOriginal) != 1) {
2520 continue;
2521 }
2522 auto chipDuplicated = mGeometry->getChipIdInStave(clusDuplicated.getSensorID());
2523 if (abs(chipDuplicated - chipOriginal) > 1) {
2524 continue;
2525 }
2526
2527 std::cout << "checks passed" << std::endl;
2528
2529 gsl::span<const o2::MCCompLabel> labsDuplicated = {};
2530 if (isMC) {
2531 labsDuplicated = mClustersMCLCont->getLabels(iClus);
2532 }
2533
2536 trackParCov.rotate(mGeometry->getSensorRefAlpha(clusDuplicated.getSensorID()));
2537 if (!propagator->propagateToDCA(clusDuplicatedPointGlob, trackParCov, b, 2.f, matCorr, &clusDuplicatedDCA)) { // check if the propagation fails
2538 continue;
2539 }
2540
2541 std::cout << "dca calculated: " << clusDuplicatedDCA[0] << " " << clusDuplicatedDCA[1] << std::endl;
2542
2543 DCAxyData[layerDuplicated]->Fill(clusDuplicatedDCA[0]);
2544 DCAzData[layerDuplicated]->Fill(clusDuplicatedDCA[1]);
2545 DistanceClustersX[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.x() - clusOriginalPointGlob.x()));
2546 DistanceClustersY[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.y() - clusOriginalPointGlob.y()));
2547 DistanceClustersZ[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.z() - clusOriginalPointGlob.z()));
2548
2549 // Imposing that the distance between the duplicated cluster and the track is less than x sigma
2550 if (!(clusDuplicatedDCA[0] > mDCACutsXY[layerDuplicated][0] && clusDuplicatedDCA[0] < mDCACutsXY[layerDuplicated][1] && clusDuplicatedDCA[1] > mDCACutsZ[layerDuplicated][0] && clusDuplicatedDCA[1] < mDCACutsZ[layerDuplicated][1])) {
2551 DCAxyRejected[layerDuplicated]->Fill(clusDuplicatedDCA[0]);
2552 DCAzRejected[layerDuplicated]->Fill(clusDuplicatedDCA[1]);
2553 continue;
2554 }
2555 m2DClusterDuplicatedPositions->Fill(clusDuplicatedPointGlob.x(), clusDuplicatedPointGlob.y());
2556 m3DDuplicatedClusterPositions->Fill(clusDuplicatedPointGlob.x(), clusDuplicatedPointGlob.y(), clusDuplicatedPointGlob.z());
2557 mXduplicated->Fill(clusDuplicatedPointGlob.x());
2558 mYduplicated->Fill(clusDuplicatedPointGlob.y());
2559 mZduplicated->Fill(clusDuplicatedPointGlob.z());
2560
2561 DistanceClustersXAftercuts[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.x() - clusOriginalPointGlob.x()));
2562 DistanceClustersYAftercuts[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.y() - clusOriginalPointGlob.y()));
2563 DistanceClustersZAftercuts[layerDuplicated]->Fill(abs(clusDuplicatedPointGlob.z() - clusOriginalPointGlob.z()));
2564
2565 if (mVerboseOutput) {
2566 LOGP(info, "Propagation ok");
2567 }
2568 double rDCA = std::hypot(clusDuplicatedDCA[0], clusDuplicatedDCA[1]);
2569
2570 // taking the closest cluster within x sigma
2571 if (rDCA < std::get<1>(clusID_rDCA_label)) { // updating the closest cluster
2572 if (isMC) {
2573 clusID_rDCA_label = {iClus, rDCA, labsDuplicated};
2574 } else {
2575 clusID_rDCA_label = {iClus, rDCA, gsl::span<const o2::MCCompLabel>()};
2576 }
2577 phiDuplicated = phiOriginal;
2578 ptDuplicated = pt;
2579 etaDuplicated = eta;
2580 clusZ = clusOriginalPointGlob.z();
2581 }
2582 adjacentFound = 1;
2583 std::cout << "Duplicated found with label: " << labsDuplicated[0] << " and phi: " << phiDuplicated << std::endl;
2584 clusDuplicated.print();
2585 std::cout << "-----" << std::endl;
2586 } // end loop on all the clusters in the rof -> at this point we have the information on the closest cluster (if there is one)
2587
2588 // here clusID_rDCA_label is updated with the closest cluster to the track other than the original one
2589 // checking if it is a good or fake match looking at the labels (only if isMC)
2590 if (!adjacentFound) {
2591 if (duplExists) {
2592 std::cout << "No duplicated found but should exist" << std::endl;
2593 std::cout << "DCA cuts were: xy-> " << mDCACutsXY[layerOriginal][0] << " to " << mDCACutsXY[layerOriginal][1] << " and z-> " << mDCACutsZ[layerOriginal][0] << " to " << mDCACutsZ[layerOriginal][1] << "\n-----" << std::endl;
2594 } else {
2595 std::cout << "No duplicated found and does not exist" << std::endl;
2596 }
2597 continue;
2598 }
2599 std::cout << "-----" << std::endl;
2600 nDuplClusters++;
2601 nDuplicatedClusters[layerOriginal]++;
2602 numPt[layerOriginal]->Fill(ptDuplicated);
2603 numPhi[layerOriginal]->Fill(phiDuplicated);
2604 numEta[layerOriginal]->Fill(etaDuplicated);
2605 mZvsPhiDUplicated[layerOriginal]->Fill(clusZ, phiDuplicated);
2606
2607 if (isMC) {
2608 bool isGood = false;
2609 for (auto lab : std::get<2>(clusID_rDCA_label)) {
2610 if (lab == tracklab) {
2611 isGood = true;
2612 numPtGood[layerOriginal]->Fill(ptDuplicated);
2613 numPhiGood[layerOriginal]->Fill(phiDuplicated);
2614 numEtaGood[layerOriginal]->Fill(etaDuplicated);
2615 continue;
2616 }
2617 }
2618 if (!isGood) {
2619 numPtFake[layerOriginal]->Fill(ptDuplicated);
2620 numPhiFake[layerOriginal]->Fill(phiDuplicated);
2621 numEtaFake[layerOriginal]->Fill(etaDuplicated);
2622 }
2623 }
2624 } // end loop on clusters associated to the track
2625 totNClusters += NLAYERS;
2626 } // end loop on tracks per ROF
2627 } // end loop on ROFRecords array
2628
2629 std::cout << " Num of duplicated clusters L0: " << nDuplicatedClusters[0] << " N tracks selected: " << nTracksSelected[0] << std::endl;
2630 std::cout << " Num of duplicated clusters L1: " << nDuplicatedClusters[1] << " N tracks selected: " << nTracksSelected[1] << std::endl;
2631 std::cout << " Num of duplicated clusters L2: " << nDuplicatedClusters[2] << " N tracks selected: " << nTracksSelected[2] << std::endl;
2632
2633 std::cout << " --------- N total clusters: " << totNClusters << std::endl;
2634 std::cout << " --------- N duplicated clusters: " << nDuplClusters << std::endl;
2635}
2636
2638{
2639 LOGP(info, "--------------- process");
2640
2642
2643 if (mUseMC) {
2644 // getDCAClusterTrackMC();
2645 // studyDCAcutsMC();
2646 // studyClusterSelectionMC();
2647 // getEfficiencyAndTrackInfo(mUseMC);
2648 // countDuplicatedAfterCuts();
2649 } else if (!mUseMC) {
2650 // saveDataInfo();
2651 }
2652
2653 getEfficiency(mUseMC);
2654
2655 LOGP(info, "** Found in {} rofs:\n\t- {} clusters\n\t",
2656 mClustersROFRecords.size(), mClusters.size());
2657
2658 if (mUseMC) {
2659 LOGP(info, "mClusters size: {}, mClustersROFRecords size: {}, mClustersMCLCont size: {}, mClustersconverted size: {} ", mClusters.size(), mClustersROFRecords.size(), mClustersMCLCont->getNElements(), mITSClustersArray.size());
2660 LOGP(info, "mTracks size: {}, mTracksROFRecords size: {}, mTracksMCLabels size: {}", mTracks.size(), mTracksROFRecords.size(), mTracksMCLabels.size());
2661 } else {
2662 LOGP(info, "mClusters size: {}, mClustersROFRecords size: {}, mClustersconverted size: {} ", mClusters.size(), mClustersROFRecords.size(), mITSClustersArray.size());
2663 LOGP(info, "mTracks size: {}, mTracksROFRecords size: {}", mTracks.size(), mTracksROFRecords.size());
2664 }
2665}
2666
2667void EfficiencyStudy::updateTimeDependentParams(ProcessingContext& pc)
2668{
2669 static bool initOnceDone = false;
2671 if (!initOnceDone) { // this params need to be queried only once
2672 initOnceDone = true;
2673 mGeometry = GeometryTGeo::Instance();
2675 }
2676}
2677
2679{
2680 LOGP(info, "--------------- endOfStream");
2681
2682 mOutFile->mkdir("EfficiencyFinal/");
2683 mOutFile->mkdir("DCAFinal/");
2684
2685 mOutFile->mkdir("DistanceClusters/");
2686 mOutFile->mkdir("DCA/");
2687 mOutFile->mkdir("Pt_Eta_Phi/");
2688
2689 if (mUseMC) {
2690
2691 mOutFile->cd("DistanceClusters");
2692 for (int i = 0; i < NLAYERS; i++) {
2693 mDistanceClustersX[i]->Write();
2694 mDistanceClustersY[i]->Write();
2695 mDistanceClustersZ[i]->Write();
2696 mDistanceClusters[i]->Write();
2697 }
2698
2699 mOutFile->cd("DCA");
2700 mDCAxyDuplicated->Write();
2701 mDCAzDuplicated->Write();
2702 for (int i = 0; i < NLAYERS; i++) {
2703 mDCAxyDuplicated_layer[i]->Write();
2704 mDCAzDuplicated_layer[i]->Write();
2705
2706 mDCAxyOriginal[i]->Write();
2707 mDCAzOriginal[i]->Write();
2708 }
2709
2710 mOutFile->cd("Pt_Eta_Phi/");
2711 for (int i = 0; i < NLAYERS; i++) {
2712 mPhiOriginal[i]->Write();
2713 mPhiTrackOriginal[i]->Write();
2714 mDuplicatedPhiAllPt[i]->Write();
2715 mPtOriginal[i]->Write();
2716 mPtDuplicated[i]->Write();
2717 mEtaDuplicated[i]->Write();
2718 mPhiDuplicated[i]->Write();
2719 mPhiTrackDuplicated[i]->Write();
2720 mPhiTrackDuplicatedvsphiDuplicated[i]->Write();
2721 mPhiTrackoriginalvsphioriginal[i]->Write();
2722 mPhiOriginalIfDuplicated[i]->Write();
2723 mDuplicatedPt[i]->Write();
2724 mDuplicatedPtEta[i]->Write();
2725 mDuplicatedPtPhi[i]->Write();
2726 mDuplicatedEtaPhi[i]->Write();
2727 mEtaOriginal[i]->Write();
2728 mDuplicatedEtaAllPt[i]->Write();
2729 mDuplicatedRow[i]->Write();
2730
2731 for (int p = 0; p < 3; p++) {
2732 mDuplicatedEta[i][p]->Write();
2733 mDuplicatedPhi[i][p]->Write();
2734 }
2735 mPt_EtaDupl[i]->Write();
2736 }
2737 }
2738
2739 mOutFile->cd("Pt_Eta_Phi/");
2740 for (int i = 0; i < NLAYERS; i++) {
2741 IPOriginalxy[i]->Write();
2742 IPOriginalz[i]->Write();
2743 mPhiOriginal[i]->Write();
2744 mPhiTrackOriginal[i]->Write();
2745 mPtOriginal[i]->Write();
2746 mEtaOriginal[i]->Write();
2747 mZvsPhiDUplicated[i]->Write();
2748 chipRowDuplicated[i]->Write();
2749 chipRowOriginalIfDuplicated[i]->Write();
2750 }
2751
2752 mOutFile->mkdir("chi2");
2753 mOutFile->cd("chi2/");
2754
2755 chi2track->Write();
2756 chi2trackAccepted->Write();
2757
2758 mOutFile->cd("EfficiencyFinal/");
2759
2760 for (int l = 0; l < NLAYERS; l++) {
2761
2762 TEfficiency* effPt = new TEfficiency(*numPt[l], *denPt[l]);
2763 effPt->SetName(Form("effPt_layer%d", l));
2764 effPt->SetTitle(Form("L%d;p_{T} (GeV/c);Efficiency", l));
2765 TEfficiency* effPtGood = new TEfficiency(*numPtGood[l], *denPt[l]);
2766 effPtGood->SetName(Form("effPtGood_layer%d", l));
2767 effPtGood->SetTitle(Form("L%d;p_{T} (GeV/c);Efficiency Good Matches", l));
2768 TEfficiency* effPtFake = new TEfficiency(*numPtFake[l], *denPt[l]);
2769 effPtFake->SetName(Form("effPtFake_layer%d", l));
2770 effPtFake->SetTitle(Form("L%d;p_{T} (GeV/c);Efficiency Fake Matches", l));
2771 effPt->Write();
2772 effPtGood->Write();
2773 effPtFake->Write();
2774
2775 TEfficiency* effPhi = new TEfficiency(*numPhi[l], *denPhi[l]);
2776 effPhi->SetName(Form("effPhi_layer%d", l));
2777 effPhi->SetTitle(Form("L%d;#phi;Efficiency", l));
2778 TEfficiency* effPhiGood = new TEfficiency(*numPhiGood[l], *denPhi[l]);
2779 effPhiGood->SetName(Form("effPhiGood_layer%d", l));
2780 effPhiGood->SetTitle(Form("L%d;#phi;Efficiency Good Matches", l));
2781 TEfficiency* effPhiFake = new TEfficiency(*numPhiFake[l], *denPhi[l]);
2782 effPhiFake->SetName(Form("effPhiFake_layer%d", l));
2783 effPhiFake->SetTitle(Form("L%d;#phi;Efficiency Fake Matches", l));
2784 effPhi->Write();
2785 effPhiGood->Write();
2786 effPhiFake->Write();
2787
2788 TEfficiency* effEta = new TEfficiency(*numEta[l], *denEta[l]);
2789 effEta->SetName(Form("effEta_layer%d", l));
2790 effEta->SetTitle(Form("L%d;#eta;Efficiency", l));
2791 TEfficiency* effEtaGood = new TEfficiency(*numEtaGood[l], *denEta[l]);
2792 effEtaGood->SetName(Form("effEtaGood_layer%d", l));
2793 effEtaGood->SetTitle(Form("L%d;#eta;Efficiency Good Matches", l));
2794 TEfficiency* effEtaFake = new TEfficiency(*numEtaFake[l], *denEta[l]);
2795 effEtaFake->SetName(Form("effEtaFake_layer%d", l));
2796 effEtaFake->SetTitle(Form("L%d;#eta;Efficiency Fake Matches", l));
2797 effEta->Write();
2798 effEtaGood->Write();
2799 effEtaFake->Write();
2800
2801 numPhi[l]->Write();
2802 denPhi[l]->Write();
2803 numPt[l]->Write();
2804 denPt[l]->Write();
2805 numEta[l]->Write();
2806 denEta[l]->Write();
2807 }
2808
2809 mOutFile->cd("DCAFinal/");
2810
2811 for (int l = 0; l < NLAYERS; l++) {
2812 DCAxyData[l]->Write();
2813 DCAzData[l]->Write();
2814 DistanceClustersX[l]->Write();
2815 DistanceClustersY[l]->Write();
2816 DistanceClustersZ[l]->Write();
2817 DistanceClustersXAftercuts[l]->Write();
2818 DistanceClustersYAftercuts[l]->Write();
2819 DistanceClustersZAftercuts[l]->Write();
2820 DCAxyRejected[l]->Write();
2821 DCAzRejected[l]->Write();
2822 }
2823
2824 mOutFile->Close();
2825}
2826
2828{
2829 std::cout << "-------- finaliseCCDB" << std::endl;
2830 if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
2831 return;
2832 }
2833 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
2835 return;
2836 }
2837}
2838
2839DataProcessorSpec getEfficiencyStudy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC, std::shared_ptr<o2::steer::MCKinematicsReader> kineReader)
2840{
2841 std::vector<OutputSpec> outputs;
2842 auto dataRequest = std::make_shared<DataRequest>();
2843 dataRequest->requestTracks(srcTracksMask, useMC);
2844 dataRequest->requestClusters(srcClustersMask, useMC);
2845
2846 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
2847 true, // GRPECS=true
2848 false, // GRPLHCIF
2849 true, // GRPMagField
2850 true, // askMatLUT
2852 dataRequest->inputs,
2853 true);
2854 return DataProcessorSpec{
2855 "its-efficiency-study",
2856 dataRequest->inputs,
2857 outputs,
2858 AlgorithmSpec{adaptFromTask<EfficiencyStudy>(dataRequest, srcTracksMask, useMC, kineReader, ggRequest)},
2859 Options{}};
2860}
2861
2862} // namespace o2::its::study
Definition of the ITSMFT compact cluster.
Wrapper container for different reconstructed object types.
Definition of the ClusterTopology class.
int32_t i
uint8_t leg
Helper for geometry and GRP related CCDB requests.
Definition of the GeometryTGeo class.
#define NLAYERS
Definition of the ITSMFT ROFrame (trigger) record.
Definition of the MCTrack class.
uint32_t j
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
Definition of the ITS track.
bool isFake() const
Definition MCCompLabel.h:78
void print() const
std::string asString() const
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:143
gsl::span< TruthElement > getLabels(uint32_t dataindex)
const Mat3D & getMatrixT2G(int sensID) const
const char * getSymbolicName(int index) const
int getLayer(int index) const
Get chip layer, from 0.
float getSensorRefAlpha(int isn) const
int getChipIdInStave(int index) const
Get chip number within stave, from 0.
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
int getStave(int index) const
Get chip stave, from 0.
void getEfficiencyAndTrackInfo(bool isMC)
void setClusterDictionary(const o2::itsmft::TopologyDictionary *d)
void finaliseCCDB(ConcreteDataMatcher &, void *) final
int getDCAClusterTrackMC(int countDuplicated)
void run(ProcessingContext &) final
void stileEfficiencyGraph(std::unique_ptr< TEfficiency > &eff, const char *name, const char *title, bool bidimensional, const int markerStyle, const double markersize, const int markercolor, const int linercolor)
void init(InitContext &) final
void initialiseRun(o2::globaltracking::RecoContainer &)
void process(o2::globaltracking::RecoContainer &)
EfficiencyStudy(std::shared_ptr< DataRequest > dr, mask_t src, bool useMC, std::shared_ptr< o2::steer::MCKinematicsReader > kineReader, std::shared_ptr< o2::base::GRPGeomRequest > gr)
void endOfStream(EndOfStreamContext &) final
This is invoked whenever we have an EndOfStream event.
GLenum src
Definition glcorearb.h:1767
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::array< T, N > array
auto get(const std::byte *buffer, size_t=0)
Definition DataHeader.h:454
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const itsmft::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:49
float mEtaCuts[2]
Definition Efficiency.h:36
float mPtCuts[2]
Definition Efficiency.h:38
float sigmaDcaXY[3]
Definition Efficiency.h:50
float dcaZ[3]
Definition Efficiency.h:49
float mDCACutsZ[3][2]
Definition Efficiency.h:56
float mPhiCutsL0[10][2]
Definition Efficiency.h:32
float sigmaDcaZ[3]
Definition Efficiency.h:51
int mChi2cut
no cut for B=0
Definition Efficiency.h:39
float mDCACutsXY[3][2]
Definition Efficiency.h:55
o2::framework::DataProcessorSpec getEfficiencyStudy(mask_t srcTracksMask, mask_t srcClustersMask, bool useMC, std::shared_ptr< o2::steer::MCKinematicsReader > kineReader)
float mPhiCutsL1[12][2]
Definition Efficiency.h:33
float mPhiCutsL2[17][2]
Definition Efficiency.h:34
float dcaXY[3]
Definition Efficiency.h:48
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
static constexpr int L2G
Definition Cartesian.h:54
static constexpr int T2L
Definition Cartesian.h:55
static constexpr int T2GRot
Definition Cartesian.h:57
static constexpr int T2G
Definition Cartesian.h:56
std::vector< o2::mch::ChannelCode > cc
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row