BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
TMDCTsf Class Reference

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

#include <TMDCTsf.h>

Public Member Functions

 TMDCTsf (unsigned sl)
 Constructor of fixed 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.
 

Detailed Description

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

Definition at line 35 of file TMDCTsf.h.

Constructor & Destructor Documentation

◆ TMDCTsf()

TMDCTsf::TMDCTsf ( unsigned  sl)

Constructor of fixed shape.

Constructor for user defined shape.

Definition at line 63 of file TMDCTsf.cxx.

64: _sl(sl),
65 _angle(0.8){
66}

◆ ~TMDCTsf()

TMDCTsf::~TMDCTsf ( )
virtual

Destructor.

Definition at line 68 of file TMDCTsf.cxx.

68 {
69}

Member Function Documentation

◆ createTsf()

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

Definition at line 315 of file TMDCTsf.cxx.

315 {
316 if (_cdc == 0) _cdc = TMDC::getTMDC();
317
318 AList<TMLink> seeds;
319 AList<TMLink> exhits;
320 AList<TSegment> list;
321
322 unsigned n = _all.length();
323 if (n < 3) return list;
324 if (seedlayer == 1 && _sl == 10) return list;
325
326 for (unsigned i = 0; i < n; ++i) {
327 TMLink * ll = _all[i];
328// if (ll->wire()->localLayerId() == seedlayer && ll->tsfTag() == 0) seeds.append(ll);
329 if (ll->wire()->localLayerId() == seedlayer) seeds.append(ll);
330 if (ll->wire()->localLayerId() > seedlayer) exhits.append(ll);
331 } //get seeds and exhits.
332
333 for (unsigned i = 0; i < seeds.length(); ++i) {
334 AList<TMLink> forSegment;
335 TMLink * seed = seeds[i];
336 unsigned lId = seed->wire()->layerId();
337 int local = (int) seed->wire()->localId();
338//cout<<"lId: "<<lId<<" loId: "<<local<<endl;
339 float phi0 = _cdc->layer(lId)->offset();
340 int nWir = (int) _cdc->layer(lId)->nWires();
341 float phi = phi0 + local*2*pi/nWir; //phi angle of seed.
342// double angle = alpha(sl, seed);
343 forSegment.append(seed);
344
345 //for check
346 int hitsOnLayer[3] = {0, 0, 0};
347
348 for (unsigned m = 0; m < exhits.length(); ++ m) {
349 TMLink * l = exhits[m];
350 unsigned lLayer = l->wire()->localLayerId();
351 unsigned tmpId = l->wire()->layerId();
352 int tmpLocal = l->wire()->localId();
353 float phi0tmp = _cdc->layer(tmpId)->offset();
354 int nWirtmp = (int) _cdc->layer(tmpId)->nWires();
355 int localOffset = (int)((phi-phi0tmp)/(2*pi/nWirtmp)); //get the corresponding localId of exhits.
356
357 int diff = abs(tmpLocal - localOffset);
358
359 if (diff > nWirtmp / 2) diff = nWirtmp - diff;
360//cout<<"lId: "<<tmpId<<" loId: "<<tmpLocal<<" diff wire: "<<diff
361//<<" cal value = "<<fabs(acos((l->position() - seed->position()).unit().dot(-seed->position().unit())))<<endl;
362 if (diff > lLayer + 2) continue; //check in natural phase..
363
364// double DRIFT = l->cDrift();
365// const HepPoint3D dirZ(0.0, 0.0, 1.0);
366// HepPoint3D pos1 = l->positionD() - DRIFT * dirZ.cross(l->positionD().unit());
367// HepPoint3D pos2 = l->positionD() + DRIFT * dirZ.cross(l->positionD().unit());
368// if (fabs(acos((pos1 - seed->position()).unit().dot(-seed->position().unit()))) < _angle
369// || fabs(acos((pos2 - seed->position()).unit().dot(-seed->position().unit()))) < _angle) {
370 if (fabs(acos((l->position() - seed->position()).unit().dot(-seed->position().unit()))) < _angle) {
371 forSegment.append(l);
372 ++hitsOnLayer[lLayer - 1 - seedlayer];
373 }
374 }
375
376 //check
377 int fireLayers = 0;
378 for (unsigned j = 0; j < 3; ++j) {
379 if (hitsOnLayer[j] > 0) ++fireLayers;
380 }
381 if (fireLayers < 2) {
382 continue;
383 }
384 list.append(new TSegment(forSegment));
385 }
386 return list;
387}
const Int_t n
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
float offset(void) const
returns offset.
Definition: TMDCLayer.h:133
unsigned nWires(void) const
returns # of wires.
Definition: TMDCLayer.h:139
unsigned localLayerId(void) const
returns local layer id in a super layer.
Definition: TMDCWire.h:231
unsigned localId(void) const
returns local id in a wire layer.
Definition: TMDCWire.h:213
unsigned layerId(void) const
returns layer id.
Definition: TMDCWire.h:219
static TMDC * getTMDC(void)
Definition: TMDC.cxx:95
const TMDCLayer *const layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
Definition: TMDC.h:259
A class to relate TMDCWireHit and TTrack objects.
Definition: TSegment.h:43
const float pi
Definition: vector3.h:133

