31 {
33 int iprt = 0;
34 int ntracks = trkl.length();
35 if (iprt) cout << "MdcxMergeDups called with " << ntracks << " tracks" << endl;
36 double m_2pi = 2.0*
M_PI;
37 int k = 0;
38 while(trkl[k]) trkl[k++]->SetUsedOnHel(0);
39
40 if (ntracks > 1) {
41 for (int i = 0; i < ntracks-1; i++) {
43 int already_merged = 0;
45 already_merged = trkl[i]->GetUsedOnHel();
47 }
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;
58
59 if (prodo > 0.0) {
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;
64 double r1=100000.;
65 if (fabs(omega1)>0.00001) r1 = 1.0/fabs(omega1);
66 double r2=100000.;
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;
73 }
75 if (iprt)
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);
83 dcxhlist.purge();
84 if (iprt) cout << " " << dcxhlist.length() << endl;
87 int uf = 0;
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()
93 << std::endl;
94 }
95 if (uf) {
96 MdcxHel fitme = (uf == 1) ? fit1 : fit2;
98 if (!finehel->
Fail()) {
99 if (already_merged) {
101 delete iptr;
102 iptr = finehel;
104 } else {
108 iptr = finehel;
110 }
111 } else {
112 delete finehel;
113 }
114 }
115 }
116 }
117 }
118 }
119
120
121 if (prodo < 0.0) {
122 if ((fabs(d01+d02) < 4.0) && (fabs(d01-d02) > 47.0)) {
123 double deltap = fabs( fabs(phi01-phi02) -
M_PI );
125 double r1=100000.;
126 if (fabs(omega1) > 0.00001) r1 = 1.0/fabs(omega1);
127 double r2=100000.;
128 if (fabs(omega2) > 0.00001) r2 = 1.0/fabs(omega2);
129 double pdrad = fabs((r1-r2)/(r1+r2)) ;
131 if (iprt)
132 cout << "MdcxMD i j sum " << i << " " << j << " " << d01+d02 << " "
133 << deltap << " " << r1 << " " << r2 << " " << pdrad << endl;
135
139 if (iprt) cout <<
"MdcxMD " << dcxhlist.length() <<
" " << iptr->
Chisq();
141 if (iprt) cout << " " << dcxh2.length() << " " << trkl[j]->Chisq();
142 dcxhlist.append(dcxh2);
143 dcxhlist.purge();
144 if (iprt) cout << " " << dcxhlist.length() << endl;
147 int uf = 0;
149 if ( !fit2.Fail() && (fit2.Rcs()<fit1.Rcs()) ) uf = 2;
150 if (uf) {
151 MdcxHel fitme = (1 == uf) ? fit1 : fit2;
153 if (!finehel->
Fail()) {
154 if (already_merged) {
156 delete iptr;
157 iptr = finehel;
159 } else {
163 iptr = finehel;
165 }
166 } else {
167 delete finehel;
168 }
169 }
170 }
171 }
172 }
173 }
174 }
175 }
176 }
177
178 k = 0;
179 while (trkl[k]) {
180 if (iprt)cout << "In MdcxMD, trk is used on " << k << " " << trkl[k]->GetUsedOnHel() << endl;
181 if (!trkl[k]->GetUsedOnHel())
CleanTrklist.append(trkl[k]);
182 k++;
183 }
184
185 k=0;
190 }
191
193 }
194
195 if (iprt) cout <<
"MdcxMD leaves with " <<
CleanTrklist.length() <<
" tracks" << endl;
196}
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