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_;
70 int tracker_nshared = 0;
72 int global_nshared = 0;
74 double tracker_quality = 0;
75 double tracker_quality_cut;
79 double muon_quality = 0;
80 double muon_quality_cut;
84 double global_quality = 0;
93 tPC.reserve(TPCollectionH.
size());
94 for(
auto const& ref: TPCollectionH) {
103 for (TrackHitsCollection::const_iterator
track=tC.begin();
track!=tC.end();
track++, tindex++) {
105 <<
"\n"<<
"reco::Track "<<tindex
106 <<
", number of RecHits = "<< (
track->second -
track->first) <<
"\n";
107 tracker_matchedIds_valid.clear();
108 muon_matchedIds_valid.clear();
110 tracker_matchedIds_INVALID.clear();
111 muon_matchedIds_INVALID.clear();
113 bool this_track_matched =
false;
114 int n_matching_simhits = 0;
118 int n_tracker_all = 0;
125 int n_tracker_valid = 0;
126 int n_muon_valid = 0;
132 int n_tracker_matched_valid = 0;
133 int n_muon_matched_valid = 0;
134 int n_dt_matched_valid = 0;
135 int n_csc_matched_valid = 0;
136 int n_rpc_matched_valid = 0;
137 int n_gem_matched_valid = 0;
140 int n_tracker_INVALID = 0;
141 int n_muon_INVALID = 0;
142 int n_dt_INVALID = 0;
143 int n_csc_INVALID = 0;
144 int n_rpc_INVALID = 0;
145 int n_gem_INVALID = 0;
147 int n_tracker_matched_INVALID = 0;
148 int n_muon_matched_INVALID = 0;
149 int n_dt_matched_INVALID = 0;
150 int n_csc_matched_INVALID = 0;
151 int n_rpc_matched_INVALID = 0;
152 int n_gem_matched_INVALID = 0;
155 getMatchedIds(tracker_matchedIds_valid, muon_matchedIds_valid,
156 tracker_matchedIds_INVALID, muon_matchedIds_INVALID,
157 n_tracker_valid, n_dt_valid, n_csc_valid, n_rpc_valid, n_gem_valid,
158 n_tracker_matched_valid, n_dt_matched_valid, n_csc_matched_valid, n_rpc_matched_valid, n_gem_matched_valid,
159 n_tracker_INVALID, n_dt_INVALID, n_csc_INVALID, n_rpc_INVALID, n_gem_INVALID,
160 n_tracker_matched_INVALID, n_dt_matched_INVALID, n_csc_matched_INVALID, n_rpc_matched_INVALID, n_gem_matched_INVALID,
162 trackertruth, dttruth, csctruth, rpctruth, gemtruth,
165 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
166 tracker_matchedIds_INVALID.size() +muon_matchedIds_INVALID.size();
168 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid + n_gem_valid;
169 n_valid = n_tracker_valid + n_muon_valid;
170 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID + n_gem_INVALID;
171 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
174 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
175 n_dt_all = n_dt_valid + n_dt_INVALID;
176 n_csc_all = n_csc_valid + n_csc_INVALID;
177 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
178 n_gem_all = n_gem_valid + n_gem_INVALID;
179 n_all = n_valid + n_INVALID;
181 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid + n_gem_matched_valid;
182 n_muon_matched_INVALID = n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID + n_gem_matched_INVALID;
185 int n_tracker_selected_hits = n_tracker_valid;
186 int n_muon_selected_hits = n_muon_valid;
187 int n_dt_selected_hits = n_dt_valid;
188 int n_csc_selected_hits = n_csc_valid;
189 int n_rpc_selected_hits = n_rpc_valid;
190 int n_gem_selected_hits = n_gem_valid;
193 int n_tracker_matched = n_tracker_matched_valid;
194 int n_muon_matched = n_muon_matched_valid;
195 int n_dt_matched = n_dt_matched_valid;
196 int n_csc_matched = n_csc_matched_valid;
197 int n_rpc_matched = n_rpc_matched_valid;
198 int n_gem_matched = n_gem_matched_valid;
205 InvMuonHits =
" ***INVALID MUON HITS***";
206 ZeroHitMuon =
" ***ZERO-HIT MUON***";
208 n_muon_selected_hits = n_muon_INVALID;
209 n_dt_selected_hits = n_dt_INVALID;
210 n_csc_selected_hits = n_csc_INVALID;
211 n_rpc_selected_hits = n_rpc_INVALID;
212 n_gem_selected_hits = n_gem_INVALID;
214 n_muon_matched = n_muon_matched_INVALID;
215 n_dt_matched = n_dt_matched_INVALID;
216 n_csc_matched = n_csc_matched_INVALID;
217 n_rpc_matched = n_rpc_matched_INVALID;
218 n_gem_matched = n_gem_matched_INVALID;
221 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
222 int n_matched = n_tracker_matched + n_muon_matched;
225 <<
"\n"<<
"# TrackingRecHits: "<<(
track->second -
track->first)
226 <<
"\n"<<
"# used RecHits = " << n_all <<
" ("<<n_tracker_all<<
"/" 227 <<n_dt_all<<
"/"<<n_csc_all<<
"/"<<n_rpc_all<<
"/"<<n_gem_all<<
" in Tracker/DT/CSC/RPC/GEM)"<<
", obtained from " << n_matching_simhits <<
" SimHits" 228 <<
"\n"<<
"# selected RecHits = " <<n_selected_hits <<
" (" <<n_tracker_selected_hits<<
"/" 229 <<n_dt_selected_hits<<
"/"<<n_csc_selected_hits<<
"/"<<n_rpc_selected_hits<<
"/"<<n_gem_selected_hits<<
" in Tracker/DT/CSC/RPC/GEM)"<<InvMuonHits
230 <<
"\n"<<
"# matched RecHits = " <<n_matched<<
" ("<<n_tracker_matched<<
"/" 231 <<n_dt_matched<<
"/"<<n_csc_matched<<
"/"<<n_rpc_matched<<
"/"<<n_gem_matched<<
" in Tracker/DT/CSC/RPC/GEM)";
233 if (n_all>0 && n_matching_simhits == 0)
235 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateRecoToSim: no matching PSimHit found for this reco::Track !";
237 if (n_matching_simhits != 0) {
239 <<
"\n"<<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" 240 <<
"\n"<<
"reco::Track "<<tindex<<ZeroHitMuon
241 <<
"\n\t"<<
"made of "<<n_selected_hits<<
" selected RecHits (tracker:"<<n_tracker_selected_hits<<
"/muons:"<<n_muon_selected_hits<<
")";
244 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
245 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
246 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
249 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
251 global_nshared = tracker_nshared + muon_nshared;
254 else if(n_tracker_selected_hits != 0) tracker_quality = (
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits));
255 else tracker_quality = 0;
258 else if(n_muon_selected_hits != 0) muon_quality = (
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits));
259 else muon_quality = 0;
262 if (n_selected_hits != 0) {
264 global_quality = global_nshared;
266 global_quality = (
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits));
267 }
else global_quality = 0;
269 bool trackerOk =
false;
270 if (n_tracker_selected_hits != 0) {
271 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
277 if (n_muon_selected_hits != 0) {
278 if (muon_quality > muon_quality_cut) muonOk =
true;
282 bool matchOk = trackerOk || muonOk;
286 matchOk = trackerOk && muonOk;
290 outputCollection[tindex].push_back(
IndexMatch(tpindex, global_quality));
291 this_track_matched =
true;
294 <<
"\n\t"<<
" **MATCHED** with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")" 295 <<
"\n\t"<<
" N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")" 296 <<
"\n"<<
" to: TrackingParticle " <<tpindex<<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
297 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
298 <<
"\n\t"<<
" pdg code = "<<(*trpart).pdgId()<<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits" 299 <<
" from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
301 g4T!=(*trpart).g4Track_end();
304 <<
"\t"<<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
309 if (global_nshared != 0)
311 <<
"\n\t"<<
" NOT matched to TrackingParticle "<<tpindex
312 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")" 313 <<
"\n"<<
" N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
318 if (!this_track_matched) {
320 <<
"\n"<<
" NOT matched to any TrackingParticle";
324 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<
"\n";
331 edm::LogVerbatim(
"MuonAssociatorByHitsHelper")<<
"0 reconstructed tracks (-->> 0 associated !)";
333 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
334 std::sort(it->second.begin(), it->second.end());
336 return outputCollection;
344 auto tTopo = resources.
tTopo_;
351 int tracker_nshared = 0;
352 int muon_nshared = 0;
353 int global_nshared = 0;
355 double tracker_quality = 0;
356 double tracker_quality_cut;
360 double muon_quality = 0;
361 double muon_quality_cut;
365 double global_quality = 0;
367 double tracker_purity = 0;
368 double muon_purity = 0;
369 double global_purity = 0;
380 tPC.reserve(TPCollectionH.
size());
381 for(
auto const& ref: TPCollectionH) {
385 bool any_trackingParticle_matched =
false;
388 for (TrackHitsCollection::const_iterator
track=tC.begin();
track!=tC.end();
track++, tindex++) {
390 <<
"\n"<<
"reco::Track "<<tindex
391 <<
", number of RecHits = "<< (
track->second -
track->first) <<
"\n";
393 tracker_matchedIds_valid.clear();
394 muon_matchedIds_valid.clear();
396 tracker_matchedIds_INVALID.clear();
397 muon_matchedIds_INVALID.clear();
399 int n_matching_simhits = 0;
403 int n_tracker_all = 0;
410 int n_tracker_valid = 0;
411 int n_muon_valid = 0;
417 int n_tracker_matched_valid = 0;
418 int n_muon_matched_valid = 0;
419 int n_dt_matched_valid = 0;
420 int n_csc_matched_valid = 0;
421 int n_rpc_matched_valid = 0;
422 int n_gem_matched_valid = 0;
425 int n_tracker_INVALID = 0;
426 int n_muon_INVALID = 0;
427 int n_dt_INVALID = 0;
428 int n_csc_INVALID = 0;
429 int n_rpc_INVALID = 0;
430 int n_gem_INVALID = 0;
432 int n_tracker_matched_INVALID = 0;
433 int n_muon_matched_INVALID = 0;
434 int n_dt_matched_INVALID = 0;
435 int n_csc_matched_INVALID = 0;
436 int n_rpc_matched_INVALID = 0;
437 int n_gem_matched_INVALID = 0;
440 getMatchedIds(tracker_matchedIds_valid, muon_matchedIds_valid,
441 tracker_matchedIds_INVALID, muon_matchedIds_INVALID,
442 n_tracker_valid, n_dt_valid, n_csc_valid, n_rpc_valid, n_gem_valid,
443 n_tracker_matched_valid, n_dt_matched_valid, n_csc_matched_valid, n_rpc_matched_valid, n_gem_matched_valid,
444 n_tracker_INVALID, n_dt_INVALID, n_csc_INVALID, n_rpc_INVALID, n_gem_INVALID,
445 n_tracker_matched_INVALID, n_dt_matched_INVALID, n_csc_matched_INVALID, n_rpc_matched_INVALID, n_gem_matched_INVALID,
447 trackertruth, dttruth, csctruth, rpctruth, gemtruth,
450 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
451 tracker_matchedIds_INVALID.size() +muon_matchedIds_INVALID.size();
453 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid + n_gem_valid;
454 n_valid = n_tracker_valid + n_muon_valid;
455 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID + n_gem_INVALID;
456 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
459 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
460 n_dt_all = n_dt_valid + n_dt_INVALID;
461 n_csc_all = n_csc_valid + n_csc_INVALID;
462 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
463 n_gem_all = n_gem_valid + n_gem_INVALID;
464 n_all = n_valid + n_INVALID;
466 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid + n_gem_matched_valid;
467 n_muon_matched_INVALID = n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID + n_gem_matched_INVALID;
470 int n_tracker_selected_hits = n_tracker_valid;
471 int n_muon_selected_hits = n_muon_valid;
472 int n_dt_selected_hits = n_dt_valid;
473 int n_csc_selected_hits = n_csc_valid;
474 int n_rpc_selected_hits = n_rpc_valid;
475 int n_gem_selected_hits = n_gem_valid;
478 int n_tracker_matched = n_tracker_matched_valid;
479 int n_muon_matched = n_muon_matched_valid;
480 int n_dt_matched = n_dt_matched_valid;
481 int n_csc_matched = n_csc_matched_valid;
482 int n_rpc_matched = n_rpc_matched_valid;
483 int n_gem_matched = n_gem_matched_valid;
490 InvMuonHits =
" ***INVALID MUON HITS***";
491 ZeroHitMuon =
" ***ZERO-HIT MUON***";
493 n_muon_selected_hits = n_muon_INVALID;
494 n_dt_selected_hits = n_dt_INVALID;
495 n_csc_selected_hits = n_csc_INVALID;
496 n_rpc_selected_hits = n_rpc_INVALID;
497 n_gem_selected_hits = n_gem_INVALID;
499 n_muon_matched = n_muon_matched_INVALID;
500 n_dt_matched = n_dt_matched_INVALID;
501 n_csc_matched = n_csc_matched_INVALID;
502 n_rpc_matched = n_rpc_matched_INVALID;
503 n_gem_matched = n_gem_matched_INVALID;
506 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
507 int n_matched = n_tracker_matched + n_muon_matched;
510 <<
"\n"<<
"# TrackingRecHits: "<<(
track->second -
track->first)
511 <<
"\n"<<
"# used RecHits = " <<n_all <<
" ("<<n_tracker_all<<
"/" 512 <<n_dt_all<<
"/"<<n_csc_all<<
"/"<<n_rpc_all<<
"/"<<n_gem_all<<
" in Tracker/DT/CSC/RPC/GEM)"<<
", obtained from " << n_matching_simhits <<
" SimHits" 513 <<
"\n"<<
"# selected RecHits = " <<n_selected_hits <<
" (" <<n_tracker_selected_hits<<
"/" 514 <<n_dt_selected_hits<<
"/"<<n_csc_selected_hits<<
"/"<<n_rpc_selected_hits<<
"/"<<n_gem_selected_hits<<
" in Tracker/DT/CSC/RPC/GEM)"<<InvMuonHits
515 <<
"\n"<<
"# matched RecHits = " <<n_matched<<
" ("<<n_tracker_matched<<
"/" 516 <<n_dt_matched<<
"/"<<n_csc_matched<<
"/"<<n_rpc_matched<<
"/"<<n_gem_matched<<
" in Tracker/DT/CSC/RPC/GEM)";
518 if (printRtS && n_all>0 && n_matching_simhits==0)
520 <<
"*** WARNING in MuonAssociatorByHitsHelper::associateSimToReco: no matching PSimHit found for this reco::Track !";
522 if (n_matching_simhits != 0) {
524 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
527 int n_tracker_recounted_simhits = 0;
528 int n_muon_simhits = 0;
529 int n_global_simhits = 0;
532 int n_tracker_selected_simhits = 0;
533 int n_muon_selected_simhits = 0;
534 int n_global_selected_simhits = 0;
537 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
538 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
541 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
543 global_nshared = tracker_nshared + muon_nshared;
544 if (global_nshared == 0)
continue;
610 n_tracker_recounted_simhits = trpart->numberOfTrackerHits();
612 n_muon_simhits = trpart->numberOfHits() - trpart->numberOfTrackerHits();
615 if (trpart->numberOfHits()==0) {
622 n_tracker_recounted_simhits = 1;
625 n_global_simhits = n_tracker_recounted_simhits + n_muon_simhits;
628 n_muon_selected_simhits = n_muon_simhits;
629 n_global_selected_simhits = n_muon_selected_simhits;
632 n_tracker_selected_simhits = n_tracker_recounted_simhits;
633 n_global_selected_simhits += n_tracker_selected_simhits;
637 else if (n_tracker_selected_simhits!=0)
638 tracker_quality =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_simhits);
639 else tracker_quality = 0;
642 else if (n_muon_selected_simhits!=0)
643 muon_quality =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_simhits);
644 else muon_quality = 0;
647 if (n_global_selected_simhits != 0) {
649 global_quality = global_nshared;
651 global_quality =
static_cast<double>(global_nshared)/static_cast<double>(n_global_selected_simhits);
653 else global_quality = 0;
656 if (n_selected_hits != 0) {
658 global_purity = global_nshared;
660 global_purity =
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits);
662 else global_purity = 0;
664 bool trackerOk =
false;
665 if (n_tracker_selected_hits != 0) {
666 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
668 tracker_purity =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits);
678 if (n_muon_selected_hits != 0) {
679 if (muon_quality > muon_quality_cut) muonOk =
true;
681 muon_purity =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits);
688 bool matchOk = trackerOk || muonOk;
692 matchOk = trackerOk && muonOk;
696 outputCollection[tpindex].push_back(
IndexMatch(tindex,global_quality));
697 any_trackingParticle_matched =
true;
700 <<
"************************************************************************************************************************" 701 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
702 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
703 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
704 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits" 705 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")" 706 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
708 g4T!=(*trpart).g4Track_end();
711 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
714 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits" 715 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")" 716 <<
"\n\t **MATCHED** 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<<
")" 719 <<
"\n" <<
" to: reco::Track "<<tindex<<ZeroHitMuon
720 <<
"\n\t"<<
" made of "<<n_selected_hits<<
" RecHits (tracker:"<<n_tracker_valid<<
"/muons:"<<n_muon_selected_hits<<
")";
724 if (global_nshared != 0) {
726 <<
"************************************************************************************************************************" 727 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
728 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
729 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
730 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits" 731 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")" 732 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
734 g4T!=(*trpart).g4Track_end();
737 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
740 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits" 741 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")" 742 <<
"\n\t NOT matched to reco::Track "<<tindex<<ZeroHitMuon
743 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")" 744 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")" 745 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
752 if (!any_trackingParticle_matched) {
755 <<
"************************************************************************************************************************" 756 <<
"\n NO TrackingParticle associated to ANY input reco::Track ! \n" 757 <<
"************************************************************************************************************************"<<
"\n";
760 <<
"************************************************************************************************************************"<<
"\n";
763 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
764 std::sort(it->second.begin(), it->second.end());
766 return outputCollection;
773 int& n_tracker_valid,
int& n_dt_valid,
int& n_csc_valid,
int& n_rpc_valid,
int& n_gem_valid,
774 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,
775 int& n_tracker_INVALID,
int& n_dt_INVALID,
int& n_csc_INVALID,
int& n_rpc_INVALID,
int& n_gem_INVALID,
776 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,
783 tracker_matchedIds_valid.clear();
784 muon_matchedIds_valid.clear();
786 tracker_matchedIds_INVALID.clear();
787 muon_matchedIds_INVALID.clear();
795 n_tracker_matched_valid = 0;
796 n_dt_matched_valid = 0;
797 n_csc_matched_valid = 0;
798 n_rpc_matched_valid = 0;
799 n_gem_matched_valid = 0;
801 n_tracker_INVALID = 0;
807 n_tracker_matched_INVALID = 0;
808 n_dt_matched_INVALID = 0;
809 n_csc_matched_INVALID = 0;
810 n_rpc_matched_INVALID = 0;
811 n_gem_matched_INVALID = 0;
813 std::vector<SimHitIdpr> SimTrackIds;
819 stringstream hit_index;
825 unsigned int detid = geoid.
rawId();
826 stringstream detector_id;
829 string hitlog =
"TrackingRecHit "+hit_index.str();
831 std::vector<string> DTSimHits;
836 bool valid_Hit = hitp->
isValid();
840 stringstream detector_id;
841 detector_id<< tTopo->
print(detid);
843 if (valid_Hit) hitlog = hitlog+
" -Tracker - detID = "+detector_id.str();
844 else hitlog = hitlog+
" *** INVALID ***"+
" -Tracker - detID = "+detector_id.str();
852 if(!SimTrackIds.empty()) {
853 n_tracker_matched_valid++;
860 if(!SimTrackIds.empty()) {
861 n_tracker_matched_INVALID++;
873 stringstream dt_detector_id;
874 dt_detector_id << dtdetid;
875 if (valid_Hit) hitlog = hitlog+
" -Muon DT - detID = "+dt_detector_id.str();
876 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon DT - detID = "+dt_detector_id.str();
888 if (!SimTrackIds.empty()) {
889 n_dt_matched_valid++;
896 if (!SimTrackIds.empty()) {
897 n_dt_matched_INVALID++;
907 std::vector<PSimHit> dtSimHits = dttruth.
associateHit(*hitp);
909 stringstream ndthits;
910 ndthits<<dtSimHits.size();
911 wireidlog =
"\t DTWireId :"+wid.str()+
", "+ndthits.str()+
" associated PSimHit :";
913 for (
unsigned int j=0; j<dtSimHits.size(); j++) {
917 simhit<<dtSimHits[j];
918 string simhitlog =
"\t\t PSimHit "+index.str()+
": "+simhit.str();
919 DTSimHits.push_back(simhitlog);
930 std::vector<const TrackingRecHit *> componentHits, phiHits, zHits;
931 if (dtsegment->
hasPhi()) {
933 componentHits.insert(componentHits.end(),phiHits.begin(),phiHits.end());
935 if (dtsegment->
hasZed()) {
937 componentHits.insert(componentHits.end(),zHits.begin(),zHits.end());
940 <<
"\n\t this TrackingRecHit is a DTRecSegment4D with " 941 <<componentHits.size()<<
" hits (phi:"<<phiHits.size()<<
", z:"<<zHits.size()<<
")";
944 std::vector<SimHitIdpr> i_SimTrackIds;
946 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
947 ithit != componentHits.end(); ++ithit) {
952 i_SimTrackIds.clear();
961 if (!i_SimTrackIds.empty()) {
962 n_dt_matched_valid++;
969 if (!i_SimTrackIds.empty()) {
970 n_dt_matched_INVALID++;
977 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a DT TrackingRecHit !";
979 unsigned int i_detid = (*ithit)->geographicalId().rawId();
982 stringstream i_dt_detector_id;
983 i_dt_detector_id << i_dtdetid;
986 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon DT - detID = "<<i_dt_detector_id.str();
988 string i_hitlog = i_ss.str();
992 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
997 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, DT TrackingRecHit is neither DTRecHit1D nor DTRecSegment4D ! ";
1004 stringstream csc_detector_id;
1005 csc_detector_id << cscdetid;
1006 if (valid_Hit) hitlog = hitlog+
" -Muon CSC- detID = "+csc_detector_id.str();
1007 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon CSC- detID = "+csc_detector_id.str();
1019 if (!SimTrackIds.empty()) {
1020 n_csc_matched_valid++;
1027 if (!SimTrackIds.empty()) {
1028 n_csc_matched_INVALID++;
1041 std::vector<const TrackingRecHit *> componentHits = cscsegment->
recHits();
1043 <<
"\n\t this TrackingRecHit is a CSCSegment with "<<componentHits.size()<<
" hits";
1045 SimTrackIds.clear();
1046 std::vector<SimHitIdpr> i_SimTrackIds;
1048 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
1049 ithit != componentHits.end(); ++ithit) {
1054 i_SimTrackIds.clear();
1063 if (!i_SimTrackIds.empty()) {
1064 n_csc_matched_valid++;
1071 if (!i_SimTrackIds.empty()) {
1072 n_csc_matched_INVALID++;
1078 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a CSC TrackingRecHit !";
1080 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1083 stringstream i_csc_detector_id;
1084 i_csc_detector_id << i_cscdetid;
1087 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon CSC- detID = "<<i_csc_detector_id.str();
1089 string i_hitlog = i_ss.str();
1093 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
1098 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, CSC TrackingRecHit is neither CSCRecHit2D nor CSCSegment ! ";
1105 stringstream rpc_detector_id;
1106 rpc_detector_id << rpcdetid;
1107 if (valid_Hit) hitlog = hitlog+
" -Muon RPC- detID = "+rpc_detector_id.str();
1108 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon RPC- detID = "+rpc_detector_id.str();
1116 if (!SimTrackIds.empty()) {
1117 n_rpc_matched_valid++;
1125 if (!SimTrackIds.empty()) {
1126 n_rpc_matched_INVALID++;
1136 stringstream gem_detector_id;
1137 gem_detector_id << gemdetid;
1138 if (valid_Hit) hitlog = hitlog+
" -Muon GEM- detID = "+gem_detector_id.str();
1139 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon GEM- detID = "+gem_detector_id.str();
1149 if (!SimTrackIds.empty()) {
1150 n_gem_matched_valid++;
1158 if (!SimTrackIds.empty()) {
1159 n_gem_matched_INVALID++;
1169 std::vector<const TrackingRecHit *> componentHits = gemsegment->
recHits();
1171 <<
"\n\t this TrackingRecHit is a GEMSegment with "<<componentHits.size()<<
" hits";
1173 SimTrackIds.clear();
1174 std::vector<SimHitIdpr> i_SimTrackIds;
1177 for (
auto const & ithit : componentHits) {
1183 i_SimTrackIds.clear();
1192 if (!i_SimTrackIds.empty()) {
1193 n_gem_matched_valid++;
1200 if (!i_SimTrackIds.empty()) {
1201 n_gem_matched_INVALID++;
1207 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a GEM TrackingRecHit !";
1210 unsigned int i_detid = ithit->geographicalId().rawId();
1213 string i_hitlog = std::to_string(i_gemdetid);
1218 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
1225 <<
"TrackingRecHit "<<iloop<<
" *** WARNING *** Unexpected Hit from Detector = "<<det;
1234 for (
unsigned int j=0; j<DTSimHits.size(); j++) {
1245 const std::vector<SimTrack>& g4Tracks = trpart->g4Tracks();
1248 for (MapOfMatchedIds::const_iterator iRecH=matchedIds.begin(); iRecH!=matchedIds.end(); ++iRecH) {
1251 std::vector<SimHitIdpr>
const & SimTrackIds = (*iRecH).second;
1255 for (
const auto& iSimH : SimTrackIds) {
1257 uint32_t simtrackId = iSimH.first;
1261 for (
const auto& simtrack : g4Tracks) {
1263 if (simtrack.trackId() == simtrackId && simtrack.eventId() == evtId) {
1280 if (SimTrackIds.empty())
1281 return " *** UNMATCHED ***";
1283 string hitlog(
" matched to SimTrack");
1285 for(
size_t j=0; j<SimTrackIds.size(); j++)
1288 snprintf(buf, 64,
" Id:%i/Evt:(%i,%i) ", SimTrackIds[j].
first, SimTrackIds[j].
second.event(), SimTrackIds[j].second.bunchCrossing());
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
constexpr uint32_t rawId() const
get the raw id
RPCHitAssociator const * rpcHitAssoc_
TrackerHitAssociator const * trackerHitAssoc_
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::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
MuonAssociatorByHitsHelper(const edm::ParameterSet &conf)
AbsoluteNumberOfHits_track
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::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)> diagnostics_
bool hasPhi() const
Does it have the Phi projection?
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::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
std::vector< SimHitIdpr > associateRecHit(const GEMRecHit *gemrechit) const
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
const TrackingRecHit * getHitPtr(edm::OwnVector< TrackingRecHit >::const_iterator iter) const
size_type size() const
Size of the RefVector.
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
AbsoluteNumberOfHits_muon
DetId geographicalId() const
double EfficiencyCut_muon
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
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.