diff --git a/python/EcalDetectorMap.py b/python/EcalDetectorMap.py new file mode 100644 index 0000000..0918c33 --- /dev/null +++ b/python/EcalDetectorMap.py @@ -0,0 +1,45 @@ +"""Conditions object providers for a mapping between ecal electronics IDs and detector IDs""" + +from LDMX.Framework import ldmxcfg + +class EcalDetectorMap(ldmxcfg.ConditionsObjectProvider) : + """The COP that maps between Electronic and Detector IDs. + + The mapping is defined in three 'tiers'. + + 1. cell - Each cell of a module has specific ROC elink and channel + 2. motherboard - Each module has a specific ROC elink and polarfire + 3. layer - Each layer has specific daq optical link + + So three CSV tables are necessary for providing this mapping. + We can't have multiple different detector maps during a single + run, so this class is meant to be a singleton. + + Attributes + ---------- + __instance : EcalDetectorMap + Singleton instance of this object + """ + + __instance = None + + def get() : + """Get the single instance of the EcalDetectorMap + + Returns + ------- + EcalDetectorMap + Single instance of the provider + """ + return EcalGeometryProvider.__instance + + def __init__(self, cell_map, motherboard_map, layer_map) : + if EcalDetectorMap.__instance != None : + raise Exception('EcalDetectorMap is a singleton class and should only be created once. You can retrieve the single instance with EcalDetectorMap.get()') + else: + # the name needs to match the conditions object name in EcalDetectorMap.h + super().__init__("EcalDetectorMap","ecal::EcalDetectorMapLoader","Ecal") + self.cell_map = cell_map + self.motherboard_map = motherboard_map + self.layer_map = layer_map + diff --git a/src/Ecal/EcalDetectorMap.cxx b/src/Ecal/EcalDetectorMap.cxx index 5ab3fa0..129f8f8 100644 --- a/src/Ecal/EcalDetectorMap.cxx +++ b/src/Ecal/EcalDetectorMap.cxx @@ -13,9 +13,9 @@ class EcalDetectorMapLoader : public framework::ConditionsObjectProvider { framework::Process& process) : ConditionsObjectProvider(EcalDetectorMap::CONDITIONS_OBJECT_NAME, tagname, parameters, process), theMap_{0} { - cellMap_=parameters.getParameter("CellMap"); - motherboardMap_=parameters.getParameter("MotherboardMap"); - layerMap_=parameters.getParameter("LayerMap"); + cellMap_=parameters.getParameter("cell_map"); + motherboardMap_=parameters.getParameter("motherboard_map"); + layerMap_=parameters.getParameter("layer_map"); } virtual std::pair