Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:56

0001 //
0002 // Package:    MuonTimingProducer
0003 // Class:      MuonTimingProducer
0004 //
0005 /**\class MuonTimingProducer MuonTimingProducer.cc RecoMuon/MuonIdentification/src/MuonTimingProducer.cc
0006 
0007  Description: <one line class summary>
0008 
0009  Implementation:
0010      <Notes on implementation>
0011 */
0012 //
0013 // Original Author:  Piotr Traczyk, CERN
0014 //         Created:  Mon Mar 16 12:27:22 CET 2009
0015 //
0016 //
0017 
0018 // system include files
0019 #include <memory>
0020 
0021 // user include files
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 //#include "FWCore/Framework/interface/EDProducer.h"
0024 
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 
0030 #include "DataFormats/MuonReco/interface/Muon.h"
0031 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0032 #include "DataFormats/MuonReco/interface/MuonTimeExtra.h"
0033 #include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h"
0034 
0035 #include "RecoMuon/MuonIdentification/plugins/MuonTimingProducer.h"
0036 #include "RecoMuon/MuonIdentification/interface/TimeMeasurementSequence.h"
0037 
0038 //
0039 // constructors and destructor
0040 //
0041 MuonTimingProducer::MuonTimingProducer(const edm::ParameterSet& iConfig) {
0042   produces<reco::MuonTimeExtraMap>("combined");
0043   produces<reco::MuonTimeExtraMap>("dt");
0044   produces<reco::MuonTimeExtraMap>("csc");
0045 
0046   m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
0047   muonToken_ = consumes<reco::MuonCollection>(m_muonCollection);
0048   // Load parameters for the TimingFiller
0049   edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
0050   theTimingFiller_ = new MuonTimingFiller(fillerParameters, consumesCollector());
0051 }
0052 
0053 MuonTimingProducer::~MuonTimingProducer() {
0054   if (theTimingFiller_)
0055     delete theTimingFiller_;
0056 }
0057 
0058 //
0059 // member functions
0060 //
0061 
0062 // ------------ method called to produce the data  ------------
0063 void MuonTimingProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0064   auto muonTimeMap = std::make_unique<reco::MuonTimeExtraMap>();
0065   reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
0066   auto muonTimeMapDT = std::make_unique<reco::MuonTimeExtraMap>();
0067   reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
0068   auto muonTimeMapCSC = std::make_unique<reco::MuonTimeExtraMap>();
0069   reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
0070 
0071   edm::Handle<reco::MuonCollection> muons;
0072   iEvent.getByToken(muonToken_, muons);
0073 
0074   unsigned int nMuons = muons->size();
0075 
0076   std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
0077   std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
0078   std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
0079 
0080   for (unsigned int i = 0; i < nMuons; ++i) {
0081     reco::MuonTimeExtra dtTime;
0082     reco::MuonTimeExtra cscTime;
0083     reco::MuonTime rpcTime;
0084     reco::MuonTimeExtra combinedTime;
0085 
0086     reco::MuonRef muonr(muons, i);
0087 
0088     theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, rpcTime, combinedTime, iEvent, iSetup);
0089 
0090     dtTimeColl[i] = dtTime;
0091     cscTimeColl[i] = cscTime;
0092     combinedTimeColl[i] = combinedTime;
0093   }
0094 
0095   filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
0096   filler.fill();
0097   fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
0098   fillerDT.fill();
0099   fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
0100   fillerCSC.fill();
0101 
0102   iEvent.put(std::move(muonTimeMap), "combined");
0103   iEvent.put(std::move(muonTimeMapDT), "dt");
0104   iEvent.put(std::move(muonTimeMapCSC), "csc");
0105 }
0106 
0107 //define this as a plug-in
0108 //DEFINE_FWK_MODULE(MuonTimingProducer);