File indexing completed on 2024-04-06 12:15:13
0001 #ifndef HGCalCommonData_HGCalTBDDDConstants_h
0002 #define HGCalCommonData_HGCalTBDDDConstants_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "DataFormats/DetId/interface/DetId.h"
0015 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0016 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0017 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0018 #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h"
0019 #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h"
0020 #include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
0021 #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
0022 #include "Geometry/HGCalTBCommonData/interface/HGCalTBParameters.h"
0023 #include <CLHEP/Geometry/Point3D.h>
0024
0025 #include <array>
0026 #include <memory>
0027 #include <string>
0028 #include <vector>
0029 #include <unordered_map>
0030
0031 class HGCalTBDDDConstants {
0032 public:
0033 HGCalTBDDDConstants(const HGCalTBParameters* hp, const std::string& name);
0034 ~HGCalTBDDDConstants() = default;
0035
0036 std::pair<int, int> assignCell(float x, float y, int lay, int subSec, bool reco) const;
0037 double cellSizeHex(int type) const;
0038 double cellThickness(int layer, int wafer) const;
0039 double distFromEdgeHex(double x, double y, double z) const;
0040 inline int firstLayer() const { return hgpar_->firstLayer_; }
0041 inline HGCalGeometryMode::GeometryMode geomMode() const { return mode_; }
0042 int getLayer(double z, bool reco) const;
0043 HGCalTBParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const;
0044 std::vector<HGCalTBParameters::hgtrap> getModules() const;
0045 inline const HGCalTBParameters* getParameter() const { return hgpar_; }
0046 inline HGCalTBParameters::hgtrform getTrForm(unsigned int k) const { return hgpar_->getTrForm(k); }
0047 inline unsigned int getTrFormN() const { return hgpar_->trformIndex_.size(); }
0048 std::vector<HGCalTBParameters::hgtrform> getTrForms() const;
0049 int getTypeHex(int layer, int wafer) const { return -1; }
0050 bool isHalfCell(int waferType, int cell) const;
0051 bool isValidHex(int lay, int mod, int cell, bool reco) const;
0052 int lastLayer(bool reco) const;
0053 int layerIndex(int lay, bool reco) const;
0054 unsigned int layers(bool reco) const;
0055 unsigned int layersInit(bool reco) const;
0056 inline int layerType(int lay) const { return HGCalTypes::WaferCenter; }
0057 std::pair<float, float> locateCell(int cell, int lay, int type, bool reco) const;
0058 std::pair<float, float> locateCellHex(int cell, int wafer, bool reco) const;
0059 inline int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; }
0060 int maxCells(bool reco) const;
0061 int maxCells(int lay, bool reco) const;
0062 inline int maxModules() const { return modHalf_; }
0063 inline int maxModulesPerLayer() const { return maxWafersPerLayer_; }
0064 int maxRows(int lay, bool reco) const;
0065 inline double minSlope() const { return hgpar_->slopeMin_[0]; }
0066 int modifyUV(int uv, int type1, int type2) const;
0067 int modules(int lay, bool reco) const;
0068 int modulesInit(int lay, bool reco) const;
0069 double mouseBite(bool reco) const;
0070 int numberCells(bool reco) const;
0071 std::vector<int> numberCells(int lay, bool reco) const;
0072 int numberCellsHexagon(int wafer) const;
0073 std::pair<double, double> rangeR(double z, bool reco) const;
0074 std::pair<double, double> rangeRLayer(int lay, bool reco) const;
0075 std::pair<double, double> rangeZ(bool reco) const;
0076 std::pair<int, int> rowColumnWafer(const int wafer) const;
0077 inline int sectors() const { return hgpar_->nSectors_; }
0078 std::pair<int, int> simToReco(int cell, int layer, int mod, bool half) const;
0079 inline unsigned int volumes() const { return hgpar_->moduleLayR_.size(); }
0080 int waferFromCopy(int copy) const;
0081 void waferFromPosition(const double x, const double y, int& wafer, int& icell, int& celltyp) const;
0082 inline bool waferHexagon6() const {
0083 return ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull));
0084 }
0085 bool waferInLayer(int wafer, int lay, bool reco) const;
0086 bool waferFullInLayer(int wafer, int lay, bool reco) const;
0087 inline int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); }
0088 inline int waferMax() const { return waferMax_[1]; }
0089 inline int waferMin() const { return waferMax_[0]; }
0090 std::pair<double, double> waferParameters(bool reco) const;
0091 std::pair<double, double> waferPosition(int wafer, bool reco) const;
0092 GlobalPoint waferLocal2Global(
0093 HepGeom::Point3D<float>& loc, const DetId& id, bool useWafer, bool reco, bool debug) const;
0094 inline double waferSepar(bool reco) const {
0095 return (reco ? hgpar_->sensorSeparation_ : HGCalTBParameters::k_ScaleToDDD * hgpar_->sensorSeparation_);
0096 }
0097 inline double waferSize(bool reco) const {
0098 return (reco ? hgpar_->waferSize_ : HGCalTBParameters::k_ScaleToDDD * hgpar_->waferSize_);
0099 }
0100 int wafers() const;
0101 int wafers(int layer, int type) const;
0102 inline int waferToCopy(int wafer) const {
0103 return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferCopy_.size())))
0104 ? hgpar_->waferCopy_[wafer]
0105 : static_cast<int>(hgpar_->waferCopy_.size());
0106 }
0107
0108 inline int waferTypeT(int wafer) const {
0109 return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeT_.size()))) ? hgpar_->waferTypeT_[wafer] : 0;
0110 }
0111
0112 inline int waferTypeL(int wafer) const {
0113 return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeL_.size()))) ? hgpar_->waferTypeL_[wafer] : 0;
0114 }
0115 int waferType(DetId const& id) const;
0116 int waferType(int layer, int wafer) const;
0117 std::tuple<int, int, int> waferType(HGCSiliconDetId const& id, bool fromFile = false) const;
0118 inline int waferUVMax() const { return hgpar_->waferUVMax_; }
0119 bool waferVirtual(int layer, int wafer) const;
0120 double waferZ(int layer, bool reco) const;
0121
0122 private:
0123 int cellHex(double xx,
0124 double yy,
0125 const double& cellR,
0126 const std::vector<double>& posX,
0127 const std::vector<double>& posY) const;
0128 std::pair<int, float> getIndex(int lay, bool reco) const;
0129 int layerFromIndex(int index, bool reco) const;
0130 bool isValidCell(int layindex, int wafer, int cell) const;
0131 int32_t waferIndex(int wafer, int index) const;
0132 bool waferInLayerTest(int wafer, int lay) const { return waferHexagon6(); }
0133
0134 HGCalGeomTools geomTools_;
0135 const double k_horizontalShift = 1.0;
0136 const float dPhiMin = 0.02;
0137 typedef std::array<std::vector<int32_t>, 2> Simrecovecs;
0138 typedef std::array<int, 3> HGCWaferParam;
0139 const HGCalTBParameters* hgpar_;
0140 constexpr static double tan30deg_ = 0.5773502693;
0141 const double sqrt3_;
0142 const HGCalGeometryMode::GeometryMode mode_;
0143 double rmax_, hexside_;
0144 double rmaxT_, hexsideT_;
0145 int32_t tot_wafers_, modHalf_;
0146 std::array<uint32_t, 2> tot_layers_;
0147 Simrecovecs max_modules_layer_;
0148 int32_t maxWafersPerLayer_;
0149 std::map<int, HGCWaferParam> waferLayer_;
0150 std::array<int, 4> waferMax_;
0151 std::unordered_map<int32_t, bool> waferIn_;
0152 };
0153
0154 #endif