Skip to content

Commit

Permalink
Merge pull request #39700 from wddgit/legacyMigrationJetMETCorrection…
Browse files Browse the repository at this point in the history
…sMinBias

JetMETCorrections/MinBias legacy migration
  • Loading branch information
cmsbuild committed Oct 12, 2022
2 parents 13301bd + 65fdd33 commit 018b8bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
18 changes: 6 additions & 12 deletions JetMETCorrections/MinBias/interface/MinBias.h
Expand Up @@ -6,36 +6,29 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "DataFormats/DetId/interface/DetId.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"

#include "TTree.h"

namespace edm {
class ParameterSet;
class Event;
class EventSetup;
} // namespace edm

//
// class decleration
//
namespace cms {
class MinBias : public edm::EDAnalyzer {
class MinBias : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
explicit MinBias(const edm::ParameterSet&);

void analyze(const edm::Event&, const edm::EventSetup&) override;
void beginJob() override;
void beginRun(edm::Run const&, edm::EventSetup const&) override;
void endRun(edm::Run const&, edm::EventSetup const&) override;
void endJob() override;

private:
Expand All @@ -46,6 +39,7 @@ namespace cms {
edm::EDGetTokenT<HBHERecHitCollection> hbheToken_;
edm::EDGetTokenT<HORecHitCollection> hoToken_;
edm::EDGetTokenT<HFRecHitCollection> hfToken_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryESToken_;
// stuff for histogramms
bool allowMissingInputs_;
//
Expand Down
14 changes: 7 additions & 7 deletions JetMETCorrections/MinBias/src/MinBias.cc
Expand Up @@ -3,11 +3,11 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "JetMETCorrections/MinBias/interface/MinBias.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"

namespace cms {
MinBias::MinBias(const edm::ParameterSet& iConfig) : geo_(nullptr) {
MinBias::MinBias(const edm::ParameterSet& iConfig)
: caloGeometryESToken_(esConsumes<edm::Transition::BeginRun>()), geo_(nullptr) {
// get names of modules, producing object collections
hbheLabel_ = iConfig.getParameter<std::string>("hbheInput");
hoLabel_ = iConfig.getParameter<std::string>("hoInput");
Expand All @@ -34,10 +34,8 @@ namespace cms {
myTree_->Branch("mom4", &mom4, "mom4/F");
}

void MinBias::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
edm::ESHandle<CaloGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
geo_ = pG.product();
void MinBias::beginRun(edm::Run const&, edm::EventSetup const& iSetup) {
geo_ = &iSetup.getData(caloGeometryESToken_);
std::vector<DetId> did = geo_->getValidDetIds();

for (auto const& id : did) {
Expand All @@ -51,6 +49,8 @@ namespace cms {
}
}

void MinBias::endRun(edm::Run const&, edm::EventSetup const& iSetup) {}

void MinBias::endJob() {
const HcalGeometry* hgeo = static_cast<const HcalGeometry*>(geo_->getSubdetectorGeometry(DetId::Hcal, 1));
const std::vector<DetId>& did = hgeo->getValidDetIds();
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace cms {
//

// ------------ method called to produce the data ------------
void MinBias::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
void MinBias::analyze(const edm::Event& iEvent, const edm::EventSetup&) {
if (!hbheLabel_.empty()) {
edm::Handle<HBHERecHitCollection> hbhe;
iEvent.getByToken(hbheToken_, hbhe);
Expand Down

0 comments on commit 018b8bc

Please sign in to comment.