CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcSegGrouperSt Class Reference

#include <MdcSegGrouperSt.h>

+ Inheritance diagram for MdcSegGrouperSt:

Public Member Functions

 MdcSegGrouperSt (const MdcDetector *gm, int debug)
 
 ~MdcSegGrouperSt ()
 
void fillWithSegs (const MdcSegList *inSegs, const MdcTrack *axialTrack)
 
void plotStereo () const
 
virtual int incompWithSeg (const MdcSeg *refSeg, const MdcSeg *testSeg)
 
virtual int incompWithGroup (MdcSeg **segGroup, const MdcSeg *testSeg, int iply)
 
void resetComb (const MdcSeg *seed=0)
 
virtual MdcTrackstorePar (MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)
 
- Public Member Functions inherited from MdcSegGrouper
virtual ~MdcSegGrouper ()
 
int nextGroup (MdcSeg **segGroup, bool printit)
 
int updateGap ()
 
void resetGap (int nGap)
 
int nPly () const
 
int combineSegs (MdcTrack *&, MdcSeg *seed, TrkContext &, double trackT0, double maxSegChisqO, int combineByFitHits=0)
 
void transferHits (MdcTrack *track, int nSegs, MdcSeg **segGroup)
 
void dumpSegList ()
 
double calcParBySegs (MdcSeg **segGroup, double seedAngle[2], int nToUse, double &qual, int &nSegFit, double param[2])
 
double calcParByHits (MdcSeg **segGroup, int nToUse, const TrkExchangePar &par, double &qual, int &nSegFit, double param[2], double Bz)
 
void setNoInner (bool noInnerFlag)
 

Additional Inherited Members

- Protected Member Functions inherited from MdcSegGrouper
 MdcSegGrouper (const MdcDetector *gm, int nDeep, int debug)
 
void resetSegCounters ()
 
- Protected Attributes inherited from MdcSegGrouper
int nDeep
 
int nPlyFilled
 
int * currentSeg
 
int * firstGood
 
int * firstBad
 
bool ** isValid
 
HepAList< MdcSeg > ** combList
 
const MdcDetector_gm
 
HepAList< MdcSeg > * segList
 
boolleaveGap
 
int nNull
 
int maxNull
 
int * gapCounter
 
bool lTestGroup
 
bool lTestSingle
 
int _debug
 
bool _noInner
 

Detailed Description

Definition at line 29 of file MdcSegGrouperSt.h.

Constructor & Destructor Documentation

◆ MdcSegGrouperSt()

MdcSegGrouperSt::MdcSegGrouperSt ( const MdcDetector * gm,
int debug )

Definition at line 45 of file MdcSegGrouperSt.cxx.

45 :
46 MdcSegGrouper(gm, gm->nStereoSuper(-1) + gm->nStereoSuper(1), debug) {
47//------------------------------------------------------------------------
48
49 lTestGroup = true;
50 lTestSingle = false;
51
52 isValid = new bool * [nPly()];
53 for (int j = 0; j < nPly(); j++) {
54 isValid[j] = 0;
55 }
56 }
int nStereoSuper(int iview) const
Definition MdcDetector.h:56
MdcSegGrouper(const MdcDetector *gm, int nDeep, int debug)
int nPly() const

◆ ~MdcSegGrouperSt()

MdcSegGrouperSt::~MdcSegGrouperSt ( )
inline

Definition at line 33 of file MdcSegGrouperSt.h.

33{ };

Member Function Documentation

◆ fillWithSegs()

void MdcSegGrouperSt::fillWithSegs ( const MdcSegList * inSegs,
const MdcTrack * axialTrack )

Definition at line 69 of file MdcSegGrouperSt.cxx.

