delphi-edm4hep
DELPHI SDST/FDST -> EDM4hep converter
Loading...
Searching...
No Matches
BankReader.h
Go to the documentation of this file.
1// BankReader.h — internal header (not exported).
2//
3// Locating and reading PA extra-modules in the ZEBRA store. A Record owns
4// the decoding of one module: where its words are, and any layout that
5// varies with the DST version. Writers map the values into EDM4hep and do
6// not read Q/IQ directly.
7
8#pragma once
9
11
12#include <cmath>
13#include <initializer_list>
14#include <optional>
15#include <string_view>
16
18
19// A located module, or a sub-record inside one. `name` is the mnemonic that
20// answered, which matters where a module changed identity between
21// data-taking eras: hadron-calorimeter clusters are HCNC at LEP1 and HCAL
22// from 1996.
23class Record {
24public:
25 Record(std::string_view name, int address)
26 : name_(name), address_(address) {}
27
28 std::string_view name() const { return name_; }
29
30 // Word `n`, numbered from 1 as in the DELPHI layout documents.
31 float real(int n) const { return phdst::Q(address_ + n); }
32 int integer(int n) const {
33 return static_cast<int>(std::lround(phdst::Q(address_ + n)));
34 }
35
36 // A record starting `n` words further on. Used for the repeated
37 // sub-records — showers, layers — that follow a module header.
38 Record subRecord(int n) const { return Record(name_, address_ + n); }
39
40 // The `n`-th sub-record `name` inside this module, counted from 1.
41 // Sub-records are named "<MODULE>.<PART>" and are located by the Fortran
42 // lookup rather than by stepping a stride. Empty when `n` exceeds the
43 // number present.
44 std::optional<Record> subRecord(const char* name, int n) const;
45
46private:
47 std::string_view name_;
48 int address_;
49};
50
51// Locate `name` on the PA at `lpa`. Empty if the module is absent.
52// `name` is passed to the Fortran lookup and must be NUL-terminated.
53std::optional<Record> find(int lpa, const char* name);
54
55// Locate the first of `names` present. Use where a module was replaced
56// between eras and either may appear.
57std::optional<Record> findFirst(int lpa,
58 std::initializer_list<const char*> names);
59
60} // namespace delphi_edm4hep::banks
Record(std::string_view name, int address)
Definition BankReader.h:25
float real(int n) const
Definition BankReader.h:31
Record subRecord(int n) const
Definition BankReader.h:38
std::string_view name() const
Definition BankReader.h:28
std::optional< Record > find(int lpa, const char *name)
Definition BankReader.cpp:7
std::optional< Record > findFirst(int lpa, std::initializer_list< const char * > names)