CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Attributes
HcalConvertedPedestalsGPU Class Reference

#include <HcalConvertedPedestalsGPU.h>

Inheritance diagram for HcalConvertedPedestalsGPU:
HcalConvertedEffectivePedestalsGPU

Classes

struct  Product
 

Public Member Functions

Product const & getProduct (cudaStream_t) const
 
 HcalConvertedPedestalsGPU (HcalPedestals const &, HcalQIEData const &, HcalQIETypes const &)
 
uint32_t offsetForHashes () const
 
 ~HcalConvertedPedestalsGPU ()=default
 

Protected Attributes

uint32_t offsetForHashes_
 
cms::cuda::ESProduct< Productproduct_
 
uint64_t totalChannels_
 
std::vector< float, cms::cuda::HostAllocator< float > > values_
 

Detailed Description

Definition at line 15 of file HcalConvertedPedestalsGPU.h.

Constructor & Destructor Documentation

◆ HcalConvertedPedestalsGPU()

HcalConvertedPedestalsGPU::HcalConvertedPedestalsGPU ( HcalPedestals const &  pedestals,
HcalQIEData const &  qieData,
HcalQIETypes const &  qieTypes 
)

Definition at line 18 of file HcalConvertedPedestalsGPU.cc.

21  : totalChannels_{pedestals.getAllContainers()[0].second.size() + pedestals.getAllContainers()[1].second.size()},
22  offsetForHashes_{static_cast<uint32_t>(pedestals.getAllContainers()[0].second.size())},
23  values_(totalChannels_ * 4) {
24 #ifdef HCAL_MAHI_CPUDEBUG
25  std::cout << "hello from converted pedestals" << std::endl;
26  std::cout << "pedestals HB values = " << pedestals.getAllContainers()[0].second.size()
27  << " HE values = " << pedestals.getAllContainers()[1].second.size() << std::endl;
28  std::cout << "qiedata HB values = " << qieData.getAllContainers()[0].second.size()
29  << " HE values = " << qieData.getAllContainers()[1].second.size() << std::endl;
30 #endif
31 
32  // retrieve all collections
33  auto const pedestalsAll = pedestals.getAllContainers();
34  auto const qieDataAll = qieData.getAllContainers();
35  auto const qieTypesAll = qieTypes.getAllContainers();
36 
37  // have to convert to fc if stored in adc
38  auto const unitIsADC = pedestals.isADC();
39 
40  // fill in barrel
41  auto const& pedestalBarrelValues = pedestalsAll[0].second;
42  auto const& qieDataBarrelValues = qieDataAll[0].second;
43  auto const& qieTypesBarrelValues = qieTypesAll[0].second;
44 
45 #ifdef HCAL_MAHI_CPUDEBUG
46  assert(pedestalBarrelValues.size() == qieDataBarrelValues.size());
47  assert(pedestalBarrelValues.size() == qieTypesBarrelValues.size());
48 #endif
49 
50  for (uint64_t i = 0; i < pedestalBarrelValues.size(); ++i) {
51  auto const& qieCoder = qieDataBarrelValues[i];
52  auto const qieType = qieTypesBarrelValues[i].getValue() > 1 ? 1 : 0;
53  auto const& qieShape = qieData.getShape(qieType);
54 
55  values_[i * 4] = unitIsADC ? convert(pedestalBarrelValues[i].getValue(0), 0, qieCoder, qieShape)
56  : pedestalBarrelValues[i].getValue(0);
57  values_[i * 4 + 1] = unitIsADC ? convert(pedestalBarrelValues[i].getValue(1), 1, qieCoder, qieShape)
58  : pedestalBarrelValues[i].getValue(1);
59  values_[i * 4 + 2] = unitIsADC ? convert(pedestalBarrelValues[i].getValue(2), 2, qieCoder, qieShape)
60  : pedestalBarrelValues[i].getValue(2);
61  values_[i * 4 + 3] = unitIsADC ? convert(pedestalBarrelValues[i].getValue(3), 3, qieCoder, qieShape)
62  : pedestalBarrelValues[i].getValue(3);
63  }
64 
65  // fill in endcap
66  auto const& pedestalEndcapValues = pedestalsAll[1].second;
67  auto const& qieDataEndcapValues = qieDataAll[1].second;
68  auto const& qieTypesEndcapValues = qieTypesAll[1].second;
69 
70 #ifdef HCAL_MAHI_CPUDEBUG
71  assert(pedestalEndcapValues.size() == qieDataEndcapValues.size());
72  assert(pedestalEndcapValues.size() == qieTypesEndcapValues.size());
73 #endif
74 
75  auto const offset = pedestalBarrelValues.size();
76  for (uint64_t i = 0; i < pedestalEndcapValues.size(); ++i) {
77  auto const& qieCoder = qieDataEndcapValues[i];
78  auto const qieType = qieTypesEndcapValues[i].getValue() > 1 ? 1 : 0;
79  auto const& qieShape = qieData.getShape(qieType);
80  auto const off = offset + i;
81 
82  values_[off * 4] = unitIsADC ? convert(pedestalEndcapValues[i].getValue(0), 0, qieCoder, qieShape)
83  : pedestalEndcapValues[i].getValue(0);
84  values_[off * 4 + 1] = unitIsADC ? convert(pedestalEndcapValues[i].getValue(1), 1, qieCoder, qieShape)
85  : pedestalEndcapValues[i].getValue(1);
86  values_[off * 4 + 2] = unitIsADC ? convert(pedestalEndcapValues[i].getValue(2), 2, qieCoder, qieShape)
87  : pedestalEndcapValues[i].getValue(2);
88  values_[off * 4 + 3] = unitIsADC ? convert(pedestalEndcapValues[i].getValue(3), 3, qieCoder, qieShape)
89  : pedestalEndcapValues[i].getValue(3);
90 
91 #ifdef HCAL_MAHI_CPUDEBUG
92  if (pedestalEndcapValues[i].rawId() == DETID_TO_DEBUG) {
93  printf("qietype = %d\n", qieType);
94  printf("ped0 = %f ped1 = %f ped2 = %f ped3 = %f\n",
95  pedestalEndcapValues[i].getValue(0),
96  pedestalEndcapValues[i].getValue(1),
97  pedestalEndcapValues[i].getValue(2),
98  pedestalEndcapValues[i].getValue(3));
99  printf("converted: ped0 = %f ped1 = %f ped2 = %f ped3 = %f\n",
100  values_[off * 4],
101  values_[off * 4 + 1],
102  values_[off * 4 + 2],
103  values_[off * 4 + 3]);
104  }
105 #endif
106  }
107 }

