9#ifndef TOOLS_ELECTRONICSMAP_H_
10#define TOOLS_ELECTRONICSMAP_H_
27template <
class ElectronicsID,
class DetID>
37 eid2did_ = std::vector<DetectorID::RawValue>(ElectronicsID::MAX_INDEX, 0);
45 unsigned int index = eid.index();
47 EXCEPTION_RAISE(
"ElectronicsMapOverflow",
48 "Attempted to insert electronics with index " +
49 std::to_string(index) +
50 " which is larger than allowed in this map");
59 bool exists(ElectronicsID eid)
const {
73 if (i == did.raw())
return true;
82 DetID
get(ElectronicsID eid)
const {
95 ElectronicsID
get(DetID did)
const {
100 ss <<
"Unable to find mapping for det id " << did;
101 EXCEPTION_RAISE(
"ElectronicsMapNotFound", ss.str());
105 for (
unsigned int i = 0; i <
eid2did_.size(); i++) {
106 if (
eid2did_[i] == did.raw())
return ElectronicsID::idFromIndex(i);
108 std::stringstream ss;
109 ss <<
"Unable to find mapping for det id " << did;
110 EXCEPTION_RAISE(
"ElectronicsMapNotFound", ss.str());
127 std::map<DetectorID::RawValue, ElectronicsID>
did2eid_;
DetID get(ElectronicsID eid) const
Get the detector ID for this electronics ID.
void addEntry(ElectronicsID eid, DetID did)
Add an entry to the map.
void clear()
Remove all entries from the map.
ElectronicsID get(DetID did) const
Get the electronics ID for this detector ID This method is slow O(N) if the map is not configured for...
bool exists(DetID did) const
Tests if a given detector id is in the map This method is slow O(N) if the map is not configured for ...
std::vector< DetectorID::RawValue > eid2did_
Linear-time map for electronics (packed index) to raw detector id.
bool makeD2E_
Flag to determine if did2eid should be filled (resource optimization)
bool exists(ElectronicsID eid) const
Tests if a given electronics id is in the map.
std::map< DetectorID::RawValue, ElectronicsID > did2eid_
Log(N) map for raw detector id to electronics id.