CMS 3D CMS Logo

SiPixelCablingSoAESProducer.cc
Go to the documentation of this file.
20 
22 
23  using namespace cms::alpakatools;
24 
26  public:
28  : ESProducer(iConfig), useQuality_(iConfig.getParameter<bool>("UseQualityInfo")) {
29  auto cc = setWhatProduced(this);
30  cablingMapToken_ = cc.consumes(edm::ESInputTag{"", iConfig.getParameter<std::string>("CablingMapLabel")});
31  if (useQuality_) {
32  qualityToken_ = cc.consumes();
33  }
34  geometryToken_ = cc.consumes();
35  }
36 
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
39  desc.add<std::string>("CablingMapLabel", "")->setComment("CablingMap label");
40  desc.add<bool>("UseQualityInfo", false);
41  descriptions.addWithDefaultLabel(desc);
42  }
43 
44  std::optional<SiPixelMappingHost> produce(const SiPixelMappingSoARecord& iRecord) {
45  auto cablingMap = iRecord.getTransientHandle(cablingMapToken_);
46  const SiPixelQuality* quality = nullptr;
47  if (useQuality_) {
48  auto qualityInfo = iRecord.getTransientHandle(qualityToken_);
49  quality = qualityInfo.product();
50  }
51 
52  auto geom = iRecord.getTransientHandle(geometryToken_);
54  std::vector<unsigned int> const& fedIds = cablingMap->fedIds();
55  std::unique_ptr<SiPixelFedCablingTree> const& cabling = cablingMap->cablingTree();
56 
57  unsigned int startFed = fedIds.front();
58  unsigned int endFed = fedIds.back();
59 
61  int index = 1;
62 
63  auto mapView = product.view();
64 
65  mapView.hasQuality() = useQuality_;
66  for (unsigned int fed = startFed; fed <= endFed; fed++) {
67  for (unsigned int link = 1; link <= pixelgpudetails::MAX_LINK; link++) {
68  for (unsigned int roc = 1; roc <= pixelgpudetails::MAX_ROC; roc++) {
69  path = {fed, link, roc};
70  const sipixelobjects::PixelROC* pixelRoc = cabling->findItem(path);
71  mapView[index].fed() = fed;
72  mapView[index].link() = link;
73  mapView[index].roc() = roc;
74  if (pixelRoc != nullptr) {
75  mapView[index].rawId() = pixelRoc->rawId();
76  mapView[index].rocInDet() = pixelRoc->idInDetUnit();
77  mapView[index].modToUnpDefault() = false;
78  if (quality != nullptr)
79  mapView[index].badRocs() = quality->IsRocBad(pixelRoc->rawId(), pixelRoc->idInDetUnit());
80  else
81  mapView[index].badRocs() = false;
82  } else { // store some dummy number
83  mapView[index].rawId() = pixelClustering::invalidModuleId;
84  mapView[index].rocInDet() = pixelClustering::invalidModuleId;
85  mapView[index].badRocs() = true;
86  mapView[index].modToUnpDefault() = true;
87  }
88  index++;
89  }
90  }
91  } // end of FED loop
92  // Given FedId, Link and idinLnk; use the following formula
93  // to get the rawId and idinDU
94  // index = (FedID-1200) * MAX_LINK* MAX_ROC + (Link-1)* MAX_ROC + idinLnk;
95  // where, MAX_LINK = 48, MAX_ROC = 8
96  // FedID varies between 1200 to 1338 (In total 108 FED's)
97  // Link varies between 1 to 48
98  // idinLnk varies between 1 to 8
99 
100  auto trackerGeom = iRecord.getTransientHandle(geometryToken_);
101 
102  for (int i = 1; i < index; i++) {
103  if (mapView[i].rawId() == pixelClustering::invalidModuleId) {
104  mapView[i].moduleId() = pixelClustering::invalidModuleId;
105  } else {
106  auto gdet = trackerGeom->idToDetUnit(mapView[i].rawId());
107  if (!gdet) {
108  LogDebug("SiPixelCablingSoAESProducer") << " Not found: " << mapView[i].rawId() << std::endl;
109  continue;
110  }
111  mapView[i].moduleId() = gdet->index();
112  }
113  LogDebug("SiPixelCablingSoAESProducer")
114  << "----------------------------------------------------------------------------" << std::endl;
115  LogDebug("SiPixelCablingSoAESProducer") << i << std::setw(20) << mapView[i].fed() << std::setw(20)
116  << mapView[i].link() << std::setw(20) << mapView[i].roc() << std::endl;
117  LogDebug("SiPixelCablingSoAESProducer")
118  << i << std::setw(20) << mapView[i].rawId() << std::setw(20) << mapView[i].rocInDet() << std::setw(20)
119  << mapView[i].moduleId() << std::endl;
120  LogDebug("SiPixelCablingSoAESProducer")
121  << i << std::setw(20) << mapView[i].badRocs() << std::setw(20) << std::endl;
122  LogDebug("SiPixelCablingSoAESProducer")
123  << "----------------------------------------------------------------------------" << std::endl;
124  }
125 
126  mapView.size() = index - 1;
127 
128  return product;
129  }
130 
131  private:
135  const bool useQuality_;
136  };
137 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
138 
140 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(SiPixelCablingSoAESProducer);
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > cablingMapToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::optional< SiPixelMappingHost > produce(const SiPixelMappingSoARecord &iRecord)
string quality
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geometryToken_
edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > qualityToken_
constexpr unsigned int MAX_ROC
alpaka::DevCpu const & host()
Definition: host.h:26
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:17
constexpr unsigned int MAX_SIZE
constexpr unsigned int MAX_LINK
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:37
constexpr uint16_t invalidModuleId
#define LogDebug(id)