413 auto trackertruth =
resources.trackerHitAssoc_;
414 auto const &csctruth = *
resources.cscHitAssoc_;
415 auto const &dttruth = *
resources.dtHitAssoc_;
416 auto const &rpctruth = *
resources.rpcHitAssoc_;
417 auto const &gemtruth = *
resources.gemHitAssoc_;
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;
Log< level::Info, true > LogVerbatim
unsigned int NHitCut_muon
const bool ThreeHitTracksAreSpecial
std::map< size_t, std::vector< IndexMatch > > IndexAssociation
double EfficiencyCut_track
const bool AbsoluteNumberOfHits_muon
std::vector< std::unique_ptr< uint_SimHitIdpr_pair > > MapOfMatchedIds
const bool rejectBadGlobal
unsigned int NHitCut_track
const bool AbsoluteNumberOfHits_track
std::vector< SimTrack >::const_iterator g4t_iterator
size_type size() const
Size of the RefVector.
const bool acceptOneStubMatchings
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
std::vector< TrackingParticle > TrackingParticleCollection
double EfficiencyCut_muon
int getShared(MapOfMatchedIds &matchedIds, TrackingParticleCollection::const_iterator trpart) const
const bool includeZeroHitMuons