Skip to content

Commit

Permalink
Fix deprecation warnings in STAMuonAnalyzer
Browse files Browse the repository at this point in the history
- changed to one::EDAnalyzer
- added missing esConsumes
  • Loading branch information
Dr15Jones committed Oct 18, 2022
1 parent 027ecfc commit 4a9030c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
10 changes: 5 additions & 5 deletions RecoMuon/StandAloneMuonProducer/test/STAMuonAnalyzer.cc
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
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 4a9030c

Please sign in to comment.