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
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 = dynamic_cast<TH2F*>(duplicateHistogram("h2z0errcotThetaerrXY",
175 "#sigma_{z0}/#sigma_{cot#theta} projected on x,y",
178
179 m_h2_OmegaerrOmegaVSpt = createHistogram2D("h2OmegaerrOmegaVSpt", "#sigma_{#omega}/#omega VS p_{t}",
180 100, 0, 3, "p_{t} (GeV/c)",
181 1000, 0, 0.2, "#sigma_{#omega}/#omega",
183
184
185 m_h2_z0errVSpt = createHistogram2D("h2z0errVSpt", "#sigma_{z0} VS p_{t}",
186 100, 0, 3, "p_{t} (GeV/c)",
187 100, 0, 0.1, "#sigma_{z0} (cm)",
189
190 m_h2_z0errVSpt_wtpxd = dynamic_cast<TH2F*>(duplicateHistogram("h2z0errVSpt_wTruePXD", "#sigma_{z0} VS p_{t}, with True PXD hits",
193 m_h2_z0errVSpt_wfpxd = dynamic_cast<TH2F*>(duplicateHistogram("h2z0errVSpt_wFalsePXD", "#sigma_{z0} VS p_{t}, with False PXD hits",
196 m_h2_z0errVSpt_wpxd = dynamic_cast<TH2F*>(duplicateHistogram("h2z0errVSpt_wPXD", "#sigma_{z0} VS p_{t}, with PXD hits",
199
200 m_h2_z0errVSpt_wopxd = dynamic_cast<TH2F*>(duplicateHistogram("h2z0errVSpt_woPXD", "#sigma_{z0} VS p_{t}, no PXD hits",
203
204 m_h2_d0errVSpt = createHistogram2D("h2d0errVSpt", "#sigma_{d0} VS p_{t}",
205 100, 0, 3, "p_{t} (GeV/c)",
206 100, 0, 0.1, "#sigma_{d0} (cm)",
208 m_h2_d0errVSpt_wtpxd = dynamic_cast<TH2F*>(duplicateHistogram("h2d0errVSpt_wTruePXD", "#sigma_{d0} VS p_{t}, with True PXD hits",
211 m_h2_d0errVSpt_wfpxd = dynamic_cast<TH2F*>(duplicateHistogram("h2d0errVSpt_wFalsePXD", "#sigma_{d0} VS p_{t}, with False PXD hits",
214 m_h2_d0errVSpt_wpxd = dynamic_cast<TH2F*>(duplicateHistogram("h2d0errVSpt_wPXD", "#sigma_{d0} VS p_{t}, with PXD hits",
217
218 m_h2_d0errVSpt_wopxd = dynamic_cast<TH2F*>(duplicateHistogram("h2d0errVSpt_woPXD", "#sigma_{d0} VS p_{t}, no PXD hits",
221 m_h2_d0errMSVSpt = createHistogram2D("h2d0errMSVSpt", "#sigma_{d0} * #betapsin^{3/2}#theta VS p_{t}",
222 50, 0, 2.5, "p_{t} (GeV/c)",
223 500, 0, 1, "cm",
225
226 //hits used in the fit
227 m_h2_TrackPointFitWeightVXD = createHistogram2D("h2TPFitWeightVXD", "VXD TrackPoint Fit Weight", 6, 0.5, 6.5, "VXD layer", 20, 0, 1,
228 "weight", m_histoList);
229 m_h2_TrackPointFitWeightCDC = createHistogram2D("h2TPFitWeightCDC", "CDC TrackPoint Fit Weight", 56, -0.5, 55.5, "CDC layer", 20, 0,
230 1, "weight", m_histoList);
231
232 m_h1_nHitDetID = createHistogram1D("h1nHitDetID", "detector ID per hit", 4, -0.5, 3.5, "0=PXD, 1=SVD2D, 2=SVD,3=CDC", m_histoList);
233 m_h1_nCDChitsPR = createHistogram1D("h1nCDCHitsPR", "number of CDC hits from PR per Layer", 56, -0.5, 55.5, "CDC Layer",
235 m_h1_nCDChitsWeighted = dynamic_cast<TH1F*>(duplicateHistogram("h1nCDCHitsWeighted", "CDC hits used in the fit per Layer, weighted",
237 m_h1_nCDChitsUsed = dynamic_cast<TH1F*>(duplicateHistogram("h1nCDCHitsUsed",
238 "approximated number of CDC hits used in the fit per Layer, weighted", m_h1_nCDChitsPR, m_histoList));
239 m_h1_nVXDhitsPR = createHistogram1D("h1nVXDHitsPR", "number of VXD hits from PR per Layer", 6, 0.5, 6.5, "VXD Layer", m_histoList);
240 m_h1_nVXDhitsWeighted = dynamic_cast<TH1F*>(duplicateHistogram("h1nVXDHitsWeighted",
241 "number of VXD hits used in the fit per Layer, weighted",
243 m_h1_nVXDhitsUsed = dynamic_cast<TH1F*>(duplicateHistogram("h1nVXDHitsUsed",
244 "approximate number of VXD hits used in the fit per Layer, weighted", m_h1_nVXDhitsPR, m_histoList));
245 m_h2_VXDhitsPR_xy = createHistogram2D("h2hitsPRXY", "Pattern Recognition hits, transverse plane",
246 2000, -15, 15, "x (cm)",
247 2000, -15, 15, "y (cm)",
249
250 m_h2_VXDhitsPR_rz = createHistogram2D("h2hitsPRRZ", "Pattern Recognition Hits, r_{t} z",
251 2000, -30, 40, "z (cm)",
252 2000, 0, 15, "r_{t} (cm)",
254
255
256
257 //histograms to produce efficiency plots
258 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
259 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()};
260 Double_t bins_phi[14 + 1];
261 Double_t width_phi = 2 * TMath::Pi() / 14;
262 for (int bin = 0; bin < 14 + 1; bin++)
263 bins_phi[bin] = - TMath::Pi() + bin * width_phi;
264
265
266 m_h3_MCParticle = createHistogram3D("h3MCParticle", "entry per MCParticle",
267 10, bins_pt, "p_{t} (GeV/c)",
268 10, bins_theta, "#theta",
269 14, bins_phi, "#phi" /*, m_histoList*/);
270
271 m_h3_TracksPerMCParticle = dynamic_cast<TH3F*>(duplicateHistogram("h3TracksPerMCParticle",
272 "entry per Track connected to a MCParticle",
273 m_h3_MCParticle /*, m_histoList*/));
274
275 m_h3_TrackswPXDHitsPerMCParticle = dynamic_cast<TH3F*>(duplicateHistogram("h3TrackswPXDHitsPerMCParticle",
276 "entry per Track with PXD hits connected to a MCParticle",
277 m_h3_MCParticle /*, m_histoList*/));
278
279 m_h3_RecoTrackswPXDHitsPerMCParticle = dynamic_cast<TH3F*>(duplicateHistogram("h3RecoTrackswPXDHitsPerMCParticle",
280 "entry per RecoTrack with PXD hits connected to a MCParticle",
281 m_h3_MCParticle /*, m_histoList*/));
282
283 m_h3_RecoTrackswPXDHitsPerMCParticlewPXDHits = dynamic_cast<TH3F*>(duplicateHistogram("h3RecoTrackswPXDHitsPerMCParticlewPXDHits",
284 "entry per RecoTrack with PXD hits connected to a MCParticle with PXD hits",
285 m_h3_MCParticle /*, m_histoList*/));
286
287 m_h3_MCParticleswPXDHits = dynamic_cast<TH3F*>(duplicateHistogram("h3MCParticleswPXDHitsPerMCParticle",
288 "entry per MCParticle with PXD hits",
289 m_h3_MCParticle /*, m_histoList*/));
290
291 m_h3_MCRecoTrack = dynamic_cast<TH3F*>(duplicateHistogram("h3MCRecoTrack",
292 "entry per MCRecoTrack connected to the MCParticle",
293 m_h3_MCParticle /*, m_histoList*/));
294
295 m_h3_TracksPerMCRecoTrack = dynamic_cast<TH3F*>(duplicateHistogram("h3TracksPerMCRecoTrack",
296 "entry per Track connected to an MCRecoTrack",
297 m_h3_MCParticle /*, m_histoList*/));
298 //plus
299 m_h3_MCParticle_plus = dynamic_cast<TH3F*>(duplicateHistogram("h3MCParticle_plus", "entry per positive MCParticle",
300 m_h3_MCParticle /*, m_histoList*/));
301
302 m_h3_TracksPerMCParticle_plus = dynamic_cast<TH3F*>(duplicateHistogram("h3TracksPerMCParticle_plus",
303 "entry per Track connected to a positive MCParticle",
304 m_h3_MCParticle /*, m_histoList*/));
305
306 m_h3_MCRecoTrack_plus = dynamic_cast<TH3F*>(duplicateHistogram("h3MCRecoTrack_plus",
307 "entry per MCRecoTrack connected to the positive MCParticle",
308 m_h3_MCParticle /*, m_histoList*/));
309
310 m_h3_TracksPerMCRecoTrack_plus = dynamic_cast<TH3F*>(duplicateHistogram("h3TracksPerMCRecoTrack_plus",
311 "entry per Track connected to a positive MCRecoTrack",
312 m_h3_MCParticle /*, m_histoList*/));
313
314
315 //minus
316 m_h3_MCParticle_minus = dynamic_cast<TH3F*>(duplicateHistogram("h3MCParticlee_minus", "entry per negative MCParticle",
317 m_h3_MCParticle /*, m_histoList*/));
318
319 m_h3_TracksPerMCParticle_minus = dynamic_cast<TH3F*>(duplicateHistogram("h3TracksPerMCParticle_minus",
320 "entry per Track connected to a negative MCParticle",
321 m_h3_MCParticle /*, m_histoList*/));
322
323 m_h3_MCRecoTrack_minus = dynamic_cast<TH3F*>(duplicateHistogram("h3MCRecoTrack_minus",
324 "entry per MCRecoTrack connected to the negative MCParticle",
325 m_h3_MCParticle /*, m_histoList*/));
326
327 m_h3_TracksPerMCRecoTrack_minus = dynamic_cast<TH3F*>(duplicateHistogram("h3TracksPerMCRecoTrack_minus",
328 "entry per Track connected to a negative MCRecoTrack",
329 m_h3_MCParticle /*, m_histoList*/));
330
331 //histograms to produce efficiency plots
332 m_h1_HitsRecoTrackPerMCRecoTrack = createHistogram1D("h1hitsTCperMCRT", "RecoTrack per MCRecoTrack Hit in VXD layers", 6, 0.5, 6.5,
333 "# VXD layer" /*, m_histoList*/);
334
335 m_h1_HitsMCRecoTrack = dynamic_cast<TH1F*>(duplicateHistogram("h1hitsMCRT", " MCRecoTrack Hit in VXD layers",
336 m_h1_HitsRecoTrackPerMCRecoTrack /*, m_histoList*/));
337
338
339 //histograms to produce purity plots
340 m_h3_Tracks = dynamic_cast<TH3F*>(duplicateHistogram("h3Tracks", "entry per Track",
341 m_h3_MCParticle /*, m_histoList*/));
342
343 m_h3_MCParticlesPerTrack = dynamic_cast<TH3F*>(duplicateHistogram("h3MCParticlesPerTrack",
344 "entry per MCParticle connected to a Track",
345 m_h3_MCParticle /*, m_histoList*/));
346}
347
352
354{
355 ROOT::Math::XYZVector magField = BFieldManager::getField(0, 0, 0) / Unit::T;
356
357 bool hasTrack = false;
358 B2DEBUG(29, "+++++ 1. loop on MCParticles");
359 for (const MCParticle& mcParticle : m_MCParticles) {
360
361 if (! isTraceable(mcParticle))
362 continue;
363
364 // cppcheck-suppress variableScope ; declaration kept at this scope for readability
365 int pdgCode = mcParticle.getPDG();
366 B2DEBUG(29, "MCParticle has PDG code " << pdgCode);
367
368 int nFittedTracksMCRT = 0;
369 int nFittedTracks = 0;
370
371 MCParticleInfo mcParticleInfo(mcParticle, magField);
372
373 hasTrack = false;
374
375 m_h3_MCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
376
377 if (mcParticleInfo.getCharge() > 0)
378 m_h3_MCParticle_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
379 else if (mcParticleInfo.getCharge() < 0)
380 m_h3_MCParticle_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
381 else
382 continue;
383
384 if (mcParticle.hasSeenInDetector(Const::PXD))
385 m_h3_MCParticleswPXDHits->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
386
387 //1. retrieve all the Tracks related to the MCParticle
388
389 //1.0 check if there is a RecoTrack
390 RelationVector<RecoTrack> MCRecoTracks_fromMCParticle =
392
393 if (MCRecoTracks_fromMCParticle.size() > 0)
394 if (MCRecoTracks_fromMCParticle[0]->hasPXDHits()) {
395 m_h3_RecoTrackswPXDHitsPerMCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
396 if (mcParticle.hasSeenInDetector(Const::PXD))
397 m_h3_RecoTrackswPXDHitsPerMCParticlewPXDHits->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
398 }
399 m_multiplicityMCRecoTracks->Fill(MCRecoTracks_fromMCParticle.size());
400
401 RelationVector<RecoTrack> RecoTracks_fromMCParticle =
403
404 m_multiplicityRecoTracks->Fill(RecoTracks_fromMCParticle.size());
405
406 if (MCRecoTracks_fromMCParticle.size() > 0) {
407 m_h3_MCRecoTrack->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
408
409 if (mcParticleInfo.getCharge() > 0)
410 m_h3_MCRecoTrack_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
411 else if (mcParticleInfo.getCharge() < 0)
412 m_h3_MCRecoTrack_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
413 else
414 continue;
415 }
416
417 //1.a retrieve all Tracks related to the MCParticle
418 RelationVector<Track> Tracks_fromMCParticle = DataStore::getRelationsWithObj<Track>(&mcParticle);
419 m_multiplicityTracks->Fill(Tracks_fromMCParticle.size());
420
421 B2DEBUG(29, Tracks_fromMCParticle.size() << " Tracks related to this MCParticle");
422
423 for (int trk = 0; trk < (int)Tracks_fromMCParticle.size(); trk++) {
424
425 const TrackFitResult* fitResult = Tracks_fromMCParticle[trk]->getTrackFitResult(Const::ChargedStable(m_ParticleHypothesis));
426
427 if ((fitResult == nullptr) || (fitResult->getParticleType() != Const::ChargedStable(m_ParticleHypothesis)))
428 B2WARNING(" the TrackFitResult is not found!");
429
430 else { // valid TrackFitResult found
431
432 if (!hasTrack) {
433
434 hasTrack = true;
435
436 nFittedTracks++;
437
438 if (fitResult->getHitPatternVXD().getNPXDHits() > 0) {
439 m_h3_TrackswPXDHitsPerMCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
440 }
441
442 m_h3_TracksPerMCParticle->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
443 if (mcParticleInfo.getCharge() > 0)
444 m_h3_TracksPerMCParticle_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
445 else if (mcParticleInfo.getCharge() < 0)
446 m_h3_TracksPerMCParticle_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
447 else
448 continue;
449
450 if (MCRecoTracks_fromMCParticle.size() > 0) {
451 nFittedTracksMCRT++;
452 m_h3_TracksPerMCRecoTrack->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
453 if (mcParticleInfo.getCharge() > 0)
454 m_h3_TracksPerMCRecoTrack_plus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
455 else if (mcParticleInfo.getCharge() < 0)
456 m_h3_TracksPerMCRecoTrack_minus->Fill(mcParticleInfo.getPt(), mcParticleInfo.getPtheta(), mcParticleInfo.getPphi());
457 else
458 continue;
459 }
460
461
462 }
463
464
465 fillTrackParams1DHistograms(fitResult, mcParticleInfo);
466
467 }
468 }
469
470 m_multiplicityFittedTracks->Fill(nFittedTracks);
471 if (MCRecoTracks_fromMCParticle.size() > 0)
472 m_multiplicityFittedTracksPerMCRT->Fill(nFittedTracksMCRT);
473
474 }
475
476
477 B2DEBUG(29, "+++++ 2. loop on Tracks");
478
479 //2. retrieve all the MCParticles related to the Tracks
481
482 for (const Track& track : m_Tracks) {
483
484 int nMCParticles = 0;
485
486 //check if the track has been fitted
487 const TrackFitResult* fitResult = track.getTrackFitResult(Const::ChargedStable(m_ParticleHypothesis));
488
489 if ((fitResult == nullptr) || (fitResult->getParticleType() != Const::ChargedStable(m_ParticleHypothesis)))
490 continue;
491
492 m_h1_pValue->Fill(fitResult->getPValue());
493
494 ROOT::Math::XYZVector momentum = fitResult->getMomentum();
495 m_h3_Tracks->Fill(momentum.Rho(), momentum.Theta(), momentum.Phi());
496
498
500
501 for (int layer = 0; layer < 56; layer++) {
502 if (fitResult->getHitPatternCDC().hasLayer(layer))
503 m_h1_nCDChitsUsed->Fill(layer);
504 }
505 for (int layer = 1; layer <= 2; layer++) {
506 for (int i = 0; i < fitResult->getHitPatternVXD().getPXDLayer(layer); i++)
507 m_h1_nVXDhitsUsed->Fill(layer);
508 }
509 for (int layer = 3; layer <= 6; layer++) {
510 int n1 = fitResult->getHitPatternVXD().getSVDLayer(layer).first;
511 int n2 = fitResult->getHitPatternVXD().getSVDLayer(layer).second;
512 int N = n1 + n2;
513
514 for (int i = 0; i < N; i++)
515 m_h1_nVXDhitsUsed->Fill(layer);
516 }
517
518
520
521 for (int mcp = 0; mcp < (int)MCParticles_fromTrack.size(); mcp++)
522 if (isTraceable(*MCParticles_fromTrack[mcp])) {
523 nMCParticles ++;
524 m_h3_MCParticlesPerTrack->Fill(momentum.Rho(), momentum.Theta(), momentum.Phi());
525 }
526 // }
527
528 m_multiplicityMCParticlesPerTrack->Fill(nMCParticles);
529
530 }
531
532
533 B2DEBUG(29, "+++++ 3. loop on MCRecoTracks");
534
535 for (const RecoTrack& mcRecoTrack : m_MCRecoTracks) {
536
537
538 //3.a retrieve the RecoTrack
539 RelationVector<RecoTrack> RecoTracks_fromMCRecoTrack = DataStore::getRelationsWithObj<RecoTrack>(&mcRecoTrack);
540 B2DEBUG(29, "~ " << RecoTracks_fromMCRecoTrack.size() << " RecoTracks related to this MCRecoTrack");
541 m_multiplicityRecoTracksPerMCRT->Fill(RecoTracks_fromMCRecoTrack.size());
542
543 //3.a retrieve the MCParticle
544 RelationVector<MCParticle> MCParticles_fromMCRecoTrack = DataStore::getRelationsWithObj<MCParticle>(&mcRecoTrack);
545
546 B2DEBUG(29, "~~~ " << MCParticles_fromMCRecoTrack.size() << " MCParticles related to this MCRecoTrack");
547 for (int mcp = 0; mcp < (int)MCParticles_fromMCRecoTrack.size(); mcp++) {
548
549 //3.b retrieve all RecoTracks related to the MCRecoTrack
551 (MCParticles_fromMCRecoTrack[mcp]);
552
553 B2DEBUG(29, "~~~~~ " << RecoTracks_fromMCParticle.size() << " RecoTracks related to this MCParticle");
554 }
555
556 }
557
558
559 B2DEBUG(29, "+++++ 4. loop on RecoTracks");
560
561 //4. retrieve all RecoTracks
562
563 for (const RecoTrack& recoTrack : m_PRRecoTracks) {
564
565 // int nMCRecoTrack = 0;
566
567 // retrieve the MCRecoTrack
569 m_multiplicityMCRecoTracksPerRT->Fill(MCRecoTracks_fromRecoTrack.size());
570
571
572 /*
573 //4.a retrieve the MCParticle
574 RelationVector<MCParticle> MCParticles_fromRecoTrack = DataStore::getRelationsWithObj<MCParticle>(&recoTrack);
575
576 B2DEBUG(29, "~~~ " << MCParticles_fromRecoTrack.size() << " MCParticles related to this RecoTrack");
577 for (int mcp = 0; mcp < (int)MCParticles_fromRecoTrack.size(); mcp++) {
578
579 //4.b retrieve all MCRecoTracks related to the RecoTrack
580 RelationVector<RecoTrack> mcRecoTracks_fromMCParticle = DataStore::getRelationsWithObj<RecoTrack>
581 (MCParticles_fromRecoTrack[mcp], m_MCRecoTracksName);
582
583 B2DEBUG(29, "~~~~~ " << mcRecoTracks_fromMCParticle.size() << " MCRecoTracks related to this MCParticle");
584 for (int mctc = 0; mctc < (int)mcRecoTracks_fromMCParticle.size(); mctc++) {
585 nMCRecoTrack++;
586
587 }
588 }
589
590 // m_multiplicityMCRecoTracksPerRT->Fill(nMCRecoTrack);
591 */
592 }
593
594}
595
597{
598
599 double num = 0;
600 double den = 0;
601
602 for (int bin = 1; bin < m_multiplicityFittedTracks->GetNbinsX(); bin ++)
603 num += m_multiplicityFittedTracks->GetBinContent(bin + 1);
604 den = m_multiplicityFittedTracks->GetEntries();
605 double efficiency = num / den ;
606 double efficiencyErr = sqrt(efficiency * (1 - efficiency)) / sqrt(den);
607
608 double nFittedTracksMCRT = 0;
609 for (int bin = 1; bin < m_multiplicityFittedTracksPerMCRT->GetNbinsX(); bin ++)
610 nFittedTracksMCRT += m_multiplicityFittedTracksPerMCRT->GetBinContent(bin + 1);
611 double efficiencyMCRT = nFittedTracksMCRT / m_multiplicityFittedTracksPerMCRT->GetEntries();
612 double efficiencyMCRTErr = sqrt(efficiencyMCRT * (1 - efficiencyMCRT)) / sqrt(m_multiplicityFittedTracksPerMCRT->GetEntries());
613
614 double nRecoTrack = 0;
615 for (int bin = 1; bin < m_multiplicityRecoTracksPerMCRT->GetNbinsX(); bin ++)
616 nRecoTrack += m_multiplicityRecoTracksPerMCRT->GetBinContent(bin + 1);
617 double efficiencyPR = nRecoTrack / m_multiplicityRecoTracksPerMCRT->GetEntries();
618 double efficiencyPRErr = sqrt(efficiencyPR * (1 - efficiencyPR)) / sqrt(m_multiplicityRecoTracksPerMCRT->GetEntries());
619
620 double nMCRecoTrack = 0;
621 for (int bin = 1; bin < m_multiplicityMCRecoTracksPerRT->GetNbinsX(); bin ++)
622 nMCRecoTrack += m_multiplicityMCRecoTracksPerRT->GetBinContent(bin + 1);
623 double purityPR = nMCRecoTrack / m_multiplicityMCRecoTracksPerRT->GetEntries();
624 double purityPRErr = sqrt(purityPR * (1 - purityPR)) / sqrt(m_multiplicityMCRecoTracksPerRT->GetEntries());
625
626 double nMCParticles = 0;
627 for (int bin = 1; bin < m_multiplicityMCParticlesPerTrack->GetNbinsX(); bin ++)
628 nMCParticles += m_multiplicityMCParticlesPerTrack->GetBinContent(bin + 1);
629 double purity = nMCParticles / m_multiplicityMCParticlesPerTrack->GetEntries();
630 double purityErr = sqrt(purity * (1 - purity)) / sqrt(m_multiplicityMCParticlesPerTrack->GetEntries());
631
632 B2INFO("");
633 B2INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
634 B2INFO("~ Tracking Performance Evaluation ~ SHORT SUMMARY ~");
635 B2INFO("");
636 B2INFO(" + overall:");
637 B2INFO(" efficiency = (" << efficiency * 100 << " +/- " << efficiencyErr * 100 << ")% ");
638 B2INFO(" purity = " << purity * 100 << " +/- " << purityErr * 100 << ")% ");
639 B2INFO("");
640 B2INFO(" + factorizing geometrical acceptance:");
641 B2INFO(" efficiency = " << efficiencyMCRT * 100 << " +/- " << efficiencyMCRTErr * 100 << ")% ");
642 B2INFO("");
643 B2INFO(" + pattern recognition:");
644 B2INFO(" efficiency = " << efficiencyPR * 100 << " +/- " << efficiencyPRErr * 100 << ")% ");
645 B2INFO(" purity = " << purityPR * 100 << " +/- " << purityPRErr * 100 << ")% ");
646 B2INFO("");
647 B2INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
648}
649
651{
652
653
656
658
659 if (m_rootFilePtr != nullptr) {
660 m_rootFilePtr->cd();
661
662 TDirectory* oldDir = gDirectory;
663
664 TDirectory* dir_multiplicity = oldDir->mkdir("multiplicity");
665 dir_multiplicity->cd();
666 TIter nextH_multiplicity(m_histoList_multiplicity);
667 TObject* obj;
668 while ((obj = nextH_multiplicity()))
669 obj->Write();
670
671 TDirectory* dir_efficiency = oldDir->mkdir("efficiency");
672 dir_efficiency->cd();
673 TIter nextH_efficiency(m_histoList_efficiency);
674 while ((obj = nextH_efficiency()))
675 obj->Write();
676
677 TDirectory* dir_trkQuality = oldDir->mkdir("trkQuality");
678 dir_trkQuality->cd();
679 TIter nextH_trkQuality(m_histoList_trkQuality);
680 while ((obj = nextH_trkQuality()))
681 obj->Write();
682
683 TDirectory* dir_firstHit = oldDir->mkdir("firstHit");
684 dir_firstHit->cd();
685 TIter nextH_firstHit(m_histoList_firstHit);
686 while ((obj = nextH_firstHit()))
687 obj->Write();
688
689
690
691
692 m_rootFilePtr->Close();
693 }
694
695}
696
697
699 MCParticleInfo mcParticleInfo)
700{
701
702 //track parameters errors
703 double d0_err = sqrt((fitResult->getCovariance5())[0][0]);
704 double phi_err = sqrt((fitResult->getCovariance5())[1][1]);
705 double omega_err = sqrt((fitResult->getCovariance5())[2][2]);
706 double z0_err = sqrt((fitResult->getCovariance5())[3][3]);
707 double cotTheta_err = sqrt((fitResult->getCovariance5())[4][4]);
708
709 //track parameters residuals:
710 double d0_res = fitResult->getD0() - mcParticleInfo.getD0();
711 double phi_res = TMath::ASin(TMath::Sin(fitResult->getPhi() - mcParticleInfo.getPhi()));
712 double omega_res = fitResult->getOmega() - mcParticleInfo.getOmega();
713 double z0_res = fitResult->getZ0() - mcParticleInfo.getZ0();
714 double cotTheta_res = fitResult->getCotTheta() - mcParticleInfo.getCotTheta();
715
716 //track parameters residuals in momentum:
717 double px_res = fitResult->getMomentum().X() - mcParticleInfo.getPx();
718 double py_res = fitResult->getMomentum().Y() - mcParticleInfo.getPy();
719 double pz_res = fitResult->getMomentum().Z() - mcParticleInfo.getPz();
720 double p_res = (fitResult->getMomentum().R() - mcParticleInfo.getP()) / mcParticleInfo.getP();
721 double pt_res = (fitResult->getMomentum().Rho() - mcParticleInfo.getPt()) / mcParticleInfo.getPt();
722
723 //track parameters residuals in position:
724 double x_res = fitResult->getPosition().X() - mcParticleInfo.getX();
725 double y_res = fitResult->getPosition().Y() - mcParticleInfo.getY();
726 double z_res = fitResult->getPosition().Z() - mcParticleInfo.getZ();
727 double r_res = fitResult->getPosition().Rho() - sqrt(mcParticleInfo.getX() * mcParticleInfo.getX() + mcParticleInfo.getY() *
728 mcParticleInfo.getY());
729 double rtot_res = fitResult->getPosition().R() - sqrt(mcParticleInfo.getX() * mcParticleInfo.getX() + mcParticleInfo.getY() *
730 mcParticleInfo.getY() + mcParticleInfo.getZ() * mcParticleInfo.getZ());
731
732 m_h1_d0_err->Fill(d0_err);
733 m_h1_phi_err->Fill(phi_err);
734 m_h1_omega_err->Fill(omega_err);
735 m_h1_z0_err->Fill(z0_err);
736 m_h1_cotTheta_err->Fill(cotTheta_err);
737
738 m_h1_d0_res->Fill(d0_res);
739 m_h1_phi_res->Fill(phi_res);
740 m_h1_omega_res->Fill(omega_res);
741 m_h1_z0_res->Fill(z0_res);
742 m_h1_cotTheta_res->Fill(cotTheta_res);
743
744 m_h1_px_res->Fill(px_res);
745 m_h1_py_res->Fill(py_res);
746 m_h1_pz_res->Fill(pz_res);
747 m_h1_p_res->Fill(p_res);
748 m_h1_pt_res->Fill(pt_res);
749
750 m_h1_x_res->Fill(x_res);
751 m_h1_y_res->Fill(y_res);
752 m_h1_z_res->Fill(z_res);
753 m_h1_r_res->Fill(r_res);
754 m_h1_rtot_res->Fill(rtot_res);
755
756 m_h2_chargeVSchargeMC->Fill(mcParticleInfo.getCharge(), fitResult->getChargeSign());
757
758 m_h1_d0_pll->Fill(d0_res / d0_err);
759 m_h1_phi_pll->Fill(phi_res / phi_err);
760 m_h1_omega_pll->Fill(omega_res / omega_err);
761 m_h1_z0_pll->Fill(z0_res / z0_err);
762 m_h1_cotTheta_pll->Fill(cotTheta_res / cotTheta_err);
763
764
765 m_h2_OmegaerrOmegaVSpt->Fill(fitResult->getMomentum().Rho(), omega_err / mcParticleInfo.getOmega());
766
767
768}
769
771{
772
773
774 double d0_err = sqrt((fitResult->getCovariance5())[0][0]);
775 double phi_err = sqrt((fitResult->getCovariance5())[1][1]);
776 double z0_err = sqrt((fitResult->getCovariance5())[3][3]);
777 double cotTheta_err = sqrt((fitResult->getCovariance5())[4][4]);
778
779 ROOT::Math::XYZVector momentum = fitResult->getMomentum();
780
781 double px = momentum.x();
782 double py = momentum.y();
783 double pz = momentum.z();
784 double pt = momentum.Rho();
785 double p = momentum.R();
786 double mass = fitResult->getParticleType().getMass();
787 double beta = p / sqrt(p * p + mass * mass);
788 double sinTheta = TMath::Sin(momentum.Theta());
789
790 m_h2_d0errphi0err_xy->Fill(d0_err / phi_err * px / pt,
791 d0_err / phi_err * py / pt);
792 m_h2_z0errcotThetaerr_xy->Fill(z0_err / cotTheta_err * px / pt,
793 z0_err / cotTheta_err * py / pt);
794 m_h2_d0errphi0err_rz->Fill(d0_err / phi_err * pz / pt,
795 d0_err / phi_err);
796
797 m_h2_d0errVSpt->Fill(pt, d0_err);
798
799 m_h2_z0errVSpt->Fill(pt, z0_err);
800
801 m_h2_d0errMSVSpt->Fill(pt, d0_err * beta * p * pow(sinTheta, 3 / 2) / 0.0136);
802
803}
804
806{
807
808 //hits used in the fit
809
811
812 const VXD::GeoCache& aGeometry = VXD::GeoCache::getInstance();
813
814 bool hasPXDhit = false;
815 bool isTrueHit = false;
816
817 double d0_err = -999;
818 double z0_err = -999;
819 double pt = -999;
820
821 if (fitResult) {
822 d0_err = sqrt((fitResult->getCovariance5())[0][0]);
823 z0_err = sqrt((fitResult->getCovariance5())[3][3]);
824 pt = fitResult->getMomentum().Rho();
825 }
826
827 const bool hasCDChit[56] = { false };
828
830
831 for (int tc = 0; tc < (int)RecoTracks_fromTrack.size(); tc++) {
832
833 const std::vector< genfit::TrackPoint* >& tp_vector = RecoTracks_fromTrack[tc]->getHitPointsWithMeasurement();
834 for (int i = 0; i < (int) tp_vector.size(); i++) {
835 const genfit::TrackPoint* tp = tp_vector[i];
836
837 int nMea = tp->getNumRawMeasurements();
838 for (int mea = 0; mea < nMea; mea++) {
839
840 genfit::AbsMeasurement* absMeas = tp->getRawMeasurement(mea);
841 double weight = 0;
842
843 std::vector<double> weights;
844 const genfit::KalmanFitterInfo* kalmanInfo = tp->getKalmanFitterInfo();
845 if (kalmanInfo)
846 weights = kalmanInfo->getWeights();
847 else //no kalman fitter info, fill the weights vector with 0 (VXD), or 0,0 (CDC)
848 B2WARNING(" No KalmanFitterInfo associated to the TrackPoint!");
849
850 double detId(-999);
851 ROOT::Math::XYZVector globalHit(-999, -999, -999);
852
853 const PXDRecoHit* pxdHit = dynamic_cast<PXDRecoHit*>(absMeas);
854 const SVDRecoHit2D* svdHit2D = dynamic_cast<SVDRecoHit2D*>(absMeas);
855 const SVDRecoHit* svdHit = dynamic_cast<SVDRecoHit*>(absMeas);
856 const CDCRecoHit* cdcHit = dynamic_cast<CDCRecoHit*>(absMeas);
857
858 if (pxdHit) {
859 hasPXDhit = true;
860 isTrueHit = false;
861
862 if (kalmanInfo)
863 weight = weights.at(mea);
864
865 detId = 0;
866 double uCoor = pxdHit->getU();
867 double vCoor = pxdHit->getV();
868 VxdID sensor = pxdHit->getSensorID();
869
870 m_h1_nVXDhitsPR->Fill(sensor.getLayerNumber());
871
872 m_h1_nVXDhitsWeighted->Fill(sensor.getLayerNumber(), weight);
873
874 m_h2_TrackPointFitWeightVXD->Fill(sensor.getLayerNumber(), weight);
875 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo(sensor);
876 globalHit = aSensorInfo.pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0), true);
877
878
879 const PXDCluster* pxdcl = pxdHit->getCluster();
881
882 if ((int)pxdth_fromcl.size() != 0) {
883 const PXDTrueHit* trueHit = pxdth_fromcl[0];
884
885 if (trueHit) {
886 int trueHitIndex = trueHit->getArrayIndex();
888 for (int mcp = 0; mcp < (int)MCParticles_fromTrack.size(); mcp++) {
889 RelationVector<PXDTrueHit> trueHit_fromMCParticles = DataStore::getRelationsWithObj<PXDTrueHit>(MCParticles_fromTrack[mcp]);
890 for (int th = 0; th < (int)trueHit_fromMCParticles.size(); th++) {
891 if (trueHit_fromMCParticles[th]->getArrayIndex() == trueHitIndex)
892 isTrueHit = true;
893 }
894 }
895 }
896 }
897
898 } else if (svdHit2D) {
899
900 if (kalmanInfo)
901 weight = weights.at(mea);
902
903 detId = 1;
904 double uCoor = svdHit2D->getU();
905 double vCoor = svdHit2D->getV();
906 VxdID sensor = svdHit2D->getSensorID();
907
908 m_h1_nVXDhitsPR->Fill(sensor.getLayerNumber());
909
910 m_h1_nVXDhitsWeighted->Fill(sensor.getLayerNumber(), weight);
911
912 m_h2_TrackPointFitWeightVXD->Fill(sensor.getLayerNumber(), weight);
913
914 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo(sensor);
915 globalHit = aSensorInfo.pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0), true);
916
917 } else if (svdHit) {
918
919 if (kalmanInfo)
920 weight = weights.at(mea);
921
922 detId = 2;
923 double uCoor = 0;
924 double vCoor = 0;
925 if (svdHit->isU())
926 uCoor = svdHit->getPosition();
927 else
928 vCoor = svdHit->getPosition();
929
930 VxdID sensor = svdHit->getSensorID();
931 m_h1_nVXDhitsPR->Fill(sensor.getLayerNumber());
932
933 m_h1_nVXDhitsWeighted->Fill(sensor.getLayerNumber(), weight);
934
935 m_h2_TrackPointFitWeightVXD->Fill(sensor.getLayerNumber(), weight);
936 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo(sensor);
937 globalHit = aSensorInfo.pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0), true);
938 } else if (cdcHit) {
939
940 if (kalmanInfo)
941 weight = weights.at(mea);
942
943 WireID wire = cdcHit->getWireID();
944 if (! hasCDChit[wire.getICLayer()]) { //needed to validate the HitPatternCDC filling
945 m_h1_nCDChitsPR->Fill(wire.getICLayer());
946
947 m_h1_nCDChitsWeighted->Fill(wire.getICLayer(), weight);
948 // hasCDChit[wire.getICLayer()] = true; //to validate the HitPatternCDC filling: uncomment this
949 }
950 m_h2_TrackPointFitWeightCDC->Fill(wire.getICLayer(), weight);
951 detId = 3;
952 }
953
954
955 m_h1_nHitDetID ->Fill(detId);
956
957 m_h2_VXDhitsPR_xy->Fill(globalHit.X(), globalHit.Y());
958
959 m_h2_VXDhitsPR_rz->Fill(globalHit.Z(), globalHit.Rho());
960
961 }
962
963 }
964 }
965
966 if ((fitResult != nullptr) && (fitResult->getParticleType() == Const::ChargedStable(m_ParticleHypothesis))) {
967 if (hasPXDhit) {
968 m_h2_d0errVSpt_wpxd->Fill(pt, d0_err);
969 m_h2_z0errVSpt_wpxd->Fill(pt, z0_err);
970 if (isTrueHit) {
971 m_h2_d0errVSpt_wtpxd->Fill(pt, d0_err);
972 m_h2_z0errVSpt_wtpxd->Fill(pt, z0_err);
973 } else {
974 m_h2_d0errVSpt_wfpxd->Fill(pt, d0_err);
975 m_h2_z0errVSpt_wfpxd->Fill(pt, z0_err);
976 }
977 } else {
978 m_h2_d0errVSpt_wopxd->Fill(pt, d0_err);
979 m_h2_z0errVSpt_wopxd->Fill(pt, z0_err);
980 }
981 }
982
983}
984
986{
987
988 //normalized to MCParticles
989 TH1F* h_ineff_pt = createHistogramsRatio("hineffpt", "inefficiency VS pt, normalized to MCParticles", m_h3_TracksPerMCParticle,
990 m_h3_MCParticle, false, 0);
991 histoList->Add(h_ineff_pt);
992
993 TH1F* h_ineff_theta = createHistogramsRatio("hinefftheta", "inefficiency VS #theta, normalized to MCParticles",
995 histoList->Add(h_ineff_theta);
996
997 TH1F* h_ineff_phi = createHistogramsRatio("hineffphi", "inefficiency VS #phi, normalized to MCParticles", m_h3_TracksPerMCParticle,
998 m_h3_MCParticle, false, 2);
999 histoList->Add(h_ineff_phi);
1000
1001 //normalized to MCRecoTracks
1002 TH1F* h_ineffMCRT_pt = createHistogramsRatio("hineffMCRTpt", "inefficiency VS pt, normalized to MCRecoTrack",
1004 histoList->Add(h_ineffMCRT_pt);
1005
1006 TH1F* h_ineffMCRT_theta = createHistogramsRatio("hineffMCRTtheta", "inefficiency VS #theta, normalized to MCRecoTrack",
1008 histoList->Add(h_ineffMCRT_theta);
1009
1010 TH1F* h_ineffMCRT_phi = createHistogramsRatio("hineffMCRTphi", "inefficiency VS #phi, normalized to MCRecoTrack",
1012 histoList->Add(h_ineffMCRT_phi);
1013
1014}
1015
1017{
1018
1019
1020 TH1F* h_MCPwPXDhits_pt = createHistogramsRatio("hMCPwPXDhits", "fraction of MCParticles with PXD hits VS pt",
1022 m_h3_MCParticle, true, 0);
1023 histoList->Add(h_MCPwPXDhits_pt);
1024
1025 TH1F* h_RTwPXDhitsMCPwPXDHits_pt = createHistogramsRatio("hRecoTrkswPXDhitsMCPwPXDHits",
1026 "fraction of MCParticles with PXD Hits with RecoTracks with PXD hits VS pt",
1028 m_h3_MCParticleswPXDHits, true, 0);
1029 histoList->Add(h_RTwPXDhitsMCPwPXDHits_pt);
1030
1031 TH1F* h_wPXDhits_pt = createHistogramsRatio("hTrkswPXDhits", "fraction of tracks with PXD hits VS pt",
1033 m_h3_TracksPerMCParticle, true, 0);
1034 histoList->Add(h_wPXDhits_pt);
1035
1036 //normalized to MCParticles
1037 TH1F* h_eff_pt = createHistogramsRatio("heffpt", "efficiency VS pt, normalized to MCParticles", m_h3_TracksPerMCParticle,
1038 m_h3_MCParticle, true, 0);
1039 histoList->Add(h_eff_pt);
1040 // B2INFO(" efficiency in pt, NUM = "<<m_nFittedTracks<<", DEN = "<<m_nMCParticles<<", eff integrata = "<<(double)m_nFittedTracks/m_nMCParticles);
1041
1042 TH1F* h_eff_theta = createHistogramsRatio("hefftheta", "efficiency VS #theta, normalized to MCParticles", m_h3_TracksPerMCParticle,
1043 m_h3_MCParticle, true, 1);
1044 histoList->Add(h_eff_theta);
1045
1046 TH1F* h_eff_phi = createHistogramsRatio("heffphi", "efficiency VS #phi, normalized to MCParticles", m_h3_TracksPerMCParticle,
1047 m_h3_MCParticle, true, 2);
1048 histoList->Add(h_eff_phi);
1049
1050 //normalized to MCRecoTracks
1051 TH1F* h_effMCRT_pt = createHistogramsRatio("heffMCRTpt", "efficiency VS pt, normalized to MCRecoTrack", m_h3_TracksPerMCRecoTrack,
1052 m_h3_MCRecoTrack, true, 0);
1053 histoList->Add(h_effMCRT_pt);
1054
1055 TH1F* h_effMCRT_theta = createHistogramsRatio("heffMCRTtheta", "efficiency VS #theta, normalized to MCRecoTrack",
1057 histoList->Add(h_effMCRT_theta);
1058
1059 TH1F* h_effMCRT_phi = createHistogramsRatio("heffMCRTphi", "efficiency VS #phi, normalized to MCRecoTrack",
1061 histoList->Add(h_effMCRT_phi);
1062
1063 // plus
1064
1065 //normalized to MCParticles
1066 TH1F* h_eff_pt_plus = createHistogramsRatio("heffpt_plus", "efficiency VS pt, normalized to positive MCParticles",
1068 histoList->Add(h_eff_pt_plus);
1069 // B2INFO(" efficiency in pt, NUM = "<<m_nFittedTracks<<", DEN = "<<m_nMCParticles<<", eff integrata = "<<(double)m_nFittedTracks/m_nMCParticles);
1070
1071 TH1F* h_eff_theta_plus = createHistogramsRatio("hefftheta_plus", "efficiency VS #theta, normalized to positive MCParticles",
1073 histoList->Add(h_eff_theta_plus);
1074
1075 TH1F* h_eff_phi_plus = createHistogramsRatio("heffphi_plus", "efficiency VS #phi, normalized to positive MCParticles",
1077 histoList->Add(h_eff_phi_plus);
1078
1079 //normalized to MCRecoTracks
1080 TH1F* h_effMCRT_pt_plus = createHistogramsRatio("heffMCRTpt_plus", "efficiency VS pt, normalized to positive MCRecoTrack",
1082 histoList->Add(h_effMCRT_pt_plus);
1083
1084 TH1F* h_effMCRT_theta_plus = createHistogramsRatio("heffMCRTtheta_plus", "efficiency VS #theta, normalized to positive MCRecoTrack",
1086 histoList->Add(h_effMCRT_theta_plus);
1087
1088 TH1F* h_effMCRT_phi_plus = createHistogramsRatio("heffMCRTphi_plus", "efficiency VS #phi, normalized to positive MCRecoTrack",
1090 histoList->Add(h_effMCRT_phi_plus);
1091
1092 // minus
1093
1094 //normalized to MCParticles
1095 TH1F* h_eff_pt_minus = createHistogramsRatio("heffpt_minus", "efficiency VS pt, normalized to positive MCParticles",
1097 histoList->Add(h_eff_pt_minus);
1098 // B2INFO(" efficiency in pt, NUM = "<<m_nFittedTracks<<", DEN = "<<m_nMCParticles<<", eff integrata = "<<(double)m_nFittedTracks/m_nMCParticles);
1099
1100 TH1F* h_eff_theta_minus = createHistogramsRatio("hefftheta_minus", "efficiency VS #theta, normalized to positive MCParticles",
1102 histoList->Add(h_eff_theta_minus);
1103
1104 TH1F* h_eff_phi_minus = createHistogramsRatio("heffphi_minus", "efficiency VS #phi, normalized to positive MCParticles",
1106 histoList->Add(h_eff_phi_minus);
1107
1108 //normalized to MCRecoTracks
1109 TH1F* h_effMCRT_pt_minus = createHistogramsRatio("heffMCRTpt_minus", "efficiency VS pt, normalized to positive MCRecoTrack",
1111 histoList->Add(h_effMCRT_pt_minus);
1112
1113 TH1F* h_effMCRT_theta_minus = createHistogramsRatio("heffMCRTtheta_minus",
1114 "efficiency VS #theta, normalized to positive MCRecoTrack", m_h3_TracksPerMCRecoTrack_minus, m_h3_MCRecoTrack_minus, true, 1);
1115 histoList->Add(h_effMCRT_theta_minus);
1116
1117 TH1F* h_effMCRT_phi_minus = createHistogramsRatio("heffMCRTphi_minus", "efficiency VS #phi, normalized to positive MCRecoTrack",
1119 histoList->Add(h_effMCRT_phi_minus);
1120
1121 //pattern recognition efficiency
1122 TH1F* h_effPR = createHistogramsRatio("heffPR", "PR efficiency VS VXD Layer, normalized to MCRecoTrack",
1124 histoList->Add(h_effPR);
1125
1126 //tracks used in the fit
1127 TH1F* h_effVXDHitFit = createHistogramsRatio("heffVXDHitFit",
1128 "weighted hits used in the fit VS VXD Layer, normalized to hits form PR", m_h1_nVXDhitsWeighted, m_h1_nVXDhitsPR, true, 0);
1129 histoList->Add(h_effVXDHitFit);
1130
1131 TH1F* h_effCDCHitFit = createHistogramsRatio("heffCDCHitFit",
1132 "weighted hits used in the fit VS CDC Layer, normalized to hits form PR", m_h1_nCDChitsWeighted, m_h1_nCDChitsPR, true, 0);
1133 histoList->Add(h_effCDCHitFit);
1134
1135}
1136
1137
1138
1139
1141{
1142
1143 bool isChargedStable = Const::chargedStableSet.find(abs(the_mcParticle.getPDG())) != Const::invalidParticle;
1144
1145 bool isPrimary = the_mcParticle.hasStatus(MCParticle::c_PrimaryParticle);
1146
1147 return (isPrimary && isChargedStable);
1148
1149}
double R
typedef autogenerated by FFTW
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:590
double getMass() const
Particle mass.
Definition UnitConst.cc:353
static const ParticleSet chargedStableSet
set of charged stable particles
Definition Const.h:619
static const ParticleType invalidParticle
Invalid particle, used internally.
Definition Const.h:682
static RelationVector< T > getRelationsWithObj(const TObject *object, const std::string &name="", const std::string &namedRelation="")
Get the relations between an object and other objects in a store array.
Definition DataStore.h:412
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:118
int getPDG() const
Return PDG code of particle.
Definition MCParticle.h:101
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
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:53
float getV() const
Get v coordinate.
Definition PXDRecoHit.h:115
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:110
VxdID getSensorID() const
Get the compact ID.
Definition PXDRecoHit.h:105
float getU() const
Get u coordinate.
Definition PXDRecoHit.h:113
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.
float getV() const
Get v coordinate.
VxdID getSensorID() const
Get the compact ID.
float getU() const
Get u coordinate.
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
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_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
static 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.
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 facilitate easy access to sensor information of the VXD like coordinate transformations or p...
Definition GeoCache.h:38
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference 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:32
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.