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&);
51  ~EGEnergyAnalyzer() override;
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 
56 private:
57  void beginJob() override ;
58  void analyze( const edm::Event&, const edm::EventSetup&) override;
59  void endJob() override ;
60 
63 
65 };
66 
67 
69 
70  ebRHToken_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
71  eeRHToken_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
72 }
73 
74 
76 {
77 
78  // do anything here that needs to be done at desctruction time
79  // (e.g. close files, deallocate resources etc.)
80 
81 }
82 
83 
84 //
85 // member functions
86 //
87 
88 // ------------ method called for each event ------------
89 void
91 {
92  using namespace edm;
93 
94  if (!corfile.IsInitialized()) {
95  corfile.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/gbrv3ph.root");
96  //corfile.Initialize(iSetup,"wgbrph",true);
97  }
98 
99  if (!cordb.IsInitialized()) {
100  //cordb.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/regweights/gbrph.root");
101  cordb.Initialize(iSetup,"wgbrph",true);
102  }
103 
104  // get photon collection
105  Handle<reco::PhotonCollection> hPhotonProduct;
106  iEvent.getByLabel("photons",hPhotonProduct);
107 
108  EcalClusterLazyTools lazyTools(iEvent, iSetup, ebRHToken_, eeRHToken_);
109 
110  Handle<reco::VertexCollection> hVertexProduct;
111  iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct);
112 
113  for (reco::PhotonCollection::const_iterator it = hPhotonProduct->begin(); it!=hPhotonProduct->end(); ++it) {
114  std::pair<double,double> corsfile = corfile.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
115  std::pair<double,double> corsdb = cordb.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
116 
117 
118  printf("file: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsfile.first,corsfile.second);
119  printf("db: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(),corsdb.first,corsdb.second);
120 
121  }
122 
123 
124 
125 
126 }
127 
128 
129 // ------------ method called once each job just before starting event loop ------------
130 void
132 {
133 
134 
135 
136 }
137 
138 // ------------ method called once each job just after ending the event loop ------------
139 void
141 {
142 }
143 
144 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
145 void
147  //The following says we do not know what parameters are allowed so do no validation
148  // Please change this to state exactly what you do use, even if it is no parameters
150  desc.setUnknown();
151  descriptions.addDefault(desc);
152 }
153 
154 //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
void endJob() override
EGEnergyCorrector corfile
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)
~EGEnergyAnalyzer() override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
Bool_t IsInitialized() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
edm::EDGetTokenT< EcalRecHitCollection > eeRHToken_
void beginJob() override