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

Generated on Wed May 4 11:52:34 2005 for New Track Event Model by doxygen 1.4.1