Skip to content

Commit

Permalink
Merge pull request #39760 from Dr15Jones/deprecatedRecoMuon
Browse files Browse the repository at this point in the history
Fix deprecation warnings in  RecoMuon sub-system
  • Loading branch information
cmsbuild authored Oct 19, 2022
2 parents 9c6a28c + 4a9030c commit 4225c3c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 40 deletions.
17 changes: 9 additions & 8 deletions RecoMuon/DetLayers/test/MuonRecoGeometryAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

#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/EventSetup.h>
#include <FWCore/Framework/interface/ESHandle.h>
Expand Down Expand Up @@ -33,11 +33,11 @@
using namespace std;
using namespace edm;

class MuonRecoGeometryAnalyzer : public EDAnalyzer {
class MuonRecoGeometryAnalyzer : public one::EDAnalyzer<> {
public:
MuonRecoGeometryAnalyzer(const ParameterSet& pset);

virtual void analyze(const Event& ev, const EventSetup& es);
void analyze(const Event& ev, const EventSetup& es) override;

void testDTLayers(const MuonDetLayerGeometry*, const MagneticField* field);
void testCSCLayers(const MuonDetLayerGeometry*, const MagneticField* field);
Expand All @@ -46,20 +46,21 @@ class MuonRecoGeometryAnalyzer : public EDAnalyzer {

private:
MeasurementEstimator* theEstimator;
ESGetToken<MuonDetLayerGeometry, MuonRecoGeometryRecord> theGeomToken;
ESGetToken<MagneticField, IdealMagneticFieldRecord> theMagfieldToken;
};

MuonRecoGeometryAnalyzer::MuonRecoGeometryAnalyzer(const ParameterSet& iConfig) {
float theMaxChi2 = 25.;
float theNSigma = 3.;
theEstimator = new Chi2MeasurementEstimator(theMaxChi2, theNSigma);
theGeomToken = esConsumes();
theMagfieldToken = esConsumes();
}

void MuonRecoGeometryAnalyzer::analyze(const Event& ev, const EventSetup& es) {
ESHandle<MuonDetLayerGeometry> geo;
es.get<MuonRecoGeometryRecord>().get(geo);

ESHandle<MagneticField> magfield;
es.get<IdealMagneticFieldRecord>().get(magfield);
ESHandle<MuonDetLayerGeometry> geo = es.getHandle(theGeomToken);
ESHandle<MagneticField> magfield = es.getHandle(theMagfieldToken);
// Some printouts

cout << "*** allDTLayers(): " << geo->allDTLayers().size() << endl;
Expand Down
12 changes: 6 additions & 6 deletions RecoMuon/L2MuonIsolationProducer/test/L2MuonIsolationAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* \author J. Alcaraz
*/

#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "RecoMuon/MuonIsolation/interface/Cuts.h"

Expand All @@ -21,19 +21,19 @@ class TFile;
class TH1F;
class TH2F;

class L2MuonIsolationAnalyzer : public edm::EDAnalyzer {
class L2MuonIsolationAnalyzer : public edm::one::EDAnalyzer<> {
public:
/// Constructor
L2MuonIsolationAnalyzer(const edm::ParameterSet& pset);

/// Destructor
virtual ~L2MuonIsolationAnalyzer();
~L2MuonIsolationAnalyzer() override;

// Operations
void analyze(const edm::Event& event, const edm::EventSetup& eventSetup);
void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) override;

virtual void beginJob();
virtual void endJob();
void beginJob() override;
void endJob() override;

private:
void Puts(const char* fmt, ...);
Expand Down
12 changes: 6 additions & 6 deletions RecoMuon/L3MuonIsolationProducer/test/L3MuonIsolationAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "RecoMuon/MuonIsolation/interface/Cuts.h"

Expand All @@ -20,19 +20,19 @@ class TFile;
class TH1F;
class TH2F;

class L3MuonIsolationAnalyzer : public edm::EDAnalyzer {
class L3MuonIsolationAnalyzer : public edm::one::EDAnalyzer<> {
public:
/// Constructor
L3MuonIsolationAnalyzer(const edm::ParameterSet& pset);

/// Destructor
virtual ~L3MuonIsolationAnalyzer();
~L3MuonIsolationAnalyzer() override;

// Operations
void analyze(const edm::Event& event, const edm::EventSetup& eventSetup);
void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) override;

virtual void beginJob();
virtual void endJob();
void beginJob() override;
void endJob() override;

private:
void Puts(const char* fmt, ...);
Expand Down
18 changes: 9 additions & 9 deletions RecoMuon/Navigation/test/MuonNavigationTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#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/EventSetup.h"
Expand All @@ -24,19 +24,21 @@
//#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

class MuonNavigationTest : public edm::EDAnalyzer {
class MuonNavigationTest : public edm::one::EDAnalyzer<> {
public:
explicit MuonNavigationTest(const edm::ParameterSet&);
~MuonNavigationTest();
~MuonNavigationTest() override;

virtual void analyze(const edm::Event&, const edm::EventSetup&);
void analyze(const edm::Event&, const edm::EventSetup&) override;

private:
edm::ESGetToken<MuonDetLayerGeometry, MuonRecoGeometryRecord> geomToken_;
};

// constructor

MuonNavigationTest::MuonNavigationTest(const edm::ParameterSet& iConfig) {
geomToken_ = esConsumes();
std::cout << "Muon Navigation Printer Begin:" << std::endl;
}

Expand All @@ -51,13 +53,11 @@ void MuonNavigationTest::analyze(const edm::Event& iEvent, const edm::EventSetup
//
// get Geometry
//
edm::ESHandle<MuonDetLayerGeometry> muon;
iSetup.get<MuonRecoGeometryRecord>().get(muon);
const MuonDetLayerGeometry* mm(&(*muon));
const MuonDetLayerGeometry& mm = iSetup.getData(geomToken_);

if (testMuon) {
MuonNavigationSchool school(mm);
MuonNavigationPrinter* printer = new MuonNavigationPrinter(mm, school);
MuonNavigationSchool school(&mm);
MuonNavigationPrinter* printer = new MuonNavigationPrinter(&mm, school);
delete printer;
}
/*
Expand Down
10 changes: 5 additions & 5 deletions RecoMuon/StandAloneMuonProducer/test/STAMuonAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ STAMuonAnalyzer::STAMuonAnalyzer(const ParameterSet& pset) {

numberOfSimTracks = 0;
numberOfRecTracks = 0;

theFieldToken = esConsumes();
theGeomToken = esConsumes();
}

/// Destructor
Expand Down Expand Up @@ -97,11 +100,8 @@ void STAMuonAnalyzer::analyze(const Event& event, const EventSetup& eventSetup)
Handle<reco::TrackCollection> staTracks;
event.getByLabel(theSTAMuonLabel, staTracks);

ESHandle<MagneticField> theMGField;
eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);

ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
eventSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
ESHandle<MagneticField> theMGField = eventSetup.getHandle(theFieldToken);
ESHandle<GlobalTrackingGeometry> theTrackingGeometry = eventSetup.getHandle(theGeomToken);

double recPt = 0.;
double simPt = 0.;
Expand Down
18 changes: 12 additions & 6 deletions RecoMuon/StandAloneMuonProducer/test/STAMuonAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// Base Class Headers
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

namespace edm {
class ParameterSet;
Expand All @@ -19,21 +19,25 @@ namespace edm {
class TFile;
class TH1F;
class TH2F;
class MagneticField;
class IdealMagneticFieldRecord;
class GlobalTrackingGeometry;
class GlobalTrackingGeometryRecord;

class STAMuonAnalyzer : public edm::EDAnalyzer {
class STAMuonAnalyzer : public edm::one::EDAnalyzer<> {
public:
/// Constructor
STAMuonAnalyzer(const edm::ParameterSet &pset);

/// Destructor
virtual ~STAMuonAnalyzer();
~STAMuonAnalyzer() override;

// Operations

void analyze(const edm::Event &event, const edm::EventSetup &eventSetup);
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;

virtual void beginJob();
virtual void endJob();
void beginJob() override;
void endJob() override;

protected:
private:
Expand All @@ -58,5 +62,7 @@ class STAMuonAnalyzer : public edm::EDAnalyzer {
int numberOfRecTracks;

std::string theDataType;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> theGeomToken;
};
#endif

0 comments on commit 4225c3c

Please sign in to comment.