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 // $Id: EGEnergyAnalyzer.cc,v 1.3 2011/12/14 21:08:11 bendavid Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 #include "TFile.h"
34 //#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
35 //#include "CondCore/DBCommon/interface/CoralServiceManager.h"
36 
43 
44 
45 //
46 // class declaration
47 //
48 
50  public:
51  explicit EGEnergyAnalyzer(const edm::ParameterSet&);
53 
54  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
55 
56 
57  private:
58  virtual void beginJob() ;
59  virtual void analyze(const edm::Event&, const edm::EventSetup&);
60  virtual void endJob() ;
61 
62  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
63  virtual void endRun(edm::Run const&, edm::EventSetup const&);
64  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
65  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
66 
69 
70  // ----------member data ---------------------------
71 };
72 
73 //
74 // constants, enums and typedefs
75 //
76 
77 //
78 // static data member definitions
79 //
80 
81 //
82 // constructors and destructor
83 //
85 
86 {
87  //now do what ever initialization is needed
88 
89 }
90 
91 
93 {
94 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98 }
99 
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called for each event ------------
106 void
108 {
109  using namespace edm;
110 
111  if (!corfile.IsInitialized()) {
112  corfile.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/gbrv3ph.root");
113  //corfile.Initialize(iSetup,"wgbrph",true);
114  }
115 
116  if (!cordb.IsInitialized()) {
117  //cordb.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/regweights/gbrph.root");
118  cordb.Initialize(iSetup,"wgbrph",true);
119  }
120 
121  // get photon collection
122  Handle<reco::PhotonCollection> hPhotonProduct;
123  iEvent.getByLabel("photons",hPhotonProduct);
124 
125  EcalClusterLazyTools lazyTools(iEvent, iSetup, edm::InputTag("reducedEcalRecHitsEB"),
126  edm::InputTag("reducedEcalRecHitsEE"));
127 
128  Handle<reco::VertexCollection> hVertexProduct;
129  iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct);
130 
131  for (reco::PhotonCollection::const_iterator it = hPhotonProduct->begin(); it!=hPhotonProduct->end(); ++it) {
132  std::pair<double,double> corsfile = corfile.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
133  std::pair<double,double> corsdb = cordb.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
134 
135 
136  printf("file: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsfile.first,corsfile.second);
137  printf("db: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsdb.first,corsdb.second);
138 
139  }
140 
141 
142 
143 
144 }
145 
146 
147 // ------------ method called once each job just before starting event loop ------------
148 void
150 {
151 
152 
153 
154 }
155 
156 // ------------ method called once each job just after ending the event loop ------------
157 void
159 {
160 }
161 
162 // ------------ method called when starting to processes a run ------------
163 void
165 {
166 }
167 
168 // ------------ method called when ending the processing of a run ------------
169 void
171 {
172 }
173 
174 // ------------ method called when starting to processes a luminosity block ------------
175 void
177 {
178 }
179 
180 // ------------ method called when ending the processing of a luminosity block ------------
181 void
183 {
184 }
185 
186 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
187 void
189  //The following says we do not know what parameters are allowed so do no validation
190  // Please change this to state exactly what you do use, even if it is no parameters
192  desc.setUnknown();
193  descriptions.addDefault(desc);
194 }
195 
196 //define this as a plug-in
void Initialize(const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
EGEnergyAnalyzer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
EGEnergyCorrector corfile
EGEnergyCorrector cordb
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
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 endRun(edm::Run const &, edm::EventSetup const &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Bool_t IsInitialized() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void beginJob()
virtual void endJob()
Definition: Run.h:33