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

complete esConsumes migration of Alignment/CommonAlignmentProducer #35271

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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#define Alignment_CommonAlignmentAlgorithm_AlignmentTrackSelector_h

#include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include <vector>

namespace edm {
Expand Down Expand Up @@ -60,6 +62,8 @@ class AlignmentTrackSelector {
};
ComparePt ptComparator;

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;

const bool applyBasicCuts_, applyNHighestPt_, applyMultiplicityFilter_;
const int seedOnlyFromAbove_;
const bool applyIsolation_, chargeCheck_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// user include files
#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/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -51,7 +51,7 @@
// class decleration
//

class AlignmentMuonHIPTrajectorySelector : public edm::EDProducer {
class AlignmentMuonHIPTrajectorySelector : public edm::stream::EDProducer<> {
public:
explicit AlignmentMuonHIPTrajectorySelector(const edm::ParameterSet&);
~AlignmentMuonHIPTrajectorySelector() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// Framework
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
//#include "FWCore/Framework/interface/EDProducer.h"
Expand Down Expand Up @@ -106,7 +106,7 @@ using namespace reco;
// class declaration
//

class GlobalTrackerMuonAlignment : public edm::EDAnalyzer {
class GlobalTrackerMuonAlignment : public edm::one::EDAnalyzer<> {
public:
explicit GlobalTrackerMuonAlignment(const edm::ParameterSet&);
~GlobalTrackerMuonAlignment() override;
Expand Down Expand Up @@ -155,6 +155,11 @@ class GlobalTrackerMuonAlignment : public edm::EDAnalyzer {
void endJob() override;

// ----------member data ---------------------------
edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> m_TkGeometryToken;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_MagFieldToken;
edm::ESGetToken<Alignments, GlobalPositionRcd> m_globalPosToken;
edm::ESGetToken<Propagator, TrackingComponentsRecord> m_propToken;
edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> m_ttrhBuilderToken;

edm::InputTag trackTags_; // used to select what tracks to read from configuration file
edm::InputTag muonTags_; // used to select what standalone muons
Expand Down Expand Up @@ -270,18 +275,19 @@ class GlobalTrackerMuonAlignment : public edm::EDAnalyzer {
// constructors and destructor
//
GlobalTrackerMuonAlignment::GlobalTrackerMuonAlignment(const edm::ParameterSet& iConfig)
: trackTags_(iConfig.getParameter<edm::InputTag>("tracks")),
: m_TkGeometryToken(esConsumes()),
m_MagFieldToken(esConsumes()),
m_globalPosToken(esConsumes()),
m_propToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<string>("Propagator")))),
m_ttrhBuilderToken(esConsumes(edm::ESInputTag("", "witTrackAngle"))),
trackTags_(iConfig.getParameter<edm::InputTag>("tracks")),
muonTags_(iConfig.getParameter<edm::InputTag>("muons")),
gmuonTags_(iConfig.getParameter<edm::InputTag>("gmuons")),
smuonTags_(iConfig.getParameter<edm::InputTag>("smuons")),
propagator_(iConfig.getParameter<string>("Propagator")),

cosmicMuonMode_(iConfig.getParameter<bool>("cosmics")),
isolatedMuonMode_(iConfig.getParameter<bool>("isolated")),

refitMuon_(iConfig.getParameter<bool>("refitmuon")),
refitTrack_(iConfig.getParameter<bool>("refittrack")),

rootOutFile_(iConfig.getUntrackedParameter<string>("rootOutFile")),
txtOutFile_(iConfig.getUntrackedParameter<string>("txtOutFile")),
writeDB_(iConfig.getUntrackedParameter<bool>("writeDB")),
Expand Down Expand Up @@ -660,20 +666,17 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrack(const edm::Event& iEvent, con
//iSetup.get<MuonGeometryRecord>().get(cscGeometry);

if (watchTrackingGeometry_.check(iSetup) || !trackingGeometry_) {
edm::ESHandle<GlobalTrackingGeometry> trackingGeometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
edm::ESHandle<GlobalTrackingGeometry> trackingGeometry = iSetup.getHandle(m_TkGeometryToken);
trackingGeometry_ = &*trackingGeometry;
}

if (watchMagneticFieldRecord_.check(iSetup) || !magneticField_) {
edm::ESHandle<MagneticField> magneticField;
iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
edm::ESHandle<MagneticField> magneticField = iSetup.getHandle(m_MagFieldToken);
magneticField_ = &*magneticField;
}

if (watchGlobalPositionRcd_.check(iSetup) || !globalPositionRcd_) {
edm::ESHandle<Alignments> globalPositionRcd;
iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
edm::ESHandle<Alignments> globalPositionRcd = iSetup.getHandle(m_globalPosToken);
globalPositionRcd_ = &*globalPositionRcd;
for (std::vector<AlignTransform>::const_iterator i = globalPositionRcd_->m_align.begin();
i != globalPositionRcd_->m_align.end();
Expand All @@ -695,8 +698,7 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrack(const edm::Event& iEvent, con
}
} // end of GlobalPositionRcd

ESHandle<Propagator> propagator;
iSetup.get<TrackingComponentsRecord>().get(propagator_, propagator);
edm::ESHandle<Propagator> propagator = iSetup.getHandle(m_propToken);

SteppingHelixPropagator alongStHePr = SteppingHelixPropagator(magneticField_, alongMomentum);
SteppingHelixPropagator oppositeStHePr = SteppingHelixPropagator(magneticField_, oppositeToMomentum);
Expand Down Expand Up @@ -1339,21 +1341,18 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrajectory(const edm::Event& iEvent
//iSetup.get<MuonGeometryRecord>().get(cscGeometry);

if (watchTrackingGeometry_.check(iSetup) || !trackingGeometry_) {
edm::ESHandle<GlobalTrackingGeometry> trackingGeometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
edm::ESHandle<GlobalTrackingGeometry> trackingGeometry = iSetup.getHandle(m_TkGeometryToken);
trackingGeometry_ = &*trackingGeometry;
theTrackingGeometry = trackingGeometry;
}

if (watchMagneticFieldRecord_.check(iSetup) || !magneticField_) {
edm::ESHandle<MagneticField> magneticField;
iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
edm::ESHandle<MagneticField> magneticField = iSetup.getHandle(m_MagFieldToken);
magneticField_ = &*magneticField;
}

if (watchGlobalPositionRcd_.check(iSetup) || !globalPositionRcd_) {
edm::ESHandle<Alignments> globalPositionRcd;
iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
edm::ESHandle<Alignments> globalPositionRcd = iSetup.getHandle(m_globalPosToken);
globalPositionRcd_ = &*globalPositionRcd;
for (std::vector<AlignTransform>::const_iterator i = globalPositionRcd_->m_align.begin();
i != globalPositionRcd_->m_align.end();
Expand All @@ -1379,8 +1378,7 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrajectory(const edm::Event& iEvent
}
} // end of GlobalPositionRcd

ESHandle<Propagator> propagator;
iSetup.get<TrackingComponentsRecord>().get(propagator_, propagator);
edm::ESHandle<Propagator> propagator = iSetup.getHandle(m_propToken);

SteppingHelixPropagator alongStHePr = SteppingHelixPropagator(magneticField_, alongMomentum);
SteppingHelixPropagator oppositeStHePr = SteppingHelixPropagator(magneticField_, oppositeToMomentum);
Expand All @@ -1407,8 +1405,7 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrajectory(const edm::Event& iEvent
theFitterOp = new KFTrajectoryFitter(oppositeSmPr, *theUpdator, *theEstimator);
theSmootherOp = new KFTrajectorySmoother(oppositeSmPr, *theUpdator, *theEstimator);

edm::ESHandle<TransientTrackingRecHitBuilder> builder;
iSetup.get<TransientRecHitRecord>().get("WithTrackAngle", builder);
edm::ESHandle<TransientTrackingRecHitBuilder> builder = iSetup.getHandle(m_ttrhBuilderToken);
this->TTRHBuilder = &(*builder);
this->MuRHBuilder = new MuonTransientTrackingRecHitBuilder(theTrackingGeometry);
if (debug_) {
Expand Down
12 changes: 4 additions & 8 deletions Alignment/CommonAlignmentProducer/src/AlignmentTrackSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/Alignment/interface/AlignmentClusterFlag.h"
#include "DataFormats/Alignment/interface/AliClusterValueMap.h"

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include <cmath>

Expand All @@ -31,7 +28,8 @@ const int kFPIX = PixelSubdetector::PixelEndcap;
// constructor ----------------------------------------------------------------

AlignmentTrackSelector::AlignmentTrackSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC)
: applyBasicCuts_(cfg.getParameter<bool>("applyBasicCuts")),
: tTopoToken_(iC.esConsumes()),
applyBasicCuts_(cfg.getParameter<bool>("applyBasicCuts")),
applyNHighestPt_(cfg.getParameter<bool>("applyNHighestPt")),
applyMultiplicityFilter_(cfg.getParameter<bool>("applyMultiplicityFilter")),
seedOnlyFromAbove_(cfg.getParameter<int>("seedOnlyFrom")),
Expand Down Expand Up @@ -222,7 +220,7 @@ AlignmentTrackSelector::AlignmentTrackSelector(const edm::ParameterSet& cfg, edm

// destructor -----------------------------------------------------------------

AlignmentTrackSelector::~AlignmentTrackSelector() {}
AlignmentTrackSelector::~AlignmentTrackSelector() = default;

// do selection ---------------------------------------------------------------

Expand Down Expand Up @@ -321,9 +319,7 @@ bool AlignmentTrackSelector::detailedHitsCheck(const reco::Track* trackp,
const edm::Event& evt,
const edm::EventSetup& eSetup) const {
//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHandle;
eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();
const TrackerTopology* const tTopo = &eSetup.getData(tTopoToken_);

// checking hit requirements beyond simple number of valid hits

Expand Down