54 if (msg ==
"") def =
true;
56 if (def || msg.find(
"cluster") != std::string::npos || msg.find(
"detail") != std::string::npos) {
58 std::cout <<
"#links=" <<
_links.length();
59 std::cout <<
"(" << _innerWidth <<
"," << _outerWidth <<
":";
60 std::cout <<
clusterType() <<
")," << _nDual <<
"," << _duality <<
",";
61 std::cout << _angle << std::endl;
63 if (def || msg.find(
"vector") != std::string::npos || msg.find(
"detail") != std::string::npos) {
65 std::cout <<
"pos" << _position <<
"," <<
"dir" << _direction;
66 std::cout << std::endl;
72TSegment0::update(
void)
const {
79 if (
_links.length() == 0)
return;
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;
88 _nLayer = _outerMostLayer - _innerMostLayer + 1;
90 double centerX =
_links[0]->position().x();
95 for (
unsigned i = 0; i <
_links.length(); i++) {
97 double diff = tmp.x() - centerX;
99 tmp.setX(centerX - 2. *
M_PI + diff);
101 else if (diff < -
M_PI) {
102 tmp.setX(centerX + 2. *
M_PI + diff);
107 unsigned id =
_links[i]->wire()->layerId();
108 if (
id == _innerMostLayer) {
111 _inners.append(
_links[i]);
113 if (
id == _outerMostLayer) {
116 _outers.append(
_links[i]);
119 _innerWidth =
Width(_inners);
120 _outerWidth =
Width(_outers);
121 _position *= (1. / (float)
_links.length());
123 inner *= (1. / (float) nInner);
124 outer *= (1. / (float) nOuter);
125 _direction = (inner - outer).
unit();
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());
136 float radial = fabs(_direction.dot(dir));
137 float radial2 = radial * radial;
139 return (dir.mag2() - radial2) > 0.0 ? sqrt(dir.mag2() - radial2) : 0.;
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());
148 float radial = fabs(
v.unit().dot(dir));
149 float radial2 = radial * radial;
151 return (dir.mag2() - radial2) > 0.0 ? sqrt(dir.mag2() - radial2) : 0.;
156#ifdef TRKRECO_DEBUG_DETAIL
158 std::cout <<
"TSegment0::range !!! bad arguments:min,max=";
159 std::cout << min <<
"," << max << std::endl;
164 if (
n == 0)
return Range(0., 0.);
169 for (
unsigned i = 0; i <
n; i++) {
170 double x =
_links[i]->position().x();
171 if (x < min || x > max)
continue;
176 if (! found)
return Range(0., 0.);
178#ifdef TRKRECO_DEBUG_DETAIL
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;
189 double distance0, distance1;
191 distance0 =
x - center;
192 distance1 = distanceMax - distance0;
195 distance1 = center -
x;
196 distance0 = distanceMax - distance1;
199 if (distance0 < distance1) {
200 if (distance0 > distanceR) distanceR = distance0;
203 if (distance1 > distanceL) distanceL = distance1;
206#ifdef TRKRECO_DEBUG_DETAIL
217 double right = center + distanceR;
218 double left = center - distanceL;
220 return Range(left, right);
224TSegment0::updateType(
void)
const {
236 if ((_innerWidth < fat) && (_outerWidth < fat)) {
240 if (_nLayer > tall) _clusterType = 2;
245 else if (_outerWidth < fat) {
251 else if (_innerWidth < fat) {
259 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
262 for (
unsigned j = 0; j <
_links.length(); j++)
263 if (
_links[j]->wire()->layerId() == i) {
275 if (space) _clusterType = 6;
286#ifdef TRKRECO_DEBUG_DETAIL
287 std::cout <<
" ... splitting : type=" <<
t << std::endl;
289 if (
t == 0)
return list;
293 if (_nDual > 2 && _duality > 0.7)
return splitDual();
296 else if (
t == 1)
return list;
297 else if (
t == 7)
return list;
300 else if (
t == 6)
return splitParallel();
303 else if (
t > 4)
return splitComplicated();
310TSegment0::splitAV(
void)
const {
316 if (
t == 3) corners = & _outers;
317 else corners = & _inners;
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);
327 if (
t == 3)
links = & _inners;
328 else links = & _outers;
332 for (
unsigned i = 0; i < 2; i++) {
333 edgePos[i] = edge[i]->wire()->xyPosition();
334 v[i] = (edgePos[i] - corner).
unit();
336 seeds[0].append(edge[0]);
337 seeds[1].append(edge[1]);
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;
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;
354 for (
unsigned i = 0; i <
n; i++) {
356 if (edge.member(l))
continue;
357 if (corners->member(l))
continue;
360 double p2 = p.mag2();
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.;
368 if (dist[0] < dist[1]) seeds[0].append(l);
369 else seeds[1].append(l);
371#ifdef TRKRECO_DEBUG_DETAIL
372 std::cout <<
" p:" << p << std::endl;
374 std::cout << l->
wire()->
localId() <<
":" << dist[0];
375 std::cout <<
"," << dist[1] << std::endl;
380 for (
unsigned i = 0; i < 2; i++) {
381 if (seeds[i].length()) {
384 if (ncx.length() == 0) {
398TSegment0::splitComplicated(
void)
const {
404 for (
unsigned i = 0; i <
n; i++) {
406 unsigned state = h->
state();
411 goodHits.append(
_links[i]);
413 if (goodHits.length() == 0)
return newClusters;
418 while (goodHits.length()) {
421 TMLink * seed = goodHits.last();
423 unsigned localId = wire->
localId();
425 unsigned nn =
_links.length();
426 for (
unsigned i = 0; i < nn; i++) {
431 if (
abs((
int) w->
localId() - (
int) localId) < 2) used.append(
t);
434#ifdef TRKRECO_DEBUG_DETAIL
435 std::cout <<
" seed is " << seed->
wire()->
name() << std::endl;
437 for (
unsigned i = 0; i < used.length(); i++) {
438 std::cout << used[i]->wire()->name() <<
",";
440 std::cout << std::endl;
444 if (used.length() == 0)
continue;
445 if (used.length() ==
nLinks())
return newClusters;
448 if (cx.length() == 0) {
450 newClusters.append(c);
453 newClusters.append(cx);
456 goodHits.remove(used);
457 original.remove(used);
461 if ((original.length()) && (original.length() <
nLinks())) {
464 if (cx.length() == 0) {
466 newClusters.append(c);
469 newClusters.append(cx);
478TSegment0::splitParallel(
void)
const {
481 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
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;
492 seeds[0].append(outerList[0]);
493 seeds[1].append(outerList[1]);
494 if (list.length() == 2)
continue;
496 const TMDCWire & wire0 = * outerList[0]->wire();
497 const TMDCWire & wire1 = * outerList[1]->wire();
498 for (
unsigned k = 0; k < list.length(); k++) {
500 if (
t == outerList[0])
continue;
501 if (
t == outerList[1])
continue;
511 if ((seeds[0].length()) && (seeds[0].length() <
nLinks())) {
515 newClusters.append(c0x);
520 newClusters.append(c0);
524 if ((seeds[1].length()) && (seeds[1].length() <
nLinks())) {
528 newClusters.append(c1x);
533 newClusters.append(
c1);
541TSegment0::updateDuality(
void)
const {
545 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; 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());
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());
558 if (list.length() == 2) {
559 if (
Width(list) != 2)
continue;
569 if (_nDual > 0) _duality /= float(_nDual);
570 _angle = (
x[1] -
x[0]).
unit().dot(x[0].
unit());
574TSegment0::splitDual(
void)
const {
575#ifdef TRKRECO_DEBUG_DETAIL
576 std::cout <<
" TSegment0::splitDual called" << std::endl;
580 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
583 if (list.length() == 2) {
584 if (
Width(list) == 2) {
585 seeds[0].append(list[0]);
586 seeds[1].append(list[1]);
590 unknown.append(list);
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;
600 const HepPoint3D & p0 = seeds[0][0]->xyPosition();
601 const HepPoint3D & p1 = seeds[1][0]->xyPosition();
605 for (
unsigned i = 0; i < unknown.length(); i++) {
608 double d0 = (x0 - (x0.dot(v0) * v0)).mag();
610 double d1 = (x1 - (x1.dot(v0) * v0)).mag();
612 if (d0 < d1) seeds[0].append(
t);
613 else seeds[1].append(
t);
618 newClusters.append(
new TSegment0(seeds[0]));
619 newClusters.append(
new TSegment0(seeds[1]));
626 if (_clusterType == 0)
return 0;
627 if (_nDual == 0)
return 0;
631 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
634 if (list.length() == 1) {
635 seeds.append(list[0]);
637 else if (list.length() == 2) {
638 if (
Width(list) > 1) {
643 if (
distance > 0.5) duals.append(list);
644#ifdef TRKRECO_DEBUG_DETAIL
652 else if (list.length() == 0) {
655#ifdef TRKRECO_DEBUG_DETAIL
657 std::cout <<
"TSegment0::solveDualHits !!! this is not expected 2";
658 std::cout << std::endl;
659 this->
dump(
"cluster hits mc",
" ");
665 if (seeds.length() < 2)
return -1;
667 const HepPoint3D & p = outers[0]->xyPosition();
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];
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);
796 unsigned nList = list.length();
797 for (
unsigned i = 0; i < nList; i++) {
799 for (
unsigned j = 0; j < links.length(); j++) {
800 unsigned state = links[j]->hit()->state();
815 unsigned n = links.length();
816 for (
unsigned i = 0; i <
n; i++) {
817 if (trackLinks.hasMember(links[i]))
double abs(const EvtComplex &c)
*******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
**********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
const HepPoint3D ORIGIN
Constants.
#define WireHitContinuous
#define WireHitPatternLeft
#define WireHitPatternRight
unsigned Width(const AList< TMLink > &list)
returns width(wire cell unit) of given AList<TMLink>. This function assumes that all TMLink's are in ...
AList< TMLink > InOut(const AList< TMLink > &list)
returns links which are in the inner most and outer most layer. This function assumes that all TMLink...
AList< TMLink > Edges(const AList< TMLink > &list)
returns links which are edges. This function assumes that all TMLink's are in the same super layer.
int SortByWireId(const void *av, const void *bv)
Sorter.
AList< TMLink > SameLayer(const AList< TMLink > &list, const TMLink &a)
returns links which are in the same layer as 'a' or 'id'.
unsigned NCoreLinks(const CAList< TSegment0 > &list)
returns # of core links in segments.
AList< TMLink > Links(const TSegment0 &s, const TTrack &t)
returns AList of TMLink used for a track.
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.
std::string name(void) const
returns name.
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
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.
double distance(const TSegment0 &) const
calculates distance between two clusters. Smaller value indicates closer.
Range rangeX(double min, double max) const
returns Range of x-coordinate of TMLinks.
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...
virtual ~TSegment0()
Destructor.
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.
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.
unsigned nLinks(unsigned mask=0) const
returns # of masked TMLinks assigned to this track object.
A class to represent a track in tracking.