Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 12, 2024
1 parent c978dba commit fe6aad7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion source/framework/core/inc/TRestDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class TRestDataSet : public TRestMetadata {
TTree* GetTree() const {
if (fTree == nullptr && fExternal) {
RESTInfo << "The tree is not accessible. Only GetDataFrame can be used in an externally "
"generated dataset" << RESTendl;
"generated dataset"
<< RESTendl;
RESTInfo << "You may write a tree using GetDataFrame()->Snapshot(\"MyTree\", \"output.root\");"
<< RESTendl;
return fTree;
Expand Down
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() {
fDataFrame = 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);
fDataFrame = DefineColumn(cName, cExpression);
Expand Down Expand Up @@ -429,7 +429,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 @@ -482,7 +483,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 @@ -557,7 +558,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 @@ -618,7 +619,7 @@ ROOT::RDF::RNode TRestDataSet::DefineColumn(const std::string& columnName, const
auto df = fDataFrame;

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 @@ -684,7 +685,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 @@ -696,7 +697,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 @@ -862,10 +863,11 @@ void TRestDataSet::Export(const std::string& filename, std::vector<std::string>

std::vector<std::string> columns = fDataFrame.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 @@ -900,7 +902,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 @@ -935,7 +938,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
2 changes: 1 addition & 1 deletion source/framework/sensitivity/src/TRestComponentDataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ std::vector<Int_t> TRestComponentDataSet::ExtractNodeStatistics() {
nEv = fDataSet.GetDataFrame().Filter(filter).Range(fSamples).Count();
}

if ((Int_t) * nEv < fSamples) {
if ((Int_t)*nEv < fSamples) {
RESTWarning << "The number of requested samples (" << fSamples
<< ") is higher than the number of dataset entries (" << *nEv << ")" << RESTendl;
}
Expand Down

0 comments on commit fe6aad7

Please sign in to comment.