Skip to content

Commit

Permalink
finalize migration to esConsumes of Alignment/CommonAlignmentMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Jun 28, 2021
1 parent bb50704 commit 4fe7330
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 244 deletions.
Expand Up @@ -36,6 +36,7 @@
#include "TH2F.h"
#include "TProfile.h"
#include "TTree.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

// forward declarations

Expand All @@ -45,7 +46,7 @@ class AlignmentMonitorBase {
typedef std::vector<ConstTrajTrackPair> ConstTrajTrackPairCollection;

/// Constructor
AlignmentMonitorBase(const edm::ParameterSet &cfg, std::string name);
AlignmentMonitorBase(const edm::ParameterSet &cfg, const edm::ConsumesCollector &iC, std::string name);

/// Destructor
virtual ~AlignmentMonitorBase() {}
Expand Down
Expand Up @@ -27,7 +27,8 @@ namespace edm {
class ParameterSet;
}

typedef edmplugin::PluginFactory<AlignmentMonitorBase*(const edm::ParameterSet&)> AlignmentMonitorPluginFactory;
typedef edmplugin::PluginFactory<AlignmentMonitorBase*(const edm::ParameterSet&, edm::ConsumesCollector&)>
AlignmentMonitorPluginFactory;

// // Forward declaration
// namespace edm { class ParameterSet; }
Expand Down
Expand Up @@ -132,11 +132,12 @@ AlignmentMonitorAsAnalyzer::AlignmentMonitorAsAnalyzer(const edm::ParameterSet&
esTokenCSCAPE_(esConsumes()),
esTokenGEMAl_(esConsumes()),
esTokenGEMAPE_(esConsumes()) {
edm::ConsumesCollector consumeCollector = consumesCollector();
std::vector<std::string> monitors = iConfig.getUntrackedParameter<std::vector<std::string>>("monitors");

for (auto const& mon : monitors) {
m_monitors.emplace_back(
AlignmentMonitorPluginFactory::get()->create(mon, iConfig.getUntrackedParameter<edm::ParameterSet>(mon)));
m_monitors.emplace_back(AlignmentMonitorPluginFactory::get()->create(
mon, iConfig.getUntrackedParameter<edm::ParameterSet>(mon), consumeCollector));
}
}

Expand Down
Expand Up @@ -8,8 +8,8 @@

#include <TString.h>

AlignmentMonitorGeneric::AlignmentMonitorGeneric(const edm::ParameterSet& cfg)
: AlignmentMonitorBase(cfg, "AlignmentMonitorGeneric") {}
AlignmentMonitorGeneric::AlignmentMonitorGeneric(const edm::ParameterSet& cfg, edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorGeneric") {}

void AlignmentMonitorGeneric::book() {
std::vector<std::string> residNames; // names of residual histograms
Expand Down
Expand Up @@ -29,7 +29,7 @@ class AlignmentMonitorGeneric : public AlignmentMonitorBase {
typedef std::vector<TH1F*> Hist1Ds;

public:
AlignmentMonitorGeneric(const edm::ParameterSet&);
AlignmentMonitorGeneric(const edm::ParameterSet&, edm::ConsumesCollector iC);

void book() override;

Expand Down
Expand Up @@ -33,7 +33,7 @@

class AlignmentMonitorMuonResiduals : public AlignmentMonitorBase {
public:
AlignmentMonitorMuonResiduals(const edm::ParameterSet &cfg);
AlignmentMonitorMuonResiduals(const edm::ParameterSet &cfg, edm::ConsumesCollector iC);
~AlignmentMonitorMuonResiduals() override{};

void book() override;
Expand Down Expand Up @@ -145,8 +145,8 @@ class AlignmentMonitorMuonResiduals : public AlignmentMonitorBase {
// member functions
//

AlignmentMonitorMuonResiduals::AlignmentMonitorMuonResiduals(const edm::ParameterSet &cfg)
: AlignmentMonitorBase(cfg, "AlignmentMonitorMuonResiduals") {
AlignmentMonitorMuonResiduals::AlignmentMonitorMuonResiduals(const edm::ParameterSet &cfg, edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorMuonResiduals") {
xresid_bins = cfg.getParameter<unsigned int>("xresid_bins");
xmean_bins = cfg.getParameter<unsigned int>("xmean_bins");
xstdev_bins = cfg.getParameter<unsigned int>("xstdev_bins");
Expand Down
Expand Up @@ -33,7 +33,7 @@

class AlignmentMonitorMuonSystemMap1D : public AlignmentMonitorBase {
public:
AlignmentMonitorMuonSystemMap1D(const edm::ParameterSet &cfg);
AlignmentMonitorMuonSystemMap1D(const edm::ParameterSet &cfg, edm::ConsumesCollector iC);
~AlignmentMonitorMuonSystemMap1D() override {}

void book() override;
Expand All @@ -46,6 +46,12 @@ class AlignmentMonitorMuonSystemMap1D : public AlignmentMonitorBase {
void afterAlignment() override;

private:
// es token
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> m_esTokenGBTGeom;
const edm::ESGetToken<DetIdAssociator, DetIdAssociatorRecord> m_esTokenDetId;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> m_esTokenProp;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_esTokenMF;

// parameters
edm::InputTag m_muonCollectionTag;
double m_minTrackPt;
Expand Down Expand Up @@ -142,8 +148,13 @@ class AlignmentMonitorMuonSystemMap1D : public AlignmentMonitorBase {
UInt_t m_run;
};

AlignmentMonitorMuonSystemMap1D::AlignmentMonitorMuonSystemMap1D(const edm::ParameterSet &cfg)
: AlignmentMonitorBase(cfg, "AlignmentMonitorMuonSystemMap1D"),
AlignmentMonitorMuonSystemMap1D::AlignmentMonitorMuonSystemMap1D(const edm::ParameterSet &cfg,
edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorMuonSystemMap1D"),
m_esTokenGBTGeom(iC.esConsumes()),
m_esTokenDetId(iC.esConsumes(edm::ESInputTag("", "MuonDetIdAssociator"))),
m_esTokenProp(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))),
m_esTokenMF(iC.esConsumes()),
m_muonCollectionTag(cfg.getParameter<edm::InputTag>("muonCollectionTag")),
m_minTrackPt(cfg.getParameter<double>("minTrackPt")),
m_maxTrackPt(cfg.getParameter<double>("maxTrackPt")),
Expand Down Expand Up @@ -253,20 +264,13 @@ void AlignmentMonitorMuonSystemMap1D::event(const edm::Event &iEvent,
const ConstTrajTrackPairCollection &trajtracks) {
m_counter_event++;

edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);

edm::Handle<reco::BeamSpot> beamSpot;
iEvent.getByLabel(m_beamSpotTag, beamSpot);

edm::ESHandle<DetIdAssociator> muonDetIdAssociator_;
iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);

edm::ESHandle<Propagator> prop;
iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", prop);

edm::ESHandle<MagneticField> magneticField;
iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
const GlobalTrackingGeometry *globalGeometry = &iSetup.getData(m_esTokenGBTGeom);
const DetIdAssociator *muonDetIdAssociator_ = &iSetup.getData(m_esTokenDetId);
const Propagator *prop = &iSetup.getData(m_esTokenProp);
const MagneticField *magneticField = &iSetup.getData(m_esTokenMF);

if (m_muonCollectionTag.label().empty()) // use trajectories
{
Expand Down
Expand Up @@ -33,7 +33,7 @@

class AlignmentMonitorMuonVsCurvature : public AlignmentMonitorBase {
public:
AlignmentMonitorMuonVsCurvature(const edm::ParameterSet &cfg);
AlignmentMonitorMuonVsCurvature(const edm::ParameterSet &cfg, edm::ConsumesCollector iC);
~AlignmentMonitorMuonVsCurvature() override {}

void book() override;
Expand All @@ -44,6 +44,13 @@ class AlignmentMonitorMuonVsCurvature : public AlignmentMonitorBase {
void processMuonResidualsFromTrack(MuonResidualsFromTrack &mrft, const Trajectory *traj = nullptr);

private:
// es token
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> m_esTokenGBTGeom;
const edm::ESGetToken<DetIdAssociator, DetIdAssociatorRecord> m_esTokenDetId;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> m_esTokenProp;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_esTokenMF;

// parameters
edm::InputTag m_muonCollectionTag;
double m_minTrackPt;
double m_minTrackP;
Expand Down Expand Up @@ -74,8 +81,13 @@ class AlignmentMonitorMuonVsCurvature : public AlignmentMonitorBase {
TH1F *th1f_trackerRedChi2Diff;
};

AlignmentMonitorMuonVsCurvature::AlignmentMonitorMuonVsCurvature(const edm::ParameterSet &cfg)
: AlignmentMonitorBase(cfg, "AlignmentMonitorMuonVsCurvature"),
AlignmentMonitorMuonVsCurvature::AlignmentMonitorMuonVsCurvature(const edm::ParameterSet &cfg,
edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorMuonVsCurvature"),
m_esTokenGBTGeom(iC.esConsumes()),
m_esTokenDetId(iC.esConsumes(edm::ESInputTag("", "MuonDetIdAssociator"))),
m_esTokenProp(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))),
m_esTokenMF(iC.esConsumes()),
m_muonCollectionTag(cfg.getParameter<edm::InputTag>("muonCollectionTag")),
m_minTrackPt(cfg.getParameter<double>("minTrackPt")),
m_minTrackP(cfg.getParameter<double>("minTrackP")),
Expand Down Expand Up @@ -182,20 +194,13 @@ void AlignmentMonitorMuonVsCurvature::book() {
void AlignmentMonitorMuonVsCurvature::event(const edm::Event &iEvent,
const edm::EventSetup &iSetup,
const ConstTrajTrackPairCollection &trajtracks) {
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);

edm::Handle<reco::BeamSpot> beamSpot;
iEvent.getByLabel(m_beamSpotTag, beamSpot);

edm::ESHandle<DetIdAssociator> muonDetIdAssociator_;
iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);

edm::ESHandle<Propagator> prop;
iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", prop);

edm::ESHandle<MagneticField> magneticField;
iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
const GlobalTrackingGeometry *globalGeometry = &iSetup.getData(m_esTokenGBTGeom);
const DetIdAssociator *muonDetIdAssociator_ = &iSetup.getData(m_esTokenDetId);
const Propagator *prop = &iSetup.getData(m_esTokenProp);
const MagneticField *magneticField = &iSetup.getData(m_esTokenMF);

if (m_muonCollectionTag.label().empty()) // use trajectories
{
Expand Down
Expand Up @@ -33,7 +33,7 @@

class AlignmentMonitorSegmentDifferences : public AlignmentMonitorBase {
public:
AlignmentMonitorSegmentDifferences(const edm::ParameterSet &cfg);
AlignmentMonitorSegmentDifferences(const edm::ParameterSet &cfg, edm::ConsumesCollector iC);
~AlignmentMonitorSegmentDifferences() override {}

void book() override;
Expand All @@ -44,6 +44,13 @@ class AlignmentMonitorSegmentDifferences : public AlignmentMonitorBase {
void processMuonResidualsFromTrack(MuonResidualsFromTrack &mrft);

private:
// es token
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> m_esTokenGBTGeom;
const edm::ESGetToken<DetIdAssociator, DetIdAssociatorRecord> m_esTokenDetId;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> m_esTokenProp;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_esTokenMF;

// parameters
edm::InputTag m_muonCollectionTag;
double m_minTrackPt;
double m_minTrackP;
Expand Down Expand Up @@ -107,8 +114,13 @@ class AlignmentMonitorSegmentDifferences : public AlignmentMonitorBase {
// member functions
//

AlignmentMonitorSegmentDifferences::AlignmentMonitorSegmentDifferences(const edm::ParameterSet &cfg)
: AlignmentMonitorBase(cfg, "AlignmentMonitorSegmentDifferences"),
AlignmentMonitorSegmentDifferences::AlignmentMonitorSegmentDifferences(const edm::ParameterSet &cfg,
edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorSegmentDifferences"),
m_esTokenGBTGeom(iC.esConsumes()),
m_esTokenDetId(iC.esConsumes(edm::ESInputTag("", "MuonDetIdAssociator"))),
m_esTokenProp(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))),
m_esTokenMF(iC.esConsumes()),
m_muonCollectionTag(cfg.getParameter<edm::InputTag>("muonCollectionTag")),
m_minTrackPt(cfg.getParameter<double>("minTrackPt")),
m_minTrackP(cfg.getParameter<double>("minTrackP")),
Expand Down Expand Up @@ -357,20 +369,13 @@ void AlignmentMonitorSegmentDifferences::book() {
void AlignmentMonitorSegmentDifferences::event(const edm::Event &iEvent,
const edm::EventSetup &iSetup,
const ConstTrajTrackPairCollection &trajtracks) {
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);

edm::Handle<reco::BeamSpot> beamSpot;
iEvent.getByLabel(m_beamSpotTag, beamSpot);

edm::ESHandle<DetIdAssociator> muonDetIdAssociator_;
iSetup.get<DetIdAssociatorRecord>().get("MuonDetIdAssociator", muonDetIdAssociator_);

edm::ESHandle<Propagator> prop;
iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", prop);

edm::ESHandle<MagneticField> magneticField;
iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
const GlobalTrackingGeometry *globalGeometry = &iSetup.getData(m_esTokenGBTGeom);
const DetIdAssociator *muonDetIdAssociator_ = &iSetup.getData(m_esTokenDetId);
const Propagator *prop = &iSetup.getData(m_esTokenProp);
const MagneticField *magneticField = &iSetup.getData(m_esTokenMF);

if (m_muonCollectionTag.label().empty()) // use trajectories
{
Expand Down
Expand Up @@ -4,8 +4,8 @@

#include "Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorSurvey.h"

AlignmentMonitorSurvey::AlignmentMonitorSurvey(const edm::ParameterSet& cfg)
: AlignmentMonitorBase(cfg, "AlignmentMonitorSurvey"),
AlignmentMonitorSurvey::AlignmentMonitorSurvey(const edm::ParameterSet& cfg, edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorSurvey"),
levelNames_(cfg.getUntrackedParameter<std::vector<std::string> >("surveyResiduals")) {}

void AlignmentMonitorSurvey::book() {
Expand Down
Expand Up @@ -20,7 +20,7 @@

class AlignmentMonitorSurvey : public AlignmentMonitorBase {
public:
AlignmentMonitorSurvey(const edm::ParameterSet&);
AlignmentMonitorSurvey(const edm::ParameterSet&, edm::ConsumesCollector);

void book() override;

Expand Down
Expand Up @@ -27,7 +27,8 @@

class AlignmentMonitorTemplate : public AlignmentMonitorBase {
public:
AlignmentMonitorTemplate(const edm::ParameterSet& cfg) : AlignmentMonitorBase(cfg, "AlignmentMonitorTemplate"){};
AlignmentMonitorTemplate(const edm::ParameterSet& cfg, edm::ConsumesCollector iC)
: AlignmentMonitorBase(cfg, iC, "AlignmentMonitorTemplate"){};
~AlignmentMonitorTemplate() override{};

void book() override;
Expand Down

0 comments on commit 4fe7330

Please sign in to comment.