Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DataFormats_ForwardDetId_HGCScintillatorDetId_H
0002 #define DataFormats_ForwardDetId_HGCScintillatorDetId_H 1
0003 
0004 #include <iosfwd>
0005 #include <vector>
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0008 
0009 /* \brief description of the bit assigment
0010    [0:8]   iphi index wrt x-axis on +z side
0011    [9:16]  |ring| index (starting from a minimum radius depending on type)
0012    [17:21] Layer #
0013    [22]    Trigger(1)/Detector(0) cell
0014    [23]    SiPM type (0 for 2mm: 1 for 4mm)
0015    [24]    Free
0016    [25:25] z-side (0 for +z; 1 for -z)
0017    [26:27] Tile granularity and type (0 fine divisions of scintillators;
0018                                       1 coarse divisions of type "c";
0019                                       2 coarse divisions of type "m")
0020    [28:31] Detector type (HGCalHSc)
0021 */
0022 
0023 class HGCScintillatorDetId : public DetId {
0024 public:
0025   /** Create a null cellid*/
0026   HGCScintillatorDetId();
0027   /** Create cellid from raw id (0=invalid tower id) */
0028   HGCScintillatorDetId(uint32_t rawid);
0029   /** Constructor from subdetector, zplus, layer, module, cell numbers */
0030   HGCScintillatorDetId(int type, int layer, int ring, int iphi, bool trigger = false, int sipm = 0);
0031   /** Constructor from a generic cell id */
0032   HGCScintillatorDetId(const DetId& id);
0033   /** Assignment from a generic cell id */
0034   HGCScintillatorDetId& operator=(const DetId& id);
0035 
0036   /** Converter for a geometry cell id */
0037   HGCScintillatorDetId geometryCell() const;
0038 
0039   /// get the subdetector
0040   DetId::Detector subdet() const { return det(); }
0041 
0042   /// get/set the type
0043   int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0044   void setType(int type);
0045 
0046   /// get the z-side of the cell (1/-1)
0047   int zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
0048 
0049   /// get the layer #
0050   int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0051 
0052   /// get the eta index
0053   int ring() const;
0054   int iradiusAbs() const { return ring(); }
0055   int iradius() const { return zside() * ring(); }
0056   int ietaAbs() const { return ring(); }
0057   int ieta() const { return zside() * ring(); }
0058 
0059   /// get the phi index
0060   int iphi() const;
0061   std::pair<int, int> ietaphi() const { return std::pair<int, int>(ieta(), iphi()); }
0062   std::pair<int, int> ringphi() const { return std::pair<int, int>(iradius(), iphi()); }
0063 
0064   /// get/set the sipm size
0065   int sipm() const { return (id_ >> kHGCalSiPMOffset) & kHGCalSiPMMask; }
0066   void setSiPM(int sipm);
0067 
0068   /// trigger or detector cell
0069   std::vector<HGCScintillatorDetId> detectorCells() const;
0070   bool trigger() const { return (((id_ >> kHGCalTriggerOffset) & kHGCalTriggerMask) == 1); }
0071   HGCScintillatorDetId triggerCell() const;
0072 
0073   /// consistency check : no bits left => no overhead
0074   bool isEE() const { return false; }
0075   bool isHE() const { return true; }
0076   bool isForward() const { return true; }
0077 
0078   static const HGCScintillatorDetId Undefined;
0079 
0080 public:
0081   static const int kHGCalPhiOffset = 0;
0082   static const int kHGCalPhiMask = 0x1FF;
0083   static const int kHGCalRadiusOffset = 9;
0084   static const int kHGCalRadiusMask = 0xFF;
0085   static const int kHGCalLayerOffset = 17;
0086   static const int kHGCalLayerMask = 0x1F;
0087   static const int kHGCalTriggerOffset = 22;
0088   static const int kHGCalTriggerMask = 0x1;
0089   static const int kHGCalSiPMOffset = 23;
0090   static const int kHGCalSiPMMask = 0x1;
0091   static const int kHGCalSiPMMask0 = 0xFF7FFFFF;
0092   static const int kHGCalZsideOffset = 25;
0093   static const int kHGCalZsideMask = 0x1;
0094   static const int kHGCalTypeOffset = 26;
0095   static const int kHGCalTypeMask = 0x3;
0096   static const int kHGCalTypeMask0 = 0xF3FFFFFF;
0097 
0098   int iradiusTriggerAbs() const;
0099   int iradiusTrigger() const { return zside() * iradiusTriggerAbs(); }
0100   int iphiTrigger() const;
0101 };
0102 
0103 std::ostream& operator<<(std::ostream&, const HGCScintillatorDetId& id);
0104 
0105 #endif