35 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"constructing MuonAssociatorByHitsHelper" << conf.
dump();
39 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n UseTracker = TRUE : Tracker SimHits and RecHits WILL be "
42 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n UseTracker = FALSE : Tracker SimHits and RecHits WILL NOT be "
47 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
" UseMuon = TRUE : Muon SimHits and RecHits WILL be counted";
50 <<
" UseMuon = FALSE : Muon SimHits and RecHits WILL NOT be counted" << endl;
55 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n includeZeroHitMuons = TRUE"
56 <<
"\n ==> (re)set NHitCut_muon = 0, PurityCut_muon = 0, "
57 "EfficiencyCut_muon = 0"
70 auto trackertruth =
resources.trackerHitAssoc_;
71 auto const &csctruth = *
resources.cscHitAssoc_;
72 auto const &dttruth = *
resources.dtHitAssoc_;
73 auto const &rpctruth = *
resources.rpcHitAssoc_;
74 auto const &gemtruth = *
resources.gemHitAssoc_;
76 int tracker_nshared = 0;
78 int global_nshared = 0;
80 double tracker_quality = 0;
81 double tracker_quality_cut;
87 double muon_quality = 0;
88 double muon_quality_cut;
94 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;
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;
344 matchOk = trackerOk && muonOk;
347 outputCollection[tindex].push_back(
IndexMatch(tpindex, global_quality));
348 this_track_matched =
true;
352 <<
" **MATCHED** with quality = " << global_quality <<
" (tracker: " << tracker_quality
353 <<
" / muon: " << muon_quality <<
")"
355 <<
" N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
356 <<
" / muon: " << muon_nshared <<
")"
358 <<
" to: TrackingParticle " << tpindex <<
", q = " << (*trpart).charge() <<
", p = " << (*trpart).p()
359 <<
", pT = " << (*trpart).pt() <<
", eta = " << (*trpart).eta() <<
", phi = " << (*trpart).phi() <<
"\n\t"
360 <<
" pdg code = " << (*trpart).pdgId() <<
", made of " << (*trpart).numberOfHits() <<
" PSimHits"
361 <<
" from " << (*trpart).g4Tracks().size() <<
" SimTrack:";
365 <<
" Id:" << (*g4T).trackId() <<
"/Evt:(" << (*g4T).eventId().event() <<
","
366 << (*g4T).eventId().bunchCrossing() <<
")";
371 if (global_nshared != 0)
374 <<
" NOT matched to TrackingParticle " << tpindex <<
" with quality = " << global_quality
375 <<
" (tracker: " << tracker_quality <<
" / muon: " << muon_quality <<
")"
377 <<
" N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
378 <<
" / muon: " << muon_nshared <<
")";
383 if (!this_track_matched) {
385 <<
" NOT matched to any TrackingParticle";
389 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
390 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
398 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"0 reconstructed tracks (-->> 0 associated !)";
400 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
401 std::sort(it->second.begin(), it->second.end());
403 return outputCollection;
411 auto trackertruth =
resources.trackerHitAssoc_;
412 auto const &csctruth = *
resources.cscHitAssoc_;
413 auto const &dttruth = *
resources.dtHitAssoc_;
414 auto const &rpctruth = *
resources.rpcHitAssoc_;
415 auto const &gemtruth = *
resources.gemHitAssoc_;
417 int tracker_nshared = 0;
418 int muon_nshared = 0;
419 int global_nshared = 0;
421 double tracker_quality = 0;
422 double tracker_quality_cut;
428 double muon_quality = 0;
429 double muon_quality_cut;
435 double global_quality = 0;
437 double tracker_purity = 0;
438 double muon_purity = 0;
439 double global_purity = 0;
449 tPC.reserve(TPCollectionH.
size());
450 for (
auto const &ref : TPCollectionH) {
454 bool any_trackingParticle_matched =
false;
457 for (TrackHitsCollection::const_iterator
track = tC.begin();
track != tC.end();
track++, tindex++) {
461 <<
"reco::Track " << tindex <<
", number of RecHits = " << (
track->second -
track->first) <<
"\n";
463 tracker_matchedIds_valid.clear();
464 muon_matchedIds_valid.clear();
466 tracker_matchedIds_INVALID.clear();
467 muon_matchedIds_INVALID.clear();
469 int n_matching_simhits = 0;
473 int n_tracker_all = 0;
480 int n_tracker_valid = 0;
481 int n_muon_valid = 0;
487 int n_tracker_matched_valid = 0;
488 int n_muon_matched_valid = 0;
489 int n_dt_matched_valid = 0;
490 int n_csc_matched_valid = 0;
491 int n_rpc_matched_valid = 0;
492 int n_gem_matched_valid = 0;
495 int n_tracker_INVALID = 0;
496 int n_muon_INVALID = 0;
497 int n_dt_INVALID = 0;
498 int n_csc_INVALID = 0;
499 int n_rpc_INVALID = 0;
500 int n_gem_INVALID = 0;
502 int n_tracker_matched_INVALID = 0;
503 int n_muon_matched_INVALID = 0;
504 int n_dt_matched_INVALID = 0;
505 int n_csc_matched_INVALID = 0;
506 int n_rpc_matched_INVALID = 0;
507 int n_gem_matched_INVALID = 0;
511 muon_matchedIds_valid,
512 tracker_matchedIds_INVALID,
513 muon_matchedIds_INVALID,
519 n_tracker_matched_valid,
529 n_tracker_matched_INVALID,
530 n_dt_matched_INVALID,
531 n_csc_matched_INVALID,
532 n_rpc_matched_INVALID,
533 n_gem_matched_INVALID,
544 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
545 tracker_matchedIds_INVALID.size() + muon_matchedIds_INVALID.size();
547 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid + n_gem_valid;
548 n_valid = n_tracker_valid + n_muon_valid;
549 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID + n_gem_INVALID;
550 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
553 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
554 n_dt_all = n_dt_valid + n_dt_INVALID;
555 n_csc_all = n_csc_valid + n_csc_INVALID;
556 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
557 n_gem_all = n_gem_valid + n_gem_INVALID;
558 n_all = n_valid + n_INVALID;
560 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid + n_gem_matched_valid;
561 n_muon_matched_INVALID =
562 n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID + n_gem_matched_INVALID;
565 int n_tracker_selected_hits = n_tracker_valid;
566 int n_muon_selected_hits = n_muon_valid;
567 int n_dt_selected_hits = n_dt_valid;
568 int n_csc_selected_hits = n_csc_valid;
569 int n_rpc_selected_hits = n_rpc_valid;
570 int n_gem_selected_hits = n_gem_valid;
573 int n_tracker_matched = n_tracker_matched_valid;
574 int n_muon_matched = n_muon_matched_valid;
575 int n_dt_matched = n_dt_matched_valid;
576 int n_csc_matched = n_csc_matched_valid;
577 int n_rpc_matched = n_rpc_matched_valid;
578 int n_gem_matched = n_gem_matched_valid;
586 InvMuonHits =
" ***INVALID MUON HITS***";
587 ZeroHitMuon =
" ***ZERO-HIT MUON***";
589 n_muon_selected_hits = n_muon_INVALID;
590 n_dt_selected_hits = n_dt_INVALID;
591 n_csc_selected_hits = n_csc_INVALID;
592 n_rpc_selected_hits = n_rpc_INVALID;
593 n_gem_selected_hits = n_gem_INVALID;
595 n_muon_matched = n_muon_matched_INVALID;
596 n_dt_matched = n_dt_matched_INVALID;
597 n_csc_matched = n_csc_matched_INVALID;
598 n_rpc_matched = n_rpc_matched_INVALID;
599 n_gem_matched = n_gem_matched_INVALID;
602 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
603 int n_matched = n_tracker_matched + n_muon_matched;
608 <<
"# TrackingRecHits: " << (
track->second -
track->first) <<
"\n"
609 <<
"# used RecHits = " << n_all <<
" (" << n_tracker_all <<
"/" << n_dt_all <<
"/" << n_csc_all <<
"/"
610 << n_rpc_all <<
"/" << n_gem_all <<
" in Tracker/DT/CSC/RPC/GEM)"
611 <<
", obtained from " << n_matching_simhits <<
" SimHits"
613 <<
"# selected RecHits = " << n_selected_hits <<
" (" << n_tracker_selected_hits <<
"/" << n_dt_selected_hits
614 <<
"/" << n_csc_selected_hits <<
"/" << n_rpc_selected_hits <<
"/" << n_gem_selected_hits
615 <<
" in Tracker/DT/CSC/RPC/GEM)" << InvMuonHits <<
"\n"
616 <<
"# matched RecHits = " << n_matched <<
" (" << n_tracker_matched <<
"/" << n_dt_matched <<
"/"
617 << n_csc_matched <<
"/" << n_rpc_matched <<
"/" << n_gem_matched <<
" in Tracker/DT/CSC/RPC/GEM)";
619 if (printRtS && n_all > 0 && n_matching_simhits == 0)
621 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateSimToReco: "
622 "no matching PSimHit found for this reco::Track !";
624 if (n_matching_simhits != 0) {
626 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
628 int n_tracker_recounted_simhits = 0;
629 int n_muon_simhits = 0;
630 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)
716 n_tracker_recounted_simhits = trpart->numberOfTrackerHits();
718 n_muon_simhits = trpart->numberOfHits() - trpart->numberOfTrackerHits();
722 if (trpart->numberOfHits() == 0) {
732 n_tracker_recounted_simhits = 1;
735 n_global_simhits = n_tracker_recounted_simhits + n_muon_simhits;
738 n_muon_selected_simhits = n_muon_simhits;
739 n_global_selected_simhits = n_muon_selected_simhits;
742 n_tracker_selected_simhits = n_tracker_recounted_simhits;
743 n_global_selected_simhits += n_tracker_selected_simhits;
747 tracker_quality = static_cast<double>(tracker_nshared);
748 else if (n_tracker_selected_simhits != 0)
749 tracker_quality = static_cast<double>(tracker_nshared) / static_cast<double>(n_tracker_selected_simhits);
754 muon_quality = static_cast<double>(muon_nshared);
755 else if (n_muon_selected_simhits != 0)
756 muon_quality = static_cast<double>(muon_nshared) / static_cast<double>(n_muon_selected_simhits);
761 if (n_global_selected_simhits != 0) {
763 global_quality = global_nshared;
765 global_quality = static_cast<double>(global_nshared) / static_cast<double>(n_global_selected_simhits);
770 if (n_selected_hits != 0) {
772 global_purity = global_nshared;
774 global_purity = static_cast<double>(global_nshared) / static_cast<double>(n_selected_hits);
778 bool trackerOk =
false;
779 if (n_tracker_selected_hits != 0) {
780 if (tracker_quality > tracker_quality_cut)
783 tracker_purity = static_cast<double>(tracker_nshared) / static_cast<double>(n_tracker_selected_hits);
785 tracker_purity = static_cast<double>(tracker_nshared);
797 if (n_muon_selected_hits != 0) {
798 if (muon_quality > muon_quality_cut)
801 muon_purity = static_cast<double>(muon_nshared) / static_cast<double>(n_muon_selected_hits);
803 muon_purity = static_cast<double>(muon_nshared);
811 bool matchOk = trackerOk || muonOk;
816 matchOk = trackerOk && muonOk;
819 outputCollection[tpindex].push_back(
IndexMatch(tindex, global_quality));
820 any_trackingParticle_matched =
true;
823 <<
"*************************************************************"
824 "***********************************************************"
826 <<
"TrackingParticle " << tpindex <<
", q = " << (*trpart).charge() <<
", p = " << (*trpart).p()
827 <<
", pT = " << (*trpart).pt() <<
", eta = " << (*trpart).eta() <<
", phi = " << (*trpart).phi() <<
"\n"
828 <<
" pdg code = " << (*trpart).pdgId() <<
", made of " << (*trpart).numberOfHits()
829 <<
" PSimHits, recounted " << n_global_simhits <<
" PSimHits"
830 <<
" (tracker:" << n_tracker_recounted_simhits <<
"/muons:" << n_muon_simhits <<
")"
831 <<
", from " << (*trpart).g4Tracks().size() <<
" SimTrack:";
834 <<
" Id:" << (*g4T).trackId() <<
"/Evt:(" << (*g4T).eventId().event() <<
","
835 << (*g4T).eventId().bunchCrossing() <<
")";
838 <<
"\t selected " << n_global_selected_simhits <<
" PSimHits"
839 <<
" (tracker:" << n_tracker_selected_simhits <<
"/muons:" << n_muon_selected_simhits <<
")"
840 <<
"\n\t **MATCHED** with quality = " << global_quality <<
" (tracker: " << tracker_quality
841 <<
" / muon: " << muon_quality <<
")"
842 <<
"\n\t and purity = " << global_purity <<
" (tracker: " << tracker_purity
843 <<
" / muon: " << muon_purity <<
")"
844 <<
"\n\t N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
845 <<
" / muon: " << muon_nshared <<
")"
847 <<
" to: reco::Track " << tindex << ZeroHitMuon <<
"\n\t"
848 <<
" made of " << n_selected_hits <<
" RecHits (tracker:" << n_tracker_valid
849 <<
"/muons:" << n_muon_selected_hits <<
")";
853 if (global_nshared != 0) {
856 <<
"*********************************************************"
857 "*********************************************************"
860 <<
"TrackingParticle " << tpindex <<
", q = " << (*trpart).charge() <<
", p = " << (*trpart).p()
861 <<
", pT = " << (*trpart).pt() <<
", eta = " << (*trpart).eta() <<
", phi = " << (*trpart).phi()
863 <<
" pdg code = " << (*trpart).pdgId() <<
", made of " << (*trpart).numberOfHits()
864 <<
" PSimHits, recounted " << n_global_simhits <<
" PSimHits"
865 <<
" (tracker:" << n_tracker_recounted_simhits <<
"/muons:" << n_muon_simhits <<
")"
866 <<
", from " << (*trpart).g4Tracks().size() <<
" SimTrack:";
871 <<
" Id:" << (*g4T).trackId() <<
"/Evt:(" << (*g4T).eventId().event() <<
","
872 << (*g4T).eventId().bunchCrossing() <<
")";
876 <<
"\t selected " << n_global_selected_simhits <<
" PSimHits"
877 <<
" (tracker:" << n_tracker_selected_simhits <<
"/muons:" << n_muon_selected_simhits <<
")"
878 <<
"\n\t NOT matched to reco::Track " << tindex << ZeroHitMuon
879 <<
" with quality = " << global_quality <<
" (tracker: " << tracker_quality
880 <<
" / muon: " << muon_quality <<
")"
881 <<
"\n\t and purity = " << global_purity <<
" (tracker: " << tracker_purity
882 <<
" / muon: " << muon_purity <<
")"
883 <<
"\n\t N shared hits = " << global_nshared <<
" (tracker: " << tracker_nshared
884 <<
" / muon: " << muon_nshared <<
")";
891 if (!any_trackingParticle_matched) {
894 <<
"*******************************************************************"
895 "*****************************************************"
896 <<
"\n NO TrackingParticle associated to ANY input reco::Track ! \n"
897 <<
"*******************************************************************"
898 "*****************************************************"
902 <<
"*******************************************************************"
903 "*****************************************************"
907 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
908 std::sort(it->second.begin(), it->second.end());
910 return outputCollection;
917 int &n_tracker_valid,
922 int &n_tracker_matched_valid,
923 int &n_dt_matched_valid,
924 int &n_csc_matched_valid,
925 int &n_rpc_matched_valid,
926 int &n_gem_matched_valid,
927 int &n_tracker_INVALID,
932 int &n_tracker_matched_INVALID,
933 int &n_dt_matched_INVALID,
934 int &n_csc_matched_INVALID,
935 int &n_rpc_matched_INVALID,
936 int &n_gem_matched_INVALID,
948 tracker_matchedIds_valid.clear();
949 muon_matchedIds_valid.clear();
951 tracker_matchedIds_INVALID.clear();
952 muon_matchedIds_INVALID.clear();
960 n_tracker_matched_valid = 0;
961 n_dt_matched_valid = 0;
962 n_csc_matched_valid = 0;
963 n_rpc_matched_valid = 0;
964 n_gem_matched_valid = 0;
966 n_tracker_INVALID = 0;
972 n_tracker_matched_INVALID = 0;
973 n_dt_matched_INVALID = 0;
974 n_csc_matched_INVALID = 0;
975 n_rpc_matched_INVALID = 0;
976 n_gem_matched_INVALID = 0;
978 std::vector<SimHitIdpr> SimTrackIds;
984 stringstream hit_index;
990 unsigned int detid = geoid.
rawId();
991 stringstream detector_id;
992 detector_id << detid;
994 string hitlog =
"TrackingRecHit " + hit_index.str();
996 std::vector<string> DTSimHits;
1001 bool valid_Hit = hitp->
isValid();
1005 stringstream detector_id;
1006 detector_id << tTopo->
print(detid);
1009 hitlog = hitlog +
" -Tracker - detID = " + detector_id.str();
1011 hitlog = hitlog +
" *** INVALID ***" +
" -Tracker - detID = " + detector_id.str();
1019 if (!SimTrackIds.empty()) {
1020 n_tracker_matched_valid++;
1025 n_tracker_INVALID++;
1027 if (!SimTrackIds.empty()) {
1028 n_tracker_matched_INVALID++;
1039 stringstream dt_detector_id;
1040 dt_detector_id << dtdetid;
1042 hitlog = hitlog +
" -Muon DT - detID = " + dt_detector_id.str();
1044 hitlog = hitlog +
" *** INVALID ***" +
" -Muon DT - detID = " + dt_detector_id.str();
1056 if (!SimTrackIds.empty()) {
1057 n_dt_matched_valid++;
1064 if (!SimTrackIds.empty()) {
1065 n_dt_matched_INVALID++;
1075 std::vector<PSimHit> dtSimHits = dttruth.
associateHit(*hitp);
1077 stringstream ndthits;
1078 ndthits << dtSimHits.size();
1079 wireidlog =
"\t DTWireId :" + wid.str() +
", " + ndthits.str() +
" associated PSimHit :";
1081 for (
unsigned int j = 0;
j < dtSimHits.size();
j++) {
1084 stringstream simhit;
1085 simhit << dtSimHits[
j];
1086 string simhitlog =
"\t\t PSimHit " +
index.str() +
": " + simhit.str();
1087 DTSimHits.push_back(simhitlog);
1094 const DTRecSegment4D *dtsegment = dynamic_cast<const DTRecSegment4D *>(hitp);
1097 std::vector<const TrackingRecHit *> componentHits, phiHits, zHits;
1098 if (dtsegment->
hasPhi()) {
1100 componentHits.insert(componentHits.end(), phiHits.begin(), phiHits.end());
1102 if (dtsegment->
hasZed()) {
1104 componentHits.insert(componentHits.end(), zHits.begin(), zHits.end());
1108 <<
"\n\t this TrackingRecHit is a DTRecSegment4D with " << componentHits.size()
1109 <<
" hits (phi:" << phiHits.size() <<
", z:" << zHits.size() <<
")";
1111 SimTrackIds.clear();
1112 std::vector<SimHitIdpr> i_SimTrackIds;
1114 for (std::vector<const TrackingRecHit *>::const_iterator ithit = componentHits.begin();
1115 ithit != componentHits.end();
1119 const DTRecHit1D *dtrechit1D = dynamic_cast<const DTRecHit1D *>(*ithit);
1121 i_SimTrackIds.clear();
1131 if (!i_SimTrackIds.empty()) {
1132 n_dt_matched_valid++;
1139 if (!i_SimTrackIds.empty()) {
1140 n_dt_matched_INVALID++;
1145 }
else if (printRtS)
1147 "MuonAssociatorByHitsHelper::getMatchedIds, null "
1148 "dynamic_cast of a DT TrackingRecHit !";
1150 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1153 stringstream i_dt_detector_id;
1154 i_dt_detector_id << i_dtdetid;
1157 i_ss <<
"\t\t hit " << i_compHit <<
" -Muon DT - detID = " << i_dt_detector_id.str();
1159 string i_hitlog = i_ss.str();
1164 SimTrackIds.insert(SimTrackIds.end(), i_SimTrackIds.begin(), i_SimTrackIds.end());
1170 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, "
1171 "DT TrackingRecHit is neither DTRecHit1D nor DTRecSegment4D "
1179 stringstream csc_detector_id;
1180 csc_detector_id << cscdetid;
1182 hitlog = hitlog +
" -Muon CSC- detID = " + csc_detector_id.str();
1184 hitlog = hitlog +
" *** INVALID ***" +
" -Muon CSC- detID = " + csc_detector_id.str();
1186 const CSCRecHit2D *cscrechit = dynamic_cast<const CSCRecHit2D *>(hitp);
1196 if (!SimTrackIds.empty()) {
1197 n_csc_matched_valid++;
1204 if (!SimTrackIds.empty()) {
1205 n_csc_matched_INVALID++;
1214 const CSCSegment *cscsegment = dynamic_cast<const CSCSegment *>(hitp);
1217 std::vector<const TrackingRecHit *> componentHits = cscsegment->
recHits();
1220 <<
"\n\t this TrackingRecHit is a CSCSegment with " << componentHits.size() <<
" hits";
1222 SimTrackIds.clear();
1223 std::vector<SimHitIdpr> i_SimTrackIds;
1225 for (std::vector<const TrackingRecHit *>::const_iterator ithit = componentHits.begin();
1226 ithit != componentHits.end();
1230 const CSCRecHit2D *cscrechit2D = dynamic_cast<const CSCRecHit2D *>(*ithit);
1232 i_SimTrackIds.clear();
1242 if (!i_SimTrackIds.empty()) {
1243 n_csc_matched_valid++;
1250 if (!i_SimTrackIds.empty()) {
1251 n_csc_matched_INVALID++;
1256 }
else if (printRtS)
1258 "MuonAssociatorByHitsHelper::getMatchedIds, null "
1259 "dynamic_cast of a CSC TrackingRecHit !";
1261 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1264 stringstream i_csc_detector_id;
1265 i_csc_detector_id << i_cscdetid;
1268 i_ss <<
"\t\t hit " << i_compHit <<
" -Muon CSC- detID = " << i_csc_detector_id.str();
1270 string i_hitlog = i_ss.str();
1275 SimTrackIds.insert(SimTrackIds.end(), i_SimTrackIds.begin(), i_SimTrackIds.end());
1281 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, "
1282 "CSC TrackingRecHit is neither CSCRecHit2D nor CSCSegment "
1290 stringstream rpc_detector_id;
1291 rpc_detector_id << rpcdetid;
1293 hitlog = hitlog +
" -Muon RPC- detID = " + rpc_detector_id.str();
1295 hitlog = hitlog +
" *** INVALID ***" +
" -Muon RPC- detID = " + rpc_detector_id.str();
1303 if (!SimTrackIds.empty()) {
1304 n_rpc_matched_valid++;
1311 if (!SimTrackIds.empty()) {
1312 n_rpc_matched_INVALID++;
1322 stringstream gem_detector_id;
1323 gem_detector_id << gemdetid;
1325 hitlog = hitlog +
" -Muon GEM- detID = " + gem_detector_id.str();
1327 hitlog = hitlog +
" *** INVALID ***" +
" -Muon GEM- detID = " + gem_detector_id.str();
1329 const GEMRecHit *gemrechit = dynamic_cast<const GEMRecHit *>(hitp);
1337 if (!SimTrackIds.empty()) {
1338 n_gem_matched_valid++;
1345 if (!SimTrackIds.empty()) {
1346 n_gem_matched_INVALID++;
1352 const GEMSegment *gemsegment = dynamic_cast<const GEMSegment *>(hitp);
1354 std::vector<const TrackingRecHit *> componentHits = gemsegment->
recHits();
1357 <<
"\n\t this TrackingRecHit is a GEMSegment with " << componentHits.size() <<
" hits";
1359 SimTrackIds.clear();
1360 std::vector<SimHitIdpr> i_SimTrackIds;
1363 for (
auto const &ithit : componentHits) {
1366 const GEMRecHit *gemrechitseg = dynamic_cast<const GEMRecHit *>(ithit);
1368 i_SimTrackIds.clear();
1378 if (!i_SimTrackIds.empty()) {
1379 n_gem_matched_valid++;
1386 if (!i_SimTrackIds.empty()) {
1387 n_gem_matched_INVALID++;
1392 }
else if (printRtS)
1394 "MuonAssociatorByHitsHelper::getMatchedIds, null "
1395 "dynamic_cast of a GEM TrackingRecHit !";
1398 unsigned int i_detid = ithit->geographicalId().rawId();
1401 string i_hitlog = std::to_string(i_gemdetid);
1406 SimTrackIds.insert(SimTrackIds.end(), i_SimTrackIds.begin(), i_SimTrackIds.end());
1411 }
else if (printRtS)
1413 <<
"TrackingRecHit " << iloop <<
" *** WARNING *** Unexpected Hit from Detector = " << det;
1424 for (
unsigned int j = 0;
j < DTSimHits.size();
j++) {
1433 TrackingParticleCollection::const_iterator trpart)
const {
1435 const std::vector<SimTrack> &g4Tracks = trpart->g4Tracks();
1439 for (MapOfMatchedIds::const_iterator iRecH = matchedIds.begin(); iRecH != matchedIds.end(); ++iRecH) {
1441 std::vector<SimHitIdpr>
const &SimTrackIds = (*iRecH).second;
1445 for (
const auto &iSimH : SimTrackIds) {
1446 uint32_t simtrackId = iSimH.first;
1451 for (
const auto &simtrack : g4Tracks) {
1452 if (simtrack.trackId() == simtrackId && simtrack.eventId() == evtId) {
1469 if (SimTrackIds.empty())
1470 return " *** UNMATCHED ***";
1472 string hitlog(
" matched to SimTrack");
1474 for (
size_t j = 0;
j < SimTrackIds.size();
j++) {
1478 " Id:%i/Evt:(%i,%i) ",
1480 SimTrackIds[
j].
second.event(),
1481 SimTrackIds[
j].second.bunchCrossing());