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;