Skip to content

Commit

Permalink
Merge branch 'jgalan_sensitivity' of github.com:rest-for-physics/fram…
Browse files Browse the repository at this point in the history
…ework into jgalan_sensitivity
  • Loading branch information
jgalan committed Feb 20, 2024
2 parents bd94cf7 + 2604713 commit c794fce
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions source/framework/core/src/TRestDataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void TRestDataSet::GenerateDataSet() {
fDataSet = MakeCut(fCut);

// Adding new user columns added to the dataset
for (const auto & [ cName, cExpression ] : fColumnNameExpressions) {
for (const auto& [cName, cExpression] : fColumnNameExpressions) {
RESTInfo << "Adding column to dataset: " << cName << RESTendl;
finalList.emplace_back(cName);
fDataSet = DefineColumn(cName, cExpression);
Expand Down Expand Up @@ -419,7 +419,8 @@ std::vector<std::string> TRestDataSet::FileSelection() {

if (!time_stamp_end || !time_stamp_start) {
RESTError << "TRestDataSet::FileSelect. Start or end dates not properly formed. Please, check "
"REST_StringHelper::StringToTimeStamp documentation for valid formats" << RESTendl;
"REST_StringHelper::StringToTimeStamp documentation for valid formats"
<< RESTendl;
return fFileSelection;
}

Expand Down Expand Up @@ -472,7 +473,7 @@ std::vector<std::string> TRestDataSet::FileSelection() {
if (!accept) continue;

Double_t acc = 0;
for (auto & [ name, properties ] : fQuantity) {
for (auto& [name, properties] : fQuantity) {
std::string value = run.ReplaceMetadataMembers(properties.metadata);
const Double_t val = REST_StringHelper::StringToDouble(value);

Expand Down Expand Up @@ -529,7 +530,7 @@ ROOT::RDF::RNode TRestDataSet::MakeCut(const TRestCut* cut) {

auto paramCut = cut->GetParamCut();
auto obsList = df.GetColumnNames();
for (const auto & [ param, condition ] : paramCut) {
for (const auto& [param, condition] : paramCut) {
if (std::find(obsList.begin(), obsList.end(), param) != obsList.end()) {
std::string pCut = param + condition;
RESTDebug << "Applying cut " << pCut << RESTendl;
Expand Down Expand Up @@ -576,7 +577,7 @@ ROOT::RDF::RNode TRestDataSet::DefineColumn(const std::string& columnName, const
auto df = fDataSet;

std::string evalFormula = formula;
for (auto const & [ name, properties ] : fQuantity)
for (auto const& [name, properties] : fQuantity)
evalFormula = REST_StringHelper::Replace(evalFormula, name, properties.value);

df = df.Define(columnName, evalFormula);
Expand Down Expand Up @@ -642,7 +643,7 @@ void TRestDataSet::PrintMetadata() {
RESTMetadata << " Relevant quantities: " << RESTendl;
RESTMetadata << " -------------------- " << RESTendl;

for (auto const & [ name, properties ] : fQuantity) {
for (auto const& [name, properties] : fQuantity) {
RESTMetadata << " - Name : " << name << ". Value : " << properties.value
<< ". Strategy: " << properties.strategy << RESTendl;
RESTMetadata << " - Metadata: " << properties.metadata << RESTendl;
Expand All @@ -654,7 +655,7 @@ void TRestDataSet::PrintMetadata() {
if (!fColumnNameExpressions.empty()) {
RESTMetadata << " New columns added to generated dataframe: " << RESTendl;
RESTMetadata << " ---------------------------------------- " << RESTendl;
for (const auto & [ cName, cExpression ] : fColumnNameExpressions) {
for (const auto& [cName, cExpression] : fColumnNameExpressions) {
RESTMetadata << " - Name : " << cName << RESTendl;
RESTMetadata << " - Expression: " << cExpression << RESTendl;
RESTMetadata << " " << RESTendl;
Expand Down Expand Up @@ -820,10 +821,11 @@ void TRestDataSet::Export(const std::string& filename, std::vector<std::string>

std::vector<std::string> columns = fDataSet.GetColumnNames();
if (!excludeColumns.empty()) {
columns.erase(std::remove_if(columns.begin(), columns.end(), [&excludeColumns](std::string elem) {
return std::find(excludeColumns.begin(), excludeColumns.end(), elem) !=
excludeColumns.end();
}),
columns.erase(std::remove_if(columns.begin(), columns.end(),
[&excludeColumns](std::string elem) {
return std::find(excludeColumns.begin(), excludeColumns.end(),
elem) != excludeColumns.end();
}),
columns.end());

RESTInfo << "Re-Generating snapshot." << RESTendl;
Expand Down Expand Up @@ -858,7 +860,8 @@ void TRestDataSet::Export(const std::string& filename, std::vector<std::string>
if (type != "Double_t" && type != "Int_t") {
RESTError << "Branch name : " << bName << " is type : " << type << RESTendl;
RESTError << "Only Int_t and Double_t types are allowed for "
"exporting to ASCII table" << RESTendl;
"exporting to ASCII table"
<< RESTendl;
RESTError << "File will not be generated" << RESTendl;
return;
}
Expand Down Expand Up @@ -893,7 +896,7 @@ void TRestDataSet::Export(const std::string& filename, std::vector<std::string>
}
fprintf(f, "###\n");
fprintf(f, "### Relevant quantities: \n");
for (auto & [ name, properties ] : fQuantity) {
for (auto& [name, properties] : fQuantity) {
fprintf(f, "### - %s : %s - %s\n", name.c_str(), properties.value.c_str(),
properties.description.c_str());
}
Expand Down

0 comments on commit c794fce

Please sign in to comment.