CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
69  // ----------member data ---------------------------
70 };
71 
72 //
73 // constants, enums and typedefs
74 //
75 
76 //
77 // static data member definitions
78 //
79 
80 //
81 // constructors and destructor
82 //
84 
85 {
86  //now do what ever initialization is needed
87 
88 }
89 
90 
92 {
93 
94  // do anything here that needs to be done at desctruction time
95  // (e.g. close files, deallocate resources etc.)
96 
97 }
98 
99 
100 //
101 // member functions
102 //
103 
104 // ------------ method called for each event ------------
105 void
107 {
108  using namespace edm;
109 
110  if (!corfile.IsInitialized()) {
111  corfile.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/gbrv3ph.root");
112  //corfile.Initialize(iSetup,"wgbrph",true);
113  }
114 
115  if (!cordb.IsInitialized()) {
116  //cordb.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/regweights/gbrph.root");
117  cordb.Initialize(iSetup,"wgbrph",true);
118  }
119 
120  // get photon collection
121  Handle<reco::PhotonCollection> hPhotonProduct;
122  iEvent.getByLabel("photons",hPhotonProduct);
123 
124  EcalClusterLazyTools lazyTools(iEvent, iSetup, edm::InputTag("reducedEcalRecHitsEB"),
125  edm::InputTag("reducedEcalRecHitsEE"));
126 
127  Handle<reco::VertexCollection> hVertexProduct;
128  iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct);
129 
130  for (reco::PhotonCollection::const_iterator it = hPhotonProduct->begin(); it!=hPhotonProduct->end(); ++it) {
131  std::pair<double,double> corsfile = corfile.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
132  std::pair<double,double> corsdb = cordb.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
133 
134 
135  printf("file: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsfile.first,corsfile.second);
136  printf("db: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsdb.first,corsdb.second);
137 
138  }
139 
140 
141 
142 
143 }
144 
145 
146 // ------------ method called once each job just before starting event loop ------------
147 void
149 {
150 
151 
152 
153 }
154 
155 // ------------ method called once each job just after ending the event loop ------------
156 void
158 {
159 }
160 
161 // ------------ method called when starting to processes a run ------------
162 void
164 {
165 }
166 
167 // ------------ method called when ending the processing of a run ------------
168 void
170 {
171 }
172 
173 // ------------ method called when starting to processes a luminosity block ------------
174 void
176 {
177 }
178 
179 // ------------ method called when ending the processing of a luminosity block ------------
180 void
182 {
183 }
184 
185 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
186 void
188  //The following says we do not know what parameters are allowed so do no validation
189  // Please change this to state exactly what you do use, even if it is no parameters
191  desc.setUnknown();
192  descriptions.addDefault(desc);
193 }
194 
195 //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
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:243
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:390
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)
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
virtual void beginJob() override
Definition: Run.h:41