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 some modules in RecoHI to esConsumes() #34961

Merged
merged 6 commits into from Aug 21, 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
11 changes: 4 additions & 7 deletions RecoHI/HiEgammaAlgos/plugins/HiEgammaSCCorrectionMaker.cc
Expand Up @@ -21,7 +21,8 @@

#include <string>

HiEgammaSCCorrectionMaker::HiEgammaSCCorrectionMaker(const edm::ParameterSet& ps) {
HiEgammaSCCorrectionMaker::HiEgammaSCCorrectionMaker(const edm::ParameterSet& ps)
: geoToken_(esConsumes()), topologyToken_(esConsumes()) {
// The verbosity level
std::string debugString = ps.getParameter<std::string>("VerbosityLevel");
if (debugString == "DEBUG")
Expand Down Expand Up @@ -80,14 +81,10 @@ void HiEgammaSCCorrectionMaker::produce(edm::Event& evt, const edm::EventSetup&
using namespace edm;

// get the collection geometry:
edm::ESHandle<CaloGeometry> geoHandle;
es.get<CaloGeometryRecord>().get(geoHandle);
const CaloGeometry& geometry = *geoHandle;
const CaloGeometry& geometry = es.getData(geoToken_);
const CaloSubdetectorGeometry* geometry_p;

edm::ESHandle<CaloTopology> pTopology;
es.get<CaloTopologyRecord>().get(theCaloTopo_);
const CaloTopology& topology = *theCaloTopo_;
const CaloTopology& topology = es.getData(topologyToken_);

std::string rHInputCollection = rHInputProducerTag_.instance();
if (rHInputCollection == "EcalRecHitsEB") {
Expand Down
3 changes: 2 additions & 1 deletion RecoHI/HiEgammaAlgos/plugins/HiEgammaSCCorrectionMaker.h
Expand Up @@ -58,9 +58,10 @@ class HiEgammaSCCorrectionMaker : public edm::stream::EDProducer<> {
edm::InputTag sCInputProducerTag_;
edm::EDGetTokenT<EcalRecHitCollection> rHInputProducer_;
edm::EDGetTokenT<reco::SuperClusterCollection> sCInputProducer_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken_;
edm::ESGetToken<CaloTopology, CaloTopologyRecord> topologyToken_;

reco::CaloCluster::AlgoId sCAlgo_;
std::string outputCollection_;
edm::ESHandle<CaloTopology> theCaloTopo_;
};
#endif
28 changes: 8 additions & 20 deletions RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc
Expand Up @@ -23,7 +23,6 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -56,6 +55,7 @@ class HiSpikeCleaner : public edm::stream::EDProducer<> {
edm::EDGetTokenT<reco::SuperClusterCollection> sCInputProducerToken_;
edm::EDGetTokenT<EcalRecHitCollection> rHInputProducerBToken_;
edm::EDGetTokenT<EcalRecHitCollection> rHInputProducerEToken_;
edm::ESGetToken<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd> ecalSevLvlAlgoToken_;
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;

std::string outputCollection_;
Expand All @@ -64,7 +64,8 @@ class HiSpikeCleaner : public edm::stream::EDProducer<> {
double etCut_;
};

HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig) : ecalClusterToolsESGetTokens_{consumesCollector()} {
HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig)
: ecalSevLvlAlgoToken_(esConsumes()), ecalClusterToolsESGetTokens_{consumesCollector()} {
//register your products
/* Examples
produces<ExampleData2>();
Expand Down Expand Up @@ -102,34 +103,21 @@ void HiSpikeCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)

// Get raw SuperClusters from the event
Handle<reco::SuperClusterCollection> pRawSuperClusters;
try {
iEvent.getByToken(sCInputProducerToken_, pRawSuperClusters);
} catch (cms::Exception& ex) {
edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the rawSuperClusters ";
}
iEvent.getByToken(sCInputProducerToken_, pRawSuperClusters);

// Get the RecHits from the event
Handle<EcalRecHitCollection> pRecHitsB;
try {
iEvent.getByToken(rHInputProducerBToken_, pRecHitsB);
} catch (cms::Exception& ex) {
edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the RecHits ";
}
iEvent.getByToken(rHInputProducerBToken_, pRecHitsB);

// Get the RecHits from the event
Handle<EcalRecHitCollection> pRecHitsE;
try {
iEvent.getByToken(rHInputProducerEToken_, pRecHitsE);
} catch (cms::Exception& ex) {
edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the RecHits ";
}
iEvent.getByToken(rHInputProducerEToken_, pRecHitsE);

// get the channel status from the DB
// edm::ESHandle<EcalChannelStatus> chStatus;
// iSetup.get<EcalChannelStatusRcd>().get(chStatus);

edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
iSetup.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
auto const& ecalSevLvlAlgo = iSetup.getData(ecalSevLvlAlgoToken_);

// Create a pointer to the RecHits and raw SuperClusters
const reco::SuperClusterCollection* rawClusters = pRawSuperClusters.product();
Expand Down Expand Up @@ -158,7 +146,7 @@ void HiSpikeCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
EcalRecHitCollection::const_iterator it = rechits.find(id);

if (it != rechits.end()) {
ecalSevLvlAlgoHndl->severityLevel(id, rechits);
ecalSevLvlAlgo.severityLevel(id, rechits);
swissCrx = EcalTools::swissCross(id, rechits, 0., true);
// std::cout << "swissCross = " << swissCrx <<std::endl;
// std::cout << " timing = " << it->time() << std::endl;
Expand Down
17 changes: 5 additions & 12 deletions RecoHI/HiEvtPlaneAlgos/interface/LoadEPDB.h
Expand Up @@ -10,27 +10,20 @@
#include "CondFormats/HIObjects/interface/RPFlatParams.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "DataFormats/HeavyIonEvent/interface/EvtPlane.h"
#include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h"
#include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h"
#include <vector>

class LoadEPDB {
public:
explicit LoadEPDB(const edm::ESHandle<RPFlatParams> flatparmsDB_, HiEvtPlaneFlatten** flat) {
explicit LoadEPDB(const RPFlatParams& flatparmsDB_, HiEvtPlaneFlatten** flat) {
int Hbins;
int Obins;
int flatTableSize = flatparmsDB_->m_table.size();
int flatTableSize = flatparmsDB_.m_table.size();
genFlatPsi_ = kTRUE;
if (flatTableSize < flat[0]->getHBins() + 2 * flat[0]->getOBins()) {
genFlatPsi_ = kFALSE;
Expand All @@ -39,7 +32,7 @@ class LoadEPDB {
Obins = flat[0]->getOBins();

for (int i = 0; i < flatTableSize; i++) {
const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[i]);
const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[i]);
for (int j = 0; j < hi::NumEPNames; j++) {
int indx = thisBin->RPNameIndx[j];
if (indx < 0 || indx >= hi::NumEPNames) {
Expand All @@ -62,13 +55,13 @@ class LoadEPDB {
}
int cbins = 0;
while (flatTableSize > Hbins + 2 * Obins + cbins) {
const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[Hbins + 2 * Obins + cbins]);
const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[Hbins + 2 * Obins + cbins]);
double centbinning = thisBin->x[0];
int ncentbins = (int)thisBin->y[0] + 0.01;
if (ncentbins == 0)
break;
for (int j = 0; j < ncentbins; j++) {
const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[Hbins + 2 * Obins + cbins + j + 1]);
const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[Hbins + 2 * Obins + cbins + j + 1]);
if (fabs(centbinning - 1.) < 0.01) {
for (int i = 0; i < hi::NumEPNames; i++) {
flat[i]->setCentRes1(j, thisBin->x[i], thisBin->y[i]);
Expand Down
19 changes: 10 additions & 9 deletions RecoHI/HiEvtPlaneAlgos/src/EvtPlaneProducer.cc
Expand Up @@ -30,7 +30,6 @@ Description: <one line class summary>
#include "FWCore/Framework/interface/EventSetup.h"

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

Expand Down Expand Up @@ -179,7 +178,6 @@ class EvtPlaneProducer : public edm::stream::EDProducer<> {
EPCuts cuts_;

std::string centralityVariable_;
std::string centralityLabel_;
std::string centralityMC_;

edm::InputTag centralityBinTag_;
Expand Down Expand Up @@ -212,6 +210,9 @@ class EvtPlaneProducer : public edm::stream::EDProducer<> {
edm::InputTag chi2MapLostTag_;
edm::EDGetTokenT<edm::ValueMap<float>> chi2MapLostToken_;

edm::ESGetToken<CentralityTable, HeavyIonRcd> centralityToken_;
edm::ESGetToken<RPFlatParams, HeavyIonRPRcd> flatparmsToken_;

bool loadDB_;
double minet_;
double maxet_;
Expand Down Expand Up @@ -383,7 +384,10 @@ EvtPlaneProducer::EvtPlaneProducer(const edm::ParameterSet &iConfig)
if (iConfig.exists("nonDefaultGlauberModel")) {
centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
}
centralityLabel_ = centralityVariable_ + centralityMC_;
centralityToken_ = esConsumes(edm::ESInputTag("", centralityVariable_ + centralityMC_));
if (loadDB_) {
flatparmsToken_ = esConsumes();
}

centralityBinToken_ = consumes<int>(centralityBinTag_);

Expand Down Expand Up @@ -438,9 +442,8 @@ void EvtPlaneProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup
//
//Get Size of Centrality Table
//
edm::ESHandle<CentralityTable> centDB_;
iSetup.get<HeavyIonRcd>().get(centralityLabel_, centDB_);
nCentBins_ = centDB_->m_table.size();
auto const &centDB = iSetup.getData(centralityToken_);
nCentBins_ = centDB.m_table.size();
for (int i = 0; i < NumEPNames; i++) {
if (caloCentRef_ > 0) {
int minbin = (caloCentRef_ - caloCentRefWidth_ / 2.) * nCentBins_ / 100.;
Expand All @@ -458,9 +461,7 @@ void EvtPlaneProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup
//Get flattening parameter file.
//
if (loadDB_ && hirpWatcher_.check(iSetup)) {
edm::ESHandle<RPFlatParams> flatparmsDB_;
iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
LoadEPDB db(flatparmsDB_, flat);
LoadEPDB db(iSetup.getData(flatparmsToken_), flat);
if (!db.IsSuccess()) {
loadDB_ = kFALSE;
}
Expand Down
16 changes: 7 additions & 9 deletions RecoHI/HiEvtPlaneAlgos/src/HiEvtPlaneFlatProducer.cc
Expand Up @@ -9,7 +9,6 @@
#include "Math/Vector3D.h"

#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"

Expand Down Expand Up @@ -57,7 +56,6 @@ class HiEvtPlaneFlatProducer : public edm::stream::EDProducer<> {
// ----------member data ---------------------------

std::string centralityVariable_;
std::string centralityLabel_;
std::string centralityMC_;

edm::InputTag centralityBinTag_;
Expand All @@ -78,6 +76,8 @@ class HiEvtPlaneFlatProducer : public edm::stream::EDProducer<> {

edm::ESWatcher<HeavyIonRcd> hiWatcher;
edm::ESWatcher<HeavyIonRPRcd> hirpWatcher;
edm::ESGetToken<CentralityTable, HeavyIonRcd> centralityESToken_;
edm::ESGetToken<RPFlatParams, HeavyIonRPRcd> flatparmsToken_;

const int FlatOrder_;
int NumFlatBins_;
Expand Down Expand Up @@ -115,7 +115,8 @@ HiEvtPlaneFlatProducer::HiEvtPlaneFlatProducer(const edm::ParameterSet& iConfig)
if (iConfig.exists("nonDefaultGlauberModel")) {
centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
}
centralityLabel_ = centralityVariable_ + centralityMC_;
centralityESToken_ = esConsumes(edm::ESInputTag("", centralityVariable_ + centralityMC_));
flatparmsToken_ = esConsumes();

centralityBinToken_ = consumes<int>(centralityBinTag_);

Expand Down Expand Up @@ -158,9 +159,8 @@ void HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup&
//
//Get Size of Centrality Table
//
edm::ESHandle<CentralityTable> centDB_;
iSetup.get<HeavyIonRcd>().get(centralityLabel_, centDB_);
nCentBins_ = centDB_->m_table.size();
auto const& centDB = iSetup.getData(centralityESToken_);
nCentBins_ = centDB.m_table.size();
for (int i = 0; i < NumEPNames; i++) {
if (caloCentRef_ > 0) {
int minbin = (caloCentRef_ - caloCentRefWidth_ / 2.) * nCentBins_ / 100.;
Expand All @@ -178,9 +178,7 @@ void HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup&
//Get flattening parameter file.
//
if (hirpWatcher.check(iSetup)) {
edm::ESHandle<RPFlatParams> flatparmsDB_;
iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
LoadEPDB db(flatparmsDB_, flat);
LoadEPDB db(iSetup.getData(flatparmsToken_), flat);
} //rp record change

//
Expand Down
8 changes: 2 additions & 6 deletions RecoHI/HiTracking/plugins/HIPixelClusterVtxProducer.cc
@@ -1,17 +1,14 @@
#include "HIPixelClusterVtxProducer.h"

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"

#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"

#include "DataFormats/GeometryVector/interface/LocalPoint.h"
Expand All @@ -27,6 +24,7 @@
/*****************************************************************************/
HIPixelClusterVtxProducer::HIPixelClusterVtxProducer(const edm::ParameterSet &ps)
: srcPixelsString_(ps.getParameter<std::string>("pixelRecHits")),
trackerToken_(esConsumes()),
minZ_(ps.getParameter<double>("minZ")),
maxZ_(ps.getParameter<double>("maxZ")),
zStep_(ps.getParameter<double>("zStep"))
Expand All @@ -53,9 +51,7 @@ void HIPixelClusterVtxProducer::produce(edm::Event &ev, const edm::EventSetup &e

// get tracker geometry
if (hRecHits.isValid()) {
edm::ESHandle<TrackerGeometry> trackerHandle;
es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
const TrackerGeometry *tgeo = trackerHandle.product();
const TrackerGeometry *tgeo = &es.getData(trackerToken_);
const SiPixelRecHitCollection *hits = hRecHits.product();

// loop over pixel rechits
Expand Down
3 changes: 3 additions & 0 deletions RecoHI/HiTracking/plugins/HIPixelClusterVtxProducer.h
Expand Up @@ -5,6 +5,8 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"

namespace edm {
class Run;
Expand All @@ -31,6 +33,7 @@ class HIPixelClusterVtxProducer : public edm::stream::EDProducer<> {

std::string srcPixelsString_; //pixel rec hits
edm::EDGetTokenT<SiPixelRecHitCollection> srcPixels_;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerToken_;

double minZ_;
double maxZ_;
Expand Down
7 changes: 4 additions & 3 deletions RecoHI/HiTracking/plugins/HIProtoTrackFilterProducer.cc
Expand Up @@ -34,6 +34,7 @@ class HIProtoTrackFilterProducer : public edm::global::EDProducer<> {

edm::EDGetTokenT<reco::BeamSpot> theBeamSpotToken;
edm::EDGetTokenT<SiPixelRecHitCollection> theSiPixelRecHitsToken;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTtopoToken;
double theTIPMax;
double theChi2Max, thePtMin;
bool doVariablePtMin;
Expand All @@ -42,6 +43,7 @@ class HIProtoTrackFilterProducer : public edm::global::EDProducer<> {
HIProtoTrackFilterProducer::HIProtoTrackFilterProducer(const edm::ParameterSet& iConfig)
: theBeamSpotToken(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
theSiPixelRecHitsToken(consumes<SiPixelRecHitCollection>(iConfig.getParameter<edm::InputTag>("siPixelRecHits"))),
theTtopoToken(esConsumes()),
theTIPMax(iConfig.getParameter<double>("tipMax")),
theChi2Max(iConfig.getParameter<double>("chi2")),
thePtMin(iConfig.getParameter<double>("ptMin")),
Expand Down Expand Up @@ -85,11 +87,10 @@ void HIProtoTrackFilterProducer::produce(edm::StreamID, edm::Event& iEvent, cons
edm::Handle<SiPixelRecHitCollection> recHitColl;
iEvent.getByToken(theSiPixelRecHitsToken, recHitColl);

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

std::vector<const TrackingRecHit*> theChosenHits;
edmNew::copyDetSetRange(*recHitColl, theChosenHits, httopo->pxbDetIdLayerComparator(1));
edmNew::copyDetSetRange(*recHitColl, theChosenHits, ttopo.pxbDetIdLayerComparator(1));
float estMult = theChosenHits.size();

double variablePtMin = thePtMin;
Expand Down