22 includeZeroHitMuons(conf.getParameter<bool>(
"includeZeroHitMuons")),
23 acceptOneStubMatchings(conf.getParameter<bool>(
"acceptOneStubMatchings")),
24 UseTracker(conf.getParameter<bool>(
"UseTracker")),
25 UseMuon(conf.getParameter<bool>(
"UseMuon")),
26 AbsoluteNumberOfHits_track(conf.getParameter<bool>(
"AbsoluteNumberOfHits_track")),
27 NHitCut_track(conf.getParameter<unsigned int>(
"NHitCut_track")),
28 EfficiencyCut_track(conf.getParameter<double>(
"EfficiencyCut_track")),
29 PurityCut_track(conf.getParameter<double>(
"PurityCut_track")),
30 AbsoluteNumberOfHits_muon(conf.getParameter<bool>(
"AbsoluteNumberOfHits_muon")),
31 NHitCut_muon(conf.getParameter<unsigned int>(
"NHitCut_muon")),
32 EfficiencyCut_muon(conf.getParameter<double>(
"EfficiencyCut_muon")),
33 PurityCut_muon(conf.getParameter<double>(
"PurityCut_muon")),
34 UsePixels(conf.getParameter<bool>(
"UsePixels")),
35 UseGrouped(conf.getParameter<bool>(
"UseGrouped")),
36 UseSplitting(conf.getParameter<bool>(
"UseSplitting")),
37 ThreeHitTracksAreSpecial(conf.getParameter<bool>(
"ThreeHitTracksAreSpecial")),
38 dumpDT(conf.getParameter<bool>(
"dumpDT")),
39 dumpInputCollections(conf.getParameter<bool>(
"dumpInputCollections")),
40 crossingframe(conf.getParameter<bool>(
"crossingframe")),
41 simtracksTag(conf.getParameter<edm::InputTag>(
"simtracksTag")),
42 simtracksXFTag(conf.getParameter<edm::InputTag>(
"simtracksXFTag")),
48 if (
UseTracker)
edm::LogVerbatim(
"MuonAssociatorByHits")<<
"\n UseTracker = TRUE : Tracker SimHits and RecHits WILL be counted";
49 else edm::LogVerbatim(
"MuonAssociatorByHits") <<
"\n UseTracker = FALSE : Tracker SimHits and RecHits WILL NOT be counted";
52 if (
UseMuon)
edm::LogVerbatim(
"MuonAssociatorByHits")<<
" UseMuon = TRUE : Muon SimHits and RecHits WILL be counted";
53 else edm::LogVerbatim(
"MuonAssociatorByHits") <<
" UseMuon = FALSE : Muon SimHits and RecHits WILL NOT be counted"<<endl;
58 <<
"\n includeZeroHitMuons = TRUE"
59 <<
"\n ==> (re)set NHitCut_muon = 0, PurityCut_muon = 0, EfficiencyCut_muon = 0"<<endl;
79 tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
83 for (IndexAssociation::const_iterator it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
84 for (std::vector<IndexMatch>::const_iterator itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
90 return outputCollection;
103 int tracker_nshared = 0;
104 int muon_nshared = 0;
105 int global_nshared = 0;
107 double tracker_quality = 0;
108 double tracker_quality_cut;
112 double muon_quality = 0;
113 double muon_quality_cut;
117 double global_quality = 0;
136 if (TPCollectionH.
size()!=0) tPC = *(TPCollectionH.
product());
140 edm::LogVerbatim(
"MuonAssociatorByHits")<<
"\n"<<
"reco::Track collection --- size = "<<tC.size();
144 edm::LogVerbatim(
"MuonAssociatorByHits")<<
"\n"<<
"TrackingParticle collection --- size = "<<tPC.size();
146 for(TrackingParticleCollection::const_iterator ITER=tPC.begin(); ITER!=tPC.end(); ITER++, j++) {
148 <<
"TrackingParticle "<<j<<
", q = "<<ITER->charge()<<
", p = "<<ITER->p()
149 <<
", pT = "<<ITER->pt()<<
", eta = "<<ITER->eta()<<
", phi = "<<ITER->phi();
152 <<
"\t pdg code = "<<ITER->pdgId()<<
", made of "<<ITER->numberOfHits()<<
" PSimHit"
153 <<
" (in "<<ITER->numberOfTrackerLayers()<<
" layers)"
154 <<
" from "<<ITER->g4Tracks().size()<<
" SimTrack:";
157 <<
"\t\t Id:"<<g4T->trackId()<<
"/Evt:("<<g4T->eventId().event()<<
","<<g4T->eventId().bunchCrossing()<<
")";
173 <<
" has size = "<<SimTk->size();
178 <<
" - Id:"<<ITER->trackId()<<
"/Evt:("<<ITER->eventId().event()<<
","<<ITER->eventId().bunchCrossing()<<
")"
179 <<
" pdgId = "<<ITER->type()<<
", q = "<<ITER->charge()<<
", p = "<<ITER->momentum().P()
180 <<
", pT = "<<ITER->momentum().Pt()<<
", eta = "<<ITER->momentum().Eta()<<
", phi = "<<ITER->momentum().Phi()
181 <<
"\n * "<<*ITER <<endl;
186 <<
" has size = "<<SimVtx->size();
191 <<
" : "<< *VITER <<endl;
198 <<
" has size = "<<simTC.size()<<endl;
200 for(edm::SimTrackContainer::const_iterator ITER=simTC.begin(); ITER!=simTC.end(); ITER++, k++){
203 <<
" - Id:"<<ITER->trackId()<<
"/Evt:("<<ITER->eventId().event()<<
","<<ITER->eventId().bunchCrossing()<<
")"
204 <<
" pdgId = "<<ITER->type()<<
", q = "<<ITER->charge()<<
", p = "<<ITER->momentum().P()
205 <<
", pT = "<<ITER->momentum().Pt()<<
", eta = "<<ITER->momentum().Eta()<<
", phi = "<<ITER->momentum().Phi()
206 <<
"\n * "<<*ITER <<endl;
208 e->
getByLabel(
"g4SimHits",simVertexCollection);
210 edm::LogVerbatim(
"MuonAssociatorByHits")<<
"\n"<<
"SimVertex collection with InputTag = "<<
"g4SimHits"
211 <<
" has size = "<<simVC.size()<<endl;
213 for (edm::SimVertexContainer::const_iterator VITER=simVC.begin(); VITER!=simVC.end(); VITER++, kv++){
216 <<
" : "<< *VITER <<endl;
222 for (TrackHitsCollection::const_iterator track=tC.begin(); track!=tC.end(); track++, tindex++) {
224 <<
"\n"<<
"reco::Track "<<tindex
225 <<
", number of RecHits = "<< (track->second - track->first) <<
"\n";
226 tracker_matchedIds_valid.clear();
227 muon_matchedIds_valid.clear();
229 tracker_matchedIds_INVALID.clear();
230 muon_matchedIds_INVALID.clear();
232 bool this_track_matched =
false;
233 int n_matching_simhits = 0;
237 int n_tracker_all = 0;
243 int n_tracker_valid = 0;
244 int n_muon_valid = 0;
249 int n_tracker_matched_valid = 0;
250 int n_muon_matched_valid = 0;
251 int n_dt_matched_valid = 0;
252 int n_csc_matched_valid = 0;
253 int n_rpc_matched_valid = 0;
256 int n_tracker_INVALID = 0;
257 int n_muon_INVALID = 0;
258 int n_dt_INVALID = 0;
259 int n_csc_INVALID = 0;
260 int n_rpc_INVALID = 0;
262 int n_tracker_matched_INVALID = 0;
263 int n_muon_matched_INVALID = 0;
264 int n_dt_matched_INVALID = 0;
265 int n_csc_matched_INVALID = 0;
266 int n_rpc_matched_INVALID = 0;
269 getMatchedIds(tracker_matchedIds_valid, muon_matchedIds_valid,
270 tracker_matchedIds_INVALID, muon_matchedIds_INVALID,
271 n_tracker_valid, n_dt_valid, n_csc_valid, n_rpc_valid,
272 n_tracker_matched_valid, n_dt_matched_valid, n_csc_matched_valid, n_rpc_matched_valid,
273 n_tracker_INVALID, n_dt_INVALID, n_csc_INVALID, n_rpc_INVALID,
274 n_tracker_matched_INVALID, n_dt_matched_INVALID, n_csc_matched_INVALID, n_rpc_matched_INVALID,
275 track->first, track->second,
276 trackertruth, dttruth, csctruth, rpctruth,
279 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
280 tracker_matchedIds_INVALID.size() +muon_matchedIds_INVALID.size();
282 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid;
283 n_valid = n_tracker_valid + n_muon_valid;
284 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID;
285 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
288 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
289 n_dt_all = n_dt_valid + n_dt_INVALID;
290 n_csc_all = n_csc_valid + n_csc_INVALID;
291 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
292 n_all = n_valid + n_INVALID;
294 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid;
295 n_muon_matched_INVALID = n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID;
298 int n_tracker_selected_hits = n_tracker_valid;
299 int n_muon_selected_hits = n_muon_valid;
300 int n_dt_selected_hits = n_dt_valid;
301 int n_csc_selected_hits = n_csc_valid;
302 int n_rpc_selected_hits = n_rpc_valid;
305 int n_tracker_matched = n_tracker_matched_valid;
306 int n_muon_matched = n_muon_matched_valid;
307 int n_dt_matched = n_dt_matched_valid;
308 int n_csc_matched = n_csc_matched_valid;
309 int n_rpc_matched = n_rpc_matched_valid;
316 InvMuonHits =
" ***INVALID MUON HITS***";
317 ZeroHitMuon =
" ***ZERO-HIT MUON***";
319 n_muon_selected_hits = n_muon_INVALID;
320 n_dt_selected_hits = n_dt_INVALID;
321 n_csc_selected_hits = n_csc_INVALID;
322 n_rpc_selected_hits = n_rpc_INVALID;
324 n_muon_matched = n_muon_matched_INVALID;
325 n_dt_matched = n_dt_matched_INVALID;
326 n_csc_matched = n_csc_matched_INVALID;
327 n_rpc_matched = n_rpc_matched_INVALID;
330 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
331 int n_matched = n_tracker_matched + n_muon_matched;
334 <<
"\n"<<
"# TrackingRecHits: "<<(track->second - track->first)
335 <<
"\n"<<
"# used RecHits = " << n_all <<
" ("<<n_tracker_all<<
"/"
336 <<n_dt_all<<
"/"<<n_csc_all<<
"/"<<n_rpc_all<<
" in Tracker/DT/CSC/RPC)"<<
", obtained from " << n_matching_simhits <<
" SimHits"
337 <<
"\n"<<
"# selected RecHits = " <<n_selected_hits <<
" (" <<n_tracker_selected_hits<<
"/"
338 <<n_dt_selected_hits<<
"/"<<n_csc_selected_hits<<
"/"<<n_rpc_selected_hits<<
" in Tracker/DT/CSC/RPC)"<<InvMuonHits
339 <<
"\n"<<
"# matched RecHits = " <<n_matched<<
" ("<<n_tracker_matched<<
"/"
340 <<n_dt_matched<<
"/"<<n_csc_matched<<
"/"<<n_rpc_matched<<
" in Tracker/DT/CSC/RPC)";
342 if (n_all>0 && n_matching_simhits == 0)
344 <<
"*** WARNING in MuonAssociatorByHits::associateRecoToSim: no matching PSimHit found for this reco::Track !";
346 if (n_matching_simhits != 0) {
348 <<
"\n"<<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
349 <<
"\n"<<
"reco::Track "<<tindex<<ZeroHitMuon
350 <<
"\n\t"<<
"made of "<<n_selected_hits<<
" selected RecHits (tracker:"<<n_tracker_selected_hits<<
"/muons:"<<n_muon_selected_hits<<
")";
353 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
354 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
355 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
358 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
360 global_nshared = tracker_nshared + muon_nshared;
363 else if(n_tracker_selected_hits != 0) tracker_quality = (
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits));
364 else tracker_quality = 0;
367 else if(n_muon_selected_hits != 0) muon_quality = (
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits));
368 else muon_quality = 0;
371 if (n_selected_hits != 0) {
373 global_quality = global_nshared;
375 global_quality = (
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits));
376 }
else global_quality = 0;
378 bool trackerOk =
false;
379 if (n_tracker_selected_hits != 0) {
380 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
386 if (n_muon_selected_hits != 0) {
387 if (muon_quality > muon_quality_cut) muonOk =
true;
391 bool matchOk = trackerOk || muonOk;
395 matchOk = trackerOk && muonOk;
399 outputCollection[tindex].push_back(
IndexMatch(tpindex, global_quality));
400 this_track_matched =
true;
403 <<
"\n\t"<<
" **MATCHED** with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
404 <<
"\n\t"<<
" N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")"
405 <<
"\n"<<
" to: TrackingParticle " <<tpindex<<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
406 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
407 <<
"\n\t"<<
" pdg code = "<<(*trpart).pdgId()<<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits"
408 <<
" from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
410 g4T!=(*trpart).g4Track_end();
413 <<
"\t"<<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
418 if (global_nshared != 0)
420 <<
"\n\t"<<
" NOT matched to TrackingParticle "<<tpindex
421 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
422 <<
"\n"<<
" N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
427 if (!this_track_matched) {
429 <<
"\n"<<
" NOT matched to any TrackingParticle";
433 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<
"\n";
440 edm::LogVerbatim(
"MuonAssociatorByHits")<<
"0 reconstructed tracks (-->> 0 associated !)";
443 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
444 std::sort(it->second.begin(), it->second.end());
446 return outputCollection;
458 tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
462 for (IndexAssociation::const_iterator it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
463 for (std::vector<IndexMatch>::const_iterator itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
465 std::make_pair(tC[itma->idx], itma->quality));
470 return outputCollection;
484 int tracker_nshared = 0;
485 int muon_nshared = 0;
486 int global_nshared = 0;
488 double tracker_quality = 0;
489 double tracker_quality_cut;
493 double muon_quality = 0;
494 double muon_quality_cut;
498 double global_quality = 0;
500 double tracker_purity = 0;
501 double muon_purity = 0;
502 double global_purity = 0;
522 if (TPCollectionH.
size()!=0) tPC = *(TPCollectionH.
product());
524 bool any_trackingParticle_matched =
false;
527 for (TrackHitsCollection::const_iterator track=tC.begin(); track!=tC.end(); track++, tindex++) {
529 <<
"\n"<<
"reco::Track "<<tindex
530 <<
", number of RecHits = "<< (track->second - track->first) <<
"\n";
532 tracker_matchedIds_valid.clear();
533 muon_matchedIds_valid.clear();
535 tracker_matchedIds_INVALID.clear();
536 muon_matchedIds_INVALID.clear();
538 int n_matching_simhits = 0;
542 int n_tracker_all = 0;
548 int n_tracker_valid = 0;
549 int n_muon_valid = 0;
554 int n_tracker_matched_valid = 0;
555 int n_muon_matched_valid = 0;
556 int n_dt_matched_valid = 0;
557 int n_csc_matched_valid = 0;
558 int n_rpc_matched_valid = 0;
561 int n_tracker_INVALID = 0;
562 int n_muon_INVALID = 0;
563 int n_dt_INVALID = 0;
564 int n_csc_INVALID = 0;
565 int n_rpc_INVALID = 0;
567 int n_tracker_matched_INVALID = 0;
568 int n_muon_matched_INVALID = 0;
569 int n_dt_matched_INVALID = 0;
570 int n_csc_matched_INVALID = 0;
571 int n_rpc_matched_INVALID = 0;
574 getMatchedIds(tracker_matchedIds_valid, muon_matchedIds_valid,
575 tracker_matchedIds_INVALID, muon_matchedIds_INVALID,
576 n_tracker_valid, n_dt_valid, n_csc_valid, n_rpc_valid,
577 n_tracker_matched_valid, n_dt_matched_valid, n_csc_matched_valid, n_rpc_matched_valid,
578 n_tracker_INVALID, n_dt_INVALID, n_csc_INVALID, n_rpc_INVALID,
579 n_tracker_matched_INVALID, n_dt_matched_INVALID, n_csc_matched_INVALID, n_rpc_matched_INVALID,
580 track->first, track->second,
581 trackertruth, dttruth, csctruth, rpctruth,
584 n_matching_simhits = tracker_matchedIds_valid.size() + muon_matchedIds_valid.size() +
585 tracker_matchedIds_INVALID.size() +muon_matchedIds_INVALID.size();
587 n_muon_valid = n_dt_valid + n_csc_valid + n_rpc_valid;
588 n_valid = n_tracker_valid + n_muon_valid;
589 n_muon_INVALID = n_dt_INVALID + n_csc_INVALID + n_rpc_INVALID;
590 n_INVALID = n_tracker_INVALID + n_muon_INVALID;
593 n_tracker_all = n_tracker_valid + n_tracker_INVALID;
594 n_dt_all = n_dt_valid + n_dt_INVALID;
595 n_csc_all = n_csc_valid + n_csc_INVALID;
596 n_rpc_all = n_rpc_valid + n_rpc_INVALID;
597 n_all = n_valid + n_INVALID;
599 n_muon_matched_valid = n_dt_matched_valid + n_csc_matched_valid + n_rpc_matched_valid;
600 n_muon_matched_INVALID = n_dt_matched_INVALID + n_csc_matched_INVALID + n_rpc_matched_INVALID;
603 int n_tracker_selected_hits = n_tracker_valid;
604 int n_muon_selected_hits = n_muon_valid;
605 int n_dt_selected_hits = n_dt_valid;
606 int n_csc_selected_hits = n_csc_valid;
607 int n_rpc_selected_hits = n_rpc_valid;
610 int n_tracker_matched = n_tracker_matched_valid;
611 int n_muon_matched = n_muon_matched_valid;
612 int n_dt_matched = n_dt_matched_valid;
613 int n_csc_matched = n_csc_matched_valid;
614 int n_rpc_matched = n_rpc_matched_valid;
621 InvMuonHits =
" ***INVALID MUON HITS***";
622 ZeroHitMuon =
" ***ZERO-HIT MUON***";
624 n_muon_selected_hits = n_muon_INVALID;
625 n_dt_selected_hits = n_dt_INVALID;
626 n_csc_selected_hits = n_csc_INVALID;
627 n_rpc_selected_hits = n_rpc_INVALID;
629 n_muon_matched = n_muon_matched_INVALID;
630 n_dt_matched = n_dt_matched_INVALID;
631 n_csc_matched = n_csc_matched_INVALID;
632 n_rpc_matched = n_rpc_matched_INVALID;
635 int n_selected_hits = n_tracker_selected_hits + n_muon_selected_hits;
636 int n_matched = n_tracker_matched + n_muon_matched;
639 <<
"\n"<<
"# TrackingRecHits: "<<(track->second - track->first)
640 <<
"\n"<<
"# used RecHits = " <<n_all <<
" ("<<n_tracker_all<<
"/"
641 <<n_dt_all<<
"/"<<n_csc_all<<
"/"<<n_rpc_all<<
" in Tracker/DT/CSC/RPC)"<<
", obtained from " << n_matching_simhits <<
" SimHits"
642 <<
"\n"<<
"# selected RecHits = " <<n_selected_hits <<
" (" <<n_tracker_selected_hits<<
"/"
643 <<n_dt_selected_hits<<
"/"<<n_csc_selected_hits<<
"/"<<n_rpc_selected_hits<<
" in Tracker/DT/CSC/RPC)"<<InvMuonHits
644 <<
"\n"<<
"# matched RecHits = " <<n_matched<<
" ("<<n_tracker_matched<<
"/"
645 <<n_dt_matched<<
"/"<<n_csc_matched<<
"/"<<n_rpc_matched<<
" in Tracker/DT/CSC/RPC)";
647 if (printRtS && n_all>0 && n_matching_simhits==0)
649 <<
"*** WARNING in MuonAssociatorByHits::associateSimToReco: no matching PSimHit found for this reco::Track !";
651 if (n_matching_simhits != 0) {
653 for (TrackingParticleCollection::const_iterator trpart = tPC.begin(); trpart != tPC.end(); ++trpart, ++tpindex) {
656 int n_tracker_recounted_simhits = 0;
657 int n_muon_simhits = 0;
658 int n_global_simhits = 0;
661 int n_tracker_selected_simhits = 0;
662 int n_muon_selected_simhits = 0;
663 int n_global_selected_simhits = 0;
666 tracker_nshared =
getShared(tracker_matchedIds_valid, trpart);
667 muon_nshared =
getShared(muon_matchedIds_valid, trpart);
670 muon_nshared =
getShared(muon_matchedIds_INVALID, trpart);
672 global_nshared = tracker_nshared + muon_nshared;
673 if (global_nshared == 0)
continue;
739 n_tracker_recounted_simhits = trpart->numberOfTrackerHits();
741 n_muon_simhits = trpart->numberOfHits() - trpart->numberOfTrackerHits();
744 if (trpart->numberOfHits()==0) {
746 n_tracker_recounted_simhits = tracker_nshared;
747 n_muon_simhits = muon_nshared;
749 n_global_simhits = n_tracker_recounted_simhits + n_muon_simhits;
752 n_muon_selected_simhits = n_muon_simhits;
753 n_global_selected_simhits = n_muon_selected_simhits;
756 n_tracker_selected_simhits = n_tracker_recounted_simhits;
757 n_global_selected_simhits += n_tracker_selected_simhits;
761 else if (n_tracker_selected_simhits!=0)
762 tracker_quality =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_simhits);
763 else tracker_quality = 0;
766 else if (n_muon_selected_simhits!=0)
767 muon_quality =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_simhits);
768 else muon_quality = 0;
771 if (n_global_selected_simhits != 0) {
773 global_quality = global_nshared;
775 global_quality =
static_cast<double>(global_nshared)/static_cast<double>(n_global_selected_simhits);
777 else global_quality = 0;
780 if (n_selected_hits != 0) {
782 global_purity = global_nshared;
784 global_purity =
static_cast<double>(global_nshared)/static_cast<double>(n_selected_hits);
786 else global_purity = 0;
788 bool trackerOk =
false;
789 if (n_tracker_selected_hits != 0) {
790 if (tracker_quality > tracker_quality_cut) trackerOk =
true;
792 tracker_purity =
static_cast<double>(tracker_nshared)/static_cast<double>(n_tracker_selected_hits);
802 if (n_muon_selected_hits != 0) {
803 if (muon_quality > muon_quality_cut) muonOk =
true;
805 muon_purity =
static_cast<double>(muon_nshared)/static_cast<double>(n_muon_selected_hits);
812 bool matchOk = trackerOk || muonOk;
816 matchOk = trackerOk && muonOk;
820 outputCollection[tpindex].push_back(
IndexMatch(tindex,global_quality));
821 any_trackingParticle_matched =
true;
824 <<
"************************************************************************************************************************"
825 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
826 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
827 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
828 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits"
829 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")"
830 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
832 g4T!=(*trpart).g4Track_end();
835 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
838 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits"
839 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")"
840 <<
"\n\t **MATCHED** with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
841 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")"
842 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")"
843 <<
"\n" <<
" to: reco::Track "<<tindex<<ZeroHitMuon
844 <<
"\n\t"<<
" made of "<<n_selected_hits<<
" RecHits (tracker:"<<n_tracker_valid<<
"/muons:"<<n_muon_selected_hits<<
")";
848 if (global_nshared != 0) {
850 <<
"************************************************************************************************************************"
851 <<
"\n"<<
"TrackingParticle " << tpindex <<
", q = "<<(*trpart).charge()<<
", p = "<<(*trpart).p()
852 <<
", pT = "<<(*trpart).pt()<<
", eta = "<<(*trpart).eta()<<
", phi = "<<(*trpart).phi()
853 <<
"\n"<<
" pdg code = "<<(*trpart).pdgId()
854 <<
", made of "<<(*trpart).numberOfHits()<<
" PSimHits, recounted "<<n_global_simhits<<
" PSimHits"
855 <<
" (tracker:"<<n_tracker_recounted_simhits<<
"/muons:"<<n_muon_simhits<<
")"
856 <<
", from "<<(*trpart).g4Tracks().size()<<
" SimTrack:";
858 g4T!=(*trpart).g4Track_end();
861 <<
" Id:"<<(*g4T).trackId()<<
"/Evt:("<<(*g4T).eventId().event()<<
","<<(*g4T).eventId().bunchCrossing()<<
")";
864 <<
"\t selected "<<n_global_selected_simhits<<
" PSimHits"
865 <<
" (tracker:"<<n_tracker_selected_simhits<<
"/muons:"<<n_muon_selected_simhits<<
")"
866 <<
"\n\t NOT matched to reco::Track "<<tindex<<ZeroHitMuon
867 <<
" with quality = "<<global_quality<<
" (tracker: "<<tracker_quality<<
" / muon: "<<muon_quality<<
")"
868 <<
"\n\t and purity = "<<global_purity<<
" (tracker: "<<tracker_purity<<
" / muon: "<<muon_purity<<
")"
869 <<
"\n\t N shared hits = "<<global_nshared<<
" (tracker: "<<tracker_nshared<<
" / muon: "<<muon_nshared<<
")";
876 if (!any_trackingParticle_matched) {
879 <<
"************************************************************************************************************************"
880 <<
"\n NO TrackingParticle associated to ANY input reco::Track ! \n"
881 <<
"************************************************************************************************************************"<<
"\n";
884 <<
"************************************************************************************************************************"<<
"\n";
888 for (IndexAssociation::iterator it = outputCollection.begin(), ed = outputCollection.end(); it != ed; ++it) {
889 std::sort(it->second.begin(), it->second.end());
891 return outputCollection;
898 int& n_tracker_valid,
int& n_dt_valid,
int& n_csc_valid,
int& n_rpc_valid,
899 int& n_tracker_matched_valid,
int& n_dt_matched_valid,
int& n_csc_matched_valid,
int& n_rpc_matched_valid,
900 int& n_tracker_INVALID,
int& n_dt_INVALID,
int& n_csc_INVALID,
int& n_rpc_INVALID,
901 int& n_tracker_matched_INVALID,
int& n_dt_matched_INVALID,
int& n_csc_matched_INVALID,
int& n_rpc_matched_INVALID,
908 tracker_matchedIds_valid.clear();
909 muon_matchedIds_valid.clear();
911 tracker_matchedIds_INVALID.clear();
912 muon_matchedIds_INVALID.clear();
919 n_tracker_matched_valid = 0;
920 n_dt_matched_valid = 0;
921 n_csc_matched_valid = 0;
922 n_rpc_matched_valid = 0;
924 n_tracker_INVALID = 0;
929 n_tracker_matched_INVALID = 0;
930 n_dt_matched_INVALID = 0;
931 n_csc_matched_INVALID = 0;
932 n_rpc_matched_INVALID = 0;
934 std::vector<SimHitIdpr> SimTrackIds;
940 stringstream hit_index;
947 stringstream detector_id;
950 string hitlog =
"TrackingRecHit "+hit_index.str();
952 std::vector<string> DTSimHits;
957 bool valid_Hit = hitp->
isValid();
961 stringstream detector_id;
962 detector_id<< tTopo->
print(detid);
964 if (valid_Hit) hitlog = hitlog+
" -Tracker - detID = "+detector_id.str();
965 else hitlog = hitlog+
" *** INVALID ***"+
" -Tracker - detID = "+detector_id.str();
973 if(!SimTrackIds.empty()) {
974 n_tracker_matched_valid++;
981 if(!SimTrackIds.empty()) {
982 n_tracker_matched_INVALID++;
994 stringstream dt_detector_id;
995 dt_detector_id << dtdetid;
996 if (valid_Hit) hitlog = hitlog+
" -Muon DT - detID = "+dt_detector_id.str();
997 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon DT - detID = "+dt_detector_id.str();
1009 if (!SimTrackIds.empty()) {
1010 n_dt_matched_valid++;
1017 if (!SimTrackIds.empty()) {
1018 n_dt_matched_INVALID++;
1028 std::vector<PSimHit> dtSimHits = dttruth.
associateHit(*hitp);
1030 stringstream ndthits;
1031 ndthits<<dtSimHits.size();
1032 wireidlog =
"\t DTWireId :"+wid.str()+
", "+ndthits.str()+
" associated PSimHit :";
1034 for (
unsigned int j=0;
j<dtSimHits.size();
j++) {
1037 stringstream simhit;
1038 simhit<<dtSimHits[
j];
1039 string simhitlog =
"\t\t PSimHit "+index.str()+
": "+simhit.str();
1040 DTSimHits.push_back(simhitlog);
1051 std::vector<const TrackingRecHit *> componentHits, phiHits, zHits;
1052 if (dtsegment->
hasPhi()) {
1054 componentHits.insert(componentHits.end(),phiHits.begin(),phiHits.end());
1056 if (dtsegment->
hasZed()) {
1058 componentHits.insert(componentHits.end(),zHits.begin(),zHits.end());
1061 <<
"\n\t this TrackingRecHit is a DTRecSegment4D with "
1062 <<componentHits.size()<<
" hits (phi:"<<phiHits.size()<<
", z:"<<zHits.size()<<
")";
1064 std::vector<SimHitIdpr> i_SimTrackIds;
1066 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
1067 ithit != componentHits.end(); ++ithit) {
1072 i_SimTrackIds.clear();
1081 if (!i_SimTrackIds.empty()) {
1082 n_dt_matched_valid++;
1089 if (!i_SimTrackIds.empty()) {
1090 n_dt_matched_INVALID++;
1097 <<
"*** WARNING in MuonAssociatorByHits::getMatchedIds, null dynamic_cast of a DT TrackingRecHit !";
1099 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1102 stringstream i_dt_detector_id;
1103 i_dt_detector_id << i_dtdetid;
1106 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon DT - detID = "<<i_dt_detector_id.str();
1108 string i_hitlog = i_ss.str();
1109 i_hitlog = i_hitlog + write_matched_simtracks(i_SimTrackIds);
1112 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
1117 <<
"*** WARNING in MuonAssociatorByHits::getMatchedIds, DT TrackingRecHit is neither DTRecHit1D nor DTRecSegment4D ! ";
1124 stringstream csc_detector_id;
1125 csc_detector_id << cscdetid;
1126 if (valid_Hit) hitlog = hitlog+
" -Muon CSC- detID = "+csc_detector_id.str();
1127 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon CSC- detID = "+csc_detector_id.str();
1139 if (!SimTrackIds.empty()) {
1140 n_csc_matched_valid++;
1147 if (!SimTrackIds.empty()) {
1148 n_csc_matched_INVALID++;
1161 std::vector<const TrackingRecHit *> componentHits = cscsegment->recHits();
1163 <<
"\n\t this TrackingRecHit is a CSCSegment with "<<componentHits.size()<<
" hits";
1165 std::vector<SimHitIdpr> i_SimTrackIds;
1167 for (std::vector<const TrackingRecHit *>::const_iterator ithit =componentHits.begin();
1168 ithit != componentHits.end(); ++ithit) {
1173 i_SimTrackIds.clear();
1182 if (!i_SimTrackIds.empty()) {
1183 n_csc_matched_valid++;
1190 if (!i_SimTrackIds.empty()) {
1191 n_csc_matched_INVALID++;
1197 <<
"*** WARNING in MuonAssociatorByHits::getMatchedIds, null dynamic_cast of a CSC TrackingRecHit !";
1199 unsigned int i_detid = (*ithit)->geographicalId().rawId();
1202 stringstream i_csc_detector_id;
1203 i_csc_detector_id << i_cscdetid;
1206 i_ss<<
"\t\t hit "<<i_compHit<<
" -Muon CSC- detID = "<<i_csc_detector_id.str();
1208 string i_hitlog = i_ss.str();
1209 i_hitlog = i_hitlog + write_matched_simtracks(i_SimTrackIds);
1212 SimTrackIds.insert(SimTrackIds.end(),i_SimTrackIds.begin(),i_SimTrackIds.end());
1217 <<
"*** WARNING in MuonAssociatorByHits::getMatchedIds, CSC TrackingRecHit is neither CSCRecHit2D nor CSCSegment ! ";
1224 stringstream rpc_detector_id;
1225 rpc_detector_id << rpcdetid;
1226 if (valid_Hit) hitlog = hitlog+
" -Muon RPC- detID = "+rpc_detector_id.str();
1227 else hitlog = hitlog+
" *** INVALID ***"+
" -Muon RPC- detID = "+rpc_detector_id.str();
1235 if (!SimTrackIds.empty()) {
1236 n_rpc_matched_valid++;
1244 if (!SimTrackIds.empty()) {
1245 n_rpc_matched_INVALID++;
1252 <<
"TrackingRecHit "<<iloop<<
" *** WARNING *** Unexpected Hit from Detector = "<<det;
1256 hitlog = hitlog + write_matched_simtracks(SimTrackIds);
1261 for (
unsigned int j=0;
j<DTSimHits.size();
j++) {
1274 for (MapOfMatchedIds::const_iterator iRecH=matchedIds.begin(); iRecH!=matchedIds.end(); ++iRecH) {
1277 std::vector<SimHitIdpr>
const & SimTrackIds = (*iRecH).second;
1281 for (std::vector<SimHitIdpr>::const_iterator iSimH=SimTrackIds.begin(); iSimH!=SimTrackIds.end(); ++iSimH) {
1282 uint32_t simtrackId = iSimH->first;
1287 if (simtrack->trackId() == simtrackId && simtrack->eventId() == evtId) {
1304 if (SimTrackIds.empty())
1305 return " *** UNMATCHED ***";
1307 string hitlog(
" matched to SimTrack");
1309 for(
size_t j=0;
j<SimTrackIds.size();
j++)
1312 snprintf(buf, 64,
" Id:%i/Evt:(%i,%i) ", SimTrackIds[
j].
first, SimTrackIds[
j].
second.event(), SimTrackIds[
j].second.bunchCrossing());
1324 for (
unsigned int j=0;
j<tPCH->size();
j++)
1339 switch (trackType) {
1344 muonHitRefs.push_back(std::make_pair(mur->
track()->recHitsBegin(), mur->
track()->recHitsEnd()));
1346 muonHitRefs.push_back(std::make_pair(hitRefVector.
begin(), hitRefVector.
end()));
1354 muonHitRefs.push_back(std::make_pair(mur->
outerTrack()->recHitsBegin(), mur->
outerTrack()->recHitsEnd()));
1356 muonHitRefs.push_back(std::make_pair(hitRefVector.
begin(), hitRefVector.
end()));
1364 muonHitRefs.push_back(std::make_pair(mur->
globalTrack()->recHitsBegin(), mur->
globalTrack()->recHitsEnd()));
1366 muonHitRefs.push_back(std::make_pair(hitRefVector.
begin(), hitRefVector.
end()));
1372 hitExtractor.
init(*event, *setup);
1374 std::vector<std::pair<size_t, size_t> > muonHitIndices;
1377 std::pair<size_t, size_t> indices(allTMRecHits.
size(), allTMRecHits.
size());
1379 std::vector<const TrackingRecHit *> hits = hitExtractor.
getMuonHits(*mur);
1380 for (std::vector<const TrackingRecHit *>::const_iterator ith = hits.begin(), edh = hits.end(); ith != edh; ++ith) {
1383 indices.second += hits.size();
1385 muonHitIndices.push_back(indices);
1388 for (
size_t i = 0,
n = allTMRecHits.
size();
i <
n; ++
i) {
1392 typedef std::pair<size_t, size_t> index_pair;
1394 for (std::vector<std::pair<size_t, size_t> >::const_iterator idxs = muonHitIndices.begin(), idxend = muonHitIndices.end(); idxs != idxend; ++idxs) {
1395 muonHitRefs.push_back(std::make_pair(hitRefBegin+idxs->first,
1396 hitRefBegin+idxs->second));
1405 for (MuonAssociatorByHits::IndexAssociation::const_iterator it = recSimColl.begin(), ed = recSimColl.end(); it != ed; ++it) {
1407 const std::vector<MuonAssociatorByHits::IndexMatch> & idxAss = it->second;
1408 std::vector<std::pair<TrackingParticleRef, double> > & tpAss = recToSim[rec];
1409 for (std::vector<MuonAssociatorByHits::IndexMatch>::const_iterator ita = idxAss.begin(), eda = idxAss.end(); ita != eda; ++ita) {
1410 tpAss.
push_back(std::make_pair(tPC[ita->idx], ita->quality));
1414 for (MuonAssociatorByHits::IndexAssociation::const_iterator it = simRecColl.begin(), ed = simRecColl.end(); it != ed; ++it) {
1416 const std::vector<MuonAssociatorByHits::IndexMatch> & idxAss = it->second;
1417 std::vector<std::pair<edm::RefToBase<reco::Muon>,
double> > & recAss = simToRec[sim];
1418 for (std::vector<MuonAssociatorByHits::IndexMatch>::const_iterator ita = idxAss.begin(), eda = idxAss.end(); ita != eda; ++ita) {
1419 recAss.
push_back(std::make_pair(muons[ita->idx], ita->quality));
std::pair< unsigned int, std::vector< SimHitIdpr > > uint_SimHitIdpr_pair
reco::RecoToSimCollection associateRecoToSim(const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Association Reco To Sim with Collections.
std::vector< TrackingParticle > TrackingParticleCollection
C const * product() const
Accessor for product collection.
std::string dump(unsigned int indent=0) const
edm::InputTag simtracksXFTag
void associateMuons(MuonToSimCollection &recoToSim, SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &, MuonTrackType, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
bool isTrackerMuon() const
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
std::vector< PSimHit > associateHit(const TrackingRecHit &hit)
const_iterator end() const
virtual TrackRef track() const
reference to a Track
boost::ptr_vector< uint_SimHitIdpr_pair > MapOfMatchedIds
const edm::ParameterSet & conf_
edm::InputTag simtracksTag
const_iterator end() const
Termination of iteration.
std::string print(DetId detid) const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit)
const bool AbsoluteNumberOfHits_muon
const_iterator begin() const
Initialize an iterator over the RefVector.
const bool includeZeroHitMuons
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
bool isNonnull() const
Checks for non-null.
std::map< TrackingParticleRef, std::vector< std::pair< edm::RefToBase< reco::Muon >, double > > > SimToMuonCollection
int getShared(MapOfMatchedIds &matchedIds, TrackingParticleCollection::const_iterator trpart) const
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, TrackerHitAssociator *trackertruth, DTHitAssociator &dttruth, MuonTruth &csctruth, RPCHitAssociator &rpctruth, bool printRts, const TrackerTopology *) const
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
void post_insert()
post insert action
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
std::vector< SimHitIdpr > associateCSCHitId(const CSCRecHit2D *)
unsigned int NHitCut_muon
bool hasPhi() const
Does it have the Phi projection?
const bool acceptOneStubMatchings
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string write_matched_simtracks(const std::vector< SimHitIdpr > &) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
const bool AbsoluteNumberOfHits_track
const bool ThreeHitTracksAreSpecial
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
std::vector< SimTrack >::const_iterator g4t_iterator
bool hasZed() const
Does it have the Z projection?
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
void insert(const key_type &k, const data_type &v)
insert an association
std::vector< SimVertex > SimVertexContainer
T const * product() const
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
T const * product() const
const_iterator begin() const
std::vector< SimHitIdpr > associateDTHitId(const DTRecHit1D *dtrechit)
reco::SimToRecoCollection associateSimToReco(const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Association Sim To Reco with Collections.
MuonAssociatorByHits(const edm::ParameterSet &)
unsigned int NHitCut_track
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
size_type size() const
Size of the RefVector.
DetId geographicalId() const
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Detector det() const
get the detector field from this detid
double EfficiencyCut_track
std::vector< SimTrack > SimTrackContainer
std::map< edm::RefToBase< reco::Muon >, std::vector< std::pair< TrackingParticleRef, double > >, RefToBaseSort > MuonToSimCollection
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
double EfficiencyCut_muon
std::vector< SimHitIdpr > associateRecHit(const TrackingRecHit &hit)
std::map< size_t, std::vector< IndexMatch > > IndexAssociation
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
DTWireId wireId() const
Return the wireId.
const bool dumpInputCollections