Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CondFormats/HcalObjects/interface/HcalChannelQualityGPU.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef CondFormats_HcalObjects_interface_HcalChannelQualityGPU_h
#define CondFormats_HcalObjects_interface_HcalChannelQualityGPU_h

#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

class HcalChannelQualityGPU {
public:
struct Product {
edm::propagate_const_array<cms::cuda::device::unique_ptr<uint32_t[]>> status;
};

#ifndef __CUDACC__
// rearrange reco params
HcalChannelQualityGPU(HcalChannelQuality const &);

// will trigger deallocation of Product thru ~Product
~HcalChannelQualityGPU() = default;

// get device pointers
Product const &getProduct(cudaStream_t) const;

private:
uint64_t totalChannels_;
std::vector<uint32_t, cms::cuda::HostAllocator<uint32_t>> status_;

cms::cuda::ESProduct<Product> product_;
#endif // __CUDACC__
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the (maybe) naive question, but should this object be COND_SERIALIZABLE ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariadalfonso @fwyzard please have a look at this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CondFormats/HcalObjects/interface/HcalChannelQuality.h is already COND_SERIALIZABLE
HcalChannelQualityGPU.h is not, but usually include the main .h
This is a common pattern for all conditions if need to do this change should be done in synch for all ECAL/HCAL/TRK ... and outside of this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I don't think these conditions need to be declared COND_SERIALIZABLE.
They are never persisted or read from the database - they are only transient conditions, derived from the persistent ones and "repackaged" for use on GPUs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks for the explanation @mariadalfonso and @fwyzard, makes sense!



#endif // RecoLocalCalo_HcalRecAlgos_interface_HcalChannelQualityGPU_h
40 changes: 40 additions & 0 deletions CondFormats/HcalObjects/src/HcalChannelQualityGPU.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
#include "CondFormats/HcalObjects/interface/HcalChannelQualityGPU.h"
#include "FWCore/Utilities/interface/typelookup.h"
#include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"

// FIXME: add proper getters to conditions
HcalChannelQualityGPU::HcalChannelQualityGPU(HcalChannelQuality const& quality)
: totalChannels_{quality.getAllContainers()[0].second.size() + quality.getAllContainers()[1].second.size()},
status_(totalChannels_) {
auto const containers = quality.getAllContainers();

// fill in eb
auto const& barrelValues = containers[0].second;
for (uint64_t i = 0; i < barrelValues.size(); ++i) {
status_[i] = barrelValues[i].getValue();
}

// fill in ee
auto const& endcapValues = containers[1].second;
auto const offset = barrelValues.size();
for (uint64_t i = 0; i < endcapValues.size(); ++i) {
status_[i + offset] = endcapValues[i].getValue();
}
}

HcalChannelQualityGPU::Product const& HcalChannelQualityGPU::getProduct(cudaStream_t stream) const {
auto const& product =
product_.dataForCurrentDeviceAsync(stream, [this](HcalChannelQualityGPU::Product& product, cudaStream_t stream) {
// allocate
product.status = cms::cuda::make_device_unique<uint32_t[]>(status_.size(), stream);

// transfer
cms::cuda::copyAsync(product.status, status_, stream);

});

return product;
}

TYPELOOKUP_DATA_REG(HcalChannelQualityGPU);
1 change: 1 addition & 0 deletions HLTrigger/Configuration/python/customizeHLTforPatatrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def customiseHcalLocalReconstruction(process):

process.load("EventFilter.HcalRawToDigi.hcalElectronicsMappingGPUESProducer_cfi")

process.load("RecoLocalCalo.HcalRecProducers.hcalChannelQualityGPUESProducer_cfi")
process.load("RecoLocalCalo.HcalRecProducers.hcalGainsGPUESProducer_cfi")
process.load("RecoLocalCalo.HcalRecProducers.hcalGainWidthsGPUESProducer_cfi")
process.load("RecoLocalCalo.HcalRecProducers.hcalLUTCorrsGPUESProducer_cfi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
hcalConvertedEffectivePedestalWidthsGPUESProducer.label0 = "withTopoEff"
hcalConvertedEffectivePedestalWidthsGPUESProducer.label1 = "withTopoEff"

from RecoLocalCalo.HcalRecProducers.hcalChannelQualityGPUESProducer_cfi import hcalChannelQualityGPUESProducer
from RecoLocalCalo.HcalRecProducers.hcalQIECodersGPUESProducer_cfi import hcalQIECodersGPUESProducer
from RecoLocalCalo.HcalRecProducers.hcalRecoParamsWithPulseShapesGPUESProducer_cfi import hcalRecoParamsWithPulseShapesGPUESProducer
from RecoLocalCalo.HcalRecProducers.hcalRespCorrsGPUESProducer_cfi import hcalRespCorrsGPUESProducer
Expand Down Expand Up @@ -50,6 +51,7 @@
hcalConvertedEffectivePedestalsGPUESProducer,
hcalConvertedPedestalWidthsGPUESProducer,
hcalConvertedEffectivePedestalWidthsGPUESProducer,
hcalChannelQualityGPUESProducer,
hcalQIECodersGPUESProducer,
hcalRecoParamsWithPulseShapesGPUESProducer,
hcalRespCorrsGPUESProducer,
Expand Down
4 changes: 4 additions & 0 deletions RecoLocalCalo/HcalRecProducers/src/DeclsForKernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <functional>
#include <optional>

#include "CondFormats/HcalObjects/interface/HcalChannelStatus.h"
#include "CUDADataFormats/HcalDigi/interface/DigiCollection.h"
#include "CUDADataFormats/HcalRecHitSoA/interface/RecHitCollection.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
Expand All @@ -18,6 +19,7 @@
#include "CondFormats/DataRecord/interface/HcalSiPMCharacteristicsRcd.h"
#include "CondFormats/DataRecord/interface/HcalSiPMParametersRcd.h"
#include "CondFormats/DataRecord/interface/HcalTimeCorrsRcd.h"
#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
#include "CondFormats/HcalObjects/interface/HcalConvertedEffectivePedestalWidthsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalConvertedEffectivePedestalsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalGainWidthsGPU.h"
Expand All @@ -30,6 +32,7 @@
#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalSiPMParametersGPU.h"
#include "CondFormats/HcalObjects/interface/HcalTimeCorrsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalChannelQualityGPU.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
Expand All @@ -49,6 +52,7 @@ namespace hcal {
HcalConvertedEffectivePedestalWidthsGPU::Product const& effectivePedestalWidths;
HcalConvertedPedestalsGPU::Product const& pedestals;
HcalQIECodersGPU::Product const& qieCoders;
HcalChannelQualityGPU::Product const& channelQuality;
HcalRecoParamsWithPulseShapesGPU::Product const& recoParams;
HcalRespCorrsGPU::Product const& respCorrs;
HcalTimeCorrsGPU::Product const& timeCorrs;
Expand Down
5 changes: 5 additions & 0 deletions RecoLocalCalo/HcalRecProducers/src/HBHERecHitProducerGPU.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ void HBHERecHitProducerGPU::acquire(edm::Event const& event,
edm::ESHandle<HcalDDDRecConstants> recConstantsHandle;
setup.get<HcalRecNumberingRecord>().get(recConstantsHandle);

edm::ESHandle<HcalChannelQualityGPU> qualHandle;
setup.get<HcalChannelQualityRcd>().get(qualHandle);
auto const& chQualProduct = qualHandle->getProduct(ctx.stream());

edm::ESHandle<HcalSiPMParametersGPU> sipmParametersHandle;
setup.get<HcalSiPMParametersRcd>().get(sipmParametersHandle);
auto const& sipmParametersProduct = sipmParametersHandle->getProduct(ctx.stream());
Expand All @@ -195,6 +199,7 @@ void HBHERecHitProducerGPU::acquire(edm::Event const& event,
effectivePedestalWidthsProduct,
pedestalsProduct,
qieCodersProduct,
chQualProduct,
recoParamsProduct,
respCorrsProduct,
timeCorrsProduct,
Expand Down
6 changes: 6 additions & 0 deletions RecoLocalCalo/HcalRecProducers/src/HcalESProducersGPUDefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "CondFormats/HcalObjects/interface/HcalRecoParamsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
#include "CondFormats/HcalObjects/interface/HcalRespCorrsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
#include "CondFormats/HcalObjects/interface/HcalChannelQualityGPU.h"
#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristics.h"
#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsGPU.h"
#include "CondFormats/HcalObjects/interface/HcalSiPMParameters.h"
Expand Down Expand Up @@ -65,6 +68,8 @@ using HcalGainWidthsGPUESProducer = ConvertingESProducerT<HcalGainWidthsRcd, Hca

using HcalQIECodersGPUESProducer = ConvertingESProducerT<HcalQIEDataRcd, HcalQIECodersGPU, HcalQIEData>;

using HcalChannelQualityGPUESProducer = ConvertingESProducerT<HcalChannelQualityRcd, HcalChannelQualityGPU, HcalChannelQuality>;

using HcalQIETypesGPUESProducer = ConvertingESProducerT<HcalQIETypesRcd, HcalQIETypesGPU, HcalQIETypes>;

using HcalSiPMParametersGPUESProducer =
Expand Down Expand Up @@ -111,6 +116,7 @@ DEFINE_FWK_EVENTSETUP_MODULE(HcalTimeCorrsGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalPedestalWidthsGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalGainWidthsGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalQIECodersGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalChannelQualityGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalQIETypesGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalSiPMParametersGPUESProducer);
DEFINE_FWK_EVENTSETUP_MODULE(HcalSiPMCharacteristicsGPUESProducer);
Expand Down
15 changes: 14 additions & 1 deletion RecoLocalCalo/HcalRecProducers/src/MahiGPU.cu
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ namespace hcal {
float* method0Time,
uint32_t* outputdid,
uint32_t const nchannels,
uint32_t const* qualityStatus,
uint32_t const* recoParam1Values,
uint32_t const* recoParam2Values,
float const* qieCoderOffsets,
Expand Down Expand Up @@ -389,6 +390,17 @@ namespace hcal {
printf("tsTOT = %f tstrig = %f ts4Thresh = %f\n", shrEnergyM0TotalAccum[lch], energym0_per_ts_gain0, ts4Thresh);
#endif

// Channel quality check
// https://github.com/cms-sw/cmssw/blob/master/RecoLocalCalo/HcalRecAlgos/plugins/HcalChannelPropertiesEP.cc#L107-L109
// https://github.com/cms-sw/cmssw/blob/6d2f66057131baacc2fcbdd203588c41c885b42c/CondCore/HcalPlugins/plugins/HcalChannelQuality_PayloadInspector.cc#L30
// const bool taggedBadByDb = severity.dropChannel(digistatus->getValue());
// do not run MAHI if taggedBadByDb = true

auto const digiStatus_ = qualityStatus[hashedId];
const bool taggedBadByDb = (digiStatus_/32770);

if(taggedBadByDb) outputChi2[gch] = -9999.f;

// check as in cpu version if mahi is not needed
// FIXME: KNOWN ISSUE: observed a problem when rawCharge and pedestal
// are basically equal and generate -0.00000...
Expand Down Expand Up @@ -418,7 +430,7 @@ namespace hcal {

#ifdef HCAL_MAHI_GPUDEBUG
printf(
"charrge(%d) = %f pedestal(%d) = %f dfc(%d) = %f pedestalWidth(%d) = %f noiseADC(%d) = %f noisPhoto(%d) = "
"charge(%d) = %f pedestal(%d) = %f dfc(%d) = %f pedestalWidth(%d) = %f noiseADC(%d) = %f noisPhoto(%d) = "
"%f\n",
sample,
rawCharge,
Expand Down Expand Up @@ -1100,6 +1112,7 @@ namespace hcal {
outputGPU.recHits.timeM0.get(),
outputGPU.recHits.did.get(),
totalChannels,
conditions.channelQuality.status,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like an odd choice by the code-format

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has a tab instead of eight spaces

conditions.recoParams.param1,
conditions.recoParams.param2,
conditions.qieCoders.offsets,
Expand Down