68 for (
int j = 0; j < size; j++) {
69 if (array[j+idx] && (!ca || ca[j]) && isvoid[j] !=
true)
86 for (
int i = 0; i < size; i++) {
88 for (
int j = i+1; j < size; j++) {
89 if (array[j+i*size] && isvoid[j] ==
false )
107 int besti = idx, bestj = -1;
108 double bestchi = chia[idx], bestdchi;
110 for (
int j = idx+1; j < size; j++) {
113 if (chia[j] < bestchi) {
122 for (
int i = idx; i < size; i++) {
125 for (
int j = i+1; j < size; j++) {
130 if (chia[j] + chia[i] < bestdchi) {
133 bestdchi = chia[j]+chia[i];
138 for (
int i = idx; i < size; i++) {
141 if (i == besti || i == bestj || besti == -1) {
144 else if (isvoid[i] ==
false) {
145 if ( (besti >= 0 && array[i*size+besti] ) ||
146 (bestj >= 0 && array[i*size+bestj] ) ) {
168 for(i = 0; i < size; i++ ) {
169 if( isvoid[i] !=
true ) {
190 double bestchi = 1e8, oworst = 0.0;
193 for (
int i = idx; i < size; i++) {
197 if (isvoid[i] !=
true) {
211 if (besti >= 0 && (3.0 > bestchi || oworst + 3.0 > bestchi)) {
212 isvoid[besti] =
good;
227 std::map<EQwDirectionID,QwTreeLine*> tl1map, tl2map;
228 for (
size_t i = 0; i < tl1.size(); i++)
229 tl1map[tl1[i]->GetDirection()] = tl1[i];
230 for (
size_t i = 0; i < tl2.size(); i++)
231 tl2map[tl2[i]->GetDirection()] = tl2[i];
237 if (tl1map.count(dir) == 0)
continue;
238 if (tl2map.count(dir) == 0)
continue;
272 if (hits1[i1]->GetElement() == hits2[i2]->GetElement()) {
273 if (hits1[i1]->IsUsed() && hits2[i2]->IsUsed())
279 else if (hits1[i1]->GetElement() > hits2[i2]->GetElement()) {
283 else if (hits1[i1]->GetElement() < hits2[i2]->GetElement()) {
297 return (10000 * common / total + 50 ) / 100;
327 int total1 = 0, total2 = 0;
330 int i1 = -1, i2 = -1;
338 if (hits1[i1]->IsUsed()) {
349 if (hits2[i2]->IsUsed()) {
372 if (hits1[i1]->GetElement() == hits2[i2]->GetElement())
382 int total = total1 > total2 ? total2 : total1;
384 if (total == 0)
return 0;
387 return (10000 * common / total + 50 ) / 100;
402 double maxchi = 35000.0;
411 int nTooManyTreeLines = 0;
413 double local_maxchi = 0.0;
414 double local_minchi = maxchi;
422 treeline; treeline = treeline->
next) {
425 if (iteration > 100 ) {
428 cout <<
"... void because too many treelines already." << endl;
434 }
else if (treeline->IsValid()) {
436 double chi = treeline->GetChiWeight();
442 cout <<
"... void because chi^2 = " << chi <<
" above " << maxchi << endl;
449 if (chi > local_maxchi) {
452 if (chi < local_minchi) {
461 maxchi = local_minchi + (local_maxchi - local_minchi) * 0.66;
463 }
while (index > 30 );
465 int nTreeLines = index;
468 if (nTooManyTreeLines != 0) {
469 if (
fDebug) std::cout <<
"Skipping event, too many treelines." << std::endl;
472 if (nTreeLines == 0) {
473 if (
fDebug) std::cout <<
"Skipping event, no good treelines." << std::endl;
476 if (
fDebug) cout <<
"Number of treelines with good chi: " << nTreeLines << endl;
482 char* connarr = (
char*) malloc (nTreeLines);
483 int* isvoid = (
int*) malloc (nTreeLines *
sizeof(
int));
484 double* chi = (
double*) malloc (nTreeLines *
sizeof(
double));
485 int* array = (
int*) malloc (nTreeLines * nTreeLines *
sizeof(
int));
491 treeline; treeline = treeline->
next) {
492 if (treeline->IsValid()) {
493 tlarr[index] = treeline;
494 isvoid[index] = treeline->
IsVoid();
495 chi[index] = treeline->GetChiWeight();
513 for (
int i = 0; i < nTreeLines; i++) {
514 array[i * nTreeLines + i] =
false;
515 for (
int j = i+1; j < nTreeLines; j++) {
517 array[i * nTreeLines + j] = array[j * nTreeLines + i] = (common > 25);
521 for (
int i = 0; i < nTreeLines; i++) {
522 array[i * nTreeLines + i] =
false;
523 for (
int j = i+1; j < nTreeLines; j++) {
525 array[i * nTreeLines + j] = array[j * nTreeLines + i] = (common > 100);
533 for (
int i = 0; i < nTreeLines; ) {
534 if (isvoid[i] ==
false ) {
535 int bestconn =
connectiv (0, array, isvoid, nTreeLines, i);
537 if (
connectarray (connarr, array, isvoid, nTreeLines, i))
continue;
545 for (
int i = 0; i < nTreeLines; i++) {
546 if (isvoid[i] ==
true) {
547 if (
connectiv (0, array, isvoid, nTreeLines, i)) {
553 for (
int i = 0; i < nTreeLines; i++) {
554 if (isvoid[i] !=
true) {
559 cout <<
"... void for some reason." << endl;
583 double *chia, chi, maxch = 2000.0, nmaxch, nminch;
595 for (
size_t pt = 0; pt < parttracklist.size(); pt++) {
596 parttrack = parttracklist[pt];
597 if (parttrack->
fIsVoid ==
false ) {
602 cout <<
"... void because chi^2 too high" << endl;
616 maxch = nminch + (nmaxch - nminch) * 0.66;
617 }
while (idx > 30 && rep < 10);
626 connarr = (
char *)malloc( num );
627 isvoid = (
int *)malloc( num *
sizeof(
int));
628 chia = (
double *)malloc( num *
sizeof(
double));
629 array = (
int*) malloc(num * num *
sizeof(
int));
632 if (! ptarr || ! array) {
633 fprintf(stderr,
"Cannot Allocate Sort Array for %d PartialTracks\n",num);
641 for (
size_t pt = 0, idx = 0; pt < parttracklist.size(); pt++) {
642 parttrack = parttracklist[pt];
643 if (parttrack->
fIsVoid ==
false) {
644 ptarr[idx] = parttrack;
645 isvoid[idx] = parttrack->
fIsVoid;
655 for (
int i = 0; i < num; i++) {
656 array[i * num + i] =
false;
657 for (
int j = i+1; j < num; j++) {
658 array[i * num + j] = array[j * num + i] =
667 for (
int i = 0; i < num; ) {
668 if (isvoid[i] ==
false) {
669 int bestconn =
connectiv( 0, array, isvoid, num, i);
682 for (
int i = 0; i < num; i++) {
683 if (isvoid[i] !=
true) {
int rcCommonWires(const QwTreeLine *line1, const QwTreeLine *line2)
Counts the number of common wires shared between two tree lines.
int connectarray(char *ca, int *array, int *isvoid, char size, int idx)
const std::vector< QwHit * > & GetListOfHits() const
Get the list of hits.
Int_t GetNumberOfHits() const
Get the number of hits.
int connectiv(char *ca, int *array, int *isvoid, char size, int idx)
int rcTreeConnSort(QwTreeLine *head, EQwRegionID region)
The best (by chi^2) treelines are select.
void SetVoid(const bool isvoid=true)
void bestunconnected(char *ca, int *array, int *isvoid, double *chia, int size, int idx)
void SetValid(const bool isvoid=false)
virtual ~QwTrackingTreeSort()
int rcPartConnSort(std::vector< QwPartialTrack * > head)
Bool_t fIsVoid
marked as being void
bool IsVoid() const
Is this tree line void?
One-dimensional (u, v, or x) track stubs and associated hits.
int rcPTCommonWires(const QwPartialTrack *track1, const QwPartialTrack *track2)
const QwDetectorInfo * GetDetectorInfo() const
Get the detector info pointer.
int bestconnected(char *ca, int *array, int *isvoid, double *chia, int size, int idx)
QwHit * fHits[2 *MAX_LAYERS]
Hit structure uniquely defining each hit.
double GetChiWeight() const
int globalconnectiv(char *ca, int *array, int *isvoid, int size, int idx)
Contains the straight part of a track in one region only.
int rcCommonWires_r3(const QwTreeLine *line1, const QwTreeLine *line2)
const std::vector< QwTreeLine * > & GetListOfTreeLines() const
Get the list of tree lines.
static const double c
Physical constants.