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_;
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,
161 track->first, track->second,
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,
446 track->first, track->second,
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) {
617 n_tracker_recounted_simhits = tracker_nshared;
618 n_muon_simhits = muon_nshared;
620 n_global_simhits = n_tracker_recounted_simhits + n_muon_simhits;
623 n_muon_selected_simhits = n_muon_simhits;
624 n_global_selected_simhits = n_muon_selected_simhits;
627 n_tracker_selected_simhits = n_tracker_recounted_simhits;
628 n_global_selected_simhits += n_tracker_selected_simhits;
632 else if (n_tracker_selected_simhits!=0)
633 tracker_quality =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_simhits);
634 else tracker_quality = 0;
637 else if (n_muon_selected_simhits!=0)
638 muon_quality =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_simhits);
639 else muon_quality = 0;
642 if (n_global_selected_simhits != 0) {
644 global_quality = global_nshared;
646 global_quality =
static_cast<double>(global_nshared)/static_cast<double>(n_global_selected_simhits);
648 else global_quality = 0;
651 if (n_selected_hits != 0) {
653 global_purity = global_nshared;
655 global_purity =
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits);
657 else global_purity = 0;
659 bool trackerOk =
false;
660 if (n_tracker_selected_hits != 0) {
661 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
663 tracker_purity =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits);
673 if (n_muon_selected_hits != 0) {
674 if (muon_quality > muon_quality_cut) muonOk =
true;
676 muon_purity =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits);
683 bool matchOk = trackerOk || muonOk;
687 matchOk = trackerOk && muonOk;
691 outputCollection[tpindex].push_back(
IndexMatch(tindex,global_quality));
692 any_trackingParticle_matched =
true;
695 <<
"************************************************************************************************************************"
696 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
697 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
698 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
699 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits"
700 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")"
701 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
703 g4T!=(*trpart).g4Track_end();
706 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
709 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits"
710 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")"
711 <<
"\n\t **MATCHED** with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
712 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")"
713 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")"
714 <<
"\n" <<
" to: reco::Track "<<tindex<<ZeroHitMuon
715 <<
"\n\t"<<
" made of "<<n_selected_hits<<
" RecHits (tracker:"<<n_tracker_valid<<
"/muons:"<<n_muon_selected_hits<<
")";
719 if (global_nshared != 0) {
721 <<
"************************************************************************************************************************"
722 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
723 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
724 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
725 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits"
726 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")"
727 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
729 g4T!=(*trpart).g4Track_end();
732 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
735 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits"
736 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")"
737 <<
"\n\t NOT matched to reco::Track "<<tindex<<ZeroHitMuon
738 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
739 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")"
740 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
747 if (!any_trackingParticle_matched) {
750 <<
"************************************************************************************************************************"
751 <<
"\n NO TrackingParticle associated to ANY input reco::Track ! \n"
752 <<
"************************************************************************************************************************"<<
"\n";
755 <<
"************************************************************************************************************************"<<
"\n";
758 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
759 std::sort(it->second.begin(), it->second.end());
761 return outputCollection;
768 int& n_tracker_valid,
int& n_dt_valid,
int& n_csc_valid,
int& n_rpc_valid,
int& n_gem_valid,
769 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,
770 int& n_tracker_INVALID,
int& n_dt_INVALID,
int& n_csc_INVALID,
int& n_rpc_INVALID,
int& n_gem_INVALID,
771 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,
778 tracker_matchedIds_valid.clear();
779 muon_matchedIds_valid.clear();
781 tracker_matchedIds_INVALID.clear();
782 muon_matchedIds_INVALID.clear();
790 n_tracker_matched_valid = 0;
791 n_dt_matched_valid = 0;
792 n_csc_matched_valid = 0;
793 n_rpc_matched_valid = 0;
794 n_gem_matched_valid = 0;
796 n_tracker_INVALID = 0;
802 n_tracker_matched_INVALID = 0;
803 n_dt_matched_INVALID = 0;
804 n_csc_matched_INVALID = 0;
805 n_rpc_matched_INVALID = 0;
806 n_gem_matched_INVALID = 0;
808 std::vector<SimHitIdpr> SimTrackIds;
814 stringstream hit_index;
820 unsigned int detid = geoid.
rawId();
821 stringstream detector_id;
824 string hitlog =
"TrackingRecHit "+hit_index.str();
826 std::vector<string> DTSimHits;
831 bool valid_Hit = hitp->
isValid();
835 stringstream detector_id;
836 detector_id<< tTopo->
print(detid);
838 if (valid_Hit) hitlog = hitlog+
" -Tracker - detID = "+detector_id.str();
839 else hitlog = hitlog+
" *** INVALID ***"+
" -Tracker - detID = "+detector_id.str();
847 if(!SimTrackIds.empty()) {
848 n_tracker_matched_valid++;
855 if(!SimTrackIds.empty()) {
856 n_tracker_matched_INVALID++;
868 stringstream dt_detector_id;
869 dt_detector_id << dtdetid;
870 if (valid_Hit) hitlog = hitlog+
" -Muon DT - detID = "+dt_detector_id.str();
871 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon DT - detID = "+dt_detector_id.str();
883 if (!SimTrackIds.empty()) {
884 n_dt_matched_valid++;
891 if (!SimTrackIds.empty()) {
892 n_dt_matched_INVALID++;
902 std::vector<PSimHit> dtSimHits = dttruth.
associateHit(*hitp);
904 stringstream ndthits;
905 ndthits<<dtSimHits.size();
906 wireidlog =
"\t DTWireId :"+wid.str()+
", "+ndthits.str()+
" associated PSimHit :";
908 for (
unsigned int j=0;
j<dtSimHits.size();
j++) {
912 simhit<<dtSimHits[
j];
913 string simhitlog =
"\t\t PSimHit "+index.str()+
": "+simhit.str();
914 DTSimHits.push_back(simhitlog);
925 std::vector<const TrackingRecHit *> componentHits, phiHits, zHits;
926 if (dtsegment->
hasPhi()) {
928 componentHits.insert(componentHits.end(),phiHits.begin(),phiHits.end());
930 if (dtsegment->
hasZed()) {
932 componentHits.insert(componentHits.end(),zHits.begin(),zHits.end());
935 <<
"\n\t this TrackingRecHit is a DTRecSegment4D with "
936 <<componentHits.size()<<
" hits (phi:"<<phiHits.size()<<
", z:"<<zHits.size()<<
")";
938 std::vector<SimHitIdpr> i_SimTrackIds;
940 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
941 ithit != componentHits.end(); ++ithit) {
946 i_SimTrackIds.clear();
955 if (!i_SimTrackIds.empty()) {
956 n_dt_matched_valid++;
963 if (!i_SimTrackIds.empty()) {
964 n_dt_matched_INVALID++;
971 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a DT TrackingRecHit !";
973 unsigned int i_detid = (*ithit)->geographicalId().rawId();
976 stringstream i_dt_detector_id;
977 i_dt_detector_id << i_dtdetid;
980 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon DT - detID = "<<i_dt_detector_id.str();
982 string i_hitlog = i_ss.str();
983 i_hitlog = i_hitlog + write_matched_simtracks(i_SimTrackIds);
986 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
991 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, DT TrackingRecHit is neither DTRecHit1D nor DTRecSegment4D ! ";
998 stringstream csc_detector_id;
999 csc_detector_id << cscdetid;
1000 if (valid_Hit) hitlog = hitlog+
" -Muon CSC- detID = "+csc_detector_id.str();
1001 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon CSC- detID = "+csc_detector_id.str();
1013 if (!SimTrackIds.empty()) {
1014 n_csc_matched_valid++;
1021 if (!SimTrackIds.empty()) {
1022 n_csc_matched_INVALID++;
1035 std::vector<const TrackingRecHit *> componentHits = cscsegment->
recHits();
1037 <<
"\n\t this TrackingRecHit is a CSCSegment with "<<componentHits.size()<<
" hits";
1039 std::vector<SimHitIdpr> i_SimTrackIds;
1041 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
1042 ithit != componentHits.end(); ++ithit) {
1047 i_SimTrackIds.clear();
1056 if (!i_SimTrackIds.empty()) {
1057 n_csc_matched_valid++;
1064 if (!i_SimTrackIds.empty()) {
1065 n_csc_matched_INVALID++;
1071 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, null dynamic_cast of a CSC TrackingRecHit !";
1073 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1076 stringstream i_csc_detector_id;
1077 i_csc_detector_id << i_cscdetid;
1080 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon CSC- detID = "<<i_csc_detector_id.str();
1082 string i_hitlog = i_ss.str();
1083 i_hitlog = i_hitlog + write_matched_simtracks(i_SimTrackIds);
1086 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
1091 <<
"*** WARNING in MuonAssociatorByHitsHelper::getMatchedIds, CSC TrackingRecHit is neither CSCRecHit2D nor CSCSegment ! ";
1098 stringstream rpc_detector_id;
1099 rpc_detector_id << rpcdetid;
1100 if (valid_Hit) hitlog = hitlog+
" -Muon RPC- detID = "+rpc_detector_id.str();
1101 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon RPC- detID = "+rpc_detector_id.str();
1109 if (!SimTrackIds.empty()) {
1110 n_rpc_matched_valid++;
1118 if (!SimTrackIds.empty()) {
1119 n_rpc_matched_INVALID++;
1129 stringstream gem_detector_id;
1130 gem_detector_id << gemdetid;
1131 if (valid_Hit) hitlog = hitlog+
" -Muon GEM- detID = "+gem_detector_id.str();
1132 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon GEM- detID = "+gem_detector_id.str();
1140 if (!SimTrackIds.empty()) {
1141 n_gem_matched_valid++;
1149 if (!SimTrackIds.empty()) {
1150 n_gem_matched_INVALID++;
1158 <<
"TrackingRecHit "<<iloop<<
" *** WARNING *** Unexpected Hit from Detector = "<<det;
1162 hitlog = hitlog + write_matched_simtracks(SimTrackIds);
1167 for (
unsigned int j=0;
j<DTSimHits.size();
j++) {
1180 for (MapOfMatchedIds::const_iterator iRecH=matchedIds.begin(); iRecH!=matchedIds.end(); ++iRecH) {
1183 std::vector<SimHitIdpr>
const & SimTrackIds = (*iRecH).second;
1187 for (std::vector<SimHitIdpr>::const_iterator iSimH=SimTrackIds.begin(); iSimH!=SimTrackIds.end(); ++iSimH) {
1188 uint32_t simtrackId = iSimH->first;
1193 if (simtrack->trackId() == simtrackId && simtrack->eventId() == evtId) {
1210 if (SimTrackIds.empty())
1211 return " *** UNMATCHED ***";
1213 string hitlog(
" matched to SimTrack");
1215 for(
size_t j=0;
j<SimTrackIds.size();
j++)
1218 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
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
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 > associateRecHit(const TrackingRecHit &hit) const
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
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
DTWireId wireId() const
Return the wireId.