Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-gex98D Use ESGetToken in some of the test analyzers in SimMuon #36115

Merged
merged 2 commits into from Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions SimMuon/CSCDigitizer/test/CSCNoiseMatrixTest.cc
@@ -1,6 +1,5 @@
#include "CalibMuon/CSCCalibration/interface/CSCConditions.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
Expand All @@ -12,9 +11,10 @@
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

class CSCNoiseMatrixTest : public edm::EDAnalyzer {
class CSCNoiseMatrixTest : public edm::one::EDAnalyzer<> {
public:
CSCNoiseMatrixTest(const edm::ParameterSet &pset) : theDbConditions(pset, consumesCollector()) {
CSCNoiseMatrixTest(const edm::ParameterSet &pset)
: theDbConditions(pset, consumesCollector()), tokGeo_{esConsumes(edm::ESInputTag("", "idealForDigi"))} {
edm::Service<edm::RandomNumberGenerator> rng;
if (!rng.isAvailable()) {
throw cms::Exception("Configuration") << "CSCNoiseMatrixTest requires the RandomNumberGeneratorService\n"
Expand All @@ -38,9 +38,7 @@ class CSCNoiseMatrixTest : public edm::EDAnalyzer {
std::vector<float> binValues(nScaBins, 0.);

// find the geometry & conditions for this event
edm::ESHandle<CSCGeometry> hGeom;
eventSetup.get<MuonGeometryRecord>().get("idealForDigi", hGeom);
const CSCGeometry *pGeom = &*hGeom;
const CSCGeometry *pGeom = &eventSetup.getData(tokGeo_);

// try making a noisifier and using it
const CSCGeometry::LayerContainer &layers = pGeom->layers();
Expand All @@ -63,6 +61,7 @@ class CSCNoiseMatrixTest : public edm::EDAnalyzer {

private:
CSCDbStripConditions theDbConditions;
const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> tokGeo_;
};

DEFINE_FWK_MODULE(CSCNoiseMatrixTest);
6 changes: 2 additions & 4 deletions SimMuon/DTDigitizer/test/DTDigiAnalyzer.cc
Expand Up @@ -19,9 +19,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/GeometryVector/interface/LocalPoint.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/DTGeometry/interface/DTLayer.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include "DataFormats/MuonDetId/interface/DTLayerId.h"
#include "DataFormats/MuonDetId/interface/DTWireId.h"
Expand All @@ -42,6 +40,7 @@ DTDigiAnalyzer::DTDigiAnalyzer(const ParameterSet &pset)
// MuonDigiStatistics = new DTMuonDigiStatistics();
// HitsAnalysis = new DTHitsAnalysis();
label = pset.getUntrackedParameter<string>("label");
tokGeo_ = esConsumes<DTGeometry, MuonGeometryRecord>();
file = new TFile("DTDigiPlots.root", "RECREATE");
file->cd();
DigiTimeBox = new TH1F("DigiTimeBox", "Digi Time Box", 2048, 0, 1600);
Expand Down Expand Up @@ -80,8 +79,7 @@ void DTDigiAnalyzer::analyze(const Event &event, const EventSetup &eventSetup) {
Handle<PSimHitContainer> simHits;
event.getByToken(psim_token, simHits);

ESHandle<DTGeometry> muonGeom;
eventSetup.get<MuonGeometryRecord>().get(muonGeom);
auto muonGeom = eventSetup.getHandle(tokGeo_);

DTWireIdMap wireMap;

Expand Down
8 changes: 6 additions & 2 deletions SimMuon/DTDigitizer/test/DTDigiAnalyzer.h
Expand Up @@ -14,7 +14,9 @@
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
#include "SimMuon/DTDigitizer/interface/Histograms.h"
#include <DataFormats/MuonDetId/interface/DTWireId.h>
#include <FWCore/Framework/interface/EDAnalyzer.h>
#include <FWCore/Framework/interface/one/EDAnalyzer.h>
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

class TH1F;
class TFile;
Expand All @@ -30,7 +32,7 @@ namespace edm {
class EventSetup;
} // namespace edm

class DTDigiAnalyzer : public edm::EDAnalyzer {
class DTDigiAnalyzer : public edm::one::EDAnalyzer<> {
public:
explicit DTDigiAnalyzer(const edm::ParameterSet &pset);
~DTDigiAnalyzer() override;
Expand All @@ -44,6 +46,8 @@ class DTDigiAnalyzer : public edm::EDAnalyzer {
TH1F *DigiTimeBox;
TFile *file;
std::string label;
edm::ESGetToken<DTGeometry, MuonGeometryRecord> tokGeo_;

// DTMCStatistics *MCStatistics;
// DTMuonDigiStatistics *MuonDigiStatistics;
// DTHitsAnalysis *HitsAnalysis;
Expand Down