38 static bool alreadyInit =
false;
39 if (alreadyInit)
return;
43 for (
int sl = 0;
sl < lastsl;
sl++) {
47 for (
int i = 0; i < nslay; i++) layArray[i] = slayer->
layer(i);
48 int cellMax = layArray[1]->
nWires();
50 for (
int cellIndex = 0; cellIndex < cellMax ; cellIndex++) {
53 wireIndex[0]= cellIndex;
54 wireIndex[1]= cellIndex+1;
55 wireIndex[2]= cellIndex;
56 wireIndex[3]= cellIndex+1;
58 wireIndex[1] =
mdcWrapWire(wireIndex[1], layArray[1]->nWires());
59 wireIndex[3] =
mdcWrapWire(wireIndex[3], layArray[3]->nWires());
61 wireIndex[1]= cellIndex+1;
63 double phi = layArray[1]->
getWire(wireIndex[1])->
phiE();
64 for(
int i = 0; i < 4; i++ ) {
65 if ( i == 1 )
continue;
67 if ( i == 3 ) phi = layArray[2]->
getWire(wireIndex[2])->
phiE();
68 BesAngle tmp(phi - layArray[i]->phiEPOffset());
70 wireIndex[i]=(tmp==0)?1:(int)ceil(layArray[i]->nWires()*tmp.
rad()/twopi);
72 wireIndex[i]=(tmp==0)?-1:(int)floor(layArray[i]->nWires()*tmp.
rad()/twopi);
74 wireIndex[i] =
mdcWrapWire(wireIndex[i], layArray[i]->nWires());
79 for (
int i = 0; i < 4; i++) {
80 for (
int j = 0; j < 4; j++) {
82 w[4*i+j] =
mdcWrapWire((wireIndex[i]+j-1), layArray[i]->nWires());
96 int lflag[44][288] = { {0} };
97 int pflag[44][288] = { {0} };
98 int ix,iy,iyp,iyn,cellMax;
115 for (ix=0; ix<lastlay; ix++){
118 for (iy=0; iy<cellMax; iy++){
119 iyp=iy+1;
if (iyp == cellMax)iyp=0;
120 iyn=iy-1;
if (iyn == -1)iyn=cellMax-1;
121 if ((lflag[ix][iyp] != 0) && (lflag[ix][iyn] != 0)) {
136 for (
sl = 0;
sl < lastsl;
sl++) {
138 int l0=fsl, l1=fsl+1, l2=fsl+2, l3=fsl+3;
144 for (
int i = 0; i < nslay; i++) layArray[i] = slayer->
layer(i);
146 cout<<
"slayer No. "<<slayer->
index()<<endl;
149 cellMax = layArray[1]->
nWires();
152 for (
int cellIndex=0; cellIndex<cellMax ; cellIndex++) {
154 unsigned int sig_mark = 0;
155 for (
int ilayer = l0; ilayer <= l3; ilayer++) {
156 for (
int iwire = 3; iwire >= 0; iwire--) {
157 if (lflag[ilayer][w[4*(ilayer-l0)+iwire]]) {
167 int iPat = (sig_mark & 0x0200) ? 0 : 11;
168 for ( ; iPat < nPat; iPat++) {
170 if ((pat & sig_mark) == pat) {
172 cout<<
"pat " << std::hex << pat << std::dec <<
" with wire";
173 for (
int tmpi = 0; tmpi < 4; tmpi++) {
182 int tw[4] = {w0, w1, w2, w3};
185 for (
int iamb = 0; iamb < namb; iamb++) {
190 <<
" <? csmax4 "<<csmax_4<< endl;
192 cout<<
"Accept this seg"<<endl;
194 cout<<
"DROP this seg"<<endl;
206 if (goodSegNo != 0)
continue;
208 iPat = (sig_mark & 0x0200) ? 0 : 14;
209 for ( ; iPat < nPat; iPat++) {
211 if ((iPat == nPat-2) && (sig_mark&0x2121 == 0x2121))
continue;
212 if ((iPat == nPat-1) && (sig_mark&0x2122 == 0x2122))
continue;
215 if ((pat & sig_mark) == pat) {
217 cout<<
"MdcxFindSegs: in pat "<<std::hex<<pat<<std::dec<<
" with wire";
218 for (
int tmpi = 0; tmpi < 4; tmpi++) {
220 cout<<
" (" << l0+tmpi <<
"," << w[4*tmpi+
m_segPat.
wirePat3[iPat][tmpi]-1] <<
")";
225 for (
int iw = 0, iwp = 0; iwp < 4; iwp++) {
227 if(
wireNo == 0 )
continue;
228 wn[iw++] = lflag[l0+iwp][w[4*iwp+
wireNo-1]] - 1;
232 for (
int iamb = 0; iamb < namb; iamb++) {
237 <<
" <? csmax3 "<<csmax_3<< endl;
239 cout<<
"Accept this seg"<<endl;
241 cout<<
"DROP this seg"<<endl;
256 cout <<
"MdcxFindSegs found " <<
MdcxSeglist.length() <<
" segs" << endl;
274 seg.append(t1); seg.append(t2); seg.append(t3); seg.append(t4);
280 double phi0 = atan2(dy,dx); dx=t1->
x(); dy=t1->
y();
281 MdcxHel hel(d0,phi0,0.0,0.0,0.0,0.0,111,0,dx,dy);
285 cout<<
"trial4 amb "<<amb
286 <<
": phi0 " << phi0 <<
" d0 " << d0
287 <<
" dx " << dx <<
" dy " << dy << endl;
298 seg.append(t1); seg.append(t2); seg.append(t3);
305 double phi0 = atan2(dy,dx); dx=t1->
x(); dy=t1->
y();
306 MdcxHel hel(d0,phi0,0.0,0.0,0.0,0.0,111,0,dx,dy);
311 cout<<
"trial3 amb "<<amb
312 <<
": phi0 " << phi0 <<
" d0 " << d0
313 <<
" dx " << dx <<
" dy " << dy << endl;