Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCAL local reconstruction in Alpaka [14.0.x] #45324

Merged
merged 1 commit into from
Jul 3, 2024
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
35 changes: 35 additions & 0 deletions CondFormats/DataRecord/interface/HcalMahiConditionsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef CondFormats_DataRecord_HcalMahiConditionsRcd_h
#define CondFormats_DataRecord_HcalMahiConditionsRcd_h

#include "FWCore/Framework/interface/DependentRecordImplementation.h"

#include "CondFormats/DataRecord/interface/HcalRecoParamsRcd.h"
#include "CondFormats/DataRecord/interface/HcalPedestalsRcd.h"
#include "CondFormats/DataRecord/interface/HcalGainsRcd.h"
#include "CondFormats/DataRecord/interface/HcalLUTCorrsRcd.h"
#include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
#include "CondFormats/DataRecord/interface/HcalTimeCorrsRcd.h"
#include "CondFormats/DataRecord/interface/HcalPedestalWidthsRcd.h"
#include "CondFormats/DataRecord/interface/HcalGainWidthsRcd.h"
#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
#include "CondFormats/DataRecord/interface/HcalQIETypesRcd.h"
#include "CondFormats/DataRecord/interface/HcalQIEDataRcd.h"
#include "CondFormats/DataRecord/interface/HcalSiPMParametersRcd.h"
#include "Geometry/Records/interface/HcalRecNumberingRecord.h"

class HcalMahiConditionsRcd
: public edm::eventsetup::DependentRecordImplementation<HcalMahiConditionsRcd,
edm::mpl::Vector<HcalRecoParamsRcd,
HcalPedestalsRcd,
HcalGainsRcd,
HcalLUTCorrsRcd,
HcalRespCorrsRcd,
HcalTimeCorrsRcd,
HcalPedestalWidthsRcd,
HcalGainWidthsRcd,
HcalChannelQualityRcd,
HcalQIETypesRcd,
HcalQIEDataRcd,
HcalSiPMParametersRcd,
HcalRecNumberingRecord>> {};
#endif
4 changes: 4 additions & 0 deletions CondFormats/DataRecord/src/HcalMahiConditionsRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/DataRecord/interface/HcalMahiConditionsRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(HcalMahiConditionsRcd);
5 changes: 5 additions & 0 deletions CondFormats/HcalObjects/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
</ifrelease>
<use name="boost_serialization"/>
<use name="CondFormats/Serialization"/>
<use name="DataFormats/Portable"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/HcalDetId"/>
<use name="DataFormats/SoATemplate"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/Utilities"/>
<use name="Geometry/CaloTopology"/>
<use name="HeterogeneousCore/CUDACore"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
<use name="HeterogeneousCore/AlpakaCore"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
</export>
11 changes: 11 additions & 0 deletions CondFormats/HcalObjects/interface/HcalMahiConditionsHost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef CondFormats_HcalObjects_interface_HcalMahiConditionsHost_h
#define CondFormats_HcalObjects_interface_HcalMahiConditionsHost_h

#include "CondFormats/HcalObjects/interface/HcalMahiConditionsSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace hcal {
using HcalMahiConditionsPortableHost = PortableHostCollection<HcalMahiConditionsSoA>;
}

#endif
71 changes: 71 additions & 0 deletions CondFormats/HcalObjects/interface/HcalMahiConditionsSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef CondFormats_HcalObjects_HcalMahiConditionsSoA_h
#define CondFormats_HcalObjects_HcalMahiConditionsSoA_h

#include "RecoLocalCalo/HcalRecAlgos/interface/HcalConstants.h"

#include "DataFormats/SoATemplate/interface/SoACommon.h"
#include "DataFormats/SoATemplate/interface/SoALayout.h"
#include "DataFormats/SoATemplate/interface/SoAView.h"

#include <array>

