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

Run3-hcx320 Use of ESGetToken in RecoLocalCalo/HcalRecAlgos #35234

Closed
wants to merge 7 commits into from
Closed
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
63 changes: 18 additions & 45 deletions CalibMuon/DTCalibration/test/DBTools/DumpDBToFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "CondFormats/DTObjects/interface/DTDeadFlag.h"
#include "CondFormats/DataRecord/interface/DTReadOutMappingRcd.h"
#include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
#include "CondFormats/DataRecord/interface/DTRecoUncertaintiesRcd.h"
#include "CondFormats/DTObjects/interface/DTRecoUncertainties.h"
#include "CondFormats/DTObjects/interface/DTRecoConditions.h"
#include "CondFormats/DataRecord/interface/DTRecoConditionsTtrigRcd.h"
#include "CondFormats/DataRecord/interface/DTRecoConditionsVdriftRcd.h"
Expand Down Expand Up @@ -98,15 +96,9 @@ void DumpDBToFile::beginRun(const edm::Run&, const EventSetup& setup) {
setup.get<DTReadOutMappingRcd>().get(channels);
channelsMap = &*channels;
} else if (dbToDump == "RecoUncertDB") {
if (format == "Legacy") {
ESHandle<DTRecoUncertainties> uncerts;
setup.get<DTRecoUncertaintiesRcd>().get(uncerts);
uncertMap = &*uncerts;
} else if (format == "DTRecoConditions") {
ESHandle<DTRecoConditions> h_rconds;
setup.get<DTRecoConditionsUncertRcd>().get(h_rconds);
rconds = &*h_rconds;
}
ESHandle<DTRecoConditions> h_rconds;
setup.get<DTRecoConditionsUncertRcd>().get(h_rconds);
rconds = &*h_rconds;
}
}

Expand Down Expand Up @@ -302,42 +294,23 @@ void DumpDBToFile::endJob() {

//---------- Uncertainties
} else if (dbToDump == "RecoUncertDB") {
if (format == "Legacy") {
int version = 1;
int type = 2; // par[step]
cout << "RecoUncertDB version: " << uncertMap->version() << endl;
for (DTRecoUncertainties::const_iterator wireAndUncerts = uncertMap->begin();
wireAndUncerts != uncertMap->end();
++wireAndUncerts) {
DTWireId wireId((*wireAndUncerts).first);
vector<float> values = (*wireAndUncerts).second;
// cout << wireId;
// copy(values.begin(), values.end(), ostream_iterator<float>(cout, " cm, "));
// cout << endl;
int nfields = values.size();
vector<float> consts = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, float(version * 1000 + type * 100 + nfields)};
consts.insert(consts.end(), values.begin(), values.end());
theCalibFile->addCell(wireId, consts);
}
} else if (format == "DTRecoConditions") {
int version = rconds->version();
string expr = rconds->getFormulaExpr();
int type = 2; // par[step]
if (version != 1 || expr != "par[step]")
throw cms::Exception("Configuration") << "only version 1, type 2 is presently supported for RecoUncertDB";
int version = rconds->version();
string expr = rconds->getFormulaExpr();
int type = 2; // par[step]
if (version != 1 || expr != "par[step]")
throw cms::Exception("Configuration") << "only version 1, type 2 is presently supported for RecoUncertDB";

cout << "[DumpDBToFile] DTRecoConditions (uncerts) version: " << rconds->version() << " expression: " << expr
<< endl;
cout << "[DumpDBToFile] DTRecoConditions (uncerts) version: " << rconds->version() << " expression: " << expr
<< endl;

for (DTRecoConditions::const_iterator irc = rconds->begin(); irc != rconds->end(); ++irc) {
DTWireId wireId(irc->first);
const vector<double>& data = irc->second;
int nfields = data.size();
vector<float> consts(11 + nfields, -1);
consts[10] = float(version * 1000 + type * 100 + nfields);
std::copy(data.begin(), data.end(), consts.begin() + 11);
theCalibFile->addCell(wireId, consts);
}
for (DTRecoConditions::const_iterator irc = rconds->begin(); irc != rconds->end(); ++irc) {
DTWireId wireId(irc->first);
const vector<double>& data = irc->second;
int nfields = data.size();
vector<float> consts(11 + nfields, -1);
consts[10] = float(version * 1000 + type * 100 + nfields);
std::copy(data.begin(), data.end(), consts.begin() + 11);
theCalibFile->addCell(wireId, consts);
}
}
//Write constants into file
Expand Down
2 changes: 0 additions & 2 deletions CalibMuon/DTCalibration/test/DBTools/DumpDBToFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class DTStatusFlag;
class DTDeadFlag;
class DTCalibrationMap;
class DTReadOutMapping;
class DTRecoUncertainties;
class DTRecoConditions;

