Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:54

0001 #ifndef L1TMuonEndCap_PhiMemoryImage_h
0002 #define L1TMuonEndCap_PhiMemoryImage_h
0003 
0004 #include <cstdint>
0005 #include <iosfwd>
0006 
0007 // Originally written by Ivan Furic and Matt Carver (Univ of Florida)
0008 
0009 class PhiMemoryImage {
0010 public:
0011   typedef uint64_t value_type;
0012 
0013   PhiMemoryImage();
0014   ~PhiMemoryImage();
0015 
0016   // Copy constructor, move constructor and copy assignment
0017   PhiMemoryImage(const PhiMemoryImage& other);
0018   PhiMemoryImage(PhiMemoryImage&& other) noexcept;
0019   PhiMemoryImage& operator=(PhiMemoryImage other);
0020 
0021   void swap(PhiMemoryImage& other);
0022 
0023   void reset();
0024 
0025   void set_bit(unsigned int layer, unsigned int bit);
0026 
0027   void clear_bit(unsigned int layer, unsigned int bit);
0028 
0029   bool test_bit(unsigned int layer, unsigned int bit) const;
0030 
0031   void set_word(unsigned int layer, unsigned int unit, value_type value);
0032 
0033   value_type get_word(unsigned int layer, unsigned int unit) const;
0034 
0035   void set_straightness(int s) { _straightness = s; }
0036 
0037   int get_straightness() const { return _straightness; }
0038 
0039   // Left rotation by n bits
0040   void rotl(unsigned int n);
0041 
0042   // Right rotation by n bits
0043   void rotr(unsigned int n);
0044 
0045   // Kind of like AND operator
0046   // It returns a layer code which encodes
0047   //   bit 0: st3 or st4 hit
0048   //   bit 1: st2 hit
0049   //   bit 2: st1 hit
0050   unsigned int op_and(const PhiMemoryImage& other) const;
0051 
0052   void print(std::ostream& out) const;
0053 
0054 private:
0055   void check_input(unsigned int layer, unsigned int bit) const;
0056 
0057   // Num of layers
0058   //   [0,1,2,3] --> [st1,st2,st3,st4]
0059   static const unsigned int _layers = 4;
0060 
0061   // Num of value_type allocated per layer
0062   //   3 * 64 bits = 192 bits
0063   static const unsigned int _units = 3;
0064 
0065   // Hits in non-key stations
0066   value_type _buffer[_layers][_units];
0067 
0068   int _straightness;
0069 };
0070 
0071 // _____________________________________________________________________________
0072 // Output streams
0073 std::ostream& operator<<(std::ostream& o, const PhiMemoryImage& p);
0074 
0075 #endif