34 int ntracks = trkl.length();
35 if (iprt) cout <<
"MdcxMergeDups called with " << ntracks <<
" tracks" << endl;
36 double m_2pi = 2.0*
M_PI;
38 while(trkl[k]) trkl[k++]->SetUsedOnHel(0);
41 for (
int i = 0; i < ntracks-1; i++) {
43 int already_merged = 0;
45 already_merged = trkl[i]->GetUsedOnHel();
48 for (
int j = i+1; j < ntracks; j++) {
49 if (trkl[j]->GetUsedOnHel())
continue;
50 double omega1 = iptr->
Omega();
51 double omega2 = trkl[j]->Omega();
52 double phi01 = iptr->
Phi0();
53 double phi02 = trkl[j]->Phi0();
54 double d01 = iptr->
D0();
55 double d02 = trkl[j]->D0();
56 double prodo = omega1*omega2;
57 if (
m_debug) cout <<
"Try track [" << i <<
"] and [" << j <<
"], prodo = " << prodo << endl;
60 if(
m_debug) std::cout <<
" fabs(d01 - d02) " << fabs(d01 - d02) << std::endl;
62 if(
m_debug) std::cout <<
" fabs(phi01-phi02) " << fabs(phi01-phi02) << std::endl;
65 if (fabs(omega1)>0.00001) r1 = 1.0/fabs(omega1);
67 if (fabs(omega2)>0.00001) r2 = 1.0/fabs(omega2);
68 double pdrad = fabs((r1-r2)/(r1+r2)) ;
70 std::cout <<
"omega1,r1 " << omega1 <<
" " << r1
71 <<
" omega2,r2 " << omega2 <<
" " << r2
72 <<
" pdrad " << pdrad << std::endl;
76 cout <<
"MdcxMD i j dif " << i <<
" " << j <<
" " << d01-d02 <<
" "
77 << phi01-phi02 <<
" " << r1 <<
" " << r2 <<
" " << pdrad << endl;
79 if (iprt) cout <<
"MdcxMD " << dcxhlist.length() <<
" " << iptr->
Chisq();
81 if (iprt) cout <<
" " << dcxh2.length() <<
" " << trkl[j]->Chisq();
82 dcxhlist.append(dcxh2);
84 if (iprt) cout <<
" " << dcxhlist.length() << endl;
89 if ( !fit2.
Fail() && (fit2.
Rcs()<fit1.
Rcs()) ) uf = 2;
91 std::cout <<
"fit1.Fail() " << fit1.
Fail() <<
" fit1.Rcs " << fit1.
Rcs()
92 <<
" fit2.Fail() " << fit2.
Fail() <<
" fit2.Rcs " << fit2.
Rcs()
96 MdcxHel fitme = (uf == 1) ? fit1 : fit2;
98 if (!finehel->
Fail()) {
103 trkl[j]->SetUsedOnHel(already_merged);
109 trkl[j]->SetUsedOnHel(already_merged);
122 if ((fabs(d01+d02) < 4.0) && (fabs(d01-d02) > 47.0)) {
123 double deltap = fabs( fabs(phi01-phi02) -
M_PI );
126 if (fabs(omega1) > 0.00001) r1 = 1.0/fabs(omega1);
128 if (fabs(omega2) > 0.00001) r2 = 1.0/fabs(omega2);
129 double pdrad = fabs((r1-r2)/(r1+r2)) ;
132 cout <<
"MdcxMD i j sum " << i <<
" " << j <<
" " << d01+d02 <<
" "
133 << deltap <<
" " << r1 <<
" " << r2 <<
" " << pdrad << endl;
139 if (iprt) cout <<
"MdcxMD " << dcxhlist.length() <<
" " << iptr->
Chisq();
141 if (iprt) cout <<
" " << dcxh2.length() <<
" " << trkl[j]->Chisq();
142 dcxhlist.append(dcxh2);
144 if (iprt) cout <<
" " << dcxhlist.length() << endl;
149 if ( !fit2.
Fail() && (fit2.
Rcs()<fit1.
Rcs()) ) uf = 2;
151 MdcxHel fitme = (1 == uf) ? fit1 : fit2;
153 if (!finehel->
Fail()) {
154 if (already_merged) {
158 trkl[j]->SetUsedOnHel(already_merged);
164 trkl[j]->SetUsedOnHel(already_merged);
180 if (iprt)cout <<
"In MdcxMD, trk is used on " << k <<
" " << trkl[k]->GetUsedOnHel() << endl;
181 if (!trkl[k]->GetUsedOnHel())
CleanTrklist.append(trkl[k]);
195 if (iprt) cout <<
"MdcxMD leaves with " <<
CleanTrklist.length() <<
" tracks" << endl;