70 {
71 //------------------------------------------------------------------------
72 // Prepare for stereo finding
73 // Load segments consistent with input track (already in phi order)
74 // Assuming from origin
75 int nsuper = _gm->nSuper();
76 resetList(); // Clear existing lists
77 if(3==_debug) std::cout<<std::endl<< "=====MdcSegGrouperSt::fillWithSegs====="<<std::endl;
78
79 const TrkFit* tkFit = track->track().fitResult();
80 if (tkFit == 0) return;
81 TrkExchangePar par = tkFit->helix(0.0);
82 double kap = 0.5 * par.omega();
83 double phi0 = par.phi0();
84 double d0 = par.d0();
85 MdcSegWorks segStuff; // holds some calculated values to pass to segInfo
86
87 bool lStraight = false;
88 if (fabs(kap) < 1.e-9) { lStraight = true; }
89
90 double rCurl = 99999999.;
91 if (!lStraight) {
92 rCurl = fabs(d0 + 1./kap);
93 }
94
95 // Create an info object to store the info (will be owned by seg)
97
98 // Loop over superlayers
99 for (int isuper = 0; isuper < nsuper; isuper++) {
100 const GmsList *inList = inSegs->oneList(isuper);
101
102 if (inList->count() == 0) continue;
103
104 MdcSeg *inSeg = (MdcSeg *) inList->first();
105 // Only load stereo segments
106 if (inSeg->superlayer()->whichView() == 0) continue;
107
108 // Calculate r & phi (approx) of axial track at slayer
109 double radius = inSeg->superlayer()->rEnd();
110 if (radius >= rCurl) break;
111 double phiArg = kap * radius;
112 if (lStraight) phiArg = d0 / radius;
113 if (phiArg < -1.0) phiArg = -1.0;
114 else if (phiArg > 1.0) phiArg = 1.0;
115 segStuff.phiArg = phiArg;
116 segStuff.phiAx.setRad(phi0 + asin(phiArg)); // Approx??!!!!
117 BesAngle delPhi( fabs(inSeg->superlayer()->delPhi()) );
118 //BesAngle maxPhiA = segStuff.phiAx + delPhi + 0.05; // allow a little slop
119 //BesAngle minPhiA = segStuff.phiAx - delPhi - 0.05;
120 BesAngle maxPhiA = segStuff.phiAx + delPhi + 0.1; // allow a little slop yzhang 2011-06-15
121 BesAngle minPhiA = segStuff.phiAx - delPhi - 0.1;//yzhang TEMP 2011-06-15
122 //yzhang FIXME
123 double maxPhi = maxPhiA;
124 double minPhi = minPhiA;
125 bool phitest = (maxPhi > minPhi);
126 //phitest = false => the valid range straddles phi = 0, so skip
127 //checking against phimin and phimax
128
129 //Calc some things needed in segInfo::calcStereo
130 segStuff.wirLen2inv = 1./ (inSeg->superlayer()->zEnd() *
131 inSeg->superlayer()->zEnd() );
132 // Loop over segs in superlayer
133 if(_debug==3) std::cout<<std::endl<<"Pick segment by phi from " <<minPhi<< " to "<<maxPhi<<" phiAx="<<segStuff.phiAx<<" delPhi="<<delPhi<<std::endl;
134 for ( ; inSeg != 0; inSeg = (MdcSeg *) inSeg->next()) {
135 // Test if within allowed phi range
136 BesAngle phiSeg(inSeg->phi());
137
138 if(_debug==3){ inSeg->plotSeg(); }
139 if (phitest) {
140 if (phiSeg < minPhi){
141 if (_debug ==3){std::cout << " CUT by phi "<<phiSeg
142 << "<min "<<minPhi << std::endl;}//yzhang debug
143 continue; // not up to candidates
144 }
145 else if(phiSeg > maxPhi) {
146 if (_debug ==3){std::cout << " CUT by phi "<<phiSeg
147 <<">max "<<maxPhi<< std::endl;}//yzhang debug
148 break; // past candidates
149 }
150 } else { // !phitest
151 if (phiSeg > maxPhi && phiSeg < minPhi) {
152 if (_debug ==3){std::cout << "!phitest "<<phiSeg
153 <<" max "<<maxPhi<< " min "<<minPhi << std::endl;}//yzhang debug
154 continue;
155 }
156 }
157
158 if(_debug == 3) std::cout<<" **KEEP seg phi="<<phiSeg<< std::endl;
159
160 //std::cout<< __FILE__ << " " << __LINE__ << " MdcSegGrouperSt::fillWithSegs call calcStereo "<<std::endl;
161 int isBad = info->calcStereo(inSeg, track->track(), segStuff);
162
163 if (isBad) {
164 if (_debug ==3){std::cout << " CUT by calcStereo isBad!"<<std::endl;}
165 continue;
166 }
167 // Test for sensible values of ct and z0
168 if (g_z0Cut) {g_z0Cut->fill(info->z0());}
169 if (g_ctCut) {g_ctCut->fill(info->ct());}
170 if (fabs(info->ct()) > inSeg->segPar()->ctcut) {
171 if (_debug ==3){std::cout << " CUT by ctcut! "
172 <<fabs(info->ct())<<" > cut:"<< inSeg->segPar()->ctcut<<" "<<phiSeg<<std::endl; }
173 continue;
174 }
175 if (fabs(info->z0()) > inSeg->segPar()->z0cut){
176 if (_debug ==3){std::cout << " CUT by z0cut! "
177 <<fabs(info->z0())<<" >cut "<< inSeg->segPar()->z0cut<<" "<<phiSeg<<std::endl; }
178 continue;
179 }
180 inSeg->setInfo(info);
181 info = new MdcSegInfoSterO;
182 segList[isuper].append(inSeg);
183 //if(_debug==3)std::cout<<" APPEND this stereo seg"<< std::endl;
184
185 } // end loop over new segs
186 } // end loop over superlayers
187 delete info;
188}
AIDA::IHistogram1D * g_z0Cut
Definition MdcHistItem.h:29
AIDA::IHistogram1D * g_ctCut
Definition MdcHistItem.h:30
void setRad(const double)
Definition BesAngle.h:133
GmsListLink * first() const
Definition GmsList.h:42
unsigned int count() const
Definition GmsList.h:43
int nSuper() const
Definition MdcDetector.h:53
HepAList< MdcSeg > * segList
const MdcDetector * _gm
double ct() const
double z0() const
int calcStereo(MdcSeg *parentSeg, const TrkRecoTrk &track, MdcSegWorks &segStuff)
const GmsList * oneList(int slayIndex) const
double wirLen2inv
Definition MdcSegWorks.h:15
BesAngle phiAx
Definition MdcSegWorks.h:17
double phiArg
Definition MdcSegWorks.h:16
const MdcSuperLayer * superlayer() const
Definition MdcSeg.h:51
static MdcSegParams * segPar()
Definition MdcSeg.h:79
void plotSeg() const
Definition MdcSeg.cxx:194
double phi() const
Definition MdcSeg.h:46
void setInfo(MdcSegInfo *ptr)
Definition MdcSeg.cxx:96
int whichView(void) const
double delPhi(void) const
double zEnd(void) const
double rEnd(void) const
double phi0() const
double omega() const
double d0() const
virtual TrkExchangePar helix(double fltL) const =0

