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

Generated on Mon Apr 4 12:38:51 2005 for New Track Event Model by doxygen 1.4.1