test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
19 // system include files
20 #include <memory>
21 
22 // user include files
24 //#include "FWCore/Framework/interface/EDProducer.h"
25 
28 
30 
35 
38 
39 
40 //
41 // constructors and destructor
42 //
44 {
45  produces<reco::MuonTimeExtraMap>("combined");
46  produces<reco::MuonTimeExtraMap>("dt");
47  produces<reco::MuonTimeExtraMap>("csc");
48 
49  m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
50  muonToken_ = consumes<reco::MuonCollection>(m_muonCollection);
51  // Load parameters for the TimingFiller
52  edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
53  theTimingFiller_ = new MuonTimingFiller(fillerParameters,consumesCollector());
54 }
55 
56 
58 {
60 }
61 
62 
63 //
64 // member functions
65 //
66 
67 // ------------ method called to produce the data ------------
68 void
70 
71  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMap(new reco::MuonTimeExtraMap());
72  reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
73  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapDT(new reco::MuonTimeExtraMap());
74  reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
75  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapCSC(new reco::MuonTimeExtraMap());
76  reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
77 
79  iEvent.getByToken(muonToken_, muons);
80 
81  unsigned int nMuons = muons->size();
82 
83  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
84  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
85  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
86 
87  for ( unsigned int i=0; i<nMuons; ++i ) {
88 
89  reco::MuonTimeExtra dtTime;
90  reco::MuonTimeExtra cscTime;
91  reco::MuonTime rpcTime;
92  reco::MuonTimeExtra combinedTime;
93 
94  reco::MuonRef muonr(muons,i);
95 
96  theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, rpcTime, combinedTime, iEvent, iSetup);
97 
98  dtTimeColl[i] = dtTime;
99  cscTimeColl[i] = cscTime;
100  combinedTimeColl[i] = combinedTime;
101 
102  }
103 
104  filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
105  filler.fill();
106  fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
107  fillerDT.fill();
108  fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
109  fillerCSC.fill();
110 
111  iEvent.put(muonTimeMap,"combined");
112  iEvent.put(muonTimeMapDT,"dt");
113  iEvent.put(muonTimeMapCSC,"csc");
114 
115 }
116 
117 
118 //define this as a plug-in
119 //DEFINE_FWK_MODULE(MuonTimingProducer);
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MuonTimingProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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)
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
MuonTimingFiller * theTimingFiller_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::InputTag m_muonCollection
edm::EDGetTokenT< reco::MuonCollection > muonToken_
tuple muons
Definition: patZpeak.py:38