namespace hcal {

static constexpr uint32_t numValuesPerChannel = 16;
using HcalPedestalArray = std::array<float, 4>; // 4 capIds
using HcalQIECodersArray = std::array<float, numValuesPerChannel>; // QIEData

GENERATE_SOA_LAYOUT(HcalMahiConditionsSoALayout,
SOA_COLUMN(HcalPedestalArray, pedestals_value),
SOA_COLUMN(HcalPedestalArray, pedestals_width),
SOA_COLUMN(HcalPedestalArray, gains_value),
SOA_COLUMN(HcalPedestalArray, effectivePedestals),
SOA_COLUMN(HcalPedestalArray, effectivePedestalWidths),
SOA_COLUMN(float, lutCorrs_values),
SOA_COLUMN(float, respCorrs_values),
SOA_COLUMN(float, timeCorrs_values),
// Use EIGEN_COLUMN for matrix?
SOA_COLUMN(float, pedestalWidths_sigma00),
SOA_COLUMN(float, pedestalWidths_sigma01),
SOA_COLUMN(float, pedestalWidths_sigma02),
SOA_COLUMN(float, pedestalWidths_sigma03),
SOA_COLUMN(float, pedestalWidths_sigma10),
SOA_COLUMN(float, pedestalWidths_sigma11),
SOA_COLUMN(float, pedestalWidths_sigma12),
SOA_COLUMN(float, pedestalWidths_sigma13),
SOA_COLUMN(float, pedestalWidths_sigma20),
SOA_COLUMN(float, pedestalWidths_sigma21),
SOA_COLUMN(float, pedestalWidths_sigma22),
SOA_COLUMN(float, pedestalWidths_sigma23),
SOA_COLUMN(float, pedestalWidths_sigma30),
SOA_COLUMN(float, pedestalWidths_sigma31),
SOA_COLUMN(float, pedestalWidths_sigma32),
SOA_COLUMN(float, pedestalWidths_sigma33),
SOA_COLUMN(float, gainWidths_value0),
SOA_COLUMN(float, gainWidths_value1),
SOA_COLUMN(float, gainWidths_value2),
SOA_COLUMN(float, gainWidths_value3),
SOA_COLUMN(uint32_t, channelQuality_status),
SOA_COLUMN(HcalQIECodersArray, qieCoders_offsets),
SOA_COLUMN(HcalQIECodersArray, qieCoders_slopes),
SOA_COLUMN(int, qieTypes_values),
SOA_COLUMN(int, sipmPar_type),
SOA_COLUMN(int, sipmPar_auxi1),
SOA_COLUMN(float, sipmPar_fcByPE),
SOA_COLUMN(float, sipmPar_darkCurrent),
SOA_COLUMN(float, sipmPar_auxi2),
SOA_SCALAR(int, maxDepthHB),
SOA_SCALAR(int, maxDepthHE),
SOA_SCALAR(int, maxPhiHE),
SOA_SCALAR(int, firstHBRing),
SOA_SCALAR(int, lastHBRing),
SOA_SCALAR(int, firstHERing),
SOA_SCALAR(int, lastHERing),
SOA_SCALAR(int, nEtaHB),
SOA_SCALAR(int, nEtaHE),
SOA_SCALAR(uint32_t, offsetForHashes))
using HcalMahiConditionsSoA = HcalMahiConditionsSoALayout<>;

} // namespace hcal

#endif
10 changes: 10 additions & 0 deletions CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsHost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef CondFormats_HcalObjects_interface_HcalMahiPulseOffsetsPortable_h
#define CondFormats_HcalObjects_interface_HcalMahiPulseOffsetsPortable_h

#include "CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace hcal {
using HcalMahiPulseOffsetsPortableHost = PortableHostCollection<HcalMahiPulseOffsetsSoA>;
}
#endif
13 changes: 13 additions & 0 deletions CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CondFormats_HcalObjects_HcalMahiPulseOffsetsSoA_h
#define CondFormats_HcalObjects_HcalMahiPulseOffsetsSoA_h

#include "DataFormats/SoATemplate/interface/SoACommon.h"
#include "DataFormats/SoATemplate/interface/SoALayout.h"
#include "DataFormats/SoATemplate/interface/SoAView.h"

namespace hcal {
GENERATE_SOA_LAYOUT(HcalMahiPulseOffsetsSoALayout, SOA_COLUMN(int, offsets))
using HcalMahiPulseOffsetsSoA = HcalMahiPulseOffsetsSoALayout<>;

} // namespace hcal
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHost_h
#define CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHost_h

