CMS 3D CMS Logo

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 
26 
28 
33 
36 
37 //
38 // constructors and destructor
39 //
41  produces<reco::MuonTimeExtraMap>("combined");
42  produces<reco::MuonTimeExtraMap>("dt");
43  produces<reco::MuonTimeExtraMap>("csc");
44 
45  m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
46  muonToken_ = consumes<reco::MuonCollection>(m_muonCollection);
47  // Load parameters for the TimingFiller
48  edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
49  theTimingFiller_ = new MuonTimingFiller(fillerParameters, consumesCollector());
50 }
51 
53  if (theTimingFiller_)
54  delete theTimingFiller_;
55 }
56 
57 //
58 // member functions
59 //
60 
61 // ------------ method called to produce the data ------------
63  auto muonTimeMap = std::make_unique<reco::MuonTimeExtraMap>();
65  auto muonTimeMapDT = std::make_unique<reco::MuonTimeExtraMap>();
66  reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
67  auto muonTimeMapCSC = std::make_unique<reco::MuonTimeExtraMap>();
68  reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
69 
71  iEvent.getByToken(muonToken_, muons);
72 
73  unsigned int nMuons = muons->size();
74 
75  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
76  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
77  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
78 
79  for (unsigned int i = 0; i < nMuons; ++i) {
80  reco::MuonTimeExtra dtTime;
81  reco::MuonTimeExtra cscTime;
82  reco::MuonTime rpcTime;
83  reco::MuonTimeExtra combinedTime;
84 
85  reco::MuonRef muonr(muons, i);
86 
87  theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, rpcTime, combinedTime, iEvent, iSetup);
88 
89  dtTimeColl[i] = dtTime;
90  cscTimeColl[i] = cscTime;
91  combinedTimeColl[i] = combinedTime;
92  }
93 
94  filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
95  filler.fill();
96  fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
97  fillerDT.fill();
98  fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
99  fillerCSC.fill();
100 
101  iEvent.put(std::move(muonTimeMap), "combined");
102  iEvent.put(std::move(muonTimeMapDT), "dt");
103  iEvent.put(std::move(muonTimeMapCSC), "csc");
104 }
105 
106 //define this as a plug-in
107 //DEFINE_FWK_MODULE(MuonTimingProducer);
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
MuonTimingProducer(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
~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
edm::InputTag m_muonCollection
edm::EDGetTokenT< reco::MuonCollection > muonToken_
def move(src, dest)
Definition: eostools.py:511