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 
00048   LHCbID(const ITChannelID& chanID);
00049 
00051   LHCbID(const OTChannelID& chanID);
00052 
00054   LHCbID(const RichSmartID& chanID);
00055 
00057   LHCbID(const CaloCellID& chanID);
00058 
00060   LHCbID() : m_lhcbID(0) {}
00061 
00063   virtual ~LHCbID() {}
00064 
00066   friend std::ostream& operator<< (std::ostream& str,
00067                                    const LHCbID& obj);
00068 
00070   virtual std::ostream& fillStream(std::ostream& s) const;
00071 
00073   bool operator==(const LHCbID& chanID) const;
00074 
00076   bool isVelo() const;
00077 
00079   VeloChannelID veloID() const;
00080 
00082   bool isST() const;
00083 
00085   ITChannelID stID() const;
00086 
00088   bool isOT() const;
00089 
00091   OTChannelID otID() const;
00092 
00094   bool isRich() const;
00095 
00097   RichSmartID richID() const;
00098 
00100   bool isCalo() const;
00101 
00103   CaloCellID caloID() const;
00104 
00106   unsigned int channelID() const;
00107 
00109   void setSpareBits(unsigned int value);
00110 
00112   unsigned int spareBits() const;
00113 
00115   unsigned int lhcbID() const;
00116 
00118   void setChannelID(unsigned int value);
00119 
00121   unsigned int detectorType() const;
00122 
00124   void setDetectorType(unsigned int value);
00125 
00126 protected:
00127 
00129   enum SpecificMask{ veloMask= 0x1FFFFFL,
00130                      otMask=0x3FFFFFFL };
00132   enum SpecificBits{ veloBits=21,
00133                      otBits=26 };
00134 
00135 private:
00136 
00138   enum channelIDType{ veloType=1,
00139                       stType,
00140                       otType,
00141                       richType,
00142                       caloType,
00143                       muonType };
00144 
00146   enum lhcbIDBits{channelIDBits    = 0,
00147                   detectorTypeBits = 28};
00148 
00150   enum lhcbIDMasks{channelIDMask    = 0xFFFFFFFL,
00151                    detectorTypeMask = 0xF0000000L};
00152 
00153 
00154   unsigned int m_lhcbID; 
00155 
00156 };
00157 
00158 // -----------------------------------------------------------------------------
00159 //   end of class
00160 // -----------------------------------------------------------------------------
00161 
00162 // Including forward declarations
00163 
00164 inline LHCbID::LHCbID(const VeloChannelID& chanID) : m_lhcbID(0) 
00165 {
00166 
00167   setDetectorType( veloType );
00168   setChannelID( chanID );
00169           
00170 }
00171 
00172 inline LHCbID::LHCbID(const ITChannelID& chanID) : m_lhcbID(0) 
00173 {
00174 
00175   setDetectorType( stType );
00176   setChannelID( ((chanID.uniqueWafer()-1)>>4) + (chanID.strip()-1) );
00177           
00178 }
00179 
00180 inline LHCbID::LHCbID(const OTChannelID& chanID) : m_lhcbID(0) 
00181 {
00182 
00183   setDetectorType( otType );
00184   setChannelID( chanID );
00185         
00186 }
00187 
00188 inline LHCbID::LHCbID(const RichSmartID& chanID) : m_lhcbID(0) 
00189 {
00190 
00191   unsigned int richData = chanID.dataBitsOnly();
00192   if( chanID.pixelDataAreValid() ) richData += 0x8000000;
00193   setDetectorType( richType );
00194   setChannelID( richData );
00195          
00196 }
00197 
00198 inline LHCbID::LHCbID(const CaloCellID& chanID) : m_lhcbID(0) 
00199 {
00200 
00201   setDetectorType( caloType );
00202   setChannelID( chanID.ccid() );
00203          
00204 }
00205 
00206 inline std::ostream& operator<< (std::ostream& str,
00207                                  const LHCbID& obj)
00208 {
00209   return obj.fillStream(str);
00210 }
00211 
00212 inline std::ostream& LHCbID::fillStream(std::ostream& s) const
00213 {
00214   s << "{ " << "lhcbID :        " << m_lhcbID << std::endl << " }";
00215   return s;
00216 }
00217 
00218 
00219 inline unsigned int LHCbID::lhcbID() const 
00220 {
00221   return m_lhcbID;
00222 }
00223 
00224 inline void LHCbID::setChannelID(unsigned int value)
00225 {
00226   unsigned int val = (unsigned int)value;
00227   m_lhcbID &= ~channelIDMask;
00228   m_lhcbID |= ((((unsigned int)val) << channelIDBits) & channelIDMask);
00229 }
00230 
00231 inline unsigned int LHCbID::detectorType() const
00232 {
00233   return (unsigned int)((m_lhcbID & detectorTypeMask) >> detectorTypeBits);
00234 }
00235 
00236 inline void LHCbID::setDetectorType(unsigned int value)
00237 {
00238   unsigned int val = (unsigned int)value;
00239   m_lhcbID &= ~detectorTypeMask;
00240   m_lhcbID |= ((((unsigned int)val) << detectorTypeBits) & detectorTypeMask);
00241 }
00242 
00243 inline bool LHCbID::operator==(const LHCbID& chanID) const 
00244 {
00245 
00246   return (this->lhcbID() == chanID.lhcbID());
00247          
00248 }
00249 
00250 inline bool LHCbID::isVelo() const 
00251 {
00252 
00253   return (veloType == detectorType()) ? true : false;
00254          
00255 }
00256 
00257 inline VeloChannelID LHCbID::veloID() const 
00258 {
00259 
00260   return isVelo() ? channelID() : 0x0;
00261          
00262 }
00263 
00264 inline bool LHCbID::isST() const 
00265 {
00266 
00267   return (stType == detectorType()) ? true : false;
00268          
00269 }
00270 
00271 inline ITChannelID LHCbID::stID() const 
00272 {
00273 
00274   return isST() ? ( ((channelID()&0xFFFF000)<<4)+(channelID()&0xFFF) ) : 0xF0000000;
00275          
00276 }
00277 
00278 inline bool LHCbID::isOT() const 
00279 {
00280 
00281   return (otType == detectorType()) ? true : false;
00282          
00283 }
00284 
00285 inline OTChannelID LHCbID::otID() const 
00286 {
00287 
00288   return isOT() ? channelID() : 0xF0000000;
00289          
00290 }
00291 
00292 inline bool LHCbID::isRich() const 
00293 {
00294 
00295   return (richType == detectorType()) ? true : false;
00296          
00297 }
00298 
00299 inline RichSmartID LHCbID::richID() const 
00300 {
00301 
00302   unsigned int rID = 0;
00303   if( isRich() ) {
00304     rID = channelID() & 0x7000000;
00305     if( channelID() && 0x8000000 ) rID += 0x7E000000;
00306   }
00307   return rID;
00308          
00309 }
00310 
00311 inline bool LHCbID::isCalo() const 
00312 {
00313 
00314   return (caloType == detectorType()) ? true : false;
00315          
00316 }
00317 
00318 inline CaloCellID LHCbID::caloID() const 
00319 {
00320 
00321   return isCalo() ? channelID() : 0xF0000000;
00322          
00323 }
00324 
00325 inline unsigned int LHCbID::channelID() const 
00326 {
00327 
00328   unsigned mask = channelIDMask;
00329   unsigned bits  = channelIDBits;
00330   if (isVelo()) mask = veloMask;
00331   if (isOT()) mask = otMask;
00332   unsigned int id = (m_lhcbID & mask) >> bits;
00333   return id;
00334         
00335 }
00336 
00337 inline void LHCbID::setSpareBits(unsigned int value) 
00338 {
00339 
00340   if ( !( isVelo() || isOT() ) ) return;
00341   unsigned int mask = channelIDMask;
00342   unsigned int bits = channelIDBits;
00343   if (isVelo()) {
00344     mask &= (~veloMask);
00345     bits = veloBits;
00346   } else if (isOT()) {
00347     mask &= (~otMask);
00348     bits = otBits;
00349   }
00350   m_lhcbID &= ~mask;
00351   m_lhcbID |= ((((unsigned int)value) << bits) & mask);
00352         
00353 }
00354 
00355 inline unsigned int LHCbID::spareBits() const 
00356 {
00357 
00358   if ( !( isVelo() || isOT() ) ) return 0;
00359   unsigned int mask = channelIDMask;
00360   unsigned int bits = channelIDBits;
00361   if (isVelo()) {
00362      mask &= (~veloMask);         
00363      bits = veloBits;
00364   } else if (isOT()) {
00365      mask &= (~otMask);   
00366      bits = otBits;
00367   }
00368   unsigned int val = ((m_lhcbID & mask) >> bits);
00369   return val;
00370          
00371 }
00372 
00373 
00374 #endif 

Generated on Thu Apr 7 22:43:27 2005 for New Track Event Model by doxygen 1.4.1