23#include "CLHEP/Vector/ThreeVector.h"
25#include "CLHEP/Matrix/Vector.h"
119 if (msg ==
"") def =
true;
121 if (def || msg.find(
"cluster") != std::string::npos || msg.find(
"detail") != std::string::npos) {
123 std::cout <<
"#links=" <<
_links.length();
124 std::cout <<
"(" << _innerWidth <<
"," << _outerWidth <<
":";
125 std::cout <<
clusterType() <<
")," << _nDual <<
"," << _duality <<
",";
126 std::cout << _angle << std::endl;
128 if (def || msg.find(
"vector") != std::string::npos || msg.find(
"detail") != std::string::npos) {
130 std::cout <<
"pos" << _position <<
"," <<
"dir" << _direction;
131 std::cout << std::endl;
133 if (def || msg.find(
"state") != std::string::npos || msg.find(
"detail") != std::string::npos) {
135 std::cout <<
"state=" << _state << std::cout << std::endl;
137 if (def || msg.find(
"link") != std::string::npos || msg.find(
"detail") != std::string::npos) {
140 std::cout <<
",major links=" <<
NMajorLinks(*
this);
142 std::cout << std::endl;
148TSegment::update(
void)
const {
156 if (
_links.length() == 0)
return;
159 _innerMostLayer =
_links[0]->wire()->layerId();
160 _outerMostLayer = _innerMostLayer;
161 for (
unsigned i = 1; i <
_links.length(); i++) {
162 unsigned id =
_links[i]->wire()->layerId();
163 if (
id < _innerMostLayer) _innerMostLayer = id;
164 else if (
id > _outerMostLayer) _outerMostLayer = id;
166 _nLayer = _outerMostLayer - _innerMostLayer + 1;
168 double centerX =
_links[0]->position().x();
173 for (
unsigned i = 0; i <
n; i++) {
183 unsigned id =
_links[i]->wire()->layerId();
184 if (
id == _innerMostLayer) {
187 _inners.append(
_links[i]);
189 if (
id == _outerMostLayer) {
190 _outerPosition += tmp;
192 _outers.append(
_links[i]);
201 _innerWidth =
Width(_inners);
202 _outerWidth =
Width(_outers);
203 _position *= (1. / float(
n));
205 inner *= (1. / (float) nInner);
206 _outerPosition *= (1. / (float) nOuter);
207 _direction = (inner - _outerPosition).
unit();
239 if (dir.x() >
M_PI) dir.setX(dir.x() - 2. *
M_PI);
240 else if (dir.x() < -
M_PI) dir.setX(2. *
M_PI + dir.x());
242 float radial = fabs(_direction.dot(dir));
243 float radial2 = radial * radial;
245 return (dir.mag2() - radial2) > 0.0 ? sqrt(dir.mag2() - radial2) : 0.;
251 if (dir.x() >
M_PI) dir.setX(dir.x() - 2. *
M_PI);
252 else if (dir.x() < -
M_PI) dir.setX(2. *
M_PI + dir.x());
254 float radial = fabs(
v.unit().dot(dir));
255 float radial2 = radial * radial;
257 return (dir.mag2() - radial2) > 0.0 ? sqrt(dir.mag2() - radial2) : 0.;
262#ifdef TRKRECO_DEBUG_DETAIL
264 std::cout <<
"TSegment::range !!! bad arguments:min,max=";
265 std::cout << min <<
"," << max << std::endl;
270 if (
n == 0)
return Range(0., 0.);
275 for (
unsigned i = 0; i <
n; i++) {
276 double x =
_links[i]->position().x();
277 if (x < min || x > max)
continue;
282 if (! found)
return Range(0., 0.);
284#ifdef TRKRECO_DEBUG_DETAIL
288 double distanceR = 0.;
289 double distanceL = 0.;
290 double distanceMax = max - min;
291 for (
unsigned i = 0; i <
n; i++) {
292 double x =
_links[i]->position().x();
293 if (x < min || x > max)
continue;
295 double distance0, distance1;
298 distance1 = distanceMax - distance0;
302 distance0 = distanceMax - distance1;
305 if (distance0 < distance1) {
306 if (distance0 > distanceR) distanceR = distance0;
309 if (distance1 > distanceL) distanceL = distance1;
312#ifdef TRKRECO_DEBUG_DETAIL
323 double right =
center + distanceR;
324 double left =
center - distanceL;
326 return Range(left, right);
330TSegment::updateType(
void)
const {
343 if ((_innerWidth < fat) && (_outerWidth < fat)) {
347 if (_nLayer > tall) _clusterType = 2;
352 else if (_outerWidth < fat) {
358 else if (_innerWidth < fat) {
366 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
369 for (
unsigned j = 0; j <
_links.length(); j++)
370 if (
_links[j]->wire()->layerId() == i) {
382 if (space) _clusterType = 6;
393#ifdef TRKRECO_DEBUG_DETAIL
394 std::cout <<
" ... splitting : type=" <<
t << std::endl;
396 if (
t == 0)
return list;
404 if (_nDual > 2 && _duality > 0.7 && _angle > 0.7)
return splitDual();
407 else if (
t == 1)
return list;
408 else if (
t == 7)
return list;
411 else if (
t == 6)
return splitParallel();
415 else if (
t > 4)
return splitComplicated();
422TSegment::splitAV(
void)
const {
428 if (
t == 3) corners = & _outers;
429 else corners = & _inners;
431 for (
unsigned i = 0; i < corners->length(); i++)
432 corner += (* corners)[i]->wire()->xyPosition();
433 corner *= 1. / (float) corners->length();
434 seeds[0].append(* corners);
435 seeds[1].append(* corners);
439 if (
t == 3)
links = & _inners;
440 else links = & _outers;
444 for (
unsigned i = 0; i < 2; i++) {
445 edgePos[i] = edge[i]->wire()->xyPosition();
446 v[i] = (edgePos[i] - corner).
unit();
448 seeds[0].append(edge[0]);
449 seeds[1].append(edge[1]);
451#ifdef TRKRECO_DEBUG_DETAIL
452 std::cout <<
" corner:" << corner << std::endl;
453 std::cout <<
" edge:" << edgePos[0] <<
"(";
454 std::cout << edge[0]->wire()->layerId() <<
"-";
455 std::cout << edge[0]->wire()->localId() <<
")";
456 std::cout <<
v[0] << std::endl;
458 std::cout << edgePos[1] <<
"(";
459 std::cout << edge[1]->wire()->layerId() <<
"-";
460 std::cout << edge[1]->wire()->localId() <<
")";
461 std::cout <<
v[1] << std::endl;
466 for (
unsigned i = 0; i <
n; i++) {
468 if (edge.member(l))
continue;
469 if (corners->member(l))
continue;
472 double p2 = p.mag2();
475 for (
unsigned j = 0; j < 2; j++) {
476 dist[j] =
v[j].dot(p);
477 double d2 = dist[j] * dist[j];
478 dist[j] = (p2 - d2) > 0. ? sqrt(p2 - d2) : 0.;
480 if (dist[0] < dist[1]) seeds[0].append(l);
481 else seeds[1].append(l);
483#ifdef TRKRECO_DEBUG_DETAIL
484 std::cout <<
" p:" << p << std::endl;
486 std::cout << l->
wire()->
localId() <<
":" << dist[0];
487 std::cout <<
"," << dist[1] << std::endl;
492 for (
unsigned i = 0; i < 2; i++) {
496 if (ncx.length() == 0) {
510TSegment::splitComplicated(
void)
const {
516 for (
unsigned i = 0; i <
n; i++) {
523 goodHits.append(
_links[i]);
525 if (goodHits.length() == 0)
return newClusters;
530 while (goodHits.length()) {
533 TMLink * seed = goodHits.last();
535 unsigned localId = wire->
localId();
537 unsigned nn =
_links.length();
538 for (
unsigned i = 0; i < nn; i++) {
543 if (
abs((
int) w->
localId() - (
int) localId) < 2) used.append(
t);
546#ifdef TRKRECO_DEBUG_DETAIL
547 std::cout <<
" seed is " << seed->
wire()->
name() << std::endl;
549 for (
unsigned i = 0; i < used.length(); i++) {
550 std::cout << used[i]->wire()->name() <<
",";
552 std::cout << std::endl;
556 if (used.length() == 0)
continue;
557 if (used.length() ==
nLinks())
return newClusters;
560 if (cx.length() == 0) {
562 newClusters.append(c);
565 newClusters.append(cx);
568 goodHits.remove(used);
569 original.remove(used);
573 if ((original.length()) && (original.length() <
nLinks())) {
576 if (cx.length() == 0) {
578 newClusters.append(c);
581 newClusters.append(cx);
590TSegment::splitParallel(
void)
const {
593 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
597#ifdef TRKRECO_DEBUG_DETAIL
598 if (outerList.length() != 2) {
599 std::cout <<
"TSegment::splitParallel !!! ";
600 std::cout <<
"This is not a parallel cluster" << std::endl;
604 seeds[0].append(outerList[0]);
605 seeds[1].append(outerList[1]);
606 if (list.length() == 2)
continue;
608 const TMDCWire & wire0 = * outerList[0]->wire();
609 const TMDCWire & wire1 = * outerList[1]->wire();
610 for (
unsigned k = 0; k < list.length(); k++) {
612 if (
t == outerList[0])
continue;
613 if (
t == outerList[1])
continue;
627 newClusters.append(c0x);
632 newClusters.append(c0);
640 newClusters.append(c1x);
645 newClusters.append(
c1);
653TSegment::updateDuality(
void)
const {
657 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
659 if (i == _innerMostLayer) {
660 for (
unsigned j = 0; j < list.length(); j++)
661 x[0] += list[j]->hit()->xyPosition();
662 x[0] *= 1. / float(list.length());
664 else if (i == _outerMostLayer) {
665 for (
unsigned j = 0; j < list.length(); j++)
666 x[1] += list[j]->hit()->xyPosition();
667 x[1] *= 1. / float(list.length());
670 if (list.length() == 2) {
671 if (
Width(list) != 2)
continue;
681 if (_nDual > 0) _duality /= float(_nDual);
682 _angle = (
x[1] -
x[0]).
unit().dot(x[0].
unit());
686TSegment::splitDual(
void)
const {
687#ifdef TRKRECO_DEBUG_DETAIL
688 std::cout <<
" TSegment::splitDual called" << std::endl;
692 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
695 if (list.length() == 2) {
696 if (
Width(list) == 2) {
697 seeds[0].append(list[0]);
698 seeds[1].append(list[1]);
702 unknown.append(list);
705 if (unknown.length() > 0) {
706#ifdef TRKRECO_DEBUG_DETAIL
707 if (seeds[0].
length() == 0)
708 std::cout <<
"TSegment::splitDual !!! no TMLink for seed 0" << std::endl;
709 if (seeds[1].
length() == 0)
710 std::cout <<
"TSegment::splitDual !!! no TMLink for seed 1" << std::endl;
712 const HepPoint3D & p0 = seeds[0][0]->xyPosition();
713 const HepPoint3D & p1 = seeds[1][0]->xyPosition();
717 for (
unsigned i = 0; i < unknown.length(); i++) {
720 double d0 = (x0 - (x0.dot(v0) * v0)).mag();
722 double d1 = (x1 - (x1.dot(v0) * v0)).mag();
724 if (d0 < d1) seeds[0].append(
t);
725 else seeds[1].append(
t);
730 newClusters.append(
new TSegment(seeds[0]));
731 newClusters.append(
new TSegment(seeds[1]));
738 if (_clusterType == 0)
return 0;
739 if (_nDual == 0)
return 0;
744 if (_clusterType == 0)
return 0;
745 if (_nDual == 0)
return 0;
749 for (
unsigned i = _innerMostLayer; i <= _outerMostLayer; i++) {
752 if (list.length() == 1) {
753 seeds.append(list[0]);
755 else if (list.length() == 2) {
756 if (
Width(list) > 1) {
763 if (
distance > 0.5) duals.append(list);
764#ifdef TRKRECO_DEBUG_DETAIL
767 std::cout <<
" lyr=" << i;
768 std::cout <<
", duality distance = " <<
distance << std::endl;
772 else if (list.length() == 0) {
775#ifdef TRKRECO_DEBUG_DETAIL
777 std::cout <<
"TSegment::solveDualHits !!! this is not expected 2";
778 std::cout << std::endl;
779 this->
dump(
"cluster hits mc",
" ");
785 if (seeds.length() < 2)
return -1;
789 unsigned n = duals.length() / 2;
790 for (
unsigned i = 0; i <
n; i++) {
791 TMLink * t0 = duals[i * 2 + 0];
792 TMLink * t1 = duals[i * 2 + 1];
795 double d0 = (x0 - (x0.dot(
v) *
v)).mag();
796 double d1 = (x1 - (x1.dot(
v) *
v)).mag();
797 if (d0 < d1)
_links.remove(t1);
949 unsigned nList = list.length();
950 for (
unsigned i = 0; i < nList; i++) {
952 for (
unsigned j = 0; j < links.length(); j++) {
953 unsigned state = links[j]->hit()->state();
968 unsigned n = links.length();
969 for (
unsigned i = 0; i <
n; i++) {
970 if (trackLinks.hasMember(links[i]))
982 unsigned nLinks =
s->innerLinks().length();
983 if (nLinks != 1)
return n;
985 s =
s->innerLinks()[0];
995 unsigned nLinks =
s->innerLinks().length();
996 if (nLinks != 1)
return links;
1009 unsigned nLinks =
s->innerLinks().length();
1010 if (nLinks == 0)
return n;
1012 int tmp = 0, ii = 0;
1013 for (
int i = 0; i < nLinks; ++i) {
1014 if(
s->innerLinks()[i]->links().length() > tmp) {
1015 tmp =
s->innerLinks()[i]->links().length();
1019 s =
s->innerLinks()[ii];
1030 unsigned nLinks =
s->innerLinks().length();
1031 if (nLinks == 0)
return links;
1032 int tmp = 0, ii = 0;
1033 for (
int i = 0; i < nLinks; ++i) {
1034 if(
s->innerLinks()[i]->links().length() > tmp) {
1035 tmp =
s->innerLinks()[i]->links().length();
1052 unsigned nLinks =
s->innerLinks().length();
1053 if (nLinks == 0)
return n;
1054 if (nLinks > 1) ++
n;
1055 s =
s->innerLinks()[0];
1064 unsigned n = in.length();
1067 for (
unsigned i = 0; i <
n; i++) {
1070 else isolated.append(
s);
1077 unsigned n = list.length();
1078 for (
unsigned i = 0; i <
n; i++)
1079 sl |= (1 << (list[i]->superLayerId()));
1094 unsigned n = list.length();
1095 for (
unsigned i = 0; i <
n; i++)
1096 links.append(list[i]->links());
1102 unsigned maxWidth = 0;
1105 unsigned w =
Width(tmp);
1106 if (w > maxWidth) maxWidth = w;
1113TSegment::maxdDistance(
TMLink *l)
const{
1116 double _averR[11] = {9.7, 14.5, 22.14, 28.62, 35.1, 42.39, 48.87, 55.35, 61.83, 69.12, 74.79};
1117 double _averR2[43] = { 7.885, 9.07, 10.29, 11.525,
1118 12.72, 13.875, 15.01, 16.16,
1119 19.7, 21.3, 22.955, 24.555,
1120 26.215, 27.82, 29.465, 31.06,
1121 32.69, 34.265, 35.875, 37.455,
1122 39.975, 41.52, 43.12, 44.76,
1123 46.415, 48.02, 49.685, 51.37,
1124 53.035, 54.595, 56.215, 57.855,
1125 59.475, 60.995, 62.565, 64.165,
1126 66.68, 68.285, 69.915, 71.57,
1127 73.21, 74.76, 76.345};
1128 double radius = _averR2[lId];
1129 const double singleSigma = l->
dDrift();
1130 return 2 * singleSigma / (radius * radius);
1142 for (
unsigned i = 0; i <
_links.length(); ++i) {
1151 cout<<
"wrong in tsf, TSegment::splitTsf ...1"<<endl;
1155 seeds2.append(
links[3]);
1156 exTsf.append(
links[2]);
1161 seeds2.append(
links[3]);
1162 exTsf.append(
links[1]);
1163 exTsf.append(
links[2]);
1166 seeds2.append(
links[2]);
1167 exTsf.append(
links[1]);
1171 else cout<<
"wrong in tsf, TSegment::splitTsf ...2"<<endl;
1172 exTsf.append(seeds2);
1175 for (
unsigned i = 0; i < seeds2.length(); ++i) {
1176 if (seed->
tsfTag() > 0 && seeds2[i]->tsfTag() > 0)
continue;
1179 fitLine(seed, seeds2[i], line);
1180 segments = appendByLine(seed, seeds2[i], seedNeighbors, exTsf, line);
1181 list.append(segments);
1182 segments.removeAll();
1187 exTsf.append(
links[1]);
1188 exTsf.append(
links[2]);
1189 for (
int k = 0; k <
links[2].length(); ++k){
1190 if (
links[2][k]->tsfTag() == 0) seeds2.append(
links[2][k]);
1192 for (
unsigned i = 0; i < seeds2.length(); ++i) {
1193 if (seed->
tsfTag() > 0 && seeds2[i]->tsfTag() > 0)
continue;
1196 fitLine(seed, seeds2[i], line2);
1197 segments2 = appendByLine(seed, seeds2[i], seedNeighbors, exTsf, line2);
1198 list.append(segments2);
1199 segments2.removeAll();
1210 double ar = seed->
cDrift();
1213 double br = outer->
cDrift();
1215 double dis = sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
1216 double costheta = (bx - ax) / dis;
1217 double sintheta = (by - ay) / dis;
1218 double c1 = (ax * ax - bx * bx + ay * ay - by * by) / (2 * dis);
1219 double c2 = (ax * by - bx * ay) / dis;
1221 line[0].setX((br - ar) * costheta + sqrt(dis * dis - (ar - br) * (ar - br)) * sintheta);
1222 line[0].setY((br - ar) * sintheta - sqrt(dis * dis - (ar - br) * (ar - br)) * costheta);
1223 line[0].setZ((br - ar) *
c1 - sqrt(dis * dis - (ar - br) * (ar - br)) * c2 + 0.5 * dis * (ar + br));
1224 line[1].setX((br - ar) * costheta - sqrt(dis * dis - (ar - br) * (ar - br)) * sintheta);
1225 line[1].setY((br - ar) * sintheta + sqrt(dis * dis - (ar - br) * (ar - br)) * costheta);
1226 line[1].setZ((br - ar) *
c1 + sqrt(dis * dis - (ar - br) * (ar - br)) * c2 + 0.5 * dis * (ar + br));
1227 line[2].setX((br + ar) * costheta + sqrt(dis * dis - (ar + br) * (ar + br)) * sintheta);
1228 line[2].setY((br + ar) * sintheta - sqrt(dis * dis - (ar + br) * (ar + br)) * costheta);
1229 line[2].setZ((br + ar) *
c1 - sqrt(dis * dis - (ar + br) * (ar + br)) * c2 + 0.5 * dis * (br - ar));
1230 line[3].setX((br + ar) * costheta - sqrt(dis * dis - (ar + br) * (ar + br)) * sintheta);
1231 line[3].setY((br + ar) * sintheta + sqrt(dis * dis - (ar + br) * (ar + br)) * costheta);
1232 line[3].setZ((br + ar) *
c1 + sqrt(dis * dis - (ar + br) * (ar + br)) * c2 + 0.5 * dis * (br - ar));
1252 for (
int i = 0; i < 4; ++i) {
1254 for (
int j = 0, size = restHits.length(); j < size; ++j) {
1255 TMLink * l = restHits[j];
1258 double maxdis = maxdDistance(l) * _times[slId];
1259 double dis = distance2(l, line[i]);
1261 if(seeds.hasMember(l))
continue;
1262 if (fabs(dis - l->
cDrift()) < maxdis) seeds.append(l);
1266 seeds.append(outer);
1267 unsigned nHitsLayer[4] = {0, 0, 0, 0};
1268 unsigned nLayers = 0;
1270 for (
int j = 0; j < seeds.length(); ++j)
1272 for (
int j = 0; j < 4; ++j)
1273 if (nHitsLayer[j] > 0) ++nLayers;
1274 if (nLayers < 3)
continue;
1277 for (
int k = 0; k < seedNeighbors.length(); ++k) {
1278 TMLink * l =seedNeighbors[k];
1280 double maxdis = maxdDistance(l) * _times[slId];
1281 double dis = distance2(l, line[i]);
1283 if(seeds.hasMember(l))
continue;
1284 if (fabs(dis - l->
cDrift()) < maxdis) seeds.append(l);
1289 for (
int k = 0; k < seeds.length(); ++k) {
1290 unsigned a = seeds[k]->tsfTag();
1292 seeds[k]->tsfTag(a);
1347 double a = line.x();
1348 double b = line.y();
1349 double c = line.z();
1350 return fabs(a * x + b * y + c) / sqrt(a * a + b * b);
1357 for(
int i = 0; i <
links.length(); ++i){
1359 double d =
links[i]->cDrift();
1360 HepPoint3D posOnLine = closestPoint(p, _lineTsf);
1366 sumPos *= (1. / double(
n));
1367 HepPoint3D posTsf = closestPoint(sumPos, line);
1374 line0.setX(tsfLine.x()/sqrt(tsfLine.x()*tsfLine.x()+tsfLine.y()*tsfLine.y()));
1375 line0.setY(tsfLine.y()/sqrt(tsfLine.x()*tsfLine.x()+tsfLine.y()*tsfLine.y()));
1376 line0.setZ(tsfLine.z()/sqrt(tsfLine.x()*tsfLine.x()+tsfLine.y()*tsfLine.y()));
1379 unsigned n =
links.length();
1380 unsigned nTrial = 0;
1382 if (nTrial > 10)
break;
1383 double a = 0., b = 0.;
1384 double sumXSig = 0., sumYSig = 0., sumX2Sig = 0., sumXYSig = 0., sumSig = 0.;
1385 for (
unsigned i = 0; i <
n; i++) {
1387 double d =
links[i]->cDrift();
1388 HepPoint3D posOnLine = closestPoint(p, _lineTsf);
1391 double Sig = maxdDistance(
links[i]);
1397 sumX2Sig += X * X * Sig;
1398 sumXYSig += X * Y * Sig;
1402 b = (sumXYSig * sumSig - sumXSig * sumYSig) / (sumX2Sig * sumSig - sumXSig * sumXSig);
1403 a = (sumYSig - sumXSig * b) / sumSig;
1405 line.set(b/sqrt(1+b*b), -1/sqrt(1+b*b), a/sqrt(1+b*b));
1409 for (
unsigned i = 0; i <
n; i++) {
1411 double d =
links[i]->cDrift();
1412 double Sig = maxdDistance(
links[i]);
1414 double dis = fabs(p.x()*line.x()+p.y()*line.y()+line.z()) - d;
1415 chi2 += dis * dis * Sig;
1418 cout<<
"n = "<<
n<<
" nTrial = "<<nTrial<<
" line0 = "<<line0<<endl;
1419 cout<<
"chi2 in TSF = "<<chi2<<endl;
1422 if (fabs(line.x()-line0.x()) < 0.0001)
break;
1433 line0.setX(tsfLine.x()/sqrt(tsfLine.x()*tsfLine.x()+tsfLine.y()*tsfLine.y()));
1434 line0.setY(tsfLine.y()/sqrt(tsfLine.x()*tsfLine.x()+tsfLine.y()*tsfLine.y()));
1435 line0.setZ(tsfLine.z()/sqrt(tsfLine.x()*tsfLine.x()+tsfLine.y()*tsfLine.y()));
1443 if (nTrial>15)
break;
1444 double a0 = line0.x();
1445 double b0 = line0.y();
1446 double c0 = line0.z();
1450 cout<<
"b0 == 0 TSegment::leastSquaresFitting!"<<endl;
1454 double a = 0., b = 0., c = 0.;
1455 double sumSigX2 = 0., sumSigX = 0., sumSig = 0.;
1456 for (
int i = 0; i <
n; ++i) {
1460 double Sig = maxdDistance(
links[i]);
1462 sumSigX2 += Sig*(X-Y*a0/b0)*(X-Y*a0/b0);
1463 sumSigX += Sig*(X-Y*a0/b0);
1466 double detM = sumSigX2*sumSig - sumSigX*sumSigX;
1467 double M11 = sumSig/detM;
1468 double M12 = -sumSigX/detM;
1470 double M22 = sumSigX2/detM;
1471 for (
int i = 0; i <
n; ++i) {
1475 double DRIFT =
links[i]->cDrift();
1476 if (a0*p.x() + b0*p.y() + c0*p.z() < 0) DRIFT = (-1) * DRIFT;
1477 double Sig = maxdDistance(
links[i]);
1479 double D = DRIFT-Y/b0;
1480 a += ((X-Y*a0/b0)*M11+M12)*Sig*D;
1481 c += ((X-Y*a0/b0)*M21+M22)*Sig*D;
1486 line.setX(a/sqrt(a*a+b*b));
1487 line.setY(b/sqrt(a*a+b*b));
1488 line.setZ(c/sqrt(a*a+b*b));
1494 for (
int i = 0; i<
n; ++i){
1496 double dis = fabs(a*p.x()+b*p.y()+c);
1497 double DRIFT =
links[i]->cDrift();
1498 double Sig = maxdDistance(
links[i]);
1501 chi2 += (dis - DRIFT)*(dis - DRIFT)*Sig;
1506 if(fabs(a-a0)<0.00001)
break;
1527 for (
int i = 0; i <
links.length(); ++i) {
1529 if(segLinks.hasMember(l))
continue;
1531 double maxdis = maxdDistance(l) * (_times[slId]);
1532 double dis = distance2(l, line);
1533 if (fabs(dis - l->
cDrift()) < maxdis) {
1535 unsigned a = l->
tsfTag();
1545TSegment::expandSeg(
const int empty,
AList<TMLink> & allLinks) {
1546 if(empty>=4 || empty<0)
return;
1548 for (
int i = 0; i < allLinks.length(); ++i)
1549 if (allLinks[i]->wire()->localLayerId() == empty) linksOnEmptyLayer.append(allLinks[i]);
1551 if (linksOnEmptyLayer.length()==0)
return;
1554 float maxPhi[4] = {0.,0.,0.,0.};
1555 float minPhi[4] = {999.,999.,999.,999.};
1556 float max = 0., min = 999.;
1557 for (
int i = 0; i <
_links.length(); ++i) {
1564 float phi = phi0 + local*2*
pi/nWir;
1566 if (phi > maxPhi[loId]) maxPhi[loId] = phi;
1567 if (phi < minPhi[loId]) minPhi[loId] = phi;
1568 if (phi > max) max = phi;
1569 if (phi < min) min = phi;
1573 for (
int i = 0; i < linksOnEmptyLayer.length(); ++i) {
1574 TMLink *l = linksOnEmptyLayer[i];
1579 float phi = phi0 + local*2*
pi/nWir;
1581 if (empty != 0 || empty != 3) {
1582 if (phi <= maxPhi[empty + 1] && phi >= minPhi[empty - 1]) tmpList.append(l);
1583 else if (phi <= maxPhi[empty - 1] && phi >= minPhi[empty + 1]) tmpList.append(l);
1584 else if (tmpList.length() == 0 && phi <= max && phi >= min) tmpList.append(l);
1586 if (empty == 0 || empty == 3) {
1587 if (phi <= maxPhi[1] && phi >= minPhi[2]) tmpList.append(l);
1588 else if (phi <= maxPhi[2] && phi >= minPhi[1]) tmpList.append(l);
1589 else if (tmpList.length() == 0 && phi <= max && phi >= min) tmpList.append(l);
1593 for(
int i = 0; i < tmpList.length(); ++i) {
1596 unsigned a = l->
tsfTag();
1611 for (
int i = 0; i <
n; ++i) {
1614 unsigned newState = l->
hit()->
state()&(~WireHitPatternRight);
1618 unsigned newState = l->
hit()->
state()&(~WireHitPatternLeft);
1628 for (
int i = 0; i <
n; ++i) {
1633 double cosA = (p -
center).
unit().dot(v1.unit());
1634 double cosB = (p -
center).
unit().dot(v2.unit());
1646 HepPoint3D PointOnLine(1, -(line.x()+line.z())/line.y(), 0);
1647 double dis = (p - PointOnLine).dot(Dir);
1648 HepPoint3D tmp(dis*Dir.x(), dis*Dir.y(), 0.);
1651 double disPLine = fabs(p.x()*line.x()+p.y()*line.y()+line.z())/sqrt(line.x()*line.x()+line.y()*line.y());
1652 double disP1P2 = sqrt((p.x()-closestPoint.x())*(p.x()-closestPoint.x())+(p.y()-closestPoint.y())*(p.y()-closestPoint.y()));
1653 if (fabs(disPLine-disP1P2)>0.00001) cout<<
"TSegment::closestPoint: dis p -> line = "<<disPLine<<
" dis p -> pos = "<<disP1P2<<endl;
1654 return closestPoint;
1661 for (
unsigned i = 0; i <
n; i++) {
1668 for (
unsigned j = 0; j < 6; j++) neighbor[j] = w->
neighbor(j);
1671 unsigned pattern = 0;
1672 for (
unsigned j = 0; j < 6; j++) {
1674 if (neighbor[j]->hit())
1675 pattern += (1 << j);
1680 if ((pattern == 34) || (pattern == 42) ||
1681 (pattern == 40) || (pattern == 10) ||
1682 (pattern == 35) || (pattern == 50))
1684 else if ((pattern == 17) || (pattern == 21) ||
1685 (pattern == 20) || (pattern == 5) ||
1686 (pattern == 19) || (pattern == 49))
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
#define WireHitNeighborHit
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 NMajorLinks(const TSegment &a)
returns # of links in the major link.
unsigned NUniqueLinks(const TSegment &a)
checks property of segments.
TSegment * OuterMostUniqueLink(const TSegment &a)
returns a segment to the outer-most unique segment.
unsigned NLinkBranches(const TSegment &a)
returns # of link branches in the major link.
unsigned NCoreLinks(const CAList< TSegment > &list)
returns # of core links in segments.
AList< TSegment > UniqueLinks(const TSegment &a)
returns a list of unique segments in links.
AList< TSegment > MajorLinks(const TSegment &a)
returns a list of segments in major links.
AList< TMLink > Links(const TSegment &s, const TTrack &t)
returns AList of TMLink used for a track.
unsigned SuperLayer(const AList< TSegment > &list)
returns super layer pattern.
void SeparateCrowded(const AList< TSegment > &in, AList< TSegment > &isolated, AList< TSegment > &crowded)
returns isolated and crowded list.
unsigned NMajorLinks(const TSegment &a)
returns # of links in the major link.
unsigned NUniqueLinks(const TSegment &a)
checks property of segments.
unsigned NLinkBranches(const TSegment &a)
returns # of link branches in the major link.
to specify 1-dim region or range by two floats
float offset(void) const
returns offset.
unsigned nWires(void) const
returns # of wires.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
unsigned state(void) const
returns state.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
const HepPoint3D & xyPosition(void) const
returns drift time
A class to represent a wire in MDC.
unsigned id(void) const
returns id.
unsigned localLayerId(void) const
returns local layer id in a super layer.
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.
unsigned superLayerId(void) const
returns super layer id.
const TMDCWire *const neighbor(unsigned) const
returns a pointer to a neighbor wire.
int localIdDifference(const TMDCWire &) const
returns local id difference.
std::string name(void) const
returns name.
static TMDC * getTMDC(void)
const TMDCLayer *const layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
unsigned tsfTag(void) const
return tsfTag of links
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
const HepPoint3D & positionD(void) const
float dDrift(void) const
returns/sets drift distance error.
double cDrift(void) const
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.
const TMLink & center(void) const
returns a TMLink which is the closest to the center.
const AList< TMLink > & outers(void) const
void solveThreeHits(void)
Range rangeX(double min, double max) const
returns Range of x-coordinate of TMLinks.
virtual ~TSegment()
Destructor.
AList< TSegment > split(void) const
returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no cluster is returne...
AList< TSegment > splitTsf(AList< TMLink > &)
unsigned state(void) const
unsigned innerMostLayer(void) const
returns inner most layer.
unsigned clusterType(void) const
returns cluster type. 0:empty, 1:short line, 2:long line, 3:V shage(from outside),...
void solveLR(void)
solve LR of hit in TSF.
AList< TSegment > & outerLinks(void)
const HepPoint3D & position(void) const
returns position.
unsigned width(void) const
returns width.
double distance(const TSegment &) const
calculates distance between two clusters. Smaller value indicates closer.
unsigned outerMostLayer(void) const
returns outer most layer.
const HepPoint3D & lineTsf(void) const
return line of Tsf for pos and dir
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.