18 : includeZeroHitMuons(conf.getParameter<bool>(
"includeZeroHitMuons")),
19 acceptOneStubMatchings(conf.getParameter<bool>(
"acceptOneStubMatchings")),
20 rejectBadGlobal(conf.getParameter<bool>(
"rejectBadGlobal")),
21 UseTracker(conf.getParameter<bool>(
"UseTracker")),
22 UseMuon(conf.getParameter<bool>(
"UseMuon")),
23 AbsoluteNumberOfHits_track(conf.getParameter<bool>(
"AbsoluteNumberOfHits_track")),
24 NHitCut_track(conf.getParameter<unsigned int>(
"NHitCut_track")),
25 EfficiencyCut_track(conf.getParameter<double>(
"EfficiencyCut_track")),
26 PurityCut_track(conf.getParameter<double>(
"PurityCut_track")),
27 AbsoluteNumberOfHits_muon(conf.getParameter<bool>(
"AbsoluteNumberOfHits_muon")),
28 NHitCut_muon(conf.getParameter<unsigned int>(
"NHitCut_muon")),
29 EfficiencyCut_muon(conf.getParameter<double>(
"EfficiencyCut_muon")),
30 PurityCut_muon(conf.getParameter<double>(
"PurityCut_muon")),
31 UsePixels(conf.getParameter<bool>(
"UsePixels")),
32 UseGrouped(conf.getParameter<bool>(
"UseGrouped")),
33 UseSplitting(conf.getParameter<bool>(
"UseSplitting")),
34 ThreeHitTracksAreSpecial(conf.getParameter<bool>(
"ThreeHitTracksAreSpecial")),
35 dumpDT(conf.getParameter<bool>(
"dumpDT")) {
36 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n constructing MuonAssociatorByHitsHelper" << conf.
dump();
40 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n UseTracker = TRUE : Tracker SimHits and RecHits WILL be "
43 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n UseTracker = FALSE : Tracker SimHits and RecHits WILL NOT be "
48 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
" UseMuon = TRUE : Muon SimHits and RecHits WILL be counted";
51 <<
" UseMuon = FALSE : Muon SimHits and RecHits WILL NOT be counted" << endl;
56 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n includeZeroHitMuons = TRUE"
57 <<
"\n ==> (re)set NHitCut_muon = 0, PurityCut_muon = 0, "
58 "EfficiencyCut_muon = 0"
70 auto tTopo = resources.
tTopo_;
77 int tracker_nshared = 0;
79 int global_nshared = 0;
81 double tracker_quality = 0;
82 double tracker_quality_cut;
88 double muon_quality = 0;
89 double muon_quality_cut;
95 double global_quality = 0;
103 tPC.reserve(TPCollectionH.
size());
104 for (
auto const &ref : TPCollectionH) {
113 for (TrackHitsCollection::const_iterator
track = tC.begin();
track != tC.end();
track++, tindex++) {
116 <<
"reco::Track " << tindex <<
", number of RecHits = " << (
track->second -
track->first) <<
"\n";
117 tracker_matchedIds_valid.clear();
118 muon_matchedIds_valid.clear();
120 tracker_matchedIds_INVALID.clear();
121 muon_matchedIds_INVALID.clear();
123 bool this_track_matched =
false;
124 int n_matching_simhits = 0;
128 int n_tracker_all = 0;
135 int n_tracker_valid = 0;
136 int n_muon_valid = 0;
142 int n_tracker_matched_valid = 0;
143 int n_muon_matched_valid = 0;
144 int n_dt_matched_valid = 0;
145 int n_csc_matched_valid = 0;
146 int n_rpc_matched_valid = 0;
147 int n_gem_matched_valid = 0;
150 int n_tracker_INVALID = 0;
151 int n_muon_INVALID = 0;
152 int n_dt_INVALID = 0;
153 int n_csc_INVALID = 0;
154 int n_rpc_INVALID = 0;
155 int n_gem_INVALID = 0;
157 int n_tracker_matched_INVALID = 0;
158 int n_muon_matched_INVALID = 0;
159 int n_dt_matched_INVALID = 0;
160 int n_csc_matched_INVALID = 0;
161 int n_rpc_matched_INVALID = 0;
162 int n_gem_matched_INVALID = 0;
164 bool printRtS =
true;
166 muon_matchedIds_valid,
167 tracker_matchedIds_INVALID,
168 muon_matchedIds_INVALID,
174 n_tracker_matched_valid,
184 n_tracker_matched_INVALID,
185 n_dt_matched_INVALID,
186 n_csc_matched_INVALID,
187 n_rpc_matched_INVALID,
188 n_gem_matched_INVALID,
199 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
200 tracker_matchedIds_INVALID.size() + muon_matchedIds_INVALID.size();
202 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid + n_gem_valid;
203 n_valid = n_tracker_valid + n_muon_valid;
204 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID + n_gem_INVALID;
205 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
208 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
209 n_dt_all = n_dt_valid + n_dt_INVALID;
210 n_csc_all = n_csc_valid + n_csc_INVALID;
211 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
212 n_gem_all = n_gem_valid + n_gem_INVALID;
213 n_all = n_valid + n_INVALID;
215 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid + n_gem_matched_valid;
216 n_muon_matched_INVALID =
217 n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID + n_gem_matched_INVALID;
220 int n_tracker_selected_hits = n_tracker_valid;
221 int n_muon_selected_hits = n_muon_valid;
222 int n_dt_selected_hits = n_dt_valid;
223 int n_csc_selected_hits = n_csc_valid;
224 int n_rpc_selected_hits = n_rpc_valid;
225 int n_gem_selected_hits = n_gem_valid;
228 int n_tracker_matched = n_tracker_matched_valid;
229 int n_muon_matched = n_muon_matched_valid;
230 int n_dt_matched = n_dt_matched_valid;
231 int n_csc_matched = n_csc_matched_valid;
232 int n_rpc_matched = n_rpc_matched_valid;
233 int n_gem_matched = n_gem_matched_valid;
241 InvMuonHits =
" ***INVALID MUON HITS***";
242 ZeroHitMuon =
" ***ZERO-HIT MUON***";
244 n_muon_selected_hits = n_muon_INVALID;
245 n_dt_selected_hits = n_dt_INVALID;
246 n_csc_selected_hits = n_csc_INVALID;
247 n_rpc_selected_hits = n_rpc_INVALID;
248 n_gem_selected_hits = n_gem_INVALID;
250 n_muon_matched = n_muon_matched_INVALID;
251 n_dt_matched = n_dt_matched_INVALID;
252 n_csc_matched = n_csc_matched_INVALID;
253 n_rpc_matched = n_rpc_matched_INVALID;
254 n_gem_matched = n_gem_matched_INVALID;
257 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
258 int n_matched = n_tracker_matched + n_muon_matched;
262 <<
"# TrackingRecHits: " << (
track->second -
track->first) <<
"\n"
263 <<
"# used RecHits = " << n_all <<
" (" << n_tracker_all <<
"/" << n_dt_all <<
"/" << n_csc_all <<
"/"
264 << n_rpc_all <<
"/" << n_gem_all <<
" in Tracker/DT/CSC/RPC/GEM)"
265 <<
", obtained from " << n_matching_simhits <<
" SimHits"
267 <<
"# selected RecHits = " << n_selected_hits <<
" (" << n_tracker_selected_hits <<
"/" << n_dt_selected_hits
268 <<
"/" << n_csc_selected_hits <<
"/" << n_rpc_selected_hits <<
"/" << n_gem_selected_hits
269 <<
" in Tracker/DT/CSC/RPC/GEM)" << InvMuonHits <<
"\n"
270 <<
"# matched RecHits = " << n_matched <<
" (" << n_tracker_matched <<
"/" << n_dt_matched <<
"/"
271 << n_csc_matched <<
"/" << n_rpc_matched <<
"/" << n_gem_matched <<
" in Tracker/DT/CSC/RPC/GEM)";
273 if (n_all > 0 && n_matching_simhits == 0)
275 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateRecoToSim: "
276 "no matching PSimHit found for this reco::Track !";
278 if (n_matching_simhits != 0) {
281 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
282 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
284 <<
"reco::Track " << tindex << ZeroHitMuon <<
"\n\t"
285 <<
"made of " << n_selected_hits <<
" selected RecHits (tracker:" << n_tracker_selected_hits
286 <<
"/muons:" << n_muon_selected_hits <<
")";
289 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
290 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
291 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
294 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
296 global_nshared = tracker_nshared + muon_nshared;
299 tracker_quality =
static_cast<double>(tracker_nshared);
300 else if (n_tracker_selected_hits != 0)
301 tracker_quality = (
static_cast<double>(tracker_nshared) / static_cast<double>(n_tracker_selected_hits));
306 muon_quality =
static_cast<double>(muon_nshared);
307 else if (n_muon_selected_hits != 0)
308 muon_quality = (
static_cast<double>(muon_nshared) / static_cast<double>(n_muon_selected_hits));
313 if (n_selected_hits != 0) {
315 global_quality = global_nshared;
317 global_quality = (
static_cast<double>(global_nshared) / static_cast<double>(n_selected_hits));
321 bool trackerOk =
false;
322 if (n_tracker_selected_hits != 0) {
323 if (tracker_quality > tracker_quality_cut)
332 if (n_muon_selected_hits != 0) {
333 if (muon_quality > muon_quality_cut)
339 bool matchOk = trackerOk || muonOk;
345 ((n_tracker_selected_hits != 0 && n_muon_selected_hits != 0) ||
rejectBadGlobal))
346 matchOk = trackerOk && muonOk;
349 outputCollection[tindex].push_back(
IndexMatch(tpindex, global_quality));
350 this_track_matched =
true;
354 <<
" **MATCHED** with quality = " << global_quality <<
" (tracker: " << tracker_quality
355 <<
" / muon: " << muon_quality <<
")"
357 <<
" N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
358 <<
" / muon: " << muon_nshared <<
")"
360 <<
" to TrackingParticle: q = " << (*trpart).charge() <<
", p = " << (*trpart).p()
361 <<
", pT = " << (*trpart).pt() <<
", eta = " << (*trpart).eta() <<
", phi = " << (*trpart).phi() <<
"\n\t"
362 <<
" pdg code = " << (*trpart).pdgId() <<
", made of " << (*trpart).numberOfHits() <<
" PSimHits"
363 <<
" from " << (*trpart).g4Tracks().size() <<
" SimTrack:";
367 <<
" Id:" << (*g4T).trackId() <<
"/Evt:(" << (*g4T).eventId().event() <<
","
368 << (*g4T).eventId().bunchCrossing() <<
")";
373 if (global_nshared != 0)
374 LogTrace(
"MuonAssociatorByHitsHelper")
376 <<
" NOT matched to TrackingParticle, with quality = " << global_quality
377 <<
" (tracker: " << tracker_quality <<
" / muon: " << muon_quality <<
")"
379 <<
" N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
380 <<
" / muon: " << muon_nshared <<
")";
385 if (!this_track_matched) {
387 <<
" NOT matched to any TrackingParticle";
391 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
392 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
400 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"0 reconstructed tracks (-->> 0 associated !)";
402 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
403 std::sort(it->second.begin(), it->second.end());
405 return outputCollection;
412 auto tTopo = resources.
tTopo_;
419 int tracker_nshared = 0;
420 int muon_nshared = 0;
421 int global_nshared = 0;
423 double tracker_quality = 0;
424 double tracker_quality_cut;
430 double muon_quality = 0;
431 double muon_quality_cut;
437 double global_quality = 0;
439 double tracker_purity = 0;
440 double muon_purity = 0;
441 double global_purity = 0;
448 bool printRtS =
false;
451 tPC.reserve(TPCollectionH.
size());
452 for (
auto const &ref : TPCollectionH) {
456 bool any_trackingParticle_matched =
false;
459 for (TrackHitsCollection::const_iterator
track = tC.begin();
track != tC.end();
track++, tindex++) {
463 <<
"reco::Track " << tindex <<
", number of RecHits = " << (
track->second -
track->first) <<
"\n";
465 tracker_matchedIds_valid.clear();
466 muon_matchedIds_valid.clear();
468 tracker_matchedIds_INVALID.clear();
469 muon_matchedIds_INVALID.clear();
471 int n_matching_simhits = 0;
475 int n_tracker_all = 0;
482 int n_tracker_valid = 0;
483 int n_muon_valid = 0;
489 int n_tracker_matched_valid = 0;
490 int n_muon_matched_valid = 0;
491 int n_dt_matched_valid = 0;
492 int n_csc_matched_valid = 0;
493 int n_rpc_matched_valid = 0;
494 int n_gem_matched_valid = 0;
497 int n_tracker_INVALID = 0;
498 int n_muon_INVALID = 0;
499 int n_dt_INVALID = 0;
500 int n_csc_INVALID = 0;
501 int n_rpc_INVALID = 0;
502 int n_gem_INVALID = 0;
504 int n_tracker_matched_INVALID = 0;
505 int n_muon_matched_INVALID = 0;
506 int n_dt_matched_INVALID = 0;
507 int n_csc_matched_INVALID = 0;
508 int n_rpc_matched_INVALID = 0;
509 int n_gem_matched_INVALID = 0;
512 muon_matchedIds_valid,
513 tracker_matchedIds_INVALID,
514 muon_matchedIds_INVALID,
520 n_tracker_matched_valid,
530 n_tracker_matched_INVALID,
531 n_dt_matched_INVALID,
532 n_csc_matched_INVALID,
533 n_rpc_matched_INVALID,
534 n_gem_matched_INVALID,
545 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
546 tracker_matchedIds_INVALID.size() + muon_matchedIds_INVALID.size();
548 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid + n_gem_valid;
549 n_valid = n_tracker_valid + n_muon_valid;
550 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID + n_gem_INVALID;
551 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
554 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
555 n_dt_all = n_dt_valid + n_dt_INVALID;
556 n_csc_all = n_csc_valid + n_csc_INVALID;
557 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
558 n_gem_all = n_gem_valid + n_gem_INVALID;
559 n_all = n_valid + n_INVALID;
561 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid + n_gem_matched_valid;
562 n_muon_matched_INVALID =
563 n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID + n_gem_matched_INVALID;
566 int n_tracker_selected_hits = n_tracker_valid;
567 int n_muon_selected_hits = n_muon_valid;
568 int n_dt_selected_hits = n_dt_valid;
569 int n_csc_selected_hits = n_csc_valid;
570 int n_rpc_selected_hits = n_rpc_valid;
571 int n_gem_selected_hits = n_gem_valid;
574 int n_tracker_matched = n_tracker_matched_valid;
575 int n_muon_matched = n_muon_matched_valid;
576 int n_dt_matched = n_dt_matched_valid;
577 int n_csc_matched = n_csc_matched_valid;
578 int n_rpc_matched = n_rpc_matched_valid;
579 int n_gem_matched = n_gem_matched_valid;
587 InvMuonHits =
" ***INVALID MUON HITS***";
588 ZeroHitMuon =
" ***ZERO-HIT MUON***";
590 n_muon_selected_hits = n_muon_INVALID;
591 n_dt_selected_hits = n_dt_INVALID;
592 n_csc_selected_hits = n_csc_INVALID;
593 n_rpc_selected_hits = n_rpc_INVALID;
594 n_gem_selected_hits = n_gem_INVALID;
596 n_muon_matched = n_muon_matched_INVALID;
597 n_dt_matched = n_dt_matched_INVALID;
598 n_csc_matched = n_csc_matched_INVALID;
599 n_rpc_matched = n_rpc_matched_INVALID;
600 n_gem_matched = n_gem_matched_INVALID;
603 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
604 int n_matched = n_tracker_matched + n_muon_matched;
609 <<
"# TrackingRecHits: " << (
track->second -
track->first) <<
"\n"
610 <<
"# used RecHits = " << n_all <<
" (" << n_tracker_all <<
"/" << n_dt_all <<
"/" << n_csc_all <<
"/"
611 << n_rpc_all <<
"/" << n_gem_all <<
" in Tracker/DT/CSC/RPC/GEM)"
612 <<
", obtained from " << n_matching_simhits <<
" SimHits"
614 <<
"# selected RecHits = " << n_selected_hits <<
" (" << n_tracker_selected_hits <<
"/" << n_dt_selected_hits
615 <<
"/" << n_csc_selected_hits <<
"/" << n_rpc_selected_hits <<
"/" << n_gem_selected_hits
616 <<
" in Tracker/DT/CSC/RPC/GEM)" << InvMuonHits <<
"\n"
617 <<
"# matched RecHits = " << n_matched <<
" (" << n_tracker_matched <<
"/" << n_dt_matched <<
"/"
618 << n_csc_matched <<
"/" << n_rpc_matched <<
"/" << n_gem_matched <<
" in Tracker/DT/CSC/RPC/GEM)";
620 if (printRtS && n_all > 0 && n_matching_simhits == 0)
622 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateSimToReco: "
623 "no matching PSimHit found for this reco::Track !";
625 if (n_matching_simhits != 0) {
627 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
629 int n_tracker_recounted_simhits = 0;
630 int n_muon_simhits = 0;
631 int n_global_simhits = 0;
633 int n_tracker_selected_simhits = 0;
634 int n_muon_selected_simhits = 0;
635 int n_global_selected_simhits = 0;
638 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
639 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
642 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
644 global_nshared = tracker_nshared + muon_nshared;
645 if (global_nshared == 0)
652 n_tracker_recounted_simhits = trpart->numberOfTrackerHits();
654 n_muon_simhits = trpart->numberOfHits() - trpart->numberOfTrackerHits();
658 if (trpart->numberOfHits() == 0) {
668 n_tracker_recounted_simhits = 1;
671 n_global_simhits = n_tracker_recounted_simhits + n_muon_simhits;
674 n_muon_selected_simhits = n_muon_simhits;
675 n_global_selected_simhits = n_muon_selected_simhits;
678 n_tracker_selected_simhits = n_tracker_recounted_simhits;
679 n_global_selected_simhits += n_tracker_selected_simhits;
683 tracker_quality =
static_cast<double>(tracker_nshared);
684 else if (n_tracker_selected_simhits != 0)
685 tracker_quality =
static_cast<double>(tracker_nshared) / static_cast<double>(n_tracker_selected_simhits);
690 muon_quality =
static_cast<double>(muon_nshared);
691 else if (n_muon_selected_simhits != 0)
692 muon_quality =
static_cast<double>(muon_nshared) / static_cast<double>(n_muon_selected_simhits);
697 if (n_global_selected_simhits != 0) {
699 global_quality = global_nshared;
701 global_quality =
static_cast<double>(global_nshared) / static_cast<double>(n_global_selected_simhits);
706 if (n_selected_hits != 0) {
708 global_purity = global_nshared;
710 global_purity =
static_cast<double>(global_nshared) / static_cast<double>(n_selected_hits);
714 bool trackerOk =
false;
715 if (n_tracker_selected_hits != 0) {
716 if (tracker_quality > tracker_quality_cut)
719 tracker_purity =
static_cast<double>(tracker_nshared) / static_cast<double>(n_tracker_selected_hits);
721 tracker_purity =
static_cast<double>(tracker_nshared);
733 if (n_muon_selected_hits != 0) {
734 if (muon_quality > muon_quality_cut)
737 muon_purity =
static_cast<double>(muon_nshared) / static_cast<double>(n_muon_selected_hits);
739 muon_purity =
static_cast<double>(muon_nshared);
747 bool matchOk = trackerOk || muonOk;
753 ((n_tracker_selected_hits != 0 && n_muon_selected_hits != 0) ||
rejectBadGlobal))
754 matchOk = trackerOk && muonOk;
757 outputCollection[tpindex].push_back(
IndexMatch(tindex, global_quality));
758 any_trackingParticle_matched =
true;
761 <<
"*************************************************************"
762 "***********************************************************"
764 <<
"TrackingParticle: q = " << (*trpart).charge() <<
", p = " << (*trpart).p()
765 <<
", pT = " << (*trpart).pt() <<
", eta = " << (*trpart).eta() <<
", phi = " << (*trpart).phi() <<
"\n"
766 <<
" pdg code = " << (*trpart).pdgId() <<
", made of " << (*trpart).numberOfHits()
767 <<
" PSimHits, recounted " << n_global_simhits <<
" PSimHits"
768 <<
" (tracker:" << n_tracker_recounted_simhits <<
"/muons:" << n_muon_simhits <<
")"
769 <<
", from " << (*trpart).g4Tracks().size() <<
" SimTrack:";
772 <<
" Id:" << (*g4T).trackId() <<
"/Evt:(" << (*g4T).eventId().event() <<
","
773 << (*g4T).eventId().bunchCrossing() <<
")";
776 <<
"\t selected " << n_global_selected_simhits <<
" PSimHits"
777 <<
" (tracker:" << n_tracker_selected_simhits <<
"/muons:" << n_muon_selected_simhits <<
")"
778 <<
"\n\t **MATCHED** with quality = " << global_quality <<
" (tracker: " << tracker_quality
779 <<
" / muon: " << muon_quality <<
")"
780 <<
"\n\t and purity = " << global_purity <<
" (tracker: " << tracker_purity
781 <<
" / muon: " << muon_purity <<
")"
782 <<
"\n\t N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
783 <<
" / muon: " << muon_nshared <<
")"
785 <<
" to: reco::Track " << tindex << ZeroHitMuon <<
"\n\t"
786 <<
" made of " << n_selected_hits <<
" RecHits (tracker:" << n_tracker_valid
787 <<
"/muons:" << n_muon_selected_hits <<
")";
791 if (global_nshared != 0) {
794 <<
"*********************************************************"
795 "*********************************************************"
798 <<
"TrackingParticle: q = " << (*trpart).charge() <<
", p = " << (*trpart).p()
799 <<
", pT = " << (*trpart).pt() <<
", eta = " << (*trpart).eta() <<
", phi = " << (*trpart).phi()
801 <<
" pdg code = " << (*trpart).pdgId() <<
", made of " << (*trpart).numberOfHits()
802 <<
" PSimHits, recounted " << n_global_simhits <<
" PSimHits"
803 <<
" (tracker:" << n_tracker_recounted_simhits <<
"/muons:" << n_muon_simhits <<
")"
804 <<
", from " << (*trpart).g4Tracks().size() <<
" SimTrack:";
809 <<
" Id:" << (*g4T).trackId() <<
"/Evt:(" << (*g4T).eventId().event() <<
","
810 << (*g4T).eventId().bunchCrossing() <<
")";
814 <<
"\t selected " << n_global_selected_simhits <<
" PSimHits"
815 <<
" (tracker:" << n_tracker_selected_simhits <<
"/muons:" << n_muon_selected_simhits <<
")"
816 <<
"\n\t NOT matched to reco::Track " << tindex << ZeroHitMuon
817 <<
" with quality = " << global_quality <<
" (tracker: " << tracker_quality
818 <<
" / muon: " << muon_quality <<
")"
819 <<
"\n\t and purity = " << global_purity <<
" (tracker: " << tracker_purity
820 <<
" / muon: " << muon_purity <<
")"
821 <<
"\n\t N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
822 <<
" / muon: " << muon_nshared <<
")";
829 if (!any_trackingParticle_matched) {
832 <<
"*******************************************************************"
833 "*****************************************************"
834 <<
"\n NO TrackingParticle associated to ANY input reco::Track ! \n"
835 <<
"*******************************************************************"
836 "*****************************************************"
840 <<
"*******************************************************************"
841 "*****************************************************"
845 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
846 std::sort(it->second.begin(), it->second.end());
848 return outputCollection;
855 int &n_tracker_valid,
860 int &n_tracker_matched_valid,
861 int &n_dt_matched_valid,
862 int &n_csc_matched_valid,
863 int &n_rpc_matched_valid,
864 int &n_gem_matched_valid,
865 int &n_tracker_INVALID,
870 int &n_tracker_matched_INVALID,
871 int &n_dt_matched_INVALID,
872 int &n_csc_matched_INVALID,
873 int &n_rpc_matched_INVALID,
874 int &n_gem_matched_INVALID,
886 tracker_matchedIds_valid.clear();
887 muon_matchedIds_valid.clear();
889 tracker_matchedIds_INVALID.clear();
890 muon_matchedIds_INVALID.clear();
898 n_tracker_matched_valid = 0;
899 n_dt_matched_valid = 0;
900 n_csc_matched_valid = 0;
901 n_rpc_matched_valid = 0;
902 n_gem_matched_valid = 0;
904 n_tracker_INVALID = 0;
910 n_tracker_matched_INVALID = 0;
911 n_dt_matched_INVALID = 0;
912 n_csc_matched_INVALID = 0;
913 n_rpc_matched_INVALID = 0;
914 n_gem_matched_INVALID = 0;
916 std::vector<SimHitIdpr> SimTrackIds;
922 stringstream hit_index;
928 unsigned int detid = geoid.
rawId();
929 stringstream detector_id;
930 detector_id << detid;
932 string hitlog =
"TrackingRecHit " + hit_index.str();
934 std::vector<string> DTSimHits;
939 bool valid_Hit = hitp->
isValid();
943 stringstream detector_id;
944 detector_id << tTopo->
print(detid);
947 hitlog = hitlog +
" -Tracker - detID = " + detector_id.str();
949 hitlog = hitlog +
" *** INVALID ***" +
" -Tracker - detID = " + detector_id.str();
957 if (!SimTrackIds.empty()) {
958 n_tracker_matched_valid++;
960 tracker_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
965 if (!SimTrackIds.empty()) {
966 n_tracker_matched_INVALID++;
968 tracker_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
977 stringstream dt_detector_id;
978 dt_detector_id << dtdetid;
980 hitlog = hitlog +
" -Muon DT - detID = " + dt_detector_id.str();
982 hitlog = hitlog +
" *** INVALID ***" +
" -Muon DT - detID = " + dt_detector_id.str();
994 if (!SimTrackIds.empty()) {
995 n_dt_matched_valid++;
997 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1002 if (!SimTrackIds.empty()) {
1003 n_dt_matched_INVALID++;
1005 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1013 std::vector<PSimHit> dtSimHits = dttruth.
associateHit(*hitp);
1015 stringstream ndthits;
1016 ndthits << dtSimHits.size();
1017 wireidlog =
"\t DTWireId :" + wid.str() +
", " + ndthits.str() +
" associated PSimHit :";
1019 for (
unsigned int j = 0;
j < dtSimHits.size();
j++) {
1022 stringstream simhit;
1023 simhit << dtSimHits[
j];
1024 string simhitlog =
"\t\t PSimHit " + index.str() +
": " + simhit.str();
1025 DTSimHits.push_back(simhitlog);
1035 std::vector<const TrackingRecHit *> componentHits, phiHits, zHits;
1036 if (dtsegment->
hasPhi()) {
1038 componentHits.insert(componentHits.end(), phiHits.begin(), phiHits.end());
1040 if (dtsegment->
hasZed()) {
1042 componentHits.insert(componentHits.end(), zHits.begin(), zHits.end());
1046 <<
"\n\t this TrackingRecHit is a DTRecSegment4D with " << componentHits.size()
1047 <<
" hits (phi:" << phiHits.size() <<
", z:" << zHits.size() <<
")";
1049 SimTrackIds.clear();
1050 std::vector<SimHitIdpr> i_SimTrackIds;
1052 for (std::vector<const TrackingRecHit *>::const_iterator ithit = componentHits.begin();
1053 ithit != componentHits.end();
1059 i_SimTrackIds.clear();
1069 if (!i_SimTrackIds.empty()) {
1070 n_dt_matched_valid++;
1072 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, i_SimTrackIds));
1077 if (!i_SimTrackIds.empty()) {
1078 n_dt_matched_INVALID++;
1080 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, i_SimTrackIds));
1083 }
else if (printRtS)
1085 "MuonAssociatorByHitsHelper::getMatchedIds, null "
1086 "dynamic_cast of a DT TrackingRecHit !";
1088 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1091 stringstream i_dt_detector_id;
1092 i_dt_detector_id << i_dtdetid;
1095 i_ss <<
"\t\t hit " << i_compHit <<
" -Muon DT - detID = " << i_dt_detector_id.str();
1097 string i_hitlog = i_ss.str();
1102 SimTrackIds.insert(SimTrackIds.end(), i_SimTrackIds.begin(), i_SimTrackIds.end());
1108 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, "
1109 "DT TrackingRecHit is neither DTRecHit1D nor DTRecSegment4D "
1117 stringstream csc_detector_id;
1118 csc_detector_id << cscdetid;
1120 hitlog = hitlog +
" -Muon CSC- detID = " + csc_detector_id.str();
1122 hitlog = hitlog +
" *** INVALID ***" +
" -Muon CSC- detID = " + csc_detector_id.str();
1134 if (!SimTrackIds.empty()) {
1135 n_csc_matched_valid++;
1137 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1142 if (!SimTrackIds.empty()) {
1143 n_csc_matched_INVALID++;
1145 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1155 std::vector<const TrackingRecHit *> componentHits = cscsegment->
recHits();
1158 <<
"\n\t this TrackingRecHit is a CSCSegment with " << componentHits.size() <<
" hits";
1160 SimTrackIds.clear();
1161 std::vector<SimHitIdpr> i_SimTrackIds;
1163 for (std::vector<const TrackingRecHit *>::const_iterator ithit = componentHits.begin();
1164 ithit != componentHits.end();
1170 i_SimTrackIds.clear();
1180 if (!i_SimTrackIds.empty()) {
1181 n_csc_matched_valid++;
1183 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, i_SimTrackIds));
1188 if (!i_SimTrackIds.empty()) {
1189 n_csc_matched_INVALID++;
1191 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, i_SimTrackIds));
1194 }
else if (printRtS)
1196 "MuonAssociatorByHitsHelper::getMatchedIds, null "
1197 "dynamic_cast of a CSC TrackingRecHit !";
1199 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1202 stringstream i_csc_detector_id;
1203 i_csc_detector_id << i_cscdetid;
1206 i_ss <<
"\t\t hit " << i_compHit <<
" -Muon CSC- detID = " << i_csc_detector_id.str();
1208 string i_hitlog = i_ss.str();
1213 SimTrackIds.insert(SimTrackIds.end(), i_SimTrackIds.begin(), i_SimTrackIds.end());
1219 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, "
1220 "CSC TrackingRecHit is neither CSCRecHit2D nor CSCSegment "
1228 stringstream rpc_detector_id;
1229 rpc_detector_id << rpcdetid;
1231 hitlog = hitlog +
" -Muon RPC- detID = " + rpc_detector_id.str();
1233 hitlog = hitlog +
" *** INVALID ***" +
" -Muon RPC- detID = " + rpc_detector_id.str();
1241 if (!SimTrackIds.empty()) {
1242 n_rpc_matched_valid++;
1244 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1249 if (!SimTrackIds.empty()) {
1250 n_rpc_matched_INVALID++;
1252 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1260 stringstream gem_detector_id;
1261 gem_detector_id << gemdetid;
1263 hitlog = hitlog +
" -Muon GEM- detID = " + gem_detector_id.str();
1265 hitlog = hitlog +
" *** INVALID ***" +
" -Muon GEM- detID = " + gem_detector_id.str();
1275 if (!SimTrackIds.empty()) {
1276 n_gem_matched_valid++;
1278 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1283 if (!SimTrackIds.empty()) {
1284 n_gem_matched_INVALID++;
1286 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, SimTrackIds));
1292 std::vector<const TrackingRecHit *> componentHits = gemsegment->
recHits();
1295 <<
"\n\t this TrackingRecHit is a GEMSegment with " << componentHits.size() <<
" hits";
1297 SimTrackIds.clear();
1298 std::vector<SimHitIdpr> i_SimTrackIds;
1301 for (
auto const &ithit : componentHits) {
1306 i_SimTrackIds.clear();
1316 if (!i_SimTrackIds.empty()) {
1317 n_gem_matched_valid++;
1319 muon_matchedIds_valid.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, i_SimTrackIds));
1324 if (!i_SimTrackIds.empty()) {
1325 n_gem_matched_INVALID++;
1327 muon_matchedIds_INVALID.emplace_back(std::make_unique<uint_SimHitIdpr_pair>(iH, i_SimTrackIds));
1330 }
else if (printRtS)
1332 "MuonAssociatorByHitsHelper::getMatchedIds, null "
1333 "dynamic_cast of a GEM TrackingRecHit !";
1336 unsigned int i_detid = ithit->geographicalId().rawId();
1344 SimTrackIds.insert(SimTrackIds.end(), i_SimTrackIds.begin(), i_SimTrackIds.end());
1349 }
else if (printRtS)
1351 <<
"TrackingRecHit " << iloop <<
" *** WARNING *** Unexpected Hit from Detector = " << det;
1362 for (
unsigned int j = 0;
j < DTSimHits.size();
j++) {
1371 TrackingParticleCollection::const_iterator trpart)
const {
1373 const std::vector<SimTrack> &g4Tracks = trpart->g4Tracks();
1377 for (MapOfMatchedIds::const_iterator iRecH = matchedIds.begin(); iRecH != matchedIds.end(); ++iRecH) {
1379 std::vector<SimHitIdpr>
const &SimTrackIds = (*iRecH)->second;
1383 for (
const auto &iSimH : SimTrackIds) {
1384 uint32_t simtrackId = iSimH.first;
1389 for (
const auto &simtrack : g4Tracks) {
1390 if (simtrack.trackId() == simtrackId && simtrack.eventId() == evtId) {
1407 if (SimTrackIds.empty())
1408 return " *** UNMATCHED ***";
1410 string hitlog(
" matched to SimTrack");
1412 for (
size_t j = 0;
j < SimTrackIds.size();
j++) {
1416 " Id:%i/Evt:(%i,%i) ",
1418 SimTrackIds[
j].
second.event(),
1419 SimTrackIds[
j].second.bunchCrossing());
Log< level::Info, true > LogVerbatim
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
unsigned int NHitCut_muon
std::string dump(unsigned int indent=0) const
std::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)> diagnostics_
const bool ThreeHitTracksAreSpecial
std::string write_matched_simtracks(const std::vector< SimHitIdpr > &) const
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
std::map< size_t, std::vector< IndexMatch > > IndexAssociation
int getShared(MapOfMatchedIds &matchedIds, TrackingParticleCollection::const_iterator trpart) const
constexpr uint32_t rawId() const
get the raw id
RPCHitAssociator const * rpcHitAssoc_
TrackerHitAssociator const * trackerHitAssoc_
std::string to_string(const V &value)
GEMHitAssociator const * gemHitAssoc_
std::vector< SimHitIdpr > associateCSCHitId(const CSCRecHit2D *) const
std::string print(DetId detid) const
std::vector< PSimHit > associateHit(const TrackingRecHit &hit) const
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
double EfficiencyCut_track
const bool AbsoluteNumberOfHits_muon
U second(std::pair< T, U > const &p)
std::vector< SimHitIdpr > associateRecHit(const TrackingRecHit &hit) const
std::vector< std::unique_ptr< uint_SimHitIdpr_pair > > MapOfMatchedIds
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
MuonAssociatorByHitsHelper(const edm::ParameterSet &conf)
const bool rejectBadGlobal
CSCHitAssociator const * cscHitAssoc_
unsigned int NHitCut_track
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
bool hasPhi() const
Does it have the Phi projection?
const bool AbsoluteNumberOfHits_track
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
std::vector< SimTrack >::const_iterator g4t_iterator
bool hasZed() const
Does it have the Z projection?
DTHitAssociator const * dtHitAssoc_
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
std::vector< SimHitIdpr > associateRecHit(const GEMRecHit *gemrechit) const
const bool acceptOneStubMatchings
TrackerTopology const * tTopo_
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
const TrackingRecHit * getHitPtr(edm::OwnVector< TrackingRecHit >::const_iterator iter) const
size_type size() const
Size of the RefVector.
std::vector< TrackingParticle > TrackingParticleCollection
DetId geographicalId() const
double EfficiencyCut_muon
std::vector< SimHitIdpr > associateDTHitId(const DTRecHit1D *dtrechit) const
const bool includeZeroHitMuons
void getMatchedIds(MapOfMatchedIds &tracker_matchedIds_valid, MapOfMatchedIds &muon_matchedIds_valid, MapOfMatchedIds &tracker_matchedIds_INVALID, MapOfMatchedIds &muon_matchedIds_INVALID, int &n_tracker_valid, int &n_dt_valid, int &n_csc_valid, int &n_rpc_valid, int &n_gem_valid, int &n_tracker_matched_valid, int &n_dt_matched_valid, int &n_csc_matched_valid, int &n_rpc_matched_valid, int &n_gem_matched_valid, int &n_tracker_INVALID, int &n_dt_INVALID, int &n_csc_INVALID, int &n_rpc_INVALID, int &n_gem_INVALID, int &n_tracker_matched_INVALID, int &n_dt_matched_INVALID, int &n_csc_matched_INVALID, int &n_rpc_matched_INVALID, int &n_gem_matched_INVALID, trackingRecHit_iterator begin, trackingRecHit_iterator end, const TrackerHitAssociator *trackertruth, const DTHitAssociator &dttruth, const CSCHitAssociator &csctruth, const RPCHitAssociator &rpctruth, const GEMHitAssociator &gemtruth, bool printRts, const TrackerTopology *) const
constexpr Detector det() const
get the detector field from this detid
DTWireId wireId() const
Return the wireId.