CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuonTimingProducer.cc
Go to the documentation of this file.
1 //
2 // Package: MuonTimingProducer
3 // Class: MuonTimingProducer
4 //
12 //
13 // Original Author: Piotr Traczyk, CERN
14 // Created: Mon Mar 16 12:27:22 CET 2009
15 //
16 //
17 
18 // system include files
19 #include <memory>
20 
21 // user include files
23 //#include "FWCore/Framework/interface/EDProducer.h"
24 
27 
29 
34 
37 
38 //
39 // constructors and destructor
40 //
42  produces<reco::MuonTimeExtraMap>("combined");
43  produces<reco::MuonTimeExtraMap>("dt");
44  produces<reco::MuonTimeExtraMap>("csc");
45 
46  m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
47  muonToken_ = consumes<reco::MuonCollection>(m_muonCollection);
48  // Load parameters for the TimingFiller
49  edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
50  theTimingFiller_ = new MuonTimingFiller(fillerParameters, consumesCollector());
51 }
52 
54  if (theTimingFiller_)
55  delete theTimingFiller_;
56 }
57 
58 //
59 // member functions
60 //
61 
62 // ------------ method called to produce the data ------------
64  auto muonTimeMap = std::make_unique<reco::MuonTimeExtraMap>();
65  reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
66  auto muonTimeMapDT = std::make_unique<reco::MuonTimeExtraMap>();
67  reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
68  auto muonTimeMapCSC = std::make_unique<reco::MuonTimeExtraMap>();
69  reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
70 
72  iEvent.getByToken(muonToken_, muons);
73 
74  unsigned int nMuons = muons->size();
75 
76  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
77  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
78  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
79 
80  for (unsigned int i = 0; i < nMuons; ++i) {
81  reco::MuonTimeExtra dtTime;
82  reco::MuonTimeExtra cscTime;
83  reco::MuonTime rpcTime;
84  reco::MuonTimeExtra combinedTime;
85 
86  reco::MuonRef muonr(muons, i);
87 
88  theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, rpcTime, combinedTime, iEvent, iSetup);
89 
90  dtTimeColl[i] = dtTime;
91  cscTimeColl[i] = cscTime;
92  combinedTimeColl[i] = combinedTime;
93  }
94 
95  filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
96  filler.fill();
97  fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
98  fillerDT.fill();
99  fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
100  fillerCSC.fill();
101 
102  iEvent.put(std::move(muonTimeMap), "combined");
103  iEvent.put(std::move(muonTimeMapDT), "dt");
104  iEvent.put(std::move(muonTimeMapCSC), "csc");
105 }
106 
107 //define this as a plug-in
108 //DEFINE_FWK_MODULE(MuonTimingProducer);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
MuonTimingProducer(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
~MuonTimingProducer() override
void fillTiming(const reco::Muon &muon, reco::MuonTimeExtra &dtTime, reco::MuonTimeExtra &cscTime, reco::MuonTime &rpcTime, reco::MuonTimeExtra &combinedTime, edm::Event &iEvent, const edm::EventSetup &iSetup)
MuonTimingFiller * theTimingFiller_
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
edm::InputTag m_muonCollection
edm::EDGetTokenT< reco::MuonCollection > muonToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple muons
Definition: patZpeak.py:41