00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "FWCore/Framework/interface/EDProducer.h"
00015
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/EventSetup.h"
00018
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020
00021 #include "DataFormats/Common/interface/Handle.h"
00022 #include "DataFormats/MuonReco/interface/Muon.h"
00023 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00024
00025 #include "RecoMuon/MuonIdentification/plugins/MuonRefProducer.h"
00026 #include "DataFormats/Common/interface/Ref.h"
00027 #include "DataFormats/Common/interface/RefVector.h"
00028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00029 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00030
00031 MuonRefProducer::MuonRefProducer(const edm::ParameterSet& iConfig)
00032 {
00033 theReferenceCollection_ = iConfig.getParameter<edm::InputTag>("ReferenceCollection");
00034 type_ = muon::TMLastStation;
00035 std::string type = iConfig.getParameter<std::string>("algorithmType");
00036 if ( type.compare("TMLastStation") != 0 )
00037 edm::LogWarning("MuonIdentification") << "Unknown algorithm type is requested: " << type << "\nUsing the default one.";
00038
00039 minNumberOfMatches_ = iConfig.getParameter<int>("minNumberOfMatchedStations");
00040 maxAbsDx_ = iConfig.getParameter<double>("maxAbsDx");
00041 maxAbsPullX_ = iConfig.getParameter<double>("maxAbsPullX");
00042 maxAbsDy_ = iConfig.getParameter<double>("maxAbsDy");
00043 maxAbsPullY_ = iConfig.getParameter<double>("maxAbsPullY");
00044 maxChamberDist_ = iConfig.getParameter<double>("maxChamberDistance");
00045 maxChamberDistPull_ = iConfig.getParameter<double>("maxChamberDistancePull");
00046
00047 std::string arbitrationType = iConfig.getParameter<std::string>("arbitrationType");
00048 if (arbitrationType.compare("NoArbitration")==0)
00049 arbitrationType_ = reco::Muon::NoArbitration;
00050 else if (arbitrationType.compare("SegmentArbitration")==0)
00051 arbitrationType_ = reco::Muon::SegmentArbitration;
00052 else if (arbitrationType.compare("SegmentAndTrackArbitration")==0)
00053 arbitrationType_ = reco::Muon::SegmentAndTrackArbitration;
00054 else {
00055 edm::LogWarning("MuonIdentification") << "Unknown arbitration type is requested: " << arbitrationType << "\nUsing the default one";
00056 arbitrationType_ = reco::Muon::SegmentAndTrackArbitration;
00057 }
00058 produces<edm::RefVector<std::vector<reco::Muon> > >();
00059 }
00060
00061
00062 MuonRefProducer::~MuonRefProducer(){}
00063
00064 void MuonRefProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00065 {
00066 using namespace edm;
00067
00068 std::auto_ptr<edm::RefVector<std::vector<reco::Muon> > > outputCollection(new edm::RefVector<std::vector<reco::Muon> >);
00069
00070 edm::Handle<reco::MuonCollection> muons;
00071 iEvent.getByLabel(theReferenceCollection_, muons);
00072
00073
00074 for ( unsigned int i=0; i<muons->size(); ++i )
00075 if ( muon::isGoodMuon( (*muons)[i], type_, minNumberOfMatches_,
00076 maxAbsDx_, maxAbsPullX_, maxAbsDy_, maxAbsPullY_, maxChamberDist_, maxChamberDistPull_, arbitrationType_) )
00077 outputCollection->push_back( edm::RefVector<std::vector<reco::Muon> >::value_type(muons,i) );
00078 iEvent.put(outputCollection);
00079 }