References HcalCondObjectContainer< Item >::getAllContainers().

◆ ~HcalConvertedPedestalsGPU()

HcalConvertedPedestalsGPU::~HcalConvertedPedestalsGPU ( )
default

Member Function Documentation

◆ getProduct()

HcalConvertedPedestalsGPU::Product const & HcalConvertedPedestalsGPU::getProduct ( cudaStream_t  stream) const

Definition at line 109 of file HcalConvertedPedestalsGPU.cc.

109  {
110  auto const& product = product_.dataForCurrentDeviceAsync(
111  stream, [this](HcalConvertedPedestalsGPU::Product& product, cudaStream_t stream) {
112  // allocate
113  product.values = cms::cuda::make_device_unique<float[]>(values_.size(), stream);
114 
115  // transfer
117  });
118 
119  return product;
120 }

References cms::cuda::copyAsync(), product_, cms::cuda::stream, HcalConvertedPedestalsGPU::Product::values, and values_.

Referenced by HBHERecHitProducerGPU::acquire().

◆ offsetForHashes()

uint32_t HcalConvertedPedestalsGPU::offsetForHashes ( ) const
inline

Definition at line 31 of file HcalConvertedPedestalsGPU.h.

31 { return offsetForHashes_; }

References offsetForHashes_.

Referenced by HBHERecHitProducerGPU::acquire().

Member Data Documentation

◆ offsetForHashes_

uint32_t HcalConvertedPedestalsGPU::offsetForHashes_
protected

Definition at line 35 of file HcalConvertedPedestalsGPU.h.

Referenced by offsetForHashes().

◆ product_

cms::cuda::ESProduct<Product> HcalConvertedPedestalsGPU::product_
protected

Definition at line 38 of file HcalConvertedPedestalsGPU.h.

Referenced by getProduct().

◆ totalChannels_

uint64_t HcalConvertedPedestalsGPU::totalChannels_
protected

Definition at line 34 of file HcalConvertedPedestalsGPU.h.

◆ values_

std::vector<float, cms::cuda::HostAllocator<float> > HcalConvertedPedestalsGPU::values_
protected

Definition at line 36 of file HcalConvertedPedestalsGPU.h.

Referenced by getProduct().

mps_fire.i
i
Definition: mps_fire.py:428
HcalConvertedPedestalsGPU::values_
std::vector< float, cms::cuda::HostAllocator< float > > values_
Definition: HcalConvertedPedestalsGPU.h:36
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalConvertedPedestalsGPU::Product
Definition: HcalConvertedPedestalsGPU.h:17
cms::cuda::assert
assert(be >=bs)
HcalConvertedPedestalsGPU::product_
cms::cuda::ESProduct< Product > product_
Definition: HcalConvertedPedestalsGPU.h:38
HcalConvertedPedestalsGPU::Product::values
edm::propagate_const_array< cms::cuda::device::unique_ptr< float[]> > values
Definition: HcalConvertedPedestalsGPU.h:18
fileCollector.convert
def convert(infile, ofile)
Definition: fileCollector.py:47
reco::JetExtendedAssociation::getValue
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
Definition: JetExtendedAssociation.cc:50
HcalConvertedPedestalsGPU::totalChannels_
uint64_t totalChannels_
Definition: HcalConvertedPedestalsGPU.h:34
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
HcalConvertedPedestalsGPU::offsetForHashes_
uint32_t offsetForHashes_
Definition: HcalConvertedPedestalsGPU.h:35
cms::cuda::copyAsync
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20