Referenced by segments().

◆ dump()

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.

72 {
73 std::cout << pre;
74 std::cout << "tsf : " << _wires.length() << " : ";
75 for (unsigned i = 0; i < _wires.length(); i++) {
76 TMDCWire * w = _wires[i];
77 std::cout << w->layerId() << "-" << w->localId() << ", ";
78 }
79 std::cout << std::endl;
80}
A class to represent a wire in MDC.
Definition: TMDCWire.h:55

Referenced by TMDCWire::dump().

◆ segments()

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

finds segments.

Definition at line 199 of file TMDCTsf.cxx.

199 {
200 _all.removeAll();
201 _all.append(links);
202
203 AList<TMLink> seeds1;
204 AList<TMLink> seeds2;
205 for (int i=0; i<_all.length(); ++i) {
206 if (_all[i]->wire()->localLayerId() == 0) seeds1.append(_all[i]);
207 else if (_all[i]->wire()->localLayerId() == 1) seeds2.append(_all[i]);
208 else continue;
209 }
210 AList<TSegment> list = createTsf(0); //get 1234 tsf.
211 unsigned n = list.length();
212 AList<TSegment> splitted;
213 AList<TMLink> seedNeighbors;
214 for (unsigned i = 0; i < n; ++i) {
215 seedNeighbors.removeAll();
216 TSegment * c = list[i];
217
218 //append seed's neighbors
219 for (int j=0; j<c->links().length(); ++j){
220 if (c->links()[j]->wire()->localLayerId() > 0) continue;
221 unsigned seedId = c->links()[j]->wire()->localId();
222 for (int k=0; k<seeds1.length(); ++k){
223 if (seeds1[k]->wire()->localIdForPlus()+1 == seedId
224 || seeds1[k]->wire()->localIdForMinus()-1 == seedId) seedNeighbors.append(seeds1[k]);
225 }
226 break;
227 }
228
229 AList<TSegment> newClusters = c->splitTsf(seedNeighbors);
230// cout<<"newClusters.length = "<<newClusters.length()<<endl;
231 splitted.append(c); //remove the segment created by TMDCTsf here!!!
232 if (newClusters.length() == 0) continue;
233 list.append(newClusters);
234 }
235 list.remove(splitted);
236 HepAListDeleteAll(splitted);
237//cout<<"sl = "<<_sl<<" list1234 = "<<list.length()<<endl;
238
239 AList<TSegment> list2 = createTsf(1); //get 234 tsf.
240 n = list2.length();
241 AList<TSegment> splitted2;
242
243 for (unsigned i = 0; i < n; ++i) {
244 seedNeighbors.removeAll();
245 TSegment * c = list2[i];
246
247 //append seed's neighbors
248 for (int j=0; j<c->links().length(); ++j){
249 if (c->links()[j]->wire()->localLayerId() != 1) continue;
250 unsigned seedId = c->links()[j]->wire()->localId();
251 for (int k=0; k<seeds2.length(); ++k){
252 if (seeds2[k]->wire()->localIdForPlus()+1 == seedId
253 || seeds2[k]->wire()->localIdForMinus()-1 == seedId) seedNeighbors.append(seeds2[k]);
254 }
255 break;
256 }
257
258 AList<TSegment> newClusters2 = c->splitTsf(seedNeighbors);
259// cout<<"newClusters2.length = "<<newClusters2.length()<<endl;
260 splitted2.append(c);
261 if (newClusters2.length() == 0) continue;
262 list2.append(newClusters2);
263 }
264 list2.remove(splitted2);
265 HepAListDeleteAll(splitted2);
266//cout<<"sl = "<<_sl<<" list234 = "<<list2.length()<<endl;
267
268 list.append(list2);
269
270 //check segment, remove the multi segs.
271 AList<TSegment> badList;
272 for(int i = 0; i < list.length(); ++i){
273 for(int j = i+1; j < list.length(); ++j){
274 AList<TMLink> links = list[j]->links();
275 AList<TMLink> multiLinks;
276 for (int k = 0; k < links.length(); ++k){
277 TMLink & l = * links[k];
278 if (list[i]->links().hasMember(l)) multiLinks.append(l);
279 }
280 if (multiLinks.length() < 2) continue;
281 unsigned minLength = links.length();
282 if (links.length() > list[i]->links().length()) minLength = list[i]->links().length();
283 if (minLength - multiLinks.length() > 1) continue;
284 int nHits[4]={0}; //in each layer.
285 int multiLayers = 0;
286 for (int k = 0; k < multiLinks.length(); ++k)
287 ++nHits[multiLinks[k]->hit()->wire()->localLayerId()];
288 for (int k = 0; k < 4; ++k)
289 if (nHits[k] > 0) ++multiLayers;
290 if(multiLayers >= 2 && (links.length() > list[i]->links().length())) badList.append(list[i]);
291 else if (multiLayers >= 2) badList.append(list[j]);
292 else continue;
293 }
294 }
295 list.remove(badList);
296
297 //reset links in badList.
298 for (int i = 0; i < badList.length(); ++i) {
299 AList<TMLink> bads = badList[i]->links();
300 for (int j = 0; j < bads.length(); ++j) {
301 unsigned n = bads[j]->tsfTag();
302 if(n == 0) continue;
303 else {
304 --n;
305 bads[j]->tsfTag(n);
306 }
307 }
308 }
309 HepAListDeleteAll(badList);
310
311 return list;
312}
AList< TSegment > createTsf(unsigned) const
Definition: TMDCTsf.cxx:315
AList< TSegment > splitTsf(AList< TMLink > &)
Definition: TSegment.cxx:1134
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:297

