BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
TSegment0.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TSegment0.cxx,v 1.7 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : TSegment0.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to manage a group of TMLink's.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#include "TrkReco/TTrack.h"
14#include "TrkReco/TSegment0.h"
15#include "TrkReco/TMDCUtil.h"
16#include "TrkReco/TMLink.h"
17#include "TrkReco/TMDCWire.h"
18#include "TrkReco/TMDCWireHit.h"
19//#include "cdc/Range.h"
20#include "TrkReco/Range.h"
21
23: TTrackBase(),
24 _innerWidth(0),
25 _outerWidth(0),
26 _nLayer(0),
27 _clusterType(0),
28 _duality(0.),
29 _nDual(0),
30 _angle(0.) {
31 _fitted = false;
32}
33
35: TTrackBase(a),
36 _innerWidth(0),
37 _outerWidth(0),
38 _nLayer(0),
39 _clusterType(0),
40 _duality(0.),
41 _nDual(0),
42 _angle(0.) {
43 _links.sort(SortByWireId);
44 _fitted = false;
45}
46
48}
49
50void
51TSegment0::dump(const std::string & msg, const std::string & pre) const {
52 if (! _fitted) update();
53 bool def = false;
54 if (msg == "") def = true;
55
56 if (def || msg.find("cluster") != std::string::npos || msg.find("detail") != std::string::npos) {
57 std::cout << pre;
58 std::cout << "#links=" << _links.length();
59 std::cout << "(" << _innerWidth << "," << _outerWidth << ":";
60 std::cout << clusterType() << ")," << _nDual << "," << _duality << ",";
61 std::cout << _angle << std::endl;
62 }
63 if (def || msg.find("vector") != std::string::npos || msg.find("detail") != std::string::npos) {
64 std::cout << pre;
65 std::cout << "pos" << _position << "," << "dir" << _direction;
66 std::cout << std::endl;
67 }
68 if (! def) TTrackBase::dump(msg, pre);
69}
70
71void
72TSegment0::update(void) const {
73 _clusterType = 0;
74 _position = ORIGIN;
75 _direction = ORIGIN;
76 _inners.removeAll();
77 _outers.removeAll();
78
79 if (_links.length() == 0) return;
80
81 _innerMostLayer = _links[0]->wire()->layerId();
82 _outerMostLayer = _innerMostLayer;
83 for (unsigned i = 1; i < _links.length(); i++) {
84 unsigned id = _links[i]->wire()->layerId();
85 if (id < _innerMostLayer) _innerMostLayer = id;
86 else if (id > _outerMostLayer) _outerMostLayer = id;
87 }
88 _nLayer = _outerMostLayer - _innerMostLayer + 1;
89
90 double centerX = _links[0]->position().x();
91 HepPoint3D inner = ORIGIN;
92 HepPoint3D outer = ORIGIN;
93 unsigned nInner = 0;
94 unsigned nOuter = 0;
95 for (unsigned i = 0; i < _links.length(); i++) {
96 HepPoint3D tmp = _links[i]->position();
97 double diff = tmp.x() - centerX;
98 if (diff > M_PI) {
99 tmp.setX(centerX - 2. * M_PI + diff);
100 }
101 else if (diff < - M_PI) {
102 tmp.setX(centerX + 2. * M_PI + diff);
103 }
104
105 _links[i]->conf(tmp);
106 _position += tmp;
107 unsigned id = _links[i]->wire()->layerId();
108 if (id == _innerMostLayer) {
109 inner += tmp;
110 ++nInner;
111 _inners.append(_links[i]);
112 }
113 if (id == _outerMostLayer) {
114 outer += tmp;
115 ++nOuter;
116 _outers.append(_links[i]);
117 }
118 }
119 _innerWidth = Width(_inners);
120 _outerWidth = Width(_outers);
121 _position *= (1. / (float) _links.length());
122
123 inner *= (1. / (float) nInner);
124 outer *= (1. / (float) nOuter);
125 _direction = (inner - outer).unit();
126
127 _fitted = true;
128}
129
130double
132 HepVector3D dir = c.position() - _position;
133 if (dir.x() > M_PI) dir.setX(dir.x() - 2. * M_PI);
134 else if (dir.x() < - M_PI) dir.setX(2. * M_PI + dir.x());
135
136 float radial = fabs(_direction.dot(dir));
137 float radial2 = radial * radial;
138
139 return (dir.mag2() - radial2) > 0.0 ? sqrt(dir.mag2() - radial2) : 0.;
140}
141
142double
143TSegment0::distance(const HepPoint3D & p, const HepVector3D & v) const {
144 HepVector3D dir = _position - p;
145 if (dir.x() > M_PI) dir.setX(dir.x() - 2. * M_PI);
146 else if (dir.x() < - M_PI) dir.setX(2. * M_PI + dir.x());
147
148 float radial = fabs(v.unit().dot(dir));
149 float radial2 = radial * radial;
150
151 return (dir.mag2() - radial2) > 0.0 ? sqrt(dir.mag2() - radial2) : 0.;
152}
153
154Range
155TSegment0::rangeX(double min, double max) const {
156#ifdef TRKRECO_DEBUG_DETAIL
157 if (min > max) {
158 std::cout << "TSegment0::range !!! bad arguments:min,max=";
159 std::cout << min << "," << max << std::endl;
160 }
161#endif
162
163 unsigned n = _links.length();
164 if (n == 0) return Range(0., 0.);
165
166 //...Search for a center...
167 bool found = false;
168 double center;
169 for (unsigned i = 0; i < n; i++) {
170 double x = _links[i]->position().x();
171 if (x < min || x > max) continue;
172 center = x;
173 found = true;
174 break;
175 }
176 if (! found) return Range(0., 0.);
177
178#ifdef TRKRECO_DEBUG_DETAIL
179// std::cout << " center=" << center << std::endl;
180#endif
181
182 double distanceR = 0.;
183 double distanceL = 0.;
184 double distanceMax = max - min;
185 for (unsigned i = 0; i < n; i++) {
186 double x = _links[i]->position().x();
187 if (x < min || x > max) continue;
188
189 double distance0, distance1;
190 if (x > center) {
191 distance0 = x - center;
192 distance1 = distanceMax - distance0;
193 }
194 else {
195 distance1 = center - x;
196 distance0 = distanceMax - distance1;
197 }
198
199 if (distance0 < distance1) {
200 if (distance0 > distanceR) distanceR = distance0;
201 }
202 else {
203 if (distance1 > distanceL) distanceL = distance1;
204 }
205
206#ifdef TRKRECO_DEBUG_DETAIL
207// std::cout << " ";
208// std::cout << _links[i]->wire()->layerId() << "-";
209// std::cout << _links[i]->wire()->localId() << ",";
210// std::cout << _links[i]->position().x();
211// std::cout << ",0,1=" << distance0 << "," << distance1;
212// std::cout << ",l,r=" << distanceL << "," << distanceR;
213// std::cout << std::endl;
214#endif
215 }
216
217 double right = center + distanceR;
218 double left = center - distanceL;
219
220 return Range(left, right);
221}
222
223void
224TSegment0::updateType(void) const {
225 if (! nLinks()) return;
226 if (! _fitted) update();
227
228 //...Parameter...
229 unsigned fat = 3;
230 unsigned tall = 3;
231
232 //...Calculate
233 updateDuality();
234
235 //...Long or short...
236 if ((_innerWidth < fat) && (_outerWidth < fat)) {
237 _clusterType = 1;
238
239 //...Check length across a super layer...
240 if (_nLayer > tall) _clusterType = 2;
241 return;
242 }
243
244 //...A...
245 else if (_outerWidth < fat) {
246 _clusterType = 3;
247 return;
248 }
249
250 //...V...
251 else if (_innerWidth < fat) {
252 _clusterType = 4;
253 return;
254 }
255
256 //...X or parallel...
257 else {
258 bool space = true;
259 for (unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
260 unsigned n = 0;
261 AList<TMLink> tmp;
262 for (unsigned j = 0; j < _links.length(); j++)
263 if (_links[j]->wire()->layerId() == i) {
264 ++n;
265 tmp.append(_links[j]);
266 }
267
268 if (n == Width(tmp)) {
269 space = false;
270 break;
271 }
272 }
273
274 _clusterType = 5;
275 if (space) _clusterType = 6;
276 return;
277 }
278}
279
281TSegment0::split(void) const {
282 AList<TSegment0> list;
283
284 //...Do not split if cluster type is 1, 2, or 7...
285 unsigned t = clusterType();
286#ifdef TRKRECO_DEBUG_DETAIL
287 std::cout << " ... splitting : type=" << t << std::endl;
288#endif
289 if (t == 0) return list;
290 else if (t == 2) {
291 // beta 5 if (_nDual > 2 && _duality > 0.7 && _angle > 0.7)
292 // return splitDual();
293 if (_nDual > 2 && _duality > 0.7) return splitDual();
294 return list;
295 }
296 else if (t == 1) return list;
297 else if (t == 7) return list;
298
299 //...Parallel...
300 else if (t == 6) return splitParallel();
301
302 //...Avoid splitting of X or parallel...(future implementation)...
303 else if (t > 4) return splitComplicated();
304
305 //...A or V...
306 return splitAV();
307}
308
310TSegment0::splitAV(void) const {
311 unsigned t = clusterType();
312 AList<TMLink> seeds[2];
313
314 //...Calculate corner of V or A...
315 const AList<TMLink> * corners;
316 if (t == 3) corners = & _outers;
317 else corners = & _inners;
318 HepPoint3D corner;
319 for (unsigned i = 0; i < corners->length(); i++)
320 corner += (* corners)[i]->wire()->xyPosition();
321 corner *= 1. / (float) corners->length();
322 seeds[0].append(* corners);
323 seeds[1].append(* corners);
324
325 //...Calculdate edges...
326 const AList<TMLink> * links;
327 if (t == 3) links = & _inners;
328 else links = & _outers;
329 AList<TMLink> edge = Edges(* links);
330 HepPoint3D edgePos[2];
331 HepVector3D v[2];
332 for (unsigned i = 0; i < 2; i++) {
333 edgePos[i] = edge[i]->wire()->xyPosition();
334 v[i] = (edgePos[i] - corner).unit();
335 }
336 seeds[0].append(edge[0]);
337 seeds[1].append(edge[1]);
338
339#ifdef TRKRECO_DEBUG_DETAIL
340 std::cout << " corner:" << corner << std::endl;
341 std::cout << " edge:" << edgePos[0] << "(";
342 std::cout << edge[0]->wire()->layerId() << "-";
343 std::cout << edge[0]->wire()->localId() << ")";
344 std::cout << v[0] << std::endl;
345 std::cout << " ";
346 std::cout << edgePos[1] << "(";
347 std::cout << edge[1]->wire()->layerId() << "-";
348 std::cout << edge[1]->wire()->localId() << ")";
349 std::cout << v[1] << std::endl;
350#endif
351
352 //...Examine each hits...
353 unsigned n = _links.length();
354 for (unsigned i = 0; i < n; i++) {
355 TMLink * l = _links[i];
356 if (edge.member(l)) continue;
357 if (corners->member(l)) continue;
358
359 HepVector3D p = l->wire()->xyPosition() - corner;
360 double p2 = p.mag2();
361
362 double dist[2];
363 for (unsigned j = 0; j < 2; j++) {
364 dist[j] = v[j].dot(p);
365 double d2 = dist[j] * dist[j];
366 dist[j] = (p2 - d2) > 0. ? sqrt(p2 - d2) : 0.;
367 }
368 if (dist[0] < dist[1]) seeds[0].append(l);
369 else seeds[1].append(l);
370
371#ifdef TRKRECO_DEBUG_DETAIL
372 std::cout << " p:" << p << std::endl;
373 std::cout << " " << l->wire()->layerId() << "-";
374 std::cout << l->wire()->localId() << ":" << dist[0];
375 std::cout << "," << dist[1] << std::endl;
376#endif
377 }
378
379 AList<TSegment0> list;
380 for (unsigned i = 0; i < 2; i++) {
381 if (seeds[i].length()) {
382 TSegment0 * nc = new TSegment0(seeds[i]);
383 AList<TSegment0> ncx = nc->split();
384 if (ncx.length() == 0) {
385 nc->solveDualHits();
386 list.append(nc);
387 }
388 else {
389 list.append(ncx);
390 delete nc;
391 }
392 }
393 }
394 return list;
395}
396
398TSegment0::splitComplicated(void) const {
399
400 //...Select best hits...
401 AList<TSegment0> newClusters;
402 AList<TMLink> goodHits;
403 unsigned n = _links.length();
404 for (unsigned i = 0; i < n; i++) {
405 const TMDCWireHit * h = _links[i]->hit();
406 unsigned state = h->state();
407 if (! (state & WireHitContinuous)) continue;
408 if (! (state & WireHitIsolated)) continue;
409 if ((! (state & WireHitPatternLeft)) &&
410 (! (state & WireHitPatternRight))) continue;
411 goodHits.append(_links[i]);
412 }
413 if (goodHits.length() == 0) return newClusters;
414
415 //...Main loop...
416 goodHits.sort(SortByWireId);
417 AList<TMLink> original(_links);
418 while (goodHits.length()) {
419
420 //...Select an edge hit...
421 TMLink * seed = goodHits.last();
422 const TMDCWire * wire = seed->wire();
423 unsigned localId = wire->localId();
424 AList<TMLink> used;
425 unsigned nn = _links.length();
426 for (unsigned i = 0; i < nn; i++) {
427 TMLink * t = _links[i];
428 const TMDCWire * w = t->wire();
429
430 //...Straight?...
431 if (abs((int) w->localId() - (int) localId) < 2) used.append(t);
432 }
433
434#ifdef TRKRECO_DEBUG_DETAIL
435 std::cout << " seed is " << seed->wire()->name() << std::endl;
436 std::cout << " ";
437 for (unsigned i = 0; i < used.length(); i++) {
438 std::cout << used[i]->wire()->name() << ",";
439 }
440 std::cout << std::endl;
441#endif
442
443 //...Create new cluster...
444 if (used.length() == 0) continue;
445 if (used.length() == nLinks()) return newClusters;
446 TSegment0 * c = new TSegment0(used);
447 AList<TSegment0> cx = c->split();
448 if (cx.length() == 0) {
449 c->solveDualHits();
450 newClusters.append(c);
451 }
452 else {
453 newClusters.append(cx);
454 delete c;
455 }
456 goodHits.remove(used);
457 original.remove(used);
458 }
459
460 //...Remainings...
461 if ((original.length()) && (original.length() < nLinks())) {
462 TSegment0 * c = new TSegment0(original);
463 AList<TSegment0> cx = c->split();
464 if (cx.length() == 0) {
465 c->solveDualHits();
466 newClusters.append(c);
467 }
468 else {
469 newClusters.append(cx);
470 delete c;
471 }
472 }
473
474 return newClusters;
475}
476
478TSegment0::splitParallel(void) const {
479 AList<TMLink> seeds[2];
480 AList<TSegment0> newClusters;
481 for (unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
482 AList<TMLink> list = SameLayer(_links, i);
483 AList<TMLink> outerList = Edges(list);
484
485#ifdef TRKRECO_DEBUG_DETAIL
486 if (outerList.length() != 2) {
487 std::cout << "TSegment0::splitParallel !!! ";
488 std::cout << "This is not a parallel cluster" << std::endl;
489 }
490#endif
491
492 seeds[0].append(outerList[0]);
493 seeds[1].append(outerList[1]);
494 if (list.length() == 2) continue;
495
496 const TMDCWire & wire0 = * outerList[0]->wire();
497 const TMDCWire & wire1 = * outerList[1]->wire();
498 for (unsigned k = 0; k < list.length(); k++) {
499 TMLink * t = list[k];
500 if (t == outerList[0]) continue;
501 if (t == outerList[1]) continue;
502
503 if (abs(wire0.localIdDifference(* t->wire())) <
504 abs(wire1.localIdDifference(* t->wire())))
505 seeds[0].append(t);
506 else
507 seeds[1].append(t);
508 }
509 }
510
511 if ((seeds[0].length()) && (seeds[0].length() < nLinks())) {
512 TSegment0 * c0 = new TSegment0(seeds[0]);
513 AList<TSegment0> c0x = c0->split();
514 if (c0x.length()) {
515 newClusters.append(c0x);
516 delete c0;
517 }
518 else {
519 c0->solveDualHits();
520 newClusters.append(c0);
521 }
522 }
523
524 if ((seeds[1].length()) && (seeds[1].length() < nLinks())) {
525 TSegment0 * c1 = new TSegment0(seeds[1]);
526 AList<TSegment0> c1x = c1->split();
527 if (c1x.length()) {
528 newClusters.append(c1x);
529 delete c1;
530 }
531 else {
532 c1->solveDualHits();
533 newClusters.append(c1);
534 }
535 }
536
537 return newClusters;
538}
539
540void
541TSegment0::updateDuality(void) const {
542 _duality = 0.;
543 _nDual = 0;
544 HepPoint3D x[2];
545 for (unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
546 AList<TMLink> list = SameLayer(_links, i);
547 if (i == _innerMostLayer) {
548 for (unsigned j = 0; j < list.length(); j++)
549 x[0] += list[j]->hit()->xyPosition();
550 x[0] *= 1. / double(list.length());
551 }
552 else if (i == _outerMostLayer) {
553 for (unsigned j = 0; j < list.length(); j++)
554 x[1] += list[j]->hit()->xyPosition();
555 x[1] *= 1. / double(list.length());
556 }
557
558 if (list.length() == 2) {
559 if (Width(list) != 2) continue;
560 const TMDCWireHit * h0 = list[0]->hit();
561 const TMDCWireHit * h1 = list[1]->hit();
562
563 double distance = (h0->xyPosition() - h1->xyPosition()).mag();
564 distance = fabs(distance - h0->drift() - h1->drift());
565 _duality += distance;
566 ++_nDual;
567 }
568 }
569 if (_nDual > 0) _duality /= float(_nDual);
570 _angle = (x[1] - x[0]).unit().dot(x[0].unit());
571}
572
574TSegment0::splitDual(void) const {
575#ifdef TRKRECO_DEBUG_DETAIL
576 std::cout << " TSegment0::splitDual called" << std::endl;
577#endif
578 AList<TMLink> seeds[2];
579 AList<TMLink> unknown;
580 for (unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
581 AList<TMLink> list = SameLayer(_links, i);
582
583 if (list.length() == 2) {
584 if (Width(list) == 2) {
585 seeds[0].append(list[0]);
586 seeds[1].append(list[1]);
587 continue;
588 }
589 }
590 unknown.append(list);
591 }
592
593 if (unknown.length() > 0) {
594#ifdef TRKRECO_DEBUG_DETAIL
595 if (seeds[0].length() == 0)
596 std::cout << "TSegment0::splitDual !!! no TMLink for seed 0" << std::endl;
597 if (seeds[1].length() == 0)
598 std::cout << "TSegment0::splitDual !!! no TMLink for seed 1" << std::endl;
599#endif
600 const HepPoint3D & p0 = seeds[0][0]->xyPosition();
601 const HepPoint3D & p1 = seeds[1][0]->xyPosition();
602 HepVector3D v0 = (seeds[0].last()->xyPosition() - p0).unit();
603 HepVector3D v1 = (seeds[1].last()->xyPosition() - p1).unit();
604
605 for (unsigned i = 0; i < unknown.length(); i++) {
606 TMLink * t = unknown[i];
607 HepVector3D x0 = t->xyPosition() - p0;
608 double d0 = (x0 - (x0.dot(v0) * v0)).mag();
609 HepVector3D x1 = t->xyPosition() - p1;
610 double d1 = (x1 - (x1.dot(v0) * v0)).mag();
611
612 if (d0 < d1) seeds[0].append(t);
613 else seeds[1].append(t);
614 }
615 }
616
617 AList<TSegment0> newClusters;
618 newClusters.append(new TSegment0(seeds[0]));
619 newClusters.append(new TSegment0(seeds[1]));
620 return newClusters;
621}
622
623int
625 updateType();
626 if (_clusterType == 0) return 0;
627 if (_nDual == 0) return 0;
628
629 AList<TMLink> seeds;
630 AList<TMLink> duals;
631 for (unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
632 AList<TMLink> list = SameLayer(_links, i);
633
634 if (list.length() == 1) {
635 seeds.append(list[0]);
636 }
637 else if (list.length() == 2) {
638 if (Width(list) > 1) {
639 const TMDCWireHit * h0 = list[0]->hit();
640 const TMDCWireHit * h1 = list[1]->hit();
641 double distance = (h0->xyPosition() - h1->xyPosition()).mag();
642 distance = fabs(distance - h0->drift() - h1->drift());
643 if (distance > 0.5) duals.append(list);
644#ifdef TRKRECO_DEBUG_DETAIL
645// h0->dump();
646// h1->dump();
647// std::cout << "duality distance = " << distance << std::endl;
648// std::cout << "i = " << i << std::endl;
649#endif
650 }
651 }
652 else if (list.length() == 0) {
653 continue;
654 }
655#ifdef TRKRECO_DEBUG_DETAIL
656 else {
657 std::cout << "TSegment0::solveDualHits !!! this is not expected 2";
658 std::cout << std::endl;
659 this->dump("cluster hits mc", " ");
660 }
661#endif
662 }
663
664 //...Solve them...
665 if (seeds.length() < 2) return -1;
666 AList<TMLink> outers = InOut(seeds);
667 const HepPoint3D & p = outers[0]->xyPosition();
668 HepVector3D v = (outers[1]->xyPosition() - p).unit();
669 unsigned n = duals.length() / 2;
670 for (unsigned i = 0; i < n; i++) {
671 TMLink * t0 = duals[i * 2 + 0];
672 TMLink * t1 = duals[i * 2 + 1];
673 HepVector3D x0 = t0->xyPosition() - p;
674 HepVector3D x1 = t1->xyPosition() - p;
675 double d0 = (x0 - (x0.dot(v) * v)).mag();
676 double d1 = (x1 - (x1.dot(v) * v)).mag();
677 if (d0 < d1) _links.remove(t1);
678 else _links.remove(t0);
679 }
680 return n;
681}
682
683/*
684#include "tuple/BelleTupleManager.h"
685
686void
687CheckSegments(const CAList<TSegment0> & list) {
688 static bool first = true;
689 static BelleHistogram * hError;
690 static BelleHistogram * hNHeps[11];
691 static BelleHistogram * hNHits[3];
692
693 if (first) {
694 first = false;
695 extern BelleTupleManager * BASF_Histogram;
696 BelleTupleManager * m = BASF_Histogram;
697
698 hError = m->histogram("segment errors", 10, 0, 10, 20000);
699
700 hNHeps[0] = m->histogram("segment nheps sl 0", 10, 0., 10.);
701 hNHeps[1] = m->histogram("segment nheps sl 1", 10, 0., 10.);
702 hNHeps[2] = m->histogram("segment nheps sl 2", 10, 0., 10.);
703 hNHeps[3] = m->histogram("segment nheps sl 3", 10, 0., 10.);
704 hNHeps[4] = m->histogram("segment nheps sl 4", 10, 0., 10.);
705 hNHeps[5] = m->histogram("segment nheps sl 5", 10, 0., 10.);
706 hNHeps[6] = m->histogram("segment nheps sl 6", 10, 0., 10.);
707 hNHeps[7] = m->histogram("segment nheps sl 7", 10, 0., 10.);
708 hNHeps[8] = m->histogram("segment nheps sl 8", 10, 0., 10.);
709 hNHeps[9] = m->histogram("segment nheps sl 9", 10, 0., 10.);
710 hNHeps[10] = m->histogram("segment nheps sl 10", 10, 0., 10.);
711
712 hNHits[0] = m->histogram("segment nhits, nheps = 1", 20, 0., 20.);
713 hNHits[1] = m->histogram("segment nhits, nheps = 2", 20, 0., 20.);
714 hNHits[2] = m->histogram("segment nhits, nheps >= 3", 20, 0., 20.);
715
716 std::cout << "CheckSegments ... initialized" << std::endl;
717 return;
718 }
719
720 unsigned n = list.length();
721 for (unsigned i = 0; i < n; i++) {
722 const TSegment0 & s = * list[i];
723 const AList<TMLink> & links = s.links();
724 unsigned nLinks = links.length();
725 if (nLinks == 0) {
726 hError->accumulate(0.5);
727 continue;
728 }
729
730 unsigned sl = links[0]->wire()->superLayerId();
731 unsigned nHeps = s.nHeps();
732 hNHeps[sl]->accumulate((float) nHeps + .5);
733 if (nHeps == 1) hNHits[0]->accumulate((float) nLinks + .5);
734 else if (nHeps == 2) hNHits[1]->accumulate((float) nLinks + .5);
735 else hNHits[2]->accumulate((float) nLinks + .5);
736 }
737}
738
739void
740CheckSegmentLink(const TSegment0 & base,
741 const TSegment0 & next,
742 float distance,
743 float dirAngle) {
744 static bool first = true;
745 static BelleHistogram * hAngle[2];
746 static BelleHistogram * hAngle1[2];
747 static BelleHistogram * hDistance[2];
748 static BelleHistogram * hDirAngle[2];
749 static BelleHistogram * hDirAngle1[2];
750
751 if (first) {
752 first = false;
753 extern BelleTupleManager * BASF_Histogram;
754 BelleTupleManager * m = BASF_Histogram;
755
756 hAngle[0] = m->histogram("segment correct link, angle",
757 50, -1., 1., 21000);
758 hAngle[1] = m->histogram("segment wrong link, angle", 50, -1., 1.);
759 hAngle1[0] = m->histogram("segment correct link, angle, wide",
760 50, .8, 1.);
761 hAngle1[1] = m->histogram("segment wrong link, angle, wide",
762 50, .8, 1.);
763 hDistance[0] = m->histogram("segment correct link, dist", 50, 0., 1.);
764 hDistance[1] = m->histogram("segment wrong link, dist", 50, 0., 1.);
765 hDirAngle[0] = m->histogram("segment correct link, dir angle",
766 50, -1, 1.);
767 hDirAngle[1] = m->histogram("segment wrong link, dir angle",
768 50, -1, 1.);
769 hDirAngle1[0] = m->histogram("segment correct link, dir angle, wide",
770 50, .8, 1.);
771 hDirAngle1[1] = m->histogram("segment wrong link, dir angle, wide",
772 50, .8, 1.);
773
774 std::cout << "CheckSegmentLink ... initialized" << std::endl;
775 return;
776 }
777
778 const TTrackHEP * const hep0 = base.hep();
779 const TTrackHEP * const hep1 = next.hep();
780
781 float angle = base.direction().dot(next.direction());
782
783 unsigned id = 0;
784 if (hep0 != hep1) id = 1;
785 hAngle[id]->accumulate(angle);
786 hAngle1[id]->accumulate(angle);
787 hDistance[id]->accumulate(distance);
788 hDirAngle[id]->accumulate(dirAngle);
789 hDirAngle1[id]->accumulate(dirAngle);
790}
791*/
792
793unsigned
795 unsigned n = 0;
796 unsigned nList = list.length();
797 for (unsigned i = 0; i < nList; i++) {
798 const AList<TMLink> & links = list[i]->links();
799 for (unsigned j = 0; j < links.length(); j++) {
800 unsigned state = links[j]->hit()->state();
801 if ((! (state & WireHitPatternLeft)) &&
802 (! (state & WireHitPatternRight)))
803 ++n;
804 }
805 }
806 return n;
807}
808
810Links(const TSegment0 & s, const TTrack & t) {
812
813 const AList<TMLink> & links = s.links();
814 const AList<TMLink> & trackLinks = t.links();
815 unsigned n = links.length();
816 for (unsigned i = 0; i < n; i++) {
817 if (trackLinks.hasMember(links[i]))
818 a.append(links[i]);
819 }
820
821 return a;
822}
const Int_t n
Double_t x[10]
double w
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
Definition: FoamA.h:90
XmlRpcServer s
Definition: HelloServer.cpp:11
const HepPoint3D ORIGIN
Constants.
Definition: TMDCUtil.cxx:47
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
#define M_PI
Definition: TConstant.h:4
unsigned NCoreLinks(const CAList< TSegment0 > &list)
returns # of core links in segments.
Definition: TSegment0.cxx:794
AList< TMLink > Links(const TSegment0 &s, const TTrack &t)
returns AList of TMLink used for a track.
Definition: TSegment0.cxx:810
to specify 1-dim region or range by two floats
unsigned state(void) const
returns state.
float drift(unsigned) const
returns drift distance.
const HepPoint3D & xyPosition(void) const
returns drift time
A class to represent a wire in MDC.
unsigned localId(void) const
returns local id in a wire layer.
unsigned layerId(void) const
returns layer id.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
int localIdDifference(const TMDCWire &) const
returns local id difference.
Definition: TMDCWire.cxx:577
std::string name(void) const
returns name.
A class to relate TMDCWireHit and TTrack objects.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TSegment0.cxx:51
int solveDualHits(void)
Definition: TSegment0.cxx:624
double distance(const TSegment0 &) const
calculates distance between two clusters. Smaller value indicates closer.
Definition: TSegment0.cxx:131
Range rangeX(double min, double max) const
returns Range of x-coordinate of TMLinks.
Definition: TSegment0.cxx:155
AList< TSegment0 > split(void) const
returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no cluster is returne...
Definition: TSegment0.cxx:281
TSegment0()
Constructor.
Definition: TSegment0.cxx:22
virtual ~TSegment0()
Destructor.
Definition: TSegment0.cxx:47
const HepPoint3D & position(void) const
returns position.
unsigned clusterType(void) const
returns cluster type. 0:empty, 1:short line, 2:long line, 3:V shage(from outside),...
A virtual class for a track class in tracking.
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TTrackBase.cxx:58
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
unsigned nLinks(unsigned mask=0) const
returns # of masked TMLinks assigned to this track object.
Definition: TTrackBase.cxx:305
A class to represent a track in tracking.
int t()
Definition: t.c:1