CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoMuon/MuonIdentification/plugins/MuonTimingProducer.cc

Go to the documentation of this file.
00001 //
00002 // Package:    MuonTimingProducer
00003 // Class:      MuonTimingProducer
00004 // 
00012 //
00013 // Original Author:  Piotr Traczyk, CERN
00014 //         Created:  Mon Mar 16 12:27:22 CET 2009
00015 // $Id: MuonTimingProducer.cc,v 1.6 2010/04/15 12:34:30 ptraczyk Exp $
00016 //
00017 //
00018 
00019 
00020 // system include files
00021 #include <memory>
00022 
00023 // user include files
00024 #include "FWCore/Framework/interface/Frameworkfwd.h"
00025 #include "FWCore/Framework/interface/EDProducer.h"
00026 
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/Framework/interface/MakerMacros.h"
00029 
00030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00031 
00032 #include "DataFormats/MuonReco/interface/Muon.h" 
00033 #include "DataFormats/MuonReco/interface/MuonFwd.h" 
00034 #include "DataFormats/MuonReco/interface/MuonTimeExtra.h"
00035 #include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h"
00036 
00037 #include "RecoMuon/MuonIdentification/plugins/MuonTimingProducer.h"
00038 #include "RecoMuon/MuonIdentification/interface/TimeMeasurementSequence.h"
00039 
00040 
00041 //
00042 // constructors and destructor
00043 //
00044 MuonTimingProducer::MuonTimingProducer(const edm::ParameterSet& iConfig)
00045 {
00046    produces<reco::MuonTimeExtraMap>("combined");
00047    produces<reco::MuonTimeExtraMap>("dt");
00048    produces<reco::MuonTimeExtraMap>("csc");
00049 
00050    m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
00051 
00052    // Load parameters for the TimingFiller
00053    edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
00054    theTimingFiller_ = new MuonTimingFiller(fillerParameters);
00055 }
00056 
00057 
00058 MuonTimingProducer::~MuonTimingProducer()
00059 {
00060    if (theTimingFiller_) delete theTimingFiller_;
00061 }
00062 
00063 
00064 //
00065 // member functions
00066 //
00067 
00068 // ------------ method called once each job just before starting event loop  ------------
00069 void 
00070 MuonTimingProducer::beginJob()
00071 {
00072 }
00073 
00074 // ------------ method called once each job just after ending the event loop  ------------
00075 void 
00076 MuonTimingProducer::endJob() {
00077 }
00078 
00079 // ------------ method called to produce the data  ------------
00080 void
00081 MuonTimingProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00082 
00083   std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMap(new reco::MuonTimeExtraMap());
00084   reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
00085   std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapDT(new reco::MuonTimeExtraMap());
00086   reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
00087   std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapCSC(new reco::MuonTimeExtraMap());
00088   reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
00089   
00090   edm::Handle<reco::MuonCollection> muons; 
00091   iEvent.getByLabel(m_muonCollection, muons);
00092 
00093   unsigned int nMuons = muons->size();
00094   
00095   std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
00096   std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
00097   std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
00098 
00099   for ( unsigned int i=0; i<nMuons; ++i ) {
00100 
00101     reco::MuonTimeExtra dtTime;
00102     reco::MuonTimeExtra cscTime;
00103     reco::MuonTimeExtra combinedTime;
00104 
00105     reco::MuonRef muonr(muons,i);
00106     
00107     theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, combinedTime, iEvent, iSetup);
00108     
00109     dtTimeColl[i] = dtTime;
00110     cscTimeColl[i] = cscTime;
00111     combinedTimeColl[i] = combinedTime;
00112      
00113   }
00114   
00115   filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
00116   filler.fill();
00117   fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
00118   fillerDT.fill();
00119   fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
00120   fillerCSC.fill();
00121 
00122   iEvent.put(muonTimeMap,"combined");
00123   iEvent.put(muonTimeMapDT,"dt");
00124   iEvent.put(muonTimeMapCSC,"csc");
00125 
00126 }
00127 
00128 
00129 //define this as a plug-in
00130 //DEFINE_FWK_MODULE(MuonTimingProducer);