00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: MdcSegUsage.h,v 1.2 2009/12/16 09:02:47 zhangy Exp $ 00004 // 00005 // Description: 00006 // Records usage of a single hit in one of my segments. Association 00007 // with hit must be maintained externally. 00008 // 00009 // Environment: 00010 // Software developed for the BaBar Detector at the SLAC B-Factory. 00011 // 00012 // Author(s): 00013 // Steve Schaffner 00014 // Zhang Yao(zhangyao@ihep.ac.cn) Migrate to BESIII 00015 //------------------------------------------------------------------------ 00016 #ifndef MDCSEGUSAGE_H 00017 #define MDCSEGUSAGE_H 00018 00019 class MdcSegUsage { 00020 public: 00021 MdcSegUsage(); 00022 virtual ~MdcSegUsage(); 00023 00024 inline bool usedSeg() const; 00025 inline bool usedAmbig(int i) const; 00026 inline void setUsedAmbig(int i); 00027 void killHit(); 00028 bool deadHit() const {return ((segUse & deadFlag()) != 0);} 00029 00030 private: 00031 // Bit-mapping definitions for segment hit use word 00032 unsigned usedNegAmb() const {return 1u;} 00033 unsigned usedPosAmb() const {return 2u;} 00034 unsigned deadFlag() const {return 4u;} 00035 00036 unsigned segUse; 00037 00038 // Preempt 00039 MdcSegUsage& operator= (const MdcSegUsage&); 00040 MdcSegUsage(const MdcSegUsage &); 00041 }; 00042 00043 // inline functs: 00044 bool 00045 MdcSegUsage::usedSeg(void) const { 00046 return ( (segUse & (usedNegAmb() | usedPosAmb())) != 0); 00047 } 00048 00049 void MdcSegUsage::setUsedAmbig(int i) { 00050 if (i <= 0) { segUse |= usedNegAmb(); } 00051 else { segUse |= usedPosAmb(); } 00052 } 00053 00054 bool 00055 MdcSegUsage::usedAmbig(int ambig) const { 00056 if (ambig <= 0) { 00057 return (usedNegAmb() & segUse) != 0; 00058 } 00059 else { 00060 return (usedPosAmb() & segUse) != 0; 00061 } 00062 } 00063 00064 #endif 00065