diff --git a/include/Ecal/EcalDetectorMap.h b/include/Ecal/EcalDetectorMap.h index 7cea227..f37d16a 100644 --- a/include/Ecal/EcalDetectorMap.h +++ b/include/Ecal/EcalDetectorMap.h @@ -58,7 +58,7 @@ class EcalDetectorMap * Building a reverse (detector->electronics) map takes extra time * and memory so it should be off by default. */ - EcalDetectorMap(bool want_d2e); + EcalDetectorMap(const std::string& cell_map, const std::string& motherboard_map, const std::string& layer_map, bool want_d2e); /// Provider which loads the map friend class EcalDetectorMapLoader; @@ -74,9 +74,6 @@ class EcalDetectorMap /// build the electronics map from loaded maps void buildElectronicsMap(); - /// the full electronics map - ldmx::ElectronicsMap emap_; - /** * Table of per-module cell information */ diff --git a/src/Ecal/EcalDetectorMap.cxx b/src/Ecal/EcalDetectorMap.cxx index aab2e56..500623f 100644 --- a/src/Ecal/EcalDetectorMap.cxx +++ b/src/Ecal/EcalDetectorMap.cxx @@ -14,30 +14,22 @@ class EcalDetectorMapLoader : public framework::ConditionsObjectProvider { framework::Process& process) : ConditionsObjectProvider(EcalDetectorMap::CONDITIONS_OBJECT_NAME, tagname, parameters, process), - theMap_{0} { + the_map_{nullptr} { want_d2e_ = parameters.getParameter("want_d2e"); - cellMap_ = parameters.getParameter("cell_map"); - motherboardMap_ = parameters.getParameter("motherboard_map"); - layerMap_ = parameters.getParameter("layer_map"); + cell_map_ = parameters.getParameter("cell_map"); + motherboard_map_ = parameters.getParameter("motherboard_map"); + layer_map_ = parameters.getParameter("layer_map"); } virtual std::pair getCondition(const ldmx::EventHeader& context) { - if (!theMap_) { - theMap_ = new EcalDetectorMap(want_d2e_); - conditions::StreamCSVLoader scell(cellMap_); - theMap_->loadCellMap(scell); - conditions::StreamCSVLoader smb(motherboardMap_); - theMap_->loadMotherboardMap(smb); - conditions::StreamCSVLoader slayer(layerMap_); - theMap_->loadLayerMap(slayer); - - theMap_->buildElectronicsMap(); + if (!the_map_) { + the_map_ = new EcalDetectorMap(cell_map_, motherboard_map_, layer_map_, want_d2e_); } return std::make_pair( - theMap_, framework::ConditionsIOV(context.getRun(), context.getRun(), + the_map_, framework::ConditionsIOV(context.getRun(), context.getRun(), true, true)); } @@ -48,16 +40,25 @@ class EcalDetectorMapLoader : public framework::ConditionsObjectProvider { virtual void releaseConditionsObject(const framework::ConditionsObject* co) {} private: - EcalDetectorMap* theMap_; - std::string cellMap_; - std::string motherboardMap_; - std::string layerMap_; + EcalDetectorMap* the_map_; + std::string cell_map_; + std::string motherboard_map_; + std::string layer_map_; bool want_d2e_; }; -EcalDetectorMap::EcalDetectorMap(bool want_d2e) +EcalDetectorMap::EcalDetectorMap(const std::string& cell_map, const std::string& motherboard_map, const std::string& layer_map, bool want_d2e) : framework::ConditionsObject(CONDITIONS_OBJECT_NAME), - ldmx::ElectronicsMap(want_d2e) {} + ldmx::ElectronicsMap(want_d2e) { + + conditions::StreamCSVLoader scell(cell_map); + this->loadCellMap(scell); + conditions::StreamCSVLoader smb(motherboard_map); + this->loadMotherboardMap(smb); + conditions::StreamCSVLoader slayer(layer_map); + this->loadLayerMap(slayer); + this->buildElectronicsMap(); +} void EcalDetectorMap::loadCellMap(conditions::GeneralCSVLoader& loader) { cells_.clear(); @@ -115,7 +116,7 @@ void EcalDetectorMap::buildElectronicsMap() { elink.polarfire_elink, cell.roc_elink_channel); - if (emap_.exists(elecId)) { + if (this->exists(elecId)) { std::stringstream ss; ss << "Two different mappings for electronics channel " << elecId; EXCEPTION_RAISE("DuplicateMapping", ss.str()); diff --git a/src/Ecal/EcalRawDecoder.cxx b/src/Ecal/EcalRawDecoder.cxx index 1ef00e1..99b86a5 100644 --- a/src/Ecal/EcalRawDecoder.cxx +++ b/src/Ecal/EcalRawDecoder.cxx @@ -1,16 +1,14 @@ -/** - * @file EcalRawDecoder.cxx - * @brief Class that performs basic ECal digitization - * @author Cameron Bravo, SLAC National Accelerator Laboratory - * @author Tom Eichlersmith, University of Minnesota - */ +#include #include "Ecal/EcalRawDecoder.h" #include "DetDescr/EcalElectronicsID.h" #include "DetDescr/EcalID.h" #include "Ecal/EcalDetectorMap.h" +#include "Packing/Utility/Mask.h" +#include "Packing/Utility/CRC.h" #include "Recon/Event/HgcrocDigiCollection.h" +#include "Tools/BufferReader.h" namespace ecal { @@ -39,7 +37,7 @@ void EcalRawDecoder::produce(framework::Event& event) { * by their channel ID. We need to do that here. */ // fill map of **electronic** IDs to the digis that were read out - std::map> eid_to_samples; tools::BufferReader r{ @@ -233,11 +231,10 @@ void EcalRawDecoder::produce(framework::Event& event) { auto detmap{ getCondition(EcalDetectorMap::CONDITIONS_OBJECT_NAME)}; ldmx::HgcrocDigiCollection digis; - for (auto const& [eid_raw, digi] : eid_to_samples) { + for (auto const& [eid, digi] : eid_to_samples) { // TODO: This checking of existence should be temporary, // the electronic ID mapping should be complete. - uint32_t did_raw{eid_raw}; - ldmx::EcalElectronicsID eid{eid_raw}; + uint32_t did_raw{eid.raw()}; if (detmap.exists(eid)) { did_raw = detmap.get(eid).raw(); }