Commit 80b2aa84 authored by Iain's avatar Iain
Browse files

Merge branch 'feature/specify-output-path' into 'develop'

Specify Output Path

See merge request !60
parents 07327e1a 6410eb18
Pipeline #53719 passed with stages
in 5 minutes and 43 seconds
......@@ -75,6 +75,8 @@ public:
}
const auto filePath = dataSourceCfgJson.get("FilePath", "").asString();
const auto outFilePath =
dataSourceCfgJson.get("OutputFilePath", "").asString();
const auto device = dataSourceCfgJson.get("Device", "").asString();
const auto channels = dataSourceCfgJson.get("Channels", 0).asInt();
auto vars = dataSourceCfgJson["Variables"];
......@@ -119,7 +121,7 @@ public:
}
rm->eventLimit = eventLimit;
rm->dataSource = {device, filePath, channels, vars};
rm->dataSource = {device, filePath, outFilePath, channels, vars};
rm->channelConfigs = channelConfigs;
}
......
......@@ -14,9 +14,10 @@ class Reader;
* sub classes.
*/
struct DataSource {
std::string device; /*!< The type of device used in the experiment. */
std::string filePath; /*!< The path to the data file. */
int channels; /*!< The number of channels used in the experiment. */
std::string device; /*!< The type of device used in the experiment. */
std::string filePath; /*!< The path to the data file. */
std::string outFilePath; /*!< The path and filename for the output file. */
int channels; /*!< The number of channels used in the experiment. */
Json::Value vars; /*!< Additional variables for specific implementations. */
};
......
......@@ -9,21 +9,21 @@ NTupleWriter::NTupleWriter(Json::Value cfg, DataSource dataSource) {
mProcDir = gDirectory;
std::string inputFilePath = dataSource.filePath;
// TODO: this part isn't OS agnostic
std::string run_name = inputFilePath.substr(
inputFilePath.find_last_of("/") + 1, inputFilePath.find(".mid.gz"));
std::string out_file_name =
inputFilePath.substr(0, inputFilePath.find_last_of("/"));
std::string outputFilePath;
if (dataSource.outFilePath.empty()) {
outputFilePath = dataSource.filePath;
} else {
outputFilePath = dataSource.outFilePath;
}
for (int channelID = 0; channelID < dataSource.channels; channelID++) {
char tmp_name[80];
sprintf(tmp_name, "%s/%s.Ch%iNTuple.root", out_file_name.c_str(),
run_name.c_str(), channelID);
char fullOutputPath[80];
sprintf(fullOutputPath, "%s.Ch%iNTuple.root", outputFilePath.c_str(),
channelID);
std::string ntp_name = "ntp" + std::to_string(channelID);
outputFiles.push_back(
{new TFile(std::string(tmp_name).c_str(), "RECREATE"),
{new TFile(fullOutputPath, "RECREATE"),
new TNtuple(ntp_name.c_str(), ntp_name.c_str(),
"evt:tt:blmu:blRMS:np:pbl:paa:pa:pt:pq:pw:tchi2:fa:ft:frt:"
"fft:ff2:fft2:fblmu:fchi2:ndf:frchi2:frndf:fcharge")});
......
......@@ -9,18 +9,16 @@ TTreeWriter::TTreeWriter(Json::Value cfg, DataSource dataSource)
: written(false), eventID(0), triggerTime(0) {
mProcDir = gDirectory;
std::string outputFilePath;
if (dataSource.outFilePath.empty()) {
outputFilePath = dataSource.filePath;
} else {
outputFilePath = dataSource.outFilePath;
}
std::string inputFilePath = dataSource.filePath;
// TODO: this part isn't OS agnostic
std::string run_name = inputFilePath.substr(
inputFilePath.find_last_of("/") + 1, inputFilePath.find(".mid.gz"));
std::string out_file_name =
inputFilePath.substr(0, inputFilePath.find_last_of("/"));
std::string fullOutputPath = outputFilePath.append(".TTree.root");
char tmp_name[80];
sprintf(tmp_name, "%s/%s.TTree.root", out_file_name.c_str(),
run_name.c_str());
mOutputFile = new TFile(std::string(tmp_name).c_str(), "RECREATE");
mOutputFile = new TFile(fullOutputPath.c_str(), "RECREATE");
mTree = new TTree("DataOutTree", "Data Results");
......
......@@ -2,6 +2,7 @@
"EventLimit": 20000,
"DataSource": {
"FilePath": "./ntp/DS-WAV/LF_TILE15_77K_73V_9VoV_2.wav",
"OutputFilePath": "./ntp/DS-WAV/LF_TILE15_77K_73V_9VoV_2_PFSProminence",
"Device": "LNGS-WAV",
"Channels": 2,
"Variables": {}
......
......@@ -2,6 +2,7 @@
"EventLimit": 100,
"DataSource": {
"FilePath": "./ntp/TEST_FILE_DIGITIZER_SINGLE_CHANNEL/run00321.mid.gz",
"OutputFilePath": "./ntp/TEST_FILE_DIGITIZER_SINGLE_CHANNEL/run00321_PFS_Triangle",
"Device": "V1730",
"Channels": 1,
"Variables": {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment