1#include "Tracking/Reco/TrackerDaqMap.h"
4#include <nlohmann/json.hpp>
6#include "Framework/Exception/Exception.h"
8namespace tracking::reco {
11 std::ifstream in(path);
15 "TrackerDaqMap could not open DAQ map file '" + path +
"'.");
21 }
catch (
const nlohmann::json::parse_error& e) {
22 EXCEPTION_RAISE(
"BadFormat",
23 "TrackerDaqMap failed to parse DAQ map file '" + path +
27 if (!doc.contains(
"sensors") || !doc.at(
"sensors").is_array() ||
28 doc.at(
"sensors").empty()) {
29 EXCEPTION_RAISE(
"BadFormat",
"TrackerDaqMap file '" + path +
30 "' has no non-empty 'sensors' array.");
34 for (
const auto& s : doc.at(
"sensors")) {
35 for (
const char* required :
36 {
"feb",
"hybrid",
"layer_id",
"n_strips",
"first_strip",
"reversed"}) {
37 if (!s.contains(required)) {
38 EXCEPTION_RAISE(
"BadFormat",
"TrackerDaqMap file '" + path +
39 "' has a sensor entry missing '" +
40 required +
"': " + s.dump());
44 const auto feb = s.at(
"feb").get<uint8_t>();
45 const auto hybrid = s.at(
"hybrid").get<uint8_t>();
46 const uint16_t k = key(feb, hybrid);
48 EXCEPTION_RAISE(
"BadFormat",
"TrackerDaqMap file '" + path +
49 "' defines (feb=" + std::to_string(feb) +
50 ", hybrid=" + std::to_string(hybrid) +
55 info.layer_id_ = s.at(
"layer_id").get<
int>();
56 info.n_strips_ = s.at(
"n_strips").get<
int>();
57 info.first_strip_ = s.at(
"first_strip").get<
int>();
58 info.reversed_ = s.at(
"reversed").get<
bool>();
66 uint8_t hybrid)
const {
67 auto it =
sensors_.find(key(feb, hybrid));
69 EXCEPTION_RAISE(
"NotFound",
"TrackerDaqMap has no entry for (feb=" +
71 ", hybrid=" + std::to_string(hybrid) +
72 "); guard with has() before calling at().");
Tracker DAQ map: the correspondence between an electronics sensor address (feb, hybrid) and the detec...
std::map< uint16_t, SensorInfo > sensors_
key = (feb << 8) | hybrid
const SensorInfo & at(uint8_t feb, uint8_t hybrid) const
Look up the sensor read by (feb, hybrid).
static TrackerDaqMap fromJsonFile(const std::string &path)
Load a DAQ map from a JSON file.
Everything the mapper needs to know about one physical sensor.