From 6f1c3568253d30516baae889be9540774732fd84 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 22 Nov 2023 09:33:18 +0100 Subject: [PATCH 1/6] TRestSystemOfUnits. Adding more informative warning --- source/framework/core/src/TRestSystemOfUnits.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/framework/core/src/TRestSystemOfUnits.cxx b/source/framework/core/src/TRestSystemOfUnits.cxx index a0fbc3e6a..ef01c59fc 100644 --- a/source/framework/core/src/TRestSystemOfUnits.cxx +++ b/source/framework/core/src/TRestSystemOfUnits.cxx @@ -310,8 +310,16 @@ TRestSystemOfUnits::TRestSystemOfUnits(string unitsStr) { } else { if (pos == unitsStr.size() - 1) { - RESTWarning << "last character inside \"" << unitsStr << "\" \"" << unitsStr[pos] + RESTWarning << "Last character inside \"" << unitsStr << "\" \"" << unitsStr[pos] << "\" unrecognized in unit definition!" << RESTendl; + + std::string lastChar = unitsStr.substr(pos, 1); + + if (isANumber(lastChar)) { + std::string tmpStr = unitsStr; + tmpStr.insert(pos, "^"); + RESTWarning << "Perhaps you meant: " << tmpStr << RESTendl; + } } pos++; From 85892b7f733add640c2c3a727b886aee472e2a49 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 22 Nov 2023 09:37:52 +0100 Subject: [PATCH 2/6] REST_GenerateDataSets is now accepting an output path --- macros/REST_GenerateDataSets.C | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/macros/REST_GenerateDataSets.C b/macros/REST_GenerateDataSets.C index d6c3f02bc..05ad63816 100644 --- a/macros/REST_GenerateDataSets.C +++ b/macros/REST_GenerateDataSets.C @@ -15,14 +15,16 @@ //*** //******************************************************************************************************* -Int_t REST_GenerateDataSets(const std::string& inputRML, const std::string& datasets) { +Int_t REST_GenerateDataSets(const std::string& inputRML, const std::string& datasets, + const std::string& outPath = "") { std::vector sets = REST_StringHelper::Split(datasets, ","); for (const auto& set : sets) { std::cout << "Set : " << set << std::endl; TRestDataSet d(inputRML.c_str(), set.c_str()); d.GenerateDataSet(); - d.Export("Dataset_" + set + ".root"); + if (!outPath.empty() && outPath.back() != '/') outPath += '/'; + d.Export(outPath + "Dataset_" + set + ".root"); } return 0; } From d776632d7e75d46d93e686b23d8cf8d8fc7b25c4 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 22 Nov 2023 09:55:20 +0100 Subject: [PATCH 3/6] restListMacros alias has been added --- cmake/thisREST.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/thisREST.cmake b/cmake/thisREST.cmake index 40a8ed8c7..4be8a9491 100644 --- a/cmake/thisREST.cmake +++ b/cmake/thisREST.cmake @@ -143,6 +143,7 @@ export PYTHONPATH=${PYTHON_BINDINGS_INSTALL_DIR}:\\\$PYTHONPATH alias restRoot=\\\"restRoot -l\\\" alias restRootMacros=\\\"restRoot -l --m\\\" +alias restListMacros=\\\"restManager ListMacros\\\" if [ \\\$(rest-config --flags | grep \\\"REST_WELCOME=ON\\\") ]; then rest-config --welcome From ea38fc7f23a5f84ce5dc3b78235a241685033087 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 23 Nov 2023 09:20:24 +0100 Subject: [PATCH 4/6] REST_GenerateDataSets. outPath is not const any more --- macros/REST_GenerateDataSets.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/REST_GenerateDataSets.C b/macros/REST_GenerateDataSets.C index 05ad63816..3c468ca6d 100644 --- a/macros/REST_GenerateDataSets.C +++ b/macros/REST_GenerateDataSets.C @@ -16,7 +16,7 @@ //******************************************************************************************************* Int_t REST_GenerateDataSets(const std::string& inputRML, const std::string& datasets, - const std::string& outPath = "") { + std::string outPath = "") { std::vector sets = REST_StringHelper::Split(datasets, ","); for (const auto& set : sets) { From ae6e9cfd55e3ea64c5ddb51ff2e9c409118eaeac Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 23 Nov 2023 10:32:07 +0100 Subject: [PATCH 5/6] REST_CheckValidRuns. Added an option to purge the non-valid REST files --- ...eckRunFileList.C => REST_CheckValidRuns.C} | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) rename macros/{REST_CheckRunFileList.C => REST_CheckValidRuns.C} (55%) diff --git a/macros/REST_CheckRunFileList.C b/macros/REST_CheckValidRuns.C similarity index 55% rename from macros/REST_CheckRunFileList.C rename to macros/REST_CheckValidRuns.C index eba5324da..30cc37aca 100644 --- a/macros/REST_CheckRunFileList.C +++ b/macros/REST_CheckValidRuns.C @@ -1,24 +1,47 @@ #include +#include + #include #include "TGeoManager.h" #include "TRestTask.h" #include "TSystem.h" using namespace std; +namespace fs = std::filesystem; -#ifndef RESTTask_CheckRunFileList -#define RESTTask_CheckRunFileList +#ifndef RESTTask_CheckValidRuns +#define RESTTask_CheckValidRuns //******************************************************************************************************* //*** -//*** Your HELP is needed to verify, validate and document this macro -//*** This macro might need update/revision. +//*** Description: This macro will identify run files that were not properly closed. +//*** +//*** -------------- +//*** The first and mandatory argument must provide a full data and pattern to filter the files that +//*** will be checked. E.g. to add all the Hits files from run number 123 the first argument would be +//*** pattern = "/path/to/data/Run00123*Hits*root". +//*** +//*** IMPORTANT: The pattern must be given using double quotes "" +//*** +//*** -------------- +//*** Usage: restManager CheckValidRuns "/full/path/file_*pattern*.root" [purge] +//*** -------------- +//*** +//*** An optional parameter `purge` can be made true. In that case, this macro will not just provide +//*** a list of the files not properly closed but it will also remove them! +//*** +//*** The following command will remove the non-valid runs +//*** -------------- +//*** Usage: restManager CheckValidRuns "/full/path/file_*pattern*.root" 1 +//*** -------------- +//*** +//*** CAUTION: Be aware that any non-REST file in the list will be removed if you use purge=1 //*** //******************************************************************************************************* -Int_t REST_CheckRunFileList(TString namePattern, Int_t N = 100000) { +Int_t REST_CheckValidRuns(TString namePattern, Bool_t purge = false) { TGeoManager::SetVerboseLevel(0); - vector filesNotWellClosed; + vector filesNotWellClosed; TRestStringOutput RESTLog; @@ -70,7 +93,16 @@ Int_t REST_CheckRunFileList(TString namePattern, Int_t N = 100000) { RESTLog << "---------------------" << RESTendl; RESTLog << "Files not well closed" << RESTendl; RESTLog << "---------------------" << RESTendl; - for (int i = 0; i < filesNotWellClosed.size(); i++) RESTLog << filesNotWellClosed[i] << RESTendl; + for (int i = 0; i < filesNotWellClosed.size(); i++) { + RESTLog << filesNotWellClosed[i] << RESTendl; + if (purge) fs::remove(filesNotWellClosed[i]); + } + + if (purge) { + RESTLog << "---------------------------" << RESTendl; + RESTLog << "The files have been removed" << RESTendl; + RESTLog << "---------------------------" << RESTendl; + } } RESTLog << "------------------------------" << RESTendl; From 533d7a15265ad78e556308d8e4e96065e814d95c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:32:49 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- macros/REST_CheckValidRuns.C | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/macros/REST_CheckValidRuns.C b/macros/REST_CheckValidRuns.C index 30cc37aca..2031a7eb9 100644 --- a/macros/REST_CheckValidRuns.C +++ b/macros/REST_CheckValidRuns.C @@ -1,6 +1,5 @@ -#include #include - +#include #include #include "TGeoManager.h"