Commit 77d76a61 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Corry: allow multiple "detectors" files to be read in. Still only one is written out

parent 8d67d6d0
Pipeline #238296 failed with stages
in 1 minute and 44 seconds
......@@ -145,12 +145,13 @@ void Timepix3EventLoader::initialise() {
LOG(DEBUG) << "Opened data file for " << detectorID << ": " << filename;
// The header is repeated in every new data file, thus skip it for all.
uint32_t headerID;
uint32_t headerID;
if(!new_file->read(reinterpret_cast<char*>(&headerID), sizeof headerID)) {
throw AlgorithmError("Cannot read header ID for " + detectorID + " in file " + filename);
}
if(headerID != 1380208723) {
throw AlgorithmError("Incorrect header ID for " + detectorID + " in file " + filename + ": " + std::to_string(headerID));
throw AlgorithmError("Incorrect header ID for " + detectorID + " in file " + filename + ": " +
std::to_string(headerID));
}
LOG(TRACE) << "Header ID: \"" << headerID << "\"";
......
......@@ -96,17 +96,31 @@ void Analysis::load() {
}
void Analysis::load_detectors() {
std::string detectors_file = global_config.getPath("detectors_file");
std::fstream file(detectors_file);
ConfigReader reader(file, detectors_file);
for(auto& detector : reader.getConfigurations()) {
LOG(INFO) << "Detector: " << detector.getName();
Detector* det_parm = new Detector(detector);
std::vector<std::string> detectors_files = global_config.getPathArray("detectors_file");
// Add the new detector to the global list:
detectors.push_back(det_parm);
for(auto& detectors_file : detectors_files) {
std::fstream file(detectors_file);
ConfigReader reader(file, detectors_file);
for(auto& detector : reader.getConfigurations()) {
std::string name = detector.getName();
// Check if we have a duplicate:
if(std::find_if(detectors.begin(), detectors.end(), [&name](Detector* obj) { return obj->name() == name; }) !=
detectors.end()) {
throw InvalidValueError(
global_config, "detectors_file", "Detector " + detector.getName() + " defined twice");
}
LOG(INFO) << "Detector: " << name;
Detector* det_parm = new Detector(detector);
// Add the new detector to the global list:
detectors.push_back(det_parm);
}
}
LOG(STATUS) << "Loaded " << detectors.size() << " detectors";
// Finally, sort the list of detectors by z position (from lowest to highest)
......
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