Referenced by MdcTrackList::createFromSegs(), and MdcTrackListCsmc::createFromSegs().

◆ incompWithGroup()

int MdcSegGrouperSt::incompWithGroup ( MdcSeg ** segGroup,
const MdcSeg * testSeg,
int iply )
virtual

Implements MdcSegGrouper.

Definition at line 228 of file MdcSegGrouperSt.cxx.

229 {
230 //-------------------------------------------------------------------------
231 // Test that the latest seg lies more or less in a line with the others
232 // Currently requiring line to point to IP; also require rough
233 // agreement in ct.
234 // iply = depth index of current seg (not yet in group)
235
236 int i;
237 // Find first segment already in group
238 for (i = iply - 1; i > 0; i--) {
239 if (!leaveGap[i]) break;
240 }
241 const MdcSeg *first = (*combList[i])[currentSeg[i]];
242
243 // Test ct
244 MdcSegInfoSterO* firstInfo = (MdcSegInfoSterO *) first->info();
245 MdcSegInfoSterO* newInfo = (MdcSegInfoSterO *) testSeg->info();
246
247 if (g_delCt) {g_delCt->fill( firstInfo->ct() - newInfo->ct());}//yzhang hist cut
248 if (fabs( firstInfo->ct() - newInfo->ct() ) >
249 testSeg->segPar()->delCtCut) {
250 if(_debug==3){
251 cout << "---MdcSegGrouperSt Ct CUT!" << endl;//yzhang debug
252 std::cout<<"first:"; first->plotSeg(); std::cout<<std::endl;
253 std::cout<<"test:"; testSeg->plotSeg();std::cout<<std::endl;
254 std::cout << "first.ct "<< firstInfo->ct()
255 <<" test.ct "<<newInfo->ct()
256 <<" delta ct "<<firstInfo->ct() - newInfo->ct()
257 <<" Cut "<<testSeg->segPar()->delCtCut << std::endl;//yzhang debug
258
259 std::cout<<"--- "<< std::endl;
260 }
261 return -1;
262 }else{
263 }
264
265 double arcFirst = firstInfo->arc();
266 double arcNew = newInfo->arc();
267 double zFirst = firstInfo->z0() + firstInfo->ct() * arcFirst;
268 double zNew = newInfo->z0() + newInfo->ct() * arcNew;
269 // project line from IP through 1st seg to new seg
270 double zProj = zFirst / arcFirst * arcNew;
271 if (g_delZ0) {g_delZ0->fill( zProj - zNew);}//yzhang hist cut
272
273 if (fabs(zProj - zNew) > testSeg->segPar()->delZ0Cut) {
274 if(3==_debug){
275 cout << "MdcSegGrouperSt delZ0Cut not incompWithGroup CUT!" << endl;//yzhang debug
276 testSeg->plotSeg();
277 std::cout<<" zProj "<< zProj << " zNew "<< zNew<< " CUT! "
278 << testSeg->segPar()->delZ0Cut << std::endl;
279 }
280 return -1;
281 }
282
283 /*
284 double delZ = newInfo->z0() + newInfo->ct() * arcNew - zFirst;
285 double z0 = zFirst - arcFirst * delZ / (arcNew - arcFirst);
286 if (fabs(z0) > testSeg->segPar()->delZ0Cut)return -1;
287
288 for (i = iply - 1; i > 0; i--) {
289 if (segGroup[i] != 0) break;
290 }
291 const MdcSeg *last = segGroup[i];
292 MdcSegInfoSterO* lastInfo = (MdcSegInfoSterO *) last->info();
293
294 // Test that slope from last segment to new one is roughly = slope from
295 // first seg to last
296 double arcLast = lastInfo->arc();
297 double arcFirst = firstInfo->arc();
298 double arcNew = newInfo->arc();
299
300 double delZold = lastInfo->z0() - firstInfo->z0() +
301 lastInfo->ct() * arcLast - firstInfo->ct() * arcFirst;
302 double delArcold = arcLast - arcFirst;
303 double delZnew = newInfo->z0() - lastInfo->z0() +
304 newInfo->ct() * arcNew - lastInfo->ct() * arcLast;
305 double delArcnew = arcNew - arcLast;
306 double p1 = delZold * delArcnew;
307 double p2 = delZnew * delArcold;
308
309 cout << " test: " << p1 << " " << p2 << endl;
310
311 if (fabs(p2 - p1) > 0.02) return -1;
312
313*/
314 return 0;
315}
AIDA::IHistogram1D * g_delCt
Definition MdcHistItem.h:31
AIDA::IHistogram1D * g_delZ0
Definition MdcHistItem.h:32
HepAList< MdcSeg > ** combList
double arc() const
Definition MdcSegInfo.h:44
double delCtCut
double delZ0Cut
MdcSegInfo * info() const
Definition MdcSeg.h:52
Index first(Pair i)

◆ incompWithSeg()

int MdcSegGrouperSt::incompWithSeg ( const MdcSeg * refSeg,
const MdcSeg * testSeg )
virtual

Implements MdcSegGrouper.

Definition at line 220 of file MdcSegGrouperSt.cxx.

221 {
222 //-------------------------------------------------------------------------
223
224 return 0;
225}

◆ plotStereo()

void MdcSegGrouperSt::plotStereo ( ) const

Definition at line 191 of file MdcSegGrouperSt.cxx.

191 {
192 //-------------------------------------------------------------------------
193 int nsuper = _gm->nSuper();
194 int isuper;
195 /*
196 for (isuper = 0; isuper < nsuper; isuper++) {
197 if (segList[isuper].length() == 0) continue;
198
199 MdcSeg *inSeg = (MdcSeg *) segList[isuper].first();
200 // Only draw stereo segments
201 if (inSeg->superlayer()->whichView() == 0) continue;
202 for (int j = 0 ; j < (int) segList[isuper].length(); j++) {
203 segList[isuper][j]->plotSeg(0,orange);
204 }
205 }
206 */
207 for (isuper = 0; isuper < nsuper; isuper++) {
208 if (segList[isuper].length() == 0) continue;
209
210 MdcSeg *inSeg = (MdcSeg *) segList[isuper].first();
211 // Only draw stereo segments
212 //if (inSeg->superlayer()->whichView() == 0) continue;
213 for (int j = 0 ; j < (int) segList[isuper].length(); j++) {
214 segList[isuper][j]->plotSeg();
215 }
216 }
217
218}
double length

