18#include "CLHEP/Alist/ConstAList.h"
23 if (_hit)
return _hit->
wire();
81 _drift[0] = h->
drift(0);
82 _drift[1] = h->
drift(1);
95 for (
unsigned i = 0; i < 6; ++i)
97 for (
unsigned i = 0; i < 4; ++i)
109 _onTrack(l._onTrack),
111 _position(l._position),
112 _positionD(l._positionD),
114 _leftRight(l._leftRight),
117 _distance(l._distance),
124 _drift[0] = l._drift[0];
125 _drift[1] = l._drift[1];
126 _dDrift[0] = l._dDrift[0];
127 _dDrift[1] = l._dDrift[1];
128 _cDrift[0] = l._cDrift[0];
129 _cDrift[1] = l._cDrift[1];
130 for (
unsigned i = 0; i < 6; ++i)
131 _neighbor[i] = l._neighbor[i];
132 for (
unsigned i = 0; i < 4; ++i)
133 _arcZ[i] = l._arcZ[i];
143 if (_track) std::cout <<
"track#=,";
153 unsigned n = list.length();
154 for (
unsigned i = 0; i <
n; i++) {
155 unsigned id = list[i]->wire()->layerId();
156 if (
id < 32) l0 |= (1 << id);
157 else l1 |= (1 << (
id - 32));
161 for (
unsigned i = 0; i < 32; i++) {
162 if (l0 & (1 << i)) ++l;
163 if (l1 & (1 << i)) ++l;
170 for (
unsigned i = 0; i < 43; i++) nHits[i] = 0;
171 unsigned nLinks = links.length();
172 for (
unsigned i = 0; i < nLinks; i++)
173 ++nHits[links[i]->wire()->layerId()];
178 for (
unsigned i = 0; i < 11; i++) nHits[i] = 0;
179 unsigned nLinks = links.length();
180 for (
unsigned i = 0; i < nLinks; i++)
181 ++nHits[links[i]->wire()->superLayerId()];
186 bool mc = (msg.find(
"mc") != std::string::npos);
187 bool pull = (msg.find(
"pull") != std::string::npos);
188 bool flag = (msg.find(
"flag") != std::string::npos);
189 bool sort = (msg.find(
"sort") != std::string::npos);
190 bool stereo = (msg.find(
"stereo") != std::string::npos);
191 bool detail = (msg.find(
"detail") != std::string::npos);
192 bool pos = (msg.find(
"position") != std::string::npos);
194 mc = pull =
flag = sort =
true;
199 unsigned n = tmp.length();
200 unsigned nForFit = 0;
204 for (
unsigned i = 0; i <
MCC_MAX; i++) {
208 bool MCCOverFlow =
false;
211 for (
unsigned i = 0; i <
n; i++) {
212 const TMLink & l = * tmp[i];
222 std::cout <<
"[" << a <<
"]";
225 std::cout <<
"(" << mcId <<
")";
252 std::cout <<
",pos=" << l.
position();
256 std::cout <<
" " <<
n <<
" l(s)";
257 if (
flag) std::cout <<
", fv " << nForFit <<
" l(s)";
261 for (
unsigned i = 0; i <
MCC_MAX; i++) {
264 std::cout << i <<
":" << MCC0[i] <<
",";
267 std::cout <<
" total " << nMC <<
" contributions";
270 std::cout <<
", fv mc";
271 for (
unsigned i = 0; i <
MCC_MAX; i++) {
274 std::cout << i <<
":" << MCC1[i] <<
",";
277 std::cout <<
" total " << nMC <<
" contributions";
281 std::cout <<
"(counter overflow)";
283 std::cout << std::endl;
287Dump(
const TMLink & link,
const std::string & msg,
const std::string & pre) {
295 unsigned nLinks = links.length();
297 for (
unsigned i = 0; i < nLinks; i++)
298 if (links[i]->wire()->stereo())
305 unsigned nLinks = links.length();
307 for (
unsigned i = 0; i < nLinks; i++)
308 if (links[i]->wire()->axial())
316 unsigned n = links.length();
317 for (
unsigned i = 0; i <
n; i++) {
318 if (links[i]->wire()->axial())
327 unsigned n = links.length();
328 for (
unsigned i = 0; i <
n; i++) {
329 if (! links[i]->wire()->axial())
337 unsigned n = a.length();
338 unsigned minId = 9999;
340 for (
unsigned i = 0; i <
n; i++) {
341 unsigned id = a[i]->wire()->id();
352 unsigned n = a.length();
355 for (
unsigned i = 0; i <
n; i++) {
356 unsigned id = a[i]->wire()->id();
369 unsigned n = input.length();
370 for (
unsigned i = 0; i <
n; i++) {
383 unsigned n = input.length();
384 for (
unsigned i = 0; i <
n; i++) {
396 if ((* a)->wire()->id() > (* b)->wire()->id())
return 1;
398 ((* a)->wire()->id() == (* b)->wire()->id())
return 0;
404 if ((* a)->position().x() > (* b)->position().x())
return 1;
405 else if ((* a)->position().x() == (* b)->position().x())
return 0;
414 if ((* a)->wire()->id() > (* b)->wire()->id())
return 1;
416 ((* a)->wire()->id() == (* b)->wire()->id())
return 0;
424 if ((* a)->position().x() > (* b)->position().x())
return 1;
425 else if ((* a)->position().x() == (* b)->position().x())
return 0;
433 unsigned n = list.length();
437 unsigned nWires =
w->layer()->nWires();
438 unsigned center =
w->localId();
440#ifdef TRKRECO_DEBUG_DETAIL
441 unsigned sId =
w->superLayerId();
446 for (
unsigned i = 1; i <
n; i++) {
448 unsigned id =
w->localId();
450 unsigned distance0, distance1;
452 distance0 =
id - center;
453 distance1 = nWires - distance0;
456 distance1 = center - id;
457 distance0 = nWires - distance1;
460 if (distance0 < distance1) {
461 if (distance0 > right) right = distance0;
464 if (distance1 > left) left = distance1;
467#ifdef TRKRECO_DEBUG_DETAIL
468 if (
w->superLayerId() != sId)
469 std::cout <<
"::width !!! super layer assumption violation" << std::endl;
473 return right + left + 1;
480 unsigned n = list.length();
482 else if (
n == 2)
return list;
485 unsigned nWires =
w->layer()->nWires();
486 unsigned center =
w->localId();
491 TMLink * rightL = list[0];
492 for (
unsigned i = 1; i <
n; i++) {
494 unsigned id =
w->localId();
496 unsigned distance0, distance1;
498 distance0 =
id - center;
499 distance1 = nWires - distance0;
502 distance1 = center - id;
503 distance0 = nWires - distance1;
506 if (distance0 < distance1) {
507 if (distance0 > right) {
513 if (distance1 > left) {
529 unsigned n = list.length();
530 for (
unsigned i = 0; i <
n; i++) {
531 if (list[i]->wire()->layerId() ==
id) same.append(list[i]);
540 unsigned n = list.length();
541 for (
unsigned i = 0; i <
n; i++) {
542 if (list[i]->wire()->superLayerId() ==
id) same.append(list[i]);
550 unsigned n = list.length();
551 for (
unsigned i = 0; i <
n; i++) {
552 if (list[i]->wire()->layerId() ==
id) same.append(list[i]);
560 unsigned n = list.length();
561 for (
unsigned i = 0; i <
n; i++) {
562 if (list[i]->wire()->superLayerId() ==
id) same.append(list[i]);
571 unsigned n = list.length();
572 unsigned innerMostLayer = 999;
573 unsigned outerMostLayer = 0;
574 for (
unsigned i = 0; i <
n; i++) {
575 unsigned id = list[i]->wire()->layerId();
576 if (
id < innerMostLayer) innerMostLayer = id;
577 else if (
id > outerMostLayer) outerMostLayer = id;
579 for (
unsigned i = 0; i <
n; i++) {
580 unsigned id = list[i]->wire()->layerId();
581 if (
id == innerMostLayer) inners.append(list[i]);
582 else if (
id == outerMostLayer) outers.append(list[i]);
584 inners.append(outers);
591 unsigned n = list.length();
592 for (
unsigned i = 0; i <
n; i++)
593 sl |= (1 << (list[i]->wire()->superLayerId()));
599 unsigned n = links.length();
600 unsigned nHits[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
601 for (
unsigned i = 0; i <
n; i++)
602 ++nHits[links[i]->wire()->superLayerId()];
604 for (
unsigned i = 0; i < 11; i++)
605 if (nHits[i] >= minN)
613 unsigned n = list.length();
614 for (
unsigned i = 0; i <
n; i++) {
615 unsigned id = list[i]->wire()->superLayerId();
620 for (
unsigned i = 0; i < 11; i++) {
621 if (l0 & (1 << i)) ++l;
628 unsigned n = links.length();
629 unsigned nHits[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
630 for (
unsigned i = 0; i <
n; i++)
631 ++nHits[links[i]->wire()->superLayerId()];
633 for (
unsigned i = 0; i < 11; i++)
634 if (nHits[i] >= minN)
641 unsigned n = links.length();
643 unsigned nHits[5] = {0, 0, 0, 0, 0};
644 for (
unsigned i = 0; i <
n; i++)
645 if (links[i]->wire()->axial())
646 ++nHits[links[i]->wire()->axialStereoLayerId() / 4];
648 while (nHits[j] == 0) ++j;
649 unsigned nMissing = 0;
651 for (
unsigned i = j; i < 5; i++) {
652 if (nHits[i] == 0) ++nMissing;
654 if (nMax < nMissing) nMax = nMissing;
665 unsigned nHep = list.length();
667 if (! nHep)
return * best;
669 unsigned * N = (
unsigned *) malloc(nHep *
sizeof(
unsigned));
670 for (
unsigned i = 0; i < nHep; i++) N[i] = 0;
672 for (
unsigned i = 0; i < links.length(); i++) {
673 const TMLink & l = * links[i];
675 for (
unsigned j = 0; j < nHep; j++)
676 if (list[j] == & hep)
681 for (
unsigned i = 0; i < nHep; i++) {
#define WireHitFindingValid
#define WireHitFittingValid
#define WireHitInvalidForFit
AList< TMLink > StereoHits(const AList< TMLink > &links)
returns stereo hits.
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 > SameSuperLayer(const AList< TMLink > &list, const TMLink &a)
returns links which are in the same super layer as 'a' or 'id'.
unsigned NAxialHits(const AList< TMLink > &links)
returns # of axial hits.
int SortByX(const void *av, const void *bv)
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.
unsigned SuperLayer(const AList< TMLink > &list)
returns super layer pattern.
const TTrackHEP & Links2HEP(const AList< TMLink > &links)
returns TTrackHEP
TMLink * OuterMost(const AList< TMLink > &a)
int SortByWireId(const void *av, const void *bv)
Sorter.
AList< TMLink > AxialHits(const AList< TMLink > &links)
returns axial hits.
TMLink * InnerMost(const AList< TMLink > &a)
returns the inner(outer)-most link.
void NHitsSuperLayer(const AList< TMLink > &links, unsigned nHits[11])
returns # of hits per super layer.
unsigned NSuperLayers(const AList< TMLink > &list)
returns # of layers.
AList< TMLink > Cores(const AList< TMLink > &input)
unsigned NLayers(const AList< TMLink > &list)
returns # of layers.
unsigned NStereoHits(const AList< TMLink > &links)
returns # of stereo hits.
AList< TMLink > SameLayer(const AList< TMLink > &list, const TMLink &a)
returns links which are in the same layer as 'a' or 'id'.
unsigned NMissingAxialSuperLayers(const AList< TMLink > &links)
void NHits(const AList< TMLink > &links, unsigned nHits[43])
void Dump(const CAList< TMLink > &links, const std::string &msg, const std::string &pre)
dumps TMLinks.
void SeparateCores(const AList< TMLink > &input, AList< TMLink > &cores, AList< TMLink > &nonCores)
separate cores and non-cores.
const TTrackHEP *const hep(void) const
returns a pointer to a GEN_HEPEVT.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
unsigned state(void) const
returns state.
float dDrift(unsigned) const
returns drift distance error.
float drift(unsigned) const
returns drift distance.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
const HepPoint3D & xyPosition(void) const
returns drift time
const TMDCWireHitMC *const mc(void) const
returns a pointer to TMDCWireHitMC.
A class to represent a wire in MDC.
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.
std::string name(void) const
returns name.
A class to relate TMDCWireHit and TTrack objects.
virtual ~TMLink()
Destructor.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
int zStatus(void) const
returns stauts of stereo hit
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
double pull(void) const
returns pull.
const HepPoint3D & position(void) const
returns position.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
TMLink(TTrack *track=0, const TMDCWireHit *hit=0, const HepPoint3D &position=HepPoint3D(), const HepPoint3D &positionD=HepPoint3D(), const double=0.0)
Constructor.
A class to represent a GEN_HEPEVT particle in tracking.
unsigned id(void) const
returns an id started from 0.
static const AList< TTrackHEP > & list(void)
returns a list of TTrackHEP's.
A class to represent a track in tracking.