Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-05 02:06:19

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   std::vector<int> getDepth(const int& det, const int& phi, const int& zside, const unsigned int& eta) const;
0065   std::vector<int> getDepth(const unsigned int& eta, const bool& extra) const;
0066   int getDepthEta16(const int& det, const int& iphi, const int& zside) const {
0067     return hcons.getDepthEta16(det, iphi, zside);
0068   }
0069   int getDepthEta29(const int& iphi, const int& zside, const int& type) const {
0070     return hcons.getDepthEta29(iphi, zside, type);
0071   }
0072   std::vector<HcalEtaBin> getEtaBins(const int& itype) const;
0073   std::pair<double, double> getEtaPhi(const int& subdet, const int& ieta, const int& iphi) const;
0074   std::pair<int, int> getEtaRange(const int& i) const { return std::pair<int, int>(iEtaMin[i], iEtaMax[i]); }
0075   const std::vector<double>& getEtaTable() const { return etaTable; }
0076   const std::vector<double>& getEtaTableHF() const { return hpar->etaTableHF; }
0077   std::pair<double, double> getEtaLimit(const int& i) const {
0078     return std::pair<double, double>(etaTable[i], etaTable[i + 1]);
0079   }
0080   HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const;
0081   std::vector<HFCellParameters> getHFCellParameters() const;
0082   void getLayerDepth(const int& ieta, std::map<int, int>& layers) const;
0083   int getLayerBack(const int& det, const int& eta, const int& phi, const int& depth) const;
0084   int getLayerFront(const int& det, const int& eta, const int& phi, const int& depth) const;
0085   double getLayer0Wt(const int& det, const int& phi, const int& zside) const {
0086     return hcons.getLayer0Wt(det, phi, zside);
0087   }
0088   int getMaxDepth(const int& type) const { return maxDepth[type]; }
0089   int getMaxDepth(const int& itype, const int& ieta, const int& iphi, const int& zside) const;
0090   int getMinDepth(const int& itype, const int& ieta, const int& iphi, const int& zside) const;
0091   int getNEta() const { return hpar->etagroup.size(); }
0092   int getNoff(const int& i) const { return hpar->noff[i]; }
0093   int getNPhi(const int& type) const { return nPhiBins[type]; }
0094   double getPhiBin(const int& i) const { return phibin[i]; }
0095   double getPhiOff(const int& i) const { return hpar->phioff[i]; }
0096   const std::vector<double>& getPhiOffs() const { return hpar->phioff; }
0097   std::vector<std::pair<int, double>> getPhis(const int& subdet, const int& ieta) const;
0098   const std::vector<double>& getPhiTable() const { return phibin; }
0099   const std::vector<double>& getPhiTableHF() const { return hpar->phitable; }
0100   int getPhiZOne(std::vector<std::pair<int, int>>& phiz) const;
0101   double getRZ(const int& subdet, const int& ieta, const int& depth) const;
0102   double getRZ(const int& subdet, const int& ieta, const int& iphi, const int& depth) const;
0103   double getRZ(const int& subdet, const int& layer) const;
0104   std::pair<double, double> getRZ(const HcalDetId& id) const;
0105   std::vector<HcalActiveLength> getThickActive(const int& type) const;
0106   int getTopoMode() const { return ((hpar->topologyMode) & 0xFF); }
0107   int getTriggerMode() const { return (((hpar->topologyMode) >> 8) & 0xFF); }
0108   std::vector<HcalCellType> HcalCellTypes(HcalSubdetector) const;
0109   bool isBH() const { return hcons.isBH(); }
0110   bool isHE() const { return hcons.isHE(); }
0111   bool isPlan1(const HcalDetId& id) const { return detIdSp_.find(id) != detIdSp_.end(); };
0112   int maxHFDepth(int ieta, int iphi) const { return hcons.maxHFDepth(ieta, iphi); }
0113   bool mergedDepthList29(int ieta, int iphi, int depth) const;
0114   std::vector<int> mergedDepthList29(int ieta, int iphi) const;
0115   unsigned int numberOfCells(HcalSubdetector) const;
0116   unsigned int nCells(HcalSubdetector) const;
0117   unsigned int nCells() const;
0118   HcalDetId mergedDepthDetId(const HcalDetId& id) const;
0119   HcalDetId idFront(const HcalDetId& id) const;
0120   HcalDetId idBack(const HcalDetId& id) const;
0121   void unmergeDepthDetId(const HcalDetId& id, std::vector<HcalDetId>& ids) const;
0122   void specialRBXHBHE(const std::vector<HcalDetId>&, std::vector<HcalDetId>&) const;
0123   bool specialRBXHBHE(bool flag, std::vector<HcalDetId>&) const;
0124   bool withSpecialRBXHBHE() const { return (hcons.ldMap()->getSubdet() != 0); }
0125   bool isPlan1ToBeMergedId(const HcalDetId& id) const { return detIdSp_.find(id) != detIdSp_.end(); };
0126   bool isPlan1MergedId(const HcalDetId& id) const { return detIdSpR_.find(id) != detIdSpR_.end(); };
0127   const HcalDDDSimConstants* dddConstants() const { return &hcons; }
0128 
0129 private:
0130   void getOneEtaBin(HcalSubdetector subdet,
0131                     int ieta,
0132                     int zside,
0133                     std::vector<std::pair<int, double>>& phis,
0134                     std::map<int, int>& layers,
0135                     bool planOne,
0136                     std::vector<HcalDDDRecConstants::HcalEtaBin>& bins) const;
0137   void initialize(void);
0138   unsigned int layerGroupSize(int eta) const;
0139   unsigned int layerGroup(int eta, int i) const;
0140 
0141   static const int maxLayer_ = 18;
0142   static const int maxLayerHB_ = 16;
0143   const HcalParameters* hpar;
0144   const HcalDDDSimConstants& hcons;
0145   std::vector<std::pair<int, int>> etaSimValu;            // eta ranges at Sim stage
0146   std::vector<double> etaTable;                           // Eta table (HB+HE)
0147   std::vector<int> ietaMap;                               // Map Sim level ieta to Rec level ieta
0148   std::vector<int> iEtaMin, iEtaMax;                      // Minimum and maximum eta
0149   std::vector<int> maxDepth;                              // Maximum depth in HB/HE/HF/HO
0150   std::vector<int> nPhiBins;                              // Number of phi bis for HB/HE/HF/HO
0151   std::vector<double> phibin;                             // Phi step for all eta bins (HB, HE, HO)
0152   std::vector<int> phiUnitS;                              // Phi unit at SIM stage
0153   std::vector<std::pair<double, double>> gconsHB;         // Geometry constatnts HB
0154   std::vector<std::pair<double, double>> gconsHE;         // Geometry constatnts HE
0155   int nModule[2], nHalves[2];                             // Modules, Halves for HB/HE
0156   std::pair<int, int> depthMaxDf_, depthMaxSp_;           // (subdet,maximum depth) default,special
0157   std::map<HcalDetId, HcalDetId> detIdSp_;                // Map of Id's for special RBX
0158   std::map<HcalDetId, std::vector<HcalDetId>> detIdSpR_;  // Reverse map for RBX
0159 };
0160 
0161 #endif