Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

LHCbID.h

Go to the documentation of this file.
00001 
00002 //   **************************************************************************
00003 //   *                                                                        *
00004 //   *                      ! ! ! A T T E N T I O N ! ! !                     *
00005 //   *                                                                        *
00006 //   *  This file was created automatically by GaudiObjDesc, please do not    *
00007 //   *  delete it or edit it by hand.                                         *
00008 //   *                                                                        *
00009 //   *  If you want to change this file, first change the corresponding       *
00010 //   *  xml-file and rerun the tools from GaudiObjDesc (or run make if you    *
00011 //   *  are using it from inside a Gaudi-package).                            *
00012 //   *                                                                        *
00013 //   **************************************************************************
00014 
00015 #ifndef LHCbKernel_LHCbID_H
00016 #define LHCbKernel_LHCbID_H 1
00017 
00018 // Include files
00019 #include "Kernel/VeloChannelID.h"
00020 #include "Kernel/ITChannelID.h"
00021 #include "Kernel/OTChannelID.h"
00022 #include "Kernel/RichSmartID.h"
00023 #include "Kernel/CaloCellID.h"
00024 #include <ostream>
00025 
00026 
00027 // Forward declarations
00028 class LHCbID;
00029 
00030 
00040 class LHCbID
00041 {
00042 public:
00043 
00045   LHCbID(const VeloChannelID& chanID,
00046          const unsigned int size=0);
00047 
00049   LHCbID(const ITChannelID& chanID,
00050          const unsigned int size=0);
00051 
00053   LHCbID(const OTChannelID& chanID);
00054 
00056   LHCbID(const RichSmartID& chanID);
00057 
00059   LHCbID(const CaloCellID& chanID);
00060 
00062   LHCbID() : m_lhcbID(0) {}
00063 
00065   virtual ~LHCbID() {}
00066 
00068   friend std::ostream& operator<< (std::ostream& str,
00069                                    const LHCbID& obj);
00070 
00072   virtual std::ostream& fillStream(std::ostream& s) const;
00073 
00075   bool operator==(const LHCbID& chanID) const;
00076 
00078   bool isVelo() const;
00079 
00081   VeloChannelID veloID() const;
00082 
00084   bool isST() const;
00085 
00087   ITChannelID stID() const;
00088 
00090   bool isOT() const;
00091 
00093   OTChannelID otID() const;
00094 
00096   bool isRich() const;
00097 
00099   RichSmartID richID() const;
00100 
00102   bool isCalo() const;
00103 
00105   CaloCellID caloID() const;
00106 
00108   unsigned int channelID() const;
00109 
00111   void setSpareBits(unsigned int value);
00112 
00114   unsigned int spareBits() const;
00115 
00117   unsigned int lhcbID() const;
00118 
00120   void setID(unsigned int value);
00121 
00123   unsigned int detectorType() const;
00124 
00126   void setDetectorType(unsigned int value);
00127 
00128 protected:
00129 
00131   enum SpecificMask{ veloMask= 0x1FFFFFL,
00132                      stMask=0x3FFFFFFL,
00133                      otMask=0x3FFFFFFL };
00135   enum SpecificBits{ veloBits=21,
00136                      stBits=26,
00137                      otBits=26 };
00138 
00139 private:
00140 
00142   enum channelIDType{ veloType=1,
00143                       stType,
00144                       otType,
00145                       richType,
00146                       caloType,
00147                       muonType };
00148 
00150   enum lhcbIDBits{IDBits           = 0,
00151                   detectorTypeBits = 28};
00152 
00154   enum lhcbIDMasks{IDMask           = 0xFFFFFFFL,
00155                    detectorTypeMask = 0xF0000000L};
00156 
00157 
00158   unsigned int m_lhcbID; 
00159 
00160 };
00161 
00162 // -----------------------------------------------------------------------------
00163 //   end of class
00164 // -----------------------------------------------------------------------------
00165 
00166 // Including forward declarations
00167 
00168 inline LHCbID::LHCbID(const VeloChannelID& chanID,
00169                       const unsigned int size) 
00170 {
00171 
00172 m_lhcbID = (veloType << detectorTypeBits) +
00173            (size     << veloBits ) +
00174            chanID;
00175           
00176 }
00177 
00178 inline LHCbID::LHCbID(const ITChannelID& chanID,
00179                       const unsigned int size) 
00180 {
00181 
00182 m_lhcbID = (stType << detectorTypeBits) +
00183           (size   << stBits ) +
00184           ((chanID.uniqueWafer()-1) >>6) +
00185           (chanID.strip()-1) ;
00186         
00187 }
00188 
00189 inline LHCbID::LHCbID(const OTChannelID& chanID) 
00190 {
00191 
00192 m_lhcbID = (otType << detectorTypeBits) + chanID;
00193         
00194 }
00195 
00196 inline LHCbID::LHCbID(const RichSmartID& chanID) : m_lhcbID(0) 
00197 {
00198 
00199   unsigned int richData = chanID.dataBitsOnly();
00200   if( chanID.pixelDataAreValid() ) richData += 0x8000000;
00201   setDetectorType( richType );
00202   setID( richData );
00203          
00204 }
00205 
00206 inline LHCbID::LHCbID(const CaloCellID& chanID) : m_lhcbID(0) 
00207 {
00208 
00209   setDetectorType( caloType );
00210   setID( chanID.ccid() );
00211          
00212 }
00213 
00214 inline std::ostream& operator<< (std::ostream& str,
00215                                  const LHCbID& obj)
00216 {
00217   return obj.fillStream(str);
00218 }
00219 
00220 inline std::ostream& LHCbID::fillStream(std::ostream& s) const
00221 {
00222   s << "{ " << "lhcbID :        " << m_lhcbID << std::endl << " }";
00223   return s;
00224 }
00225 
00226 
00227 inline unsigned int LHCbID::lhcbID() const 
00228 {
00229   return m_lhcbID;
00230 }
00231 
00232 inline void LHCbID::setID(unsigned int value)
00233 {
00234   unsigned int val = (unsigned int)value;
00235   m_lhcbID &= ~IDMask;
00236   m_lhcbID |= ((((unsigned int)val) << IDBits) & IDMask);
00237 }
00238 
00239 inline unsigned int LHCbID::detectorType() const
00240 {
00241   return (unsigned int)((m_lhcbID & detectorTypeMask) >> detectorTypeBits);
00242 }
00243 
00244 inline void LHCbID::setDetectorType(unsigned int value)
00245 {
00246   unsigned int val = (unsigned int)value;
00247   m_lhcbID &= ~detectorTypeMask;
00248   m_lhcbID |= ((((unsigned int)val) << detectorTypeBits) & detectorTypeMask);
00249 }
00250 
00251 inline bool LHCbID::operator==(const LHCbID& chanID) const 
00252 {
00253 
00254   return (this->lhcbID() == chanID.lhcbID());
00255          
00256 }
00257 
00258 inline bool LHCbID::isVelo() const 
00259 {
00260 
00261   return (veloType == detectorType());
00262          
00263 }
00264 
00265 inline VeloChannelID LHCbID::veloID() const 
00266 {
00267 
00268 if ( !isVelo() ) return 0xF0000000;
00269 return ( m_lhcbID & veloMask );
00270          
00271 }
00272 
00273 inline bool LHCbID::isST() const 
00274 {
00275 
00276   return (stType == detectorType());
00277          
00278 }
00279 
00280 inline ITChannelID LHCbID::stID() const 
00281 {
00282 
00283 if ( !isST() ) return 0xF0000000;
00284 return ( ( (m_lhcbID & 0x3FFFC00 ) << 6) + ( m_lhcbID & 0x3FF));
00285          
00286 }
00287 
00288 inline bool LHCbID::isOT() const 
00289 {
00290 
00291 return (otType == detectorType());
00292          
00293 }
00294 
00295 inline OTChannelID LHCbID::otID() const 
00296 {
00297 
00298 if ( !isOT() ) return  0xF0000000;
00299 return m_lhcbID & otMask;
00300          
00301 }
00302 
00303 inline bool LHCbID::isRich() const 
00304 {
00305 
00306   return (richType == detectorType());
00307          
00308 }
00309 
00310 inline RichSmartID LHCbID::richID() const 
00311 {
00312 
00313 if ( !isRich() ) return 0x0;
00314 int id = m_lhcbID & IDMask;
00315 if( id && 0x8000000 ) id = id | 0x7E000000;
00316 return id;
00317          
00318 }
00319 
00320 inline bool LHCbID::isCalo() const 
00321 {
00322 
00323   return (caloType == detectorType());
00324          
00325 }
00326 
00327 inline CaloCellID LHCbID::caloID() const 
00328 {
00329 
00330   return isCalo() ? (m_lhcbID & IDMask) : 0xF0000000;
00331          
00332 }
00333 
00334 inline unsigned int LHCbID::channelID() const 
00335 {
00336 
00337 return m_lhcbID & IDMask;
00338         
00339 }
00340 
00341 inline void LHCbID::setSpareBits(unsigned int value) 
00342 {
00343 
00344   if ( !( isVelo() || isOT() || isST() ) ) return;
00345   unsigned int mask = IDMask;
00346   unsigned int bits = IDBits;
00347   if (isVelo()) {
00348     mask &= (~veloMask);
00349     bits = veloBits;
00350   } else if (isST()) {
00351     mask &= (~stMask);
00352     bits = stBits;
00353   } else if (isOT()) {
00354     mask &= (~otMask);
00355     bits = otBits;
00356   }
00357   m_lhcbID &= ~mask;
00358   m_lhcbID |= ((value << bits) & mask);
00359         
00360 }
00361 
00362 inline unsigned int LHCbID::spareBits() const 
00363 {
00364 
00365   if ( !( isVelo() || isOT() || isST()) ) return 0;
00366   unsigned int mask = IDMask;
00367   unsigned int bits = IDBits;
00368   if (isVelo()) {
00369      mask &= (~veloMask);         
00370      bits = veloBits;
00371   } else if (isST()) {
00372     mask &= (~stMask);
00373     bits = stBits;
00374   } else if (isOT()) {
00375      mask &= (~otMask);   
00376      bits = otBits;
00377   }
00378   unsigned int val = ((m_lhcbID & mask) >> bits);
00379   return val;
00380          
00381 }
00382 
00383 
00384 #endif 

Generated on Mon Jul 4 13:54:28 2005 for New Track Event Model by doxygen 1.4.1