Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:08

0001 #ifndef DataFormats_MuonDetId_ME0DetId_h
0002 #define DataFormats_MuonDetId_ME0DetId_h
0003 
0004 /** \class ME0DetId
0005  * 
0006  *  DetUnit identifier for ME0s
0007  *
0008  */
0009 
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 
0013 #include <iosfwd>
0014 #include <iostream>
0015 
0016 class ME0DetId : public DetId {
0017 public:
0018   ME0DetId();
0019 
0020   /// Construct from a packed id. It is required that the Detector part of
0021   /// id is Muon and the SubDet part is ME0, otherwise an exception is thrown.
0022   ME0DetId(uint32_t id);
0023   ME0DetId(DetId id);
0024 
0025   /// Construct from fully qualified identifier.
0026   ME0DetId(int region, int layer, int chamber, int roll);
0027 
0028   /// Sort Operator based on the raw detector id
0029   bool operator<(const ME0DetId& r) const {
0030     if (this->layer() == r.layer()) {
0031       return this->rawId() < r.rawId();
0032     } else {
0033       return (this->layer() > r.layer());
0034     }
0035   }
0036 
0037   /// Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap
0038   int region() const { return int((id_ >> RegionStartBit_) & RegionMask_) + minRegionId; }
0039 
0040   /// Chamber id: it identifies a chamber in a ring it goes from 1 to 36
0041   int chamber() const { return int((id_ >> ChamberStartBit_) & ChamberMask_) + minChamberId; }
0042 
0043   /// Layer id: each chamber has six layers of chambers: layer 1 is the inner layer and layer 6 is the outer layer
0044   int layer() const { return int((id_ >> LayerStartBit_) & LayerMask_) + minLayerId; }
0045 
0046   /// Roll id  (also known as eta partition): each chamber is divided along the strip direction in
0047   /// several parts  (rolls) ME0 up to 10
0048   int roll() const {
0049     return int((id_ >> RollStartBit_) & RollMask_) + minRollId;  // value 0 is used as wild card
0050   }
0051 
0052   /// Return the corresponding ChamberId (mask layers)
0053   ME0DetId chamberId() const { return ME0DetId(id_ & chamberIdMask_); }
0054   /// Return the corresponding LayerId (mask eta partition)
0055   ME0DetId layerId() const { return ME0DetId(id_ & layerIdMask_); }
0056 
0057   //Return the stationId, always 1 for now
0058   int station() const { return 1; }
0059 
0060   /// For future modifications (implement more layers)
0061   int nlayers() const { return int(maxLayerId); }
0062 
0063   static constexpr int minRegionId = -1;
0064   static constexpr int maxRegionId = 1;
0065 
0066   static constexpr int minChamberId = 0;
0067   static constexpr int maxChamberId = 18;  // ME0 ring consists of 18 chambers spanning 20 degrees
0068 
0069   static constexpr int minLayerId = 0;
0070   static constexpr int maxLayerId = 6;
0071 
0072   static constexpr int minRollId = 0;
0073   static constexpr int maxRollId = 10;  // ME0 layer consists of 10 etapartitions
0074 
0075 private:
0076   static constexpr int RegionNumBits_ = 2;
0077   static constexpr int RegionStartBit_ = 0;
0078   static constexpr int RegionMask_ = 0X3;
0079 
0080   static constexpr int ChamberNumBits_ = 6;
0081   static constexpr int ChamberStartBit_ = RegionStartBit_ + RegionNumBits_;
0082   static constexpr unsigned int ChamberMask_ = 0X3F;
0083 
0084   static constexpr int LayerNumBits_ = 5;
0085   static constexpr int LayerStartBit_ = ChamberStartBit_ + ChamberNumBits_;
0086   static constexpr unsigned int LayerMask_ = 0X1F;
0087 
0088   static constexpr int RollNumBits_ = 5;
0089   static constexpr int RollStartBit_ = LayerStartBit_ + LayerNumBits_;
0090   static constexpr unsigned int RollMask_ = 0X1F;
0091 
0092 public:
0093   static constexpr uint32_t chamberIdMask_ = ~((LayerMask_ << LayerStartBit_) | (RollMask_ << RollStartBit_));
0094   static constexpr uint32_t layerIdMask_ = ~(RollMask_ << RollStartBit_);
0095 
0096 private:
0097   void init(int region, int layer, int chamber, int roll);
0098 
0099   int trind;
0100 };  // ME0DetId
0101 
0102 std::ostream& operator<<(std::ostream& os, const ME0DetId& id);
0103 
0104 #endif