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 
39 
40 //
41 // class declaration
42 //
43 
45 public:
46  explicit EGEnergyAnalyzer(const edm::ParameterSet&);
47  ~EGEnergyAnalyzer() override;
48 
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 private:
52  void beginJob() override;
53  void analyze(const edm::Event&, const edm::EventSetup&) override;
54  void endJob() override;
55 
58 
61 };
62 
64  : ecalClusterToolsESGetTokens_{consumesCollector()} {
65  ebRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEB"));
66  eeRHToken_ = consumes(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 
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:56
EGEnergyAnalyzer::ecalClusterToolsESGetTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
Definition: EGEnergyAnalyzer.cc:60
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
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:46
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:59
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:59
EGEnergyAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EGEnergyAnalyzer.cc:79
EGEnergyAnalyzer
Definition: EGEnergyAnalyzer.cc:44
EGEnergyAnalyzer::EGEnergyAnalyzer
EGEnergyAnalyzer(const edm::ParameterSet &)
Definition: EGEnergyAnalyzer.cc:63
EcalClusterLazyToolsBase::ESGetTokens
Definition: EcalClusterLazyTools.h:53
EcalClusterLazyTools
EGEnergyCorrector::IsInitialized
Bool_t IsInitialized() const
Definition: EGEnergyCorrector.h:27
EGEnergyAnalyzer::cordb
EGEnergyCorrector cordb
Definition: EGEnergyAnalyzer.cc:57
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:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
EGEnergyAnalyzer::beginJob
void beginJob() override
Definition: EGEnergyAnalyzer.cc:111
EcalClusterLazyToolsBase::ESGetTokens::get
ESData get(edm::EventSetup const &eventSetup) const
Definition: EcalClusterLazyTools.h:62
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
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