CMS 3D CMS Logo

HcalRecoParamsWithPulseShapesESProducer.cc
Go to the documentation of this file.
3 
7 
11 
18 
21  public:
23  auto cc = setWhatProduced(this);
24  recoParamsToken_ = cc.consumes();
25  }
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
29  descriptions.addWithDefaultLabel(desc);
30  }
31 
32  std::unique_ptr<hcal::HcalRecoParamWithPulseShapeHost> produce(HcalRecoParamsRcd const& iRecord) {
33  auto const& recoParams = iRecord.get(recoParamsToken_);
34 
35  auto const containers = recoParams.getAllContainers();
36  size_t const totalChannels =
37  recoParams.getAllContainers()[0].second.size() + recoParams.getAllContainers()[1].second.size();
38 
39  //Get unique ids
40  HcalPulseShapes pulseShapes;
41  std::unordered_map<unsigned int, uint32_t> idCache; //<pulseShapeId,pulseShapeIdx>
42 
43  auto const& barrelValues = containers[0].second;
44  for (uint64_t i = 0; i < barrelValues.size(); ++i) {
45  auto const pulseShapeId = barrelValues[i].pulseShapeID();
46  if (pulseShapeId == 0)
47  continue;
48  if (auto const iter = idCache.find(pulseShapeId); iter == idCache.end()) {
49  idCache[pulseShapeId] = idCache.size();
50  }
51  }
52  auto const& endcapValues = containers[1].second;
53  for (uint64_t i = 0; i < endcapValues.size(); ++i) {
54  auto const pulseShapeId = endcapValues[i].pulseShapeID();
55  if (pulseShapeId == 0)
56  continue;
57  if (auto const iter = idCache.find(pulseShapeId); iter == idCache.end()) {
58  idCache[pulseShapeId] = idCache.size();
59  }
60  }
61 
62  // Fill products
63  auto product = std::make_unique<hcal::HcalRecoParamWithPulseShapeHost>(
64  totalChannels, idCache.size(), cms::alpakatools::host());
65  auto recoView = product->recoParamView();
66  auto pulseShapeView = product->pulseShapeView();
67  for (uint64_t i = 0; i < barrelValues.size(); ++i) {
68  auto vi = recoView[i];
69  vi.param1() = barrelValues[i].param1();
70  vi.param2() = barrelValues[i].param2();
71  vi.ids() = (barrelValues[i].pulseShapeID() == 0)
72  ? 0
73  : idCache.at(barrelValues[i].pulseShapeID()); //idx of the pulseShape of channel i
74  }
75  // fill in endcap
76  auto const offset = barrelValues.size();
77  for (uint64_t i = 0; i < endcapValues.size(); ++i) {
78  auto vi = recoView[i + offset];
79  vi.param1() = endcapValues[i].param1();
80  vi.param2() = endcapValues[i].param2();
81  vi.ids() = (endcapValues[i].pulseShapeID() == 0)
82  ? 0
83  : idCache.at(endcapValues[i].pulseShapeID()); //idx of the pulseShape of channel i
84  }
85 
86  //fill pulseShape views
87  for (auto& it : idCache) {
88  auto const pulseShapeId = it.first;
89  auto const arrId = it.second;
90  auto const& pulseShape = pulseShapes.getShape(pulseShapeId);
91  FitterFuncs::PulseShapeFunctor functor{pulseShape, false, false, false, 1, 0, 0, hcal::constants::maxSamples};
92 
93  for (int i = 0; i < hcal::constants::maxPSshapeBin; i++) {
94  pulseShapeView[arrId].acc25nsVec()[i] = functor.acc25nsVec()[i];
95  pulseShapeView[arrId].diff25nsItvlVec()[i] = functor.diff25nsItvlVec()[i];
96  }
97  for (int i = 0; i < hcal::constants::nsPerBX; i++) {
98  pulseShapeView[arrId].accVarLenIdxMinusOneVec()[i] = functor.accVarLenIdxMinusOneVec()[i];
99  pulseShapeView[arrId].diffVarItvlIdxMinusOneVec()[i] = functor.diffVarItvlIdxMinusOneVec()[i];
100  pulseShapeView[arrId].accVarLenIdxZEROVec()[i] = functor.accVarLenIdxZEROVec()[i];
101  pulseShapeView[arrId].diffVarItvlIdxZEROVec()[i] = functor.diffVarItvlIdxZEROVec()[i];
102  }
103  }
104 
105  return product;
106  }
107 
108  private:
110  };
111 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
112 
113 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(HcalRecoParamWithPulseShapeESProducer);
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
constexpr int maxPSshapeBin
Definition: HcalConstants.h:7
constexpr int nsPerBX
Definition: HcalConstants.h:8
std::unique_ptr< hcal::HcalRecoParamWithPulseShapeHost > produce(HcalRecoParamsRcd const &iRecord)
const Shape & getShape(int shapeType) const
alpaka::DevCpu const & host()
Definition: host.h:14
unsigned long long uint64_t
Definition: Time.h:13
constexpr int maxSamples
Definition: HcalConstants.h:6
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:17
def functor(code, kwds, debug=0)
Definition: utils.py:70
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const