Skip to content

Commit

Permalink
Merge pull request #32583 from bsunanda/Run3-gex45
Browse files Browse the repository at this point in the history
Run3-gex45 Use of ESGetToken in EcalAlgo examples
  • Loading branch information
cmsbuild committed Jan 3, 2021
2 parents a8e5c6e + 46606fd commit f28e11e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
13 changes: 8 additions & 5 deletions Geometry/EcalAlgo/test/EcalBarrelCellParameterDump.cc
@@ -1,7 +1,6 @@
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
Expand All @@ -17,17 +16,21 @@ typedef EZArrayFL<GlobalPoint> CornersVec;

class EcalBarrelCellParameterDump : public edm::one::EDAnalyzer<> {
public:
explicit EcalBarrelCellParameterDump(const edm::ParameterSet&) {}
explicit EcalBarrelCellParameterDump(const edm::ParameterSet&);

void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}

private:
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
};

EcalBarrelCellParameterDump::EcalBarrelCellParameterDump(const edm::ParameterSet&)
: tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()) {}

void EcalBarrelCellParameterDump::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
edm::ESHandle<CaloGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
const CaloGeometry* geo = pG.product();
const CaloGeometry* geo = &iSetup.getData(tok_geom_);
const CaloSubdetectorGeometry* ecalGeom =
static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalBarrel));

Expand Down
13 changes: 8 additions & 5 deletions Geometry/EcalAlgo/test/EcalEndcapCellParameterDump.cc
@@ -1,7 +1,6 @@
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
Expand All @@ -17,17 +16,21 @@ typedef EZArrayFL<GlobalPoint> CornersVec;

class EcalEndcapCellParameterDump : public edm::one::EDAnalyzer<> {
public:
explicit EcalEndcapCellParameterDump(const edm::ParameterSet&) {}
explicit EcalEndcapCellParameterDump(const edm::ParameterSet&);

void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}

private:
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
};

EcalEndcapCellParameterDump::EcalEndcapCellParameterDump(const edm::ParameterSet&)
: tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()) {}

void EcalEndcapCellParameterDump::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
edm::ESHandle<CaloGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
const CaloGeometry* geo = pG.product();
const CaloGeometry* geo = &iSetup.getData(tok_geom_);
const CaloSubdetectorGeometry* ecalGeom =
static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalEndcap));

Expand Down
9 changes: 4 additions & 5 deletions Geometry/EcalAlgo/test/EcalPreshowerParameterDump.cc
Expand Up @@ -2,7 +2,6 @@
#include "DataFormats/EcalDetId/interface/ESDetId.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
Expand Down Expand Up @@ -34,11 +33,13 @@ class EcalPreshowerCellParameterDump : public edm::one::EDAnalyzer<edm::one::Sha

private:
const bool debug_;
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
std::vector<TH2D*> hist_;
};

EcalPreshowerCellParameterDump::EcalPreshowerCellParameterDump(const edm::ParameterSet& ps)
: debug_(ps.getUntrackedParameter<bool>("debug", false)) {
: debug_(ps.getUntrackedParameter<bool>("debug", false)),
tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()) {
usesResource(TFileService::kSharedResource);

if (debug_) {
Expand All @@ -63,9 +64,7 @@ void EcalPreshowerCellParameterDump::fillDescriptions(edm::ConfigurationDescript
}

void EcalPreshowerCellParameterDump::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
edm::ESHandle<CaloGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
const CaloGeometry* geo = pG.product();
const CaloGeometry* geo = &iSetup.getData(tok_geom_);
const CaloSubdetectorGeometry* ecalGeom =
static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalPreshower));

Expand Down

0 comments on commit f28e11e

Please sign in to comment.