CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00009 //
00010 //   $Date: 2007/04/02 15:44:06 $
00011 //   $Revision: 1.5 $
00012 //
00013 //   Author :
00014 //   H. Sakulin               HEPHY Vienna
00015 //   N. Neumeister            CERN EP 
00016 //
00017 //   Migrated to CMSSW:
00018 //   I. Mikulec
00019 //
00020 //--------------------------------------------------
00021 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
00022 #define DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
00023 
00024 //---------------
00025 // C++ Headers --
00026 //---------------
00027 #include <string>
00028 
00029 //----------------------
00030 // Base Class Headers --
00031 //----------------------
00032 
00033 //------------------------------------
00034 // Collaborating Class Declarations --
00035 //------------------------------------
00036 
00037 
00038 //              ---------------------
00039 //              -- Class Interface --
00040 //              ---------------------
00041 
00042 class L1MuGMTCand {
00043 
00044   public:
00045 
00047     L1MuGMTCand();
00048    
00050     L1MuGMTCand(unsigned data, int bx=0);
00051    
00053     L1MuGMTCand(const L1MuGMTCand&);
00054 
00056     virtual ~L1MuGMTCand();
00057 
00059     void reset();
00060 
00061     //
00062     // Getters
00063     //
00064 
00066     bool empty() const { return readDataField( PT_START, PT_LENGTH) == 0; }
00067 
00069     unsigned getDataWord() const { return m_dataWord; }
00070 
00072     std::string name() const { return m_name; }
00073 
00075     unsigned int phiIndex() const { return readDataField( PHI_START, PHI_LENGTH); }
00076     
00078     unsigned int ptIndex() const { return readDataField( PT_START, PT_LENGTH); }
00079     
00081 
00095     unsigned int quality() const { return readDataField( QUAL_START, QUAL_LENGTH); }
00096 
00098     bool useInSingleMuonTrigger() const { return quality() >= 4; };
00099     
00101     bool useInDiMuonTrigger() const { return (quality() >= 3) && (quality() !=4); }; 
00102 
00104     bool isMatchedCand() const { return quality() == 7; }
00105 
00107     bool isHaloCand() const { return quality() == 1; }
00108 
00110     unsigned int etaIndex() const { return readDataField( ETA_START, ETA_LENGTH); }
00111     
00113     unsigned sysign() const { return readDataField( SYSIGN_START, SYSIGN_LENGTH); }
00114     
00116     bool isol() const { return readDataField( ISO_START, ISO_LENGTH) == 1; }
00117 
00119     bool mip() const { return readDataField( MIP_START, MIP_LENGTH) == 1; } 
00120     
00122     int bx() const { return m_bx; }
00123     
00126     float phiValue() const;
00127     
00130     float etaValue() const;
00131     
00134     float ptValue() const;
00135     
00137     int charge() const { return (readDataField( SYSIGN_START, SYSIGN_LENGTH) & 1 ) == 0 ? 1: -1; }
00138         
00140     bool charge_valid() const { 
00141       unsigned sysign = readDataField( SYSIGN_START, SYSIGN_LENGTH) ;
00142       return  (sysign == 0 || sysign == 1 );
00143     }
00144     
00146     bool isSyncWord() const { return readDataField( SYSIGN_START, SYSIGN_LENGTH) == 3; }
00147     
00151     
00153     void setPhiPacked(unsigned phi) { writeDataField( PHI_START, PHI_LENGTH, phi); }
00154     
00156     void setPtPacked(unsigned pt) { writeDataField( PT_START, PT_LENGTH, pt); }
00157     
00159     void setQuality(unsigned quality) { writeDataField( QUAL_START, QUAL_LENGTH, quality); }
00160 
00162     void setEtaPacked(unsigned eta) { writeDataField( ETA_START, ETA_LENGTH, eta); }
00163 
00165     void setIsolation(bool isol) { writeDataField( ISO_START, ISO_LENGTH, isol?1:0); }
00166     
00168     void setMIP(bool mip) { writeDataField( MIP_START, MIP_LENGTH, mip?1:0); }    
00169 
00171     void setChargePacked(unsigned ch) { writeDataField( SYSIGN_START, SYSIGN_LENGTH, ch); }    
00172 
00174     void setBx(int bx) { m_bx = bx; }
00175 
00177 
00179     void setPhiValue(float phiVal) {m_phiValue = phiVal;}
00180 
00182     void setPtValue(float ptVal) {m_ptValue = ptVal;}
00183 
00185     void setEtaValue(float etaVal) {m_etaValue = etaVal;}
00186 
00187     //
00188     // Other
00189     //
00190 
00191     unsigned int linearizedPt(float lsbValue, unsigned maxScale) const { return 0; }
00192 
00193     unsigned int etaRegionIndex() const { return etaIndex(); }
00194 
00195     unsigned int phiRegionIndex() const { return phiIndex(); }
00196 
00198     bool operator==(const L1MuGMTCand&) const;
00199     
00201     bool operator!=(const L1MuGMTCand&) const;
00202 
00204     void print() const;
00205   
00207     friend std::ostream& operator<<(std::ostream&, const L1MuGMTCand&);
00208 
00209   protected: 
00210 
00211   protected: 
00212     inline unsigned readDataField(unsigned start, unsigned count) const; 
00213     inline void writeDataField(unsigned start, unsigned count, unsigned value); 
00214 
00215     std::string       m_name;
00216     int          m_bx;      // in here only for technical reasons in simulation
00217     unsigned m_dataWord;                                // muon data word (26 bits) :
00218 
00219     float m_phiValue;
00220     float m_etaValue;
00221     float m_ptValue;
00222     static const float m_invalidValue;
00223 
00224 
00225                                                         // definition of the bit fields
00226     enum { PHI_START=0};     enum { PHI_LENGTH = 8};    // Bits 0:7   phi (8 bits)
00227     enum { PT_START=8};      enum { PT_LENGTH =  5};    // Bits 8:12  pt  (5 bits)
00228     enum { QUAL_START=13};   enum { QUAL_LENGTH = 3};   // Bits 13:15 quality (3 bits)
00229     enum { ETA_START=16};    enum { ETA_LENGTH = 6};    // Bits 16:21 eta (6 bits)
00230     enum { ISO_START=22};    enum { ISO_LENGTH = 1};    // Bit  22    Isolation
00231     enum { MIP_START=23};    enum { MIP_LENGTH = 1};    // Bit  23    MIP
00232     enum { SYSIGN_START=24}; enum { SYSIGN_LENGTH = 2}; // Bit  24:25 Charge/Syncword
00233 };
00234 
00235 unsigned L1MuGMTCand::readDataField(unsigned start, unsigned count) const {
00236   unsigned mask = ( (1 << count) - 1 ) << start;
00237   return (m_dataWord & mask) >> start;
00238 }
00239 
00240 void L1MuGMTCand::writeDataField(unsigned start, unsigned count, unsigned value) {
00241   unsigned mask = ( (1 << count) - 1 ) << start;
00242   m_dataWord &= ~mask; // clear
00243   m_dataWord |= (value << start) & mask ;
00244 }
00245 
00246 
00247 #endif