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

Remove deprecation warnings from TrackingTools #36391

Merged
merged 7 commits into from Dec 14, 2021
4 changes: 2 additions & 2 deletions RecoLocalMuon/RPCRecHit/plugins/TracktoRPC.cc
Expand Up @@ -59,9 +59,9 @@ TracktoRPC::TracktoRPC(const edm::ParameterSet &iConfig, const edm::InputTag &tr
cscMapToken_(iC.esConsumes()),
propagatorToken_(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))) {
if (tracklabel.label().find("cosmic") == 0)
theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(iConfig);
theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(iConfig, iC);
else if (tracklabel.label().find("globalCosmic") == 0)
theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(iConfig);
theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(iConfig, iC);
else
theTrackTransformer = std::make_unique<TrackTransformer>(iConfig, iC);
}
Expand Down
Expand Up @@ -31,52 +31,33 @@ class TSCBLBuilderWithPropagatorESProducer : public edm::ESProducer {

private:
// ----------member data ---------------------------
edm::ParameterSet pset_;
edm::ESGetToken<Propagator, TrackingComponentsRecord> propToken_;
const std::string myName_;
const std::string propName_;
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
TSCBLBuilderWithPropagatorESProducer::TSCBLBuilderWithPropagatorESProducer(const edm::ParameterSet& p) {
//the following line is needed to tell the framework what
// data is being produced
std::string myName = p.getParameter<std::string>("ComponentName");
pset_ = p;
setWhatProduced(this, myName);

TSCBLBuilderWithPropagatorESProducer::TSCBLBuilderWithPropagatorESProducer(const edm::ParameterSet& p)
: myName_(p.getParameter<std::string>("ComponentName")), propName_(p.getParameter<std::string>("Propagator")) {
auto cc = setWhatProduced(this, myName_);
//now do what ever other initialization is needed
propToken_ = cc.consumes(edm::ESInputTag{"", propName_});
}

TSCBLBuilderWithPropagatorESProducer::~TSCBLBuilderWithPropagatorESProducer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
TSCBLBuilderWithPropagatorESProducer::~TSCBLBuilderWithPropagatorESProducer() = default;

//
// member functions
//

// ------------ method called to produce the data ------------
TSCBLBuilderWithPropagatorESProducer::ReturnType TSCBLBuilderWithPropagatorESProducer::produce(
const TrackingComponentsRecord& iRecord) {
using namespace edm::es;
std::string propname = pset_.getParameter<std::string>("Propagator");

edm::ESHandle<Propagator> theProp;
iRecord.get(propname, theProp);

const Propagator* pro = theProp.product();

const Propagator* pro = &iRecord.get(propToken_);
auto pTSCBLBuilderWithPropagator = std::make_unique<TSCBLBuilderWithPropagator>(*pro);

return pTSCBLBuilderWithPropagator;
}

Expand Down
11 changes: 6 additions & 5 deletions TrackingTools/TrackAssociator/test/CaloMatchingExample.cc
Expand Up @@ -19,7 +19,7 @@

// 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/EventSetup.h"
Expand Down Expand Up @@ -79,7 +79,7 @@

#include "CLHEP/Random/Random.h"

class CaloMatchingExample : public edm::EDAnalyzer {
class CaloMatchingExample : public edm::one::EDAnalyzer<> {
public:
explicit CaloMatchingExample(const edm::ParameterSet&);
virtual ~CaloMatchingExample() {
Expand All @@ -91,6 +91,8 @@ class CaloMatchingExample : public edm::EDAnalyzer {
virtual void analyze(const edm::Event&, const edm::EventSetup&);

private:
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;

TrackDetectorAssociator trackAssociator_;
bool useEcal_;
bool useHcal_;
Expand Down Expand Up @@ -140,7 +142,7 @@ class CaloMatchingExample : public edm::EDAnalyzer {
TrackAssociatorParameters parameters_;
};

CaloMatchingExample::CaloMatchingExample(const edm::ParameterSet& iConfig) {
CaloMatchingExample::CaloMatchingExample(const edm::ParameterSet& iConfig) : caloGeomToken_(esConsumes()) {
CLHEP::HepRandom::createInstance();
file_ = new TFile(iConfig.getParameter<std::string>("outputfile").c_str(), "recreate");
tree_ = new TTree("calomatch", "calomatch");
Expand Down Expand Up @@ -197,8 +199,7 @@ void CaloMatchingExample::analyze(const edm::Event& iEvent, const edm::EventSetu
using namespace edm;

// calo geometry
edm::ESHandle<CaloGeometry> geometry;
iSetup.get<CaloGeometryRecord>().get(geometry);
const auto& geometry = iSetup.getHandle(caloGeomToken_);
if (!geometry.isValid())
throw cms::Exception("FatalError") << "Unable to find CaloGeometryRecord in event!\n";

Expand Down
4 changes: 2 additions & 2 deletions TrackingTools/TrackAssociator/test/TestTrackAssociator.cc
Expand Up @@ -21,7 +21,7 @@

// 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/EventSetup.h"
Expand Down Expand Up @@ -79,7 +79,7 @@
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"

class TestTrackAssociator : public edm::EDAnalyzer {
class TestTrackAssociator : public edm::one::EDAnalyzer<> {
public:
explicit TestTrackAssociator(const edm::ParameterSet&);
virtual ~TestTrackAssociator() {}
Expand Down
Expand Up @@ -19,21 +19,21 @@
* modified for zed ordering by N. Kypreos - UF <nicholas.theodore.kypreos@cern.ch>
*/

#include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h"

#include "TrackingTools/TrackRefitter/interface/RefitDirection.h"

#include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h"

#include "TrackingTools/TrackRefitter/interface/RefitDirection.h"

#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "TrackingTools/TrackRefitter/interface/RefitDirection.h"
#include "TrackingTools/TrackRefitter/interface/RefitDirection.h"
#include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h"
#include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"

#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"

namespace edm {
class ParameterSet;
Expand All @@ -52,7 +52,7 @@ class Trajectory;
class TrackTransformerForCosmicMuons : public TrackTransformerBase {
public:
/// Constructor
TrackTransformerForCosmicMuons(const edm::ParameterSet&);
TrackTransformerForCosmicMuons(const edm::ParameterSet&, edm::ConsumesCollector);

/// Destructor
~TrackTransformerForCosmicMuons() override;
Expand Down Expand Up @@ -85,6 +85,17 @@ class TrackTransformerForCosmicMuons : public TrackTransformerBase {

protected:
private:
const edm::ESGetToken<Propagator, TrackingComponentsRecord> theIOpropToken;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> theOIpropToken;
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> thGlobTrackGeoToken;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMFToken;
const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> theIOFitterToken;
const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> theOIFitterToken;
const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> theIOSmootherToken;
const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> theOISmootherToken;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTkRecHitBuildToken;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuildToken;

edm::ESHandle<Propagator> thePropagatorIO;
edm::ESHandle<Propagator> thePropagatorOI;

Expand Down
Expand Up @@ -13,17 +13,19 @@
* \author R. Bellan - CERN <riccardo.bellan@cern.ch>
*/

#include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h"

#include "TrackingTools/TrackRefitter/interface/RefitDirection.h"

#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "TrackingTools/TrackRefitter/interface/RefitDirection.h"
#include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"

#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"

namespace edm {
class ParameterSet;
Expand All @@ -43,7 +45,7 @@ class TrackerTopology;
class TrackTransformerForGlobalCosmicMuons : public TrackTransformerBase {
public:
/// Constructor
TrackTransformerForGlobalCosmicMuons(const edm::ParameterSet&);
TrackTransformerForGlobalCosmicMuons(const edm::ParameterSet&, edm::ConsumesCollector);

/// Destructor
~TrackTransformerForGlobalCosmicMuons() override;
Expand Down Expand Up @@ -77,6 +79,18 @@ class TrackTransformerForGlobalCosmicMuons : public TrackTransformerBase {

protected:
private:
const edm::ESGetToken<Propagator, TrackingComponentsRecord> theIOpropToken;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> theOIpropToken;
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> thGlobTrackGeoToken;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMFToken;
const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> theIOFitterToken;
const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> theOIFitterToken;
const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> theIOSmootherToken;
const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> theOISmootherToken;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTkRecHitBuildToken;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuildToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTopologyToken;

edm::ESHandle<Propagator> thePropagatorIO;
edm::ESHandle<Propagator> thePropagatorOI;

Expand Down
5 changes: 3 additions & 2 deletions TrackingTools/TrackRefitter/plugins/TracksToTrajectories.cc
Expand Up @@ -75,9 +75,10 @@ TracksToTrajectories::TracksToTrajectories(const ParameterSet& parameterSet, con
if (type == "Default")
theTrackTransformer = std::make_unique<TrackTransformer>(trackTransformerParam, consumesCollector());
else if (type == "GlobalCosmicMuonsForAlignment")
theTrackTransformer = std::make_unique<TrackTransformerForGlobalCosmicMuons>(trackTransformerParam);
theTrackTransformer =
std::make_unique<TrackTransformerForGlobalCosmicMuons>(trackTransformerParam, consumesCollector());
else if (type == "CosmicMuonsForAlignment")
theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(trackTransformerParam);
theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(trackTransformerParam, consumesCollector());
else {
throw cms::Exception("TracksToTrajectories")
<< "The selected algorithm does not exist"
Expand Down
39 changes: 24 additions & 15 deletions TrackingTools/TrackRefitter/src/TrackTransformerForCosmicMuons.cc
Expand Up @@ -31,12 +31,21 @@ using namespace std;
using namespace edm;

/// Constructor
TrackTransformerForCosmicMuons::TrackTransformerForCosmicMuons(const ParameterSet& parameterSet) {
theTrackerRecHitBuilderName = parameterSet.getParameter<string>("TrackerRecHitBuilder");
theMuonRecHitBuilderName = parameterSet.getParameter<string>("MuonRecHitBuilder");

TrackTransformerForCosmicMuons::TrackTransformerForCosmicMuons(const ParameterSet& parameterSet,
edm::ConsumesCollector iC)
: theIOpropToken(iC.esConsumes(edm::ESInputTag("", "SmartPropagatorRK"))),
theOIpropToken(iC.esConsumes(edm::ESInputTag("", "SmartPropagatorRKOpposite"))),
thGlobTrackGeoToken(iC.esConsumes()),
theMFToken(iC.esConsumes()),
theIOFitterToken(iC.esConsumes(edm::ESInputTag("", "KFFitterForRefitInsideOut"))),
theOIFitterToken(iC.esConsumes(edm::ESInputTag("", "KFSmootherForRefitInsideOut"))),
theIOSmootherToken(iC.esConsumes(edm::ESInputTag("", "KFFitterForRefitOutsideIn"))),
theOISmootherToken(iC.esConsumes(edm::ESInputTag("", "KFSmootherForRefitOutsideIn"))),
theTkRecHitBuildToken(
iC.esConsumes(edm::ESInputTag("", parameterSet.getParameter<string>("TrackerRecHitBuilder")))),
theMuonRecHitBuildToken(
iC.esConsumes(edm::ESInputTag("", parameterSet.getParameter<string>("MuonRecHitBuilder")))) {
theRPCInTheFit = parameterSet.getParameter<bool>("RefitRPCHits");

theCacheId_TC = theCacheId_GTG = theCacheId_MG = theCacheId_TRH = 0;
}

Expand All @@ -46,43 +55,43 @@ TrackTransformerForCosmicMuons::~TrackTransformerForCosmicMuons() {}
void TrackTransformerForCosmicMuons::setServices(const EventSetup& setup) {
const std::string metname = "Reco|TrackingTools|TrackTransformer";

setup.get<TrajectoryFitter::Record>().get("KFFitterForRefitInsideOut", theFitterIO);
setup.get<TrajectoryFitter::Record>().get("KFSmootherForRefitInsideOut", theSmootherIO);
setup.get<TrajectoryFitter::Record>().get("KFFitterForRefitOutsideIn", theFitterOI);
setup.get<TrajectoryFitter::Record>().get("KFSmootherForRefitOutsideIn", theSmootherOI);
theFitterIO = setup.getHandle(theIOFitterToken);
theFitterOI = setup.getHandle(theOIFitterToken);
theSmootherIO = setup.getHandle(theIOSmootherToken);
theSmootherOI = setup.getHandle(theOISmootherToken);

unsigned long long newCacheId_TC = setup.get<TrackingComponentsRecord>().cacheIdentifier();

if (newCacheId_TC != theCacheId_TC) {
LogTrace(metname) << "Tracking Component changed!";
theCacheId_TC = newCacheId_TC;
setup.get<TrackingComponentsRecord>().get("SmartPropagatorRK", thePropagatorIO);
setup.get<TrackingComponentsRecord>().get("SmartPropagatorRKOpposite", thePropagatorOI);
thePropagatorIO = setup.getHandle(theIOpropToken);
thePropagatorOI = setup.getHandle(theOIpropToken);
}

// Global Tracking Geometry
unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
if (newCacheId_GTG != theCacheId_GTG) {
LogTrace(metname) << "GlobalTrackingGeometry changed!";
theCacheId_GTG = newCacheId_GTG;
setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
theTrackingGeometry = setup.getHandle(thGlobTrackGeoToken);
}

// Magfield Field
unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
if (newCacheId_MG != theCacheId_MG) {
LogTrace(metname) << "Magnetic Field changed!";
theCacheId_MG = newCacheId_MG;
setup.get<IdealMagneticFieldRecord>().get(theMGField);
theMGField = setup.getHandle(theMFToken);
}

// Transient Rechit Builders
unsigned long long newCacheId_TRH = setup.get<TransientRecHitRecord>().cacheIdentifier();
if (newCacheId_TRH != theCacheId_TRH) {
theCacheId_TRH = newCacheId_TRH;
LogTrace(metname) << "TransientRecHitRecord changed!";
setup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName, theTrackerRecHitBuilder);
setup.get<TransientRecHitRecord>().get(theMuonRecHitBuilderName, theMuonRecHitBuilder);
theTrackerRecHitBuilder = setup.getHandle(theTkRecHitBuildToken);
theMuonRecHitBuilder = setup.getHandle(theMuonRecHitBuildToken);
}
}

Expand Down