◆ resetComb()

void MdcSegGrouperSt::resetComb ( const MdcSeg * seed = 0)
virtual

Implements MdcSegGrouper.

Definition at line 318 of file MdcSegGrouperSt.cxx.

318 {
319 //**************************************************************************
320
321 // Delete existing list of valid/invalid segs
322 if (isValid != 0) {
323 int i;
324 for (i = 0; i < nDeep; i++) {
325 delete [] isValid[i];
326 isValid[i] = 0;
327 }
328 }
329
330 //Grab the seglist for each slayer
331 int islay = 0;
332 int iply = 0;
333 nPlyFilled = 0;
334 nNull = 0;
335
336
337 // Set up all sorts of stuff for fast grouping of segs in nextGroup()
338 for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0;
339 thisSlay = thisSlay->next()) {
340 //bool noGoodYet = true;
341 islay++;
342 if (thisSlay->whichView() == 0) continue;
343 firstGood[iply] = 0;
344 firstBad[iply] = segList[islay-1].length();
345 if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply];
346 if (firstGood[iply] == firstBad[iply]) {
347 // If there are no valid segs for this ply, skip it
348 continue;
349 }
350 // Associate correct seglist with this ply
351 combList[iply] = &segList[islay-1];
352 leaveGap[iply] = false;
353 iply++;
354 }
355
356 nPlyFilled = iply;
358 maxNull = nPlyFilled - 2;
359}
const MdcSuperLayer * firstSlay(void) const
Definition MdcDetector.h:46
const MdcSuperLayer * next(void) const

◆ storePar()

MdcTrack * MdcSegGrouperSt::storePar ( MdcTrack * trk,
double parms[2],
double chisq,
TrkContext & ,
double trackT0 )
virtual

Implements MdcSegGrouper.

Definition at line 362 of file MdcSegGrouperSt.cxx.

364 {
365 //---------------------------------------------------------------------
366 assert (trk != 0);
367 TrkHelixMaker maker;
368 if(3==_debug) std::cout<< "-----storePar z0 "<<parms[0]<<" ct "<<parms[1]<<std::endl;
369 maker.addZValues(trk->track(), parms[0], parms[1], chisq);
370 return trk;
371}
TrkRecoTrk & track()
Definition MdcTrack.h:27
void addZValues(TrkRecoTrk &theTrack, double z0, double tanDip, double chi2)

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