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 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
30 #include "TFile.h"
32 //#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
33 //#include "CondCore/DBCommon/interface/CoralServiceManager.h"
34 
41 
42 //
43 // class declaration
44 //
45 
47 public:
48  explicit EGEnergyAnalyzer(const edm::ParameterSet&);
49  ~EGEnergyAnalyzer() override;
50 
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54  void beginJob() override;
55  void analyze(const edm::Event&, const edm::EventSetup&) override;
56  void endJob() override;
57 
60 
62 };
63 
65  ebRHToken_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
66  eeRHToken_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
67 }
68 
70  // do anything here that needs to be done at desctruction time
71  // (e.g. close files, deallocate resources etc.)
72 }
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called for each event ------------
80  using namespace edm;
81 
82  if (!corfile.IsInitialized()) {
83  corfile.Initialize(iSetup, "/afs/cern.ch/user/b/bendavid/cmspublic/gbrv3ph.root");
84  //corfile.Initialize(iSetup,"wgbrph",true);
85  }
86 
87  if (!cordb.IsInitialized()) {
88  //cordb.Initialize(iSetup,"/afs/cern.ch/user/b/bendavid/cmspublic/regweights/gbrph.root");
89  cordb.Initialize(iSetup, "wgbrph", true);
90  }
91 
92  // get photon collection
93  Handle<reco::PhotonCollection> hPhotonProduct;
94  iEvent.getByLabel("photons", hPhotonProduct);
95 
96  EcalClusterLazyTools lazyTools(iEvent, iSetup, ebRHToken_, eeRHToken_);
97 
98  Handle<reco::VertexCollection> hVertexProduct;
99  iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct);
100 
101  for (reco::PhotonCollection::const_iterator it = hPhotonProduct->begin(); it != hPhotonProduct->end(); ++it) {
102  std::pair<double, double> corsfile = corfile.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
103  std::pair<double, double> corsdb = cordb.CorrectedEnergyWithError(*it, *hVertexProduct, lazyTools, iSetup);
104 
105  printf("file: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(), corsfile.first, corsfile.second);
106  printf("db: default = %5f, correction = %5f, uncertainty = %5f\n", it->energy(), corsdb.first, corsdb.second);
107  }
108 }
109 
110 // ------------ method called once each job just before starting event loop ------------
112 
113 // ------------ method called once each job just after ending the event loop ------------
115 
116 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
118  //The following says we do not know what parameters are allowed so do no validation
119  // Please change this to state exactly what you do use, even if it is no parameters
121  desc.setUnknown();
122  descriptions.addDefault(desc);
123 }
124 
125 //define this as a plug-in
EGEnergyCorrector::Initialize
void Initialize(const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
Definition: EGEnergyCorrector.cc:47
EGEnergyAnalyzer::corfile
EGEnergyCorrector corfile
Definition: EGEnergyAnalyzer.cc:58
EDAnalyzer.h
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EGEnergyAnalyzer::~EGEnergyAnalyzer
~EGEnergyAnalyzer() override
Definition: EGEnergyAnalyzer.cc:69
EcalClusterLazyTools.h
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle< reco::PhotonCollection >
EGEnergyAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EGEnergyAnalyzer.cc:117
MakerMacros.h
Photon.h
EGEnergyAnalyzer::eeRHToken_
edm::EDGetTokenT< EcalRecHitCollection > eeRHToken_
Definition: EGEnergyAnalyzer.cc:61
PoolDBOutputService.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
EGEnergyAnalyzer::ebRHToken_
edm::EDGetTokenT< EcalRecHitCollection > ebRHToken_
Definition: EGEnergyAnalyzer.cc:61
EGEnergyAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EGEnergyAnalyzer.cc:79
EGEnergyAnalyzer
Definition: EGEnergyAnalyzer.cc:46
EGEnergyAnalyzer::EGEnergyAnalyzer
EGEnergyAnalyzer(const edm::ParameterSet &)
Definition: EGEnergyAnalyzer.cc:64
EcalClusterLazyTools
EGEnergyCorrector::IsInitialized
Bool_t IsInitialized() const
Definition: EGEnergyCorrector.h:27
EGEnergyAnalyzer::cordb
EGEnergyCorrector cordb
Definition: EGEnergyAnalyzer.cc:59
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
EGEnergyCorrector::CorrectedEnergyWithError
std::pair< double, double > CorrectedEnergyWithError(const reco::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, const edm::EventSetup &es)
Definition: EGEnergyCorrector.cc:95
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::EventSetup
Definition: EventSetup.h:57
EGEnergyAnalyzer::beginJob
void beginJob() override
Definition: EGEnergyAnalyzer.cc:111
Frameworkfwd.h
EGEnergyCorrector
Definition: EGEnergyCorrector.h:21
EventSetup.h
ParameterSet.h
EGEnergyAnalyzer::endJob
void endJob() override
Definition: EGEnergyAnalyzer.cc:114
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
EGEnergyCorrector.h