40 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonLinksProducer";
46 std::vector<edm::ParameterSet> theMapPSets = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"Maps");
47 for (std::vector<edm::ParameterSet>::const_iterator iMPS = theMapPSets.begin();
48 iMPS != theMapPSets.end(); iMPS++) {
51 theTrackLinks.push_back( make_pair(subTrackTag, parentTrackTag) );
54 for(std::vector<std::pair<edm::InputTag, edm::InputTag> >::const_iterator iLink = theTrackLinks.begin();
55 iLink != theTrackLinks.end(); iLink++) {
56 LogDebug(category_) <<
"preparing map between " << (*iLink).first<<
" & "<< (*iLink).second;
57 std::string mapname = (*iLink).first.label() +
"To" + (*iLink).second.label();
58 produces<reco::TrackToTrackMap>(mapname);
65 if (theService)
delete theService;
73 LogInfo(category_) <<
"Processing event number: " << iEvent.
id();
75 theService->update(iSetup);
77 for(std::vector<std::pair<edm::InputTag, edm::InputTag> >::const_iterator iLink = theTrackLinks.begin();
78 iLink != theTrackLinks.end(); iLink++){
79 LogDebug(category_) <<
"making map between " << (*iLink).first<<
" and "<< (*iLink).second;
80 std::string mapname = (*iLink).first.label() +
"To" + (*iLink).second.label();
86 if ( iEvent.
getByLabel( (*iLink).first, subTracks) && iEvent.
getByLabel( (*iLink).second, parentTracks) ) {
88 ttmap = mapTracks(subTracks, parentTracks);
90 (*iLink).first.label()<<
" "<<subTracks->size()<<
" and "<<(*iLink).second.label()<<
" "<<parentTracks->size()<<
", results: "<< ttmap.
size() <<endl;
95 iEvent.
put(trackToTrackmap, mapname);
102 for (
unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
103 TrackRef track1(subTracks, position1);
104 for (
unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
105 TrackRef track2(parentTracks, position2);
107 LogTrace(category_)<<
"sharedHits "<<shared<<
" track1 "<<track1->found()<<
" track2 "<<track2->found()<<endl;
109 if (shared > (track1->found())/2 ) map.
insert(track1, track2);
121 if ( !(*hit1)->isValid() )
continue;
122 DetId id1 = (*hit1)->geographicalId();
124 LogTrace(category_)<<
"first ID "<<id1.
rawId()<<
" "<<(*hit1)->localPosition()<<endl;
125 GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
129 if ( !(*hit2)->isValid() )
continue;
131 DetId id2 = (*hit2)->geographicalId();
138 GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
139 if ( ( pos1 - pos2 ).mag()< 10
e-5 ) match++;
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName, BranchDescription::MatchMode m)
int sharedHits(const reco::Track &track1, const reco::Track &track2) const
uint32_t rawId() const
get the raw id
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
~CosmicMuonLinksProducer()
size_type size() const
map size
void insert(const key_type &k, const data_type &v)
insert an association
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 &)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.