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

migrate Validation/RecoTrack to esConsumes #33235

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Validation/RecoTrack/interface/MultiTrackValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "CommonTools/RecoAlgos/interface/CosmicTrackingParticleSelector.h"
#include "SimTracker/Common/interface/TrackingParticleSelector.h"
#include "CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h"
#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
#include "SimTracker/TrackAssociation/interface/ParametersDefinerForTP.h"
#include "CommonTools/Utils/interface/DynArray.h"
#include "DataFormats/Common/interface/ValueMap.h"
Expand Down Expand Up @@ -52,6 +53,13 @@ class MultiTrackValidator : public DQMGlobalEDAnalyzer<MultiTrackValidatorHistog
void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;

protected:
// ES Tokens
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoEsToken;

std::string parametersDefiner;
const edm::ESGetToken<ParametersDefinerForTP, TrackAssociatorRecord> tpDefinerEsToken;
const bool parametersDefinerIsCosmic_;

//these are used by MTVGenPs
// MTV-specific data members
std::vector<edm::InputTag> associators;
Expand All @@ -72,9 +80,6 @@ class MultiTrackValidator : public DQMGlobalEDAnalyzer<MultiTrackValidatorHistog
edm::EDGetTokenT<edm::ValueMap<reco::DeDxData>> m_dEdx1Tag;
edm::EDGetTokenT<edm::ValueMap<reco::DeDxData>> m_dEdx2Tag;

std::string parametersDefiner;

const bool parametersDefinerIsCosmic_;
const bool ignoremissingtkcollection_;
const bool useAssociators_;
const bool calculateDrSingleCollection_;
Expand Down
3 changes: 3 additions & 0 deletions Validation/RecoTrack/interface/SiPixelTrackingRecHitsValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class SiPixelTrackingRecHitsValid : public DQMOneEDAnalyzer<> {
const BoundPlane& plane);

private:
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoEsToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomEsToken_;

TrackerHitAssociator::Config trackerHitAssociatorConfig_;
//TrackLocalAngle *anglefinder_;
DQMStore* dbe_;
Expand Down
18 changes: 11 additions & 7 deletions Validation/RecoTrack/interface/SiStripTrackingRecHitsValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h"
#include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
#include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
#include "RecoLocalTracker/Records/interface/TkStripCPERecord.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Expand All @@ -45,6 +46,7 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

//--- for SimHit association
Expand Down Expand Up @@ -246,9 +248,15 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer {
protected:
void analyze(const edm::Event& e, const edm::EventSetup& c) override;
void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& es) override;
const MagneticField* magfield2_;

private:
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> m_geomToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken, m_topoTokenBR;
const edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> m_SiStripDetCablingToken;
const edm::ESGetToken<StripClusterParameterEstimator, TkStripCPERecord> m_stripCPEToken;

edm::ESWatcher<SiStripDetCablingRcd> watchSiStripDetCablingRcd_;

