CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoMuon/MuonIdentification/plugins/MuonRefProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    MuonIdentification
00004 // Class:      MuonRefProducer
00005 // 
00006 //
00007 // Original Author:  Dmytro Kovalskyi
00008 // $Id: MuonRefProducer.cc,v 1.5 2010/03/25 14:08:49 jribnik Exp $
00009 //
00010 //
00011 
00012 // user include files
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; // default type
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    std::auto_ptr<edm::RefVector<std::vector<reco::Muon> > > outputCollection(new edm::RefVector<std::vector<reco::Muon> >);
00067 
00068    edm::Handle<reco::MuonCollection> muons;
00069    iEvent.getByLabel(theReferenceCollection_, muons);
00070    
00071    // loop over input collection
00072    for ( unsigned int i=0; i<muons->size(); ++i ) 
00073      if ( muon::isGoodMuon( (*muons)[i], type_, minNumberOfMatches_,
00074           maxAbsDx_, maxAbsPullX_, maxAbsDy_, maxAbsPullY_, maxChamberDist_, maxChamberDistPull_, arbitrationType_) )
00075        outputCollection->push_back( edm::RefVector<std::vector<reco::Muon> >::value_type(muons,i) );
00076    iEvent.put(outputCollection);
00077 }