#include "CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeT.h"
#include "DataFormats/Portable/interface/PortableCollection.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace hcal {
using HcalRecoParamWithPulseShapeHost = HcalRecoParamWithPulseShapeT<alpaka::DevCpu>;
}
namespace cms::alpakatools {
template <>
struct CopyToDevice<::hcal::HcalRecoParamWithPulseShapeHost> {
template <typename TQueue>
static auto copyAsync(TQueue& queue, ::hcal::HcalRecoParamWithPulseShapeHost const& hostProduct) {
using RecoParamCopy = CopyToDevice<::hcal::HcalRecoParamWithPulseShapeHost::RecoParamCollection>;
using PulseShapeCopy = CopyToDevice<::hcal::HcalRecoParamWithPulseShapeHost::PulseShapeCollection>;
using Device = alpaka::Dev<TQueue>;
return ::hcal::HcalRecoParamWithPulseShapeT<Device>(RecoParamCopy::copyAsync(queue, hostProduct.recoParam()),
PulseShapeCopy::copyAsync(queue, hostProduct.pulseShape()));
}
};
} // namespace cms::alpakatools

#endif
31 changes: 31 additions & 0 deletions CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef CondFormats_HcalObjects_HcalRecoParamWithPulseShapeSoA_h
#define CondFormats_HcalObjects_HcalRecoParamWithPulseShapeSoA_h

#include "RecoLocalCalo/HcalRecAlgos/interface/HcalConstants.h"

#include "DataFormats/SoATemplate/interface/SoACommon.h"
#include "DataFormats/SoATemplate/interface/SoALayout.h"
#include "DataFormats/SoATemplate/interface/SoAView.h"

#include <array>

namespace hcal {
using HcalPSfunctorArray = std::array<float, hcal::constants::maxPSshapeBin>; // 256
using HcalPSfunctorBXarray = std::array<float, hcal::constants::nsPerBX>; // 25

GENERATE_SOA_LAYOUT(HcalRecoParamSoALayout,
SOA_COLUMN(uint32_t, param1),
SOA_COLUMN(uint32_t, param2),
SOA_COLUMN(uint32_t, ids))
GENERATE_SOA_LAYOUT(HcalPulseShapeSoALayout,
SOA_COLUMN(HcalPSfunctorArray, acc25nsVec),
SOA_COLUMN(HcalPSfunctorArray, diff25nsItvlVec),
SOA_COLUMN(HcalPSfunctorBXarray, accVarLenIdxMinusOneVec),
SOA_COLUMN(HcalPSfunctorBXarray, diffVarItvlIdxMinusOneVec),
SOA_COLUMN(HcalPSfunctorBXarray, accVarLenIdxZEROVec),
SOA_COLUMN(HcalPSfunctorBXarray, diffVarItvlIdxZEROVec))

using HcalRecoParamSoA = HcalRecoParamSoALayout<>;
using HcalPulseShapeSoA = HcalPulseShapeSoALayout<>;
} // namespace hcal
#endif
57 changes: 57 additions & 0 deletions CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHostT_h
#define CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHostT_h

#include "CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeSoA.h"
#include "DataFormats/Portable/interface/PortableCollection.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace hcal {
template <typename TDev>
class HcalRecoParamWithPulseShapeT {
public:
using RecoParamCollection = PortableCollection<HcalRecoParamSoA, TDev>;
using PulseShapeCollection = PortableCollection<HcalPulseShapeSoA, TDev>;

using PulseShapeConstElement = typename PulseShapeCollection::ConstView::const_element;

class ConstView {
public:
using RecoParamConstView = typename RecoParamCollection::ConstView;
using PulseShapeConstView = typename PulseShapeCollection::ConstView;
constexpr ConstView(RecoParamConstView recoView, PulseShapeConstView psView)
: recoParamView_{recoView}, pulseShapeView_{psView} {};

ALPAKA_FN_ACC PulseShapeConstElement getPulseShape(uint32_t const hashedId) const {
auto const recoPulseShapeId = recoParamView_.ids()[hashedId];
return pulseShapeView_[recoPulseShapeId];
}

constexpr typename RecoParamCollection::ConstView recoParamView() { return recoParamView_; }

private:
typename RecoParamCollection::ConstView recoParamView_;
typename PulseShapeCollection::ConstView pulseShapeView_;
};

HcalRecoParamWithPulseShapeT(size_t recoSize, size_t pulseSize, TDev const& dev)
: recoParam_(recoSize, dev), pulseShape_(pulseSize, dev) {}
template <typename TQueue, typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
HcalRecoParamWithPulseShapeT(size_t recoSize, size_t pulseSize, TQueue const& queue)
: recoParam_(recoSize, queue), pulseShape_(pulseSize, queue) {}
HcalRecoParamWithPulseShapeT(RecoParamCollection reco, PulseShapeCollection pulse)
: recoParam_(std::move(reco)), pulseShape_(std::move(pulse)) {}

const RecoParamCollection& recoParam() const { return recoParam_; }
const PulseShapeCollection& pulseShape() const { return pulseShape_; }

typename RecoParamCollection::View recoParamView() { return recoParam_.view(); }
typename PulseShapeCollection::View pulseShapeView() { return pulseShape_.view(); }

ConstView const_view() const { return ConstView(recoParam_.view(), pulseShape_.view()); }

private:
RecoParamCollection recoParam_;
PulseShapeCollection pulseShape_;
};
} // namespace hcal
#endif
12 changes: 12 additions & 0 deletions CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsHost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef CondFormats_HcalObjects_interface_HcalSiPMCharacteristicsPortable_h
#define CondFormats_HcalObjects_interface_HcalSiPMCharacteristicsPortable_h

