Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-05 02:13:41

0001 #ifndef RecoLocalCalo_HcalRecProducers_src_DeclsForKernels_h
0002 #define RecoLocalCalo_HcalRecProducers_src_DeclsForKernels_h
0003 
0004 #include <functional>
0005 #include <optional>
0006 
0007 #include "CondFormats/HcalObjects/interface/HcalChannelStatus.h"
0008 #include "CUDADataFormats/HcalDigi/interface/DigiCollection.h"
0009 #include "CUDADataFormats/HcalRecHitSoA/interface/RecHitCollection.h"
0010 #include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
0011 #include "CondFormats/DataRecord/interface/HcalCombinedRecordsGPU.h"
0012 #include "CondFormats/DataRecord/interface/HcalGainWidthsRcd.h"
0013 #include "CondFormats/DataRecord/interface/HcalGainsRcd.h"
0014 #include "CondFormats/DataRecord/interface/HcalLUTCorrsRcd.h"
0015 #include "CondFormats/DataRecord/interface/HcalQIEDataRcd.h"
0016 #include "CondFormats/DataRecord/interface/HcalQIETypesRcd.h"
0017 #include "CondFormats/DataRecord/interface/HcalRecoParamsRcd.h"
0018 #include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
0019 #include "CondFormats/DataRecord/interface/HcalSiPMCharacteristicsRcd.h"
0020 #include "CondFormats/DataRecord/interface/HcalSiPMParametersRcd.h"
0021 #include "CondFormats/DataRecord/interface/HcalTimeCorrsRcd.h"
0022 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
0023 #include "CondFormats/HcalObjects/interface/HcalConvertedEffectivePedestalWidthsGPU.h"
0024 #include "CondFormats/HcalObjects/interface/HcalConvertedEffectivePedestalsGPU.h"
0025 #include "CondFormats/HcalObjects/interface/HcalGainWidthsGPU.h"
0026 #include "CondFormats/HcalObjects/interface/HcalGainsGPU.h"
0027 #include "CondFormats/HcalObjects/interface/HcalLUTCorrsGPU.h"
0028 #include "CondFormats/HcalObjects/interface/HcalQIECodersGPU.h"
0029 #include "CondFormats/HcalObjects/interface/HcalQIETypesGPU.h"
0030 #include "CondFormats/HcalObjects/interface/HcalRecoParamsGPU.h"
0031 #include "CondFormats/HcalObjects/interface/HcalRespCorrsGPU.h"
0032 #include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsGPU.h"
0033 #include "CondFormats/HcalObjects/interface/HcalSiPMParametersGPU.h"
0034 #include "CondFormats/HcalObjects/interface/HcalTimeCorrsGPU.h"
0035 #include "CondFormats/HcalObjects/interface/HcalChannelQualityGPU.h"
0036 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0037 #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
0038 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0039 #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
0040 #include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
0041 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalMahiPulseOffsetsGPU.h"
0042 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalRecoParamsWithPulseShapesGPU.h"
0043 
0044 namespace hcal {
0045   namespace reconstruction {
0046 
0047     struct ConditionsProducts {
0048       HcalGainWidthsGPU::Product const& gainWidths;
0049       HcalGainsGPU::Product const& gains;
0050       HcalLUTCorrsGPU::Product const& lutCorrs;
0051       HcalConvertedPedestalWidthsGPU::Product const& pedestalWidths;
0052       HcalConvertedEffectivePedestalWidthsGPU::Product const& effectivePedestalWidths;
0053       HcalConvertedPedestalsGPU::Product const& pedestals;
0054       HcalQIECodersGPU::Product const& qieCoders;
0055       HcalChannelQualityGPU::Product const& channelQuality;
0056       HcalRecoParamsWithPulseShapesGPU::Product const& recoParams;
0057       HcalRespCorrsGPU::Product const& respCorrs;
0058       HcalTimeCorrsGPU::Product const& timeCorrs;
0059       HcalQIETypesGPU::Product const& qieTypes;
0060       HcalSiPMParametersGPU::Product const& sipmParameters;
0061       HcalSiPMCharacteristicsGPU::Product const& sipmCharacteristics;
0062       HcalConvertedPedestalsGPU::Product const* convertedEffectivePedestals;
0063       HcalTopology const* topology;
0064       HcalDDDRecConstants const* recConstants;
0065       uint32_t offsetForHashes;
0066       HcalMahiPulseOffsetsGPU::Product const& pulseOffsets;
0067       std::vector<int, cms::cuda::HostAllocator<int>> const& pulseOffsetsHost;
0068     };
0069 
0070     struct ConfigParameters {
0071       uint32_t maxTimeSamples;
0072       uint32_t kprep1dChannelsPerBlock;
0073       int sipmQTSShift;
0074       int sipmQNTStoSum;
0075       int firstSampleShift;
0076       bool useEffectivePedestals;
0077 
0078       float meanTime;
0079       float timeSigmaSiPM, timeSigmaHPD;
0080       float ts4Thresh;
0081 
0082       std::array<uint32_t, 3> kernelMinimizeThreads;
0083 
0084       // FIXME:
0085       //   - add "getters" to HcalTimeSlew calib formats
0086       //   - add ES Producer to consume what is produced above not to replicate.
0087       //   which ones to use is hardcoded, therefore no need to send those to the device
0088       bool applyTimeSlew;
0089       float tzeroTimeSlew, slopeTimeSlew, tmaxTimeSlew;
0090     };
0091 
0092     struct OutputDataGPU {
0093       RecHitCollection<::calo::common::DevStoragePolicy> recHits;
0094 
0095       void allocate(ConfigParameters const& config, uint32_t size, cudaStream_t cudaStream) {
0096         recHits.energy = cms::cuda::make_device_unique<float[]>(size, cudaStream);
0097         recHits.chi2 = cms::cuda::make_device_unique<float[]>(size, cudaStream);
0098         recHits.energyM0 = cms::cuda::make_device_unique<float[]>(size, cudaStream);
0099         recHits.timeM0 = cms::cuda::make_device_unique<float[]>(size, cudaStream);
0100         recHits.did = cms::cuda::make_device_unique<uint32_t[]>(size, cudaStream);
0101       }
0102     };
0103 
0104     struct ScratchDataGPU {
0105       cms::cuda::device::unique_ptr<float[]> amplitudes, noiseTerms, electronicNoiseTerms, pulseMatrices,
0106           pulseMatricesM, pulseMatricesP;
0107       cms::cuda::device::unique_ptr<int8_t[]> soiSamples;
0108     };
0109 
0110     struct InputDataGPU {
0111       DigiCollection<Flavor1, ::calo::common::DevStoragePolicy> const& f01HEDigis;
0112       DigiCollection<Flavor5, ::calo::common::DevStoragePolicy> const& f5HBDigis;
0113       DigiCollection<Flavor3, ::calo::common::DevStoragePolicy> const& f3HBDigis;
0114     };
0115 
0116   }  // namespace reconstruction
0117 }  // namespace hcal
0118 
0119 #endif  // RecoLocalCalo_HcalRecProducers_src_DeclsForKernels_h