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
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::MuonTimeExtra combinedTime;
92 
93  reco::MuonRef muonr(muons,i);
94 
95  theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, combinedTime, iEvent, iSetup);
96 
97  dtTimeColl[i] = dtTime;
98  cscTimeColl[i] = cscTime;
99  combinedTimeColl[i] = combinedTime;
100 
101  }
102 
103  filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
104  filler.fill();
105  fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
106  fillerDT.fill();
107  fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
108  fillerCSC.fill();
109 
110  iEvent.put(muonTimeMap,"combined");
111  iEvent.put(muonTimeMapDT,"dt");
112  iEvent.put(muonTimeMapCSC,"csc");
113 
114 }
115 
116 
117 //define this as a plug-in
118 //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:434
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:116
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
void fillTiming(const reco::Muon &muon, reco::MuonTimeExtra &dtTime, reco::MuonTimeExtra &cscTime, reco::MuonTimeExtra &combinedTime, edm::Event &iEvent, const edm::EventSetup &iSetup)