LDMX Software
DetectorIDInterpreter.h
1#ifndef DETDESCR_DETECTORIDINTERPRETER_H
2#define DETDESCR_DETECTORIDINTERPRETER_H
3
4// STL
5#include <vector>
6
7// LDMX
8#include "DetDescr/DetectorID.h"
9#include "DetDescr/IDField.h"
10
11namespace ldmx {
12
25 public:
28
30
34 typedef unsigned FieldValue;
35
39 typedef std::vector<FieldValue> FieldValueList;
40
45 DetectorID getId() const { return id_; }
46
51 void setRawValue(DetectorID rawValue);
52
57 FieldValue getFieldValue(int i) const;
58
64 void setFieldValue(int i, FieldValue value);
65
71 void setFieldValue(const std::string& fieldName, FieldValue fieldValue);
72
77 int getFieldCount() const { return int(p_field_info_->field_list_.size()); }
78
84 return p_field_info_->field_list_;
85 }
86
92 const IDField* getField(const std::string& fieldName) const;
93
98 FieldValue getFieldValue(const std::string& fieldName) const;
99
103 static void registerInterpreter(SubdetectorIDType idtype,
104 const IDField::IDFieldList& fieldList);
105
110 static void registerInterpreter(SubdetectorIDType idtype, unsigned int mask,
111 unsigned int equality,
112 const IDField::IDFieldList& fieldList);
113
114 private:
119 static void loadStandardInterpreters();
120
128 void init();
129
133 void unpack();
134
138 void pack();
139
144
149
151 IDField::IDFieldMap field_map_;
152 IDField::IDFieldList field_list_;
153 };
154
155 struct IDSignature {
156 unsigned int mask_;
157 unsigned int comparison_;
158 bool operator<(const IDSignature& id) const {
159 return (comparison_ & mask_) < (id.comparison_ & id.mask_);
160 }
161 };
162
163 static std::map<IDSignature, const SubdetectorIDFields*> g_rosetta_stone;
164
169};
170
171} // namespace ldmx
172
173#endif
Class provides an "introspection" capability for the 32-bit packed IDs used for uniquely identifying ...
static void loadStandardInterpreters()
Load the standard field interpreters if not yet loaded.
FieldValue getFieldValue(int i) const
Decode and return a field's value from the raw ID.
FieldValueList field_values_
The unpacked list of field values.
const IDField::IDFieldList & getFieldList() const
Get the list of field information.
void unpack()
Unpack the current raw value into a list.
void pack()
Pack the current list of field values into a raw value.
DetectorID getId() const
Get the raw value of the detector ID.
void setRawValue(DetectorID rawValue)
Set the raw value of the detector ID.
unsigned FieldValue
Definition of the field value type.
int getFieldCount() const
Get the list of field information.
const IDField * getField(const std::string &fieldName) const
Get the information for a field by name.
void init()
Reinitialize the ID in case the field list changed.
DetectorID id_
The raw, packed value of the ID.
std::vector< FieldValue > FieldValueList
A list of field values.
void setFieldValue(int i, FieldValue value)
Set a field value by index in the field value list.
const SubdetectorIDFields * p_field_info_
Pointer to the appropriate field info for this class.
static void registerInterpreter(SubdetectorIDType idtype, const IDField::IDFieldList &fieldList)
Register a new field interpreter for a given subdetector id.
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
Definition DetectorID.h:36
Provides information about a field within a DetectorID.
Definition IDField.h:15
std::map< std::string, IDField * > IDFieldMap
Map of name to field.
Definition IDField.h:20
std::vector< IDField * > IDFieldList
List of fields.
Definition IDField.h:25