TMDCTsf Class Reference

A class to represent a Track Finder Segment(TSF). More...

#include <TMDCTsf.h>

List of all members.

Public Member Functions

 TMDCTsf (unsigned sl)
 Constructor for user defined shape.
virtual ~TMDCTsf ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
AList< TSegmentsegments (const AList< TMLink > &links)
 finds segments.
AList< TSegmentcreateTsf (unsigned) const
void solveLeftRight (void)
 solves left-right ambiguityies.

Private Member Functions

bool create (const AList< int > &offset, const AList< int > &width, const TMDCWire *const)
 creates a wire list, returns false if failed.
double alpha (unsigned, TMLink *) const
 find Tsf.

Private Attributes

unsigned _sl
double _angle
AList< TMLink_all
AList< TMLink_links
AList< TMDCWire_wires

Static Private Attributes

static TMDC_cdc = 0


Detailed Description

A class to represent a Track Finder Segment(TSF).

Definition at line 35 of file TMDCTsf.h.


Constructor & Destructor Documentation

TMDCTsf::TMDCTsf ( unsigned  sl  ) 

Constructor for user defined shape.

Definition at line 63 of file TMDCTsf.cxx.

00064 : _sl(sl),
00065   _angle(0.8){
00066 }

TMDCTsf::~TMDCTsf (  )  [virtual]

Destructor.

Definition at line 68 of file TMDCTsf.cxx.

00068                   {
00069 }


Member Function Documentation

double TMDCTsf::alpha ( unsigned  ,
TMLink  
) const [private]

find Tsf.

Definition at line 390 of file TMDCTsf.cxx.

References unit.

