BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcxMergeDups Class Reference

#include <MdcxMergeDups.h>

Public Member Functions

 MdcxMergeDups (HepAList< MdcxFittedHel > &f, int debug)
 
virtual ~MdcxMergeDups ()
 
const HepAList< MdcxFittedHel > & GetMergedTrklist ()
 

Protected Member Functions

void KillList ()
 

Protected Attributes

HepAList< MdcxFittedHelNewTrklist
 
HepAList< MdcxFittedHelCleanTrklist
 
int m_debug
 

Detailed Description

Definition at line 29 of file MdcxMergeDups.h.

Constructor & Destructor Documentation

◆ MdcxMergeDups()

MdcxMergeDups::MdcxMergeDups ( HepAList< MdcxFittedHel > &  f,
int  debug 
)

FIXME

Definition at line 31 of file MdcxMergeDups.cxx.

31 {
32 m_debug = (debug == 10);
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++) {
42 MdcxFittedHel* iptr = trkl[i];
43 int already_merged = 0;
44 if (iptr->GetUsedOnHel()) {
45 already_merged = trkl[i]->GetUsedOnHel();
46 iptr = NewTrklist[already_merged-1];
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 // Try to merge pair that looks like duplicates (same charge)
59 if (prodo > 0.0) {
60 if(m_debug) std::cout << " fabs(d01 - d02) " << fabs(d01 - d02) << std::endl;
61 if (fabs(d01 - d02) < MdcxParameters::maxDd0InMerge) {
62 if(m_debug) std::cout << " fabs(phi01-phi02) " << fabs(phi01-phi02) << std::endl;
63 if (fabs(phi01-phi02) < MdcxParameters::maxDphi0InMerge) {
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); //FIXME
68 double pdrad = fabs((r1-r2)/(r1+r2)) ;
69 if (m_debug) {
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;
78 HepAList<MdcxHit> dcxhlist = iptr->XHitList();
79 if (iprt) cout << "MdcxMD " << dcxhlist.length() << " " << iptr->Chisq();
80 const HepAList<MdcxHit>& dcxh2 = trkl[j]->XHitList();
81 if (iprt) cout << " " << dcxh2.length() << " " << trkl[j]->Chisq();
82 dcxhlist.append(dcxh2);
83 dcxhlist.purge();
84 if (iprt) cout << " " << dcxhlist.length() << endl;
85 MdcxFittedHel fit1(dcxhlist, *iptr); // fit1.FitPrint(); fit1.print();
86 MdcxFittedHel fit2(dcxhlist, *trkl[j]); // fit2.FitPrint(); fit2.print();
87 int uf = 0;
88 if ( !fit1.Fail() && (fit1.Rcs()<MdcxParameters::maxRcsInMerge) ) uf = 1;
89 if ( !fit2.Fail() && (fit2.Rcs()<fit1.Rcs()) ) uf = 2;
90 if (m_debug) {
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;
97 MdcxFittedHel* finehel = new MdcxFittedHel(dcxhlist, fitme);
98 if (!finehel->Fail()) {
99 if (already_merged) {
100 NewTrklist.replace(iptr, finehel);
101 delete iptr;
102 iptr = finehel;
103 trkl[j]->SetUsedOnHel(already_merged);
104 } else {
105 NewTrklist.append(finehel);
106 already_merged = NewTrklist.length();
107 iptr->SetUsedOnHel(already_merged);
108 iptr = finehel;
109 trkl[j]->SetUsedOnHel(already_merged);
110 }
111 } else {
112 delete finehel;
113 }
114 }
115 }
116 }
117 }
118 }
119
120 // Try to merge pair that looks like albedo (opp charge, large d0)
121 if (prodo < 0.0) {
122 if ((fabs(d01+d02) < 4.0) && (fabs(d01-d02) > 47.0)) { /// FIXME
123 double deltap = fabs( fabs(phi01-phi02) - M_PI );
124 if (deltap < MdcxParameters::maxDphi0InMerge) {
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;
134 MdcxHel temp1 = *iptr;
135 //zoujh?: temp1.SetTurnFlag(1);
136 MdcxHel temp2 = *trkl[j];
137 temp2.SetTurnFlag(1);
138 HepAList<MdcxHit> dcxhlist = iptr->XHitList();
139 if (iprt) cout << "MdcxMD " << dcxhlist.length() << " " << iptr->Chisq();
140 const HepAList<MdcxHit>& dcxh2 = trkl[j]->XHitList();
141 if (iprt) cout << " " << dcxh2.length() << " " << trkl[j]->Chisq();
142 dcxhlist.append(dcxh2);
143 dcxhlist.purge();
144 if (iprt) cout << " " << dcxhlist.length() << endl;
145 MdcxFittedHel fit1(dcxhlist, temp1); // fit1.FitPrint(); fit1.print();
146 MdcxFittedHel fit2(dcxhlist, temp2); // fit2.FitPrint(); fit2.print();
147 int uf = 0;
148 if ( !fit1.Fail() && (fit1.Rcs()<MdcxParameters::maxRcsInMerge) ) uf = 1;
149 if ( !fit2.Fail() && (fit2.Rcs()<fit1.Rcs()) ) uf = 2;
150 if (uf) {
151 MdcxHel fitme = (1 == uf) ? fit1 : fit2;
152 MdcxFittedHel* finehel = new MdcxFittedHel(dcxhlist, fitme);
153 if (!finehel->Fail()) {
154 if (already_merged) {
155 NewTrklist.replace(iptr, finehel);
156 delete iptr;
157 iptr = finehel;
158 trkl[j]->SetUsedOnHel(already_merged);
159 } else {
160 NewTrklist.append(finehel);
161 already_merged = NewTrklist.length();
162 iptr->SetUsedOnHel(already_merged);
163 iptr = finehel;
164 trkl[j]->SetUsedOnHel(already_merged);
165 }
166 } else {
167 delete finehel;
168 }
169 }
170 }
171 }
172 }
173 }
174 }//end j loop
175 }//end i loop
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;
186 while (NewTrklist[k]) {
187 if (iprt && m_debug) {
188 NewTrklist[k]->FitPrint();
189 NewTrklist[k]->print();
190 }
191
192 CleanTrklist.append(NewTrklist[k++]);
193 }
194
195 if (iprt) cout << "MdcxMD leaves with " << CleanTrklist.length() << " tracks" << endl;
196}
#define M_PI
Definition: TConstant.h:4
void SetUsedOnHel(const int &i)
Definition: MdcxFittedHel.h:55
const HepAList< MdcxHit > & XHitList() const
Definition: MdcxFittedHel.h:59
int GetUsedOnHel() const
Definition: MdcxFittedHel.h:56
float Chisq() const
Definition: MdcxFittedHel.h:45
int Fail(float Probmin=0.0) const
double Phi0() const
Definition: MdcxHel.h:54
double D0() const
Definition: MdcxHel.h:53
double Omega() const
Definition: MdcxHel.h:55
void SetTurnFlag(const int &i)
Definition: MdcxHel.h:115
HepAList< MdcxFittedHel > NewTrklist
Definition: MdcxMergeDups.h:36
HepAList< MdcxFittedHel > CleanTrklist
Definition: MdcxMergeDups.h:37
static const double maxDd0InMerge
static const double maxPdradInMerge
static const double maxRcsInMerge
static const double maxDphi0InMerge

