LDMX Software
DetectorIDInterpreter.h
1#ifndef DETDESCR_DETECTORIDINTERPRETER_H
2#define DETDESCR_DETECTORIDINTERPRETER_H
3
4// STL
5#include <iostream>
6#include <vector>
7
8// LDMX
9#include "DetDescr/DetectorID.h"
10#include "DetDescr/IDField.h"
11
12namespace ldmx {
13
26 public:
29
31
35 typedef unsigned FieldValue;
36
40 typedef std::vector<FieldValue> FieldValueList;
41
46 DetectorID getId() const { return id_; }
47
52 void setRawValue(DetectorID rawValue);
53
58 FieldValue getFieldValue(int i) const;
59
65 void setFieldValue(int i, FieldValue value);
66
72 void setFieldValue(const std::string& fieldName, FieldValue fieldValue);
73
78 int getFieldCount() const { return int(p_fieldInfo_->fieldList_.size()); }
79
85 return p_fieldInfo_->fieldList_;
86 }
87
93 const IDField* getField(const std::string& fieldName) const;
94
99 FieldValue getFieldValue(const std::string& fieldName) const;
100
104 static void registerInterpreter(SubdetectorIDType idtype,
105 const IDField::IDFieldList& fieldList);
106
111 static void registerInterpreter(SubdetectorIDType idtype, unsigned int mask,
112 unsigned int equality,
113 const IDField::IDFieldList& fieldList);
114
115 private:
120 static void loadStandardInterpreters();
121
129 void init();
130
134 void unpack();
135
139 void pack();
140
145
150
152 IDField::IDFieldMap fieldMap_;
153 IDField::IDFieldList fieldList_;
154 };
155
156 struct IDSignature {
157 unsigned int mask_;
158 unsigned int comparison_;
159 bool operator<(const IDSignature& id) const {
160 return (comparison_ & mask_) < (id.comparison_ & id.mask_);
161 }
162 };
163
164 static std::map<IDSignature, const SubdetectorIDFields*> g_rosettaStone;
165
170};
171
172} // namespace ldmx
173
174#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.
std::vector< FieldValue > FieldValueList
A 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.
const SubdetectorIDFields * p_fieldInfo_
Pointer to the appropriate field info for this class.
DetectorID getId() const
Get the raw value of the detector ID.
void setRawValue(DetectorID rawValue)
Set the raw value of the detector ID.
FieldValueList fieldValues_
The unpacked list of field values.
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.
void setFieldValue(int i, FieldValue value)
Set a field value by index in the field value list.
unsigned FieldValue
Definition of the field value type.
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:35
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