Skip to content
Snippets Groups Projects
Commit ca2fd43c authored by Sylvester Joosten's avatar Sylvester Joosten
Browse files

added facilities to ensure output directories are writable, debug replay script

parent 22bca8e0
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ ROOTfiles
raw
raw.copiedtotape
cache
logs
# Symbolic links
hcana
\ No newline at end of file
hcana
......@@ -37,7 +37,7 @@ using namespace std;
#include "THcTrigDet.h"
std::string coda_file_pattern(bool do_coin) {
return fmt::format("{}_all_{{:05d}}.dat", do_coin? "coin", "shms");
return fmt::format("{}_all_{{:05d}}.dat", do_coin ? "coin" : "shms");
}
std::string output_file_pattern(string_view path, string_view content, string_view extension,
bool do_coin, bool do_all) {
......@@ -45,8 +45,8 @@ std::string output_file_pattern(string_view path, string_view content, string_vi
do_all ? "all_" : "", extension);
}
void replay_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 0, string_view mode = "shms",
const bool do_all = false) {
int replay_shms(Int_t RunNumber = 7160, Int_t MaxEvent = -1, Int_t FirstEvent = 0,
const bool do_coin = false, const bool do_all = false) {
// ===========================================================================
// Setup logging
spdlog::set_level(spdlog::level::warn);
......@@ -68,11 +68,6 @@ void replay_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 0, string_view mode =
return -1;
}
}
if (mode != "shms" && mode != "SHMS" && mode != "coin" && mode != "COIN") {
cerr << "Invalid mode `" << mode << "`, has to be either `coin` or `shms`\n";
return -1;
}
const bool do_coin = (mode == "coin" || mode == "COIN");
// ===========================================================================
// Create file name patterns.
......@@ -252,7 +247,7 @@ void replay_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 0, string_view mode =
// File to record accounting information for cuts
analyzer->SetSummaryFile(fmt::format(output_file_pattern("REPORT_OUTPUT/PRODUCTION", "summary",
"report", do_coin, do_all),
Run Number, MaxEvent)
RunNumber, MaxEvent)
.c_str());
// Start the actual analysis.
analyzer->Process(run);
......@@ -261,8 +256,10 @@ void replay_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 0, string_view mode =
"TEMPLATES/SHMS/PRODUCTION/pstackana_production.template",
fmt::format(output_file_pattern("REPORT_OUTPUT/PRODUCTION", "replay_production", "report",
do_coin, do_all),
Run Number, MaxEvent)
RunNumber, MaxEvent)
.c_str());
delete analyzer;
return 0;
}
......@@ -12,6 +12,16 @@ function print_the_help {
exit
}
function io_error {
echo ERROR: cannot create or write to directory $1
exit -1
}
function ensure_directory {
echo "Ensuring $1 exists and is writable"
[[ -d "$1" ]] || mkdir -p $1
touch $1/.write_check || io_error $1
}
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
......@@ -63,7 +73,7 @@ do
shift # past argument
;;
-c|--coin)
DO_COIN="true"
shift # past argument
;;
*) # unknown option
......@@ -97,5 +107,16 @@ fi
# exit
#fi
hcana -b -q \
"SCRIPTS/SHMS/replay_shms.cxx+(${run_number},${n_events},${min_event},${DO_COIN},${DO_ALL})"
## NOTE: if you change anything here, make sure you make corresponding changes
## in the replay script
REPLAY_ARGS="${run_number},${n_events},${min_event},${DO_COIN},${DO_ALL}"
REPLAY_CMD="SCRIPTS/PRODUCTION/replay_shms.cxx+(${REPLAY_ARGS})"
REPORT_DIR="REPORT_OUTPUT/PRODUCTION"
LOGDIR="logs"
ROOTDIR="ROOTfiles"
ensure_directory ${REPORT_DIR}
ensure_directory ${LOGDIR}
ensure_directory ${ROOTDIR}
hcana -b -q "${REPLAY_CMD}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment