LDMX Software
tracking::reco::TrackerDaqMap Class Reference

Tracker DAQ map: the correspondence between an electronics sensor address (feb, hybrid) and the detector layer it reads, plus the strip transform that turns a physical channel (pchannel) into a sensor strip index. More...

#include <TrackerDaqMap.h>

Classes

struct  SensorInfo
 Everything the mapper needs to know about one physical sensor. More...
 

Public Member Functions

bool has (uint8_t feb, uint8_t hybrid) const
 True if the map has an entry for this electronics sensor.
 
const SensorInfoat (uint8_t feb, uint8_t hybrid) const
 Look up the sensor read by (feb, hybrid).
 
std::size_t size () const
 Number of sensors in the map.
 
const std::map< uint16_t, SensorInfo > & sensors () const
 All sensors, keyed by (feb << 8) | hybrid.
 

Static Public Member Functions

static TrackerDaqMap fromJsonFile (const std::string &path)
 Load a DAQ map from a JSON file.
 

Static Private Member Functions

static uint16_t key (uint8_t feb, uint8_t hybrid)
 

Private Attributes

std::map< uint16_t, SensorInfosensors_
 key = (feb << 8) | hybrid
 

Detailed Description

Tracker DAQ map: the correspondence between an electronics sensor address (feb, hybrid) and the detector layer it reads, plus the strip transform that turns a physical channel (pchannel) into a sensor strip index.

Definition at line 15 of file TrackerDaqMap.h.

Member Function Documentation

◆ at()

const TrackerDaqMap::SensorInfo & tracking::reco::TrackerDaqMap::at ( uint8_t feb,
uint8_t hybrid ) const

Look up the sensor read by (feb, hybrid).

Exceptions
framework::exception::Exceptionif there is no such entry; callers that want to skip unmapped sensors must guard with has() first.

Definition at line 65 of file TrackerDaqMap.cxx.

66 {
67 auto it = sensors_.find(key(feb, hybrid));
68 if (it == sensors_.end()) {
69 EXCEPTION_RAISE("NotFound", "TrackerDaqMap has no entry for (feb=" +
70 std::to_string(feb) +
71 ", hybrid=" + std::to_string(hybrid) +
72 "); guard with has() before calling at().");
73 }
74 return it->second;
75}
std::map< uint16_t, SensorInfo > sensors_
key = (feb << 8) | hybrid

References sensors_.

Referenced by tracking::reco::SiStripWaveformFitProcessor::produce().

◆ fromJsonFile()

TrackerDaqMap tracking::reco::TrackerDaqMap::fromJsonFile ( const std::string & path)
static

Load a DAQ map from a JSON file.

Expected schema:

{ "sensors": [ { "feb": 0, "hybrid": 0, "layer_id": 3101,
"n_strips": 640, "first_strip": 0, "reversed": false },
... ] }

Extra keys (e.g. "station", "orientation", "_comment") are ignored.

Exceptions
framework::exception::Exceptionif the file cannot be opened, is not valid JSON, lacks a non-empty "sensors" array, has a malformed entry, or defines the same (feb, hybrid) twice. There is no silent empty-map failure mode.

Definition at line 10 of file TrackerDaqMap.cxx.

10 {
11 std::ifstream in(path);
12 if (!in) {
13 EXCEPTION_RAISE(
14 "FileNotFound",
15 "TrackerDaqMap could not open DAQ map file '" + path + "'.");
16 }
17
18 nlohmann::json doc;
19 try {
20 in >> doc;
21 } catch (const nlohmann::json::parse_error& e) {
22 EXCEPTION_RAISE("BadFormat",
23 "TrackerDaqMap failed to parse DAQ map file '" + path +
24 "': " + e.what());
25 }
26
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.");
31 }
32
33 TrackerDaqMap map;
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());
41 }
42 }
43
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);
47 if (map.sensors_.count(k) != 0u) {
48 EXCEPTION_RAISE("BadFormat", "TrackerDaqMap file '" + path +
49 "' defines (feb=" + std::to_string(feb) +
50 ", hybrid=" + std::to_string(hybrid) +
51 ") more than once.");
52 }
53
54 SensorInfo info;
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>();
59 map.sensors_[k] = info;
60 }
61
62 return map;
63}

References sensors_.

Referenced by tracking::reco::SiStripWaveformFitProcessor::onProcessStart().

◆ has()

bool tracking::reco::TrackerDaqMap::has ( uint8_t feb,
uint8_t hybrid ) const
inline

True if the map has an entry for this electronics sensor.

Definition at line 46 of file TrackerDaqMap.h.

46 {
47 return sensors_.find(key(feb, hybrid)) != sensors_.end();
48 }

References sensors_.

Referenced by tracking::reco::SiStripWaveformFitProcessor::produce().

◆ key()

static uint16_t tracking::reco::TrackerDaqMap::key ( uint8_t feb,
uint8_t hybrid )
inlinestaticprivate

Definition at line 66 of file TrackerDaqMap.h.

66 {
67 return static_cast<uint16_t>((static_cast<uint16_t>(feb) << 8) | hybrid);
68 }

◆ sensors()

const std::map< uint16_t, SensorInfo > & tracking::reco::TrackerDaqMap::sensors ( ) const
inline

All sensors, keyed by (feb << 8) | hybrid.

For consumers that need to index by something other than the electronics address (e.g. build a layer_id -> n_strips lookup).

Definition at line 63 of file TrackerDaqMap.h.

63{ return sensors_; }

References sensors_.

◆ size()

std::size_t tracking::reco::TrackerDaqMap::size ( ) const
inline

Number of sensors in the map.

Definition at line 58 of file TrackerDaqMap.h.

58{ return sensors_.size(); }

References sensors_.

Referenced by tracking::reco::SiStripWaveformFitProcessor::onProcessStart().

Member Data Documentation

◆ sensors_

std::map<uint16_t, SensorInfo> tracking::reco::TrackerDaqMap::sensors_
private

key = (feb << 8) | hybrid

Definition at line 70 of file TrackerDaqMap.h.

Referenced by at(), fromJsonFile(), has(), sensors(), and size().


The documentation for this class was generated from the following files: