Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:17

0001 #ifndef HcalCastorDetId_h_included
0002 #define HcalCastorDetId_h_included 1
0003 
0004 #include <ostream>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 
0007 /** \class HcalCastorDetId
0008   *  
0009   *  Contents of the HcalCastorDetId :
0010   *     [9]   Z position (true for positive)
0011   *     [8:7] Section (EM/HAD)
0012   *     [6:4] sector (depth)
0013   * [3:0] module
0014 
0015   * NEW:
0016   * [8]   z position
0017   * [7:4] sector 
0018   * [3:0] module
0019 
0020   * \author P. Katsas, T. McCauley
0021   */
0022 
0023 class HcalCastorDetId : public DetId {
0024 public:
0025   enum Section { Unknown = 0, EM = 1, HAD = 2 };
0026 
0027   // 1 => CaloTower, 2 => ZDC, 3 => Castor
0028   static const int SubdetectorId = 3;
0029 
0030   /** Create a null cellid*/
0031   HcalCastorDetId();
0032 
0033   /** Create cellid from raw id (0=invalid tower id) */
0034   HcalCastorDetId(uint32_t rawid);
0035 
0036   /** Constructor from section, z-side, sector and module */
0037   HcalCastorDetId(Section section, bool true_for_positive_eta, int sector, int module);
0038 
0039   // constructor without section
0040   HcalCastorDetId(bool true_for_positive_eta, int sector, int module);
0041 
0042   /** Constructor from a generic cell id */
0043   HcalCastorDetId(const DetId& id);
0044 
0045   /** Assignment from a generic cell id */
0046   HcalCastorDetId& operator=(const DetId& id);
0047 
0048   /// get the z-side of the cell (1/-1)
0049   //int zside() const { return (id_&0x40)?(1):(-1); }
0050   int zside() const { return 2 * ((id_ >> 8) & 0x1) - 1; }
0051 
0052   /// get the section
0053   //Section section() const { return (Section)((id_>>7)&0x3); }
0054   Section section() const;
0055 
0056   /// get the module (1-2 for EM, 1-12 for HAD)
0057   //int module() const { return id_&0xF; }
0058   int module() const { return (id_ & 0xF); }
0059 
0060   /// get the sector (1-16)
0061   //int sector() const { return (id_>>6)&0x3; }
0062   int sector() const { return ((id_ >> 4) & 0xF) + 1; }
0063 
0064   // get the individual cell id
0065   //  int channel() const;
0066 
0067   static constexpr int kNumberModulesPerEnd = 14, kNumberSectorsPerEnd = 16,
0068                        kNumberCellsPerEnd = kNumberModulesPerEnd * kNumberSectorsPerEnd,
0069                        kSizeForDenseIndexing = kNumberCellsPerEnd;
0070 
0071   uint32_t denseIndex() const;
0072 
0073   static bool validDetId(Section iSection, bool posEta, int iSector, int iMod);
0074 
0075   static bool validDenseIndex(uint32_t din) { return (din < kSizeForDenseIndexing); }
0076 
0077   static HcalCastorDetId detIdFromDenseIndex(uint32_t di);
0078 
0079 private:
0080   void buildMe(Section section, bool true_for_positive_eta, int sector, int module);
0081 };
0082 
0083 std::ostream& operator<<(std::ostream&, const HcalCastorDetId& id);
0084 
0085 #endif  // HcalCastorDetId_h_included