CMS 3D CMS Logo

HGCalMappingModuleESProducer.cc
Go to the documentation of this file.
4 
18 
19 #include <string>
20 #include <iostream>
21 #include <fstream>
22 #include <sstream>
23 
25 
26  namespace hgcal {
27 
29  public:
30  //
32  : ESProducer(iConfig), filename_(iConfig.getParameter<edm::FileInPath>("filename")) {
33  auto cc = setWhatProduced(this);
34  moduleIndexTkn_ = cc.consumes(iConfig.getParameter<edm::ESInputTag>("moduleindexer"));
35  }
36 
37  //
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
40  desc.add<edm::FileInPath>("filename")->setComment("module locator file");
41  desc.add<edm::ESInputTag>("moduleindexer", edm::ESInputTag(""))->setComment("Dense module index tool");
42  descriptions.addWithDefaultLabel(desc);
43  }
44 
45  //
46  std::optional<HGCalMappingModuleParamHostCollection> produce(const HGCalElectronicsMappingRcd& iRecord) {
47  //get cell and module indexer
48  auto modIndexer = iRecord.get(moduleIndexTkn_);
49 
50  // load dense indexing
51  const uint32_t size = modIndexer.maxModulesIdx_;
53  for (size_t i = 0; i < size; i++)
54  moduleParams.view()[i].valid() = false;
55 
58  auto& entities = pmap.getEntries();
59  for (auto row : entities) {
60  int fedid = pmap.getIntAttr("fedid", row);
61  int captureblockidx = pmap.getIntAttr("captureblockidx", row);
62  int econdidx = pmap.getIntAttr("econdidx", row);
63  int idx = modIndexer.getIndexForModule(fedid, captureblockidx, econdidx);
64  int typeidx = modIndexer.getTypeForModule(fedid, captureblockidx, econdidx);
65  std::string typecode = pmap.getAttr("typecode", row);
66  auto celltypes = modIndexer.convertTypeCode(typecode);
67  bool isSiPM = celltypes.first;
68  int celltype = celltypes.second;
69  int zside = pmap.getIntAttr("zside", row);
70  int plane = pmap.getIntAttr("plane", row);
71  int i1 = pmap.getIntAttr("u", row);
72  int i2 = pmap.getIntAttr("v", row);
73  uint32_t eleid = HGCalElectronicsId((zside > 0), fedid, captureblockidx, econdidx, 0, 0).raw();
74  uint32_t detid(0);
75  if (!isSiPM) {
76  int zp(zside > 0 ? 1 : -1);
77  DetId::Detector det = plane <= 26 ? DetId::Detector::HGCalEE : DetId::Detector::HGCalHSi;
78  detid = HGCSiliconDetId(det, zp, celltype, plane, i1, i2, 0, 0).rawId();
79  }
80 
81  auto module = moduleParams.view()[idx];
82  module.valid() = true;
83  module.zside() = (zside > 0);
84  module.isSiPM() = isSiPM;
85  module.celltype() = celltype;
86  module.plane() = plane;
87  module.i1() = i1;
88  module.i2() = i2;
89  module.typeidx() = typeidx;
90  module.fedid() = fedid;
91  module.slinkidx() = pmap.getIntAttr("slinkidx", row);
92  module.captureblock() = pmap.getIntAttr("captureblock", row);
93  ;
94  module.econdidx() = econdidx;
95  module.captureblockidx() = captureblockidx;
96  module.eleid() = eleid;
97  module.detid() = detid;
98  }
99 
100  return moduleParams;
101 
102  } // end of produce()
103 
104  private:
107  };
108 
109  } // namespace hgcal
110 
111 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
112 
113 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(hgcal::HGCalMappingModuleESProducer);
uint32_t raw() const
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
float getIntAttr(std::string col, HGCalEntityRow &row)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
int zside(DetId const &)
const std::vector< HGCalEntityRow > & getEntries()
std::optional< HGCalMappingModuleParamHostCollection > produce(const HGCalElectronicsMappingRcd &iRecord)
HGCalEntityAttr getAttr(std::string col, HGCalEntityRow &row)
gets the attribute corresponding the column col in a row
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
bool isSiPM(int ieta, int iphi, int depth)
wrapper for a 32b data word identifying a readout channel in the raw data The format is the following...
alpaka::DevCpu const & host()
Definition: host.h:14
void buildFrom(std::string url)
builds the entity list from a file
edm::ESGetToken< HGCalMappingModuleIndexer, HGCalElectronicsMappingRcd > moduleIndexTkn_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector
Definition: DetId.h:24
HLT enums.
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:17
const std::string & fullPath() const
Definition: FileInPath.cc:144
::hgcal::HGCalMappingModuleParamHostCollection HGCalMappingModuleParamHostCollection