◆ solveLeftRight()

void TMDCTsf::solveLeftRight ( void  )

solves left-right ambiguityies.

Definition at line 122 of file TMDCTsf.cxx.

122 {
123 //...For debug...
124 // this->dump();
125
126// TMDCWire * innerWire = _wires[0];
127// TMDCWireHit * innerHit = innerWire->hit();
128
129// unsigned outerMostLayer = _wires.last()->layerId();
130// unsigned i = _wires.length();
131// while (_wires[--i]->layerId() == outerMostLayer) {
132// TMDCWireHit * outerHit = _wires[i]->hit();
133// if (! outerHit) continue;
134
135// //...Find four lines by two hit points...
136// // AList<TMDCLine> lines = innerHit->lines(outerHit);
137// // AList<TMDCLine> lines; // = innerHit->lines(outerHit);
138
139// //...Line loop...
140// for (unsigned ii = 0; ii < 4; ii++) {
141// TMDCLine * l = lines[ii];
142
143// //...For debug...
144// // l->dump();
145
146// //...Find hits on this line...
147// unsigned j = i;
148// while (TMDCWire * w = _wires[--j]) {
149
150// //...Check condition...
151// if (w == innerWire) break;
152// if (w->layerId() == outerMostLayer) continue;
153// TMDCWireHit * hit = w->hit();
154// if (! hit) continue;
155
156// //...Append this hit...
157// l->appendHit(hit);
158
159// //...Obtain distance of closest approach...
160// double distance = l->distance(* l->closest().last());
161
162// //...Cal. tolerable distance...
163// unsigned leftRight = * (l->leftRight().last());
164// double tolerable = 5. * hit->dDistance(leftRight);
165
166// //...Is this OK?...
167// if (distance > tolerable) {
168// l->removeLastHit();
169// continue;
170// }
171
172// //...For debug...
173// // hit->dump("", " ");
174// // std::cout << "distance = " << distance << std::endl;
175// }
176
177// //...Check # of hits on this line
178// if (l->hits().length() > 2) {
179// unsigned i = 0;
180// while (TMDCWireHit * h = (l->hits())[i]) {
181// unsigned leftRight = * (l->leftRight())[i];
182// unsigned newState = h->state() | (1 << leftRight);
183// h->state(newState);
184// ++i;
185
186// //...For debug...
187// // h->dump("", " ");
188// }
189// }
190
191// //...Delete line here...
192// delete l;
193// }
194// }
195}

The documentation for this class was generated from the following files: