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

ECAL - Make EcalConstants constexpr arrays compatible with CUDA code #37161

Merged
merged 1 commit into from
Mar 13, 2022
Merged
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: 26 additions & 12 deletions DataFormats/EcalDigi/interface/EcalConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@
#ifndef DataFormats_EcalDigi_EcalConstants_h
#define DataFormats_EcalDigi_EcalConstants_h

#include "FWCore/Utilities/interface/HostDeviceConstant.h"

// The HOST_DEVICE_CONSTANTs can not reside in the classes directly, which is
// why they are defined in a namespace and constant pointers to them are used in the classes
namespace ecalph2 {
constexpr unsigned int NGAINS = 2; // Number of CATIA gains
HOST_DEVICE_CONSTANT float gains[NGAINS] = {10., 1.}; // CATIA gain values
} // namespace ecalph2

namespace ecalph1 {
constexpr unsigned int NGAINS = 4; // Number of MGPA gains including a zero gain that
// could be encoded in the gain id mask
HOST_DEVICE_CONSTANT float gains[NGAINS] = {0., 12., 6., 1.}; // MGPA gain values including a zero gain
} // namespace ecalph1

class ecalPh2 {
public:
static constexpr double Samp_Period = 6.25; // ADC sampling period in ns
static constexpr unsigned int NGAINS = 2; // Number of CATIA gains
static constexpr float gains[NGAINS] = {10., 1.}; // CATIA gain values
static constexpr unsigned int NGAINS = ecalph2::NGAINS; // Number of CATIA gains
static constexpr const float *gains = ecalph2::gains; // CATIA gain values
static constexpr unsigned int gainId1 = 1; // Position of gain 1 in gains array
static constexpr unsigned int gainId10 = 0; // Position of gain 10 in gains array
static constexpr unsigned int sampleSize = 16; // Number of samples per event
Expand All @@ -23,15 +38,14 @@ class ecalPh2 {

class ecalPh1 {
public:
static constexpr double Samp_Period = 25.; // ADC sampling period in ns
static constexpr unsigned int NGAINS = 4; // Number of MGPA gains including a zero gain that
// could be encoded in the gain id mask
static constexpr float gains[NGAINS] = {0., 12., 6., 1.}; // MGPA gain values including a zero gain
static constexpr unsigned int sampleSize = 10; // Number of samples per event
static constexpr unsigned int NBITS = 12; // Number of available bits
static constexpr unsigned int kNOffsets = 2000; // Number of time offsets generated for APD pulse shape
// simulation and reused for every kNOffsets^th channel
static constexpr unsigned int kAdcMask = 0xFFF; // ADC sample mask for unpacking
static constexpr unsigned int kGainIdMask = 0x3; // Gain id mask for unpacking
static constexpr double Samp_Period = 25.; // ADC sampling period in ns
static constexpr unsigned int NGAINS = ecalph1::NGAINS; // Number of MGPA gains including a zero gain
static constexpr const float *gains = ecalph1::gains; // MGPA gain values including a zero gain
static constexpr unsigned int sampleSize = 10; // Number of samples per event
static constexpr unsigned int NBITS = 12; // Number of available bits
static constexpr unsigned int kNOffsets = 2000; // Number of time offsets generated for APD pulse shape
// simulation and reused for every kNOffsets^th channel
static constexpr unsigned int kAdcMask = 0xFFF; // ADC sample mask for unpacking
static constexpr unsigned int kGainIdMask = 0x3; // Gain id mask for unpacking
};
#endif