BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcSegGrouperCsmc.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: MdcSegGrouperCsmc.cxx,v 1.7 2009/12/16 09:02:47 zhangy Exp $
4//
5// Description:
6//
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Authors:
12//
13// Copyright (C) 1996 The Board of Trustees of
14//
15// History:
16// Migration for BESIII MDC
17// The Leland Stanford Junior University. All Rights Reserved.
18//------------------------------------------------------------------------
19#include <assert.h>
20#include "MdcGeom/BesAngle.h"
21#include "CLHEP/Alist/AList.h"
22#include "MdcGeom/MdcSuperLayer.h"
23#include "MdcGeom/MdcDetector.h"
24#include "MdcTrkRecon/MdcSegGrouperCsmc.h"
25#include "MdcTrkRecon/MdcSegList.h"
26#include "MdcTrkRecon/MdcSeg.h"
27#include "MdcTrkRecon/MdcSegInfoCsmc.h"
28#include "MdcTrkRecon/mdcWrapAng.h"
29#include "MdcTrkRecon/MdcTrack.h"
30#include "MdcTrkRecon/GmsList.h"
31#include "TrkBase/TrkExchangePar.h"
32
33//Constructor
34//------------------------------------------------------------------------
36 MdcSegGrouper(gm, gm->nAxialSuper()-1, debug) {
37//------------------------------------------------------------------------
38
39 lTestGroup = false;
40 lTestSingle = false;
41
42 isValid = new bool * [nPly()];
43 for (int j = 0; j < nPly(); j++) {
44 isValid[j] = 0;
45 }
46}
47
48//------------------------------------------------------------------------
49void
51//------------------------------------------------------------------------
52 // Prepare for axial finding
53 // Store the segments (pointers, actually), sorting by phi0
54 for (int isuper = 0; isuper < _gm->nSuper(); isuper++) {
55 const GmsList *inList = inSegs->oneList(isuper);
56 if (inList->count() == 0) continue;
57
58 MdcSeg *inSeg = (MdcSeg *) inList->first();
59 // Only load axial segments
60 if (inSeg->superlayer()->whichView() != 0) continue;
61
62 while (inSeg != 0) {
63 // Create an info object within the seg to store info
65 inSeg->setInfo(info);
66 info->calcStraight(inSeg); // calc. origin-dependent info
67
68 // Loop over the segs already stored, looking for the right place
69 // to stick the new one
70 int isInserted = 0;
71 for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) {
72 MdcSeg *aSeg = segList[isuper][iseg];
73 if ( ((MdcSegInfoCsmc *)aSeg->info())->phi0() < info->phi0())
74 continue;
75 segList[isuper].insert(inSeg, iseg);
76 isInserted = 1;
77 break;
78 } // end of loop over existing segs
79 if (isInserted == 0) segList[isuper].append(inSeg);
80
81 inSeg = (MdcSeg *) inSeg->next();
82 } // end loop over new segs
83 } // end loop over superlayers
84
85}
86
87//-------------------------------------------------------------------------
88int
90 const MdcSeg *testSeg) {
91//-------------------------------------------------------------------------
92
93 return 0;
94 // Returns 0 if valid, -1 if invalid, +1 if invalid and no more valid
95 // ones possible in this slayer (assumes they're ordered)
96 if (testSeg == 0) return 0;
97
98 // Test phi0 match
99 MdcSegInfoCsmc *refInfo = (MdcSegInfoCsmc *) refSeg->info();
100 MdcSegInfoCsmc *testInfo = (MdcSegInfoCsmc *) testSeg->info();
101 double sigPhi0 = (refInfo->sigPhi0() > testInfo->sigPhi0() ?
102 refInfo->sigPhi0() : testInfo->sigPhi0());
103 double refPhi0 = refInfo->phi0();
104 double testPhi0 = testInfo->phi0();
105 double corrPhi0 = mdcWrapAng(refPhi0, testPhi0);
106 if (refPhi0 - corrPhi0 > 6. * sigPhi0) return -1;
107 if (corrPhi0 - refPhi0 > 6. * sigPhi0) {
108 if (testPhi0 > refPhi0) return 1;
109 else return -1; // => testPhi0>2pi & refPhi0<2pi
110 }
111
112 // Test d0 match
113 // use larger error of the two
114 double sigD0 = (refInfo->sigD0() > testInfo->sigD0() ?
115 refInfo->sigD0() : testInfo->sigD0());
116 double refD0 = refInfo->d0();
117 double testD0 = testInfo->d0();
118 if (fabs(refD0 - testD0) > 6. * sigD0) return -2;
119
120 return 0;
121}
122//-------------------------------------------------------------------------
123int
125 int iply) {
126//-------------------------------------------------------------------------
127
128 return 0;
129}
130
131//---------------------------------------------------------------------
132void
134//---------------------------------------------------------------------
135
136 // Delete existing list of valid/invalid segs
137 if (isValid != 0) {
138 int i;
139 for (i = 0; i < nDeep; i++) {
140 delete [] isValid[i];
141 isValid[i] = 0;
142 }
143 }
144
145 _seed = seed;
146 //Grab the seglist for each slayer
147 int islay = 0;
148 int iply = 0;
149 nPlyFilled = 0;
150 nNull = 0;
151 const MdcSuperLayer *seedSlay = 0;
152 if (seed != 0) seedSlay = seed->superlayer();
153
154 // Set up all sorts of stuff for fast grouping of segs in nextGroup()
155 for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0;
156 thisSlay = thisSlay->next()) {
157 bool noGoodYet = true;
158 islay++;
159
160 if (thisSlay == seedSlay) continue;
161 if (thisSlay->whichView() != 0) continue;
162 firstGood[iply] = 0;
163 // Loop over the segs, marking start & end of valid region for this seed
164 firstBad[iply] = 0;
165 if (segList[islay-1].length() != 0)
166 isValid[iply] = new bool[segList[islay-1].length()];
167 for (int i = 0; i < (int) segList[islay-1].length(); i++) {
168 MdcSeg *aSeg = segList[islay-1][i];
169 int invalid = incompWithSeg(seed, aSeg);
170 isValid[iply][i] = true;
171 if (invalid < 0) {
172 firstBad[iply] = i;
173 isValid[iply][i] = false;
174 if (noGoodYet) firstGood[iply] = i+1;
175 }
176 else if (invalid > 0) {
177 // No more valid segs in this slayer
178 firstBad[iply] = i;
179 for (int j = i; j < (int) segList[islay-1].length(); j++)
180 isValid[iply][j] = false;
181 break;
182 }
183 else {
184 firstBad[iply] = i+1;
185 noGoodYet = false;
186 }
187 }
188 // if (thisSlay->whichView() != 0) continue;
189 // firstGood[iply] = 0;
190 // // Loop over the segs, marking start & end of valid region
191 // firstBad[iply] = 0;
192 // firstBad[iply] = segList[islay-1].length();
193
194
195 if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply];
196 if (firstGood[iply] == firstBad[iply]) {
197 // If there are no valid segs for this ply, skip it
198 continue;
199 }
200 // Associate correct seglist with this ply
201 combList[iply] = &segList[islay-1];
202 leaveGap[iply] = false;
203 iply++;
204 }
205 nPlyFilled = iply;
207 maxNull = nPlyFilled - 2;
208 maxNull++;
209}
210//---------------------------------------------------------------------
211MdcTrack*
212MdcSegGrouperCsmc::storePar(MdcTrack* trk, double parms[2], double chi2,
213 TrkContext& context, double t0){
214//---------------------------------------------------------------------
215 assert(trk == 0);
216 BesAngle foundPhi0(parms[1]);
217 TrkExchangePar par(parms[0], foundPhi0.Rad(), 0., 0., 0.);
218 return new MdcTrack(_gm->nSuper(), par, chi2, context, t0);
219}
double mdcWrapAng(double phi1, double phi2)
const MdcSuperLayer * firstSlay(void) const
void resetComb(const class MdcSeg *)
MdcSegGrouperCsmc(const MdcDetector *gm, int debug)
void fillWithSegs(const MdcSegList *inSegs)
virtual MdcTrack * storePar(MdcTrack *trk, double parms[2], double chisq, TrkContext &, double trackT0)
virtual int incompWithSeg(const MdcSeg *refSeg, const MdcSeg *testSeg)
virtual int incompWithGroup(MdcSeg **segGroup, const MdcSeg *testSeg, int iply)
void resetSegCounters()
double sigPhi0() const
double sigD0() const
void calcStraight(double phi, double slope, double rad, const double *inErr)
const GmsList * oneList(int slayIndex) const
Definition: MdcSegList.cxx:412
const MdcSuperLayer * superlayer() const
void setInfo(MdcSegInfo *ptr)
Definition: MdcSeg.cxx:96
const MdcSuperLayer * next(void) const