BOSS 8.0.0
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 "MdcTrkRecon/MdcSegGrouperCsmc.h"
20#include "CLHEP/Alist/AList.h"
21#include "MdcGeom/BesAngle.h"
22#include "MdcGeom/MdcDetector.h"
23#include "MdcGeom/MdcSuperLayer.h"
24#include "MdcTrkRecon/GmsList.h"
25#include "MdcTrkRecon/MdcSeg.h"
26#include "MdcTrkRecon/MdcSegInfoCsmc.h"
27#include "MdcTrkRecon/MdcSegList.h"
28#include "MdcTrkRecon/MdcTrack.h"
29#include "MdcTrkRecon/mdcWrapAng.h"
30#include "TrkBase/TrkExchangePar.h"
31#include <assert.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++ ) { isValid[j] = 0; }
44}
45
46//------------------------------------------------------------------------
48 //------------------------------------------------------------------------
49 // Prepare for axial finding
50 // Store the segments (pointers, actually), sorting by phi0
51 for ( int isuper = 0; isuper < _gm->nSuper(); isuper++ )
52 {
53 const GmsList* inList = inSegs->oneList( isuper );
54 if ( inList->count() == 0 ) continue;
55
56 MdcSeg* inSeg = (MdcSeg*)inList->first();
57 // Only load axial segments
58 if ( inSeg->superlayer()->whichView() != 0 ) continue;
59
60 while ( inSeg != 0 )
61 {
62 // Create an info object within the seg to store info
64 inSeg->setInfo( info );
65 info->calcStraight( inSeg ); // calc. origin-dependent info
66
67 // Loop over the segs already stored, looking for the right place
68 // to stick the new one
69 int isInserted = 0;
70 for ( int iseg = 0; iseg < (int)segList[isuper].length(); iseg++ )
71 {
72 MdcSeg* aSeg = segList[isuper][iseg];
73 if ( ( (MdcSegInfoCsmc*)aSeg->info() )->phi0() < info->phi0() ) continue;
74 segList[isuper].insert( inSeg, iseg );
75 isInserted = 1;
76 break;
77 } // end of loop over existing segs
78 if ( isInserted == 0 ) segList[isuper].append( inSeg );
79
80 inSeg = (MdcSeg*)inSeg->next();
81 } // end loop over new segs
82 } // end loop over superlayers
83}
84
85//-------------------------------------------------------------------------
86int MdcSegGrouperCsmc::incompWithSeg( const MdcSeg* refSeg, const MdcSeg* testSeg ) {
87 //-------------------------------------------------------------------------
88
89 return 0;
90 // Returns 0 if valid, -1 if invalid, +1 if invalid and no more valid
91 // ones possible in this slayer (assumes they're ordered)
92 if ( testSeg == 0 ) return 0;
93
94 // Test phi0 match
95 MdcSegInfoCsmc* refInfo = (MdcSegInfoCsmc*)refSeg->info();
96 MdcSegInfoCsmc* testInfo = (MdcSegInfoCsmc*)testSeg->info();
97 double sigPhi0 =
98 ( refInfo->sigPhi0() > testInfo->sigPhi0() ? refInfo->sigPhi0() : testInfo->sigPhi0() );
99 double refPhi0 = refInfo->phi0();
100 double testPhi0 = testInfo->phi0();
101 double corrPhi0 = mdcWrapAng( refPhi0, testPhi0 );
102 if ( refPhi0 - corrPhi0 > 6. * sigPhi0 ) return -1;
103 if ( corrPhi0 - refPhi0 > 6. * sigPhi0 )
104 {
105 if ( testPhi0 > refPhi0 ) return 1;
106 else return -1; // => testPhi0>2pi & refPhi0<2pi
107 }
108
109 // Test d0 match
110 // use larger error of the two
111 double sigD0 =
112 ( refInfo->sigD0() > testInfo->sigD0() ? refInfo->sigD0() : testInfo->sigD0() );
113 double refD0 = refInfo->d0();
114 double testD0 = testInfo->d0();
115 if ( fabs( refD0 - testD0 ) > 6. * sigD0 ) return -2;
116
117 return 0;
118}
119//-------------------------------------------------------------------------
120int MdcSegGrouperCsmc::incompWithGroup( MdcSeg** segGroup, const MdcSeg* testSeg, int iply ) {
121 //-------------------------------------------------------------------------
122
123 return 0;
124}
125
126//---------------------------------------------------------------------
127void MdcSegGrouperCsmc::resetComb( const class MdcSeg* seed ) {
128 //---------------------------------------------------------------------
129
130 // Delete existing list of valid/invalid segs
131 if ( isValid != 0 )
132 {
133 int i;
134 for ( i = 0; i < nDeep; i++ )
135 {
136 delete[] isValid[i];
137 isValid[i] = 0;
138 }
139 }
140
141 _seed = seed;
142 // Grab the seglist for each slayer
143 int islay = 0;
144 int iply = 0;
145 nPlyFilled = 0;
146 nNull = 0;
147 const MdcSuperLayer* seedSlay = 0;
148 if ( seed != 0 ) seedSlay = seed->superlayer();
149
150 // Set up all sorts of stuff for fast grouping of segs in nextGroup()
151 for ( const MdcSuperLayer* thisSlay = _gm->firstSlay(); thisSlay != 0;
152 thisSlay = thisSlay->next() )
153 {
154 bool noGoodYet = true;
155 islay++;
156
157 if ( thisSlay == seedSlay ) continue;
158 if ( thisSlay->whichView() != 0 ) continue;
159 firstGood[iply] = 0;
160 // Loop over the segs, marking start & end of valid region for this seed
161 firstBad[iply] = 0;
162 if ( segList[islay - 1].length() != 0 )
163 isValid[iply] = new bool[segList[islay - 1].length()];
164 for ( int i = 0; i < (int)segList[islay - 1].length(); i++ )
165 {
166 MdcSeg* aSeg = segList[islay - 1][i];
167 int invalid = incompWithSeg( seed, aSeg );
168 isValid[iply][i] = true;
169 if ( invalid < 0 )
170 {
171 firstBad[iply] = i;
172 isValid[iply][i] = false;
173 if ( noGoodYet ) firstGood[iply] = i + 1;
174 }
175 else if ( invalid > 0 )
176 {
177 // No more valid segs in this slayer
178 firstBad[iply] = i;
179 for ( int j = i; j < (int)segList[islay - 1].length(); j++ ) isValid[iply][j] = false;
180 break;
181 }
182 else
183 {
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 if ( firstGood[iply] > firstBad[iply] ) firstGood[iply] = firstBad[iply];
195 if ( firstGood[iply] == firstBad[iply] )
196 {
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* MdcSegGrouperCsmc::storePar( MdcTrack* trk, double parms[2], double chi2,
212 TrkContext& context, double t0 ) {
213 //---------------------------------------------------------------------
214 assert( trk == 0 );
215 BesAngle foundPhi0( parms[1] );
216 TrkExchangePar par( parms[0], foundPhi0.Rad(), 0., 0., 0. );
217 return new MdcTrack( _gm->nSuper(), par, chi2, context, t0 );
218}
double mdcWrapAng(double phi1, double phi2)
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)
MdcSegGrouper(const MdcDetector *gm, int nDeep, int debug)
double sigPhi0() const
double sigD0() const
void calcStraight(double phi, double slope, double rad, const double *inErr)
const GmsList * oneList(int slayIndex) const
void setInfo(MdcSegInfo *ptr)
Definition MdcSeg.cxx:97