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 once each job just before starting event loop ------------
68 void
70 {
71 }
72 
73 // ------------ method called once each job just after ending the event loop ------------
74 void
76 }
77 
78 // ------------ method called to produce the data ------------
79 void
81 
82  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMap(new reco::MuonTimeExtraMap());
83  reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
84  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapDT(new reco::MuonTimeExtraMap());
85  reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
86  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapCSC(new reco::MuonTimeExtraMap());
87  reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
88 
90  iEvent.getByToken(muonToken_, muons);
91 
92  unsigned int nMuons = muons->size();
93 
94  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
95  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
96  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
97 
98  for ( unsigned int i=0; i<nMuons; ++i ) {
99 
100  reco::MuonTimeExtra dtTime;
101  reco::MuonTimeExtra cscTime;
102  reco::MuonTimeExtra combinedTime;
103 
104  reco::MuonRef muonr(muons,i);
105 
106  theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, combinedTime, iEvent, iSetup);
107 
108  dtTimeColl[i] = dtTime;
109  cscTimeColl[i] = cscTime;
110  combinedTimeColl[i] = combinedTime;
111 
112  }
113 
114  filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
115  filler.fill();
116  fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
117  fillerDT.fill();
118  fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
119  fillerCSC.fill();
120 
121  iEvent.put(muonTimeMap,"combined");
122  iEvent.put(muonTimeMapDT,"dt");
123  iEvent.put(muonTimeMapCSC,"csc");
124 
125 }
126 
127 
128 //define this as a plug-in
129 //DEFINE_FWK_MODULE(MuonTimingProducer);
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MuonTimingProducer(const edm::ParameterSet &)
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:243
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.
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag m_muonCollection
edm::EDGetTokenT< reco::MuonCollection > muonToken_
virtual void beginJob()
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)