38 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonLinksProducer";
44 std::vector<edm::ParameterSet> theMapPSets = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"Maps");
45 for (std::vector<edm::ParameterSet>::const_iterator iMPS = theMapPSets.begin();
46 iMPS != theMapPSets.end(); iMPS++) {
53 theTrackLinks.push_back( make_pair(subTrackTag, parentTrackTag) );
54 theTrackLinkNames.push_back( make_pair(sTag.
label(), pTag.label()) );
57 LogDebug(category_) <<
"preparing map between " << sTag<<
" & "<< pTag;
59 produces<reco::TrackToTrackMap>(mapname);
68 if (theService)
delete theService;
76 LogInfo(category_) <<
"Processing event number: " << iEvent.
id();
78 theService->update(iSetup);
82 iLink != theTrackLinks.end(); iLink++){
86 labelsForToken(iLink->first, labels_first);
87 labelsForToken(iLink->second, labels_second);
88 LogDebug(category_) <<
"making map between " << labels_first.
module <<
" and "<< labels_second.
module;
97 iEvent.
getByToken((*iLink).second, parentTracks);
99 ttmap = mapTracks(subTracks, parentTracks);
101 theTrackLinkNames[
counter].first <<
" "<<subTracks->size()<<
" and "<<theTrackLinkNames[
counter].second<<
" "<<parentTracks->size()<<
", results: "<< ttmap.
size() <<endl;
103 iEvent.
put(std::make_unique<reco::TrackToTrackMap>(ttmap), mapname);
112 for (
unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
113 TrackRef track1(subTracks, position1);
114 for (
unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
115 TrackRef track2(parentTracks, position2);
117 LogTrace(category_)<<
"sharedHits "<<shared<<
" track1 "<<track1->found()<<
" track2 "<<track2->found()<<endl;
119 if (shared > (track1->found())/2 ) map.
insert(track1, track2);
131 if ( !(*hit1)->isValid() )
continue;
132 DetId id1 = (*hit1)->geographicalId();
134 LogTrace(category_)<<
"first ID "<<id1.
rawId()<<
" "<<(*hit1)->localPosition()<<endl;
135 GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
139 if ( !(*hit2)->isValid() )
continue;
141 DetId id2 = (*hit2)->geographicalId();
148 GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
149 if ( ( pos1 - pos2 ).mag()< 10
e-5 ) match++;
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
void produce(edm::Event &, const edm::EventSetup &) override
int sharedHits(const reco::Track &track1, const reco::Track &track2) const
uint32_t rawId() const
get the raw id
~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
Detector det() const
get the detector field from this detid
CosmicMuonLinksProducer(const edm::ParameterSet &)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.