CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoHI/HiMuonAlgos/plugins/HIMuonTrackingRegionProducer.h

Go to the documentation of this file.
00001 #ifndef RecoHI_HiTracking_HIMuonTrackingRegionProducer_H 
00002 #define RecoHI_HiTracking_HIMuonTrackingRegionProducer_H
00003 
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 
00006 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
00007 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
00008 #include "RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h"
00009 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00010 
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/Framework/interface/Event.h"
00016 
00017 class HIMuonTrackingRegionProducer : public TrackingRegionProducer {
00018   
00019  public:
00020   
00021   HIMuonTrackingRegionProducer(const edm::ParameterSet& cfg) { 
00022         
00023     // get parameters from PSet
00024     theMuonSource                         = cfg.getParameter<edm::InputTag>("MuonSrc");
00025     
00026     // initialize region builder
00027     edm::ParameterSet regionBuilderPSet   = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
00028     theRegionBuilder                      = new MuonTrackingRegionBuilder(regionBuilderPSet);
00029 
00030     // initialize muon service proxy
00031     edm::ParameterSet servicePSet         = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
00032     theService                            = new MuonServiceProxy(servicePSet);
00033 
00034   }  
00035   
00036 
00037   virtual ~HIMuonTrackingRegionProducer(){}
00038   
00039 
00040   virtual std::vector<TrackingRegion* > regions(const edm::Event& ev, const edm::EventSetup& es) const {
00041     
00042     // initialize output vector of tracking regions
00043     std::vector<TrackingRegion* > result;
00044 
00045     // initialize the region builder
00046     theService->update(es);
00047     theRegionBuilder->init(theService);
00048     theRegionBuilder->setEvent(ev);
00049 
00050     // get stand-alone muon collection
00051     edm::Handle<reco::TrackCollection> muonH;
00052     ev.getByLabel(theMuonSource ,muonH);
00053     
00054     // loop over all muons and add a tracking region for each
00055     // that passes the requirements specified to theRegionBuilder
00056     unsigned int nMuons = muonH->size();
00057     //std::cout << "there are " << nMuons << " muon(s)" << std::endl;
00058 
00059     // TO DO: this can be extended further to a double-loop 
00060     // over all combinations of muons, returning tracking regions
00061     // for pairs that pass some loose invariant mass cuts
00062     for(unsigned int imu=0; imu<nMuons; imu++) {
00063       reco::TrackRef muRef(muonH, imu);
00064       //std::cout << "muon #" << imu << ": pt=" << muRef->pt() << std::endl;
00065       RectangularEtaPhiTrackingRegion *etaphiRegion = theRegionBuilder->region(muRef);
00066       result.push_back(etaphiRegion);
00067     }
00068 
00069     return result;
00070 
00071   }
00072   
00073   
00074  private:
00075   
00076   edm::InputTag theMuonSource;
00077   MuonTrackingRegionBuilder* theRegionBuilder;
00078   MuonServiceProxy* theService;
00079   
00080 };
00081 
00082 #endif