Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:45

0001 #ifndef Geometry_HcalTowerAlgo_HcalDDDRecConstants_h
0002 #define Geometry_HcalTowerAlgo_HcalDDDRecConstants_h
0003 
0004 /** \class HcalDDDRecConstants
0005  *
0006  * this class reads the constant section of
0007  * the hcal-sim-numbering xml-file
0008  *  
0009  * \author Sunanda Banerjee, SINP <sunanda.banerjee@cern.ch>
0010  *
0011  */
0012 
0013 #include <map>
0014 #include <string>
0015 #include <vector>
0016 #include <iostream>
0017 
0018 #include "CondFormats/GeometryObjects/interface/HcalParameters.h"
0019 #include "Geometry/HcalCommonData/interface/HcalCellType.h"
0020 #include "Geometry/HcalCommonData/interface/HcalDDDSimConstants.h"
0021 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0022 
0023 class HcalDDDRecConstants {
0024 public:
0025   HcalDDDRecConstants(const HcalParameters* hp, const HcalDDDSimConstants& hc);
0026   ~HcalDDDRecConstants();
0027 
0028   struct HcalID {
0029     int subdet, eta, phi, depth;
0030     HcalID(int sub = 0, int et = 0, int fi = 0, int d = 0) : subdet(sub), eta(et), phi(fi), depth(d) {}
0031   };
0032   struct HcalEtaBin {
0033     int ieta, zside, depthStart;
0034     double dphi, etaMin, etaMax;
0035     std::vector<std::pair<int, int>> layer;
0036     std::vector<std::pair<int, double>> phis;
0037     HcalEtaBin(int eta = 0, int zs = 1, double dfi = 0, double et1 = 0, double et2 = 0)
0038         : ieta(eta), zside(zs), depthStart(0), dphi(dfi), etaMin(et1), etaMax(et2) {}
0039   };
0040   struct HcalActiveLength {
0041     int ieta, depth, zside, stype;
0042     double eta, thick;
0043     std::vector<int> iphis;
0044     HcalActiveLength(int ie = 0, int d = 0, int z = 0, int s = 0, double et = 0, double t = 0)
0045         : ieta(ie), depth(d), zside(z), stype(s), eta(et), thick(t) {}
0046   };
0047   struct HFCellParameters {
0048     int ieta, depth, firstPhi, stepPhi, nPhi;
0049     double rMin, rMax;
0050     HFCellParameters(int ie = 0, int d = 1, int ffi = 1, int sfi = 2, int nfi = 36, double r1 = 0, double r2 = 0)
0051         : ieta(ie), depth(d), firstPhi(ffi), stepPhi(sfi), nPhi(nfi), rMin(r1), rMax(r2) {}
0052   };
0053 
0054   std::vector<std::pair<double, double>> getConstHBHE(const int& type) const {
0055     if (type == 0)
0056       return gconsHB;
0057     else if (type == 1)
0058       return gconsHE;
0059     else {
0060       std::vector<std::pair<double, double>> gcons;
0061       return gcons;
0062     }
0063   }
0064   int findDepth(const int& det, const int& eta, const int& phi, const int& zside, const int& lay) const;
0065   std::vector<int> getDepth(const int& det, const int& phi, const int& zside, const unsigned int& eta) const;
0066   std::vector<int> getDepth(const unsigned int& eta, const bool& extra) const;
0067   int getDepthEta16(const int& det, const int& iphi, const int& zside) const {
0068     return hcons.getDepthEta16(det, iphi, zside);
0069   }
0070   int getDepthEta29(const int& iphi, const int& zside, const int& type) const {
0071     return hcons.getDepthEta29(iphi, zside, type);
0072   }
0073   std::vector<HcalEtaBin> getEtaBins(const int& itype) const;
0074   std::pair<double, double> getEtaPhi(const int& subdet, const int& ieta, const int& iphi) const;
0075   std::pair<int, int> getEtaRange(const int& i) const { return std::pair<int, int>(iEtaMin[i], iEtaMax[i]); }
0076   const std::vector<double>& getEtaTable() const { return etaTable; }
0077   const std::vector<double>& getEtaTableHF() const { return hpar->etaTableHF; }
0078   std::pair<double, double> getEtaLimit(const int& i) const {
0079     return std::pair<double, double>(etaTable[i], etaTable[i + 1]);
0080   }
0081   HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const;
0082   std::vector<HFCellParameters> getHFCellParameters() const;
0083   void getLayerDepth(const int& ieta, std::map<int, int>& layers) const;
0084   int getLayerBack(const int& det, const int& eta, const int& phi, const int& depth) const;
0085   int getLayerFront(const int& det, const int& eta, const int& phi, const int& depth) const;
0086   double getLayer0Wt(const int& det, const int& phi, const int& zside) const {
0087     return hcons.getLayer0Wt(det, phi, zside);
0088   }
0089   int getMaxDepth(const int& type) const { return maxDepth[type]; }
0090   int getMaxDepth(const int& itype, const int& ieta, const int& iphi, const int& zside) const;
0091   int getMinDepth(const int& itype, const int& ieta, const int& iphi, const int& zside) const;
0092   int getNEta() const { return hpar->etagroup.size(); }
0093   int getNoff(const int& i) const { return hpar->noff[i]; }
0094   int getNPhi(const int& type) const { return nPhiBins[type]; }
0095   double getPhiBin(const int& i) const { return phibin[i]; }
0096   double getPhiOff(const int& i) const { return hpar->phioff[i]; }
0097   const std::vector<double>& getPhiOffs() const { return hpar->phioff; }
0098   std::vector<std::pair<int, double>> getPhis(const int& subdet, const int& ieta) const;
0099   const std::vector<double>& getPhiTable() const { return phibin; }
0100   const std::vector<double>& getPhiTableHF() const { return hpar->phitable; }
0101   int getPhiZOne(std::vector<std::pair<int, int>>& phiz) const;
0102   double getRZ(const int& subdet, const int& ieta, const int& depth) const;
0103   double getRZ(const int& subdet, const int& ieta, const int& iphi, const int& depth) const;
0104   double getRZ(const int& subdet, const int& layer) const;
0105   std::pair<double, double> getRZ(const HcalDetId& id) const;
0106   std::vector<HcalActiveLength> getThickActive(const int& type) const;
0107   int getTopoMode() const { return ((hpar->topologyMode) & 0xFF); }
0108   int getTriggerMode() const { return (((hpar->topologyMode) >> 8) & 0xFF); }
0109   std::vector<HcalCellType> HcalCellTypes(HcalSubdetector) const;
0110   bool isBH() const { return hcons.isBH(); }
0111   bool isHE() const { return hcons.isHE(); }
0112   bool isPlan1(const HcalDetId& id) const { return detIdSp_.find(id) != detIdSp_.end(); };
0113   int maxHFDepth(int ieta, int iphi) const { return hcons.maxHFDepth(ieta, iphi); }
0114   bool mergedDepthList29(int ieta, int iphi, int depth) const;
0115   std::vector<int> mergedDepthList29(int ieta, int iphi) const;
0116   unsigned int numberOfCells(HcalSubdetector) const;
0117   unsigned int nCells(HcalSubdetector) const;
0118   unsigned int nCells() const;
0119   HcalDetId mergedDepthDetId(const HcalDetId& id) const;
0120   HcalDetId idFront(const HcalDetId& id) const;
0121   HcalDetId idBack(const HcalDetId& id) const;
0122   void unmergeDepthDetId(const HcalDetId& id, std::vector<HcalDetId>& ids) const;
0123   void specialRBXHBHE(const std::vector<HcalDetId>&, std::vector<HcalDetId>&) const;
0124   bool specialRBXHBHE(bool flag, std::vector<HcalDetId>&) const;
0125   bool withSpecialRBXHBHE() const { return (hcons.ldMap()->getSubdet() != 0); }
0126   bool isPlan1ToBeMergedId(const HcalDetId& id) const { return detIdSp_.find(id) != detIdSp_.end(); };
0127   bool isPlan1MergedId(const HcalDetId& id) const { return detIdSpR_.find(id) != detIdSpR_.end(); };
0128   const HcalDDDSimConstants* dddConstants() const { return &hcons; }
0129 
0130 private:
0131   void getOneEtaBin(HcalSubdetector subdet,
0132                     int ieta,
0133                     int zside,
0134                     std::vector<std::pair<int, double>>& phis,
0135                     std::map<int, int>& layers,
0136                     bool planOne,
0137                     std::vector<HcalDDDRecConstants::HcalEtaBin>& bins) const;
0138   void initialize(void);
0139   unsigned int layerGroupSize(int eta) const;
0140   unsigned int layerGroup(int eta, int i) const;
0141 
0142   static const int maxLayer_ = 18;
0143   static const int maxLayerHB_ = 16;
0144   const HcalParameters* hpar;
0145   const HcalDDDSimConstants& hcons;
0146   std::vector<std::pair<int, int>> etaSimValu;            // eta ranges at Sim stage
0147   std::vector<double> etaTable;                           // Eta table (HB+HE)
0148   std::vector<int> ietaMap;                               // Map Sim level ieta to Rec level ieta
0149   std::vector<int> iEtaMin, iEtaMax;                      // Minimum and maximum eta
0150   std::vector<int> maxDepth;                              // Maximum depth in HB/HE/HF/HO
0151   std::vector<int> nPhiBins;                              // Number of phi bis for HB/HE/HF/HO
0152   std::vector<double> phibin;                             // Phi step for all eta bins (HB, HE, HO)
0153   std::vector<int> phiUnitS;                              // Phi unit at SIM stage
0154   std::vector<std::pair<double, double>> gconsHB;         // Geometry constatnts HB
0155   std::vector<std::pair<double, double>> gconsHE;         // Geometry constatnts HE
0156   int nModule[2], nHalves[2];                             // Modules, Halves for HB/HE
0157   std::pair<int, int> depthMaxDf_, depthMaxSp_;           // (subdet,maximum depth) default,special
0158   std::map<HcalDetId, HcalDetId> detIdSp_;                // Map of Id's for special RBX
0159   std::map<HcalDetId, std::vector<HcalDetId>> detIdSpR_;  // Reverse map for RBX
0160 };
0161 
0162 #endif