CMS 3D CMS Logo

HcalSiPMCharacteristicsESProducer.cc
Go to the documentation of this file.
3 
7 
13 
16  public:
18  auto cc = setWhatProduced(this);
19  sipmCharacteristicsToken_ = cc.consumes();
20  }
21 
22  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
24  descriptions.addWithDefaultLabel(desc);
25  }
26 
27  std::unique_ptr<hcal::HcalSiPMCharacteristicsPortableHost> produce(HcalSiPMCharacteristicsRcd const& iRecord) {
28  auto const& sipmCharacteristics = iRecord.get(sipmCharacteristicsToken_);
29 
30  size_t const totalItems = sipmCharacteristics.getTypes();
31 
32  auto product = std::make_unique<hcal::HcalSiPMCharacteristicsPortableHost>(totalItems, cms::alpakatools::host());
33 
34  auto view = product->view();
35 
36  for (uint32_t i = 0; i < sipmCharacteristics.getTypes(); i++) {
37  auto vi = view[i];
38  auto const type = sipmCharacteristics.getType(i);
39 
40  // type index starts with 1 .. 6
41  if (static_cast<uint32_t>(type) != i + 1)
42  throw cms::Exception("HcalSiPMCharacteristics")
43  << "Wrong assumption for HcalSiPMcharacteristics type values, "
44  << "should be type value <- type index + 1" << std::endl
45  << "Observed type value = " << type << " and index = " << i << std::endl;
46 
47  vi.precisionItem() = HcalSiPMCharacteristics::PrecisionItem(type,
48  sipmCharacteristics.getPixels(type),
49  sipmCharacteristics.getNonLinearities(type)[0],
50  sipmCharacteristics.getNonLinearities(type)[1],
51  sipmCharacteristics.getNonLinearities(type)[2],
52  sipmCharacteristics.getCrossTalk(type),
53  sipmCharacteristics.getAuxi1(type),
54  sipmCharacteristics.getAuxi2(type));
55  }
56  return product;
57  }
58 
59  private:
61  };
62 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
63 
64 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(HcalSiPMCharacteristicsESProducer);
std::unique_ptr< hcal::HcalSiPMCharacteristicsPortableHost > produce(HcalSiPMCharacteristicsRcd const &iRecord)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
alpaka::DevCpu const & host()
Definition: host.h:14
edm::ESGetToken< HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd > sipmCharacteristicsToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:17