00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <assert.h>
00020 #include "MdcGeom/BesAngle.h"
00021 #include "CLHEP/Alist/AList.h"
00022 #include "MdcGeom/MdcSuperLayer.h"
00023 #include "MdcGeom/MdcDetector.h"
00024 #include "MdcTrkRecon/MdcSegGrouperCsmc.h"
00025 #include "MdcTrkRecon/MdcSegList.h"
00026 #include "MdcTrkRecon/MdcSeg.h"
00027 #include "MdcTrkRecon/MdcSegInfoCsmc.h"
00028 #include "MdcTrkRecon/mdcWrapAng.h"
00029 #include "MdcTrkRecon/MdcTrack.h"
00030 #include "MdcTrkRecon/GmsList.h"
00031 #include "TrkBase/TrkExchangePar.h"
00032
00033
00034
00035 MdcSegGrouperCsmc::MdcSegGrouperCsmc(const MdcDetector *gm, int debug) :
00036 MdcSegGrouper(gm, gm->nAxialSuper()-1, debug) {
00037
00038
00039 lTestGroup = false;
00040 lTestSingle = false;
00041
00042 isValid = new bool * [nPly()];
00043 for (int j = 0; j < nPly(); j++) {
00044 isValid[j] = 0;
00045 }
00046 }
00047
00048
00049 void
00050 MdcSegGrouperCsmc::fillWithSegs( const MdcSegList *inSegs) {
00051
00052
00053
00054 for (int isuper = 0; isuper < _gm->nSuper(); isuper++) {
00055 const GmsList *inList = inSegs->oneList(isuper);
00056 if (inList->count() == 0) continue;
00057
00058 MdcSeg *inSeg = (MdcSeg *) inList->first();
00059
00060 if (inSeg->superlayer()->whichView() != 0) continue;
00061
00062 while (inSeg != 0) {
00063
00064 MdcSegInfoCsmc *info = new MdcSegInfoCsmc;
00065 inSeg->setInfo(info);
00066 info->calcStraight(inSeg);
00067
00068
00069
00070 int isInserted = 0;
00071 for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) {
00072 MdcSeg *aSeg = segList[isuper][iseg];
00073 if ( ((MdcSegInfoCsmc *)aSeg->info())->phi0() < info->phi0())
00074 continue;
00075 segList[isuper].insert(inSeg, iseg);
00076 isInserted = 1;
00077 break;
00078 }
00079 if (isInserted == 0) segList[isuper].append(inSeg);
00080
00081 inSeg = (MdcSeg *) inSeg->next();
00082 }
00083 }
00084
00085 }
00086
00087
00088 int
00089 MdcSegGrouperCsmc::incompWithSeg(const MdcSeg *refSeg,
00090 const MdcSeg *testSeg) {
00091
00092
00093 return 0;
00094
00095
00096 if (testSeg == 0) return 0;
00097
00098
00099 MdcSegInfoCsmc *refInfo = (MdcSegInfoCsmc *) refSeg->info();
00100 MdcSegInfoCsmc *testInfo = (MdcSegInfoCsmc *) testSeg->info();
00101 double sigPhi0 = (refInfo->sigPhi0() > testInfo->sigPhi0() ?
00102 refInfo->sigPhi0() : testInfo->sigPhi0());
00103 double refPhi0 = refInfo->phi0();
00104 double testPhi0 = testInfo->phi0();
00105 double corrPhi0 = mdcWrapAng(refPhi0, testPhi0);
00106 if (refPhi0 - corrPhi0 > 6. * sigPhi0) return -1;
00107 if (corrPhi0 - refPhi0 > 6. * sigPhi0) {
00108 if (testPhi0 > refPhi0) return 1;
00109 else return -1;
00110 }
00111
00112
00113
00114 double sigD0 = (refInfo->sigD0() > testInfo->sigD0() ?
00115 refInfo->sigD0() : testInfo->sigD0());
00116 double refD0 = refInfo->d0();
00117 double testD0 = testInfo->d0();
00118 if (fabs(refD0 - testD0) > 6. * sigD0) return -2;
00119
00120 return 0;
00121 }
00122
00123 int
00124 MdcSegGrouperCsmc::incompWithGroup(MdcSeg **segGroup, const MdcSeg *testSeg,
00125 int iply) {
00126
00127
00128 return 0;
00129 }
00130
00131
00132 void
00133 MdcSegGrouperCsmc::resetComb(const class MdcSeg *seed) {
00134
00135
00136
00137 if (isValid != 0) {
00138 int i;
00139 for (i = 0; i < nDeep; i++) {
00140 delete [] isValid[i];
00141 isValid[i] = 0;
00142 }
00143 }
00144
00145 _seed = seed;
00146
00147 int islay = 0;
00148 int iply = 0;
00149 nPlyFilled = 0;
00150 nNull = 0;
00151 const MdcSuperLayer *seedSlay = 0;
00152 if (seed != 0) seedSlay = seed->superlayer();
00153
00154
00155 for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0;
00156 thisSlay = thisSlay->next()) {
00157 bool noGoodYet = true;
00158 islay++;
00159
00160 if (thisSlay == seedSlay) continue;
00161 if (thisSlay->whichView() != 0) continue;
00162 firstGood[iply] = 0;
00163
00164 firstBad[iply] = 0;
00165 if (segList[islay-1].length() != 0)
00166 isValid[iply] = new bool[segList[islay-1].length()];
00167 for (int i = 0; i < (int) segList[islay-1].length(); i++) {
00168 MdcSeg *aSeg = segList[islay-1][i];
00169 int invalid = incompWithSeg(seed, aSeg);
00170 isValid[iply][i] = true;
00171 if (invalid < 0) {
00172 firstBad[iply] = i;
00173 isValid[iply][i] = false;
00174 if (noGoodYet) firstGood[iply] = i+1;
00175 }
00176 else if (invalid > 0) {
00177
00178 firstBad[iply] = i;
00179 for (int j = i; j < (int) segList[islay-1].length(); j++)
00180 isValid[iply][j] = false;
00181 break;
00182 }
00183 else {
00184 firstBad[iply] = i+1;
00185 noGoodYet = false;
00186 }
00187 }
00188
00189
00190
00191
00192
00193
00194
00195 if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply];
00196 if (firstGood[iply] == firstBad[iply]) {
00197
00198 continue;
00199 }
00200
00201 combList[iply] = &segList[islay-1];
00202 leaveGap[iply] = false;
00203 iply++;
00204 }
00205 nPlyFilled = iply;
00206 resetSegCounters();
00207 maxNull = nPlyFilled - 2;
00208 maxNull++;
00209 }
00210
00211 MdcTrack*
00212 MdcSegGrouperCsmc::storePar(MdcTrack* trk, double parms[2], double chi2,
00213 TrkContext& context, double t0){
00214
00215 assert(trk == 0);
00216 BesAngle foundPhi0(parms[1]);
00217 TrkExchangePar par(parms[0], foundPhi0.Rad(), 0., 0., 0.);
00218 return new MdcTrack(_gm->nSuper(), par, chi2, context, t0);
00219 }