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++){
83 LogDebug(category_) <<
"making map between " << (*iLink).first<<
" and "<< (*iLink).second;
91 iEvent.
getByToken((*iLink).second, parentTracks);
93 ttmap = mapTracks(subTracks, parentTracks);
95 theTrackLinkNames[
counter].first <<
" "<<subTracks->size()<<
" and "<<theTrackLinkNames[
counter].second<<
" "<<parentTracks->size()<<
", results: "<< ttmap.
size() <<endl;
98 iEvent.
put(trackToTrackmap, mapname);
107 for (
unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
108 TrackRef track1(subTracks, position1);
109 for (
unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
110 TrackRef track2(parentTracks, position2);
112 LogTrace(category_)<<
"sharedHits "<<shared<<
" track1 "<<track1->found()<<
" track2 "<<track2->found()<<endl;
114 if (shared > (track1->found())/2 ) map.
insert(track1, track2);
126 if ( !(*hit1)->isValid() )
continue;
127 DetId id1 = (*hit1)->geographicalId();
129 LogTrace(category_)<<
"first ID "<<id1.
rawId()<<
" "<<(*hit1)->localPosition()<<endl;
130 GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
134 if ( !(*hit2)->isValid() )
continue;
136 DetId id2 = (*hit2)->geographicalId();
143 GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
144 if ( ( pos1 - pos2 ).mag()< 10
e-5 ) match++;
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void produce(edm::Event &, const edm::EventSetup &)
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.
~CosmicMuonLinksProducer()
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 &)
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.