24 for (
unsigned int ww = 0; ww < associators.size(); ww++) {
25 for (
unsigned int www = 0; www <
label.size(); www++) {
30 auto setBinLogX = [
this](TH1* th1) {
37 dirName += algo.
process() +
"_";
38 if (!algo.
label().empty())
39 dirName += algo.
label();
42 if (dirName.find(
"Tracks") < dirName.length()) {
43 dirName.replace(dirName.find(
"Tracks"), 6,
"Trks");
45 if (dirName.find(
"UpdatedAtVtx") < dirName.length()) {
46 dirName.replace(dirName.find(
"UpdatedAtVtx"), 12,
"UpdAtVtx");
48 string assoc = associators[ww];
49 if (assoc.find(
"tpToTkmuTrackAssociation") < assoc.length()) {
56 ibooker.
book1D(
"Ntracks",
"Number of reconstructed tracks", nintNTracks, minNTracks,
maxNTracks));
57 h_fakes.push_back(ibooker.
book1D(
"Nfakes",
"Number of fake reco tracks", nintFTracks, minFTracks, maxFTracks));
58 h_charge.push_back(ibooker.
book1D(
"Ncharge",
"track charge", 3, -1.5, 1.5));
60 h_recoeta.push_back(ibooker.
book1D(
"num_reco_eta",
"N of reco track vs eta", nintEta, minEta,
maxEta));
61 h_assoceta.push_back(ibooker.
book1D(
62 "num_assoSimToReco_eta",
"N of associated tracks (simToReco) vs eta", nintEta, minEta,
maxEta));
63 h_assoc2eta.push_back(ibooker.
book1D(
64 "num_assoRecoToSim_eta",
"N of associated (recoToSim) tracks vs eta", nintEta, minEta,
maxEta));
65 h_simuleta.push_back(ibooker.
book1D(
"num_simul_eta",
"N of simulated tracks vs eta", nintEta, minEta,
maxEta));
66 h_misideta.push_back(ibooker.
book1D(
"num_chargemisid_eta",
67 "N of associated (simToReco) tracks with charge misID vs eta",
72 h_recopT.push_back(ibooker.
book1D(
"num_reco_pT",
"N of reco track vs pT", nintPt,
minPt, maxPt, setBinLogX));
73 h_assocpT.push_back(ibooker.
book1D(
74 "num_assoSimToReco_pT",
"N of associated tracks (simToReco) vs pT", nintPt,
minPt, maxPt, setBinLogX));
75 h_assoc2pT.push_back(ibooker.
book1D(
76 "num_assoRecoToSim_pT",
"N of associated (recoToSim) tracks vs pT", nintPt,
minPt, maxPt, setBinLogX));
78 ibooker.
book1D(
"num_simul_pT",
"N of simulated tracks vs pT", nintPt,
minPt, maxPt, setBinLogX));
79 h_misidpT.push_back(ibooker.
book1D(
"num_chargemisid_pT",
80 "N of associated (simToReco) tracks with charge misID vs pT",
86 h_recophi.push_back(ibooker.
book1D(
"num_reco_phi",
"N of reco track vs phi", nintPhi,
minPhi,
maxPhi));
87 h_assocphi.push_back(ibooker.
book1D(
88 "num_assoSimToReco_phi",
"N of associated tracks (simToReco) vs phi", nintPhi,
minPhi,
maxPhi));
89 h_assoc2phi.push_back(ibooker.
book1D(
90 "num_assoRecoToSim_phi",
"N of associated (recoToSim) tracks vs phi", nintPhi,
minPhi,
maxPhi));
91 h_simulphi.push_back(ibooker.
book1D(
"num_simul_phi",
"N of simulated tracks vs phi", nintPhi,
minPhi,
maxPhi));
92 h_misidphi.push_back(ibooker.
book1D(
"num_chargemisid_phi",
93 "N of associated (simToReco) tracks with charge misID vs phi",
98 h_recohit.push_back(ibooker.
book1D(
"num_reco_hit",
"N of reco tracks vs N SimHits", nintNHit, minNHit, maxNHit));
99 h_assochit.push_back(ibooker.
book1D(
100 "num_assoSimToReco_hit",
"N of associated tracks (simToReco) vs N SimHits", nintNHit, minNHit, maxNHit));
101 h_assoc2hit.push_back(ibooker.
book1D(
102 "num_assoRecoToSim_hit",
"N of associated (recoToSim) tracks vs N Rechits", nintNHit, minNHit, maxNHit));
103 h_simulhit.push_back(
104 ibooker.
book1D(
"num_simul_hit",
"N of simulated tracks vs N SimHits", nintNHit, minNHit, maxNHit));
105 h_misidhit.push_back(ibooker.
book1D(
"num_chargemisid_hit",
106 "N of associated (recoToSim) tracks with charge misID vs N RecHits",
111 h_recodxy.push_back(ibooker.
book1D(
"num_reco_dxy",
"N of reco track vs dxy", nintDxy, minDxy,
maxDxy));
112 h_assocdxy.push_back(ibooker.
book1D(
113 "num_assoSimToReco_dxy",
"N of associated tracks (simToReco) vs dxy", nintDxy, minDxy,
maxDxy));
114 h_assoc2dxy.push_back(ibooker.
book1D(
115 "num_assoRecoToSim_dxy",
"N of associated (recoToSim) tracks vs dxy", nintDxy, minDxy,
maxDxy));
116 h_simuldxy.push_back(ibooker.
book1D(
"num_simul_dxy",
"N of simulated tracks vs dxy", nintDxy, minDxy,
maxDxy));
117 h_misiddxy.push_back(ibooker.
book1D(
"num_chargemisid_dxy",
118 "N of associated (simToReco) tracks with charge misID vs dxy",
122 h_recodz.push_back(ibooker.
book1D(
"num_reco_dz",
"N of reco track vs dz", nintDz, minDz, maxDz));
124 ibooker.
book1D(
"num_assoSimToReco_dz",
"N of associated tracks (simToReco) vs dz", nintDz, minDz, maxDz));
125 h_assoc2dz.push_back(
126 ibooker.
book1D(
"num_assoRecoToSim_dz",
"N of associated (recoToSim) tracks vs dz", nintDz, minDz, maxDz));
127 h_simuldz.push_back(ibooker.
book1D(
"num_simul_dz",
"N of simulated tracks vs dz", nintDz, minDz, maxDz));
128 h_misiddz.push_back(ibooker.
book1D(
129 "num_chargemisid_dz",
"N of associated (simToReco) tracks with charge misID vs dz", nintDz, minDz, maxDz));
131 h_assocRpos.push_back(ibooker.
book1D(
132 "num_assoSimToReco_Rpos",
"N of associated tracks (simToReco) vs Radius", nintRpos, minRpos, maxRpos));
133 h_simulRpos.push_back(
134 ibooker.
book1D(
"num_simul_Rpos",
"N of simulated tracks vs Radius", nintRpos, minRpos, maxRpos));
136 h_assocZpos.push_back(ibooker.
book1D(
137 "num_assoSimToReco_Zpos",
"N of associated tracks (simToReco) vs Z", nintZpos, minZpos, maxZpos));
138 h_simulZpos.push_back(ibooker.
book1D(
"num_simul_Zpos",
"N of simulated tracks vs Z", nintZpos, minZpos, maxZpos));
140 h_recopu.push_back(ibooker.
book1D(
"num_reco_pu",
"N of reco track vs pu", nintPU, minPU, maxPU));
142 ibooker.
book1D(
"num_assoSimToReco_pu",
"N of associated tracks (simToReco) vs pu", nintPU, minPU, maxPU));
143 h_assoc2pu.push_back(
144 ibooker.
book1D(
"num_assoRecoToSim_pu",
"N of associated (recoToSim) tracks vs pu", nintPU, minPU, maxPU));
145 h_simulpu.push_back(ibooker.
book1D(
"num_simul_pu",
"N of simulated tracks vs pu", nintPU, minPU, maxPU));
146 h_misidpu.push_back(ibooker.
book1D(
147 "num_chargemisid_pu",
"N of associated (simToReco) charge misIDed tracks vs pu", nintPU, minPU, maxPU));
149 h_nchi2.push_back(ibooker.
book1D(
"chi2",
"Track normalized #chi^{2}", 80, 0., 20.));
150 h_nchi2_prob.push_back(ibooker.
book1D(
"chi2prob",
"Probability of track normalized #chi^{2}", 100, 0., 1.));
152 chi2_vs_nhits.push_back(
153 ibooker.
book2D(
"chi2_vs_nhits",
"#chi^{2} vs nhits", nintNHit, minNHit, maxNHit, 20, 0., 10.));
154 chi2_vs_eta.push_back(ibooker.
book2D(
"chi2_vs_eta",
"chi2_vs_eta", nintEta, minEta,
maxEta, 40, 0., 20.));
155 chi2_vs_phi.push_back(ibooker.
book2D(
"chi2_vs_phi",
"#chi^{2} vs #phi", nintPhi,
minPhi,
maxPhi, 40, 0., 20.));
157 h_nhits.push_back(ibooker.
book1D(
"nhits",
"Number of hits per track", nintNHit, minNHit, maxNHit));
158 nhits_vs_eta.push_back(
159 ibooker.
book2D(
"nhits_vs_eta",
"Number of Hits vs eta", nintEta, minEta,
maxEta, nintNHit, minNHit, maxNHit));
160 nhits_vs_phi.push_back(
161 ibooker.
book2D(
"nhits_vs_phi",
"#hits vs #phi", nintPhi,
minPhi,
maxPhi, nintNHit, minNHit, maxNHit));
163 if (do_MUOhitsPlots) {
164 nDThits_vs_eta.push_back(ibooker.
book2D(
165 "nDThits_vs_eta",
"Number of DT hits vs eta", nintEta, minEta,
maxEta, nintDTHit, minDTHit, maxDTHit));
166 nCSChits_vs_eta.push_back(ibooker.
book2D(
167 "nCSChits_vs_eta",
"Number of CSC hits vs eta", nintEta, minEta,
maxEta, nintCSCHit, minCSCHit, maxCSCHit));
168 nRPChits_vs_eta.push_back(ibooker.
book2D(
169 "nRPChits_vs_eta",
"Number of RPC hits vs eta", nintEta, minEta,
maxEta, nintRPCHit, minRPCHit, maxRPCHit));
171 nGEMhits_vs_eta.push_back(ibooker.
book2D(
172 "nGEMhits_vs_eta",
"Number of GEM hits vs eta", nintEta, minEta,
maxEta, nintNHit, minNHit, maxNHit));
174 nME0hits_vs_eta.push_back(ibooker.
book2D(
175 "nME0hits_vs_eta",
"Number of ME0 hits vs eta", nintEta, minEta,
maxEta, nintNHit, minNHit, maxNHit));
178 if (do_TRKhitsPlots) {
179 nTRK_LayersWithMeas_vs_eta.push_back(ibooker.
book2D(
"nTRK_LayersWithMeas_vs_eta",
180 "# TRK Layers with measurement vs eta",
187 nPixel_LayersWithMeas_vs_eta.push_back(ibooker.
book2D(
"nPixel_LayersWithMeas_vs_eta",
188 "Number of Pixel Layers with measurement vs eta",
195 h_nmisslayers_inner.push_back(ibooker.
book1D(
196 "nTRK_misslayers_inner",
"Number of missing inner TRK layers", nintLayers, minLayers, maxLayers));
197 h_nmisslayers_outer.push_back(ibooker.
book1D(
198 "nTRK_misslayers_outer",
"Number of missing outer TRK layers", nintLayers, minLayers, maxLayers));
199 h_nlosthits.push_back(ibooker.
book1D(
"nlosthits",
"Number of lost hits per track", 6, -0.5, 5.5));
200 nlosthits_vs_eta.push_back(ibooker.
book2D(
201 "nlosthits_vs_eta",
"Number of lost hits per track vs eta", nintEta, minEta,
maxEta, 6, -0.5, 5.5));
204 ptres_vs_eta.push_back(ibooker.
book2D(
"ptres_vs_eta",
205 "p_{T} Relative Residual vs #eta",
212 ptres_vs_phi.push_back(ibooker.
book2D(
"ptres_vs_phi",
213 "p_{T} Relative Residual vs #phi",
220 ptres_vs_pt.push_back(ibooker.
book2D(
"ptres_vs_pt",
221 "p_{T} Relative Residual vs p_{T}",
229 h_ptpull.push_back(ibooker.
book1D(
"ptpull",
"p_{T} Pull", 100, -10., 10.));
230 ptpull_vs_eta.push_back(
231 ibooker.
book2D(
"ptpull_vs_eta",
"p_{T} Pull vs #eta", nintEta, minEta,
maxEta, 100, -10., 10.));
232 ptpull_vs_phi.push_back(
233 ibooker.
book2D(
"ptpull_vs_phi",
"p_{T} Pull vs #phi", nintPhi,
minPhi,
maxPhi, 100, -10., 10.));
234 h_qoverppull.push_back(ibooker.
book1D(
"qoverppull",
"q/p Pull", 100, -10., 10.));
236 h_etaRes.push_back(ibooker.
book1D(
"etaRes",
"#eta residual", etaRes_nbin, etaRes_rangeMin, etaRes_rangeMax));
237 etares_vs_eta.push_back(ibooker.
book2D(
"etares_vs_eta",
238 "#eta Residual vs #eta",
246 thetaCotres_vs_eta.push_back(ibooker.
book2D(
"thetaCotres_vs_eta",
247 "cot(#theta) Residual vs #eta",
252 cotThetaRes_rangeMin,
253 cotThetaRes_rangeMax));
254 thetaCotres_vs_pt.push_back(ibooker.
book2D(
"thetaCotres_vs_pt",
255 "cot(#theta) Residual vs p_{T}",
260 cotThetaRes_rangeMin,
261 cotThetaRes_rangeMax,
263 h_thetapull.push_back(ibooker.
book1D(
"thetapull",
"#theta Pull", 100, -10., 10.));
264 thetapull_vs_eta.push_back(
265 ibooker.
book2D(
"thetapull_vs_eta",
"#theta Pull vs #eta", nintEta, minEta,
maxEta, 100, -10, 10));
266 thetapull_vs_phi.push_back(
267 ibooker.
book2D(
"thetapull_vs_phi",
"#theta Pull vs #phi", nintPhi,
minPhi,
maxPhi, 100, -10, 10));
269 phires_vs_eta.push_back(ibooker.
book2D(
"phires_vs_eta",
270 "#phi Residual vs #eta",
277 phires_vs_pt.push_back(ibooker.
book2D(
"phires_vs_pt",
278 "#phi Residual vs p_{T}",
286 phires_vs_phi.push_back(ibooker.
book2D(
"phires_vs_phi",
287 "#phi Residual vs #phi",
294 h_phipull.push_back(ibooker.
book1D(
"phipull",
"#phi Pull", 100, -10., 10.));
295 phipull_vs_eta.push_back(
296 ibooker.
book2D(
"phipull_vs_eta",
"#phi Pull vs #eta", nintEta, minEta,
maxEta, 100, -10, 10));
297 phipull_vs_phi.push_back(
298 ibooker.
book2D(
"phipull_vs_phi",
"#phi Pull vs #phi", nintPhi,
minPhi,
maxPhi, 100, -10, 10));
300 dxyres_vs_eta.push_back(ibooker.
book2D(
"dxyres_vs_eta",
301 "dxy Residual vs #eta",
308 dxyres_vs_pt.push_back(ibooker.
book2D(
"dxyres_vs_pt",
309 "dxy Residual vs p_{T}",
317 h_dxypull.push_back(ibooker.
book1D(
"dxypull",
"dxy Pull", 100, -10., 10.));
318 dxypull_vs_eta.push_back(
319 ibooker.
book2D(
"dxypull_vs_eta",
"dxy Pull vs #eta", nintEta, minEta,
maxEta, 100, -10, 10));
321 dzres_vs_eta.push_back(ibooker.
book2D(
322 "dzres_vs_eta",
"dz Residual vs #eta", nintEta, minEta,
maxEta, dzRes_nbin, dzRes_rangeMin, dzRes_rangeMax));
323 dzres_vs_pt.push_back(ibooker.
book2D(
"dzres_vs_pt",
324 "dz Residual vs p_{T}",
332 h_dzpull.push_back(ibooker.
book1D(
"dzpull",
"dz Pull", 100, -10., 10.));
333 dzpull_vs_eta.push_back(
334 ibooker.
book2D(
"dzpull_vs_eta",
"dz Pull vs #eta", nintEta, minEta,
maxEta, 100, -10, 10));
336 nRecHits_vs_nSimHits.push_back(ibooker.
book2D(
337 "nRecHits_vs_nSimHits",
"nRecHits vs nSimHits", nintNHit, minNHit, maxNHit, nintNHit, minNHit, maxNHit));
340 h_PurityVsQuality.push_back(
341 ibooker.
book2D(
"PurityVsQuality",
"Purity vs Quality (MABH)", 20, 0.01, 1.01, 20, 0.01, 1.01));
344 if (associators[ww] ==
"trackAssociatorByChi2") {
345 h_assochi2.push_back(ibooker.
book1D(
"assocChi2",
"track association #chi^{2}", 1000, 0., 100.));
346 h_assochi2_prob.push_back(ibooker.
book1D(
"assocChi2_prob",
"probability of association #chi^{2}", 100, 0., 1.));
347 }
else if (associators[ww] ==
"trackAssociatorByHits") {
348 h_assocFraction.push_back(ibooker.
book1D(
"assocFraction",
"fraction of shared hits", 22, 0., 1.1));
349 h_assocSharedHit.push_back(ibooker.
book1D(
"assocSharedHit",
"number of shared hits", 41, -0.5, 40.5));
357 using namespace reco;
359 edm::LogInfo(
"MuonTrackValidator") <<
"\n===================================================="
361 <<
"Analyzing new event"
363 <<
"====================================================\n"
367 int PU_NumInteractions(-1);
369 if (parametersDefiner ==
"LhcParametersDefinerForTP") {
371 event.getByToken(pileupinfo_Token, puinfoH);
372 for (std::vector<PileupSummaryInfo>::const_iterator puInfoIt = puinfoH->begin(); puInfoIt != puinfoH->end();
374 if (puInfoIt->getBunchCrossing() == 0) {
375 PU_NumInteractions = puInfoIt->getPU_NumInteractions();
380 }
else if (parametersDefiner ==
"CosmicParametersDefinerForTP") {
383 event.getByToken(_simHitTpMapTag, simHitsTPAssoc);
384 cosmicParametersDefinerTP_->initEvent(simHitsTPAssoc);
385 cosmictpSelector.initEvent(simHitsTPAssoc);
393 if (label_tp_refvector) {
394 event.getByToken(tp_refvector_Token, TPCollectionRefVector_H);
395 ptr_TPrefV = TPCollectionRefVector_H.
product();
397 event.getByToken(tp_Token, TPCollection_H);
398 size_t nTP = TPCollection_H->size();
399 for (
size_t i = 0;
i < nTP; ++
i) {
402 ptr_TPrefV = &TPrefV;
407 bool bs_Available =
event.getByToken(bsSrc_Token, recoBeamSpotHandle);
410 bs = *recoBeamSpotHandle;
413 std::vector<const reco::TrackToTrackingParticleAssociator*> associator;
414 if (UseAssociators) {
416 for (
auto const& associatorName : associators) {
417 event.getByLabel(associatorName, theAssociator);
418 associator.push_back(theAssociator.
product());
423 for (
unsigned int ww = 0; ww < associators.size(); ww++) {
424 for (
unsigned int www = 0; www <
label.size(); www++) {
429 unsigned int trackCollectionSize = 0;
435 if (!event.
getByToken(track_Collection_Token[www], trackCollection) && ignoremissingtkcollection_) {
442 trackCollectionSize = trackCollection->size();
444 if (UseAssociators) {
446 <<
"Analyzing " <<
label[www].process() <<
":" <<
label[www].label() <<
":" <<
label[www].instance()
447 <<
" with " << associators[ww].c_str() <<
"\n";
449 LogTrace(
"MuonTrackValidator") <<
"Calling associateRecoToSim method"
451 recSimColl = associator[ww]->associateRecoToSim(trackCollection, TPCollection_H);
452 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method"
454 simRecColl = associator[ww]->associateSimToReco(trackCollection, TPCollection_H);
457 <<
"Analyzing " <<
label[www].process() <<
":" <<
label[www].label() <<
":" <<
label[www].instance()
458 <<
" with " << associatormap.process() <<
":" << associatormap.label() <<
":" << associatormap.instance()
462 event.getByToken(simToRecoCollection_Token, simtorecoCollectionH);
463 simRecColl = *simtorecoCollectionH.
product();
466 event.getByToken(recoToSimCollection_Token, recotosimCollectionH);
467 recSimColl = *recotosimCollectionH.
product();
474 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPC.size() <<
"\n";
478 for (
size_t i = 0;
i < tPC.size();
i++) {
479 bool TP_is_matched =
false;
480 bool isChargeOK =
true;
493 if (parametersDefiner ==
"LhcParametersDefinerForTP") {
494 LogTrace(
"MuonTrackValidator") <<
"TrackingParticle " <<
i;
505 else if (parametersDefiner ==
"CosmicParametersDefinerForTP") {
507 if (!cosmictpSelector(tpr, &
bs, event, setup))
509 momentumTP = cosmicParametersDefinerTP_->momentum(event, setup, tpr);
510 vertexTP = cosmicParametersDefinerTP_->vertex(event, setup, tpr);
517 if (usetracker && usemuon) {
518 nSimHits = tpr.
get()->numberOfHits();
519 }
else if (!usetracker && usemuon) {
520 nSimHits = tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
521 }
else if (usetracker && !usemuon) {
522 nSimHits = tpr.
get()->numberOfTrackerHits();
525 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #" << tpr.
key()
526 <<
" (N counted simhits = " << nSimHits <<
")";
528 <<
"momentumTP: pt = " <<
sqrt(momentumTP.perp2()) <<
", pz = " << momentumTP.z()
529 <<
", \t vertexTP: radius = " <<
sqrt(vertexTP.perp2()) <<
", z = " << vertexTP.z();
532 double TPeta = momentumTP.eta();
533 double xTPeta = getEta(TPeta);
534 double TPpt =
sqrt(momentumTP.perp2());
535 double xTPpt = getPt(TPpt);
536 double TPphi = momentumTP.phi();
537 double TPrpos =
sqrt(vertexTP.perp2());
538 double TPzpos = vertexTP.z();
540 int assoc_recoTrack_NValidHits = 0;
541 if (simRecColl.
find(tpr) != simRecColl.
end()) {
542 auto const&
rt = simRecColl[tpr];
545 TP_is_matched =
true;
547 if (assoc_recoTrack->
charge() != tpr->charge())
549 quality =
rt.begin()->second;
551 edm::LogVerbatim(
"MuonTrackValidator") <<
"-----------------------------associated to Track #"
552 << assoc_recoTrack.
key() <<
" with quality:" << quality <<
"\n";
556 <<
"TrackingParticle #" << tpr.
key() <<
" with pt,eta,phi: " <<
sqrt(momentumTP.perp2()) <<
" , "
557 << momentumTP.eta() <<
" , " << momentumTP.phi() <<
" , "
558 <<
" NOT associated to any reco::Track"
563 fillPlotNoFlow(h_simuleta[
w], xTPeta);
565 fillPlotNoFlow(h_assoceta[w], xTPeta);
567 fillPlotNoFlow(h_misideta[w], xTPeta);
571 fillPlotNoFlow(h_simulphi[w], TPphi);
573 fillPlotNoFlow(h_assocphi[w], TPphi);
575 fillPlotNoFlow(h_misidphi[w], TPphi);
579 fillPlotNoFlow(h_simulpT[w], xTPpt);
581 fillPlotNoFlow(h_assocpT[w], xTPpt);
583 fillPlotNoFlow(h_misidpT[w], xTPpt);
587 fillPlotNoFlow(h_simuldxy[w], dxySim);
589 fillPlotNoFlow(h_assocdxy[w], dxySim);
591 fillPlotNoFlow(h_misiddxy[w], dxySim);
595 fillPlotNoFlow(h_simuldz[w], dzSim);
597 fillPlotNoFlow(h_assocdz[w], dzSim);
599 fillPlotNoFlow(h_misiddz[w], dzSim);
603 fillPlotNoFlow(h_simulRpos[w], TPrpos);
605 fillPlotNoFlow(h_assocRpos[w], TPrpos);
608 fillPlotNoFlow(h_simulZpos[w], TPzpos);
610 fillPlotNoFlow(h_assocZpos[w], TPzpos);
613 fillPlotNoFlow(h_simulhit[w], nSimHits);
615 fillPlotNoFlow(h_assochit[w], nSimHits);
616 nRecHits_vs_nSimHits[
w]->Fill(nSimHits, assoc_recoTrack_NValidHits);
623 fillPlotNoFlow(h_simulpu[w], PU_NumInteractions);
625 fillPlotNoFlow(h_assocpu[w], PU_NumInteractions);
627 fillPlotNoFlow(h_misidpu[w], PU_NumInteractions);
636 <<
"\n# of reco::Tracks with " <<
label[www].process() <<
":" <<
label[www].label() <<
":"
637 <<
label[www].instance() <<
": " << trackCollectionSize <<
"\n";
642 bool Track_is_matched =
false;
643 bool isChargeOK =
true;
648 std::vector<std::pair<TrackingParticleRef, double> >
tp;
652 if (BiDirectional_RecoToSim_association) {
653 edm::LogVerbatim(
"MuonTrackValidator") <<
"----------------------------------------Track #" << track.
key()
654 <<
" (N valid rechits = " << nRecHits <<
")";
656 if (recSimColl.
find(track) != recSimColl.
end()) {
657 tp = recSimColl[
track];
659 tpr = tp.begin()->first;
661 if (simRecColl.
find(tpr) != simRecColl.
end()) {
662 auto const& assoc_track_checkback = simRecColl[tpr].
begin()->first;
664 if (assoc_track_checkback.key() == track.
key()) {
665 Track_is_matched =
true;
667 if (track->
charge() != tpr->charge())
669 double Purity = tp.begin()->second;
672 <<
"with pt=" << track->
pt() <<
" associated with purity:" << Purity <<
" to TrackingParticle #"
673 << tpr.
key() <<
"\n";
675 h_PurityVsQuality[
w]->Fill(Quality, Purity);
681 if (!Track_is_matched)
683 <<
"with pt=" << track->
pt() <<
" NOT associated to any TrackingParticle"
688 if (recSimColl.
find(track) != recSimColl.
end()) {
689 tp = recSimColl[
track];
691 tpr = tp.begin()->first;
692 Track_is_matched =
true;
694 if (track->
charge() != tpr->charge())
696 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.
key() <<
" with pt=" << track->
pt()
697 <<
" associated with quality:" << tp.begin()->second <<
"\n";
700 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.
key() <<
" with pt=" << track->
pt()
701 <<
" NOT associated to any TrackingParticle"
706 double etaRec = track->
eta();
707 double xetaRec = getEta(etaRec);
709 double ptRec = track->
pt();
710 double xptRec = getPt(ptRec);
712 double qoverpRec = track->
qoverp();
713 double phiRec = track->
phi();
714 double thetaRec = track->
theta();
715 double dxyRec = track->
dxy(
bs.position());
716 double dzRec = track->
dz(
bs.position());
719 double ptError = track->
ptError();
721 double phiError = track->
phiError();
722 double dxyError = track->
dxyError();
723 double dzError = track->
dzError();
726 fillPlotNoFlow(h_recoeta[
w], xetaRec);
727 if (Track_is_matched) {
728 fillPlotNoFlow(h_assoc2eta[w], xetaRec);
732 fillPlotNoFlow(h_recophi[w], phiRec);
733 if (Track_is_matched) {
734 fillPlotNoFlow(h_assoc2phi[w], phiRec);
738 fillPlotNoFlow(h_recopT[w], xptRec);
739 if (Track_is_matched) {
740 fillPlotNoFlow(h_assoc2pT[w], xptRec);
744 fillPlotNoFlow(h_recodxy[w], dxyRec);
745 if (Track_is_matched) {
746 fillPlotNoFlow(h_assoc2dxy[w], dxyRec);
750 fillPlotNoFlow(h_recodz[w], dzRec);
751 if (Track_is_matched) {
752 fillPlotNoFlow(h_assoc2dz[w], dzRec);
756 fillPlotNoFlow(h_recohit[w], nRecHits);
757 if (Track_is_matched) {
758 fillPlotNoFlow(h_assoc2hit[w], nRecHits);
761 fillPlotNoFlow(h_misidhit[w], nRecHits);
765 fillPlotNoFlow(h_recopu[w], PU_NumInteractions);
766 if (Track_is_matched) {
767 fillPlotNoFlow(h_assoc2pu[w], PU_NumInteractions);
776 if (parametersDefiner ==
"LhcParametersDefinerForTP") {
778 if (!(Track_is_matched && tpSelector(*tpp)))
781 momentumTP = lhcParametersDefinerTP_->
momentum(event, setup, tpr);
782 vertexTP = lhcParametersDefinerTP_->vertex(event, setup, tpr);
784 }
else if (parametersDefiner ==
"CosmicParametersDefinerForTP") {
786 if (!(Track_is_matched && cosmictpSelector(tpr, &
bs, event, setup)))
789 momentumTP = cosmicParametersDefinerTP_->momentum(event, setup, tpr);
790 vertexTP = cosmicParametersDefinerTP_->vertex(event, setup, tpr);
794 if (associators[ww] ==
"trackAssociatorByChi2") {
796 double assocChi2 = -tp.begin()->second;
797 h_assochi2[www]->Fill(assocChi2);
798 h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5, 5));
799 }
else if (associators[ww] ==
"trackAssociatorByHits") {
800 double fraction = tp.begin()->second;
801 h_assocFraction[www]->Fill(fraction);
802 h_assocSharedHit[www]->Fill(fraction * nRecHits);
805 h_charge[
w]->Fill(track->
charge());
808 h_nhits[
w]->Fill(nRecHits);
809 nhits_vs_eta[
w]->Fill(xetaRec, nRecHits);
810 nhits_vs_phi[
w]->Fill(phiRec, nRecHits);
812 if (do_MUOhitsPlots) {
822 if (do_TRKhitsPlots) {
833 h_nchi2_prob[
w]->Fill(TMath::Prob(track->
chi2(), (int)track->
ndof()));
838 double ptSim =
sqrt(momentumTP.perp2());
839 double xptSim = getPt(ptSim);
840 double qoverpSim = tpr->charge() /
sqrt(momentumTP.x() * momentumTP.x() + momentumTP.y() * momentumTP.y() +
841 momentumTP.z() * momentumTP.z());
842 double etaSim = momentumTP.eta();
843 double thetaSim = momentumTP.theta();
844 double phiSim = momentumTP.phi();
848 double etares = etaRec - etaSim;
849 double ptRelRes = (ptRec - ptSim) / ptSim;
850 double ptPull = (ptRec - ptSim) / ptError;
851 double qoverpPull = (qoverpRec - qoverpSim) / qoverpError;
852 double thetaPull = (thetaRec - thetaSim) / thetaError;
853 double phiDiff = phiRec - phiSim;
856 phiDiff = phiDiff - 2. *
M_PI;
858 phiDiff = phiDiff + 2. *
M_PI;
860 double phiPull = phiDiff / phiError;
861 double dxyPull = (dxyRec - dxySim) / dxyError;
862 double dzPull = (dzRec - dzSim) / dzError;
864 h_etaRes[
w]->Fill(etares);
865 etares_vs_eta[
w]->Fill(xetaRec, etares);
867 ptres_vs_eta[
w]->Fill(xetaRec, ptRelRes);
868 ptres_vs_pt[
w]->Fill(xptSim, ptRelRes);
869 ptres_vs_phi[
w]->Fill(phiRec, ptRelRes);
870 h_ptpull[
w]->Fill(ptPull);
871 ptpull_vs_eta[
w]->Fill(xetaRec, ptPull);
872 ptpull_vs_phi[
w]->Fill(phiRec, ptPull);
873 h_qoverppull[
w]->Fill(qoverpPull);
875 thetaCotres_vs_eta[
w]->Fill(xetaRec,
cos(thetaRec) /
sin(thetaRec) -
cos(thetaSim) /
sin(thetaSim));
876 thetaCotres_vs_pt[
w]->Fill(xptSim,
cos(thetaRec) /
sin(thetaRec) -
cos(thetaSim) /
sin(thetaSim));
877 h_thetapull[
w]->Fill(thetaPull);
878 thetapull_vs_eta[
w]->Fill(xetaRec, thetaPull);
879 thetapull_vs_phi[
w]->Fill(phiRec, thetaPull);
881 phires_vs_eta[
w]->Fill(xetaRec, phiDiff);
882 phires_vs_pt[
w]->Fill(xptSim, phiDiff);
883 phires_vs_phi[
w]->Fill(phiRec, phiDiff);
884 h_phipull[
w]->Fill(phiPull);
885 phipull_vs_eta[
w]->Fill(xetaRec, phiPull);
886 phipull_vs_phi[
w]->Fill(phiRec, phiPull);
888 dxyres_vs_eta[
w]->Fill(xetaRec, dxyRec - dxySim);
889 dxyres_vs_pt[
w]->Fill(xptSim, dxyRec - dxySim);
890 h_dxypull[
w]->Fill(dxyPull);
891 dxypull_vs_eta[
w]->Fill(xetaRec, dxyPull);
893 dzres_vs_eta[
w]->Fill(xetaRec, dzRec - dzSim);
894 dzres_vs_pt[
w]->Fill(xptSim, dzRec - dzSim);
895 h_dzpull[
w]->Fill(dzPull);
896 dzpull_vs_eta[
w]->Fill(xetaRec, dzPull);
898 double contrib_Qoverp = qoverpPull * qoverpPull / 5;
899 double contrib_dxy = dxyPull * dxyPull / 5;
900 double contrib_dz = dzPull * dzPull / 5;
901 double contrib_theta = thetaPull * thetaPull / 5;
902 double contrib_phi = phiPull * phiPull / 5;
903 double assoChi2 = contrib_Qoverp + contrib_dxy + contrib_dz + contrib_theta + contrib_phi;
905 LogTrace(
"MuonTrackValidator") <<
"normalized Chi2 (track 5-dofs matching) = " << assoChi2 <<
"\n"
906 <<
"\t contrib_Qoverp = " << contrib_Qoverp <<
"\n"
907 <<
"\t contrib_theta = " << contrib_theta <<
"\n"
908 <<
"\t contrib_phi = " << contrib_phi <<
"\n"
909 <<
"\t contrib_dxy = " << contrib_dxy <<
"\n"
910 <<
"\t contrib_dz = " << contrib_dz <<
"\n";
912 LogTrace(
"MuonTrackValidator") <<
"ptRec = " << ptRec <<
"\n"
913 <<
"etaRec = " << etaRec <<
"\n"
914 <<
"qoverpRec = " << qoverpRec <<
"\n"
915 <<
"thetaRec = " << thetaRec <<
"\n"
916 <<
"phiRec = " << phiRec <<
"\n"
917 <<
"dxyRec = " << dxyRec <<
"\n"
918 <<
"dzRec = " << dzRec <<
"\n"
921 <<
"qoverpError = " << qoverpError <<
"\n"
922 <<
"thetaError = " << thetaError <<
"\n"
923 <<
"phiError = " << phiError <<
"\n"
924 <<
"dxyError = " << dxyError <<
"\n"
925 <<
"dzError = " << dzError <<
"\n"
928 <<
"ptSim = " << ptSim <<
"\n"
929 <<
"etaSim = " << etaSim <<
"\n"
930 <<
"qoverpSim = " << qoverpSim <<
"\n"
931 <<
"thetaSim = " << thetaSim <<
"\n"
932 <<
"phiSim = " << phiSim <<
"\n"
933 <<
"dxySim = " << dxySim <<
"\n"
934 <<
"dzSim = " << dzSim <<
"\n";
937 h_tracks[
w]->Fill(at);
938 h_fakes[
w]->Fill(rT - at);
940 <<
"Total Associated (simToReco): " << ats <<
"\n"
941 <<
"Total Reconstructed: " << rT <<
"\n"
942 <<
"Total Associated (recoToSim): " << at <<
"\n"
943 <<
"Total Fakes: " << rT - at <<
"\n";
double qoverp() const
q / p
Log< level::Info, true > LogVerbatim
virtual void setCurrentFolder(std::string const &fullpath)
Vector momentum() const
spatial momentum vector
const_iterator end() const
last iterator over the map (read only)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double theta() const
polar angle
double dxyError() const
error on dxy
uint32_t const *__restrict__ Quality * quality
Sin< T >::type sin(const T &t)
const_iterator find(const key_type &k) const
find element with specified reference key
double phi() const
azimuthal angle of momentum vector
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
key_type key() const
Accessor for product key.
int pixelLayersWithMeasurement() const
int trackerLayersWithMeasurement() const
int numberOfValidMuonCSCHits() const
int numberOfValidMuonRPCHits() const
math::XYZPointD Point
point in the space
double eta() const
pseudorapidity of momentum vector
double chi2() const
chi-squared of the fit
auto dz(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
void post_insert()
post insert action
double ndof() const
number of degrees of freedom of the fit
double pt() const
track transverse momentum
Cos< T >::type cos(const T &t)
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
double phiError() const
error on phi
Abs< T >::type abs(const T &t)
unsigned short numberOfValidHits() const
number of valid hits found
T const * get() const
Returns C++ pointer to the item.
double qoverpError() const
error on signed transverse curvature
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double dzError() const
error on dz
Log< level::Info, false > LogInfo
T const * product() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
int numberOfLostHits(HitCategory category) const
Point vertex() const
Parent vertex position.
void bookHistograms(DQMEDAnalyzer::DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int numberOfValidMuonGEMHits() const
auto dxy(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
int numberOfValidMuonME0Hits() const
int numberOfValidMuonDTHits() const
void analyze(const edm::Event &, const edm::EventSetup &) override
Monte Carlo truth information used for tracking validation.
int charge() const
track electric charge
const_iterator begin() const
first iterator over the map (read only)
math::XYZVectorD Vector
point in the space
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
edm::Ref< TrackingParticleCollection > TrackingParticleRef
double thetaError() const
error on theta