Skip to content

Commit

Permalink
Fixed CMS deprectation warnings in RecoMuon/TrackingTools
Browse files Browse the repository at this point in the history
- changed to thread-friendly module types
- added esConsumes calls
  • Loading branch information
Dr15Jones committed Jun 14, 2022
1 parent 03c0e6a commit 0414bb9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
23 changes: 8 additions & 15 deletions RecoMuon/TrackingTools/plugins/MuonErrorMatrixAdjuster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

MuonErrorMatrixAdjuster::MuonErrorMatrixAdjuster(const edm::ParameterSet& iConfig) {
MuonErrorMatrixAdjuster::MuonErrorMatrixAdjuster(const edm::ParameterSet& iConfig)
: theFieldToken{esConsumes()}, theHttopoToken{esConsumes()} {
theCategory = "MuonErrorMatrixAdjuster";
theInstanceName = iConfig.getParameter<std::string>("instanceName");
//register your products
Expand All @@ -25,9 +26,12 @@ MuonErrorMatrixAdjuster::MuonErrorMatrixAdjuster(const edm::ParameterSet& iConfi
produces<reco::TrackExtraCollection>();

theTrackLabel = iConfig.getParameter<edm::InputTag>("trackLabel");
consumes<reco::TrackCollection>(theTrackLabel);
theRescale = iConfig.getParameter<bool>("rescale");

theMatrixProvider_pset = iConfig.getParameter<edm::ParameterSet>("errorMatrix_pset");
auto matrixProvider_pset = iConfig.getParameter<edm::ParameterSet>("errorMatrix_pset");

theMatrixProvider = std::make_unique<MuonErrorMatrix>(matrixProvider_pset);
}

MuonErrorMatrixAdjuster::~MuonErrorMatrixAdjuster() {
Expand Down Expand Up @@ -179,11 +183,9 @@ void MuonErrorMatrixAdjuster::produce(edm::Event& iEvent, const edm::EventSetup&
<< theTrackLabel << ")";

//get the mag field
iSetup.get<IdealMagneticFieldRecord>().get(theField);
theField = iSetup.getHandle(theFieldToken);

edm::ESHandle<TrackerTopology> httopo;
iSetup.get<TrackerTopologyRcd>().get(httopo);
const TrackerTopology& ttopo = *httopo;
const TrackerTopology& ttopo = iSetup.getData(theHttopoToken);

//prepare the output collection
auto Toutput = std::make_unique<reco::TrackCollection>();
Expand Down Expand Up @@ -240,12 +242,3 @@ void MuonErrorMatrixAdjuster::produce(edm::Event& iEvent, const edm::EventSetup&
iEvent.put(std::move(TEoutput));
iEvent.put(std::move(TRHoutput));
}

// ------------ method called once each job just before starting event loop ------------
void MuonErrorMatrixAdjuster::beginJob() { theMatrixProvider = new MuonErrorMatrix(theMatrixProvider_pset); }

// ------------ method called once each job just after ending the event loop ------------
void MuonErrorMatrixAdjuster::endJob() {
if (theMatrixProvider)
delete theMatrixProvider;
}
23 changes: 12 additions & 11 deletions RecoMuon/TrackingTools/plugins/MuonErrorMatrixAdjuster.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,34 @@

#include <memory>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include <FWCore/Framework/interface/EventSetup.h>
#include "FWCore/Framework/interface/EventSetup.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <DataFormats/TrackReco/interface/Track.h>
#include <DataFormats/TrackReco/interface/TrackExtra.h>
#include <DataFormats/TrackingRecHit/interface/TrackingRecHit.h>
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackExtra.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"

#include "FWCore/Utilities/interface/InputTag.h"

class FreeTrajectoryState;
class MuonErroMatrix;
class MagneticField;
class IdealMagneticFieldRecord;
class MuonErrorMatrix;
class TrackerTopologyRcd;
#include "DataFormats/GeometryVector/interface/GlobalVector.h"

#include <FWCore/Framework/interface/ESHandle.h>
#include "FWCore/Framework/interface/ESHandle.h"

//
// class decleration
//

class MuonErrorMatrixAdjuster : public edm::EDProducer {
class MuonErrorMatrixAdjuster : public edm::stream::EDProducer<> {
public:
/// constructor
explicit MuonErrorMatrixAdjuster(const edm::ParameterSet&);
Expand All @@ -50,9 +52,7 @@ class MuonErrorMatrixAdjuster : public edm::EDProducer {

private:
/// framework method
void beginJob() override;
void produce(edm::Event&, const edm::EventSetup&) override;
void endJob() override;

/// return a corrected error matrix
reco::TrackBase::CovarianceMatrix fix_cov_matrix(const reco::TrackBase::CovarianceMatrix& error_matrix,
Expand Down Expand Up @@ -95,11 +95,12 @@ class MuonErrorMatrixAdjuster : public edm::EDProducer {
bool theRescale;

/// holds the error matrix parametrization
edm::ParameterSet theMatrixProvider_pset;
MuonErrorMatrix* theMatrixProvider;
std::unique_ptr<MuonErrorMatrix> theMatrixProvider;

/// hold on to the magnetic field
edm::ESHandle<MagneticField> theField;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theHttopoToken;

/// get reference before put track extra to the event, in order to create edm::Ref
edm::RefProd<reco::TrackExtraCollection> theRefprodTE;
Expand Down
7 changes: 4 additions & 3 deletions RecoMuon/TrackingTools/test/MuonErrorMatrixAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ MuonErrorMatrixAnalyzer::MuonErrorMatrixAnalyzer(const edm::ParameterSet& iConfi
Surface::RotationType R;
refRSurface = Cylinder::build(theRadius, O, R);
thePropagatorName = iConfig.getParameter<std::string>("propagatorName");
thePropagatorToken = esConsumes(edm::ESInputTag("", thePropagatorName));
theZ = iConfig.getParameter<double>("z");
if (theZ != 0) {
//plane can only be specified if R is specified
Expand Down Expand Up @@ -139,11 +140,11 @@ void MuonErrorMatrixAnalyzer::analyze_from_errormatrix(const edm::Event& iEvent,

if (theRadius != 0) {
//get a propagator
iSetup.get<TrackingComponentsRecord>().get(thePropagatorName, thePropagator);
thePropagator = iSetup.getHandle(thePropagatorToken);
}

//get the mag field
iSetup.get<IdealMagneticFieldRecord>().get(theField);
theField = iSetup.getHandle(theFieldToken);

//open a collection of track
edm::Handle<reco::TrackCollection> tracks;
Expand Down Expand Up @@ -192,7 +193,7 @@ void MuonErrorMatrixAnalyzer::analyze_from_pull(const edm::Event& iEvent, const
using namespace edm;

//get the mag field
iSetup.get<IdealMagneticFieldRecord>().get(theField);
theField = iSetup.getHandle(theFieldToken);

//open a collection of track
edm::Handle<View<reco::Track> > tracks;
Expand Down
8 changes: 6 additions & 2 deletions RecoMuon/TrackingTools/test/MuonErrorMatrixAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <memory>
#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 @@ -30,14 +30,16 @@
#include "CommonTools/UtilAlgos/interface/TFileService.h"

class MagneticField;
class IdealMagneticFieldRecord;
class TrackingComponentsRecord;
class TH1;
class TH2;
class Propagator;
//
// class decleration
//

class MuonErrorMatrixAnalyzer : public edm::EDAnalyzer {
class MuonErrorMatrixAnalyzer : public edm::one::EDAnalyzer<> {
public:
/// constructor
explicit MuonErrorMatrixAnalyzer(const edm::ParameterSet&);
Expand Down Expand Up @@ -69,6 +71,7 @@ class MuonErrorMatrixAnalyzer : public edm::EDAnalyzer {

/// hold on the magnetic field
edm::ESHandle<MagneticField> theField;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;

/// class holder for the reported error parametrization
MuonErrorMatrix* theErrorMatrixStore_Reported;
Expand Down Expand Up @@ -100,6 +103,7 @@ class MuonErrorMatrixAnalyzer : public edm::EDAnalyzer {
/// propagator used to go to the cylinder surface, ALONG momentum
std::string thePropagatorName;
edm::ESHandle<Propagator> thePropagator;
edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;

/// put the free trajectory state to the TSCPBuilderNoMaterial or the cylinder surface
FreeTrajectoryState refLocusState(const FreeTrajectoryState& fts);
Expand Down

0 comments on commit 0414bb9

Please sign in to comment.