10 #include <unordered_map> 15 param1_(totalChannels_),
16 param2_(totalChannels_),
17 ids_(totalChannels_) {
18 #ifdef HCAL_MAHI_CPUDEBUG 19 printf(
"hello from a reco params with pulse shapes\n");
22 auto const containers = recoParams.getAllContainers();
25 std::unordered_map<unsigned int, uint32_t> idCache;
28 auto const& barrelValues = containers[0].second;
29 for (
uint64_t i = 0;
i < barrelValues.size(); ++
i) {
30 param1_[
i] = barrelValues[
i].param1();
31 param2_[
i] = barrelValues[
i].param2();
33 auto const pulseShapeId = barrelValues[
i].pulseShapeID();
37 if (pulseShapeId == 0) {
41 if (
auto const iter = idCache.find(pulseShapeId); iter == idCache.end()) {
43 auto const newId = idCache.size();
44 idCache[pulseShapeId] = newId;
57 auto const& pulseShape = pulseShapes.
getShape(pulseShapeId);
61 auto const numShapes = newId;
63 acc25nsVec_[offset256 * numShapes +
i] =
functor.acc25nsVec()[
i];
64 diff25nsItvlVec_[offset256 * numShapes +
i] =
functor.diff25nsItvlVec()[
i];
68 accVarLenIdxMinusOneVec_[offset25 * numShapes +
i] =
functor.accVarLenIdxMinusOneVec()[
i];
69 diffVarItvlIdxMinusOneVec_[offset25 * numShapes +
i] =
functor.diffVarItvlIdxMinusOneVec()[
i];
70 accVarLenIdxZEROVec_[offset25 * numShapes +
i] =
functor.accVarLenIdxZEROVec()[
i];
71 diffVarItvlIdxZEROVec_[offset25 * numShapes +
i] =
functor.diffVarItvlIdxZEROVec()[
i];
75 ids_[
i] = iter->second;
77 #ifdef HCAL_MAHI_CPUDEBUG 78 if (barrelValues[
i].rawId() == DETID_TO_DEBUG) {
79 printf(
"recoShapeId = %u myid = %u\n", pulseShapeId, ids_[
i]);
85 auto const& endcapValues = containers[1].second;
86 auto const offset = barrelValues.size();
87 for (
uint64_t i = 0;
i < endcapValues.size(); ++
i) {
88 param1_[
i +
offset] = endcapValues[
i].param1();
89 param2_[
i +
offset] = endcapValues[
i].param2();
91 auto const pulseShapeId = endcapValues[
i].pulseShapeID();
95 if (pulseShapeId == 0) {
99 if (
auto const iter = idCache.find(pulseShapeId); iter == idCache.end()) {
101 auto const newId = idCache.size();
102 idCache[pulseShapeId] = newId;
115 auto const& pulseShape = pulseShapes.
getShape(pulseShapeId);
119 auto const numShapes = newId;
121 acc25nsVec_[offset256 * numShapes +
i] =
functor.acc25nsVec()[
i];
122 diff25nsItvlVec_[offset256 * numShapes +
i] =
functor.diff25nsItvlVec()[
i];
126 accVarLenIdxMinusOneVec_[offset25 * numShapes +
i] =
functor.accVarLenIdxMinusOneVec()[
i];
127 diffVarItvlIdxMinusOneVec_[offset25 * numShapes +
i] =
functor.diffVarItvlIdxMinusOneVec()[
i];
128 accVarLenIdxZEROVec_[offset25 * numShapes +
i] =
functor.accVarLenIdxZEROVec()[
i];
129 diffVarItvlIdxZEROVec_[offset25 * numShapes +
i] =
functor.diffVarItvlIdxZEROVec()[
i];
133 ids_[
i +
offset] = iter->second;
137 #ifdef HCAL_MAHI_CPUDEBUG 138 for (
auto const&
p : idCache)
139 printf(
"recoPulseShapeId = %u id = %u\n",
p.first,
p.second);
157 cudaStream_t cudaStream)
const {
158 auto const& product =
product_.dataForCurrentDeviceAsync(
161 cudaCheck(cudaMalloc((
void**)&product.
param1, this->param1_.size() *
sizeof(uint32_t)));
162 cudaCheck(cudaMalloc((
void**)&product.
param2, this->param2_.size() *
sizeof(uint32_t)));
163 cudaCheck(cudaMalloc((
void**)&product.
ids, this->ids_.size() *
sizeof(uint32_t)));
167 this->accVarLenIdxMinusOneVec_.size() *
sizeof(
float)));
169 this->diffVarItvlIdxMinusOneVec_.size() *
sizeof(
float)));
176 this->param1_.data(),
177 this->
param1_.size() *
sizeof(uint32_t),
178 cudaMemcpyHostToDevice,
181 this->param2_.data(),
182 this->
param2_.size() *
sizeof(uint32_t),
183 cudaMemcpyHostToDevice,
186 product.
ids, this->ids_.data(), this->
ids_.size() *
sizeof(uint32_t), cudaMemcpyHostToDevice, cudaStream));
188 this->acc25nsVec_.data(),
190 cudaMemcpyHostToDevice,
193 this->diff25nsItvlVec_.data(),
195 cudaMemcpyHostToDevice,
198 this->accVarLenIdxMinusOneVec_.data(),
200 cudaMemcpyHostToDevice,
203 this->diffVarItvlIdxMinusOneVec_.data(),
205 cudaMemcpyHostToDevice,
208 this->accVarLenIdxZEROVec_.data(),
210 cudaMemcpyHostToDevice,
213 this->diffVarItvlIdxZEROVec_.data(),
215 cudaMemcpyHostToDevice,
float * accVarLenIdxMinusOneVec
std::vector< float, cms::cuda::HostAllocator< float > > diffVarItvlIdxZEROVec_
HcalRecoParamsWithPulseShapesGPU(HcalRecoParams const &)
std::vector< float, cms::cuda::HostAllocator< float > > accVarLenIdxMinusOneVec_
std::vector< uint32_t, cms::cuda::HostAllocator< uint32_t > > param1_
std::vector< float, cms::cuda::HostAllocator< float > > diffVarItvlIdxMinusOneVec_
cms::cuda::ESProduct< Product > product_
std::vector< float, cms::cuda::HostAllocator< float > > accVarLenIdxZEROVec_
float * diffVarItvlIdxZEROVec
Product const & getProduct(cudaStream_t) const
constexpr int maxPSshapeBin
float * accVarLenIdxZEROVec
const tAllContWithNames getAllContainers() const
const Shape & getShape(int shapeType) const
std::vector< float, cms::cuda::HostAllocator< float > > acc25nsVec_
std::vector< uint32_t, cms::cuda::HostAllocator< uint32_t > > param2_
unsigned long long uint64_t
#define TYPELOOKUP_DATA_REG(_dataclass_)
float * diffVarItvlIdxMinusOneVec
def functor(code, kwds, debug=0)
#define cudaCheck(ARG,...)
std::vector< float, cms::cuda::HostAllocator< float > > diff25nsItvlVec_
std::vector< uint32_t, cms::cuda::HostAllocator< uint32_t > > ids_