Belle II Software development
TrackingPerformanceEvaluationModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <tracking/modules/trackingPerformanceEvaluation/TrackingPerformanceEvaluationModule.h>
10
11#include <framework/datastore/StoreArray.h>
12#include <framework/datastore/RelationVector.h>
13
14#include <framework/geometry/BFieldManager.h>
15
16#include <vxd/geometry/GeoCache.h>
17
18#include <mdst/dataobjects/HitPatternCDC.h>
19#include <mdst/dataobjects/HitPatternVXD.h>
20
21#include <pxd/reconstruction/PXDRecoHit.h>
22#include <svd/reconstruction/SVDRecoHit.h>
23#include <svd/reconstruction/SVDRecoHit2D.h>
24#include <cdc/dataobjects/CDCRecoHit.h>
25
26#include <pxd/dataobjects/PXDTrueHit.h>
27#include <pxd/dataobjects/PXDCluster.h>
28#include <svd/dataobjects/SVDCluster.h>
29#include <cdc/dataobjects/CDCHit.h>
30
31#include <genfit/KalmanFitterInfo.h>
32
33#include <root/TObject.h>
34
35using namespace Belle2;
36
37//-----------------------------------------------------------------
38// Register the Module
39//-----------------------------------------------------------------
40REG_MODULE(TrackingPerformanceEvaluation);
41
43 Module()
44{
45
46 setDescription("This module evaluates the tracking package performance");
47
48 addParam("outputFileName", m_rootFileName, "Name of output root file.",
49 std::string("TrackingPerformanceEvaluation_output.root"));
50 addParam("MCParticlesName", m_MCParticlesName, "Name of MC Particle collection.", std::string(""));
51 addParam("TracksName", m_TracksName, "Name of Track collection.", std::string(""));
52 addParam("RecoTracksName", m_RecoTracksName, "Name of RecoTrack collection.", std::string("RecoTracks"));
53 addParam("MCRecoTracksName", m_MCRecoTracksName, "Name of MCRecoTrack collection.", std::string("MCRecoTracks"));
54 addParam("ParticleHypothesis", m_ParticleHypothesis, "Particle Hypothesis used in the track fit.", int(211));
55
56}
57
59{
60
61}
62
64{
65 // MCParticles, Tracks, RecoTracks, MCRecoTracks needed for this module
69
70 m_Tracks.isRequired(m_TracksName);
71
72 //create list of histograms to be saved in the rootfile
73 m_histoList = new TList;
74 m_histoList_multiplicity = new TList;
76 m_histoList_trkQuality = new TList;
77 m_histoList_firstHit = new TList;
78 m_histoList_pr = new TList;
79 m_histoList_fit = new TList;
80 m_histoList_efficiency = new TList;
81 m_histoList_purity = new TList;
82 m_histoList_others = new TList;
83
84 //set the ROOT File
85 m_rootFilePtr = new TFile(m_rootFileName.c_str(), "RECREATE");
86
87 //now create histograms
88
89 //multiplicity histograms
90 m_multiplicityTracks = createHistogram1D("h1nTrk", "number of tracks per MC Particle", 8, -0.5, 7.5, "# tracks",
92
93 m_multiplicityRecoTracks = createHistogram1D("h1nRcTrk", "number of recoTracks per MC Particle", 8, -0.5, 7.5, "# tracks",
95
96 m_multiplicityMCRecoTracks = createHistogram1D("h1nMCRcTrk", "number of MC recoTracks per MC Particle", 8, -0.5, 7.5, "# tracks",
98
99 m_multiplicityFittedTracks = createHistogram1D("h1nFitTrk", "number of fitted tracks per MC Particle", 5, -0.5, 4.5,
100 "# fitted tracks", m_histoList_multiplicity);
101 m_multiplicityFittedTracksPerMCRT = createHistogram1D("h1nFitTrkMCRT", "number of fitted tracks per MCRecoTrack", 5, -0.5, 4.5,
102 "# fitted tracks", m_histoList_multiplicity);
103 m_multiplicityMCParticlesPerTrack = createHistogram1D("h1nMCPrtcl", "number of MCParticles per fitted tracks", 5, -0.5, 4.5,
104 "# MCParticles", m_histoList_multiplicity);
105 m_multiplicityRecoTracksPerMCRT = createHistogram1D("h1nRecoTrack", "number of RecoTrack per MCRecoTrack", 5, -0.5, 4.5,
106 "# RecoTrack",
108 m_multiplicityMCRecoTracksPerRT = createHistogram1D("h1nMCRecoTrack", "number of MCRecoTrack per RecoTrack", 5, -0.5, 4.5,
109 "# MCRecoTrack", m_histoList_multiplicity);
110
111 //tracks pValue
112 m_h1_pValue = createHistogram1D("h1pValue", "pValue of the fit", 100, 0, 1, "pValue", m_histoList_trkQuality);
113
114
115 //track parameters errors
116 m_h1_d0_err = createHistogram1D("h1d0err", "d0 error", 100, 0, 0.1, "#sigma_{d0} (cm)", m_histoList_trkQuality);
117 m_h1_phi_err = createHistogram1D("h1phierr", "#phi error", 100, 0, 0.02, "#sigma_{#phi} (rad)", m_histoList_trkQuality);
118 m_h1_omega_err = createHistogram1D("h1omegaerr", "#omega error", 100, 0, 0.002, "#sigma_{#omega} (cm^{-1})",
120 m_h1_z0_err = createHistogram1D("h1z0err", "z0 error", 100, 0, 0.1, "#sigma_{z0} (cm)", m_histoList_trkQuality);
121 m_h1_cotTheta_err = createHistogram1D("h1cotThetaerr", "cot#theta error", 100, 0, 0.03, "#sigma_{cot#theta}",
123
124 //track parameters residuals
125 m_h1_d0_res = createHistogram1D("h1d0res", "d0 residuals", 100, -0.1, 0.1, "d0 resid (cm)", m_histoList_trkQuality);
126 m_h1_phi_res = createHistogram1D("h1phires", "#phi residuals", 100, -0.1, 0.1, "#phi resid (rad)", m_histoList_trkQuality);
127 m_h1_omega_res = createHistogram1D("h1omegares", "#omega residuals", 100, -0.0005, 0.0005, "#omega resid (cm^{-1})",
129 m_h1_z0_res = createHistogram1D("h1z0res", "z0 residuals", 100, -0.1, 0.1, "z0 resid (cm)", m_histoList_trkQuality);
130 m_h1_cotTheta_res = createHistogram1D("h1cotThetares", "cot#theta residuals", 100, -0.1, 0.1, "cot#theta resid",
132
133 //track parameters residuals - momentum
134 m_h1_px_res = createHistogram1D("h1pxres", "px absolute residuals", 200, -0.05, 0.05, "px_{reco} - px_{MC} (GeV/c)",
136 m_h1_py_res = createHistogram1D("h1pyres", "py absolute residuals", 200, -0.05, 0.05, "py_{reco} - py_{MC} (GeV/c)",
138 m_h1_pz_res = createHistogram1D("h1pzres", "pz absolute residuals", 200, -0.05, 0.05, "pz_{reco} - pz_{MC} (GeV/c)",
140 m_h1_p_res = createHistogram1D("h1pres", "p relative residuals", 200, -0.05, 0.05, "p_{reco} - p_{MC} / p_{MC}",
142 m_h1_pt_res = createHistogram1D("h1ptres", "pt relative residuals", 200, -0.05, 0.05, "pt_{reco} - pt_{MC} / pt_{MC}",
144 //track parameters residuals - position
145 m_h1_x_res = createHistogram1D("h1xres", " residuals", 200, -0.05, 0.05, "x_{reco} - x_{MC} (cm)", m_histoList_trkQuality);
146 m_h1_y_res = createHistogram1D("h1yres", " residuals", 200, -0.05, 0.05, "y_{reco} - y_{MC} (cm)", m_histoList_trkQuality);
147 m_h1_z_res = createHistogram1D("h1zres", " residuals", 200, -0.05, 0.05, "z_{reco} - z_{MC} (cm)", m_histoList_trkQuality);
148 m_h1_r_res = createHistogram1D("h1rres", " residuals", 200, -0.05, 0.05, "r_{reco} - r_{MC} (cm)", m_histoList_trkQuality);
149 m_h1_rtot_res = createHistogram1D("h1rtotres", " residuals", 200, -0.05, 0.05, "rtot_{reco} - rtot_{MC} (cm)",
151
152 m_h2_chargeVSchargeMC = createHistogram2D("h2chargecheck", "chargeVSchargeMC", 3, -1.5, 1.5, "charge MC", 3, -1.5, 1.5,
153 "charge reco", m_histoList_trkQuality);
154
155 //track parameters pulls
156 m_h1_d0_pll = createHistogram1D("h1d0pll", "d0 pulls", 100, -5, 5, "d0 pull", m_histoList_trkQuality);
157 m_h1_phi_pll = createHistogram1D("h1phipll", "#phi pulls", 100, -5, 5, "#phi pull", m_histoList_trkQuality);
158 m_h1_omega_pll = createHistogram1D("h1omegapll", "#omega pulls", 100, -5, 5, "#omega pull", m_histoList_trkQuality);
159 m_h1_z0_pll = createHistogram1D("h1z0pll", "z0 pulls", 100, -5, 5, "z0 pull", m_histoList_trkQuality);
160 m_h1_cotTheta_pll = createHistogram1D("h1cotThetapll", "cot#theta pulls", 100, -5, 5, "cot#theta pull", m_histoList_trkQuality);
161
162
163 //first hit position using track parameters errors
164 m_h2_d0errphi0err_xy = createHistogram2D("h2d0errphierrXY", "#sigma_{d0}/#sigma_{#phi} projected on x,y",
165 2000, -10, 10, "x (cm)",
166 2000, -10, 10, "y (cm)",
168
169 m_h2_d0errphi0err_rz = createHistogram2D("h2d0errphierrRZ", "#sigma_{d0}/#sigma_{#phi} projected on z and r_{t}=#sqrt{x^{2}+y^{2}}",
170 2000, -30, 40, "z (cm)",
171 2000, 0, 15, "r_{t} (cm)",
173
174 m_h2_z0errcotThetaerr_xy = (TH2F*)duplicateHistogram("h2z0errcotThetaerrXY", "#sigma_{z0}/#sigma_{cot#theta} projected on x,y",
177
178 m_h2_OmegaerrOmegaVSpt = createHistogram2D("h2OmegaerrOmegaVSpt", "#sigma_{#omega}/#omega VS p_{t}",
179 100, 0, 3, "p_{t} (GeV/c)",
180 1000, 0, 0.2, "#sigma_{#omega}/#omega",
182
183
184 m_h2_z0errVSpt = createHistogram2D("h2z0errVSpt", "#sigma_{z0} VS p_{t}",
185 100, 0, 3, "p_{t} (GeV/c)",
186 100, 0, 0.1, "#sigma_{z0} (cm)",
188
189 m_h2_z0errVSpt_wtpxd = (TH2F*)duplicateHistogram("h2z0errVSpt_wTruePXD", "#sigma_{z0} VS p_{t}, with True PXD hits", m_h2_z0errVSpt,
191 m_h2_z0errVSpt_wfpxd = (TH2F*)duplicateHistogram("h2z0errVSpt_wFalsePXD", "#sigma_{z0} VS p_{t}, with False PXD hits",
194 m_h2_z0errVSpt_wpxd = (TH2F*)duplicateHistogram("h2z0errVSpt_wPXD", "#sigma_{z0} VS p_{t}, with PXD hits", m_h2_z0errVSpt,
196
197 m_h2_z0errVSpt_wopxd = (TH2F*)duplicateHistogram("h2z0errVSpt_woPXD", "#sigma_{z0} VS p_{t}, no PXD hits", m_h2_z0errVSpt,
199
200 m_h2_d0errVSpt = createHistogram2D("h2d0errVSpt", "#sigma_{d0} VS p_{t}",
201 100, 0, 3, "p_{t} (GeV/c)",
202 100, 0, 0.1, "#sigma_{d0} (cm)",
204 m_h2_d0errVSpt_wtpxd = (TH2F*)duplicateHistogram("h2d0errVSpt_wTruePXD", "#sigma_{d0} VS p_{t}, with True PXD hits", m_h2_d0errVSpt,
206 m_h2_d0errVSpt_wfpxd = (TH2F*)duplicateHistogram("h2d0errVSpt_wFalsePXD", "#sigma_{d0} VS p_{t}, with False PXD hits",
209 m_h2_d0errVSpt_wpxd = (TH2F*)duplicateHistogram("h2d0errVSpt_wPXD", "#sigma_{d0} VS p_{t}, with PXD hits", m_h2_d0errVSpt,
211
212 m_h2_d0errVSpt_wopxd = (TH2F*)duplicateHistogram("h2d0errVSpt_woPXD", "#sigma_{d0} VS p_{t}, no PXD hits", m_h2_d0errVSpt,
214 m_h2_d0errMSVSpt = createHistogram2D("h2d0errMSVSpt", "#sigma_{d0} * #betapsin^{3/2}#theta VS p_{t}",
215 50, 0, 2.5, "p_{t} (GeV/c)",
216 500, 0, 1, "cm",
218
219 //hits used in the fit
220 m_h2_TrackPointFitWeightVXD = createHistogram2D("h2TPFitWeightVXD", "VXD TrackPoint Fit Weight", 6, 0.5, 6.5, "VXD layer", 20, 0, 1,
221 "weight", m_histoList);
222 m_h2_TrackPointFitWeightCDC = createHistogram2D("h2TPFitWeightCDC", "CDC TrackPoint Fit Weight", 56, -0.5, 55.5, "CDC layer", 20, 0,
223 1, "weight", m_histoList);
224
225 m_h1_nHitDetID = createHistogram1D("h1nHitDetID", "detector ID per hit", 4, -0.5, 3.5, "0=PXD, 1=SVD2D, 2=SVD,3=CDC", m_histoList);
226 m_h1_nCDChitsPR = createHistogram1D("h1nCDCHitsPR", "number of CDC hits from PR per Layer", 56, -0.5, 55.5, "CDC Layer",
228 m_h1_nCDChitsWeighted = (TH1F*)duplicateHistogram("h1nCDCHitsWeighted", "CDC hits used in the fit per Layer, weighted",
230 m_h1_nCDChitsUsed = (TH1F*)duplicateHistogram("h1nCDCHitsUsed",
231 "approximated number of CDC hits used in the fit per Layer, weighted", m_h1_nCDChitsPR, m_histoList);
232 m_h1_nVXDhitsPR = createHistogram1D("h1nVXDHitsPR", "number of VXD hits from PR per Layer", 6, 0.5, 6.5, "VXD Layer", m_histoList);
233 m_h1_nVXDhitsWeighted = (TH1F*)duplicateHistogram("h1nVXDHitsWeighted", "number of VXD hits used in the fit per Layer, weighted",
235 m_h1_nVXDhitsUsed = (TH1F*)duplicateHistogram("h1nVXDHitsUsed",
236 "approximate number of VXD hits used in the fit per Layer, weighted", m_h1_nVXDhitsPR, m_histoList);
237 m_h2_VXDhitsPR_xy = createHistogram2D("h2hitsPRXY", "Pattern Recognition hits, transverse plane",
238 2000, -15, 15, "x (cm)",
239 2000, -15, 15, "y (cm)",
241
242 m_h2_VXDhitsPR_rz = createHistogram2D("h2hitsPRRZ", "Pattern Recognition Hits, r_{t} z",
243 2000, -30, 40, "z (cm)",
244 2000, 0, 15, "r_{t} (cm)",
246
247
248
249 //histograms to produce efficiency plots
250 Double_t bins_pt[10 + 1] = {0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.5, 1, 1.5, 2, 3.5}; //GeV/c
251 Double_t bins_theta[10 + 1] = {0, 0.25, 0.5, 0.75, 0.75 + 0.32, 0.75 + 2 * 0.32, 0.75 + 3 * 0.32, 0.75 + 4 * 0.32, 0.75 + 5 * 0.32, 2.65, TMath::Pi()};
252 Double_t bins_phi[14 + 1];
253 Double_t width_phi = 2 * TMath::Pi() / 14;
254 for (int bin = 0; bin < 14 + 1; bin++)
255 bins_phi[bin] = - TMath::Pi() + bin * width_phi;
256
257
258 m_h3_MCParticle = createHistogram3D("h3MCParticle", "entry per MCParticle",
259 10, bins_pt, "p_{t} (GeV/c)",
260 10, bins_theta, "#theta",
261 14, bins_phi, "#phi" /*, m_histoList*/);
262
263 m_h3_TracksPerMCParticle = (TH3F*)duplicateHistogram("h3TracksPerMCParticle",
264 "entry per Track connected to a MCParticle",
265 m_h3_MCParticle /*, m_histoList*/);
266
267 m_h3_TrackswPXDHitsPerMCParticle = (TH3F*)duplicateHistogram("h3TrackswPXDHitsPerMCParticle",
268 "entry per Track with PXD hits connected to a MCParticle",
269 m_h3_MCParticle /*, m_histoList*/);
270
271 m_h3_RecoTrackswPXDHitsPerMCParticle = (TH3F*)duplicateHistogram("h3RecoTrackswPXDHitsPerMCParticle",
272 "entry per RecoTrack with PXD hits connected to a MCParticle",
273 m_h3_MCParticle /*, m_histoList*/);
274
275 m_h3_RecoTrackswPXDHitsPerMCParticlewPXDHits = (TH3F*)duplicateHistogram("h3RecoTrackswPXDHitsPerMCParticlewPXDHits",
276 "entry per RecoTrack with PXD hits connected to a MCParticle with PXD hits",
277 m_h3_MCParticle /*, m_histoList*/);
278
279 m_h3_MCParticleswPXDHits = (TH3F*)duplicateHistogram("h3MCParticleswPXDHitsPerMCParticle",
280 "entry per MCParticle with PXD hits",
281 m_h3_MCParticle /*, m_histoList*/);
282
283 m_h3_MCRecoTrack = (TH3F*)duplicateHistogram("h3MCRecoTrack",
284 "entry per MCRecoTrack connected to the MCParticle",
285 m_h3_MCParticle /*, m_histoList*/);
286
287 m_h3_TracksPerMCRecoTrack = (TH3F*)duplicateHistogram("h3TracksPerMCRecoTrack",
288 "entry per Track connected to an MCRecoTrack",
289 m_h3_MCParticle /*, m_histoList*/);
290 //plus
291 m_h3_MCParticle_plus = (TH3F*)duplicateHistogram("h3MCParticle_plus", "entry per positive MCParticle",
292 m_h3_MCParticle /*, m_histoList*/);
293
294 m_h3_TracksPerMCParticle_plus = (TH3F*)duplicateHistogram("h3TracksPerMCParticle_plus",
295 "entry per Track connected to a positive MCParticle",
296 m_h3_MCParticle /*, m_histoList*/);
297
298 m_h3_MCRecoTrack_plus = (TH3F*)duplicateHistogram("h3MCRecoTrack_plus",
299 "entry per MCRecoTrack connected to the positive MCParticle",
300 m_h3_MCParticle /*, m_histoList*/);
301
302 m_h3_TracksPerMCRecoTrack_plus = (TH3F*)duplicateHistogram("h3TracksPerMCRecoTrack_plus",
303 "entry per Track connected to a positive MCRecoTrack",
304 m_h3_MCParticle /*, m_histoList*/);
305
306
307 //minus
308 m_h3_MCParticle_minus = (TH3F*)duplicateHistogram("h3MCParticlee_minus", "entry per negative MCParticle",
309 m_h3_MCParticle /*, m_histoList*/);
310
311 m_h3_TracksPerMCParticle_minus = (TH3F*)duplicateHistogram("h3TracksPerMCParticle_minus",
312 "entry per Track connected to a negative MCParticle",
313 m_h3_MCParticle /*, m_histoList*/);
314
315 m_h3_MCRecoTrack_minus = (TH3F*)duplicateHistogram("h3MCRecoTrack_minus",
316 "entry per MCRecoTrack connected to the negative MCParticle",
317 m_h3_MCParticle /*, m_histoList*/);
318
319 m_h3_TracksPerMCRecoTrack_minus = (TH3F*)duplicateHistogram("h3TracksPerMCRecoTrack_minus",
320 "entry per Track connected to a negative MCRecoTrack",
321 m_h3_MCParticle /*, m_histoList*/);
322
323 //histograms to produce efficiency plots
324 m_h1_HitsRecoTrackPerMCRecoTrack = createHistogram1D("h1hitsTCperMCRT", "RecoTrack per MCRecoTrack Hit in VXD layers", 6, 0.5, 6.5,
325 "# VXD layer" /*, m_histoList*/);
326
327 m_h1_HitsMCRecoTrack = (TH1F*) duplicateHistogram("h1hitsMCRT", " MCRecoTrack Hit in VXD layers",
328 m_h1_HitsRecoTrackPerMCRecoTrack /*, m_histoList*/);
329
330
331 //histograms to produce purity plots
332 m_h3_Tracks = (TH3F*)duplicateHistogram("h3Tracks", "entry per Track",
333 m_h3_MCParticle /*, m_histoList*/);
334
335 m_h3_MCParticlesPerTrack = (TH3F*)duplicateHistogram("h3MCParticlesPerTrack",
336 "entry per MCParticle connected to a Track",
337 m_h3_MCParticle /*, m_histoList*/);
338}
339
341{
342
343}
344
346{
347 ROOT::Math::XYZVector magField = BFieldManager::getField(0, 0, 0) / Unit::T;
348
349 bool hasTrack = false;
350 B2DEBUG(29, "+++++ 1. loop on MCParticles");
351 for (const MCParticle& mcParticle : m_MCParticles) {
352
353 if (! isTraceable(mcParticle))
354 continue;
355
356 int pdgCode = mcParticle.getPDG();
357 B2DEBUG(29, "MCParticle has PDG code " << pdgCode);
358
359 int nFittedTracksMCRT = 0;
360 int nFittedTracks = 0;
361
362 MCParticleInfo mcParticleInfo(mcParticle, magField);
363
364 hasTrack = false;
365
366 m_h3_MCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
367
368 if (mcParticleInfo.getCharge() > 0)
369 m_h3_MCParticle_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
370 else if (mcParticleInfo.getCharge() < 0)
371 m_h3_MCParticle_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
372 else
373 continue;
374
375 if (mcParticle.hasSeenInDetector(Const::PXD))
376 m_h3_MCParticleswPXDHits->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
377
378 //1. retrieve all the Tracks related to the MCParticle
379
380 //1.0 check if there is a RecoTrack
381 RelationVector<RecoTrack> MCRecoTracks_fromMCParticle =
382 DataStore::getRelationsWithObj<RecoTrack>(&mcParticle, m_MCRecoTracksName);
383
384 if (MCRecoTracks_fromMCParticle.size() > 0)
385 if (MCRecoTracks_fromMCParticle[0]->hasPXDHits()) {
386 m_h3_RecoTrackswPXDHitsPerMCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
387 if (mcParticle.hasSeenInDetector(Const::PXD))
388 m_h3_RecoTrackswPXDHitsPerMCParticlewPXDHits->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
389 }
390 m_multiplicityMCRecoTracks->Fill(MCRecoTracks_fromMCParticle.size());
391
392 RelationVector<RecoTrack> RecoTracks_fromMCParticle =
393 DataStore::getRelationsWithObj<RecoTrack>(&mcParticle, m_RecoTracksName);
394
395 m_multiplicityRecoTracks->Fill(RecoTracks_fromMCParticle.size());
396
397 if (MCRecoTracks_fromMCParticle.size() > 0) {
398 m_h3_MCRecoTrack->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
399
400 if (mcParticleInfo.getCharge() > 0)
401 m_h3_MCRecoTrack_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
402 else if (mcParticleInfo.getCharge() < 0)
403 m_h3_MCRecoTrack_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
404 else
405 continue;
406 }
407
408 //1.a retrieve all Tracks related to the MCParticle
409 RelationVector<Track> Tracks_fromMCParticle = DataStore::getRelationsWithObj<Track>(&mcParticle);
410 m_multiplicityTracks->Fill(Tracks_fromMCParticle.size());
411
412 B2DEBUG(29, Tracks_fromMCParticle.size() << " Tracks related to this MCParticle");
413
414 for (int trk = 0; trk < (int)Tracks_fromMCParticle.size(); trk++) {
415
416 const TrackFitResult* fitResult = Tracks_fromMCParticle[trk]->getTrackFitResult(Const::ChargedStable(m_ParticleHypothesis));
417
418 if ((fitResult == nullptr) || (fitResult->getParticleType() != Const::ChargedStable(m_ParticleHypothesis)))
419 B2WARNING(" the TrackFitResult is not found!");
420
421 else { // valid TrackFitResult found
422
423 if (!hasTrack) {
424
425 hasTrack = true;
426
427 nFittedTracks++;
428
429 if (fitResult->getHitPatternVXD().getNPXDHits() > 0) {
430 m_h3_TrackswPXDHitsPerMCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
431 }
432
433 m_h3_TracksPerMCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
434 if (mcParticleInfo.getCharge() > 0)
435 m_h3_TracksPerMCParticle_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
436 else if (mcParticleInfo.getCharge() < 0)
437 m_h3_TracksPerMCParticle_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
438 else
439 continue;
440
441 if (MCRecoTracks_fromMCParticle.size() > 0) {
442 nFittedTracksMCRT++;
443 m_h3_TracksPerMCRecoTrack->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
444 if (mcParticleInfo.getCharge() > 0)
445 m_h3_TracksPerMCRecoTrack_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
446 else if (mcParticleInfo.getCharge() < 0)
447 m_h3_TracksPerMCRecoTrack_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
448 else
449 continue;
450 }
451
452
453 }
454
455
456 fillTrackParams1DHistograms(fitResult, mcParticleInfo);
457
458 }
459 }
460
461 m_multiplicityFittedTracks->Fill(nFittedTracks);
462 if (MCRecoTracks_fromMCParticle.size() > 0)
463 m_multiplicityFittedTracksPerMCRT->Fill(nFittedTracksMCRT);
464
465 }
466
467
468 B2DEBUG(29, "+++++ 2. loop on Tracks");
469
470 //2. retrieve all the MCParticles related to the Tracks
472
473 for (const Track& track : m_Tracks) {
474
475 int nMCParticles = 0;
476
477 //check if the track has been fitted
478 const TrackFitResult* fitResult = track.getTrackFitResult(Const::ChargedStable(m_ParticleHypothesis));
479
480 if ((fitResult == nullptr) || (fitResult->getParticleType() != Const::ChargedStable(m_ParticleHypothesis)))
481 continue;
482
483 m_h1_pValue->Fill(fitResult->getPValue());
484
485 ROOT::Math::XYZVector momentum = fitResult->getMomentum();
486 m_h3_Tracks->Fill(momentum.Rho(), momentum.Theta(), momentum.Phi());
487
489
491
492 for (int layer = 0; layer < 56; layer++) {
493 if (fitResult->getHitPatternCDC().hasLayer(layer))
494 m_h1_nCDChitsUsed->Fill(layer);
495 }
496 for (int layer = 1; layer <= 2; layer++) {
497 for (int i = 0; i < fitResult->getHitPatternVXD().getPXDLayer(layer); i++)
498 m_h1_nVXDhitsUsed->Fill(layer);
499 }
500 for (int layer = 3; layer <= 6; layer++) {
501 int n1 = fitResult->getHitPatternVXD().getSVDLayer(layer).first;
502 int n2 = fitResult->getHitPatternVXD().getSVDLayer(layer).second;
503 int N = n1 + n2;
504
505 for (int i = 0; i < N; i++)
506 m_h1_nVXDhitsUsed->Fill(layer);
507 }
508
509
510 RelationVector<MCParticle> MCParticles_fromTrack = DataStore::getRelationsWithObj<MCParticle>(&track);
511
512 for (int mcp = 0; mcp < (int)MCParticles_fromTrack.size(); mcp++)
513 if (isTraceable(*MCParticles_fromTrack[mcp])) {
514 nMCParticles ++;
515 m_h3_MCParticlesPerTrack->Fill(momentum.Rho(), momentum.Theta(), momentum.Phi());
516 }
517 // }
518
519 m_multiplicityMCParticlesPerTrack->Fill(nMCParticles);
520
521 }
522
523
524 B2DEBUG(29, "+++++ 3. loop on MCRecoTracks");
525
526 for (const RecoTrack& mcRecoTrack : m_MCRecoTracks) {
527
528 bool hasRecoTrack = false;
529
530 //3.a retrieve the RecoTrack
531 RelationVector<RecoTrack> RecoTracks_fromMCRecoTrack = DataStore::getRelationsWithObj<RecoTrack>(&mcRecoTrack);
532 B2DEBUG(29, "~ " << RecoTracks_fromMCRecoTrack.size() << " RecoTracks related to this MCRecoTrack");
533 m_multiplicityRecoTracksPerMCRT->Fill(RecoTracks_fromMCRecoTrack.size());
534
535 //3.a retrieve the MCParticle
536 RelationVector<MCParticle> MCParticles_fromMCRecoTrack = DataStore::getRelationsWithObj<MCParticle>(&mcRecoTrack);
537
538 B2DEBUG(29, "~~~ " << MCParticles_fromMCRecoTrack.size() << " MCParticles related to this MCRecoTrack");
539 for (int mcp = 0; mcp < (int)MCParticles_fromMCRecoTrack.size(); mcp++) {
540
541 //3.b retrieve all RecoTracks related to the MCRecoTrack
542 RelationVector<RecoTrack> RecoTracks_fromMCParticle = DataStore::getRelationsWithObj<RecoTrack>
543 (MCParticles_fromMCRecoTrack[mcp]);
544
545 B2DEBUG(29, "~~~~~ " << RecoTracks_fromMCParticle.size() << " RecoTracks related to this MCParticle");
546 for (int tc = 0; tc < (int)RecoTracks_fromMCParticle.size(); tc++)
547 if (!hasRecoTrack) {
548 hasRecoTrack = true;
549 }
550
551 }
552
553 }
554
555
556 B2DEBUG(29, "+++++ 4. loop on RecoTracks");
557
558 //4. retrieve all RecoTracks
559
560 for (const RecoTrack& recoTrack : m_PRRecoTracks) {
561
562 // int nMCRecoTrack = 0;
563
564 // retrieve the MCRecoTrack
565 RelationVector<RecoTrack> MCRecoTracks_fromRecoTrack = DataStore::getRelationsWithObj<RecoTrack>(&recoTrack, m_MCRecoTracksName);
566 m_multiplicityMCRecoTracksPerRT->Fill(MCRecoTracks_fromRecoTrack.size());
567
568
569 /*
570 //4.a retrieve the MCParticle
571 RelationVector<MCParticle> MCParticles_fromRecoTrack = DataStore::getRelationsWithObj<MCParticle>(&recoTrack);
572
573 B2DEBUG(29, "~~~ " << MCParticles_fromRecoTrack.size() << " MCParticles related to this RecoTrack");
574 for (int mcp = 0; mcp < (int)MCParticles_fromRecoTrack.size(); mcp++) {
575
576 //4.b retrieve all MCRecoTracks related to the RecoTrack
577 RelationVector<RecoTrack> mcRecoTracks_fromMCParticle = DataStore::getRelationsWithObj<RecoTrack>
578 (MCParticles_fromRecoTrack[mcp], m_MCRecoTracksName);
579
580 B2DEBUG(29, "~~~~~ " << mcRecoTracks_fromMCParticle.size() << " MCRecoTracks related to this MCParticle");
581 for (int mctc = 0; mctc < (int)mcRecoTracks_fromMCParticle.size(); mctc++) {
582 nMCRecoTrack++;
583
584 }
585 }
586
587 // m_multiplicityMCRecoTracksPerRT->Fill(nMCRecoTrack);
588 */
589 }
590
591}
592
594{
595
596 double num = 0;
597 double den = 0;
598
599 for (int bin = 1; bin < m_multiplicityFittedTracks->GetNbinsX(); bin ++)
600 num += m_multiplicityFittedTracks->GetBinContent(bin + 1);
601 den = m_multiplicityFittedTracks->GetEntries();
602 double efficiency = num / den ;
603 double efficiencyErr = sqrt(efficiency * (1 - efficiency)) / sqrt(den);
604
605 double nFittedTracksMCRT = 0;
606 for (int bin = 1; bin < m_multiplicityFittedTracksPerMCRT->GetNbinsX(); bin ++)
607 nFittedTracksMCRT += m_multiplicityFittedTracksPerMCRT->GetBinContent(bin + 1);
608 double efficiencyMCRT = nFittedTracksMCRT / m_multiplicityFittedTracksPerMCRT->GetEntries();
609 double efficiencyMCRTErr = sqrt(efficiencyMCRT * (1 - efficiencyMCRT)) / sqrt(m_multiplicityFittedTracksPerMCRT->GetEntries());
610
611 double nRecoTrack = 0;
612 for (int bin = 1; bin < m_multiplicityRecoTracksPerMCRT->GetNbinsX(); bin ++)
613 nRecoTrack += m_multiplicityRecoTracksPerMCRT->GetBinContent(bin + 1);
614 double efficiencyPR = nRecoTrack / m_multiplicityRecoTracksPerMCRT->GetEntries();
615 double efficiencyPRErr = sqrt(efficiencyPR * (1 - efficiencyPR)) / sqrt(m_multiplicityRecoTracksPerMCRT->GetEntries());
616
617 double nMCRecoTrack = 0;
618 for (int bin = 1; bin < m_multiplicityMCRecoTracksPerRT->GetNbinsX(); bin ++)
619 nMCRecoTrack += m_multiplicityMCRecoTracksPerRT->GetBinContent(bin + 1);
620 double purityPR = nMCRecoTrack / m_multiplicityMCRecoTracksPerRT->GetEntries();
621 double purityPRErr = sqrt(purityPR * (1 - purityPR)) / sqrt(m_multiplicityMCRecoTracksPerRT->GetEntries());
622
623 double nMCParticles = 0;
624 for (int bin = 1; bin < m_multiplicityMCParticlesPerTrack->GetNbinsX(); bin ++)
625 nMCParticles += m_multiplicityMCParticlesPerTrack->GetBinContent(bin + 1);
626 double purity = nMCParticles / m_multiplicityMCParticlesPerTrack->GetEntries();
627 double purityErr = sqrt(purity * (1 - purity)) / sqrt(m_multiplicityMCParticlesPerTrack->GetEntries());
628
629 B2INFO("");
630 B2INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
631 B2INFO("~ Tracking Performance Evaluation ~ SHORT SUMMARY ~");
632 B2INFO("");
633 B2INFO(" + overall:");
634 B2INFO(" efficiency = (" << efficiency * 100 << " +/- " << efficiencyErr * 100 << ")% ");
635 B2INFO(" purity = " << purity * 100 << " +/- " << purityErr * 100 << ")% ");
636 B2INFO("");
637 B2INFO(" + factorizing geometrical acceptance:");
638 B2INFO(" efficiency = " << efficiencyMCRT * 100 << " +/- " << efficiencyMCRTErr * 100 << ")% ");
639 B2INFO("");
640 B2INFO(" + pattern recognition:");
641 B2INFO(" efficiency = " << efficiencyPR * 100 << " +/- " << efficiencyPRErr * 100 << ")% ");
642 B2INFO(" purity = " << purityPR * 100 << " +/- " << purityPRErr * 100 << ")% ");
643 B2INFO("");
644 B2INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
645}
646
648{
649
650
653
655
656 if (m_rootFilePtr != nullptr) {
657 m_rootFilePtr->cd();
658
659 TDirectory* oldDir = gDirectory;
660
661 TDirectory* dir_multiplicity = oldDir->mkdir("multiplicity");
662 dir_multiplicity->cd();
663 TIter nextH_multiplicity(m_histoList_multiplicity);
664 TObject* obj;
665 while ((obj = nextH_multiplicity()))
666 obj->Write();
667
668 TDirectory* dir_efficiency = oldDir->mkdir("efficiency");
669 dir_efficiency->cd();
670 TIter nextH_efficiency(m_histoList_efficiency);
671 while ((obj = nextH_efficiency()))
672 obj->Write();
673
674 TDirectory* dir_trkQuality = oldDir->mkdir("trkQuality");
675 dir_trkQuality->cd();
676 TIter nextH_trkQuality(m_histoList_trkQuality);
677 while ((obj = nextH_trkQuality()))
678 obj->Write();
679
680 TDirectory* dir_firstHit = oldDir->mkdir("firstHit");
681 dir_firstHit->cd();
682 TIter nextH_firstHit(m_histoList_firstHit);
683 while ((obj = nextH_firstHit()))
684 obj->Write();
685
686
687
688
689 m_rootFilePtr->Close();
690 }
691
692}
693
694
696 MCParticleInfo mcParticleInfo)
697{
698
699 //track parameters errors
700 double d0_err = sqrt((fitResult->getCovariance5())[0][0]);
701 double phi_err = sqrt((fitResult->getCovariance5())[1][1]);
702 double omega_err = sqrt((fitResult->getCovariance5())[2][2]);
703 double z0_err = sqrt((fitResult->getCovariance5())[3][3]);
704 double cotTheta_err = sqrt((fitResult->getCovariance5())[4][4]);
705
706 //track parameters residuals:
707 double d0_res = fitResult->getD0() - mcParticleInfo.getD0();
708 double phi_res = TMath::ASin(TMath::Sin(fitResult->getPhi() - mcParticleInfo.getPhi()));
709 double omega_res = fitResult->getOmega() - mcParticleInfo.getOmega();
710 double z0_res = fitResult->getZ0() - mcParticleInfo.getZ0();
711 double cotTheta_res = fitResult->getCotTheta() - mcParticleInfo.getCotTheta();
712
713 //track parameters residuals in momentum:
714 double px_res = fitResult->getMomentum().X() - mcParticleInfo.getPx();
715 double py_res = fitResult->getMomentum().Y() - mcParticleInfo.getPy();
716 double pz_res = fitResult->getMomentum().Z() - mcParticleInfo.getPz();
717 double p_res = (fitResult->getMomentum().R() - mcParticleInfo.getP()) / mcParticleInfo.getP();
718 double pt_res = (fitResult->getMomentum().Rho() - mcParticleInfo.getPt()) / mcParticleInfo.getPt();
719
720 //track parameters residuals in position:
721 double x_res = fitResult->getPosition().X() - mcParticleInfo.getX();
722 double y_res = fitResult->getPosition().Y() - mcParticleInfo.getY();
723 double z_res = fitResult->getPosition().Z() - mcParticleInfo.getZ();
724 double r_res = fitResult->getPosition().Rho() - sqrt(mcParticleInfo.getX() * mcParticleInfo.getX() + mcParticleInfo.getY() *
725 mcParticleInfo.getY());
726 double rtot_res = fitResult->getPosition().R() - sqrt(mcParticleInfo.getX() * mcParticleInfo.getX() + mcParticleInfo.getY() *
727 mcParticleInfo.getY() + mcParticleInfo.getZ() * mcParticleInfo.getZ());
728
729 m_h1_d0_err->Fill(d0_err);
730 m_h1_phi_err->Fill(phi_err);
731 m_h1_omega_err->Fill(omega_err);
732 m_h1_z0_err->Fill(z0_err);
733 m_h1_cotTheta_err->Fill(cotTheta_err);
734
735 m_h1_d0_res->Fill(d0_res);
736 m_h1_phi_res->Fill(phi_res);
737 m_h1_omega_res->Fill(omega_res);
738 m_h1_z0_res->Fill(z0_res);
739 m_h1_cotTheta_res->Fill(cotTheta_res);
740
741 m_h1_px_res->Fill(px_res);
742 m_h1_py_res->Fill(py_res);
743 m_h1_pz_res->Fill(pz_res);
744 m_h1_p_res->Fill(p_res);
745 m_h1_pt_res->Fill(pt_res);
746
747 m_h1_x_res->Fill(x_res);
748 m_h1_y_res->Fill(y_res);
749 m_h1_z_res->Fill(z_res);
750 m_h1_r_res->Fill(r_res);
751 m_h1_rtot_res->Fill(rtot_res);
752
753 m_h2_chargeVSchargeMC->Fill(mcParticleInfo.getCharge(), fitResult->getChargeSign());
754
755 m_h1_d0_pll->Fill(d0_res / d0_err);
756 m_h1_phi_pll->Fill(phi_res / phi_err);
757 m_h1_omega_pll->Fill(omega_res / omega_err);
758 m_h1_z0_pll->Fill(z0_res / z0_err);
759 m_h1_cotTheta_pll->Fill(cotTheta_res / cotTheta_err);
760
761
762 m_h2_OmegaerrOmegaVSpt->Fill(fitResult->getMomentum().Rho(), omega_err / mcParticleInfo.getOmega());
763
764
765}
766
768{
769
770
771 double d0_err = sqrt((fitResult->getCovariance5())[0][0]);
772 double phi_err = sqrt((fitResult->getCovariance5())[1][1]);
773 double z0_err = sqrt((fitResult->getCovariance5())[3][3]);
774 double cotTheta_err = sqrt((fitResult->getCovariance5())[4][4]);
775
776 ROOT::Math::XYZVector momentum = fitResult->getMomentum();
777
778 double px = momentum.x();
779 double py = momentum.y();
780 double pz = momentum.z();
781 double pt = momentum.Rho();
782 double p = momentum.R();
783 double mass = fitResult->getParticleType().getMass();
784 double beta = p / sqrt(p * p + mass * mass);
785 double sinTheta = TMath::Sin(momentum.Theta());
786
787 m_h2_d0errphi0err_xy->Fill(d0_err / phi_err * px / pt,
788 d0_err / phi_err * py / pt);
789 m_h2_z0errcotThetaerr_xy->Fill(z0_err / cotTheta_err * px / pt,
790 z0_err / cotTheta_err * py / pt);
791 m_h2_d0errphi0err_rz->Fill(d0_err / phi_err * pz / pt,
792 d0_err / phi_err);
793
794 m_h2_d0errVSpt->Fill(pt, d0_err);
795
796 m_h2_z0errVSpt->Fill(pt, z0_err);
797
798 m_h2_d0errMSVSpt->Fill(pt, d0_err * beta * p * pow(sinTheta, 3 / 2) / 0.0136);
799
800}
801
803{
804
805 //hits used in the fit
806
808
809 const VXD::GeoCache& aGeometry = VXD::GeoCache::getInstance();
810
811 bool hasPXDhit = false;
812 bool isTrueHit = false;
813
814 double d0_err = -999;
815 double z0_err = -999;
816 double pt = -999;
817
818 if (fitResult) {
819 d0_err = sqrt((fitResult->getCovariance5())[0][0]);
820 z0_err = sqrt((fitResult->getCovariance5())[3][3]);
821 pt = fitResult->getMomentum().Rho();
822 }
823
824 const bool hasCDChit[56] = { false };
825
826 RelationVector<RecoTrack> RecoTracks_fromTrack = DataStore::getRelationsWithObj<RecoTrack>(&theTrack);
827
828 for (int tc = 0; tc < (int)RecoTracks_fromTrack.size(); tc++) {
829
830 const std::vector< genfit::TrackPoint* >& tp_vector = RecoTracks_fromTrack[tc]->getHitPointsWithMeasurement();
831 for (int i = 0; i < (int) tp_vector.size(); i++) {
832 genfit::TrackPoint* tp = tp_vector[i];
833
834 int nMea = tp->getNumRawMeasurements();
835 for (int mea = 0; mea < nMea; mea++) {
836
837 genfit::AbsMeasurement* absMeas = tp->getRawMeasurement(mea);
838 double weight = 0;
839
840 std::vector<double> weights;
841 genfit::KalmanFitterInfo* kalmanInfo = tp->getKalmanFitterInfo();
842 if (kalmanInfo)
843 weights = kalmanInfo->getWeights();
844 else //no kalman fitter info, fill the weights vector with 0 (VXD), or 0,0 (CDC)
845 B2WARNING(" No KalmanFitterInfo associated to the TrackPoint!");
846
847 double detId(-999);
848 ROOT::Math::XYZVector globalHit(-999, -999, -999);
849
850 PXDRecoHit* pxdHit = dynamic_cast<PXDRecoHit*>(absMeas);
851 SVDRecoHit2D* svdHit2D = dynamic_cast<SVDRecoHit2D*>(absMeas);
852 SVDRecoHit* svdHit = dynamic_cast<SVDRecoHit*>(absMeas);
853 CDCRecoHit* cdcHit = dynamic_cast<CDCRecoHit*>(absMeas);
854
855 if (pxdHit) {
856 hasPXDhit = true;
857 isTrueHit = false;
858
859 if (kalmanInfo)
860 weight = weights.at(mea);
861
862 detId = 0;
863 double uCoor = pxdHit->getU();
864 double vCoor = pxdHit->getV();
865 VxdID sensor = pxdHit->getSensorID();
866
867 m_h1_nVXDhitsPR->Fill(sensor.getLayerNumber());
868
869 m_h1_nVXDhitsWeighted->Fill(sensor.getLayerNumber(), weight);
870
871 m_h2_TrackPointFitWeightVXD->Fill(sensor.getLayerNumber(), weight);
872 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo(sensor);
873 globalHit = aSensorInfo.pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0), true);
874
875
876 const PXDCluster* pxdcl = pxdHit->getCluster();
877 RelationVector<PXDTrueHit> pxdth_fromcl = DataStore::getRelationsWithObj<PXDTrueHit>(pxdcl);
878
879 if ((int)pxdth_fromcl.size() != 0) {
880 const PXDTrueHit* trueHit = pxdth_fromcl[0];
881
882 if (trueHit) {
883 int trueHitIndex = trueHit->getArrayIndex();
884 RelationVector<MCParticle> MCParticles_fromTrack = DataStore::getRelationsWithObj<MCParticle>(&theTrack);
885 for (int mcp = 0; mcp < (int)MCParticles_fromTrack.size(); mcp++) {
886 RelationVector<PXDTrueHit> trueHit_fromMCParticles = DataStore::getRelationsWithObj<PXDTrueHit>(MCParticles_fromTrack[mcp]);
887 for (int th = 0; th < (int)trueHit_fromMCParticles.size(); th++) {
888 if (trueHit_fromMCParticles[th]->getArrayIndex() == trueHitIndex)
889 isTrueHit = true;
890 }
891 }
892 }
893 }
894
895 } else if (svdHit2D) {
896
897 if (kalmanInfo)
898 weight = weights.at(mea);
899
900 detId = 1;
901 double uCoor = svdHit2D->getU();
902 double vCoor = svdHit2D->getV();
903 VxdID sensor = svdHit2D->getSensorID();
904
905 m_h1_nVXDhitsPR->Fill(sensor.getLayerNumber());
906
907 m_h1_nVXDhitsWeighted->Fill(sensor.getLayerNumber(), weight);
908
909 m_h2_TrackPointFitWeightVXD->Fill(sensor.getLayerNumber(), weight);
910
911 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo(sensor);
912 globalHit = aSensorInfo.pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0), true);
913
914 } else if (svdHit) {
915
916 if (kalmanInfo)
917 weight = weights.at(mea);
918
919 detId = 2;
920 double uCoor = 0;
921 double vCoor = 0;
922 if (svdHit->isU())
923 uCoor = svdHit->getPosition();
924 else
925 vCoor = svdHit->getPosition();
926
927 VxdID sensor = svdHit->getSensorID();
928 m_h1_nVXDhitsPR->Fill(sensor.getLayerNumber());
929
930 m_h1_nVXDhitsWeighted->Fill(sensor.getLayerNumber(), weight);
931
932 m_h2_TrackPointFitWeightVXD->Fill(sensor.getLayerNumber(), weight);
933 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo(sensor);
934 globalHit = aSensorInfo.pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0), true);
935 } else if (cdcHit) {
936
937 if (kalmanInfo)
938 weight = weights.at(mea);
939
940 WireID wire = cdcHit->getWireID();
941 if (! hasCDChit[wire.getICLayer()]) { //needed to validate the HitPatternCDC filling
942 m_h1_nCDChitsPR->Fill(wire.getICLayer());
943
944 m_h1_nCDChitsWeighted->Fill(wire.getICLayer(), weight);
945 // hasCDChit[wire.getICLayer()] = true; //to validate the HitPatternCDC filling: uncomment this
946 }
947 m_h2_TrackPointFitWeightCDC->Fill(wire.getICLayer(), weight);
948 detId = 3;
949 }
950
951
952 m_h1_nHitDetID ->Fill(detId);
953
954 m_h2_VXDhitsPR_xy->Fill(globalHit.X(), globalHit.Y());
955
956 m_h2_VXDhitsPR_rz->Fill(globalHit.Z(), globalHit.Rho());
957
958 }
959
960 }
961 }
962
963 if ((fitResult != nullptr) && (fitResult->getParticleType() == Const::ChargedStable(m_ParticleHypothesis))) {
964 if (hasPXDhit) {
965 m_h2_d0errVSpt_wpxd->Fill(pt, d0_err);
966 m_h2_z0errVSpt_wpxd->Fill(pt, z0_err);
967 if (isTrueHit) {
968 m_h2_d0errVSpt_wtpxd->Fill(pt, d0_err);
969 m_h2_z0errVSpt_wtpxd->Fill(pt, z0_err);
970 } else {
971 m_h2_d0errVSpt_wfpxd->Fill(pt, d0_err);
972 m_h2_z0errVSpt_wfpxd->Fill(pt, z0_err);
973 }
974 } else {
975 m_h2_d0errVSpt_wopxd->Fill(pt, d0_err);
976 m_h2_z0errVSpt_wopxd->Fill(pt, z0_err);
977 }
978 }
979
980}
981
983{
984
985 //normalized to MCParticles
986 TH1F* h_ineff_pt = createHistogramsRatio("hineffpt", "inefficiency VS pt, normalized to MCParticles", m_h3_TracksPerMCParticle,
987 m_h3_MCParticle, false, 0);
988 histoList->Add(h_ineff_pt);
989
990 TH1F* h_ineff_theta = createHistogramsRatio("hinefftheta", "inefficiency VS #theta, normalized to MCParticles",
992 histoList->Add(h_ineff_theta);
993
994 TH1F* h_ineff_phi = createHistogramsRatio("hineffphi", "inefficiency VS #phi, normalized to MCParticles", m_h3_TracksPerMCParticle,
995 m_h3_MCParticle, false, 2);
996 histoList->Add(h_ineff_phi);
997
998 //normalized to MCRecoTracks
999 TH1F* h_ineffMCRT_pt = createHistogramsRatio("hineffMCRTpt", "inefficiency VS pt, normalized to MCRecoTrack",
1001 histoList->Add(h_ineffMCRT_pt);
1002
1003 TH1F* h_ineffMCRT_theta = createHistogramsRatio("hineffMCRTtheta", "inefficiency VS #theta, normalized to MCRecoTrack",
1005 histoList->Add(h_ineffMCRT_theta);
1006
1007 TH1F* h_ineffMCRT_phi = createHistogramsRatio("hineffMCRTphi", "inefficiency VS #phi, normalized to MCRecoTrack",
1009 histoList->Add(h_ineffMCRT_phi);
1010
1011}
1012
1014{
1015
1016
1017 TH1F* h_MCPwPXDhits_pt = createHistogramsRatio("hMCPwPXDhits", "fraction of MCParticles with PXD hits VS pt",
1019 m_h3_MCParticle, true, 0);
1020 histoList->Add(h_MCPwPXDhits_pt);
1021
1022 TH1F* h_RTwPXDhitsMCPwPXDHits_pt = createHistogramsRatio("hRecoTrkswPXDhitsMCPwPXDHits",
1023 "fraction of MCParticles with PXD Hits with RecoTracks with PXD hits VS pt",
1025 m_h3_MCParticleswPXDHits, true, 0);
1026 histoList->Add(h_RTwPXDhitsMCPwPXDHits_pt);
1027
1028 TH1F* h_wPXDhits_pt = createHistogramsRatio("hTrkswPXDhits", "fraction of tracks with PXD hits VS pt",
1030 m_h3_TracksPerMCParticle, true, 0);
1031 histoList->Add(h_wPXDhits_pt);
1032
1033 //normalized to MCParticles
1034 TH1F* h_eff_pt = createHistogramsRatio("heffpt", "efficiency VS pt, normalized to MCParticles", m_h3_TracksPerMCParticle,
1035 m_h3_MCParticle, true, 0);
1036 histoList->Add(h_eff_pt);
1037 // B2INFO(" efficiency in pt, NUM = "<<m_nFittedTracks<<", DEN = "<<m_nMCParticles<<", eff integrata = "<<(double)m_nFittedTracks/m_nMCParticles);
1038
1039 TH1F* h_eff_theta = createHistogramsRatio("hefftheta", "efficiency VS #theta, normalized to MCParticles", m_h3_TracksPerMCParticle,
1040 m_h3_MCParticle, true, 1);
1041 histoList->Add(h_eff_theta);
1042
1043 TH1F* h_eff_phi = createHistogramsRatio("heffphi", "efficiency VS #phi, normalized to MCParticles", m_h3_TracksPerMCParticle,
1044 m_h3_MCParticle, true, 2);
1045 histoList->Add(h_eff_phi);
1046
1047 //normalized to MCRecoTracks
1048 TH1F* h_effMCRT_pt = createHistogramsRatio("heffMCRTpt", "efficiency VS pt, normalized to MCRecoTrack", m_h3_TracksPerMCRecoTrack,
1049 m_h3_MCRecoTrack, true, 0);
1050 histoList->Add(h_effMCRT_pt);
1051
1052 TH1F* h_effMCRT_theta = createHistogramsRatio("heffMCRTtheta", "efficiency VS #theta, normalized to MCRecoTrack",
1054 histoList->Add(h_effMCRT_theta);
1055
1056 TH1F* h_effMCRT_phi = createHistogramsRatio("heffMCRTphi", "efficiency VS #phi, normalized to MCRecoTrack",
1058 histoList->Add(h_effMCRT_phi);
1059
1060 // plus
1061
1062 //normalized to MCParticles
1063 TH1F* h_eff_pt_plus = createHistogramsRatio("heffpt_plus", "efficiency VS pt, normalized to positive MCParticles",
1065 histoList->Add(h_eff_pt_plus);
1066 // B2INFO(" efficiency in pt, NUM = "<<m_nFittedTracks<<", DEN = "<<m_nMCParticles<<", eff integrata = "<<(double)m_nFittedTracks/m_nMCParticles);
1067
1068 TH1F* h_eff_theta_plus = createHistogramsRatio("hefftheta_plus", "efficiency VS #theta, normalized to positive MCParticles",
1070 histoList->Add(h_eff_theta_plus);
1071
1072 TH1F* h_eff_phi_plus = createHistogramsRatio("heffphi_plus", "efficiency VS #phi, normalized to positive MCParticles",
1074 histoList->Add(h_eff_phi_plus);
1075
1076 //normalized to MCRecoTracks
1077 TH1F* h_effMCRT_pt_plus = createHistogramsRatio("heffMCRTpt_plus", "efficiency VS pt, normalized to positive MCRecoTrack",
1079 histoList->Add(h_effMCRT_pt_plus);
1080
1081 TH1F* h_effMCRT_theta_plus = createHistogramsRatio("heffMCRTtheta_plus", "efficiency VS #theta, normalized to positive MCRecoTrack",
1083 histoList->Add(h_effMCRT_theta_plus);
1084
1085 TH1F* h_effMCRT_phi_plus = createHistogramsRatio("heffMCRTphi_plus", "efficiency VS #phi, normalized to positive MCRecoTrack",
1087 histoList->Add(h_effMCRT_phi_plus);
1088
1089 // minus
1090
1091 //normalized to MCParticles
1092 TH1F* h_eff_pt_minus = createHistogramsRatio("heffpt_minus", "efficiency VS pt, normalized to positive MCParticles",
1094 histoList->Add(h_eff_pt_minus);
1095 // B2INFO(" efficiency in pt, NUM = "<<m_nFittedTracks<<", DEN = "<<m_nMCParticles<<", eff integrata = "<<(double)m_nFittedTracks/m_nMCParticles);
1096
1097 TH1F* h_eff_theta_minus = createHistogramsRatio("hefftheta_minus", "efficiency VS #theta, normalized to positive MCParticles",
1099 histoList->Add(h_eff_theta_minus);
1100
1101 TH1F* h_eff_phi_minus = createHistogramsRatio("heffphi_minus", "efficiency VS #phi, normalized to positive MCParticles",
1103 histoList->Add(h_eff_phi_minus);
1104
1105 //normalized to MCRecoTracks
1106 TH1F* h_effMCRT_pt_minus = createHistogramsRatio("heffMCRTpt_minus", "efficiency VS pt, normalized to positive MCRecoTrack",
1108 histoList->Add(h_effMCRT_pt_minus);
1109
1110 TH1F* h_effMCRT_theta_minus = createHistogramsRatio("heffMCRTtheta_minus",
1111 "efficiency VS #theta, normalized to positive MCRecoTrack", m_h3_TracksPerMCRecoTrack_minus, m_h3_MCRecoTrack_minus, true, 1);
1112 histoList->Add(h_effMCRT_theta_minus);
1113
1114 TH1F* h_effMCRT_phi_minus = createHistogramsRatio("heffMCRTphi_minus", "efficiency VS #phi, normalized to positive MCRecoTrack",
1116 histoList->Add(h_effMCRT_phi_minus);
1117
1118 //pattern recognition efficiency
1119 TH1F* h_effPR = createHistogramsRatio("heffPR", "PR efficiency VS VXD Layer, normalized to MCRecoTrack",
1121 histoList->Add(h_effPR);
1122
1123 //tracks used in the fit
1124 TH1F* h_effVXDHitFit = createHistogramsRatio("heffVXDHitFit",
1125 "weighted hits used in the fit VS VXD Layer, normalized to hits form PR", m_h1_nVXDhitsWeighted, m_h1_nVXDhitsPR, true, 0);
1126 histoList->Add(h_effVXDHitFit);
1127
1128 TH1F* h_effCDCHitFit = createHistogramsRatio("heffCDCHitFit",
1129 "weighted hits used in the fit VS CDC Layer, normalized to hits form PR", m_h1_nCDChitsWeighted, m_h1_nCDChitsPR, true, 0);
1130 histoList->Add(h_effCDCHitFit);
1131
1132}
1133
1134
1135
1136
1138{
1139
1140 bool isChargedStable = Const::chargedStableSet.find(abs(the_mcParticle.getPDG())) != Const::invalidParticle;
1141
1142 bool isPrimary = the_mcParticle.hasStatus(MCParticle::c_PrimaryParticle);
1143
1144 return (isPrimary && isChargedStable);
1145
1146}
This class is used to transfer CDC information to the track fit.
Definition: CDCRecoHit.h:32
WireID getWireID() const
Getter for WireID object.
Definition: CDCRecoHit.h:49
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
Definition: Const.h:571
double getMass() const
Particle mass.
Definition: UnitConst.cc:356
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
static const ParticleType invalidParticle
Invalid particle, used internally.
Definition: Const.h:681
bool hasLayer(const unsigned short layer) const
Getter for single layer.
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
std::pair< const unsigned short, const unsigned short > getSVDLayer(const unsigned short layerId) const
Get the number of hits in a specific layer of the SVD.
This struct is used by the TrackingPerformanceEvaluation Module to save information of reconstructed ...
double getPx()
Getter for x component of momentum.
double getZ()
Getter for z component of vertex.
double getPt()
Getter for transverse momentum.
double getY()
Getter for y component of vertex.
double getCharge()
Getter for electric charge of particle.
double getPtheta()
Getter for theta of momentum vector.
double getZ0()
Getter for Z0.
double getX()
Getter for x component of vertex.
double getPy()
Getter for y component of momentum.
double getCotTheta()
Getter for Theta.
double getPhi()
Getter for Phi.
double getPz()
Getter for z component of momentum.
double getOmega()
Getter for Omega.
double getPphi()
Getter for phi of momentum vector.
double getD0()
Getter for D0.
double getP()
Getter for magnitut of momentum.
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
Definition: MCParticle.h:129
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
PXDRecoHit - an extended form of PXDCluster containing geometry information.
Definition: PXDRecoHit.h:49
float getV() const
Get v coordinate.
Definition: PXDRecoHit.h:111
const PXDCluster * getCluster() const
Get pointer to the Cluster used when creating this RecoHit, can be NULL if created from something els...
Definition: PXDRecoHit.h:106
VxdID getSensorID() const
Get the compact ID.
Definition: PXDRecoHit.h:101
float getU() const
Get u coordinate.
Definition: PXDRecoHit.h:109
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: PXDTrueHit.h:31
TH1F * createHistogram1D(const char *name, const char *title, Int_t nbins, Double_t min, Double_t max, const char *xtitle, TList *histoList=nullptr)
Create a 1D histogram and add it to the TList of 1D-histograms.
TList * m_histoList_evtCharacterization
List of event-characterization histograms.
TList * m_histoList_fit
List of track-fit histograms.
TH1 * duplicateHistogram(const char *newname, const char *newtitle, TH1 *h, TList *histoList=nullptr)
Make a copy of a 1D histogram and add it to the TList of 1D-histograms.
TList * m_histoList_others
List of other performance-evaluation histograms.
TList * m_histoList_pr
List of pattern-recognition histograms.
TList * m_histoList_trkQuality
List of track-quality histograms.
TList * m_histoList_purity
List of purity histograms.
TList * m_histoList
List of performance-evaluation histograms.
TList * m_histoList_multiplicity
List of multiplicity histograms.
void addPurityPlots(TList *graphList=nullptr, TH3F *h3_xPerMCParticle=nullptr, TH3F *h3_MCParticle=nullptr)
Create pt-, theta- and phi-purity 1D histograms and add them to the TList of 1D-histograms.
TList * m_histoList_firstHit
List of first-hit-position histograms.
TH3F * createHistogram3D(const char *name, const char *title, Int_t nbinsX, Double_t minX, Double_t maxX, const char *titleX, Int_t nbinsY, Double_t minY, Double_t maxY, const char *titleY, Int_t nbinsZ, Double_t minZ, Double_t maxZ, const char *titleZ, TList *histoList=nullptr)
Create a 3D histogram and add it to the TList of 3D-histograms.
TH2F * createHistogram2D(const char *name, const char *title, Int_t nbinsX, Double_t minX, Double_t maxX, const char *titleX, Int_t nbinsY, Double_t minY, Double_t maxY, const char *titleY, TList *histoList=nullptr)
Create a 2D histogram and add it to the TList of 2D-histograms.
TH1F * createHistogramsRatio(const char *name, const char *title, TH1 *hNum, TH1 *hDen, bool isEffPlot, int axisRef)
Make a new 1D histogram from the ratio of two others and add it to the TList of 1D-histograms.
TFile * m_rootFilePtr
pointer at root file used for storing histograms
TList * m_histoList_efficiency
List of efficiency histograms.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
SVDRecoHit - an extended form of SVDHit containing geometry information.
Definition: SVDRecoHit2D.h:46
float getV() const
Get v coordinate.
Definition: SVDRecoHit2D.h:112
VxdID getSensorID() const
Get the compact ID.
Definition: SVDRecoHit2D.h:100
float getU() const
Get u coordinate.
Definition: SVDRecoHit2D.h:110
SVDRecoHit - an extended form of SVDHit containing geometry information.
Definition: SVDRecoHit.h:47
bool isU() const
Is the coordinate u or v?
Definition: SVDRecoHit.h:91
float getPosition() const
Get coordinate.
Definition: SVDRecoHit.h:94
VxdID getSensorID() const
Get the compact ID.
Definition: SVDRecoHit.h:82
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Values of the result of a track fit with a given particle hypothesis.
TMatrixDSym getCovariance5() const
Getter for covariance matrix of perigee parameters in matrix form.
double getPhi() const
Getter for phi0 with CDF naming convention.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
double getOmega() const
Getter for omega.
double getD0() const
Getter for d0.
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
HitPatternVXD getHitPatternVXD() const
Getter for the hit pattern in the VXD;.
Class that bundles various TrackFitResults.
Definition: Track.h:25
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Default Access to TrackFitResults.
Definition: Track.cc:30
void addMoreEfficiencyPlots(TList *histoList)
add efficiency plots
TH1F * m_multiplicityMCRecoTracksPerRT
number of MCRecoTracks per RecoTracks
TH1F * m_multiplicityTracks
number of tracks per MCParticles
TH1F * m_multiplicityFittedTracks
number of fitted tracks per MCParticles
int m_ParticleHypothesis
Particle Hypothesis for the track fit (default: 211)
void event() override
This method is called for each event.
TH1F * m_multiplicityMCRecoTracks
number of MCRecoTracks per MCParticles
void endRun() override
This method is called if the current run ends.
TH1F * m_multiplicityRecoTracksPerMCRT
number of RecoTracks per MCRecoTracks
void terminate() override
This method is called at the end of the event processing.
StoreArray< RecoTrack > m_PRRecoTracks
PR RecoTracks StoreArray.
TH1F * m_multiplicityMCParticlesPerTrack
number of MCParticles per fitted Track
bool isTraceable(const MCParticle &the_mcParticle)
is traceable
void beginRun() override
Called when entering a new run.
void fillTrackParams1DHistograms(const TrackFitResult *fitResult, MCParticleInfo mcParticleInfo)
fills err, resid and pull TH1F for each of the 5 track parameters
void addMoreInefficiencyPlots(TList *histoList)
add inefficiency plots
StoreArray< RecoTrack > m_MCRecoTracks
MC RecoTracks StoreArray.
std::string m_MCParticlesName
MCParticle StoreArray name.
TH1F * m_h1_r_res
R residual (in cylindrical coordinates)
TH1F * m_multiplicityRecoTracks
number of recoTracks per MCParticles
void fillTrackErrParams2DHistograms(const TrackFitResult *fitResult)
fills TH2F
std::string m_MCRecoTracksName
MCRecoTrack StoreArray name.
StoreArray< MCParticle > m_MCParticles
MCParticles StoreArray.
TH1F * m_multiplicityFittedTracksPerMCRT
number of fitted tracks per MCRecoTrack
static const double T
[tesla]
Definition: Unit.h:120
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getICLayer() const
Getter for continuous layer numbering.
Definition: WireID.cc:24
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.