18 includeZeroHitMuons(conf.getParameter<bool>(
"includeZeroHitMuons")),
19 acceptOneStubMatchings(conf.getParameter<bool>(
"acceptOneStubMatchings")),
20 UseTracker(conf.getParameter<bool>(
"UseTracker")),
21 UseMuon(conf.getParameter<bool>(
"UseMuon")),
22 AbsoluteNumberOfHits_track(conf.getParameter<bool>(
"AbsoluteNumberOfHits_track")),
23 NHitCut_track(conf.getParameter<unsigned int>(
"NHitCut_track")),
24 EfficiencyCut_track(conf.getParameter<double>(
"EfficiencyCut_track")),
25 PurityCut_track(conf.getParameter<double>(
"PurityCut_track")),
26 AbsoluteNumberOfHits_muon(conf.getParameter<bool>(
"AbsoluteNumberOfHits_muon")),
27 NHitCut_muon(conf.getParameter<unsigned int>(
"NHitCut_muon")),
28 EfficiencyCut_muon(conf.getParameter<double>(
"EfficiencyCut_muon")),
29 PurityCut_muon(conf.getParameter<double>(
"PurityCut_muon")),
30 UsePixels(conf.getParameter<bool>(
"UsePixels")),
31 UseGrouped(conf.getParameter<bool>(
"UseGrouped")),
32 UseSplitting(conf.getParameter<bool>(
"UseSplitting")),
33 ThreeHitTracksAreSpecial(conf.getParameter<bool>(
"ThreeHitTracksAreSpecial")),
34 dumpDT(conf.getParameter<bool>(
"dumpDT"))
36 edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"constructing MuonAssociatorByHitsHelper" << conf.
dump();
39 if (
UseTracker)
edm::LogVerbatim(
"MuonAssociatorByHitsHelper")<<
"\n UseTracker = TRUE : Tracker SimHits and RecHits WILL be counted";
40 else edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
"\n UseTracker = FALSE : Tracker SimHits and RecHits WILL NOT be counted";
43 if (
UseMuon)
edm::LogVerbatim(
"MuonAssociatorByHitsHelper")<<
" UseMuon = TRUE : Muon SimHits and RecHits WILL be counted";
44 else edm::LogVerbatim(
"MuonAssociatorByHitsHelper") <<
" UseMuon = FALSE : Muon SimHits and RecHits WILL NOT be counted"<<endl;
49 <<
"\n includeZeroHitMuons = TRUE"
50 <<
"\n ==> (re)set NHitCut_muon = 0, PurityCut_muon = 0, EfficiencyCut_muon = 0"<<endl;
63 auto tTopo = resources.
tTopo_;
69 int tracker_nshared = 0;
71 int global_nshared = 0;
73 double tracker_quality = 0;
74 double tracker_quality_cut;
78 double muon_quality = 0;
79 double muon_quality_cut;
83 double global_quality = 0;
92 tPC.reserve(TPCollectionH.
size());
93 for(
auto const& ref: TPCollectionH) {
102 for (TrackHitsCollection::const_iterator track=tC.begin(); track!=tC.end(); track++, tindex++) {
104 <<
"\n"<<
"reco::Track "<<tindex
105 <<
", number of RecHits = "<< (track->second - track->first) <<
"\n";
106 tracker_matchedIds_valid.clear();
107 muon_matchedIds_valid.clear();
109 tracker_matchedIds_INVALID.clear();
110 muon_matchedIds_INVALID.clear();
112 bool this_track_matched =
false;
113 int n_matching_simhits = 0;
117 int n_tracker_all = 0;
123 int n_tracker_valid = 0;
124 int n_muon_valid = 0;
129 int n_tracker_matched_valid = 0;
130 int n_muon_matched_valid = 0;
131 int n_dt_matched_valid = 0;
132 int n_csc_matched_valid = 0;
133 int n_rpc_matched_valid = 0;
136 int n_tracker_INVALID = 0;
137 int n_muon_INVALID = 0;
138 int n_dt_INVALID = 0;
139 int n_csc_INVALID = 0;
140 int n_rpc_INVALID = 0;
142 int n_tracker_matched_INVALID = 0;
143 int n_muon_matched_INVALID = 0;
144 int n_dt_matched_INVALID = 0;
145 int n_csc_matched_INVALID = 0;
146 int n_rpc_matched_INVALID = 0;
149 getMatchedIds(tracker_matchedIds_valid, muon_matchedIds_valid,
150 tracker_matchedIds_INVALID, muon_matchedIds_INVALID,
151 n_tracker_valid, n_dt_valid, n_csc_valid, n_rpc_valid,
152 n_tracker_matched_valid, n_dt_matched_valid, n_csc_matched_valid, n_rpc_matched_valid,
153 n_tracker_INVALID, n_dt_INVALID, n_csc_INVALID, n_rpc_INVALID,
154 n_tracker_matched_INVALID, n_dt_matched_INVALID, n_csc_matched_INVALID, n_rpc_matched_INVALID,
155 track->first, track->second,
156 trackertruth, dttruth, csctruth, rpctruth,
159 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
160 tracker_matchedIds_INVALID.size() +muon_matchedIds_INVALID.size();
162 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid;
163 n_valid = n_tracker_valid + n_muon_valid;
164 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID;
165 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
168 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
169 n_dt_all = n_dt_valid + n_dt_INVALID;
170 n_csc_all = n_csc_valid + n_csc_INVALID;
171 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
172 n_all = n_valid + n_INVALID;
174 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid;
175 n_muon_matched_INVALID = n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID;
178 int n_tracker_selected_hits = n_tracker_valid;
179 int n_muon_selected_hits = n_muon_valid;
180 int n_dt_selected_hits = n_dt_valid;
181 int n_csc_selected_hits = n_csc_valid;
182 int n_rpc_selected_hits = n_rpc_valid;
185 int n_tracker_matched = n_tracker_matched_valid;
186 int n_muon_matched = n_muon_matched_valid;
187 int n_dt_matched = n_dt_matched_valid;
188 int n_csc_matched = n_csc_matched_valid;
189 int n_rpc_matched = n_rpc_matched_valid;
196 InvMuonHits =
" ***INVALID MUON HITS***";
197 ZeroHitMuon =
" ***ZERO-HIT MUON***";
199 n_muon_selected_hits = n_muon_INVALID;
200 n_dt_selected_hits = n_dt_INVALID;
201 n_csc_selected_hits = n_csc_INVALID;
202 n_rpc_selected_hits = n_rpc_INVALID;
204 n_muon_matched = n_muon_matched_INVALID;
205 n_dt_matched = n_dt_matched_INVALID;
206 n_csc_matched = n_csc_matched_INVALID;
207 n_rpc_matched = n_rpc_matched_INVALID;
210 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
211 int n_matched = n_tracker_matched + n_muon_matched;
214 <<
"\n"<<
"# TrackingRecHits: "<<(track->second - track->first)
215 <<
"\n"<<
"# used RecHits = " << n_all <<
" ("<<n_tracker_all<<
"/"
216 <<n_dt_all<<
"/"<<n_csc_all<<
"/"<<n_rpc_all<<
" in Tracker/DT/CSC/RPC)"<<
", obtained from " << n_matching_simhits <<
" SimHits"
217 <<
"\n"<<
"# selected RecHits = " <<n_selected_hits <<
" (" <<n_tracker_selected_hits<<
"/"
218 <<n_dt_selected_hits<<
"/"<<n_csc_selected_hits<<
"/"<<n_rpc_selected_hits<<
" in Tracker/DT/CSC/RPC)"<<InvMuonHits
219 <<
"\n"<<
"# matched RecHits = " <<n_matched<<
" ("<<n_tracker_matched<<
"/"
220 <<n_dt_matched<<
"/"<<n_csc_matched<<
"/"<<n_rpc_matched<<
" in Tracker/DT/CSC/RPC)";
222 if (n_all>0 && n_matching_simhits == 0)
224 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateRecoToSim: no matching PSimHit found for this reco::Track !";
226 if (n_matching_simhits != 0) {
228 <<
"\n"<<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
229 <<
"\n"<<
"reco::Track "<<tindex<<ZeroHitMuon
230 <<
"\n\t"<<
"made of "<<n_selected_hits<<
" selected RecHits (tracker:"<<n_tracker_selected_hits<<
"/muons:"<<n_muon_selected_hits<<
")";
233 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
234 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
235 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
238 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
240 global_nshared = tracker_nshared + muon_nshared;
243 else if(n_tracker_selected_hits != 0) tracker_quality = (
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits));
244 else tracker_quality = 0;
247 else if(n_muon_selected_hits != 0) muon_quality = (
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits));
248 else muon_quality = 0;
251 if (n_selected_hits != 0) {
253 global_quality = global_nshared;
255 global_quality = (
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits));
256 }
else global_quality = 0;
258 bool trackerOk =
false;
259 if (n_tracker_selected_hits != 0) {
260 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
266 if (n_muon_selected_hits != 0) {
267 if (muon_quality > muon_quality_cut) muonOk =
true;
271 bool matchOk = trackerOk || muonOk;
275 matchOk = trackerOk && muonOk;
279 outputCollection[tindex].push_back(
IndexMatch(tpindex, global_quality));
280 this_track_matched =
true;
283 <<
"\n\t"<<
" **MATCHED** with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
284 <<
"\n\t"<<
" N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")"
285 <<
"\n"<<
" to: TrackingParticle " <<tpindex<<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
286 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
287 <<
"\n\t"<<
" pdg code = "<<(*trpart).pdgId()<<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits"
288 <<
" from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
290 g4T!=(*trpart).g4Track_end();
293 <<
"\t"<<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
298 if (global_nshared != 0)
300 <<
"\n\t"<<
" NOT matched to TrackingParticle "<<tpindex
301 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
302 <<
"\n"<<
" N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
307 if (!this_track_matched) {
309 <<
"\n"<<
" NOT matched to any TrackingParticle";
313 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<
"\n";
320 edm::LogVerbatim(
"MuonAssociatorByHitsHelper")<<
"0 reconstructed tracks (-->> 0 associated !)";
322 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
323 std::sort(it->second.begin(), it->second.end());
325 return outputCollection;
333 auto tTopo = resources.
tTopo_;
339 int tracker_nshared = 0;
340 int muon_nshared = 0;
341 int global_nshared = 0;
343 double tracker_quality = 0;
344 double tracker_quality_cut;
348 double muon_quality = 0;
349 double muon_quality_cut;
353 double global_quality = 0;
355 double tracker_purity = 0;
356 double muon_purity = 0;
357 double global_purity = 0;
368 tPC.reserve(TPCollectionH.
size());
369 for(
auto const& ref: TPCollectionH) {
373 bool any_trackingParticle_matched =
false;
376 for (TrackHitsCollection::const_iterator track=tC.begin(); track!=tC.end(); track++, tindex++) {
378 <<
"\n"<<
"reco::Track "<<tindex
379 <<
", number of RecHits = "<< (track->second - track->first) <<
"\n";
381 tracker_matchedIds_valid.clear();
382 muon_matchedIds_valid.clear();
384 tracker_matchedIds_INVALID.clear();
385 muon_matchedIds_INVALID.clear();
387 int n_matching_simhits = 0;
391 int n_tracker_all = 0;
397 int n_tracker_valid = 0;
398 int n_muon_valid = 0;
403 int n_tracker_matched_valid = 0;
404 int n_muon_matched_valid = 0;
405 int n_dt_matched_valid = 0;
406 int n_csc_matched_valid = 0;
407 int n_rpc_matched_valid = 0;
410 int n_tracker_INVALID = 0;
411 int n_muon_INVALID = 0;
412 int n_dt_INVALID = 0;
413 int n_csc_INVALID = 0;
414 int n_rpc_INVALID = 0;
416 int n_tracker_matched_INVALID = 0;
417 int n_muon_matched_INVALID = 0;
418 int n_dt_matched_INVALID = 0;
419 int n_csc_matched_INVALID = 0;
420 int n_rpc_matched_INVALID = 0;
423 getMatchedIds(tracker_matchedIds_valid, muon_matchedIds_valid,
424 tracker_matchedIds_INVALID, muon_matchedIds_INVALID,
425 n_tracker_valid, n_dt_valid, n_csc_valid, n_rpc_valid,
426 n_tracker_matched_valid, n_dt_matched_valid, n_csc_matched_valid, n_rpc_matched_valid,
427 n_tracker_INVALID, n_dt_INVALID, n_csc_INVALID, n_rpc_INVALID,
428 n_tracker_matched_INVALID, n_dt_matched_INVALID, n_csc_matched_INVALID, n_rpc_matched_INVALID,
429 track->first, track->second,
430 trackertruth, dttruth, csctruth, rpctruth,
433 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
434 tracker_matchedIds_INVALID.size() +muon_matchedIds_INVALID.size();
436 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid;
437 n_valid = n_tracker_valid + n_muon_valid;
438 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID;
439 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
442 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
443 n_dt_all = n_dt_valid + n_dt_INVALID;
444 n_csc_all = n_csc_valid + n_csc_INVALID;
445 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
446 n_all = n_valid + n_INVALID;
448 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid;
449 n_muon_matched_INVALID = n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID;
452 int n_tracker_selected_hits = n_tracker_valid;
453 int n_muon_selected_hits = n_muon_valid;
454 int n_dt_selected_hits = n_dt_valid;
455 int n_csc_selected_hits = n_csc_valid;
456 int n_rpc_selected_hits = n_rpc_valid;
459 int n_tracker_matched = n_tracker_matched_valid;
460 int n_muon_matched = n_muon_matched_valid;
461 int n_dt_matched = n_dt_matched_valid;
462 int n_csc_matched = n_csc_matched_valid;
463 int n_rpc_matched = n_rpc_matched_valid;
470 InvMuonHits =
" ***INVALID MUON HITS***";
471 ZeroHitMuon =
" ***ZERO-HIT MUON***";
473 n_muon_selected_hits = n_muon_INVALID;
474 n_dt_selected_hits = n_dt_INVALID;
475 n_csc_selected_hits = n_csc_INVALID;
476 n_rpc_selected_hits = n_rpc_INVALID;
478 n_muon_matched = n_muon_matched_INVALID;
479 n_dt_matched = n_dt_matched_INVALID;
480 n_csc_matched = n_csc_matched_INVALID;
481 n_rpc_matched = n_rpc_matched_INVALID;
484 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
485 int n_matched = n_tracker_matched + n_muon_matched;
488 <<
"\n"<<
"# TrackingRecHits: "<<(track->second - track->first)
489 <<
"\n"<<
"# used RecHits = " <<n_all <<
" ("<<n_tracker_all<<
"/"
490 <<n_dt_all<<
"/"<<n_csc_all<<
"/"<<n_rpc_all<<
" in Tracker/DT/CSC/RPC)"<<
", obtained from " << n_matching_simhits <<
" SimHits"
491 <<
"\n"<<
"# selected RecHits = " <<n_selected_hits <<
" (" <<n_tracker_selected_hits<<
"/"
492 <<n_dt_selected_hits<<
"/"<<n_csc_selected_hits<<
"/"<<n_rpc_selected_hits<<
" in Tracker/DT/CSC/RPC)"<<InvMuonHits
493 <<
"\n"<<
"# matched RecHits = " <<n_matched<<
" ("<<n_tracker_matched<<
"/"
494 <<n_dt_matched<<
"/"<<n_csc_matched<<
"/"<<n_rpc_matched<<
" in Tracker/DT/CSC/RPC)";
496 if (printRtS && n_all>0 && n_matching_simhits==0)
498 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateSimToReco: no matching PSimHit found for this reco::Track !";
500 if (n_matching_simhits != 0) {
502 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
505 int n_tracker_recounted_simhits = 0;
506 int n_muon_simhits = 0;
507 int n_global_simhits = 0;
510 int n_tracker_selected_simhits = 0;
511 int n_muon_selected_simhits = 0;
512 int n_global_selected_simhits = 0;
515 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
516 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
519 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
521 global_nshared = tracker_nshared + muon_nshared;
522 if (global_nshared == 0)
continue;
588 n_tracker_recounted_simhits = trpart->numberOfTrackerHits();
590 n_muon_simhits = trpart->numberOfHits() - trpart->numberOfTrackerHits();
593 if (trpart->numberOfHits()==0) {
595 n_tracker_recounted_simhits = tracker_nshared;
596 n_muon_simhits = muon_nshared;
598 n_global_simhits = n_tracker_recounted_simhits + n_muon_simhits;
601 n_muon_selected_simhits = n_muon_simhits;
602 n_global_selected_simhits = n_muon_selected_simhits;
605 n_tracker_selected_simhits = n_tracker_recounted_simhits;
606 n_global_selected_simhits += n_tracker_selected_simhits;
610 else if (n_tracker_selected_simhits!=0)
611 tracker_quality =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_simhits);
612 else tracker_quality = 0;
615 else if (n_muon_selected_simhits!=0)
616 muon_quality =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_simhits);
617 else muon_quality = 0;
620 if (n_global_selected_simhits != 0) {
622 global_quality = global_nshared;
624 global_quality =
static_cast<double>(global_nshared)/static_cast<double>(n_global_selected_simhits);
626 else global_quality = 0;
629 if (n_selected_hits != 0) {
631 global_purity = global_nshared;
633 global_purity =
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits);
635 else global_purity = 0;
637 bool trackerOk =
false;
638 if (n_tracker_selected_hits != 0) {
639 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
641 tracker_purity =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits);
651 if (n_muon_selected_hits != 0) {
652 if (muon_quality > muon_quality_cut) muonOk =
true;
654 muon_purity =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits);
661 bool matchOk = trackerOk || muonOk;
665 matchOk = trackerOk && muonOk;
669 outputCollection[tpindex].push_back(
IndexMatch(tindex,global_quality));
670 any_trackingParticle_matched =
true;
673 <<
"************************************************************************************************************************"
674 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
675 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
676 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
677 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits"
678 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")"
679 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
681 g4T!=(*trpart).g4Track_end();
684 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
687 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits"
688 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")"
689 <<
"\n\t **MATCHED** with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
690 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")"
691 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")"
692 <<
"\n" <<
" to: reco::Track "<<tindex<<ZeroHitMuon
693 <<
"\n\t"<<
" made of "<<n_selected_hits<<
" RecHits (tracker:"<<n_tracker_valid<<
"/muons:"<<n_muon_selected_hits<<
")";
697 if (global_nshared != 0) {
699 <<
"************************************************************************************************************************"
700 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
701 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
702 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
703 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits"
704 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")"
705 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
707 g4T!=(*trpart).g4Track_end();
710 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
713 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits"
714 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")"
715 <<
"\n\t NOT matched to reco::Track "<<tindex<<ZeroHitMuon
716 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
717 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")"
718 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
725 if (!any_trackingParticle_matched) {
728 <<
"************************************************************************************************************************"
729 <<
"\n NO TrackingParticle associated to ANY input reco::Track ! \n"
730 <<
"************************************************************************************************************************"<<
"\n";
733 <<
"************************************************************************************************************************"<<
"\n";
736 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
737 std::sort(it->second.begin(), it->second.end());
739 return outputCollection;
746 int& n_tracker_valid,
int& n_dt_valid,
int& n_csc_valid,
int& n_rpc_valid,
747 int& n_tracker_matched_valid,
int& n_dt_matched_valid,
int& n_csc_matched_valid,
int& n_rpc_matched_valid,
748 int& n_tracker_INVALID,
int& n_dt_INVALID,
int& n_csc_INVALID,
int& n_rpc_INVALID,
749 int& n_tracker_matched_INVALID,
int& n_dt_matched_INVALID,
int& n_csc_matched_INVALID,
int& n_rpc_matched_INVALID,
756 tracker_matchedIds_valid.clear();
757 muon_matchedIds_valid.clear();
759 tracker_matchedIds_INVALID.clear();
760 muon_matchedIds_INVALID.clear();
767 n_tracker_matched_valid = 0;
768 n_dt_matched_valid = 0;
769 n_csc_matched_valid = 0;
770 n_rpc_matched_valid = 0;
772 n_tracker_INVALID = 0;
777 n_tracker_matched_INVALID = 0;
778 n_dt_matched_INVALID = 0;
779 n_csc_matched_INVALID = 0;
780 n_rpc_matched_INVALID = 0;
782 std::vector<SimHitIdpr> SimTrackIds;
788 stringstream hit_index;
795 stringstream detector_id;
798 string hitlog =
"TrackingRecHit "+hit_index.str();
800 std::vector<string> DTSimHits;
805 bool valid_Hit = hitp->
isValid();
809 stringstream detector_id;
810 detector_id<< tTopo->
print(detid);
812 if (valid_Hit) hitlog = hitlog+
" -Tracker - detID = "+detector_id.str();
813 else hitlog = hitlog+
" *** INVALID ***"+
" -Tracker - detID = "+detector_id.str();
821 if(!SimTrackIds.empty()) {
822 n_tracker_matched_valid++;
829 if(!SimTrackIds.empty()) {
830 n_tracker_matched_INVALID++;
842 stringstream dt_detector_id;
843 dt_detector_id << dtdetid;
844 if (valid_Hit) hitlog = hitlog+
" -Muon DT - detID = "+dt_detector_id.str();
845 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon DT - detID = "+dt_detector_id.str();
857 if (!SimTrackIds.empty()) {
858 n_dt_matched_valid++;
865 if (!SimTrackIds.empty()) {
866 n_dt_matched_INVALID++;
876 std::vector<PSimHit> dtSimHits = dttruth.
associateHit(*hitp);
878 stringstream ndthits;
879 ndthits<<dtSimHits.size();
880 wireidlog =
"\t DTWireId :"+wid.str()+
", "+ndthits.str()+
" associated PSimHit :";
882 for (
unsigned int j=0;
j<dtSimHits.size();
j++) {
886 simhit<<dtSimHits[
j];
887 string simhitlog =
"\t\t PSimHit "+index.str()+
": "+simhit.str();
888 DTSimHits.push_back(simhitlog);
899 std::vector<const TrackingRecHit *> componentHits, phiHits, zHits;
900 if (dtsegment->
hasPhi()) {
902 componentHits.insert(componentHits.end(),phiHits.begin(),phiHits.end());
904 if (dtsegment->
hasZed()) {
906 componentHits.insert(componentHits.end(),zHits.begin(),zHits.end());
909 <<
"\n\t this TrackingRecHit is a DTRecSegment4D with "
910 <<componentHits.size()<<
" hits (phi:"<<phiHits.size()<<
", z:"<<zHits.size()<<
")";
912 std::vector<SimHitIdpr> i_SimTrackIds;
914 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
915 ithit != componentHits.end(); ++ithit) {
920 i_SimTrackIds.clear();
929 if (!i_SimTrackIds.empty()) {
930 n_dt_matched_valid++;
937 if (!i_SimTrackIds.empty()) {
938 n_dt_matched_INVALID++;
945 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a DT TrackingRecHit !";
947 unsigned int i_detid = (*ithit)->geographicalId().rawId();
950 stringstream i_dt_detector_id;
951 i_dt_detector_id << i_dtdetid;
954 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon DT - detID = "<<i_dt_detector_id.str();
956 string i_hitlog = i_ss.str();
957 i_hitlog = i_hitlog + write_matched_simtracks(i_SimTrackIds);
960 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
965 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, DT TrackingRecHit is neither DTRecHit1D nor DTRecSegment4D ! ";
972 stringstream csc_detector_id;
973 csc_detector_id << cscdetid;
974 if (valid_Hit) hitlog = hitlog+
" -Muon CSC- detID = "+csc_detector_id.str();
975 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon CSC- detID = "+csc_detector_id.str();
987 if (!SimTrackIds.empty()) {
988 n_csc_matched_valid++;
995 if (!SimTrackIds.empty()) {
996 n_csc_matched_INVALID++;
1009 std::vector<const TrackingRecHit *> componentHits = cscsegment->
recHits();
1011 <<
"\n\t this TrackingRecHit is a CSCSegment with "<<componentHits.size()<<
" hits";
1013 std::vector<SimHitIdpr> i_SimTrackIds;
1015 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
1016 ithit != componentHits.end(); ++ithit) {
1021 i_SimTrackIds.clear();
1030 if (!i_SimTrackIds.empty()) {
1031 n_csc_matched_valid++;
1038 if (!i_SimTrackIds.empty()) {
1039 n_csc_matched_INVALID++;
1045 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a CSC TrackingRecHit !";
1047 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1050 stringstream i_csc_detector_id;
1051 i_csc_detector_id << i_cscdetid;
1054 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon CSC- detID = "<<i_csc_detector_id.str();
1056 string i_hitlog = i_ss.str();
1057 i_hitlog = i_hitlog + write_matched_simtracks(i_SimTrackIds);
1060 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
1065 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, CSC TrackingRecHit is neither CSCRecHit2D nor CSCSegment ! ";
1072 stringstream rpc_detector_id;
1073 rpc_detector_id << rpcdetid;
1074 if (valid_Hit) hitlog = hitlog+
" -Muon RPC- detID = "+rpc_detector_id.str();
1075 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon RPC- detID = "+rpc_detector_id.str();
1083 if (!SimTrackIds.empty()) {
1084 n_rpc_matched_valid++;
1092 if (!SimTrackIds.empty()) {
1093 n_rpc_matched_INVALID++;
1100 <<
"TrackingRecHit "<<iloop<<
" *** WARNING *** Unexpected Hit from Detector = "<<det;
1104 hitlog = hitlog + write_matched_simtracks(SimTrackIds);
1109 for (
unsigned int j=0;
j<DTSimHits.size();
j++) {
1122 for (MapOfMatchedIds::const_iterator iRecH=matchedIds.begin(); iRecH!=matchedIds.end(); ++iRecH) {
1125 std::vector<SimHitIdpr>
const & SimTrackIds = (*iRecH).second;
1129 for (std::vector<SimHitIdpr>::const_iterator iSimH=SimTrackIds.begin(); iSimH!=SimTrackIds.end(); ++iSimH) {
1130 uint32_t simtrackId = iSimH->first;
1135 if (simtrack->trackId() == simtrackId && simtrack->eventId() == evtId) {
1152 if (SimTrackIds.empty())
1153 return " *** UNMATCHED ***";
1155 string hitlog(
" matched to SimTrack");
1157 for(
size_t j=0;
j<SimTrackIds.size();
j++)
1160 snprintf(buf, 64,
" Id:%i/Evt:(%i,%i) ", SimTrackIds[
j].
first, SimTrackIds[
j].
second.event(), SimTrackIds[
j].second.bunchCrossing());
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_tracker_matched_valid, int &n_dt_matched_valid, int &n_csc_matched_valid, int &n_rpc_matched_valid, int &n_tracker_INVALID, int &n_dt_INVALID, int &n_csc_INVALID, int &n_rpc_INVALID, int &n_tracker_matched_INVALID, int &n_dt_matched_INVALID, int &n_csc_matched_INVALID, int &n_rpc_matched_INVALID, trackingRecHit_iterator begin, trackingRecHit_iterator end, const TrackerHitAssociator *trackertruth, const DTHitAssociator &dttruth, const CSCHitAssociator &csctruth, const RPCHitAssociator &rpctruth, bool printRts, const TrackerTopology *) const
std::vector< TrackingParticle > TrackingParticleCollection
unsigned int NHitCut_muon
std::string dump(unsigned int indent=0) const
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
RPCHitAssociator const * rpcHitAssoc_
TrackerHitAssociator const * trackerHitAssoc_
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
uint32_t rawId() const
get the raw id
const bool AbsoluteNumberOfHits_muon
U second(std::pair< T, U > const &p)
std::vector< SimHitIdpr > associateRecHit(const TrackingRecHit &hit) const
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
MuonAssociatorByHitsHelper(const edm::ParameterSet &conf)
CSCHitAssociator const * cscHitAssoc_
unsigned int NHitCut_track
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
std::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)> diagnostics_
bool hasPhi() const
Does it have the Phi projection?
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
const bool AbsoluteNumberOfHits_track
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::pair< unsigned int, std::vector< SimHitIdpr > > uint_SimHitIdpr_pair
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
boost::ptr_vector< uint_SimHitIdpr_pair > MapOfMatchedIds
size_type size() const
Size of the RefVector.
DetId geographicalId() const
double EfficiencyCut_muon
Detector det() const
get the detector field from this detid
std::vector< SimHitIdpr > associateDTHitId(const DTRecHit1D *dtrechit) const
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
const bool includeZeroHitMuons
DTWireId wireId() const
Return the wireId.