69 {
70
71
72
73
74
76 int nSegs = 0;
77 int newSegs;
78 unsigned int groupWord;
80 int lPrevHit = 0;
81
82 static const int layerWire[8][2] =
83 { { 0, -1}, { 0, 0}, { 1, 0}, { 2, -1},
84 { 2, 0}, { 3, -1}, { 3, 0}, { 3, 1} };
85
86
88 while (slayer != 0) {
90 int wireIndex[4];
91
92
93
94
96 for (
int i = 0; i < nslay; i++) layArray[i] = slayer->
layer(i);
97 if(nslay != 4) layArray[3] = 0;
98
99
100
101
102
103
104
105
106
107 for (
int cellIndex = 0; cellIndex < layArray[1]->
nWires(); cellIndex++) {
108
109 double phi = layArray[1]->
getWire(cellIndex)->
phiE();
110 for(int i = 0; i < 4; i++ ) {
111 wireIndex[i] = cellIndex;
112 if ( slayer->
slayNum() > 4)
continue;
113 if ( (slayer->
slayNum() > 9) && (i==3) )
break;
114 if ( i == 1 ) continue;
115 if ( i == 3 ) phi = layArray[2]->
getWire(wireIndex[2])->
phiE();
116 BesAngle tmp(phi - layArray[i]->phiEPOffset());
117 int wlow = (int)floor(layArray[i]->nWires() * tmp.rad() / twopi );
118 int wbig = (int)ceil(layArray[i]->nWires() * tmp.rad() / twopi );
119 if (tmp == 0 ){
120 wlow = -1;
121 wbig = 1;
122 }
123 if ( i!=3 ) {
124 wireIndex[i]=wbig;
125 }else{
126 wireIndex[i]= wlow;
127 }
128
129 wireIndex[i] =
mdcWrapWire(wireIndex[i], layArray[i]->nWires());
130 }
131
132 groupWord = 0u;
133 unsigned bitWord = 1u;
134 int nGroup = 0;
135 for (int ii = 0; ii < 8; ii++) {
136 groupHits[ii] = 0;
137
138 if(layArray[ layerWire[ii][0] ] == 0) continue;
139
140 int laynum = layArray[ layerWire[ii][0] ]->
layNum();
141 int wire = wireIndex[ layerWire[ii][0] ] + layerWire[ii][1];
142 wire =
mdcWrapWire(wire, layArray[ layerWire[ii][0] ]->nWires());
144 if (thisHit != 0) {
145 if ( !usedHits.
get(thisHit)->deadHit() ) {
146 groupHits[ii] = thisHit;
147 groupWord |= bitWord;
148 nGroup++;
149 } else {
150
151 }
152 }
153
154 if ( (ii == 2 && nGroup < 1) || (ii == 4 && nGroup < 2) ) break;
155 bitWord <<= 1;
156 }
157 if (nGroup < 3) continue;
158
159
160 int lastWire =
mdcWrapWire(cellIndex - 1, layArray[0]->nWires());
161 if (map->
hitWire(layArray[1]->layNum(), lastWire) != 0) lPrevHit = 1;
162
163 else lPrevHit = 0;
164
165
166 int nPatt = patternList.
npatt4[groupWord];
167
168 if ((layArray[1]->layNum()==5) && (cellIndex ==46)) {
169 for(int i=0;i<4;i++){
170
171 }
172
173 }
174
175 if (nPatt > 0) {
176 newSegs = tryPatterns(groupHits, groupWord, 4, lPrevHit, nPatt,
177 patternList.
allowedPatt4[groupWord], slayer, segs, usedHits, map,
178 bunchTime);
179 nSegs += newSegs;
180 }
181
182
183
185 int nUnused = 0;
186 for (int i = 0; i < 8; i++) {
187 if (groupHits[i] != 0) {
188 if (usedHits.
get(groupHits[i])->usedSeg() == 0) nUnused++;
189 }
190 }
191 if (nUnused > 0) {
192 nPatt = patternList.
npatt3[groupWord];
193 if (nPatt > 0) {
194
195 newSegs = tryPatterns(groupHits, groupWord, 3, lPrevHit, nPatt,
196 patternList.
allowedPatt3[groupWord], slayer, segs, usedHits, map,
197 bunchTime);
198 nSegs += newSegs;
199 }
200 }
201 }
202
203 slayer = slayer->
next();
204 }
205
206 if (nSegs > 0) {
207 segs.massageSegs();
209 }
210
211 nSegs = segs.
count();
212
214 cout << "Number of Segs found: " << nSegs << "\n";
215 }
216
217 return nSegs;
218}
const MdcSuperLayer * firstSlay(void) const
MdcHit * hitWire(int lay, int wire) const
MdcSWire * getWire(int wire) const
bool get(const K &theKey, V &theAnswer) const
void resetSeed(const MdcDetector *gm)
const MdcSuperLayer * next(void) const
const MdcLayer * layer(int i) const
int mdcWrapWire(int wireIn, int nCell)