Skip to content

Commit

Permalink
Merge pull request #36490 from ggovi/condcore-dboutputservice-final-c…
Browse files Browse the repository at this point in the history
…leanup-2-123X

DBOutputService: Removed deprecated methods
  • Loading branch information
cmsbuild committed Dec 17, 2021
2 parents 4fb0a88 + 0f24a5d commit 185ca7c
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 117 deletions.
6 changes: 3 additions & 3 deletions CalibMuon/DTCalibration/interface/DTCalibDBUtils.h
Expand Up @@ -25,17 +25,17 @@ class DTCalibDBUtils {
/// Write the payload to the DB using PoolDBOutputService.
/// New payload are created in the DB, existing payload are appended.
template <typename T>
static void writeToDB(std::string record, T* payload) {
static void writeToDB(std::string record, const T& payload) {
// Write the ttrig object to DB
edm::Service<cond::service::PoolDBOutputService> dbOutputSvc;
if (dbOutputSvc.isAvailable()) {
try {
if (dbOutputSvc->isNewTagRequest(record)) {
//create mode
dbOutputSvc->writeOne<T>(payload, dbOutputSvc->beginOfTime(), record);
dbOutputSvc->writeOneIOV<T>(payload, dbOutputSvc->beginOfTime(), record);
} else {
//append mode. Note: correct PoolDBESSource must be loaded
dbOutputSvc->writeOne<T>(payload, dbOutputSvc->currentTime(), record);
dbOutputSvc->writeOneIOV<T>(payload, dbOutputSvc->currentTime(), record);
}
} catch (const cond::Exception& er) {
std::cout << er.what() << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions CalibMuon/DTCalibration/plugins/DTNoiseCalibration.cc
Expand Up @@ -356,7 +356,7 @@ void DTNoiseCalibration::endJob() {
}

// Save on file the occupancy histos and write the list of noisy cells
DTStatusFlag* statusMap = new DTStatusFlag();
DTStatusFlag statusMap;
for (map<DTLayerId, TH1F*>::const_iterator lHisto = theHistoOccupancyMap_.begin();
lHisto != theHistoOccupancyMap_.end();
++lHisto) {
Expand Down Expand Up @@ -405,7 +405,7 @@ void DTNoiseCalibration::endJob() {
double rateOffset = (useAbsoluteRate_) ? 0. : averageRate;
if ((channelRate - rateOffset) > maximumNoiseRate_) {
DTWireId wireID((*lHisto).first, i_wire);
statusMap->setCellNoise(wireID, true);
statusMap.setCellNoise(wireID, true);
LogVerbatim("Calibration") << ">>> Channel noisy: " << wireID;
}
}
Expand Down
6 changes: 3 additions & 3 deletions CalibMuon/DTCalibration/plugins/DTT0Correction.cc
Expand Up @@ -55,7 +55,7 @@ void DTT0Correction::beginRun(const edm::Run& run, const edm::EventSetup& setup)

void DTT0Correction::endJob() {
// Create the object to be written to DB
DTT0* t0NewMap = new DTT0();
DTT0 t0NewMap;

// Loop over all channels
for (vector<const DTSuperLayer*>::const_iterator sl = muonGeom_->superLayers().begin();
Expand All @@ -82,15 +82,15 @@ void DTT0Correction::endJob() {
dtCalibration::DTT0Data t0Corr = correctionAlgo_->correction(wireId);
float t0MeanNew = t0Corr.mean;
float t0RMSNew = t0Corr.rms;
t0NewMap->set(wireId, t0MeanNew, t0RMSNew, DTTimeUnits::counts);
t0NewMap.set(wireId, t0MeanNew, t0RMSNew, DTTimeUnits::counts);

LogVerbatim("Calibration") << "New t0 for: " << wireId << " mean from " << t0Mean << " to " << t0MeanNew
<< " rms from " << t0RMS << " to " << t0RMSNew << endl;
} catch (cms::Exception& e) {
LogError("Calibration") << e.explainSelf();
// Set db to the old value, if it was there in the first place
if (!status) {
t0NewMap->set(wireId, t0Mean, t0RMS, DTTimeUnits::counts);
t0NewMap.set(wireId, t0Mean, t0RMS, DTTimeUnits::counts);
LogVerbatim("Calibration") << "Keep old t0 for: " << wireId << " mean " << t0Mean << " rms " << t0RMS
<< endl;
}
Expand Down
6 changes: 3 additions & 3 deletions CalibMuon/DTCalibration/plugins/DTTTrigCorrection.cc
Expand Up @@ -62,7 +62,7 @@ void DTTTrigCorrection::beginRun(const edm::Run& run, const edm::EventSetup& set

void DTTTrigCorrection::endJob() {
// Create the object to be written to DB
DTTtrig* tTrigNewMap = new DTTtrig();
DTTtrig tTrigNewMap;

for (vector<const DTSuperLayer*>::const_iterator sl = muonGeom_->superLayers().begin();
sl != muonGeom_->superLayers().end();
Expand All @@ -77,7 +77,7 @@ void DTTTrigCorrection::endJob() {
float tTrigMeanNew = tTrigCorr.mean;
float tTrigSigmaNew = tTrigCorr.sigma;
float kFactorNew = tTrigCorr.kFactor;
tTrigNewMap->set((*sl)->id(), tTrigMeanNew, tTrigSigmaNew, kFactorNew, DTTimeUnits::ns);
tTrigNewMap.set((*sl)->id(), tTrigMeanNew, tTrigSigmaNew, kFactorNew, DTTimeUnits::ns);

LogVerbatim("Calibration") << "New tTrig for: " << (*sl)->id() << " mean from " << tTrigMean << " to "
<< tTrigMeanNew << " sigma from " << tTrigSigma << " to " << tTrigSigmaNew
Expand All @@ -86,7 +86,7 @@ void DTTTrigCorrection::endJob() {
LogError("Calibration") << e.explainSelf();
// Set db to the old value, if it was there in the first place
if (!status) {
tTrigNewMap->set((*sl)->id(), tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
tTrigNewMap.set((*sl)->id(), tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
LogVerbatim("Calibration") << "Keep old tTrig for: " << (*sl)->id() << " mean " << tTrigMean << " sigma "
<< tTrigSigma << " kFactor " << kFactor << endl;
}
Expand Down
4 changes: 2 additions & 2 deletions CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.cc
Expand Up @@ -47,7 +47,7 @@ void DTTTrigCorrectionFirst::beginRun(const edm::Run& run, const edm::EventSetup

void DTTTrigCorrectionFirst::endJob() {
// Create the object to be written to DB
DTTtrig* tTrigNewMap = new DTTtrig();
DTTtrig tTrigNewMap;
//Get the superlayers list
vector<const DTSuperLayer*> dtSupLylist = muonGeom->superLayers();

Expand Down Expand Up @@ -225,7 +225,7 @@ void DTTTrigCorrectionFirst::endJob() {
}

//Store new ttrig in the new map
tTrigNewMap->set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor, DTTimeUnits::ns);
tTrigNewMap.set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor, DTTimeUnits::ns);
if (debug) {
cout << "New tTrig: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
cout << "New tTrigSigma: " << (*sl)->id() << " from " << ttrigSigma << " to " << newTTrigSigma << endl;
Expand Down
12 changes: 6 additions & 6 deletions CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc
Expand Up @@ -280,12 +280,12 @@ void DTVDriftCalibration::endJob() {
// Instantiate a DTCalibrationMap object if you want to calculate the calibration constants
DTCalibrationMap calibValuesFile(theCalibFilePar);
// Create the object to be written to DB
DTMtime* mTime = nullptr;
DTRecoConditions* vDrift = nullptr;
std::unique_ptr<DTMtime> mTime;
std::unique_ptr<DTRecoConditions> vDrift;
if (writeLegacyVDriftDB) {
mTime = new DTMtime();
mTime = std::make_unique<DTMtime>();
} else {
vDrift = new DTRecoConditions();
vDrift = std::make_unique<DTRecoConditions>();
vDrift->setFormulaExpr("[0]");
//vDriftNewMap->setFormulaExpr("[0]*(1-[1]*x)"); // add parametrization for dependency along Y
vDrift->setVersion(1);
Expand Down Expand Up @@ -381,9 +381,9 @@ void DTVDriftCalibration::endJob() {
// Write the vdrift object to DB
if (writeLegacyVDriftDB) {
string record = "DTMtimeRcd";
DTCalibDBUtils::writeToDB<DTMtime>(record, mTime);
DTCalibDBUtils::writeToDB<DTMtime>(record, *mTime);
} else {
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", vDrift);
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", *vDrift);
}
}

Expand Down
12 changes: 6 additions & 6 deletions CalibMuon/DTCalibration/plugins/DTVDriftWriter.cc
Expand Up @@ -76,12 +76,12 @@ void DTVDriftWriter::beginRun(const edm::Run& run, const edm::EventSetup& setup)

void DTVDriftWriter::endJob() {
// Create the object to be written to DB
DTMtime* mTimeNewMap = nullptr;
DTRecoConditions* vDriftNewMap = nullptr;
std::unique_ptr<DTMtime> mTimeNewMap;
std::unique_ptr<DTRecoConditions> vDriftNewMap;
if (writeLegacyVDriftDB) {
mTimeNewMap = new DTMtime();
mTimeNewMap = std::make_unique<DTMtime>();
} else {
vDriftNewMap = new DTRecoConditions();
vDriftNewMap = std::make_unique<DTRecoConditions>();
vDriftNewMap->setFormulaExpr("[0]");
//vDriftNewMap->setFormulaExpr("[0]*(1-[1]*x)"); // add parametrization for dependency along Y
vDriftNewMap->setVersion(1);
Expand Down Expand Up @@ -137,8 +137,8 @@ void DTVDriftWriter::endJob() {
LogVerbatim("Calibration") << "[DTVDriftWriter]Writing vdrift object to DB!";
if (writeLegacyVDriftDB) {
string record = "DTMtimeRcd";
DTCalibDBUtils::writeToDB<DTMtime>(record, mTimeNewMap);
DTCalibDBUtils::writeToDB<DTMtime>(record, *mTimeNewMap);
} else {
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", vDriftNewMap);
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", *vDriftNewMap);
}
}
94 changes: 47 additions & 47 deletions CalibMuon/DTCalibration/test/DBTools/DumpFileToDB.cc
Expand Up @@ -72,26 +72,26 @@ void DumpFileToDB::endJob() {
//---------- VDrift
if (dbToDump == "VDriftDB") {
if (format == "Legacy") {
DTMtime* mtime = new DTMtime();
DTMtime mtime;
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
// cout << "key: " << (*keyAndCalibs).first
// << " vdrift (cm/ns): " << theCalibFile->meanVDrift((*keyAndCalibs).first)
// << " hit reso (cm): " << theCalibFile->sigma_meanVDrift((*keyAndCalibs).first) << endl;
// vdrift is cm/ns , resolution is cm
mtime->set((*keyAndCalibs).first.superlayerId(),
theCalibFile->meanVDrift((*keyAndCalibs).first),
theCalibFile->sigma_meanVDrift((*keyAndCalibs).first),
DTVelocityUnits::cm_per_ns);
mtime.set((*keyAndCalibs).first.superlayerId(),
theCalibFile->meanVDrift((*keyAndCalibs).first),
theCalibFile->sigma_meanVDrift((*keyAndCalibs).first),
DTVelocityUnits::cm_per_ns);
}
DTCalibDBUtils::writeToDB<DTMtime>("DTMtimeRcd", mtime);
} else if (format == "DTRecoConditions") {
DTRecoConditions* conds = new DTRecoConditions();
conds->setFormulaExpr("[0]");
// conds->setFormulaExpr("[0]*(1-[1]*x)");
DTRecoConditions conds;
conds.setFormulaExpr("[0]");
// conds.setFormulaExpr("[0]*(1-[1]*x)");
int version = 1;
conds->setVersion(version);
conds.setVersion(version);
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
Expand All @@ -107,15 +107,15 @@ void DumpFileToDB::endJob() {
throw cms::Exception("IncorrectSetup") << "Inconsistent version of file";

vector<double> params(values.begin() + 11, values.begin() + 11 + nfields);
conds->set((*keyAndCalibs).first, params);
conds.set((*keyAndCalibs).first, params);
}
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", conds);
}

//---------- TTrig
} else if (dbToDump == "TTrigDB") {
if (format == "Legacy") {
DTTtrig* tTrig = new DTTtrig();
DTTtrig tTrig;
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
Expand All @@ -131,11 +131,11 @@ void DumpFileToDB::endJob() {
<< "The differentialMode can only be used with kFactor = 0, old: " << kFactor
<< " new: " << theCalibFile->kFactor((*keyAndCalibs).first);
}
tTrig->set((*keyAndCalibs).first.superlayerId(),
theCalibFile->tTrig((*keyAndCalibs).first) + tmean,
theCalibFile->sigma_tTrig((*keyAndCalibs).first),
theCalibFile->kFactor((*keyAndCalibs).first),
DTTimeUnits::ns);
tTrig.set((*keyAndCalibs).first.superlayerId(),
theCalibFile->tTrig((*keyAndCalibs).first) + tmean,
theCalibFile->sigma_tTrig((*keyAndCalibs).first),
theCalibFile->kFactor((*keyAndCalibs).first),
DTTimeUnits::ns);
// cout << "key: " << (*keyAndCalibs).first
// << " ttrig_mean (ns): " << theCalibFile->tTrig((*keyAndCalibs).first) + tmean
// << " ttrig_sigma(ns): " << theCalibFile->sigma_tTrig((*keyAndCalibs).first)
Expand All @@ -146,20 +146,20 @@ void DumpFileToDB::endJob() {
// << " ttrig_mean (ns): " << theCalibFile->tTrig((*keyAndCalibs).first)
// << " ttrig_sigma(ns): " << theCalibFile->sigma_tTrig((*keyAndCalibs).first)
// << " kFactor: " << theCalibFile->kFactor((*keyAndCalibs).first) << endl;
tTrig->set((*keyAndCalibs).first.superlayerId(),
theCalibFile->tTrig((*keyAndCalibs).first),
theCalibFile->sigma_tTrig((*keyAndCalibs).first),
theCalibFile->kFactor((*keyAndCalibs).first),
DTTimeUnits::ns);
tTrig.set((*keyAndCalibs).first.superlayerId(),
theCalibFile->tTrig((*keyAndCalibs).first),
theCalibFile->sigma_tTrig((*keyAndCalibs).first),
theCalibFile->kFactor((*keyAndCalibs).first),
DTTimeUnits::ns);
}
}
DTCalibDBUtils::writeToDB<DTTtrig>("DTTtrigRcd", tTrig);

} else if (format == "DTRecoConditions") {
DTRecoConditions* conds = new DTRecoConditions();
conds->setFormulaExpr("[0]");
DTRecoConditions conds;
conds.setFormulaExpr("[0]");
int version = 1;
conds->setVersion(version);
conds.setVersion(version);

for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
Expand All @@ -177,15 +177,15 @@ void DumpFileToDB::endJob() {
throw cms::Exception("IncorrectSetup") << "Inconsistent version of file";

vector<double> params(values.begin() + 11, values.begin() + 11 + nfields);
conds->set((*keyAndCalibs).first, params);
conds.set((*keyAndCalibs).first, params);
}
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsTtrigRcd", conds);
}

} else if (dbToDump == "TZeroDB") { // Write the T0

// Create the object to be written to DB
DTT0* tZeroMap = new DTT0();
DTT0 tZeroMap;

// Loop over file entries
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
Expand All @@ -195,40 +195,40 @@ void DumpFileToDB::endJob() {
float t0rms = (*keyAndCalibs).second[6];
cout << "key: " << (*keyAndCalibs).first << " T0 mean (TDC counts): " << t0mean
<< " T0_rms (TDC counts): " << t0rms << endl;
tZeroMap->set((*keyAndCalibs).first, t0mean, t0rms, DTTimeUnits::counts);
tZeroMap.set((*keyAndCalibs).first, t0mean, t0rms, DTTimeUnits::counts);
}

DTCalibDBUtils::writeToDB<DTT0>("DTT0Rcd", tZeroMap);

} else if (dbToDump == "NoiseDB") { // Write the Noise
DTStatusFlag* statusMap = new DTStatusFlag();
DTStatusFlag statusMap;

// Loop over file entries
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
cout << "key: " << (*keyAndCalibs).first << " Noisy flag: " << (*keyAndCalibs).second[7] << endl;
statusMap->setCellNoise((*keyAndCalibs).first, (*keyAndCalibs).second[7]);
statusMap.setCellNoise((*keyAndCalibs).first, (*keyAndCalibs).second[7]);
}

DTCalibDBUtils::writeToDB<DTStatusFlag>("DTStatusFlagRcd", statusMap);

} else if (dbToDump == "DeadDB") { // Write the tp-dead
DTDeadFlag* deadMap = new DTDeadFlag();
DTDeadFlag deadMap;

// Loop over file entries
for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
++keyAndCalibs) {
cout << "key: " << (*keyAndCalibs).first << " dead flag: " << (*keyAndCalibs).second[7] << endl;
deadMap->setCellDead_TP((*keyAndCalibs).first, (*keyAndCalibs).second[7]);
deadMap.setCellDead_TP((*keyAndCalibs).first, (*keyAndCalibs).second[7]);
}

DTCalibDBUtils::writeToDB<DTDeadFlag>("DTDeadFlagRcd", deadMap);

} else if (dbToDump == "ChannelsDB") { //Write channels map

DTReadOutMapping* ro_map = new DTReadOutMapping("cmssw_ROB", "cmssw_ROS");
DTReadOutMapping ro_map("cmssw_ROB", "cmssw_ROS");
//Loop over file entries
string line;
ifstream file(mapFileName.c_str());
Expand All @@ -238,17 +238,17 @@ void DumpFileToDB::endJob() {
stringstream linestr;
linestr << line;
vector<int> channelMap = readChannelsMap(linestr);
int status = ro_map->insertReadOutGeometryLink(channelMap[0],
channelMap[1],
channelMap[2],
channelMap[3],
channelMap[4],
channelMap[5],
channelMap[6],
channelMap[7],
channelMap[8],
channelMap[9],
channelMap[10]);
int status = ro_map.insertReadOutGeometryLink(channelMap[0],
channelMap[1],
channelMap[2],
channelMap[3],
channelMap[4],
channelMap[5],
channelMap[6],
channelMap[7],
channelMap[8],
channelMap[9],
channelMap[10]);
cout << "ddu " << channelMap[0] << " "
<< "ros " << channelMap[1] << " "
<< "rob " << channelMap[2] << " "
Expand All @@ -268,10 +268,10 @@ void DumpFileToDB::endJob() {
//---------- Uncertainties
} else if (dbToDump == "RecoUncertDB") { // Write the Uncertainties

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

for (DTCalibrationMap::const_iterator keyAndCalibs = theCalibFile->keyAndConsts_begin();
keyAndCalibs != theCalibFile->keyAndConsts_end();
Expand All @@ -288,7 +288,7 @@ void DumpFileToDB::endJob() {
throw cms::Exception("IncorrectSetup") << "Inconsistent version of file";

vector<double> params(values.begin() + 11, values.begin() + 11 + nfields);
conds->set((*keyAndCalibs).first, params);
conds.set((*keyAndCalibs).first, params);
DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsUncertRcd", conds);
}
}
Expand Down

0 comments on commit 185ca7c

Please sign in to comment.