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

Removed lexical_cast boost dependency in CondCore #34932

Merged
merged 5 commits into from Sep 7, 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
Expand Up @@ -22,8 +22,8 @@ int main(int argc, char** argv) {
std::string connectionString("frontier://FrontierProd/CMS_CONDITIONS");

std::string tag = "TrackerAlignment_v21_offline";
cond::Time_t start = boost::lexical_cast<unsigned long long>(294034);
cond::Time_t end = boost::lexical_cast<unsigned long long>(305898);
cond::Time_t start = static_cast<unsigned long long>(294034);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just noticing that would you have implemented something similar as in the other PR of yours, #34976, you would have used here

Suggested change
cond::Time_t start = static_cast<unsigned long long>(294034);
cond::Time_t start = std::stoull(294034);

etc.

What's the reason for the different approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not string. For string conversions I have used stoi/stod/stoull for int to long/ul I used static cast since stoull will give error type not string

cond::Time_t end = static_cast<unsigned long long>(305898);

std::cout << "## Alignment Histos" << std::endl;

Expand Down
Expand Up @@ -27,8 +27,8 @@ int main(int argc, char** argv) {
// BeamSpot

std::string tag = "BeamSpotObjects_PCL_byLumi_v0_prompt";
cond::Time_t start = boost::lexical_cast<unsigned long long>(1406876667347162);
//cond::Time_t end = boost::lexical_cast<unsigned long long>(1406876667347162);
cond::Time_t start = static_cast<unsigned long long>(1406876667347162);
//cond::Time_t end = static_cast<unsigned long long>(1406876667347162);

edm::LogPrint("testBeamSpotPayloadInspector") << "## Exercising BeamSpot plots " << std::endl;

Expand All @@ -37,7 +37,7 @@ int main(int argc, char** argv) {
edm::LogPrint("testBeamSpotPayloadInspector") << histoParameters.data() << std::endl;

tag = "BeamSpotOnlineTestLegacy";
start = boost::lexical_cast<unsigned long long>(1443392479297557);
start = static_cast<unsigned long long>(1443392479297557);

edm::LogPrint("testBeamSpotPayloadInspector") << "## Exercising BeamSpotOnline plots " << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions CondCore/DBOutputService/src/OnlineDBOutputService.cc
Expand Up @@ -69,8 +69,8 @@ namespace cond {
if (!std::getline(sinfo, slumi, ',')) {
throw Exception("Can't get lumi id from OMS Service.");
}
unsigned int run = boost::lexical_cast<unsigned int>(srun);
unsigned int lumi = boost::lexical_cast<unsigned int>(slumi);
unsigned int run = std::stoul(srun);
unsigned int lumi = std::stoul(slumi);
lastLumiProcessed = cond::time::lumiTime(run, lumi);
return lastLumiProcessed;
}
Expand Down
Expand Up @@ -22,8 +22,8 @@ int main(int argc, char** argv) {
std::string connectionString("frontier://FrontierProd/CMS_CONDITIONS");

std::string tag = "AlCaRecoHLTpaths8e29_1e31_v7_hlt";
cond::Time_t start = boost::lexical_cast<unsigned long long>(270000);
cond::Time_t end = boost::lexical_cast<unsigned long long>(304820);
cond::Time_t start = static_cast<unsigned long long>(270000);
cond::Time_t end = static_cast<unsigned long long>(304820);

std::cout << "## AlCaRecoTriggerBit Histos" << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions CondCore/RunInfoPlugins/test/testRunInfoPayloadInspector.cpp
Expand Up @@ -22,8 +22,8 @@ int main(int argc, char** argv) {
std::string connectionString("frontier://FrontierProd/CMS_CONDITIONS");

std::string tag = "runinfo_31X_hlt";
cond::Time_t start = boost::lexical_cast<unsigned long long>(311950);
cond::Time_t end = boost::lexical_cast<unsigned long long>(312237);
cond::Time_t start = static_cast<unsigned long long>(311950);
cond::Time_t end = static_cast<unsigned long long>(312237);

std::cout << "## RunInfo testing" << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions CondCore/SiPixelPlugins/interface/SiPixelGainCalibHelper.h
Expand Up @@ -426,7 +426,7 @@ namespace gainCalibHelper {
auto paramValues = cond::payloadInspector::PlotBase::inputParamValues();
auto ip = paramValues.find("SetLog");
if (ip != paramValues.end()) {
auto answer = boost::lexical_cast<std::string>(ip->second);
auto answer = ip->second;
if (!SiPixelPI::checkAnswerOK(answer, setLog)) {
throw cms::Exception(label_)
<< "\nERROR: " << answer
Expand Down Expand Up @@ -590,7 +590,7 @@ namespace gainCalibHelper {
auto paramValues = cond::payloadInspector::PlotBase::inputParamValues();
auto ip = paramValues.find("SetLog");
if (ip != paramValues.end()) {
auto answer = boost::lexical_cast<std::string>(ip->second);
auto answer = ip->second;
if (!SiPixelPI::checkAnswerOK(answer, setLog)) {
throw cms::Exception(label_)
<< "\nERROR: " << answer
Expand Down
Expand Up @@ -82,7 +82,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("Scenarios");
if (ip != paramValues.end()) {
auto input = boost::lexical_cast<std::string>(ip->second);
auto input = ip->second;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So casting is not needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already of type string

typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
boost::char_separator<char> sep{","};
tokenizer tok{input, sep};
Expand Down
34 changes: 17 additions & 17 deletions CondCore/SiPixelPlugins/test/testSiPixelPayloadInspector.cpp
Expand Up @@ -33,8 +33,8 @@ int main(int argc, char** argv) {
// Lorentz Angle

std::string tag = "SiPixelLorentzAngle_v11_offline";
cond::Time_t start = boost::lexical_cast<unsigned long long>(303790);
cond::Time_t end = boost::lexical_cast<unsigned long long>(324245);
cond::Time_t start = static_cast<unsigned long long>(303790);
cond::Time_t end = static_cast<unsigned long long>(324245);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising Lorentz Angle plots " << std::endl;

Expand Down Expand Up @@ -68,7 +68,7 @@ int main(int argc, char** argv) {
// 2 tags comparisons

std::string tag2 = "SiPixelLorentzAngle_2016_ultralegacymc_v2";
cond::Time_t start2 = boost::lexical_cast<unsigned long long>(1);
cond::Time_t start2 = static_cast<unsigned long long>(1);

SiPixelLorentzAngleValueComparisonTwoTags histo6;
histo6.process(connectionString, PI::mk_input(tag, start, start, tag2, start2, start2));
Expand All @@ -81,8 +81,8 @@ int main(int argc, char** argv) {
// SiPixelQuality

tag = "SiPixelQuality_forDigitizer_phase1_2018_permanentlyBad";
start = boost::lexical_cast<unsigned long long>(1);
end = boost::lexical_cast<unsigned long long>(1);
start = static_cast<unsigned long long>(1);
end = static_cast<unsigned long long>(1);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising SiPixelQuality plots " << std::endl;

Expand All @@ -97,8 +97,8 @@ int main(int argc, char** argv) {
// SiPixelGainCalibrationOffline

tag = "SiPixelGainCalibration_2009runs_express";
start = boost::lexical_cast<unsigned long long>(312203);
end = boost::lexical_cast<unsigned long long>(312203);
start = static_cast<unsigned long long>(312203);
end = static_cast<unsigned long long>(312203);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising SiPixelGainCalibrationOffline plots " << std::endl;

Expand All @@ -118,7 +118,7 @@ int main(int argc, char** argv) {
histo13.process(connectionString, PI::mk_input(tag, start, end));
edm::LogPrint("testSiPixelPayloadInspector") << histo13.data() << std::endl;

end = boost::lexical_cast<unsigned long long>(326851);
end = static_cast<unsigned long long>(326851);

SiPixelGainCalibOfflinePedestalComparisonSingleTag histo14;
histo14.process(connectionString, PI::mk_input(tag, start, end));
Expand All @@ -143,8 +143,8 @@ int main(int argc, char** argv) {
// SiPixelTemplates

tag = "SiPixelTemplateDBObject38Tv3_express";
start = boost::lexical_cast<unsigned long long>(326083);
end = boost::lexical_cast<unsigned long long>(326083);
start = static_cast<unsigned long long>(326083);
end = static_cast<unsigned long long>(326083);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising SiPixelTemplates plots " << std::endl;

Expand Down Expand Up @@ -177,8 +177,8 @@ int main(int argc, char** argv) {
// SiPixelGenErrors

tag = "SiPixelGenErrorDBObject_phase1_BoR3_HV350_Tr2000";
start = boost::lexical_cast<unsigned long long>(1);
end = boost::lexical_cast<unsigned long long>(1);
start = static_cast<unsigned long long>(1);
end = static_cast<unsigned long long>(1);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising SiPixelGenErrors plots " << std::endl;

Expand All @@ -193,8 +193,8 @@ int main(int argc, char** argv) {
// SiPixelQualityProbabilities

tag = "SiPixelQualityProbabilities_UltraLegacy2018_v0_mc";
start = boost::lexical_cast<unsigned long long>(1);
end = boost::lexical_cast<unsigned long long>(1);
start = static_cast<unsigned long long>(1);
end = static_cast<unsigned long long>(1);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising SiPixelQualityProbabilities plots " << std::endl;

Expand All @@ -205,8 +205,8 @@ int main(int argc, char** argv) {
// SiPixelDynamicInefficiency

tag = "SiPixelDynamicInefficiency_PhaseI_v9";
start = boost::lexical_cast<unsigned long long>(1);
end = boost::lexical_cast<unsigned long long>(1);
start = static_cast<unsigned long long>(1);
end = static_cast<unsigned long long>(1);

edm::LogPrint("testSiPixelPayloadInspector") << "## Exercising SiPixeDynamicInefficiency plots " << std::endl;

Expand All @@ -215,7 +215,7 @@ int main(int argc, char** argv) {
edm::LogPrint("testSiPixelPayloadInspector") << histo26.data() << std::endl;

tag2 = "SiPixelDynamicInefficiency_PhaseI_v6";
start2 = boost::lexical_cast<unsigned long long>(1);
start2 = static_cast<unsigned long long>(1);

SiPixelFullIneffROCsMapCompareTwoTags histo27;
histo27.process(connectionString, PI::mk_input(tag, start, start, tag2, start2, start2));
Expand Down
Expand Up @@ -566,7 +566,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("nsigma");
if (ip != paramValues.end()) {
nsigma = boost::lexical_cast<unsigned int>(ip->second);
nsigma = std::stoul(ip->second);
}

// trick to deal with the multi-ioved tag and two tag case at the same time
Expand Down Expand Up @@ -674,7 +674,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("nsigma");
if (ip != paramValues.end()) {
nsigma = boost::lexical_cast<unsigned int>(ip->second);
nsigma = std::stoul(ip->second);
edm::LogPrint("SiStripApvGain_PayloadInspector")
<< "using custom z-axis saturation: " << nsigma << " sigmas" << std::endl;
} else {
Expand Down
Expand Up @@ -117,7 +117,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("DetIds");
if (ip != paramValues.end()) {
auto input = boost::lexical_cast<std::string>(ip->second);
auto input = ip->second;
typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
boost::char_separator<char> sep{","};
tokenizer tok{input, sep};
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("DetId");
if (ip != paramValues.end()) {
the_detid = boost::lexical_cast<unsigned int>(ip->second);
the_detid = std::stoul(ip->second);
}

if (payload.get()) {
Expand Down Expand Up @@ -962,7 +962,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("nsigma");
if (ip != paramValues.end()) {
nsigma = boost::lexical_cast<unsigned int>(ip->second);
nsigma = std::stoul(ip->second);
}

// trick to deal with the multi-ioved tag and two tag case at the same time
Expand Down
Expand Up @@ -116,7 +116,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("DetIds");
if (ip != paramValues.end()) {
auto input = boost::lexical_cast<std::string>(ip->second);
auto input = ip->second;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So casting is not needed here? (same as in SiPixelFEDChannelContainer_PayloadInspector.cc)

typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
boost::char_separator<char> sep{","};
tokenizer tok{input, sep};
Expand Down Expand Up @@ -315,7 +315,7 @@ namespace {
auto paramValues = PlotBase::inputParamValues();
auto ip = paramValues.find("DetId");
if (ip != paramValues.end()) {
the_detid = boost::lexical_cast<unsigned int>(ip->second);
the_detid = std::stoul(ip->second);
}

if (payload.get()) {
Expand Down
25 changes: 13 additions & 12 deletions CondCore/SiStripPlugins/test/testSiStripPayloadInspector.cpp
Expand Up @@ -31,8 +31,9 @@ int main(int argc, char** argv) {
// Gains

std::string tag = "SiStripApvGain_FromParticles_GR10_v11_offline";
cond::Time_t start = boost::lexical_cast<unsigned long long>(132440);
cond::Time_t end = boost::lexical_cast<unsigned long long>(285368);

cond::Time_t start = static_cast<unsigned long long>(132440);
cond::Time_t end = static_cast<unsigned long long>(285368);
py::dict inputs;

edm::LogPrint("testSiStripPayloadInspector") << "## Exercising Gains plots " << std::endl;
Expand Down Expand Up @@ -72,8 +73,8 @@ int main(int argc, char** argv) {
// Noise

tag = "SiStripNoise_GR10_v1_hlt";
start = boost::lexical_cast<unsigned long long>(312968);
end = boost::lexical_cast<unsigned long long>(313120);
start = static_cast<unsigned long long>(312968);
end = static_cast<unsigned long long>(313120);

edm::LogPrint("testSiStripPayloadInspector") << "## Exercising Noise plots " << std::endl;

Expand All @@ -98,8 +99,8 @@ int main(int argc, char** argv) {
// Pedestals

tag = "SiStripPedestals_v2_prompt";
start = boost::lexical_cast<unsigned long long>(303420);
end = boost::lexical_cast<unsigned long long>(313120);
start = static_cast<unsigned long long>(303420);
end = static_cast<unsigned long long>(313120);

edm::LogPrint("testSiStripPayloadInspector") << "## Exercising Pedestal plots " << std::endl;

Expand All @@ -121,8 +122,8 @@ int main(int argc, char** argv) {
//Latency

tag = "SiStripLatency_v2_prompt";
start = boost::lexical_cast<unsigned long long>(315347);
end = boost::lexical_cast<unsigned long long>(316675);
start = static_cast<unsigned long long>(315347);
end = static_cast<unsigned long long>(316675);

edm::LogPrint("testSiStripPayloadInspector") << "## Exercising Latency plots " << std::endl;

Expand All @@ -136,8 +137,8 @@ int main(int argc, char** argv) {

//Threshold
tag = "SiStripThreshold_v1_prompt";
start = boost::lexical_cast<unsigned long long>(315352);
end = boost::lexical_cast<unsigned long long>(315460);
start = static_cast<unsigned long long>(315352);
end = static_cast<unsigned long long>(315460);

edm::LogPrint("testSiStripPayloadInspector") << "## Exercising Threshold plots " << std::endl;

Expand All @@ -147,8 +148,8 @@ int main(int argc, char** argv) {

// test SiStripTkMaps
tag = "SiStripBadComponents_startupMC_for2017_v1_mc";
start = boost::lexical_cast<unsigned long long>(1);
end = boost::lexical_cast<unsigned long long>(1);
start = static_cast<unsigned long long>(1);
end = static_cast<unsigned long long>(1);

edm::LogPrint("testSiStripPayloadInspector") << "## Exercising SiStripTkMaps plots " << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion CondCore/Utilities/bin/conddb_test_read.cpp
Expand Up @@ -53,7 +53,7 @@ int cond::TestReadUtilities::execute() {
std::string siovs = getOptionValue<std::string>("iovs");
tokenizer tok(siovs);
for (auto &t : tok) {
iovs.push_back(boost::lexical_cast<unsigned long long>(t));
iovs.push_back(std::stoull(t));
}
}

Expand Down
4 changes: 1 addition & 3 deletions CondCore/Utilities/src/CondDBFetch.cc
Expand Up @@ -344,9 +344,7 @@ namespace cond {
std::string payloadTypeName;
bool found = session.fetchPayloadData(payloadId, payloadTypeName, data, streamerInfo);
if (!found)
throwException(
"Payload with id " + boost::lexical_cast<std::string>(payloadId) + " has not been found in the database.",
"fetch");
throwException("Payload with id " + payloadId + " has not been found in the database.", "fetch");
return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr);
}

Expand Down
2 changes: 1 addition & 1 deletion CondCore/Utilities/test/testPngHistograms.cpp
Expand Up @@ -23,7 +23,7 @@ int main(int argc, char** argv) {
std::string connectionString("frontier://FrontierProd/CMS_CONDITIONS");

std::string tag = std::string("BasicPayload_v10.0");
cond::Time_t since = boost::lexical_cast<unsigned long long>("901");
cond::Time_t since = std::stoull("901");

std::cout << "## PNG Histo" << std::endl;

Expand Down