class DumpDBToFile : public edm::EDAnalyzer {
Expand All @@ -47,7 +46,6 @@ class DumpDBToFile : public edm::EDAnalyzer {
const DTStatusFlag *statusMap;
const DTDeadFlag *deadMap;
const DTReadOutMapping *channelsMap;
const DTRecoUncertainties *uncertMap;
const DTRecoConditions *rconds;

DTCalibrationMap *theCalibFile;
Expand Down
57 changes: 20 additions & 37 deletions CalibMuon/DTCalibration/test/DBTools/DumpFileToDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "CondFormats/DTObjects/interface/DTStatusFlag.h"
#include "CondFormats/DTObjects/interface/DTDeadFlag.h"
#include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
#include "CondFormats/DTObjects/interface/DTRecoUncertainties.h"
#include "CondFormats/DTObjects/interface/DTRecoConditions.h"
#include "CondFormats/DataRecord/interface/DTRecoConditionsTtrigRcd.h"
#include "CondFormats/DataRecord/interface/DTRecoConditionsVdriftRcd.h"
Expand Down Expand Up @@ -268,43 +267,27 @@ void DumpFileToDB::endJob() {
//---------- Uncertainties
} else if (dbToDump == "RecoUncertDB") { // Write the Uncertainties

if (format == "Legacy") {
DTRecoUncertainties* uncert = new DTRecoUncertainties();
int version = 1; // Uniform uncertainties per SL and step; parameters 0-3 are for steps 1-4.
uncert->setVersion(version);
// Loop over file entries
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
vector<float> values = (*keyAndCalibs).second;
vector<float> uncerts(values.begin() + 11, values.end());
uncert->set((*keyAndCalibs).first, uncerts);
}
DTCalibDBUtils::writeToDB<DTRecoUncertainties>("DTRecoUncertaintiesRcd", uncert);

} else if (format == "DTRecoConditions") {
DTRecoConditions* conds = new DTRecoConditions();
conds->setFormulaExpr("par[step]");
int version = 1; // Uniform uncertainties per SL and step; parameters 0-3 are for steps 1-4.
conds->setVersion(version);

for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
vector<float> values = (*keyAndCalibs).second;
int fversion = int(values[10] / 1000);
int type = (int(values[10]) % 1000) / 100;
int nfields = int(values[10]) % 100;
if (type != 2)
throw cms::Exception("IncorrectSetup") << "Only type==2 supported for uncertainties DB";
if (values.size() != unsigned(nfields + 11))
throw cms::Exception("IncorrectSetup") << "Inconsistent number of fields";
if (fversion != version)
throw cms::Exception("IncorrectSetup") << "Inconsistent version of file";
DTRecoConditions* conds = new DTRecoConditions();
conds->setFormulaExpr("par[step]");
int version = 1; // Uniform uncertainties per SL and step; parameters 0-3 are for steps 1-4.
conds->setVersion(version);

vector<double> params(values.begin() + 11, values.begin() + 11 + nfields);
conds->set((*keyAndCalibs).first, params);
}
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
vector<float> values = (*keyAndCalibs).second;
int fversion = int(values[10] / 1000);
int type = (int(values[10]) % 1000) / 100;
int nfields = int(values[10]) % 100;
if (type != 2)
throw cms::Exception("IncorrectSetup") << "Only type==2 supported for uncertainties DB";
if (values.size() != unsigned(nfields + 11))
throw cms::Exception("IncorrectSetup") << "Inconsistent number of fields";
if (fversion != version)
throw cms::Exception("IncorrectSetup") << "Inconsistent version of file";

vector<double> params(values.begin() + 11, values.begin() + 11 + nfields);
conds->set((*keyAndCalibs).first, params);
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsUncertRcd", conds);
}
}
Expand Down
4 changes: 2 additions & 2 deletions CalibMuon/DTCalibration/test/DumpDBToFile_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
if TYPE=="TTrigDB" : RECORD = "DTTtrigRcd"
if TYPE=="VDriftDB" : RECORD = "DTMtimeRcd"
if TYPE=="UncertDB" :
RECORD = "DTRecoUncertaintiesRcd"
print('\nWARNING, Legacy RecoUncertDB is deprecated, as it is no longer used in reconstruction code')
RECORD = ""
print('\nERROR, Legacy RecoUncertDB is no longer supported')
elif DBFORMAT=="DTRecoConditions" :
if TYPE=="TTrigDB" : RECORD = "DTRecoConditionsTtrigRcd"
if TYPE=="VDriftDB" : RECORD = "DTRecoConditionsVdriftRcd"
Expand Down
4 changes: 2 additions & 2 deletions CalibMuon/DTCalibration/test/DumpFileToDB_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
if TYPE=="TTrigDB" : RECORD = "DTTtrigRcd"
if TYPE=="VDriftDB" : RECORD = "DTMtimeRcd"
if TYPE=="UncertDB" :
RECORD = "DTRecoUncertaintiesRcd"
print('\nWARNING, Legacy RecoUncertDB is deprecated, as it is no longer used in reconstruction code')
RECORD = ""
print('\nERROR, Legacy RecoUncertDB is no longer supported')
elif DBFORMAT=="DTRecoConditions" :
if TYPE=="TTrigDB" : RECORD = "DTRecoConditionsTtrigRcd"
if TYPE=="VDriftDB" : RECORD = "DTRecoConditionsVdriftRcd"
Expand Down
1 change: 0 additions & 1 deletion GeneratorInterface/SherpaInterface/src/SherpaHadronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ SherpaHadronizer::~SherpaHadronizer() {

bool SherpaHadronizer::initializeForInternalPartons() {
//initialize Sherpa but only once
throw cms::Exception("TEST");
if (!isInitialized) {
int argc = arguments.size();
char *argv[argc];
Expand Down
1 change: 0 additions & 1 deletion RecoLocalCalo/HcalRecAlgos/src/HBHEIsolatedNoiseAlgos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Original Author: John Paul Chou (Brown University)
#include "RecoLocalCalo/HcalRecAlgos/interface/HBHEIsolatedNoiseAlgos.h"

#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "DataFormats/METReco/interface/CaloMETCollection.h"
#include "DataFormats/METReco/interface/CaloMET.h"
Expand Down
29 changes: 12 additions & 17 deletions RecoLocalCalo/HcalRecAlgos/test/HcalRecHitReflagger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/one/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
Expand All @@ -37,7 +37,6 @@
#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
#include "CondFormats/HcalObjects/interface/HcalCondObjectContainer.h"
#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
#include "FWCore/Framework/interface/ESHandle.h"

using namespace std;
using namespace edm;
Expand All @@ -46,16 +45,15 @@ using namespace edm;
// class declaration
//

class HcalRecHitReflagger : public edm::EDProducer {
class HcalRecHitReflagger : public edm::one::EDProducer<> {
public:
explicit HcalRecHitReflagger(const edm::ParameterSet&);
~HcalRecHitReflagger();

private:
virtual void beginJob() override;
virtual void produce(edm::Event&, const edm::EventSetup&) override;
virtual void endJob() override;
virtual void beginRun(const Run& r, const EventSetup& c) override;
void beginJob() override;
void produce(edm::Event&, const edm::EventSetup&) override;
void endJob() override;

// Threshold function gets values from polynomial-parameterized functions
double GetThreshold(const int base, const std::vector<double>& params);
Expand All @@ -73,6 +71,8 @@ class HcalRecHitReflagger : public edm::EDProducer {
double GetSlope(const int ieta, const std::vector<double>& params);

// ----------member data ---------------------------
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> tokTopo_;
const edm::ESGetToken<HcalChannelQuality, HcalChannelQualityRcd> tokChan_;
const HcalTopology* topo;
edm::InputTag hfInputLabel_;
edm::EDGetTokenT<HFRecHitCollection> tok_hf_;
Expand Down Expand Up @@ -115,7 +115,9 @@ class HcalRecHitReflagger : public edm::EDProducer {
//
// constructors and destructor
//
HcalRecHitReflagger::HcalRecHitReflagger(const edm::ParameterSet& ps) {
HcalRecHitReflagger::HcalRecHitReflagger(const edm::ParameterSet& ps)
: tokTopo_(esConsumes<HcalTopology, HcalRecNumberingRecord>()),
tokChan_(esConsumes<HcalChannelQuality, HcalChannelQualityRcd>(edm::ESInputTag("", "withTopo"))) {
//register your products
produces<HFRecHitCollection>();

Expand Down Expand Up @@ -158,9 +160,6 @@ HcalRecHitReflagger::~HcalRecHitReflagger() {
//
// member functions
//

void HcalRecHitReflagger::beginRun(const Run& r, const EventSetup& c) {}

// ------------ method called to produce the data ------------
void HcalRecHitReflagger::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
// read HF RecHits
Expand All @@ -171,14 +170,10 @@ void HcalRecHitReflagger::produce(edm::Event& iEvent, const edm::EventSetup& iSe
}

//get the hcal topology
edm::ESHandle<HcalTopology> topo_;
iSetup.get<HcalRecNumberingRecord>().get(topo_);
topo = &*topo_;
topo = &iSetup.getData(tokTopo_);

//get channel quality conditions
edm::ESHandle<HcalChannelQuality> p;
iSetup.get<HcalChannelQualityRcd>().get("withTopo", p);
const HcalChannelQuality& chanquality_(*p.product());
const HcalChannelQuality& chanquality_ = iSetup.getData(tokChan_);

std::vector<DetId> mydetids = chanquality_.getAllChannels();
for (std::vector<DetId>::const_iterator i = mydetids.begin(); i != mydetids.end(); ++i) {
Expand Down
29 changes: 16 additions & 13 deletions RecoLocalCalo/HcalRecAlgos/test/HcalSevLvlAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

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

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

#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
Expand All @@ -37,17 +36,21 @@
// class decleration
//

class HcalSevLvlAnalyzer : public edm::EDAnalyzer {
class HcalSevLvlAnalyzer : public edm::one::EDAnalyzer<> {
public:
explicit HcalSevLvlAnalyzer(const edm::ParameterSet&);
~HcalSevLvlAnalyzer();

private:
virtual void beginJob();
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob();
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
void endJob() override;

// ----------member data ---------------------------
#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
const edm::ESGetToken<SetupData, SetupRecord> totkSet_;
#endif
const edm::ESGetToken<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd> tokSev_;
};

//
Expand All @@ -62,8 +65,11 @@ class HcalSevLvlAnalyzer : public edm::EDAnalyzer {
// constructors and destructor
//
HcalSevLvlAnalyzer::HcalSevLvlAnalyzer(const edm::ParameterSet& iConfig)

{
:
#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
totkSet_(esConsumes()),
#endif
tokSev_(esConsumes()) {
//now do what ever initialization is needed

// initialize the severity level code
Expand All @@ -88,14 +94,11 @@ void HcalSevLvlAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
#endif

#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
ESHandle<SetupData> pSetup;
iSetup.get<SetupRecord>().get(pSetup);
auto pSetup = &iSetup.getData(tokSet_);
#endif

// here's how to access the severity level computer:
ESHandle<HcalSeverityLevelComputer> mycomputer;
iSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
const HcalSeverityLevelComputer* myProd = mycomputer.product();
const HcalSeverityLevelComputer* myProd = &iSetup.getData(tokSev_);

// create some example cases:
std::cout << std::showbase;
Expand Down
8 changes: 4 additions & 4 deletions RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class MahiDebugger : public edm::one::EDAnalyzer<edm::one::SharedResources> {
std::unique_ptr<MahiFit> mahi_;

edm::EDGetTokenT<HBHEChannelInfoCollection> token_ChannelInfo_;
const edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> tokDelay_;

const HcalTimeSlew* hcalTimeSlewDelay;

Expand Down Expand Up @@ -181,7 +182,8 @@ MahiDebugger::MahiDebugger(const edm::ParameterSet& iConfig)
nMaxItersMin_(iConfig.getParameter<int>("nMaxItersMin")),
nMaxItersNNLS_(iConfig.getParameter<int>("nMaxItersNNLS")),
deltaChiSqThresh_(iConfig.getParameter<double>("deltaChiSqThresh")),
nnlsThresh_(iConfig.getParameter<double>("nnlsThresh")) {
nnlsThresh_(iConfig.getParameter<double>("nnlsThresh")),
tokDelay_(esConsumes<HcalTimeSlew, HcalTimeSlewRecord>(edm::ESInputTag("", "HBHE"))) {
usesResource("TFileService");

mahi_ = std::make_unique<MahiFit>();
Expand Down Expand Up @@ -214,9 +216,7 @@ MahiDebugger::~MahiDebugger() {}
void MahiDebugger::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;

edm::ESHandle<HcalTimeSlew> delay;
iSetup.get<HcalTimeSlewRecord>().get("HBHE", delay);
hcalTimeSlewDelay = &*delay;
hcalTimeSlewDelay = &iSetup.getData(tokDelay_);

run = iEvent.id().run();
evt = iEvent.id().event();
Expand Down
Loading