DQMStore* dbe_;
bool runStandalone;
bool outputMEsInRootFile;
Expand Down Expand Up @@ -385,9 +393,6 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer {
std::map<std::string, StereoAndMatchedMEs> StereoAndMatchedMEsMap;
std::map<std::string, std::vector<uint32_t> > LayerDetMap;
std::map<std::string, std::vector<uint32_t> > StereoAndMatchedDetMap;

edm::ESHandle<SiStripDetCabling> SiStripDetCabling_;

std::pair<LocalPoint, LocalVector> projectHit(const PSimHit& hit,
const StripGeomDetUnit* stripDet,
const BoundPlane& plane);
Expand Down Expand Up @@ -429,15 +434,14 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer {

edm::ParameterSet conf_;
TrackerHitAssociator::Config trackerHitAssociatorConfig_;
unsigned long long m_cacheID_;
edm::ParameterSet Parameters;

RecHitProperties rechitpro;

void rechitanalysis(LocalVector ldir,
const TrackingRecHit* rechit,
const StripGeomDetUnit* stripdet,
edm::ESHandle<StripClusterParameterEstimator> stripcpe,
const StripClusterParameterEstimator* stripcpe,
TrackerHitAssociator& associate,
bool simplehit1or2D);

Expand All @@ -446,7 +450,7 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer {
const TrackingRecHit* rechit,
const GluedGeomDet* gluedDet,
TrackerHitAssociator& associate,
edm::ESHandle<StripClusterParameterEstimator> stripcpe,
const StripClusterParameterEstimator* stripcpe,
const MatchStatus matchedmonorstereo);

float track_rapidity;
Expand Down
33 changes: 11 additions & 22 deletions Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
Expand Down Expand Up @@ -96,10 +96,10 @@ class JetCoreMCtruthSeedGenerator : public edm::one::EDProducer<edm::one::Shared
void endJob() override;

// ----------member data ---------------------------
std::string propagatorName_;
edm::ESHandle<MagneticField> magfield_;
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> geomEsToken_;
const edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> pixelCPEEsToken_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoEsToken_;
edm::ESHandle<GlobalTrackingGeometry> geometry_;
edm::ESHandle<Propagator> propagator_;

edm::EDGetTokenT<std::vector<reco::Vertex>> vertices_;
edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster>> pixelClusters_;
Expand All @@ -114,7 +114,6 @@ class JetCoreMCtruthSeedGenerator : public edm::one::EDProducer<edm::one::Shared
double deltaR_;
double chargeFracMin_;
double centralMIPCharge_;
std::string pixelCPE_;

std::pair<bool, Basic3DVector<float>> findIntersection(const GlobalVector&,
const reco::Candidate::Point&,
Expand Down Expand Up @@ -158,8 +157,9 @@ class JetCoreMCtruthSeedGenerator : public edm::one::EDProducer<edm::one::Shared
};

JetCoreMCtruthSeedGenerator::JetCoreMCtruthSeedGenerator(const edm::ParameterSet& iConfig)
:

: geomEsToken_(esConsumes()),
pixelCPEEsToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("pixelCPE")))),
tTopoEsToken_(esConsumes()),
vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
pixelClusters_(
consumes<edmNew::DetSetVector<SiPixelCluster>>(iConfig.getParameter<edm::InputTag>("pixelClusters"))),
Expand All @@ -170,10 +170,7 @@ JetCoreMCtruthSeedGenerator::JetCoreMCtruthSeedGenerator(const edm::ParameterSet
ptMin_(iConfig.getParameter<double>("ptMin")),
deltaR_(iConfig.getParameter<double>("deltaR")),
chargeFracMin_(iConfig.getParameter<double>("chargeFractionMin")),
centralMIPCharge_(iConfig.getParameter<double>("centralMIPCharge")),
pixelCPE_(iConfig.getParameter<std::string>("pixelCPE"))

{
centralMIPCharge_(iConfig.getParameter<double>("centralMIPCharge")) {
produces<TrajectorySeedCollection>();
produces<reco::TrackCollection>();
}
Expand All @@ -187,9 +184,7 @@ void JetCoreMCtruthSeedGenerator::produce(edm::Event& iEvent, const edm::EventSe
using namespace edm;
using namespace reco;

iSetup.get<IdealMagneticFieldRecord>().get(magfield_);
iSetup.get<GlobalTrackingGeometryRecord>().get(geometry_);
iSetup.get<TrackingComponentsRecord>().get("AnalyticalPropagator", propagator_);
geometry_ = iSetup.getHandle(geomEsToken_);

const auto& inputPixelClusters_ = iEvent.get(pixelClusters_);
const auto& simtracksVector = iEvent.get(simtracksToken_);
Expand All @@ -198,14 +193,8 @@ void JetCoreMCtruthSeedGenerator::produce(edm::Event& iEvent, const edm::EventSe
const auto& vertices = iEvent.get(vertices_);
const auto& cores = iEvent.get(cores_);

edm::ESHandle<PixelClusterParameterEstimator> pixelCPEhandle;
const PixelClusterParameterEstimator* pixelCPE;
iSetup.get<TkPixelCPERecord>().get(pixelCPE_, pixelCPEhandle);
pixelCPE = pixelCPEhandle.product();

edm::ESHandle<TrackerTopology> tTopoHandle;
iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();
const PixelClusterParameterEstimator* pixelCPE = &iSetup.getData(pixelCPEEsToken_);
const TrackerTopology* const tTopo = &iSetup.getData(tTopoEsToken_);

auto output = std::make_unique<edmNew::DetSetVector<SiPixelCluster>>();

Expand Down
13 changes: 6 additions & 7 deletions Validation/RecoTrack/plugins/MultiTrackValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ namespace {
} // namespace

MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset)
: associators(pset.getUntrackedParameter<std::vector<edm::InputTag>>("associators")),
label(pset.getParameter<std::vector<edm::InputTag>>("label")),
: tTopoEsToken(esConsumes()),
parametersDefiner(pset.getParameter<std::string>("parametersDefiner")),
tpDefinerEsToken(esConsumes(edm::ESInputTag("", parametersDefiner))),
parametersDefinerIsCosmic_(parametersDefiner == "CosmicParametersDefinerForTP"),
associators(pset.getUntrackedParameter<std::vector<edm::InputTag>>("associators")),
label(pset.getParameter<std::vector<edm::InputTag>>("label")),
ignoremissingtkcollection_(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection", false)),
useAssociators_(pset.getParameter<bool>("UseAssociators")),
calculateDrSingleCollection_(pset.getUntrackedParameter<bool>("calculateDrSingleCollection")),
Expand Down Expand Up @@ -586,14 +588,11 @@ void MultiTrackValidator::dqmAnalyze(const edm::Event& event,
<< "====================================================\n"
<< "\n";

edm::ESHandle<ParametersDefinerForTP> parametersDefinerTPHandle;
setup.get<TrackAssociatorRecord>().get(parametersDefiner, parametersDefinerTPHandle);
const auto& parametersDefinerTPHandle = setup.getHandle(tpDefinerEsToken);
//Since we modify the object, we must clone it
auto parametersDefinerTP = parametersDefinerTPHandle->clone();

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

// FIXME: we really need to move to edm::View for reading the
// TrackingParticles... Unfortunately it has non-trivial
Expand Down
8 changes: 2 additions & 6 deletions Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ void MultiTrackValidatorGenPs::dqmAnalyze(const edm::Event& event,
<< "====================================================\n"
<< "\n";

edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP;
setup.get<TrackAssociatorRecord>().get(parametersDefiner, parametersDefinerTP);

edm::ESHandle<TrackerTopology> httopo;
setup.get<TrackerTopologyRcd>().get(httopo);
const TrackerTopology& ttopo = *httopo;
const auto& parametersDefinerTP = &setup.getData(tpDefinerEsToken);
const TrackerTopology& ttopo = setup.getData(tTopoEsToken);

edm::Handle<GenParticleCollection> TPCollectionHeff;
event.getByToken(label_tp_effic, TPCollectionHeff);
Expand Down
20 changes: 11 additions & 9 deletions Validation/RecoTrack/plugins/SiPixelTrackingRecHitsValid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ void SiPixelTrackingRecHitsValid::beginJob() {
}

SiPixelTrackingRecHitsValid::SiPixelTrackingRecHitsValid(const edm::ParameterSet& ps)
: trackerHitAssociatorConfig_(ps, consumesCollector()), dbe_(nullptr), tfile_(nullptr), t_(nullptr) {
: tTopoEsToken_(esConsumes()),
tGeomEsToken_(esConsumes()),
trackerHitAssociatorConfig_(ps, consumesCollector()),
dbe_(nullptr),
tfile_(nullptr),
t_(nullptr) {
//Read config file
MTCCtrack_ = ps.getParameter<bool>("MTCCtrack");
runStandalone = ps.getParameter<bool>("runStandalone");
Expand Down Expand Up @@ -1103,8 +1108,7 @@ SiPixelTrackingRecHitsValid::~SiPixelTrackingRecHitsValid() {
// Functions that gets called by framework every event
void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es) {
//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopo;
es.get<TrackerTopologyRcd>().get(tTopo);
const auto& tTopo = &es.getData(tTopoEsToken_);

run = e.id().run();
evt = e.id().event();
Expand All @@ -1124,9 +1128,7 @@ void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventS
std::vector<PSimHit> matched;
TrackerHitAssociator associate(e, trackerHitAssociatorConfig_);

edm::ESHandle<TrackerGeometry> pDD;
es.get<TrackerDigiGeometryRecord>().get(pDD);
const TrackerGeometry* tracker = &(*pDD);
const TrackerGeometry* tracker = &es.getData(tGeomEsToken_);

if (!MTCCtrack_) {
// --------------------------------------- all hits -----------------------------------------------------------
Expand All @@ -1139,8 +1141,8 @@ void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventS
// << " Pixel RecHits" << std::endl;

//-----Iterate over detunits
for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
DetId detId = ((*it)->geographicalId());
for (const auto& it : tracker->dets()) {
DetId detId = it->geographicalId();

unsigned int subid = detId.subdetId();
if (!((subid == 1) || (subid == 2)))
Expand All @@ -1162,7 +1164,7 @@ void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventS
float rechitx = lp.x();
float rechity = lp.y();

detId = (*it)->geographicalId();
detId = it->geographicalId();
subdetId = (int)detId.subdetId();
if ((int)detId.subdetId() == (int)PixelSubdetector::PixelBarrel) {
mePosxBarrel_all_hits->Fill(rechitx);
Expand Down
27 changes: 12 additions & 15 deletions Validation/RecoTrack/plugins/TrackFromSeedProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ class TrackFromSeedProducer : public edm::global::EDProducer<> {
// ----------member data ---------------------------
edm::EDGetTokenT<edm::View<TrajectorySeed> > seedsToken;
edm::EDGetTokenT<reco::BeamSpot> beamSpotToken;
std::string tTRHBuilderName;
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> geoToken_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> mfToken_;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> ttrhToken_;
};

//
Expand All @@ -76,7 +78,10 @@ class TrackFromSeedProducer : public edm::global::EDProducer<> {
// constructors and destructor
//
TrackFromSeedProducer::TrackFromSeedProducer(const edm::ParameterSet& iConfig)
: geoToken_(esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord>()) {
: geoToken_(esConsumes()),
tTopoToken_(esConsumes()),
mfToken_(esConsumes()),
ttrhToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("TTRHBuilder")))) {
//register your products
produces<reco::TrackCollection>();
produces<TrackingRecHitCollection>();
Expand All @@ -85,7 +90,6 @@ TrackFromSeedProducer::TrackFromSeedProducer(const edm::ParameterSet& iConfig)
// read parametes
edm::InputTag seedsTag(iConfig.getParameter<edm::InputTag>("src"));
edm::InputTag beamSpotTag(iConfig.getParameter<edm::InputTag>("beamSpot"));
tTRHBuilderName = iConfig.getParameter<std::string>("TTRHBuilder");

//consumes
seedsToken = consumes<edm::View<TrajectorySeed> >(seedsTag);
Expand Down Expand Up @@ -121,16 +125,9 @@ void TrackFromSeedProducer::produce(edm::StreamID, edm::Event& iEvent, const edm
// some objects to build to tracks
TSCBLBuilderNoMaterial tscblBuilder;

edm::ESHandle<TransientTrackingRecHitBuilder> tTRHBuilder;
iSetup.get<TransientRecHitRecord>().get(tTRHBuilderName, tTRHBuilder);

edm::ESHandle<MagneticField> theMF;
iSetup.get<IdealMagneticFieldRecord>().get(theMF);

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

const auto& tTRHBuilder = &iSetup.getData(ttrhToken_);
const auto& theMF = &iSetup.getData(mfToken_);
const TrackerTopology& ttopo = iSetup.getData(tTopoToken_);
const GlobalTrackingGeometry* const geometry_ = &iSetup.getData(geoToken_);

// create tracks from seeds
Expand All @@ -141,10 +138,10 @@ void TrackFromSeedProducer::produce(edm::StreamID, edm::Event& iEvent, const edm
TrajectoryStateOnSurface state;
if (seed.nHits() == 0) { //this is for deepCore seeds only
const Surface* deepCore_sruface = &geometry_->idToDet(seed.startingState().detId())->specificSurface();
state = trajectoryStateTransform::transientState(seed.startingState(), deepCore_sruface, theMF.product());
state = trajectoryStateTransform::transientState(seed.startingState(), deepCore_sruface, theMF);
} else {
TransientTrackingRecHit::RecHitPointer lastRecHit = tTRHBuilder->build(&*(seed.recHits().end() - 1));
state = trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), theMF.product());
state = trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), theMF);
}
TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed =
tscblBuilder(*state.freeState(), *beamSpot); //as in TrackProducerAlgorithm
Expand Down
Loading