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 Alignment/LaserAlignment to esConsumes #33054

Merged
merged 2 commits into from Mar 8, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 15 additions & 13 deletions Alignment/LaserAlignment/plugins/LaserAlignment.cc
Expand Up @@ -17,7 +17,13 @@
///
///
LaserAlignment::LaserAlignment(edm::ParameterSet const& theConf)
: theEvents(0),
: topoToken_(esConsumes()),
geomToken_(esConsumes()),
geomDetToken_(esConsumes()),
ptpToken_(esConsumes()),
gprToken_(esConsumes()),
stripPedestalsToken_(esConsumes()),
theEvents(0),
theDoPedestalSubtraction(theConf.getUntrackedParameter<bool>("SubtractPedestals", true)),
theUseMinuitAlgorithm(theConf.getUntrackedParameter<bool>("RunMinuitAlignmentTubeAlgorithm", false)),
theApplyBeamKinkCorrections(theConf.getUntrackedParameter<bool>("ApplyBeamKinkCorrections", true)),
Expand Down Expand Up @@ -271,32 +277,28 @@ void LaserAlignment::beginJob() {
void LaserAlignment::produce(edm::Event& theEvent, edm::EventSetup const& theSetup) {
if (firstEvent_) {
//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHandle;
theSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();
const TrackerTopology* const tTopo = &theSetup.getData(topoToken_);

// access the tracker
theSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
theSetup.get<IdealGeometryRecord>().get(gD);
gD = theSetup.getHandle(geomDetToken_);
theTrackerGeometry = theSetup.getHandle(geomToken_);

// access pedestals (from db..) if desired
edm::ESHandle<SiStripPedestals> pedestalsHandle;
if (theDoPedestalSubtraction) {
theSetup.get<SiStripPedestalsRcd>().get(pedestalsHandle);
pedestalsHandle = theSetup.getHandle(stripPedestalsToken_);
fillPedestalProfiles(pedestalsHandle);
}

// global positions
// edm::ESHandle<Alignments> theGlobalPositionRcd;
theSetup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get(theGlobalPositionRcd);
theGlobalPositionRcd = &theSetup.getData(gprToken_);

// select the reference geometry
if (!updateFromInputGeometry) {
// the AlignableTracker object is initialized with the ideal geometry
edm::ESHandle<GeometricDet> theGeometricDet;
theSetup.get<IdealGeometryRecord>().get(theGeometricDet);
edm::ESHandle<PTrackerParameters> ptp;
theSetup.get<PTrackerParametersRcd>().get(ptp);
const GeometricDet* theGeometricDet = &theSetup.getData(geomDetToken_);
const PTrackerParameters* ptp = &theSetup.getData(ptpToken_);

TrackerGeomBuilderFromGeometricDet trackerBuilder;
TrackerGeometry* theRefTracker = trackerBuilder.build(&*theGeometricDet, *ptp, tTopo);

Expand Down
8 changes: 8 additions & 0 deletions Alignment/LaserAlignment/plugins/LaserAlignment.h
Expand Up @@ -127,6 +127,14 @@ class LaserAlignment : public edm::one::EDProducer<edm::EndRunProducer> {
LASGlobalData<LASCoordinateSet>&,
LASBarrelAlignmentParameterSet&);

/// Tokens for ESconsumes
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::ESGetToken<GeometricDet, IdealGeometryRecord> geomDetToken_;
const edm::ESGetToken<PTrackerParameters, PTrackerParametersRcd> ptpToken_;
const edm::ESGetToken<Alignments, GlobalPositionRcd> gprToken_;
const edm::ESGetToken<SiStripPedestals, SiStripPedestalsRcd> stripPedestalsToken_;

/// counter for the total number of events processed
int theEvents;

Expand Down
8 changes: 3 additions & 5 deletions Alignment/LaserAlignment/plugins/LaserAlignmentEventFilter.cc
Expand Up @@ -7,9 +7,7 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h"
#include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h"

#include <algorithm>
Expand All @@ -26,7 +24,8 @@ std::vector<T> copy_and_sort_vector(std::vector<U> const& input) {
/// constructors and destructor
///
LaserAlignmentEventFilter::LaserAlignmentEventFilter(const edm::ParameterSet& iConfig)
: FED_collection_token(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("FedInputTag"))),
: cablingToken_(esConsumes()),
FED_collection_token(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("FedInputTag"))),
las_fed_ids(copy_and_sort_vector<uint16_t>(iConfig.getParameter<std::vector<int>>("FED_IDs"))),
las_signal_ids(copy_and_sort_vector<uint32_t>(iConfig.getParameter<std::vector<int>>("SIGNAL_IDs"))),
single_channel_thresh(iConfig.getParameter<unsigned>("SINGLE_CHANNEL_THRESH")),
Expand All @@ -49,8 +48,7 @@ bool LaserAlignmentEventFilter::filter(edm::StreamID sid, edm::Event& iEvent, co
iEvent.getByToken(FED_collection_token, buffers);

// read the cabling map from the EventSetup
edm::ESHandle<SiStripFedCabling> cabling;
iSetup.get<SiStripFedCablingRcd>().get(cabling);
const auto& cabling = &iSetup.getData(cablingToken_);

std::vector<uint16_t>::const_iterator ifed = las_fed_ids.begin();
for (; ifed != las_fed_ids.end(); ifed++) {
Expand Down
5 changes: 4 additions & 1 deletion Alignment/LaserAlignment/plugins/LaserAlignmentEventFilter.h
@@ -1,6 +1,6 @@
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/global/EDFilter.h"

#include "CondFormats/DataRecord/interface/SiStripFedCablingRcd.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"

class SiStripFedCabling;
Expand All @@ -13,6 +13,9 @@ class LaserAlignmentEventFilter : public edm::global::EDFilter<> {
private:
bool filter(edm::StreamID, edm::Event &, edm::EventSetup const &) const override;

// ES token
edm::ESGetToken<SiStripFedCabling, SiStripFedCablingRcd> cablingToken_;

// FED RAW data input collection
const edm::EDGetTokenT<FEDRawDataCollection> FED_collection_token;

Expand Down
23 changes: 15 additions & 8 deletions Alignment/LaserAlignment/plugins/TkLasBeamFitter.cc
Expand Up @@ -145,6 +145,16 @@ class TkLasBeamFitter : public edm::one::EDProducer<edm::EndRunProducer> {
double &chi2);

// ----------member data ---------------------------

// ES token
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;

// handles
edm::Handle<TkLasBeamCollection> laserBeams;
edm::ESHandle<MagneticField> fieldHandle;
edm::ESHandle<TrackerGeometry> geometry;

const edm::InputTag src_;
bool fitBeamSplitters_;
unsigned int nAtParameters_;
Expand Down Expand Up @@ -194,16 +204,13 @@ double TkLasBeamFitter::gBSparam = 0.0;
bool TkLasBeamFitter::gFitBeamSplitters = false;
bool TkLasBeamFitter::gIsInnerBarrel = false;

// handles
Handle<TkLasBeamCollection> laserBeams;
ESHandle<MagneticField> fieldHandle;
ESHandle<TrackerGeometry> geometry;

//
// constructors and destructor
//
TkLasBeamFitter::TkLasBeamFitter(const edm::ParameterSet &iConfig)
: src_(iConfig.getParameter<edm::InputTag>("src")),
: magFieldToken_(esConsumes<edm::Transition::EndRun>()),
geomToken_(esConsumes<edm::Transition::EndRun>()),
src_(iConfig.getParameter<edm::InputTag>("src")),
fitBeamSplitters_(iConfig.getParameter<bool>("fitBeamSplitters")),
nAtParameters_(iConfig.getParameter<unsigned int>("numberOfFittedAtParameters")),
h_bsAngle(nullptr),
Expand Down Expand Up @@ -336,8 +343,8 @@ void TkLasBeamFitter::endRunProduce(edm::Run &run, const edm::EventSetup &setup)

// get TkLasBeams, Tracker geometry, magnetic field
run.getByLabel("LaserAlignment", "tkLaserBeams", laserBeams);
setup.get<TrackerDigiGeometryRecord>().get(geometry);
setup.get<IdealMagneticFieldRecord>().get(fieldHandle);
geometry = setup.getHandle(geomToken_);
fieldHandle = setup.getHandle(magFieldToken_);

// hack for fixed BSparams (ugly!)
// double bsParams[34] = {-0.000266,-0.000956,-0.001205,-0.000018,-0.000759,0.002554,
Expand Down