Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:33

0001 #ifndef CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h
0002 #define CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h
0003 
0004 #include <cstdint>
0005 #include <alpaka/alpaka.hpp>
0006 #include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLTLayout.h"
0007 
0008 struct SiPixelGainUtilities {
0009   ALPAKA_FN_HOST_ACC ALPAKA_FN_ACC ALPAKA_FN_INLINE static std::pair<float, float> getPedAndGain(
0010       const SiPixelGainCalibrationForHLTSoAConstView& view,
0011       uint32_t moduleInd,
0012       int col,
0013       int row,
0014       bool& isDeadColumn,
0015       bool& isNoisyColumn) {
0016     auto start = view.modStarts()[moduleInd];
0017     auto end = view.modEnds()[moduleInd];
0018     auto nCols = view.modCols()[moduleInd];
0019     // determine what averaged data block we are in (there should be 1 or 2 of these depending on if plaquette is 1 by X or 2 by X
0020     unsigned int lengthOfColumnData = (end - start) / nCols;
0021     unsigned int lengthOfAveragedDataInEachColumn = 2;  // we always only have two values per column averaged block
0022     unsigned int numberOfDataBlocksToSkip = row / view.numberOfRowsAveragedOver();
0023 
0024     auto offset = start + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip;
0025     assert(offset < end);
0026     assert(offset < 3088384);
0027     assert(0 == offset % 2);
0028 
0029     auto lp = view.v_pedestals();
0030     auto s = lp[offset / 2];
0031 
0032     isDeadColumn = (s.ped & 0xFF) == view.deadFlag();
0033     isNoisyColumn = (s.ped & 0xFF) == view.noisyFlag();
0034     float decodeGain = float(s.gain & 0xFF) * view.gainPrecision() + view.minGain();
0035     float decodePed = float(s.ped & 0xFF) * view.pedPrecision() + view.minPed();
0036 
0037     return std::make_pair(decodePed, decodeGain);
0038   };
0039 };
0040 
0041 #endif  //CondFormats_SiPixelObjects_interface_alpaka_SiPixelGainCalibrationForHLTUtilities_h