#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"

namespace hcal {
using HcalSiPMCharacteristicsPortableHost = PortableHostCollection<HcalSiPMCharacteristicsSoA>;
}
#endif
15 changes: 15 additions & 0 deletions CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef CondFormats_HcalObjects_HcalSiPMCharacteristicsSoA_h
#define CondFormats_HcalObjects_HcalSiPMCharacteristicsSoA_h

#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristics.h"

#include "DataFormats/SoATemplate/interface/SoACommon.h"
#include "DataFormats/SoATemplate/interface/SoALayout.h"
#include "DataFormats/SoATemplate/interface/SoAView.h"

namespace hcal {
GENERATE_SOA_LAYOUT(HcalSiPMCharacteristicsSoALayout,
SOA_COLUMN(HcalSiPMCharacteristics::PrecisionItem, precisionItem))
using HcalSiPMCharacteristicsSoA = HcalSiPMCharacteristicsSoALayout<>;
} // namespace hcal
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef CondFormats_HcalObjects_interface_alpaka_HcalMahiConditionsDevice_h
#define CondFormats_HcalObjects_interface_alpaka_HcalMahiConditionsDevice_h

#include "CondFormats/HcalObjects/interface/HcalMahiConditionsHost.h"
#include "CondFormats/HcalObjects/interface/HcalMahiConditionsSoA.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

namespace hcal {

using ::hcal::HcalMahiConditionsPortableHost;
using HcalMahiConditionsPortableDevice = PortableCollection<::hcal::HcalMahiConditionsSoA>;
} // namespace hcal

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef CondFormats_HcalObjects_interface_alpaka_HcalMahiPulseOffsetsPortable_h
#define CondFormats_HcalObjects_interface_alpaka_HcalMahiPulseOffsetsPortable_h

#include "CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsHost.h"
#include "CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsSoA.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

namespace hcal {
using ::hcal::HcalMahiPulseOffsetsPortableHost;
using HcalMahiPulseOffsetsPortableDevice = PortableCollection<::hcal::HcalMahiPulseOffsetsSoA>;

} // namespace hcal

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CondFormats_HcalObjects_interface_alpaka_HcalRecoParamWithPulseShapeDevice_h
#define CondFormats_HcalObjects_interface_alpaka_HcalRecoParamWithPulseShapeDevice_h

#include "CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeT.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {
namespace hcal {
using HcalRecoParamWithPulseShapeDevice = ::hcal::HcalRecoParamWithPulseShapeT<Device>;
}
} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CondFormats_HcalObjects_interface_alpaka_HcalSiPMCharacteristicsPortable_h
#define CondFormats_HcalObjects_interface_alpaka_HcalSiPMCharacteristicsPortable_h

#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsHost.h"
#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsSoA.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

namespace hcal {
using ::hcal::HcalSiPMCharacteristicsPortableHost;
using HcalSiPMCharacteristicsPortableDevice = PortableCollection<::hcal::HcalSiPMCharacteristicsSoA>;
} // namespace hcal

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#endif
4 changes: 4 additions & 0 deletions CondFormats/HcalObjects/src/ES_HcalMahiConditionsHost.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/HcalObjects/interface/HcalMahiConditionsHost.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(hcal::HcalMahiConditionsPortableHost);
4 changes: 4 additions & 0 deletions CondFormats/HcalObjects/src/ES_HcalMahiPulseOffsetsHost.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsHost.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(hcal::HcalMahiPulseOffsetsPortableHost);
Loading