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 // $Id: MuonTimingProducer.cc,v 1.6 2010/04/15 12:34:30 ptraczyk Exp $
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 
36 
39 
40 
41 //
42 // constructors and destructor
43 //
45 {
46  produces<reco::MuonTimeExtraMap>("combined");
47  produces<reco::MuonTimeExtraMap>("dt");
48  produces<reco::MuonTimeExtraMap>("csc");
49 
50  m_muonCollection = iConfig.getParameter<edm::InputTag>("MuonCollection");
51 
52  // Load parameters for the TimingFiller
53  edm::ParameterSet fillerParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
54  theTimingFiller_ = new MuonTimingFiller(fillerParameters);
55 }
56 
57 
59 {
61 }
62 
63 
64 //
65 // member functions
66 //
67 
68 // ------------ method called once each job just before starting event loop ------------
69 void
71 {
72 }
73 
74 // ------------ method called once each job just after ending the event loop ------------
75 void
77 }
78 
79 // ------------ method called to produce the data ------------
80 void
82 
83  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMap(new reco::MuonTimeExtraMap());
84  reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
85  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapDT(new reco::MuonTimeExtraMap());
86  reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
87  std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapCSC(new reco::MuonTimeExtraMap());
88  reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);
89 
91  iEvent.getByLabel(m_muonCollection, muons);
92 
93  unsigned int nMuons = muons->size();
94 
95  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
96  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
97  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
98 
99  for ( unsigned int i=0; i<nMuons; ++i ) {
100 
101  reco::MuonTimeExtra dtTime;
102  reco::MuonTimeExtra cscTime;
103  reco::MuonTimeExtra combinedTime;
104 
105  reco::MuonRef muonr(muons,i);
106 
107  theTimingFiller_->fillTiming(*muonr, dtTime, cscTime, combinedTime, iEvent, iSetup);
108 
109  dtTimeColl[i] = dtTime;
110  cscTimeColl[i] = cscTime;
111  combinedTimeColl[i] = combinedTime;
112 
113  }
114 
115  filler.insert(muons, combinedTimeColl.begin(), combinedTimeColl.end());
116  filler.fill();
117  fillerDT.insert(muons, dtTimeColl.begin(), dtTimeColl.end());
118  fillerDT.fill();
119  fillerCSC.insert(muons, cscTimeColl.begin(), cscTimeColl.end());
120  fillerCSC.fill();
121 
122  iEvent.put(muonTimeMap,"combined");
123  iEvent.put(muonTimeMapDT,"dt");
124  iEvent.put(muonTimeMapCSC,"csc");
125 
126 }
127 
128 
129 //define this as a plug-in
130 //DEFINE_FWK_MODULE(MuonTimingProducer);
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MuonTimingProducer(const edm::ParameterSet &)
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
MuonTimingFiller * theTimingFiller_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag m_muonCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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)