00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: MdcSegData.cxx,v 1.5 2011/09/26 01:06:37 zhangy Exp $ 00004 // 00005 // Author(s): Steve Schaffner 00006 //------------------------------------------------------------------------ 00007 00008 #include "MdcTrkRecon/MdcSegData.h" 00009 #include "MdcData/MdcHit.h" 00010 #include "MdcTrkRecon/MdcSegUsage.h" 00011 #include "MdcGeom/MdcDetector.h" 00012 #include "MdcData/MdcHitMap.h" 00013 #include "MdcTrkRecon/mdcWrapWire.h" 00014 00015 //------------------------------------------------------------------------ 00016 MdcSegData::MdcSegData(bool skip) 00017 //------------------------------------------------------------------------ 00018 { 00019 eventNumber=0; 00020 _segUsage = 0; 00021 _hitMap = 0; 00022 _bunchTime = 0; 00023 _skipUsed = skip; 00024 00025 _theHits = 0; 00026 } 00027 00028 //------------------------------------------------------------------------ 00029 MdcSegData::~MdcSegData(void) { 00030 //------------------------------------------------------------------------ 00031 delete [] _segUsage; 00032 } 00033 00034 //------------------------------------------------------------------------ 00035 int 00036 MdcSegData::nhits() const { 00037 //------------------------------------------------------------------------ 00038 return _theHits->size(); 00039 } 00040 00041 //------------------------------------------------------------------------ 00042 void 00043 MdcSegData::loadevent(MdcHitCol *hitcol, MdcHitMap *hitmap, double tb) { 00044 //------------------------------------------------------------------------ 00045 _bunchTime = tb; 00046 _theHits = hitcol; 00047 _hitMap = hitmap; 00048 assert (_hitMap != 0); 00049 00050 _segUsageDict.clear(); 00051 delete [] _segUsage; 00052 _segUsage = 0; 00053 eventNumber++; 00054 00055 _segUsage = new MdcSegUsage[nhits()]; 00056 00057 MdcHit* aHit = 0; 00058 MdcHitCol::iterator iter = _theHits->begin(); 00059 int index = 0; 00060 for (;iter != _theHits->end(); iter++) { 00061 aHit = *iter; 00062 _segUsageDict.put(aHit, &(_segUsage[index])); 00063 if (skippingUsed() && aHit->usedHit()) { 00064 // Mark for later skipping 00065 _segUsage[index].killHit(); 00066 } 00067 index++; 00068 } 00069 } 00070 00071 //------------------------------------------------------------------------ 00072 const MdcHit* 00073 MdcSegData::hit(int hitno) const { 00074 //------------------------------------------------------------------------ 00075 return (*_theHits)[hitno]; 00076 } 00077 00078 00079 //------------------------------------------------------------------------ 00080 void 00081 MdcSegData::poisonHits(const MdcDetector *gm, int debug) { 00082 //------------------------------------------------------------------------ 00083 // Mark hits as poor candidates for segment-finding, if they are located 00084 // within a string of consecutive hits in the same layer (end hits are 00085 // not marked). 00086 for (int ilayer = 0; ilayer < gm->nLayer(); ilayer++) { 00087 int nwire = gm->Layer(ilayer)->nWires(); 00088 for (int iwire=0; iwire < nwire;++iwire) { 00089 int wireNext = mdcWrapWire(iwire+1, nwire); 00090 if ( 0 == hitMap()->hitWire(ilayer, wireNext) ) { 00091 // 0 1 2 3 4 00092 // next wire not there: ? o ? ? ? 00093 // so the next-to-next wire shouldn't be poisened 00094 // (it's left neighbour is empty) 00095 // and the next candidate to check is + 3 00096 iwire+=2; continue; 00097 } 00098 00099 MdcHit* theHit = hitMap()->hitWire(ilayer, iwire); 00100 if (theHit == 0) { 00101 // 0 1 2 3 4 00102 // next wire is there, this one isn't : o x ? ? ? 00103 // and the next candidate to check is + 2 00104 ++iwire; continue; 00105 } 00106 00107 int wirePrev = mdcWrapWire(iwire-1, nwire); 00108 if ( 0 != hitMap()->hitWire(ilayer, wirePrev)) { 00109 segUsage().get(theHit)->killHit(); 00110 if(debug>1){ 00111 theHit->print(std::cout); 00112 std::cout<< " killed " << std::endl; 00113 } 00114 }else{ 00115 if(debug>1){ 00116 theHit->print(std::cout); 00117 std::cout<< " ok " << std::endl; 00118 } 00119 } 00120 } // end wire loop 00121 } // end layer loop 00122 00123 return; 00124 } 00125