36 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonLinksProducer";
42 std::vector<edm::ParameterSet> theMapPSets = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"Maps");
43 for (std::vector<edm::ParameterSet>::const_iterator iMPS = theMapPSets.begin(); iMPS != theMapPSets.end(); iMPS++) {
49 theTrackLinks.push_back(make_pair(subTrackTag, parentTrackTag));
50 theTrackLinkNames.push_back(make_pair(sTag.
label(), pTag.label()));
52 LogDebug(category_) <<
"preparing map between " << sTag <<
" & " << pTag;
54 produces<reco::TrackToTrackMap>(mapname);
65 LogInfo(category_) <<
"Processing event number: " << iEvent.
id();
67 theService->update(iSetup);
73 iLink != theTrackLinks.end();
78 labelsForToken(iLink->first, labels_first);
79 labelsForToken(iLink->second, labels_second);
80 LogDebug(category_) <<
"making map between " << labels_first.
module <<
" and " << labels_second.
module;
89 iEvent.
getByToken((*iLink).second, parentTracks);
91 ttmap = mapTracks(subTracks, parentTracks);
92 LogTrace(category_) <<
"Mapped: " << theTrackLinkNames[
counter].first <<
" " << subTracks->size() <<
" and " 93 << theTrackLinkNames[
counter].second <<
" " << parentTracks->size()
94 <<
", results: " << ttmap.
size() << endl;
96 iEvent.
put(std::make_unique<reco::TrackToTrackMap>(ttmap), mapname);
105 for (
unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
106 TrackRef track1(subTracks, position1);
107 for (
unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
108 TrackRef track2(parentTracks, position2);
110 LogTrace(category_) <<
"sharedHits " << shared <<
" track1 " << track1->found() <<
" track2 " << track2->found()
113 if (shared > (track1->found()) / 2)
114 map.
insert(track1, track2);
125 if (!(*hit1)->isValid())
127 DetId id1 = (*hit1)->geographicalId();
130 LogTrace(category_) <<
"first ID " << id1.
rawId() <<
" " << (*hit1)->localPosition() << endl;
131 GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
134 if (!(*hit2)->isValid())
137 DetId id2 = (*hit2)->geographicalId();
146 GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
147 if ((pos1 - pos2).mag() < 10
e-5)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr uint32_t rawId() const
get the raw id
void produce(edm::Event &, const edm::EventSetup &) override
int sharedHits(const reco::Track &track1, const reco::Track &track2) const
~CosmicMuonLinksProducer() override
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
size_type size() const
map size
void insert(const key_type &k, const data_type &v)
insert an association
static std::atomic< unsigned int > counter
reco::TrackToTrackMap mapTracks(const edm::Handle< reco::TrackCollection > &, const edm::Handle< reco::TrackCollection > &) const
CosmicMuonLinksProducer(const edm::ParameterSet &)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
constexpr Detector det() const
get the detector field from this detid
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.