22#include "MdcxReco/MdcxMergeDups.h"
23#include "MdcxReco/MdcxHel.h"
24#include "CLHEP/Alist/AIterator.h"
25#include "MdcxReco/MdcxHit.h"
26#include "MdcxReco/MdcxParameters.h"
33 int ntracks = trkl.length();
34 if (iprt) cout <<
"MdcxMergeDups called with " << ntracks <<
" tracks" << endl;
35 double m_2pi = 2.0*
M_PI;
37 while(trkl[k]) trkl[k++]->SetUsedOnHel(0);
40 for (
int i = 0; i < ntracks-1; i++) {
42 int already_merged = 0;
44 already_merged = trkl[i]->GetUsedOnHel();
47 for (
int j = i+1; j < ntracks; j++) {
48 if (trkl[j]->GetUsedOnHel())
continue;
49 double omega1 = iptr->
Omega();
50 double omega2 = trkl[j]->Omega();
51 double phi01 = iptr->
Phi0();
52 double phi02 = trkl[j]->Phi0();
53 double d01 = iptr->
D0();
54 double d02 = trkl[j]->D0();
55 double prodo = omega1*omega2;
56 if (
m_debug) cout <<
"Try track [" << i <<
"] and [" << j <<
"], prodo = " << prodo << endl;
59 if(
m_debug) std::cout <<
" fabs(d01 - d02) " << fabs(d01 - d02) << std::endl;
61 if(
m_debug) std::cout <<
" fabs(phi01-phi02) " << fabs(phi01-phi02) << std::endl;
64 if (fabs(omega1)>0.00001) r1 = 1.0/fabs(omega1);
66 if (fabs(omega2)>0.00001) r2 = 1.0/fabs(omega2);
67 double pdrad = fabs((r1-r2)/(r1+r2)) ;
69 std::cout <<
"omega1,r1 " << omega1 <<
" " << r1
70 <<
" omega2,r2 " << omega2 <<
" " << r2
71 <<
" pdrad " << pdrad << std::endl;
75 cout <<
"MdcxMD i j dif " << i <<
" " << j <<
" " << d01-d02 <<
" "
76 << phi01-phi02 <<
" " << r1 <<
" " << r2 <<
" " << pdrad << endl;
78 if (iprt) cout <<
"MdcxMD " << dcxhlist.length() <<
" " << iptr->
Chisq();
80 if (iprt) cout <<
" " << dcxh2.length() <<
" " << trkl[j]->Chisq();
81 dcxhlist.append(dcxh2);
83 if (iprt) cout <<
" " << dcxhlist.length() << endl;
88 if ( !fit2.
Fail() && (fit2.
Rcs()<fit1.
Rcs()) ) uf = 2;
90 std::cout <<
"fit1.Fail() " << fit1.
Fail() <<
" fit1.Rcs " << fit1.
Rcs()
91 <<
" fit2.Fail() " << fit2.
Fail() <<
" fit2.Rcs " << fit2.
Rcs()
95 MdcxHel fitme = (uf == 1) ? fit1 : fit2;
97 if (!finehel->
Fail()) {
102 trkl[j]->SetUsedOnHel(already_merged);
108 trkl[j]->SetUsedOnHel(already_merged);
121 if ((fabs(d01+d02) < 4.0) && (fabs(d01-d02) > 47.0)) {
122 double deltap = fabs( fabs(phi01-phi02) -
M_PI );
125 if (fabs(omega1) > 0.00001) r1 = 1.0/fabs(omega1);
127 if (fabs(omega2) > 0.00001) r2 = 1.0/fabs(omega2);
128 double pdrad = fabs((r1-r2)/(r1+r2)) ;
131 cout <<
"MdcxMD i j sum " << i <<
" " << j <<
" " << d01+d02 <<
" "
132 << deltap <<
" " << r1 <<
" " << r2 <<
" " << pdrad << endl;
138 if (iprt) cout <<
"MdcxMD " << dcxhlist.length() <<
" " << iptr->
Chisq();
140 if (iprt) cout <<
" " << dcxh2.length() <<
" " << trkl[j]->Chisq();
141 dcxhlist.append(dcxh2);
143 if (iprt) cout <<
" " << dcxhlist.length() << endl;
148 if ( !fit2.
Fail() && (fit2.
Rcs()<fit1.
Rcs()) ) uf = 2;
150 MdcxHel fitme = (1 == uf) ? fit1 : fit2;
152 if (!finehel->
Fail()) {
153 if (already_merged) {
157 trkl[j]->SetUsedOnHel(already_merged);
163 trkl[j]->SetUsedOnHel(already_merged);
179 if (iprt)cout <<
"In MdcxMD, trk is used on " << k <<
" " << trkl[k]->GetUsedOnHel() << endl;
180 if (!trkl[k]->GetUsedOnHel())
CleanTrklist.append(trkl[k]);
194 if (iprt) cout <<
"MdcxMD leaves with " <<
CleanTrklist.length() <<
" tracks" << endl;
void SetUsedOnHel(const int &i)
const HepAList< MdcxHit > & XHitList() const
int Fail(float Probmin=0.0) const
void SetTurnFlag(const int &i)
HepAList< MdcxFittedHel > CleanTrklist
HepAList< MdcxFittedHel > NewTrklist
MdcxMergeDups(HepAList< MdcxFittedHel > &f, int debug)
static const double maxDd0InMerge
static const double maxPdradInMerge
static const double maxRcsInMerge
static const double maxDphi0InMerge