◆ ~MdcxMergeDups()

MdcxMergeDups::~MdcxMergeDups ( )
virtual

Definition at line 198 of file MdcxMergeDups.cxx.

198 {
199 KillList();
200}

Member Function Documentation

◆ GetMergedTrklist()

const HepAList< MdcxFittedHel > & MdcxMergeDups::GetMergedTrklist ( )
inline

Definition at line 33 of file MdcxMergeDups.h.

33{return CleanTrklist;}

Referenced by MdcxTrackFinder::execute().

◆ KillList()

void MdcxMergeDups::KillList ( )
inlineprotected

Definition at line 40 of file MdcxMergeDups.h.

40{HepAListDeleteAll(NewTrklist);}

Referenced by ~MdcxMergeDups().

Member Data Documentation

◆ CleanTrklist

HepAList<MdcxFittedHel> MdcxMergeDups::CleanTrklist
protected

Definition at line 37 of file MdcxMergeDups.h.

Referenced by GetMergedTrklist(), and MdcxMergeDups().

◆ m_debug

int MdcxMergeDups::m_debug
protected

Definition at line 38 of file MdcxMergeDups.h.

Referenced by MdcxMergeDups().

◆ NewTrklist

HepAList<MdcxFittedHel> MdcxMergeDups::NewTrklist
protected

Definition at line 36 of file MdcxMergeDups.h.

Referenced by KillList(), and MdcxMergeDups().


The documentation for this class was generated from the following files: