CMS 3D CMS Logo

MuonLinksProducerForHLT.cc
Go to the documentation of this file.
1 
6 // system include files
7 #include <memory>
8 
9 // user include files
11 
14 
16 
19 
20 //#include <algorithm>
21 
23  produces<reco::MuonTrackLinksCollection>();
24  theLinkCollectionInInput = iConfig.getParameter<edm::InputTag>("LinkCollection");
25  theInclusiveTrackCollectionInInput = iConfig.getParameter<edm::InputTag>("InclusiveTrackerTrackCollection");
26  ptMin = iConfig.getParameter<double>("ptMin");
27  pMin = iConfig.getParameter<double>("pMin");
28  shareHitFraction = iConfig.getParameter<double>("shareHitFraction");
29 
30  linkToken_ = consumes<reco::MuonTrackLinksCollection>(theLinkCollectionInInput);
31  trackToken_ = consumes<reco::TrackCollection>(theInclusiveTrackCollectionInInput);
32 }
33 
35 
37  auto output = std::make_unique<reco::MuonTrackLinksCollection>();
38 
40  iEvent.getByToken(linkToken_, links);
41 
43  iEvent.getByToken(trackToken_, incTracks);
44 
45  for (reco::MuonTrackLinksCollection::const_iterator link = links->begin(); link != links->end(); ++link) {
46  bool found = false;
47  unsigned int trackIndex = 0;
48  unsigned int muonTrackHits = link->trackerTrack()->extra()->recHitsSize();
49  for (reco::TrackCollection::const_iterator track = incTracks->begin(); track != incTracks->end();
50  ++track, ++trackIndex) {
51  if (track->pt() < ptMin)
52  continue;
53  if (track->p() < pMin)
54  continue;
55  //std::cout << "pt (muon/track) " << link->trackerTrack()->pt() << " " << track->pt() << std::endl;
56  unsigned trackHits = track->extra()->recHitsSize();
57  //std::cout << "hits (muon/track) " << muonTrackHits << " " << trackHits() << std::endl;
58  unsigned int smallestNumberOfHits = trackHits < muonTrackHits ? trackHits : muonTrackHits;
59  int numberOfCommonDetIds = 0;
60  for (auto hit = track->extra()->recHitsBegin(); hit != track->extra()->recHitsEnd(); ++hit) {
61  for (auto mit = link->trackerTrack()->extra()->recHitsBegin();
62  mit != link->trackerTrack()->extra()->recHitsEnd();
63  ++mit) {
64  if ((*hit)->geographicalId() == (*mit)->geographicalId() &&
65  (*hit)->sharesInput((*mit), TrackingRecHit::some)) {
66  numberOfCommonDetIds++;
67  break;
68  }
69  }
70  }
71  double fraction = (double)numberOfCommonDetIds / smallestNumberOfHits;
72  // std::cout << "Overlap/Smallest/fraction = " << numberOfCommonDetIds << " " << smallestNumberOfHits << " " << fraction << std::endl;
73  if (fraction > shareHitFraction) {
74  output->push_back(
75  reco::MuonTrackLinks(reco::TrackRef(incTracks, trackIndex), link->standAloneTrack(), link->globalTrack()));
76  found = true;
77  break;
78  }
79  }
80  if (!found)
81  output->push_back(reco::MuonTrackLinks(link->trackerTrack(), link->standAloneTrack(), link->globalTrack()));
82  }
83  iEvent.put(std::move(output));
84 }
edm::StreamID
Definition: StreamID.h:30
Handle.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
MuonLinksProducerForHLT::theInclusiveTrackCollectionInInput
edm::InputTag theInclusiveTrackCollectionInInput
Definition: MuonLinksProducerForHLT.h:34
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
MuonLinksProducerForHLT::pMin
double pMin
Definition: MuonLinksProducerForHLT.h:38
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle< reco::MuonTrackLinksCollection >
edm::Ref< TrackCollection >
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52802
TrackingRecHit::some
Definition: TrackingRecHit.h:59
MuonLinksProducerForHLT::ptMin
double ptMin
Definition: MuonLinksProducerForHLT.h:37
MuonLinksProducerForHLT.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
MuonLinksProducerForHLT::linkToken_
edm::EDGetTokenT< reco::MuonTrackLinksCollection > linkToken_
Definition: MuonLinksProducerForHLT.h:35
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonLinksProducerForHLT::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: MuonLinksProducerForHLT.cc:36
edm::EventSetup
Definition: EventSetup.h:58
MuonLinksProducerForHLT::trackToken_
edm::EDGetTokenT< reco::TrackCollection > trackToken_
Definition: MuonLinksProducerForHLT.h:36
MuonLinksProducerForHLT::shareHitFraction
double shareHitFraction
Definition: MuonLinksProducerForHLT.h:39
eostools.move
def move(src, dest)
Definition: eostools.py:511
MuonLinksProducerForHLT::MuonLinksProducerForHLT
MuonLinksProducerForHLT(const edm::ParameterSet &)
Definition: MuonLinksProducerForHLT.cc:22
Frameworkfwd.h
electronStore.links
links
Definition: electronStore.py:149
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
MuonLinksProducerForHLT::theLinkCollectionInInput
edm::InputTag theLinkCollectionInInput
Definition: MuonLinksProducerForHLT.h:33
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MuonLinksProducerForHLT::~MuonLinksProducerForHLT
~MuonLinksProducerForHLT() override
Definition: MuonLinksProducerForHLT.cc:34