Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-16 00:32:46

0001 //
0002 // Original Author:  Marco Zanetti
0003 //         Created:  Tue Sep  9 15:56:24 CEST 2008
0004 
0005 // user include files
0006 #include "CalibMuon/DTCalibration/interface/DTCalibMuonSelection.h"
0007 
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Utilities/interface/InputTag.h"
0011 
0012 #include "DataFormats/MuonReco/interface/Muon.h"
0013 
0014 #include "DataFormats/TrackReco/interface/Track.h"
0015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0016 
0017 using namespace edm;
0018 using namespace reco;
0019 
0020 DTCalibMuonSelection::DTCalibMuonSelection(const edm::ParameterSet& iConfig) {
0021   muonList = consumes<MuonCollection>(iConfig.getParameter<edm::InputTag>("src"));
0022   etaMin = iConfig.getParameter<double>("etaMin");
0023   etaMax = iConfig.getParameter<double>("etaMax");
0024   ptMin = iConfig.getParameter<double>("ptMin");
0025 }
0026 
0027 DTCalibMuonSelection::~DTCalibMuonSelection() {}
0028 
0029 bool DTCalibMuonSelection::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0030   bool result = false;
0031 
0032   //Retrieve the muons list
0033   Handle<MuonCollection> MuHandle;
0034   iEvent.getByToken(muonList, MuHandle);
0035 
0036   for (MuonCollection::const_iterator nmuon = MuHandle->begin(); nmuon != MuHandle->end(); ++nmuon) {
0037     double ptMuon(0.);
0038     double etaMuon(-999.);
0039 
0040     if (nmuon->isGlobalMuon()) {
0041       ptMuon = nmuon->globalTrack()->pt();
0042       etaMuon = nmuon->globalTrack()->eta();
0043     } else
0044       continue;
0045 
0046     if (ptMuon > ptMin && etaMuon > etaMin && etaMuon < etaMax) {
0047       result = true;
0048       break;
0049     }
0050   }
0051 
0052   return result;
0053 }
0054 
0055 // ------------ method called once each job just before starting event loop  ------------
0056 void DTCalibMuonSelection::beginStream(edm::StreamID) {}
0057 
0058 // ------------ method called once each job just after ending the event loop  ------------
0059 void DTCalibMuonSelection::endStream() {}