CMS 3D CMS Logo

EGEnergyAnalyzer.cc
Go to the documentation of this file.
1  // -*- C++ -*-
2 //
3 // Package: EGEnergyAnalyzer
4 // Class: EGEnergyAnalyzer
5 //
13 //
14 // Original Author: Josh Bendavid
15 // Created: Tue Nov 8 22:26:45 CET 2011
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 #include "TFile.h"
33 //#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
34 //#include "CondCore/DBCommon/interface/CoralServiceManager.h"
35 
42 
43 
44 //
45 // class declaration
46 //
47 
49 public:
50  explicit EGEnergyAnalyzer(const edm::ParameterSet&);
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 
56 private:
57  virtual void beginJob() override ;
58  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
59  virtual void endJob() override ;
60 
61  virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
62  virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
63  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
64  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
65 
68 
70 };
71 
72 
74 
75  ebRHToken_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
76  eeRHToken_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
77 }
78 
79 
81 {
82 
83  // do anything here that needs to be done at desctruction time
84  // (e.g. close files, deallocate resources etc.)
85 
86 }
87 
88 
89 //
90 // member functions
91 //
92 
93 // ------------ method called for each event ------------
94 void
96 {
97  using namespace edm;
98 
99  if (!corfile.IsInitialized()) {
100  corfile.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/gbrv3ph.root");
101  //corfile.Initialize(iSetup,"wgbrph",true);
102  }
103 
104  if (!cordb.IsInitialized()) {
105  //cordb.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/regweights/gbrph.root");
106  cordb.Initialize(iSetup,"wgbrph",true);
107  }
108 
109  // get photon collection
110  Handle<reco::PhotonCollection> hPhotonProduct;
111  iEvent.getByLabel("photons",hPhotonProduct);
112 
113  EcalClusterLazyTools lazyTools(iEvent, iSetup, ebRHToken_, eeRHToken_);
114 
115  Handle<reco::VertexCollection> hVertexProduct;
116  iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct);
117 
118  for (reco::PhotonCollection::const_iterator it = hPhotonProduct->begin(); it!=hPhotonProduct->end(); ++it) {
119  std::pair<double,double> corsfile = corfile.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
120  std::pair<double,double> corsdb = cordb.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
121 
122 
123  printf("file: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsfile.first,corsfile.second);
124  printf("db: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsdb.first,corsdb.second);
125 
126  }
127 
128 
129 
130 
131 }
132 
133 
134 // ------------ method called once each job just before starting event loop ------------
135 void
137 {
138 
139 
140 
141 }
142 
143 // ------------ method called once each job just after ending the event loop ------------
144 void
146 {
147 }
148 
149 // ------------ method called when starting to processes a run ------------
150 void
152 {
153 }
154 
155 // ------------ method called when ending the processing of a run ------------
156 void
158 {
159 }
160 
161 // ------------ method called when starting to processes a luminosity block ------------
162 void
164 {
165 }
166 
167 // ------------ method called when ending the processing of a luminosity block ------------
168 void
170 {
171 }
172 
173 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
174 void
176  //The following says we do not know what parameters are allowed so do no validation
177  // Please change this to state exactly what you do use, even if it is no parameters
179  desc.setUnknown();
180  descriptions.addDefault(desc);
181 }
182 
183 //define this as a plug-in
void Initialize(const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
EGEnergyAnalyzer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endJob() override
EGEnergyCorrector corfile
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< EcalRecHitCollection > ebRHToken_
EGEnergyCorrector cordb
std::pair< double, double > CorrectedEnergyWithError(const reco::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
Bool_t IsInitialized() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< EcalRecHitCollection > eeRHToken_
virtual void beginJob() override
Definition: Run.h:42