Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:14

0001 #ifndef ECALDETID_ECALTRIGTOWERDETID_H
0002 #define ECALDETID_ECALTRIGTOWERDETID_H
0003 
0004 #include <iosfwd>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0007 
0008 /** \class EcalTrigTowerDetId
0009     
0010    DetId for an Ecal Trigger tower
0011 
0012 */
0013 
0014 class EcalTrigTowerDetId : public DetId {
0015 public:
0016   /** Constructor of a null id */
0017   EcalTrigTowerDetId();
0018   /** Constructor from a raw value */
0019   EcalTrigTowerDetId(uint32_t rawid);
0020   /** \brief Constructor from signed ieta, iphi
0021    */
0022   EcalTrigTowerDetId(int zside, EcalSubdetector subdet, int i, int j, int mode = SUBDETIJMODE);
0023 
0024   /** Constructor from a generic cell id */
0025   EcalTrigTowerDetId(const DetId& id);
0026   /** Assignment from a generic cell id */
0027   EcalTrigTowerDetId& operator=(const DetId& id);
0028 
0029   /// get the z-side of the tower (1/-1)
0030   int zside() const { return (id_ & 0x8000) ? (1) : (-1); }
0031 
0032   /// get the subDetector associated to the Trigger Tower
0033   EcalSubdetector subDet() const { return (id_ & 0x4000) ? EcalBarrel : EcalEndcap; }
0034 
0035   /// get the absolute value of the tower ieta
0036   int ietaAbs() const {
0037     /*       if ( subDet() == EcalBarrel) */
0038     return (id_ >> 7) & 0x7f;
0039     /*       else */
0040     /*  throw(std::runtime_error("EcalTrigTowerDetId: ietaAbs not applicable for this subDetector.")); */
0041   }
0042 
0043   /// get the tower ieta
0044   int ieta() const {
0045     /*       if ( subDet() == EcalBarrel) */
0046     return zside() * ietaAbs();
0047     /*       else */
0048     /*  throw(std::runtime_error("EcalTrigTowerDetId: ieta not applicable for this subDetector.")); */
0049   }
0050 
0051   /// get the tower iphi
0052   int iphi() const {
0053     /*       if ( subDet() == EcalBarrel) */
0054     return id_ & 0x7F;
0055     /*       else */
0056     /*  throw(std::runtime_error("EcalTrigTowerDetId: iphi not applicable for this subDetector.")); */
0057   }
0058 
0059   int iquadrant() const;
0060 
0061   /// get the tower ix (Endcap case) */
0062   int ix() const {
0063     if (subDet() == EcalEndcap)
0064       return (id_ >> 7) & 0x7f;
0065     else
0066       throw(std::runtime_error("EcalTrigTowerDetId: ix not applicable for this subDetector."));
0067   }
0068 
0069   /// get the tower iy (Endcap case) */
0070   int iy() const {
0071     if (subDet() == EcalEndcap)
0072       return id_ & 0x7F;
0073     else
0074       throw(std::runtime_error("EcalTrigTowerDetId: ix not applicable for this subDetector."));
0075   }
0076 
0077   /// get a compact index for arrays [TODO: NEEDS WORK]
0078   int hashedIndex() const;
0079 
0080   uint32_t denseIndex() const { return hashedIndex(); }
0081 
0082   static bool validDenseIndex(uint32_t din) { return (din < kSizeForDenseIndexing); }
0083 
0084   static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di);
0085 
0086   /// check if a valid index combination
0087   static bool validDetId(int iz, EcalSubdetector sd, int i, int j);
0088 
0089   /// get the ECAL DCC id - in the  barrrel ism == iDCC
0090   int iDCC() const;
0091 
0092   /// sequential index within one DCC
0093   int iTT() const;
0094 
0095   static const int MIN_I = 1;
0096   static const int MIN_J = 1;
0097   static const int MAX_I = 127;
0098   static const int MAX_J = 127;
0099 
0100   static const int kEBTowersInPhi = 4;              // per SM (in the Barrel)
0101   static const int kEBTowersPerSM = 68;             // per SM (in the Barrel)
0102   static const int kEBTowersInEta = 17;             // per SM (in the Barrel)
0103                                                     //  static const int kEETowersInEta = 11; // Endcap
0104   static const int kEETowersInPhiPerQuadrant = 18;  // per Quadrant (in the Endcap)
0105 
0106   // function modes for (int, int) constructor
0107   static const int SUBDETIJMODE = 0;
0108   static const int SUBDETDCCTTMODE = 1;
0109 
0110   enum {
0111     kEETowersInPhiPerEndcap = 4 * kEETowersInPhiPerQuadrant,
0112     kEEOuterEta = 18,
0113     kEEInnerEta = 28,
0114     kEETowersInEta = (kEEInnerEta - kEEOuterEta + 1),
0115     kEBHalfTowers = kEBTowersPerSM * 18,
0116     kEBTotalTowers = kEBHalfTowers * 2,
0117     kEETowersPerEndcap = kEETowersInEta * kEETowersInPhiPerEndcap - 72,
0118     kEETotalTowers = kEETowersPerEndcap * 2,
0119     kSizeForDenseIndexing = kEBTotalTowers + kEETotalTowers
0120   };
0121 };
0122 
0123 std::ostream& operator<<(std::ostream&, const EcalTrigTowerDetId& id);
0124 
0125 #endif