CMS 3D CMS Logo

CosmicMuonLinksProducer Class Reference

Date
2009/01/05 21:58:19
Revision
1.2
Original Author: Chang Liu - Purdue University <chang.liu@cern.ch> More...

#include <RecoMuon/CosmicMuonProducer/src/CosmicMuonLinksProducer.h>

Inheritance diagram for CosmicMuonLinksProducer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 CosmicMuonLinksProducer (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~CosmicMuonLinksProducer ()

Private Member Functions

reco::TrackToTrackMap mapTracks (const edm::Handle< reco::TrackCollection > &, const edm::Handle< reco::TrackCollection > &) const
int sharedHits (const reco::Track &track1, const reco::Track &track2) const

Private Attributes

std::string category_
MuonServiceProxytheService
std::vector< std::pair
< edm::InputTag, edm::InputTag > > 
theTrackLinks


Detailed Description

Date
2009/01/05 21:58:19
Revision
1.2
Original Author: Chang Liu - Purdue University <chang.liu@cern.ch>

Definition at line 17 of file CosmicMuonLinksProducer.h.


Constructor & Destructor Documentation

CosmicMuonLinksProducer::CosmicMuonLinksProducer ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 37 of file CosmicMuonLinksProducer.cc.

References category_, edm::ParameterSet::getParameter(), LogDebug, MuonServiceProxy_cff::MuonServiceProxy, theService, and theTrackLinks.

00038 {
00039 
00040   category_ = "Muon|RecoMuon|CosmicMuon|CosmicMuonLinksProducer";
00041 
00042   ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
00043 
00044   theService = new MuonServiceProxy(serviceParameters);
00045 
00046   std::vector<edm::ParameterSet> theMapPSets = iConfig.getParameter<std::vector<edm::ParameterSet> >("Maps");
00047   for (std::vector<edm::ParameterSet>::const_iterator iMPS = theMapPSets.begin();
00048        iMPS != theMapPSets.end(); iMPS++) {
00049      edm::InputTag subTrackTag = (*iMPS).getParameter<edm::InputTag>("subTrack");
00050      edm::InputTag parentTrackTag = (*iMPS).getParameter<edm::InputTag>("parentTrack");
00051      theTrackLinks.push_back( make_pair(subTrackTag, parentTrackTag) );
00052   }
00053 
00054   for(std::vector<std::pair<edm::InputTag, edm::InputTag> >::const_iterator iLink = theTrackLinks.begin();
00055      iLink != theTrackLinks.end(); iLink++) {
00056     LogDebug(category_) << "preparing map between " << (*iLink).first<<" & "<< (*iLink).second;
00057     std::string mapname = (*iLink).first.label() + "To" + (*iLink).second.label();
00058     produces<reco::TrackToTrackMap>(mapname);
00059   }
00060 
00061 }

CosmicMuonLinksProducer::~CosmicMuonLinksProducer (  ) 

Definition at line 63 of file CosmicMuonLinksProducer.cc.

References theService.

00064 {
00065   if (theService) delete theService;
00066 }


Member Function Documentation

reco::TrackToTrackMap CosmicMuonLinksProducer::mapTracks ( const edm::Handle< reco::TrackCollection > &  subTracks,
const edm::Handle< reco::TrackCollection > &  parentTracks 
) const [private]

Definition at line 100 of file CosmicMuonLinksProducer.cc.

References category_, lat::endl(), edm::AssociationMap< Tag >::insert(), LogTrace, and sharedHits().

Referenced by produce().

00100                                                                                                                                                           {
00101   reco::TrackToTrackMap map;
00102   for ( unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
00103     TrackRef track1(subTracks, position1);
00104     for ( unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
00105       TrackRef track2(parentTracks, position2);
00106       int shared = sharedHits(*track1, *track2); 
00107       LogTrace(category_)<<"sharedHits "<<shared<<" track1 "<<track1->found()<<" track2 "<<track2->found()<<endl;
00108  
00109       if (shared > (track1->found())/2 ) map.insert(track1, track2);
00110     }
00111   }
00112 
00113   return map; 
00114 }

void CosmicMuonLinksProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 71 of file CosmicMuonLinksProducer.cc.

References category_, lat::endl(), edm::Event::getByLabel(), edm::Event::id(), LogDebug, LogTrace, mapTracks(), edm::Event::put(), edm::AssociationMap< Tag >::size(), theService, and theTrackLinks.

00072 {
00073   LogInfo(category_) << "Processing event number: " << iEvent.id();
00074 
00075   theService->update(iSetup);
00076 
00077   for(std::vector<std::pair<edm::InputTag, edm::InputTag> >::const_iterator iLink = theTrackLinks.begin();
00078      iLink != theTrackLinks.end(); iLink++){
00079     LogDebug(category_) << "making map between " << (*iLink).first<<" and "<< (*iLink).second;
00080     std::string mapname = (*iLink).first.label() + "To" + (*iLink).second.label();
00081     reco::TrackToTrackMap ttmap;
00082 
00083     Handle<reco::TrackCollection> subTracks;
00084     Handle<reco::TrackCollection> parentTracks;
00085 
00086     if ( iEvent.getByLabel( (*iLink).first, subTracks) && iEvent.getByLabel( (*iLink).second, parentTracks) ) {
00087 
00088          ttmap = mapTracks(subTracks, parentTracks); 
00089          LogTrace(category_) << "Mapped: "<<
00090 (*iLink).first.label()<<" "<<subTracks->size()<< " and "<<(*iLink).second.label()<<" "<<parentTracks->size()<<", results: "<< ttmap.size() <<endl;
00091 
00092     }
00093 
00094     auto_ptr<reco::TrackToTrackMap> trackToTrackmap(new reco::TrackToTrackMap(ttmap));
00095     iEvent.put(trackToTrackmap, mapname);
00096   }
00097 
00098 }

int CosmicMuonLinksProducer::sharedHits ( const reco::Track track1,
const reco::Track track2 
) const [private]

Definition at line 116 of file CosmicMuonLinksProducer.cc.

References category_, DetId::det(), e, lat::endl(), LogTrace, edm::match(), DetId::Muon, DetId::rawId(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), and theService.

Referenced by mapTracks().

00116                                                                                               {
00117 
00118   int match = 0;
00119 
00120   for (trackingRecHit_iterator hit1 = track1.recHitsBegin(); hit1 != track1.recHitsEnd(); ++hit1) {
00121     if ( !(*hit1)->isValid() ) continue;
00122     DetId id1 = (*hit1)->geographicalId();
00123     if ( id1.det() != DetId::Muon ) continue; //ONLY MUON
00124     LogTrace(category_)<<"first ID "<<id1.rawId()<<" "<<(*hit1)->localPosition()<<endl;
00125     GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
00126 
00127     for (trackingRecHit_iterator hit2 = track2.recHitsBegin(); hit2 != track2.recHitsEnd(); ++hit2) {
00128 
00129           if ( !(*hit2)->isValid() ) continue;
00130 
00131           DetId id2 = (*hit2)->geographicalId();
00132           if ( id2.det() != DetId::Muon ) continue; //ONLY MUON
00133 
00134 //          LogTrace(category_)<<"second ID "<<id2.rawId()<< (*hit2)->localPosition()<<endl;
00135 
00136           if (id2.rawId() != id1.rawId() ) continue;
00137 
00138           GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
00139           if ( ( pos1 - pos2 ).mag()< 10e-5 ) match++;
00140 
00141         }
00142 
00143     }
00144 
00145    return match;
00146 
00147 }


Member Data Documentation

std::string CosmicMuonLinksProducer::category_ [private]

Definition at line 35 of file CosmicMuonLinksProducer.h.

Referenced by CosmicMuonLinksProducer(), mapTracks(), produce(), and sharedHits().

MuonServiceProxy* CosmicMuonLinksProducer::theService [private]

Definition at line 31 of file CosmicMuonLinksProducer.h.

Referenced by CosmicMuonLinksProducer(), produce(), sharedHits(), and ~CosmicMuonLinksProducer().

std::vector<std::pair<edm::InputTag, edm::InputTag> > CosmicMuonLinksProducer::theTrackLinks [private]

Definition at line 33 of file CosmicMuonLinksProducer.h.

Referenced by CosmicMuonLinksProducer(), and produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:16:54 2009 for CMSSW by  doxygen 1.5.4