Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-30 08:50:30

0001 #ifndef CUDADataFormats_HGCal_HGCConditions_h
0002 #define CUDADataFormats_HGCal_HGCConditions_h
0003 
0004 #include <cstdint>
0005 #include <cstddef>
0006 #include <array>
0007 #include <vector>
0008 
0009 class HeterogeneousHGCSiliconDetId {
0010 public:
0011   constexpr HeterogeneousHGCSiliconDetId(uint32_t id) : id_(id) {}
0012   constexpr std::int32_t type() { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0013   constexpr std::int32_t zside() { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
0014   constexpr std::int32_t layer() { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0015   constexpr std::int32_t waferUAbs() { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; }
0016   constexpr std::int32_t waferVAbs() { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; }
0017   constexpr std::int32_t waferU() {
0018     return (((id_ >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs());
0019   }
0020   constexpr std::int32_t waferV() {
0021     return (((id_ >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs());
0022   }
0023   constexpr std::int32_t waferX() { return (-2 * waferU() + waferV()); }
0024   constexpr std::int32_t waferY() { return (2 * waferV()); }
0025   constexpr std::int32_t cellU() { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; }
0026   constexpr std::int32_t cellV() { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; }
0027   constexpr std::int32_t nCellsSide() { return (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; }
0028   constexpr std::int32_t cellX() {
0029     const std::int32_t N = nCellsSide();
0030     return (3 * (cellV() - N) + 2);
0031   }
0032   constexpr std::int32_t cellY() {
0033     const std::int32_t N = nCellsSide();
0034     return (2 * cellU() - (N + cellV()));
0035   }
0036 
0037 private:
0038   std::uint32_t id_;
0039   enum waferType { HGCalFine = 0, HGCalCoarseThin = 1, HGCalCoarseThick = 2 };
0040   static constexpr std::int32_t HGCalFineN = 12;
0041   static constexpr std::int32_t HGCalCoarseN = 8;
0042   static constexpr std::int32_t kHGCalCellUOffset = 0;
0043   static constexpr std::int32_t kHGCalCellUMask = 0x1F;
0044   static constexpr std::int32_t kHGCalCellVOffset = 5;
0045   static constexpr std::int32_t kHGCalCellVMask = 0x1F;
0046   static constexpr std::int32_t kHGCalWaferUOffset = 10;
0047   static constexpr std::int32_t kHGCalWaferUMask = 0xF;
0048   static constexpr std::int32_t kHGCalWaferUSignOffset = 14;
0049   static constexpr std::int32_t kHGCalWaferUSignMask = 0x1;
0050   static constexpr std::int32_t kHGCalWaferVOffset = 15;
0051   static constexpr std::int32_t kHGCalWaferVMask = 0xF;
0052   static constexpr std::int32_t kHGCalWaferVSignOffset = 19;
0053   static constexpr std::int32_t kHGCalWaferVSignMask = 0x1;
0054   static constexpr std::int32_t kHGCalLayerOffset = 20;
0055   static constexpr std::int32_t kHGCalLayerMask = 0x1F;
0056   static constexpr std::int32_t kHGCalZsideOffset = 25;
0057   static constexpr std::int32_t kHGCalZsideMask = 0x1;
0058   static constexpr std::int32_t kHGCalTypeOffset = 26;
0059   static constexpr std::int32_t kHGCalTypeMask = 0x3;
0060 };
0061 
0062 class HeterogeneousHGCScintillatorDetId {
0063 public:
0064   constexpr HeterogeneousHGCScintillatorDetId(uint32_t id) : id_(id) {}
0065   constexpr std::int32_t type() { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0066   constexpr std::int32_t zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
0067   constexpr std::int32_t layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0068 
0069 private:
0070   std::uint32_t id_;
0071   static constexpr std::uint32_t kHGCalPhiOffset = 0;
0072   static constexpr std::uint32_t kHGCalPhiMask = 0x1FF;
0073   static constexpr std::uint32_t kHGCalRadiusOffset = 9;
0074   static constexpr std::uint32_t kHGCalRadiusMask = 0xFF;
0075   static constexpr std::uint32_t kHGCalLayerOffset = 17;
0076   static constexpr std::uint32_t kHGCalLayerMask = 0x1F;
0077   static constexpr std::uint32_t kHGCalTriggerOffset = 22;
0078   static constexpr std::uint32_t kHGCalTriggerMask = 0x1;
0079   static constexpr std::uint32_t kHGCalZsideOffset = 25;
0080   static constexpr std::uint32_t kHGCalZsideMask = 0x1;
0081   static constexpr std::uint32_t kHGCalTypeOffset = 26;
0082   static constexpr std::uint32_t kHGCalTypeMask = 0x3;
0083 };
0084 
0085 namespace hgcal_conditions {
0086   namespace parameters {
0087     enum class HeterogeneousHGCalEEParametersType { Double, Int32_t };
0088     enum class HeterogeneousHGCalHEFParametersType { Double, Int32_t };
0089     enum class HeterogeneousHGCalHEBParametersType { Double, Int32_t };
0090 
0091     const std::array<HeterogeneousHGCalEEParametersType, 5> typesEE = {{HeterogeneousHGCalEEParametersType::Double,
0092                                                                         HeterogeneousHGCalEEParametersType::Double,
0093                                                                         HeterogeneousHGCalEEParametersType::Double,
0094                                                                         HeterogeneousHGCalEEParametersType::Double,
0095                                                                         HeterogeneousHGCalEEParametersType::Int32_t}};
0096 
0097     const std::array<HeterogeneousHGCalHEFParametersType, 5> typesHEF = {
0098         {HeterogeneousHGCalHEFParametersType::Double,
0099          HeterogeneousHGCalHEFParametersType::Double,
0100          HeterogeneousHGCalHEFParametersType::Double,
0101          HeterogeneousHGCalHEFParametersType::Double,
0102          HeterogeneousHGCalHEFParametersType::Int32_t}};
0103 
0104     const std::array<HeterogeneousHGCalHEBParametersType, 2> typesHEB = {
0105         {HeterogeneousHGCalHEBParametersType::Double, HeterogeneousHGCalHEBParametersType::Int32_t}};
0106 
0107     class HeterogeneousHGCalEEParameters {
0108     public:
0109       //indexed by cell number
0110       double *cellFineX_;
0111       double *cellFineY_;
0112       double *cellCoarseX_;
0113       double *cellCoarseY_;
0114       //index by wafer number
0115       std::int32_t *waferTypeL_;
0116     };
0117     class HeterogeneousHGCalHEFParameters {
0118     public:
0119       //indexed by cell number
0120       double *cellFineX_;
0121       double *cellFineY_;
0122       double *cellCoarseX_;
0123       double *cellCoarseY_;
0124       //index by wafer number
0125       std::int32_t *waferTypeL_;
0126     };
0127     class HeterogeneousHGCalHEBParameters {
0128     public:
0129       double *testD_;
0130       std::int32_t *testI_;
0131     };
0132 
0133   }  //namespace parameters
0134 
0135   namespace positions {
0136 
0137     enum class HeterogeneousHGCalPositionsType { Float, Int32_t, Uint32_t };
0138 
0139     const std::vector<HeterogeneousHGCalPositionsType> types = {HeterogeneousHGCalPositionsType::Float,
0140                                                                 HeterogeneousHGCalPositionsType::Float,
0141                                                                 HeterogeneousHGCalPositionsType::Float,
0142                                                                 HeterogeneousHGCalPositionsType::Int32_t,
0143                                                                 HeterogeneousHGCalPositionsType::Int32_t,
0144                                                                 HeterogeneousHGCalPositionsType::Int32_t,
0145                                                                 HeterogeneousHGCalPositionsType::Uint32_t};
0146 
0147     struct HGCalPositionsMapping {
0148       std::vector<float> zLayer;                    //z position per layer
0149       std::vector<std::int32_t> nCellsLayer;        //#cells per layer
0150       std::vector<std::int32_t> nCellsWaferUChunk;  //#cells per U wafer (each in turn including all V wafers)
0151       std::vector<std::int32_t> nCellsHexagon;      //#cells per V wafer
0152       std::vector<std::uint32_t> detid;
0153       //variables required for calculating the positions (x,y) from the detid in the GPU
0154       float waferSize;
0155       float sensorSeparation;
0156       //variables required for the mapping of detid -> cell in the geometry
0157       std::int32_t firstLayer;
0158       std::int32_t lastLayer;
0159       std::int32_t waferMax;
0160       std::int32_t waferMin;
0161     };
0162 
0163     struct HeterogeneousHGCalPositionsMapping {
0164       //the x, y and z positions will not be filled in the CPU
0165       float *x;
0166       float *y;
0167       float *zLayer;
0168       std::int32_t *nCellsLayer;
0169       std::int32_t *nCellsWaferUChunk;
0170       std::int32_t *nCellsHexagon;
0171       std::uint32_t *detid;
0172       //variables required for calculating the positions (x,y) from the detid in the GPU
0173       float waferSize;
0174       float sensorSeparation;
0175       //variables required for the mapping of detid -> cell in the geometry
0176       std::int32_t firstLayer;
0177       std::int32_t lastLayer;
0178       std::int32_t waferMax;
0179       std::int32_t waferMin;
0180     };
0181 
0182   }  //namespace positions
0183 
0184   struct HeterogeneousEEConditionsESProduct {
0185     parameters::HeterogeneousHGCalEEParameters params;
0186   };
0187   struct HeterogeneousHEFConditionsESProduct {
0188     parameters::HeterogeneousHGCalHEFParameters params;
0189     //positions::HeterogeneousHGCalPositionsMapping posmap;
0190     //size_t nelems_posmap;
0191   };
0192   struct HeterogeneousHEBConditionsESProduct {
0193     parameters::HeterogeneousHGCalHEBParameters params;
0194   };
0195 
0196   struct HeterogeneousHEFCellPositionsConditionsESProduct {
0197     positions::HeterogeneousHGCalPositionsMapping posmap;
0198     std::size_t nelems_posmap;
0199   };
0200 
0201 }  // namespace hgcal_conditions
0202 
0203 #endif  //CUDADataFormats_HGCal_HGCConditions_h