CMS 3D CMS Logo

HGCalMappingESProducer.cc
Go to the documentation of this file.
18 
23 public:
24  explicit HGCalMappingESProducer(const edm::ParameterSet& iConfig) {
25  //parse the files and hold the list of entities in memory
26  for (auto v : {"modules", "si", "sipm"}) {
29  pmap.buildFrom(fip.fullPath());
30  parsedMaps_[v] = pmap;
31  }
32 
35 
36  findingRecord<HGCalElectronicsMappingRcd>();
37 
40  }
41 
42  std::shared_ptr<HGCalMappingModuleIndexer> produceModuleMapIndexer(const HGCalElectronicsMappingRcd&) {
43  return std::shared_ptr<HGCalMappingModuleIndexer>(&modIndexer_, edm::do_nothing_deleter());
44  }
45 
46  std::shared_ptr<HGCalMappingCellIndexer> produceCellMapIndexer(const HGCalElectronicsMappingRcd&) {
47  return std::shared_ptr<HGCalMappingCellIndexer>(&cellIndexer_, edm::do_nothing_deleter());
48  }
49 
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
52  desc.add<edm::FileInPath>("modules")->setComment("module locator file");
53  desc.add<edm::FileInPath>("si")->setComment("file containing the mapping of the readout cells in Si modules");
54  desc.add<edm::FileInPath>("sipm")->setComment(
55  "file containing the mapping of the readout cells in SiPM-on-tile modules");
56  descriptions.addWithDefaultLabel(desc);
57  }
58 
59 private:
61  const edm::IOVSyncValue&,
62  edm::ValidityInterval& oValidity) override {
64  }
65 
68 
69  std::map<std::string, hgcal::mappingtools::HGCalEntityList> parsedMaps_;
72 };
73 
74 //
76  for (auto v : {"si", "sipm"}) {
77  auto& pmap = parsedMaps_[v];
78  const auto& entities = pmap.getEntries();
79  for (auto row : entities) {
80  std::string typecode = pmap.getAttr("Typecode", row);
81  int chip = pmap.getIntAttr("ROC", row);
82  int half = pmap.getIntAttr("HalfROC", row);
83  cellIndexer_.processNewCell(typecode, chip, half);
84  }
85  }
86 
87  // all {hex,tile}board types are loaded finalize the mapping indexer
89 }
90 
91 //
93  //default values to assign in case module type has not yet been mapped
94  //a high density module (max possible) will be assigned so that the mapping doesn't block
95  auto defaultTypeCodeIdx = cellIndexer_.getEnumFromTypecode("MH-F");
96  auto typecodeidx = defaultTypeCodeIdx;
97  auto defaultNerx = cellIndexer_.getNErxExpectedFor(defaultTypeCodeIdx);
98  auto nerx = defaultNerx;
99  auto defaultTypeNWords = cellIndexer_.getNWordsExpectedFor(defaultTypeCodeIdx);
100  auto nwords = defaultTypeNWords;
101 
102  auto& pmap = parsedMaps_["modules"];
103  auto& entities = pmap.getEntries();
104  for (auto row : entities) {
105  std::string typecode = pmap.getAttr("typecode", row);
106 
107  if (typecode.find('M') == 0 && typecode.size() > 4)
108  typecode = typecode.substr(0, 4);
109 
110  try {
111  typecodeidx = cellIndexer_.getEnumFromTypecode(typecode);
112  nwords = cellIndexer_.getNWordsExpectedFor(typecode);
113  nerx = cellIndexer_.getNErxExpectedFor(typecode);
114  } catch (cms::Exception& e) {
115  int plane = pmap.getIntAttr("plane", row);
116  int u = pmap.getIntAttr("u", row);
117  int v = pmap.getIntAttr("v", row);
118  edm::LogWarning("HGCalMappingESProducer") << "Exception caught decoding index for typecode=" << typecode
119  << " @ plane=" << plane << " u=" << u << " v=" << v << "\n"
120  << e.what() << "\n"
121  << "===> will assign default (MH-F) which may be inefficient";
122  typecodeidx = defaultTypeCodeIdx;
123  nwords = defaultTypeNWords;
124  nerx = defaultNerx;
125  }
126 
127  int fedid = pmap.getIntAttr("fedid", row);
128  int captureblockidx = pmap.getIntAttr("captureblockidx", row);
129  int econdidx = pmap.getIntAttr("econdidx", row);
130  modIndexer_.processNewModule(fedid, captureblockidx, econdidx, typecodeidx, nerx, nwords);
131  }
132 
134 }
135 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< std::string, hgcal::mappingtools::HGCalEntityList > parsedMaps_
utility class to assign dense readout module indexing the class holds the information on the expected...
std::string fullPath() const
Definition: FileInPath.cc:161
void processNewCell(std::string typecode, uint16_t chip, uint16_t half)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::shared_ptr< HGCalMappingModuleIndexer > produceModuleMapIndexer(const HGCalElectronicsMappingRcd &)
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string
HGCalMappingCellIndexer cellIndexer_
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void processNewModule(uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx, uint32_t typecodeIdx, uint32_t nerx, uint32_t nwords)
for a new module it adds it&#39;s type to the readaout sequence vector if the fed id is not yet existing ...
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &oValidity) override
std::shared_ptr< HGCalMappingCellIndexer > produceCellMapIndexer(const HGCalElectronicsMappingRcd &)
void buildFrom(std::string url)
builds the entity list from a file
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
void update()
process the current list of type codes handled and updates the dense indexers
utility class to assign dense readout cell indexing
plugin parses the module/cell locator files to produce the indexer records
HGCalMappingESProducer(const edm::ParameterSet &iConfig)
HGCalMappingModuleIndexer modIndexer_
size_t getNWordsExpectedFor(std::string typecode) const
gets the number of words for a given typecode
Log< level::Warning, false > LogWarning
size_t getNErxExpectedFor(std::string typecode) const
gets the number of e-Rx for a given typecode