30 {
32 int iprt = 0;
33 int ntracks = trkl.length();
34 if (iprt) cout << "MdcxMergeDups called with " << ntracks << " tracks" << endl;
35 double m_2pi = 2.0*
M_PI;
36 int k = 0;
37 while(trkl[k]) trkl[k++]->SetUsedOnHel(0);
38
39 if (ntracks > 1) {
40 for (int i = 0; i < ntracks-1; i++) {
42 int already_merged = 0;
44 already_merged = trkl[i]->GetUsedOnHel();
46 }
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;
57
58 if (prodo > 0.0) {
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;
63 double r1=100000.;
64 if (fabs(omega1)>0.00001) r1 = 1.0/fabs(omega1);
65 double r2=100000.;
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;
72 }
74 if (iprt)
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);
82 dcxhlist.purge();
83 if (iprt) cout << " " << dcxhlist.length() << endl;
86 int uf = 0;
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()
92 << std::endl;
93 }
94 if (uf) {
95 MdcxHel fitme = (uf == 1) ? fit1 : fit2;
97 if (!finehel->
Fail()) {
98 if (already_merged) {
100 delete iptr;
101 iptr = finehel;
103 } else {
107 iptr = finehel;
109 }
110 } else {
111 delete finehel;
112 }
113 }
114 }
115 }
116 }
117 }
118
119
120 if (prodo < 0.0) {
121 if ((fabs(d01+d02) < 4.0) && (fabs(d01-d02) > 47.0)) {
122 double deltap = fabs( fabs(phi01-phi02) -
M_PI );
124 double r1=100000.;
125 if (fabs(omega1) > 0.00001) r1 = 1.0/fabs(omega1);
126 double r2=100000.;
127 if (fabs(omega2) > 0.00001) r2 = 1.0/fabs(omega2);
128 double pdrad = fabs((r1-r2)/(r1+r2)) ;
130 if (iprt)
131 cout << "MdcxMD i j sum " << i << " " << j << " " << d01+d02 << " "
132 << deltap << " " << r1 << " " << r2 << " " << pdrad << endl;
134
138 if (iprt) cout <<
"MdcxMD " << dcxhlist.length() <<
" " << iptr->
Chisq();
140 if (iprt) cout << " " << dcxh2.length() << " " << trkl[j]->Chisq();
141 dcxhlist.append(dcxh2);
142 dcxhlist.purge();
143 if (iprt) cout << " " << dcxhlist.length() << endl;
146 int uf = 0;
148 if ( !fit2.Fail() && (fit2.Rcs()<fit1.Rcs()) ) uf = 2;
149 if (uf) {
150 MdcxHel fitme = (1 == uf) ? fit1 : fit2;
152 if (!finehel->
Fail()) {
153 if (already_merged) {
155 delete iptr;
156 iptr = finehel;
158 } else {
162 iptr = finehel;
164 }
165 } else {
166 delete finehel;
167 }
168 }
169 }
170 }
171 }
172 }
173 }
174 }
175 }
176
177 k = 0;
178 while (trkl[k]) {
179 if (iprt)cout << "In MdcxMD, trk is used on " << k << " " << trkl[k]->GetUsedOnHel() << endl;
180 if (!trkl[k]->GetUsedOnHel())
CleanTrklist.append(trkl[k]);
181 k++;
182 }
183
184 k=0;
189 }
190
192 }
193
194 if (iprt) cout <<
"MdcxMD leaves with " <<
CleanTrklist.length() <<
" tracks" << endl;
195}
void SetUsedOnHel(const int &i)
const HepAList< MdcxHit > & XHitList() const
int Fail(float Probmin=0.0) const
void SetTurnFlag(const int &i)
HepAList< MdcxFittedHel > NewTrklist
HepAList< MdcxFittedHel > CleanTrklist
static const double maxDd0InMerge
static const double maxPdradInMerge
static const double maxRcsInMerge
static const double maxDphi0InMerge