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 
96  auto const& ecalClusterToolsESData = ecalClusterToolsESGetTokens_.get(iSetup);
97  auto const& caloGeometry = ecalClusterToolsESData.caloGeometry;
98  EcalClusterLazyTools lazyTools(iEvent, ecalClusterToolsESData, ebRHToken_, eeRHToken_);
99 
100  Handle<reco::VertexCollection> hVertexProduct;
101  iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct);
102 
103  for (auto const& it : *hPhotonProduct) {
104  std::pair<double, double> corsfile = corfile.CorrectedEnergyWithError(it, *hVertexProduct, lazyTools, caloGeometry);
105  std::pair<double, double> corsdb = cordb.CorrectedEnergyWithError(it, *hVertexProduct, lazyTools, caloGeometry);
106 
107  printf("file: default = %5f, correction = %5f, uncertainty = %5f\n", it.energy(), corsfile.first, corsfile.second);
108  printf("db: default = %5f, correction = %5f, uncertainty = %5f\n", it.energy(), corsdb.first, corsdb.second);
109  }
110 }
111 
112 // ------------ method called once each job just before starting event loop ------------
114 
115 // ------------ method called once each job just after ending the event loop ------------
117 
118 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
120  //The following says we do not know what parameters are allowed so do no validation
121  // Please change this to state exactly what you do use, even if it is no parameters
123  desc.setUnknown();
124  descriptions.addDefault(desc);
125 }
126 
127 //define this as a plug-in
EGEnergyCorrector::Initialize
void Initialize(const edm::EventSetup &iSetup, std::string regweights, bool weightsFromDB=false)
Definition: EGEnergyCorrector.cc:31
EGEnergyAnalyzer::corfile
EGEnergyCorrector corfile
Definition: EGEnergyAnalyzer.cc:56
EGEnergyAnalyzer::ecalClusterToolsESGetTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
Definition: EGEnergyAnalyzer.cc:60
EDAnalyzer.h
EcalClusterLazyToolsBase::ESData::caloGeometry
const CaloGeometry & caloGeometry
Definition: EcalClusterLazyTools.h:48
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:47
EcalClusterLazyTools.h
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle< reco::PhotonCollection >
EGEnergyAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EGEnergyAnalyzer.cc:119
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:55
EcalClusterLazyTools
EGEnergyAnalyzer::cordb
EGEnergyCorrector cordb
Definition: EGEnergyAnalyzer.cc:57
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
EGEnergyAnalyzer::beginJob
void beginJob() override
Definition: EGEnergyAnalyzer.cc:113
EcalClusterLazyToolsBase::ESGetTokens::get
ESData get(edm::EventSetup const &eventSetup) const
Definition: EcalClusterLazyTools.h:64
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Frameworkfwd.h
EGEnergyCorrector
Definition: EGEnergyCorrector.h:22
EventSetup.h
EGEnergyCorrector::IsInitialized
bool IsInitialized() const
Definition: EGEnergyCorrector.h:27
EGEnergyCorrector::CorrectedEnergyWithError
std::pair< double, double > CorrectedEnergyWithError(const reco::Photon &p, const reco::VertexCollection &vtxcol, EcalClusterLazyTools &clustertools, CaloGeometry const &caloGeometry)
Definition: EGEnergyCorrector.cc:77
ParameterSet.h
EGEnergyAnalyzer::endJob
void endJob() override
Definition: EGEnergyAnalyzer.cc:116
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