/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/TrkReco/TrkReco-00-08-59-patch4-slc6tag/src/TSegmentCurl.cxx

Go to the documentation of this file.
00001 #include "TrkReco/TSegmentCurl.h"
00002 
00003 #define inline
00004 
00005 
00006 TSegmentCurl::TSegmentCurl(const unsigned superLayerId,
00007                            const unsigned max)
00008   : m_MaxLocalLayerId(max), m_superLayerId(superLayerId), m_flagOfUpdate(true)
00009 {
00010   m_list.removeAll();
00011   for(unsigned i=0;i<4;++i){
00012     m_seqOfLayer[i] = m_sizeOfLayer[i] = 0;
00013     m_layer[i].removeAll();
00014   }
00015 }
00016 
00017 
00018 TSegmentCurl::TSegmentCurl(TSegmentCurl &s)
00019   : m_flagOfUpdate(s.m_flagOfUpdate), m_list(s.m_list), m_MaxLocalLayerId(s.m_MaxLocalLayerId), m_superLayerId(s.m_superLayerId), 
00020     m_maxSeq(s.m_maxSeq), m_layerIdOfMaxSeq(s.m_layerIdOfMaxSeq), m_numOfSeqOneLayer(s.m_numOfSeqOneLayer),
00021     m_numOfLargeSeqLayer(s.m_numOfLargeSeqLayer)
00022 {
00023   for(unsigned i=0;i<4;++i){
00024     m_seqOfLayer[i] = s.m_seqOfLayer[i];
00025     m_sizeOfLayer[i] = s.m_sizeOfLayer[i];
00026     m_layer[i] = s.m_layer[i];
00027   } 
00028 }
00029 
00030 
00031 TSegmentCurl::TSegmentCurl(TSegmentCurl *s)
00032   : m_flagOfUpdate(s->m_flagOfUpdate), m_list(s->m_list), m_MaxLocalLayerId(s->m_MaxLocalLayerId), m_superLayerId(s->m_superLayerId), 
00033     m_maxSeq(s->m_maxSeq), m_layerIdOfMaxSeq(s->m_layerIdOfMaxSeq), m_numOfSeqOneLayer(s->m_numOfSeqOneLayer),
00034     m_numOfLargeSeqLayer(s->m_numOfLargeSeqLayer)
00035 {
00036   for(unsigned i=0;i<4;++i){
00037     m_seqOfLayer[i] = s->m_seqOfLayer[i];
00038     m_sizeOfLayer[i] = s->m_sizeOfLayer[i];
00039     m_layer[i] = s->m_layer[i];
00040   } 
00041 }
00042 
00043 
00044 TSegmentCurl::~TSegmentCurl(void)
00045 {
00046   m_list.removeAll();
00047   for(unsigned i=0;i<4;++i){
00048     m_layer[i].removeAll();
00049   }
00050 }
00051 
00052 
00053 inline
00054 const unsigned 
00055 TSegmentCurl::maxLocalLayerId(void) const
00056 {
00057   return m_MaxLocalLayerId;
00058 }
00059 
00060 
00061 inline
00062 const unsigned 
00063 TSegmentCurl::superLayerId(void) const
00064 {
00065   return m_superLayerId;
00066 }
00067 
00068 
00069 inline
00070 const unsigned 
00071 TSegmentCurl::seqOfLayer(const unsigned i)
00072 {
00073   if(m_flagOfUpdate)update();
00074   return m_seqOfLayer[i];
00075 }
00076 
00077 
00078 inline
00079 const unsigned 
00080 TSegmentCurl::sizeOfLayer(const unsigned i)
00081 {
00082   if(m_flagOfUpdate)update();
00083   return m_sizeOfLayer[i];
00084 }
00085 
00086 
00087 inline
00088 const unsigned 
00089 TSegmentCurl::maxLocalLayerId(const unsigned i)
00090 {
00091   m_MaxLocalLayerId = i;
00092   return m_MaxLocalLayerId;
00093 }
00094 
00095 
00096 inline
00097 const unsigned 
00098 TSegmentCurl::superLayerId(const unsigned i)
00099 {
00100   m_superLayerId = i;
00101   return m_superLayerId;
00102 }
00103 
00104 
00105 inline
00106 void 
00107 TSegmentCurl::append(TMLink &e)
00108 {
00109   m_flagOfUpdate = true;
00110   m_layer[e.hit()->wire()->localLayerId()].append(e);
00111   m_list.append(e);
00112 }
00113 
00114 
00115 inline
00116 void 
00117 TSegmentCurl::append(TMLink *e)
00118 {
00119   m_flagOfUpdate = true;
00120   m_layer[e->hit()->wire()->localLayerId()].append(e);
00121   m_list.append(e);
00122 }
00123 
00124 
00125 inline
00126 void 
00127 TSegmentCurl::append(AList<TMLink> &e)
00128 {
00129   m_flagOfUpdate = true;
00130   for(unsigned i = 0; i < e.length(); ++i)
00131     m_layer[e[i]->hit()->wire()->localLayerId()].append(e[i]);
00132   m_list.append(e);
00133 }
00134 
00135 
00136 inline
00137 void 
00138 TSegmentCurl::remove(TMLink &e)
00139 {
00140   m_flagOfUpdate = true;
00141   m_layer[e.hit()->wire()->localLayerId()].remove(e);
00142   m_list.remove(e);
00143 }
00144 
00145 
00146 inline
00147 void 
00148 TSegmentCurl::remove(TMLink *e)
00149 {
00150   m_flagOfUpdate = true;
00151   m_layer[e->hit()->wire()->localLayerId()].remove(e);
00152   m_list.remove(e);
00153 }
00154 
00155 
00156 inline
00157 void 
00158 TSegmentCurl::remove(AList<TMLink> &e)
00159 {
00160   m_flagOfUpdate = true;
00161   for(unsigned i = 0; i < e.length(); ++i)
00162     m_layer[e[i]->hit()->wire()->localLayerId()].remove(e[i]);
00163   m_list.remove(e);
00164 }
00165 
00166 
00167 inline
00168 void 
00169 TSegmentCurl::removeAll(void)
00170 {
00171   m_flagOfUpdate = true;
00172   m_list.removeAll();
00173   for(unsigned i=0;i<4;++i){
00174     m_layer[i].removeAll();
00175   }
00176 }
00177 
00178 
00179 inline
00180 const unsigned 
00181 TSegmentCurl::maxSeq(void) const
00182 {
00183   // I try to use non-const member.
00184   // If this method is bad, other methods are necessary.
00185   TSegmentCurl * const localThis = const_cast<TSegmentCurl * const>(this);
00186   if(m_flagOfUpdate)localThis->update();
00187   return m_maxSeq;
00188 }
00189 
00190 
00191 inline
00192 const unsigned 
00193 TSegmentCurl::layerIdOfMaxSeq(void)
00194 {
00195   if(m_flagOfUpdate)update();
00196   return m_layerIdOfMaxSeq;
00197 }
00198 
00199 
00200 inline
00201 const unsigned 
00202 TSegmentCurl::numOfSeqOneLayer(void)
00203 {
00204   if(m_flagOfUpdate)update();
00205   return m_numOfSeqOneLayer;
00206 }
00207 
00208 
00209 inline
00210 const unsigned
00211 TSegmentCurl::numOfLargeSeqLayer(void)
00212 {
00213   if(m_flagOfUpdate)update();
00214   return m_numOfLargeSeqLayer;
00215 }
00216 
00217 
00218 void 
00219 TSegmentCurl::update(void)
00220 {
00221   if(m_list.length() == 0){
00222     m_flagOfUpdate = false;
00223     return;
00224   }
00225   m_maxSeq = m_layerIdOfMaxSeq = 0;
00226   m_numOfSeqOneLayer = m_numOfLargeSeqLayer = 0;
00227   for(unsigned i = 0; i <= m_MaxLocalLayerId; ++i){
00228     m_sizeOfLayer[i] = m_layer[i].length();
00229     calcuSeq(i);
00230     if(m_seqOfLayer[i] >= m_maxSeq){
00231       m_maxSeq = m_seqOfLayer[i];
00232       m_layerIdOfMaxSeq = i;
00233     }
00234     if(m_seqOfLayer[i] == 1)++m_numOfSeqOneLayer;
00235     if(m_seqOfLayer[i] >= TCURL_LARGE_SEQUENCE)++m_numOfLargeSeqLayer;
00236   }
00237 
00238   m_flagOfUpdate = false;
00239 }
00240 
00241 
00242 TSegmentCurl &
00243 TSegmentCurl::operator=(const TSegmentCurl &s)
00244 {
00245   if(this == &s)return *this;
00246 
00247   m_flagOfUpdate = s.m_flagOfUpdate;
00248   m_list = s.m_list;
00249   m_MaxLocalLayerId = s.m_MaxLocalLayerId;
00250   m_superLayerId = s.m_superLayerId;
00251  
00252   m_maxSeq = s.m_maxSeq;
00253   m_layerIdOfMaxSeq = s.m_layerIdOfMaxSeq;
00254   m_numOfSeqOneLayer = s.m_numOfSeqOneLayer;
00255   m_numOfLargeSeqLayer = s.m_numOfLargeSeqLayer;
00256 
00257   for(unsigned i=0;i<4;++i){
00258     m_seqOfLayer[i] = s.m_seqOfLayer[i];
00259     m_sizeOfLayer[i] = s.m_sizeOfLayer[i];
00260     m_layer[i] = s.m_layer[i];
00261   }
00262   
00263   return *this;
00264 }
00265 
00266 #if defined(__GNUG__)
00267 int
00268 sortByWireSerialNumber( const TMLink **a, const TMLink **b )
00269 {
00270   if( (*a)->hit()->wire()->id() < (*b)->hit()->wire()->id() ){
00271     return 1;
00272   }else if( (*a)->hit()->wire()->id() == (*b)->hit()->wire()->id() ){
00273     return 0;
00274   }else{
00275     return -1;
00276   }
00277 }
00278 #else
00279 extern "C" int
00280 sortByWireSerialNumber( const void *av, const void *bv )
00281 {
00282   const TMLink **a((const TMLink **)av);
00283   const TMLink **b((const TMLink **)bv);
00284   if( (*a)->hit()->wire()->id() < (*b)->hit()->wire()->id() ){
00285     return 1;
00286   }else if( (*a)->hit()->wire()->id() == (*b)->hit()->wire()->id() ){
00287     return 0;
00288   }else{
00289     return -1;
00290   }
00291 }
00292 #endif
00293 
00294 void
00295 TSegmentCurl::calcuSeq(unsigned i)
00296 {
00297   //...exception
00298   if(i > m_MaxLocalLayerId){
00299     m_seqOfLayer[i] = 0;
00300     return;
00301   }
00302   unsigned size = m_layer[i].length();
00303   if(size < 1){
00304     m_seqOfLayer[i] = 0;
00305     return;
00306   }
00307   if(size == 1){
00308     m_seqOfLayer[i] = 1;
00309     return;
00310   }
00311 
00312   //...initialize
00313   m_layer[i].sort(sortByWireSerialNumber);
00314   unsigned seq = 1;
00315   unsigned maxSeq = 0;
00316   unsigned layerIdForWires = m_layer[i][0]->hit()->wire()->layerId();
00317   
00318   //...calculation
00319 //  if(m_layer[i][0]->hit()->wire()->localId() == static_cast<unsigned>(wires(m_superLayerId)-1) && 
00320   if(m_layer[i][0]->hit()->wire()->localId() == static_cast<unsigned>(wires(layerIdForWires)-1) &&
00321      m_layer[i][size-1]->hit()->wire()->localId() == 0){
00322     for(unsigned j=0;j<size-1;++j){
00323       if(m_layer[i][j]->hit()->wire()->localIdForMinus()-1 == 
00324          m_layer[i][j+1]->hit()->wire()->localId()){
00325         ++seq;
00326       }else{
00327         break;
00328       }
00329       if(j == size-2)goto loop;
00330     }
00331     ++seq;
00332     for(unsigned j=size-1;j>0;--j){
00333       if(m_layer[i][j]->hit()->wire()->localIdForPlus()+1 == 
00334          m_layer[i][j-1]->hit()->wire()->localId()){
00335         ++seq;
00336       }else{
00337         break;
00338       }
00339     }
00340      loop:
00341     if(seq > maxSeq)maxSeq = seq;
00342   }
00343   seq = 1;
00344   for(unsigned j=0;j<size-1;++j){
00345     if(m_layer[i][j]->hit()->wire()->localIdForMinus()-1 == 
00346        m_layer[i][j+1]->hit()->wire()->localId()){
00347       ++seq;
00348     }else{
00349       if(seq > maxSeq)maxSeq = seq;
00350       seq = 1;
00351     }
00352   }
00353   if(seq > maxSeq)maxSeq = seq;
00354 
00355   //...set and return
00356   m_seqOfLayer[i] = maxSeq;
00357   return;
00358 }
00359 
00360 
00361 /*unsigned
00362 TSegmentCurl::wires(const unsigned superLayerId) const
00363 {
00364   // input   - super layer id#(0-10)
00365   // output  - # of its super layer
00366   if(superLayerId ==  0)return  64;
00367   if(superLayerId ==  1)return  80;
00368   if(superLayerId ==  2)return  96;
00369   if(superLayerId ==  3)return 128;
00370   if(superLayerId ==  4)return 144;
00371   if(superLayerId ==  5)return 160;
00372   if(superLayerId ==  6)return 192;
00373   if(superLayerId ==  7)return 208;
00374   if(superLayerId ==  8)return 240;
00375   if(superLayerId ==  9)return 256;
00376   if(superLayerId == 10)return 288;
00377 
00378   std::cerr << "Error in the SegmentCurl(wires)." << std::endl;
00379   return 0;
00380 }*/
00381 unsigned
00382 TSegmentCurl::wires(const unsigned LayerId) const
00383 {
00384   // input   - layer id#(0-422)
00385   // output  - # of its layer
00386   if(LayerId ==  0)return  40;
00387   if(LayerId ==  1)return  44;
00388   if(LayerId ==  2)return  48;
00389   if(LayerId ==  3)return  56;
00390   if(LayerId ==  4)return  64;
00391   if(LayerId ==  5)return  72;
00392   if(LayerId ==  6 || LayerId ==  7) return  80;
00393   if(LayerId ==  8 || LayerId ==  9) return  76;
00394   if(LayerId ==  10|| LayerId ==  11)return  88;
00395   if(LayerId ==  12|| LayerId ==  13)return 100;
00396   if(LayerId ==  14|| LayerId ==  15)return 112;
00397   if(LayerId ==  16|| LayerId ==  17)return 128;
00398   if(LayerId ==  18|| LayerId ==  19)return 140;
00399   if(LayerId < 24)return 160;
00400   if(LayerId < 28)return 176;
00401   if(LayerId < 32)return 208;
00402   if(LayerId < 36)return 240;
00403   if(LayerId < 40)return 256;
00404   if(LayerId < 43)return 288;
00405                                                                                                                              
00406   std::cerr << "Error in the SegmentCurl(wires)." << std::endl;
00407   return 0;
00408 }
00409 
00410 void
00411 TSegmentCurl::dump(void)
00412 {
00413   //std::cout.form(" Hep  idhep mother mcPX  mcPY  mcPZ  mcE   mcMass\n");
00414   //std::cout.form(" %3d   % 4d   % 4d % 2.2f % 2.2f % 2.2f % 2.2f % 2.3f\n", 
00415   //hepID, partID, mothID, mcpx, mcpy, mcpz, mce, mcmass);
00416 
00417   std::cout << "=====Segment for Curling Track Finder=====" << std::endl;
00418   std::cout << "List Size = " << m_list.length() << std::endl;
00419   std::cout << "Flag of Update = " << m_flagOfUpdate 
00420        << ", Max Local Layer ID = " << m_MaxLocalLayerId
00421        << ", Super Layer ID = " << m_superLayerId << std::endl;
00422   std::cout << "Max Seq. = " << m_maxSeq << ", Its Layer ID = " << m_layerIdOfMaxSeq << std::endl;
00423   std::cout << "# of Seq = 1 Layer = " << m_numOfSeqOneLayer 
00424        << ", # of Large Seq. Layer = " << m_numOfLargeSeqLayer << std::endl;
00425   //std::cout.form(" ID | Seq. of Layer | Size of Layer | Local ID List\n");
00426   std::cout << "ID | Seq. of Layer | Size of Layer | Local ID List" << std::endl;
00427   for(unsigned i=0;i<4;++i){
00428     //std::cout.form("  %1d |  %2d           | %2d            |", i, m_seqOfLayer[i], m_sizeOfLayer[i]);
00429     std::cout << i << " | " << m_seqOfLayer[i] << "   | " << m_sizeOfLayer[i] << "   | ";
00430     for(unsigned j = 0, size = m_layer[i].length(); j < size; ++j)
00431       std::cout << m_layer[i][j]->hit()->wire()->localId() << ", ";
00432     std::cout << std::endl;
00433   }
00434 }

Generated on Tue Nov 29 23:14:16 2016 for BOSS_7.0.2 by  doxygen 1.4.7