CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00006 //
00007 //   $Date: 2007/10/18 12:19:14 $
00008 //   $Revision: 1.3 $
00009 //
00010 //   Author :
00011 //   H. Sakulin                    HEPHY Vienna
00012 //
00013 //   Migrated to CMSSW:
00014 //   I. Mikulec
00015 //
00016 //--------------------------------------------------
00017 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuRegionalCand_h
00018 #define DataFormatsL1GlobalMuonTrigger_L1MuRegionalCand_h
00019 
00020 //------------------------------------
00021 // Collaborating Class Declarations --
00022 //------------------------------------
00023 
00024 //              ---------------------
00025 //              -- Class Interface --
00026 //              ---------------------
00027 
00028 class L1MuRegionalCand {
00029 
00030   public:
00031   
00033     L1MuRegionalCand(unsigned dataword = 0, int bx = 0); 
00034 
00036     L1MuRegionalCand(unsigned type_idx, unsigned phi, unsigned eta, unsigned pt, unsigned charge,
00037                      unsigned ch_valid, unsigned finehalo, unsigned quality, int bx);
00038 
00040     virtual ~L1MuRegionalCand() {}
00041     
00045 
00047     virtual bool empty() const { 
00048       return (readDataField( PT_START, PT_LENGTH) == 0) || (readDataField( PHI_START, PHI_LENGTH) == 0xff); 
00049     }
00050 
00052     float phiValue() const;   
00053 
00055     float etaValue() const;    
00056 
00058     float ptValue() const;
00059     
00061     int chargeValue() const { return readDataField( CHARGE_START, CHARGE_LENGTH) == 0 ? 1: -1; }
00062         
00064     bool chargeValid() const { return charge_valid_packed() == 1; }
00065 
00067     bool isFineHalo() const { return finehalo_packed() == 1; }
00068 
00070     unsigned int quality() const { return quality_packed(); }    
00071         
00073     unsigned type_idx() const { return (int) readDataField( TYPE_START, TYPE_LENGTH); };
00074 
00076     int bx() const { return  m_bx; }
00077 
00078 
00082 
00084     unsigned phi_packed() const { return readDataField (PHI_START, PHI_LENGTH); } 
00085 
00087     unsigned pt_packed() const { return readDataField (PT_START, PT_LENGTH); } 
00088 
00090     unsigned int quality_packed() const { return readDataField( QUAL_START, QUAL_LENGTH); }
00091 
00093     unsigned eta_packed() const { return readDataField( ETA_START, ETA_LENGTH); }
00094 
00096     unsigned finehalo_packed() const { return readDataField( FINEHALO_START, FINEHALO_LENGTH); }
00097 
00099     unsigned charge_packed() const { return readDataField( CHARGE_START, CHARGE_LENGTH); } 
00100 
00102     unsigned charge_valid_packed() const { return readDataField( CHVALID_START, CHVALID_LENGTH); } 
00103 
00105     unsigned getDataWord() const { return m_dataWord; };
00106 
00110 
00112     void setType(unsigned type) { writeDataField( TYPE_START, TYPE_LENGTH, type); }
00113 
00115     void setBx(int bx) { m_bx = bx; }
00116 
00118     void setPhiPacked(unsigned phi) { writeDataField (PHI_START, PHI_LENGTH, phi); }
00119 
00121     void setPtPacked(unsigned pt) { writeDataField (PT_START, PT_LENGTH, pt); }
00122 
00124     void setQualityPacked(unsigned qual) { writeDataField (QUAL_START, QUAL_LENGTH, qual); }
00125 
00127     void setChargePacked(unsigned ch) { writeDataField (CHARGE_START, CHARGE_LENGTH, ch); }
00128 
00130     void setChargeValidPacked(unsigned valid) { writeDataField( CHVALID_START, CHVALID_LENGTH, valid ); }
00131 
00133     void setEtaPacked(unsigned eta) { writeDataField (ETA_START, ETA_LENGTH, eta); }
00134 
00136     void setFineHaloPacked(unsigned fh) { writeDataField (FINEHALO_START, FINEHALO_LENGTH, fh); }
00137 
00138 
00142 
00144     void setPhiValue(float phiVal) {m_phiValue = phiVal;}
00145 
00147     void setPtValue(float ptVal) {m_ptValue = ptVal;}
00148 
00150     void setEtaValue(float etaVal) {m_etaValue = etaVal;}
00151 
00153     void setChargeValue(int charge) { writeDataField (CHARGE_START, CHARGE_LENGTH, charge == 1 ? 0 : 1); }
00154 
00156     void setChargeValid(bool valid) { writeDataField( CHVALID_START, CHVALID_LENGTH, valid ? 1 : 0); }
00157 
00159     void setFineHalo(bool fh) { writeDataField (FINEHALO_START, FINEHALO_LENGTH, fh ? 1 : 0); }
00160 
00161 
00163     virtual void reset();
00164 
00166     void setDataWord(unsigned dataword) { m_dataWord = dataword;}
00167 
00169     virtual void print() const;
00170 
00171   private:
00172     unsigned readDataField(unsigned start, unsigned count) const; 
00173     void writeDataField(unsigned start, unsigned count, unsigned value); 
00174 
00175   private:
00176     int m_bx;
00177     unsigned m_dataWord;                                   // muon data word (25 bits) :
00178 
00179     float m_phiValue;
00180     float m_etaValue;
00181     float m_ptValue;
00182     static const float m_invalidValue;
00183 
00184 
00185   public:
00186                                                            // definition of the bit fields
00187     enum { PHI_START=0};       enum { PHI_LENGTH = 8};     // Bits 0:7   phi (8 bits)
00188     enum { PT_START=8};        enum { PT_LENGTH =  5};     // Bits 8:12  pt  (5 bits)
00189     enum { QUAL_START=13};     enum { QUAL_LENGTH = 3};    // Bits 13:15 quality (3 bits)
00190     enum { ETA_START=16};      enum { ETA_LENGTH = 6};     // Bits 16:21 eta (6 bits)
00191     enum { FINEHALO_START=22}; enum { FINEHALO_LENGTH = 1};// Bit  22 Eta is fine (DT) / Halo (CSC)
00192     enum { CHARGE_START=23};   enum { CHARGE_LENGTH = 1};  // Bit  23 Charge: 0 = positive
00193     enum { CHVALID_START=24};  enum { CHVALID_LENGTH = 1}; // Bit  24 Charge is vaild (1=valid)
00194                                                            // Bits 26 to 29: Synchronization
00195  
00196     enum { TYPE_START=30};     enum { TYPE_LENGTH = 2};    // Bit  30/31 type DT, bRPC, CSC, fRPC
00197                                                            // these bits are not sent to the GMT in hardware
00198 };
00199 #endif