File indexing completed on 2024-04-06 12:27:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <memory>
0020
0021
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023
0024 #include "FWCore/Framework/interface/Event.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028
0029 #include "DataFormats/MuonReco/interface/Muon.h"
0030 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0031 #include "DataFormats/MuonReco/interface/MuonTimeExtra.h"
0032 #include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h"
0033
0034 #include "RecoMuon/MuonIdentification/plugins/MuonTimingProducer.h"
0035 #include "RecoMuon/MuonIdentification/interface/TimeMeasurementSequence.h"
0036
0037
0038
0039
0040 MuonTimingProducer::MuonTimingProducer(const edm::ParameterSet& iConfig) {
0041 produces<reco::MuonTimeExtraMap>("combined");
0042 produces<reco::MuonTimeExtraMap>("dt");
0043 produces<reco::MuonTimeExtraMap>("csc");
0044
0045 m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
0046 muonToken_ = consumes<reco::MuonCollection>(m_muonCollection);
0047
0048 edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
0049 theTimingFiller_ = new MuonTimingFiller(fillerParameters, consumesCollector());
0050 }
0051
0052 MuonTimingProducer::~MuonTimingProducer() {
0053 if (theTimingFiller_)
0054 delete theTimingFiller_;
0055 }
0056
0057
0058
0059
0060
0061
0062 void MuonTimingProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0063 auto muonTimeMap = std::make_unique<reco::MuonTimeExtraMap>();
0064 reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
0065 auto muonTimeMapDT = std::make_unique<reco::MuonTimeExtraMap>();
0066 reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
0067 auto muonTimeMapCSC = std::make_unique<reco::MuonTimeExtraMap>();
0068 reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
0069
0070 edm::Handle<reco::MuonCollection> muons;
0071 iEvent.getByToken(muonToken_, muons);
0072
0073 unsigned int nMuons = muons->size();
0074
0075 std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
0076 std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
0077 std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
0078
0079 for (unsigned int i = 0; i < nMuons; ++i) {
0080 reco::MuonTimeExtra dtTime;
0081 reco::MuonTimeExtra cscTime;
0082 reco::MuonTime rpcTime;
0083 reco::MuonTimeExtra combinedTime;
0084
0085 reco::MuonRef muonr(muons, i);
0086
0087 theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, rpcTime, combinedTime, iEvent, iSetup);
0088
0089 dtTimeColl[i] = dtTime;
0090 cscTimeColl[i] = cscTime;
0091 combinedTimeColl[i] = combinedTime;
0092 }
0093
0094 filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
0095 filler.fill();
0096 fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
0097 fillerDT.fill();
0098 fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
0099 fillerCSC.fill();
0100
0101 iEvent.put(std::move(muonTimeMap), "combined");
0102 iEvent.put(std::move(muonTimeMapDT), "dt");
0103 iEvent.put(std::move(muonTimeMapCSC), "csc");
0104 }
0105
0106
0107