00390                                               {
00391     double radius[11] = { 11.525, 16.160, 24.555, 31.060, 37.455, 44.760, 51.370, 57.855, 64.165, 71.570, 76.345 };
00392     HepPoint3D pa, pb, pc;
00393     double rcell;
00394     if (sl < 2) rcell = 0.6;
00395     else rcell = 0.8;
00396     pa.set(0, 2 / radius[sl], 0);
00397     pb.set(-2*rcell/(rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 2*(radius[sl]+rcell)/(rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 0);
00398     pc.set(2*rcell/(rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 2*(radius[sl]+rcell)/(rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 0);
00399     cout<<"sl = "<<sl<<"alpha2 = "<<acos((pb - pa).unit().dot((pc - pa).unit()))/2<<endl;
00400     HepPoint3D pa2, pb2, pc2;
00401     pa2.set(0, 2 / radius[sl], 0);
00402     pb2.set(-6*rcell/(9*rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 2*(radius[sl]+rcell)/(9*rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 0);
00403     pc2.set(6*rcell/(9*rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 2*(radius[sl]+rcell)/(9*rcell*rcell + (radius[sl]+rcell)*(radius[sl]+rcell)), 0);
00404     cout<<"alpha22 = "<<acos((pb2 - pa2).unit().dot((pc2 - pa2).unit()))/2<<endl;
00405     return 1.0;
00406 }

bool TMDCTsf::create ( const AList< int > &  offset,
const AList< int > &  width,
const TMDCWire const 
) [private]

creates a wire list, returns false if failed.

Definition at line 83 of file TMDCTsf.cxx.

References _wires, GMDC, ganga-rec::j, TMDC::nLocalLayer(), TMDCTSF_MIN_LAYERS, w, and TMDC::wire().

00085                                           {
00086 
00087     //...Check wire position...
00088     unsigned localId = w->localLayerId();
00089     unsigned superId = w->superLayerId();
00090     unsigned availableLayer = GMDC->nLocalLayer(superId) - localId;
00091     if (availableLayer < TMDCTSF_MIN_LAYERS) {
00092         std::cout << "TMDCTsf::create !!! can not create TSF for wire ";
00093         std::cout << superId << "-" << localId << " because of ";
00094         std::cout << "lack of layer(s)." << std::endl;
00095         return false;
00096     }
00097     availableLayer = (availableLayer > offset.length())
00098         ? offset.length() : availableLayer;
00099 
00100     //...Check offset...
00101     bool offsetLayer = false;
00102     if (w->layer()->offset() != 0.) offsetLayer = true;
00103 
00104     //...Loop over available layers...
00105     for (unsigned l = 0; l < availableLayer; l++) {
00106         unsigned absLayerId = w->layerId() + l;
00107         int wireId[2];
00108         wireId[0] = w->localId() + (* offset[l]);
00109         wireId[1] = w->localId() + (* offset[l]);
00110         if (offsetLayer) ++wireId[1];
00111 
00112         //...Loop over wires...
00113         for (unsigned j = 0; j < * (width[l]); j++) {
00114             _wires.append((TMDCWire *) GMDC->wire(absLayerId, wireId[l % 2] + j));
00115         }
00116     }
00117 
00118     return true;
00119 }

AList< TSegment > TMDCTsf::createTsf ( unsigned   )  const

Definition at line 315 of file TMDCTsf.cxx.

References _all, _angle, _cdc, _sl, abs, TMDC::getTMDC(), genRecEmupikp::i, ganga-rec::j, TMDC::layer(), TMDCWire::layerId(), TMDCWire::localId(), TMDCLayer::nWires(), TMDCLayer::offset(), phi0, pi, TMLink::position(), unit, and TMLink::wire().

Referenced by segments().

00315                                           {
00316     if (_cdc == 0) _cdc = TMDC::getTMDC();
00317 
00318     AList<TMLink> seeds;
00319     AList<TMLink> exhits;
00320     AList<TSegment> list;
00321 
00322     unsigned n = _all.length();
00323     if (n < 3) return list;
00324     if (seedlayer == 1 && _sl == 10) return list;
00325 
00326     for (unsigned i = 0; i < n; ++i) {
00327         TMLink * ll = _all[i];
00328 //      if (ll->wire()->localLayerId() == seedlayer && ll->tsfTag() == 0) seeds.append(ll);
00329         if (ll->wire()->localLayerId() == seedlayer) seeds.append(ll);
00330         if (ll->wire()->localLayerId() > seedlayer) exhits.append(ll);
00331     }   //get seeds and exhits.
00332 
00333     for (unsigned i = 0; i < seeds.length(); ++i) {
00334         AList<TMLink> forSegment;
00335         TMLink * seed = seeds[i];
00336         unsigned lId = seed->wire()->layerId();
00337         int local = (int) seed->wire()->localId();
00338 //cout<<"lId: "<<lId<<" loId: "<<local<<endl;
00339         float phi0 = _cdc->layer(lId)->offset();
00340         int nWir = (int) _cdc->layer(lId)->nWires();
00341         float phi = phi0 + local*2*pi/nWir; //phi angle of seed.
00342 //      double angle = alpha(sl, seed);
00343         forSegment.append(seed);
00344 
00345         //for check
00346         int hitsOnLayer[3] = {0, 0, 0};
00347 
00348         for (unsigned m = 0; m < exhits.length(); ++ m) {
00349             TMLink * l = exhits[m];
00350             unsigned lLayer = l->wire()->localLayerId();
00351             unsigned tmpId = l->wire()->layerId();
00352             int tmpLocal = l->wire()->localId();
00353             float phi0tmp = _cdc->layer(tmpId)->offset();
00354             int nWirtmp = (int) _cdc->layer(tmpId)->nWires();
00355             int localOffset = (int)((phi-phi0tmp)/(2*pi/nWirtmp));   //get the corresponding localId of exhits.
00356 
00357             int diff = abs(tmpLocal - localOffset);
00358 
00359             if (diff > nWirtmp / 2) diff = nWirtmp - diff;
00360 //cout<<"lId: "<<tmpId<<" loId: "<<tmpLocal<<" diff wire: "<<diff
00361 //<<" cal value = "<<fabs(acos((l->position() - seed->position()).unit().dot(-seed->position().unit())))<<endl;
00362             if (diff > lLayer + 2) continue;       //check in natural phase..
00363 
00364 //          double DRIFT = l->cDrift();
00365 //          const HepPoint3D dirZ(0.0, 0.0, 1.0);
00366 //          HepPoint3D pos1 = l->positionD() - DRIFT * dirZ.cross(l->positionD().unit());
00367 //          HepPoint3D pos2 = l->positionD() + DRIFT * dirZ.cross(l->positionD().unit());
00368 //          if (fabs(acos((pos1 - seed->position()).unit().dot(-seed->position().unit()))) < _angle
00369 //              || fabs(acos((pos2 - seed->position()).unit().dot(-seed->position().unit()))) < _angle) {
00370             if (fabs(acos((l->position() - seed->position()).unit().dot(-seed->position().unit()))) < _angle) {
00371                 forSegment.append(l);
00372                 ++hitsOnLayer[lLayer - 1 - seedlayer];
00373             }
00374         }
00375 
00376         //check
00377         int fireLayers = 0;
00378         for (unsigned j = 0; j < 3; ++j) {
00379             if (hitsOnLayer[j] > 0) ++fireLayers;
00380         }
00381         if (fireLayers < 2) {
00382             continue;
00383         }
00384         list.append(new TSegment(forSegment));
00385     }
00386     return list;
00387 }

void TMDCTsf::dump ( const std::string message = std::string(""),
const std::string prefix = std::string("") 
) const

dumps debug information.

Definition at line 72 of file TMDCTsf.cxx.

References _wires, genRecEmupikp::i, and w.

00072                                                                 {
00073     std::cout << pre;
00074     std::cout << "tsf : " << _wires.length() << " : ";
00075     for (unsigned i = 0; i < _wires.length(); i++) {
00076         TMDCWire * w = _wires[i];
00077         std::cout << w->layerId() << "-" << w->localId() << ", ";
00078     }
00079     std::cout << std::endl;
00080 }

AList< TSegment > TMDCTsf::segments ( const AList< TMLink > &  links  ) 

finds segments.

Definition at line 199 of file TMDCTsf.cxx.

References _all, createTsf(), genRecEmupikp::i, ganga-rec::j, TTrackBase::links(), and TSegment::splitTsf().

Referenced by TConformalFinder::findSegmentsTsf().

00199                                              {
00200     _all.removeAll();
00201     _all.append(links);
00202 
00203     AList<TMLink> seeds1;
00204     AList<TMLink> seeds2;
00205     for (int i=0; i<_all.length(); ++i) {
00206         if (_all[i]->wire()->localLayerId() == 0) seeds1.append(_all[i]);
00207         else if (_all[i]->wire()->localLayerId() == 1) seeds2.append(_all[i]);
00208         else continue;
00209     }
00210     AList<TSegment> list = createTsf(0);  //get 1234 tsf.
00211     unsigned n = list.length();
00212     AList<TSegment> splitted;
00213     AList<TMLink> seedNeighbors;
00214     for (unsigned i = 0; i < n; ++i) {
00215         seedNeighbors.removeAll();
00216         TSegment * c = list[i];
00217 
00218         //append seed's neighbors
00219         for (int j=0; j<c->links().length(); ++j){
00220             if (c->links()[j]->wire()->localLayerId() > 0) continue;
00221             unsigned seedId = c->links()[j]->wire()->localId();
00222             for (int k=0; k<seeds1.length(); ++k){ 
00223                 if (seeds1[k]->wire()->localIdForPlus()+1 == seedId
00224                  || seeds1[k]->wire()->localIdForMinus()-1 == seedId) seedNeighbors.append(seeds1[k]);
00225             }
00226             break;
00227         }
00228 
00229         AList<TSegment> newClusters = c->splitTsf(seedNeighbors);
00230 //      cout<<"newClusters.length = "<<newClusters.length()<<endl;
00231         splitted.append(c); //remove the segment created by TMDCTsf here!!!
00232         if (newClusters.length() == 0) continue;
00233         list.append(newClusters);
00234     }
00235     list.remove(splitted);
00236     HepAListDeleteAll(splitted);
00237 //cout<<"sl = "<<_sl<<"    list1234 = "<<list.length()<<endl;
00238 
00239     AList<TSegment> list2 = createTsf(1);  //get 234 tsf.
00240     n = list2.length();
00241     AList<TSegment> splitted2;
00242 
00243     for (unsigned i = 0; i < n; ++i) {
00244         seedNeighbors.removeAll();
00245         TSegment * c = list2[i];
00246 
00247         //append seed's neighbors
00248         for (int j=0; j<c->links().length(); ++j){
00249             if (c->links()[j]->wire()->localLayerId() != 1) continue;
00250             unsigned seedId = c->links()[j]->wire()->localId();
00251             for (int k=0; k<seeds2.length(); ++k){
00252                 if (seeds2[k]->wire()->localIdForPlus()+1 == seedId
00253                  || seeds2[k]->wire()->localIdForMinus()-1 == seedId) seedNeighbors.append(seeds2[k]);
00254             }
00255             break;
00256         }
00257 
00258         AList<TSegment> newClusters2 = c->splitTsf(seedNeighbors);
00259 //      cout<<"newClusters2.length = "<<newClusters2.length()<<endl;
00260         splitted2.append(c);
00261         if (newClusters2.length() == 0) continue;
00262         list2.append(newClusters2);
00263     }
00264     list2.remove(splitted2);
00265     HepAListDeleteAll(splitted2);
00266 //cout<<"sl = "<<_sl<<"    list234 = "<<list2.length()<<endl;
00267 
00268     list.append(list2);
00269 
00270     //check segment, remove the multi segs.
00271     AList<TSegment> badList;
00272     for(int i = 0; i < list.length(); ++i){
00273         for(int j = i+1; j < list.length(); ++j){
00274             AList<TMLink> links = list[j]->links();
00275             AList<TMLink> multiLinks;
00276             for (int k = 0; k < links.length(); ++k){
00277                 TMLink & l = * links[k];
00278                 if (list[i]->links().hasMember(l)) multiLinks.append(l);
00279             }
00280             if (multiLinks.length() < 2) continue;
00281             unsigned minLength = links.length();
00282             if (links.length() > list[i]->links().length()) minLength = list[i]->links().length();
00283             if (minLength - multiLinks.length() > 1) continue;
00284             int nHits[4]={0};  //in each layer.
00285             int multiLayers = 0;
00286             for (int k = 0; k < multiLinks.length(); ++k)
00287                 ++nHits[multiLinks[k]->hit()->wire()->localLayerId()];
00288             for (int k = 0; k < 4; ++k)
00289                 if (nHits[k] > 0) ++multiLayers;
00290             if(multiLayers >= 2 && (links.length() > list[i]->links().length())) badList.append(list[i]);
00291             else if (multiLayers >= 2) badList.append(list[j]);
00292             else continue;
00293         }
00294     }
00295     list.remove(badList);
00296 
00297     //reset links in badList.
00298     for (int i = 0; i < badList.length(); ++i) {
00299         AList<TMLink> bads = badList[i]->links();
00300         for (int j = 0; j < bads.length(); ++j) {
00301             unsigned n = bads[j]->tsfTag();
00302             if(n == 0) continue;
00303             else {
00304                 --n;
00305                 bads[j]->tsfTag(n);
00306             }
00307         }
00308     }
00309     HepAListDeleteAll(badList);
00310 
00311     return list;
00312 }

void TMDCTsf::solveLeftRight ( void   ) 

solves left-right ambiguityies.

Definition at line 122 of file TMDCTsf.cxx.

00122                             {
00123     //...For debug...
00124     // this->dump();
00125 
00126 //     TMDCWire * innerWire = _wires[0];
00127 //     TMDCWireHit * innerHit = innerWire->hit();
00128 
00129 //     unsigned outerMostLayer = _wires.last()->layerId();
00130 //     unsigned i = _wires.length();
00131 //     while (_wires[--i]->layerId() == outerMostLayer) {
00132 //      TMDCWireHit * outerHit = _wires[i]->hit();
00133 //      if (! outerHit) continue;
00134 
00135 //      //...Find four lines by two hit points...
00136 //      //      AList<TMDCLine> lines = innerHit->lines(outerHit);
00137 //      // AList<TMDCLine> lines; // = innerHit->lines(outerHit);
00138 
00139 //      //...Line loop...
00140 //      for (unsigned ii = 0; ii < 4; ii++) {
00141 //          TMDCLine * l = lines[ii];
00142 
00143 //          //...For debug...
00144 //          // l->dump();
00145 
00146 //          //...Find hits on this line...
00147 //          unsigned j = i;
00148 //          while (TMDCWire * w = _wires[--j]) {
00149 
00150 //              //...Check condition...
00151 //              if (w == innerWire) break;
00152 //              if (w->layerId() == outerMostLayer) continue;
00153 //              TMDCWireHit * hit = w->hit();
00154 //              if (! hit) continue;
00155 
00156 //              //...Append this hit...
00157 //              l->appendHit(hit);
00158 
00159 //              //...Obtain distance of closest approach...
00160 //              double distance = l->distance(* l->closest().last());
00161 
00162 //              //...Cal. tolerable distance...
00163 //              unsigned leftRight = * (l->leftRight().last());
00164 //              double tolerable = 5. * hit->dDistance(leftRight);
00165 
00166 //              //...Is this OK?...
00167 //              if (distance > tolerable) {
00168 //                  l->removeLastHit();
00169 //                  continue;
00170 //              }
00171 
00172 //              //...For debug...
00173 //              // hit->dump("", "    ");
00174 //              // std::cout << "distance = " << distance << std::endl;
00175 //          }
00176 
00177 //          //...Check # of hits on this line
00178 //          if (l->hits().length() > 2) {
00179 //              unsigned i = 0;
00180 //              while (TMDCWireHit * h = (l->hits())[i]) {
00181 //                  unsigned leftRight = * (l->leftRight())[i];
00182 //                  unsigned newState = h->state() | (1 << leftRight);
00183 //                  h->state(newState);
00184 //                  ++i;
00185 
00186 //                  //...For debug...
00187 //                  // h->dump("", "    ");
00188 //              }
00189 //          }
00190 
00191 //          //...Delete line here...
00192 //          delete l;
00193 //      }
00194 //     }
00195 }


Member Data Documentation

AList<TMLink> TMDCTsf::_all [private]

Definition at line 79 of file TMDCTsf.h.

Referenced by createTsf(), and segments().

double TMDCTsf::_angle [private]

Definition at line 77 of file TMDCTsf.h.

Referenced by createTsf().

TMDC * TMDCTsf::_cdc = 0 [static, private]

Definition at line 86 of file TMDCTsf.h.

Referenced by createTsf().

AList<TMLink> TMDCTsf::_links [private]

Definition at line 80 of file TMDCTsf.h.

unsigned TMDCTsf::_sl [private]

Definition at line 76 of file TMDCTsf.h.

Referenced by createTsf().

AList<TMDCWire> TMDCTsf::_wires [private]

Definition at line 84 of file TMDCTsf.h.

Referenced by create(), and dump().


Generated on Tue Nov 29 23:36:02 2016 for BOSS_7.0.2 by  doxygen 1.4.7