BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcxFindSegs Class Reference

#include <MdcxFindSegs.h>

Public Member Functions

 MdcxFindSegs (MdcDetector *g, const HepAList< MdcxHit > &l, int m_debug=0)
 
 MdcxFindSegs (const HepAList< MdcxHit > &l, int debug=0)
 
virtual ~MdcxFindSegs ()
 
void initWireGroups (void)
 
void process ()
 
const HepAList< MdcxSeg > & GetMdcxSeglist ()
 
void appendseg (MdcxFittedHel &fithel, int pat, int amb)
 
void printseg (MdcxFittedHel &fithel, int pat, int amb, int subtry=0)
 
void print (std::ostream &o, int pmax=10) const
 
void setDebug (bool debug=0)
 
 MdcxFindSegs (MdcDetector *g, const HepAList< MdcxHit > &l, int m_debug=0)
 
 MdcxFindSegs (const HepAList< MdcxHit > &l, int debug=0)
 
virtual ~MdcxFindSegs ()
 
void initWireGroups (void)
 
void process ()
 
const HepAList< MdcxSeg > & GetMdcxSeglist ()
 
void appendseg (MdcxFittedHel &fithel, int pat, int amb)
 
void printseg (MdcxFittedHel &fithel, int pat, int amb, int subtry=0)
 
void print (std::ostream &o, int pmax=10) const
 
void setDebug (bool debug=0)
 

Protected Member Functions

MdcxFittedHel trial (int i1, int i2, int i3, int i4, int amb)
 
MdcxFittedHel trial (int i1, int i2, int i3, int amb)
 
void KillList ()
 
MdcxFittedHel trial (int i1, int i2, int i3, int i4, int amb)
 
MdcxFittedHel trial (int i1, int i2, int i3, int amb)
 
void KillList ()
 

Protected Attributes

HepAList< MdcxSegMdcxSeglist
 
int sl
 
MdcxFittedHel fithel
 
int nseg
 
const MdcDetectorgm
 
HepAList< MdcxHitdchitlist
 
int m_debug
 
MdcxSegPatterns m_segPat
 

Static Protected Attributes

static int wireGroups [11][288][16] = { { {0} } }
 

Detailed Description

Constructor & Destructor Documentation

◆ MdcxFindSegs() [1/4]

MdcxFindSegs::MdcxFindSegs ( MdcDetector g,
const HepAList< MdcxHit > &  l,
int  m_debug = 0 
)

Definition at line 18 of file MdcxFindSegs.cxx.

◆ MdcxFindSegs() [2/4]

MdcxFindSegs::MdcxFindSegs ( const HepAList< MdcxHit > &  l,
int  debug = 0 
)

Definition at line 26 of file MdcxFindSegs.cxx.

26 {
27 m_debug = debug;
29 dchitlist = hitlist;
31 process();
32}
static MdcDetector * instance()
Definition: MdcDetector.cxx:21

◆ ~MdcxFindSegs() [1/2]

MdcxFindSegs::~MdcxFindSegs ( )
virtual

Definition at line 34 of file MdcxFindSegs.cxx.

◆ MdcxFindSegs() [3/4]

MdcxFindSegs::MdcxFindSegs ( MdcDetector g,
const HepAList< MdcxHit > &  l,
int  m_debug = 0 
)

◆ MdcxFindSegs() [4/4]

MdcxFindSegs::MdcxFindSegs ( const HepAList< MdcxHit > &  l,
int  debug = 0 
)

◆ ~MdcxFindSegs() [2/2]

virtual MdcxFindSegs::~MdcxFindSegs ( )
virtual

Member Function Documentation

◆ appendseg() [1/2]

void MdcxFindSegs::appendseg ( MdcxFittedHel fithel,
int  pat,
int  amb 
)

Definition at line 318 of file MdcxFindSegs.cxx.

Referenced by process().

◆ appendseg() [2/2]

void MdcxFindSegs::appendseg ( MdcxFittedHel fithel,
int  pat,
int  amb 
)

◆ GetMdcxSeglist() [1/2]

const HepAList< MdcxSeg > & MdcxFindSegs::GetMdcxSeglist ( )
inline

◆ GetMdcxSeglist() [2/2]

const HepAList< MdcxSeg > & MdcxFindSegs::GetMdcxSeglist ( )
inline

◆ initWireGroups() [1/2]

void MdcxFindSegs::initWireGroups ( void  )

Definition at line 36 of file MdcxFindSegs.cxx.

36 {
37 //Assure initWireGroups run only once
38 static bool alreadyInit = false;
39 if (alreadyInit) return;
40
41 //Make wire groups
42 int lastsl= gm->nSuper();
43 for (int sl = 0; sl < lastsl; sl++) { // loop over superLayers
44 const MdcLayer *layArray[4];
45 const MdcSuperLayer* slayer = gm->SuperLayer(sl);
46 int nslay = slayer->nLayers();
47 for (int i = 0; i < nslay; i++) layArray[i] = slayer->layer(i);
48 int cellMax = layArray[1]->nWires();
49 // loop over cells
50 for (int cellIndex = 0; cellIndex < cellMax ; cellIndex++) {
51 int wireIndex[4];
52 if (slayer->slayNum() > 4) {
53 wireIndex[0]= cellIndex;
54 wireIndex[1]= cellIndex+1;
55 wireIndex[2]= cellIndex;
56 wireIndex[3]= cellIndex+1;
57
58 wireIndex[1] = mdcWrapWire(wireIndex[1], layArray[1]->nWires());
59 wireIndex[3] = mdcWrapWire(wireIndex[3], layArray[3]->nWires());
60 } else {
61 wireIndex[1]= cellIndex+1;
62 //take No.2 wire as referenc wire
63 double phi = layArray[1]->getWire(wireIndex[1])->phiE();
64 for(int i = 0; i < 4; i++ ) {
65 if ( i == 1 ) continue;
66 //change reference wire
67 if ( i == 3 ) phi = layArray[2]->getWire(wireIndex[2])->phiE();
68 BesAngle tmp(phi - layArray[i]->phiEPOffset());//yzhang temp
69 if ( i==3 ) {
70 wireIndex[i]=(tmp==0)?1:(int)ceil(layArray[i]->nWires()*tmp.rad()/twopi);
71 }else{
72 wireIndex[i]=(tmp==0)?-1:(int)floor(layArray[i]->nWires()*tmp.rad()/twopi);
73 }
74 wireIndex[i] = mdcWrapWire(wireIndex[i], layArray[i]->nWires());
75 }
76 }
77 // set wireGroups
78 int* w = wireGroups[sl][cellIndex];
79 for (int i = 0; i < 4; i++) {
80 for (int j = 0; j < 4; j++) {
81 //wireGroups[sl][cellIndex][4*i+j] = wireIndex[i] + (j - 1);
82 w[4*i+j] = mdcWrapWire((wireIndex[i]+j-1), layArray[i]->nWires());
83 }
84 }
85 } //end loop cells
86 } //end loop superLayers
87
88 //Set alreadyInit flag
89 alreadyInit = true;
90 return;
91}
double w
int mdcWrapWire(int wireIn, int nCell)
const MdcSuperLayer * SuperLayer(unsigned id) const
MdcSWire * getWire(int wire) const

Referenced by MdcxFindSegs().

◆ initWireGroups() [2/2]

void MdcxFindSegs::initWireGroups ( void  )

◆ KillList() [1/2]

void MdcxFindSegs::KillList ( )
inlineprotected

Definition at line 52 of file InstallArea/include/MdcxReco/MdcxReco/MdcxFindSegs.h.

52{HepAListDeleteAll(MdcxSeglist);}

Referenced by ~MdcxFindSegs().

◆ KillList() [2/2]

void MdcxFindSegs::KillList ( )
inlineprotected

◆ print() [1/2]

void MdcxFindSegs::print ( std::ostream &  o,
int  pmax = 10 
) const

◆ print() [2/2]

void MdcxFindSegs::print ( std::ostream &  o,
int  pmax = 10 
) const

◆ printseg() [1/2]

void MdcxFindSegs::printseg ( MdcxFittedHel fithel,
int  pat,
int  amb,
int  subtry = 0 
)

Definition at line 323 of file MdcxFindSegs.cxx.

323 {
324 cout << "Seg: pat " << pat << " amb " << amb << " subtry " << subtry
325 << " sl " << sl << " fail "
326 << fithel.Fail() << " chi2 " << fithel.Chisq() << endl;
327}
int Fail(float Probmin=0.0) const

Referenced by process().

◆ printseg() [2/2]

void MdcxFindSegs::printseg ( MdcxFittedHel fithel,
int  pat,
int  amb,
int  subtry = 0 
)

◆ process() [1/2]

void MdcxFindSegs::process ( )

Definition at line 93 of file MdcxFindSegs.cxx.

93 {
94 //if(3 == m_debug) cout <<" Event contains "<<dchitlist.length()<<" MdcxHit "<<endl;
95 // for last super layer use 44
96 int lflag[44][288] = { {0} };
97 int pflag[44][288] = { {0} };
98 int ix,iy,iyp,iyn,cellMax;
99
100 //yzhang 2009-10-20 do not use poison
101 int ipoison=0;
102 //number of last layer
103 int lastlay= gm->nLayer();
104
105 // tag hit's lfalg
106 int k=0;
107 while(dchitlist[k]){
108 MdcxHit* temp = dchitlist[k];
109 k++;
110 lflag[temp->Layer()][temp->WireNo()]=k;
111 }
112
113 // try poisoning
114 if (ipoison){
115 for (ix=0; ix<lastlay; ix++){
116 cellMax = gm->Layer(ix)->nWires();
117 // if have hits in left and right , poison this cell
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)) {
122 pflag[ix][iy] = 1;
123 lflag[ix][iy] = 0;
124 //g_poison->fill(ix,iy);
125 }
126 }
127 //for (iy=0; iy<cellMax; iy++) {if (pflag[ix][iy] != 0) lflag[ix][iy] = 0;}
128 }
129 } //FIXME (optimize ???)
130
131 float csmax_4 = MdcxParameters::csmax4;
132 float csmax_3 = MdcxParameters::csmax3;
133 int lastsl= gm->nSuper();//lastSLayNum;
134
135 // loop superlayer
136 for (sl = 0; sl < lastsl; sl++) {
137 int fsl=4*sl;
138 int l0=fsl, l1=fsl+1, l2=fsl+2, l3=fsl+3;
139 int iprt = 0;
140 //initialize superlayer pointer in layArray[]
141 const MdcLayer *layArray[4];
142 const MdcSuperLayer* slayer = gm->SuperLayer(sl);
143 int nslay = slayer->nLayers();
144 for (int i = 0; i < nslay; i++) layArray[i] = slayer->layer(i);
145 if(3 == m_debug){
146 cout<<"slayer No. "<<slayer->index()<<endl;//yzhang debug
147 }
148 //reference point (2,1)
149 cellMax = layArray[1]->nWires();
150
151 // loop over cells
152 for (int cellIndex=0; cellIndex<cellMax ; cellIndex++) {
153 int* w = wireGroups[sl][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]]) {
158 sig_mark |= 0x1;
159 }
160 sig_mark <<= 1;
161 }
162 }
163 sig_mark >>= 1;
164
165 int goodSegNo = 0;
166 int nPat = m_segPat.patt4_size;
167 int iPat = (sig_mark & 0x0200) ? 0 : 11;
168 for ( ; iPat < nPat; iPat++) {
169 int pat = m_segPat.patt4[iPat];
170 if ((pat & sig_mark) == pat) {
171 if(3 == m_debug) {
172 cout<< "pat " << std::hex << pat << std::dec << " with wire";
173 for (int tmpi = 0; tmpi < 4; tmpi++) {
174 cout<<"("<<l0+tmpi<<","<<w[4*tmpi+m_segPat.wirePat4[iPat][tmpi]-1]<<")";
175 }
176 cout << endl;
177 }
178 int w0 = lflag[l0][w[0 +m_segPat.wirePat4[iPat][0]-1]] - 1;
179 int w1 = lflag[l1][w[4 +m_segPat.wirePat4[iPat][1]-1]] - 1;
180 int w2 = lflag[l2][w[8 +m_segPat.wirePat4[iPat][2]-1]] - 1;
181 int w3 = lflag[l3][w[12+m_segPat.wirePat4[iPat][3]-1]] - 1;
182 int tw[4] = {w0, w1, w2, w3};
183
184 int namb = m_segPat.ambPat4_size[iPat];
185 for (int iamb = 0; iamb < namb; iamb++) {
186 int amb = m_segPat.ambigPatt4[iPat][iamb];
187 fithel = trial(w0, w1, w2, w3, amb);
188 if(3 == m_debug){
189 cout<<"chisq "<<fithel.Chisq()
190 <<" <? csmax4 "<<csmax_4<< endl;
191 if (fithel.Chisq() < csmax_4) {
192 cout<<"Accept this seg"<<endl;
193 }else{
194 cout<<"DROP this seg"<<endl;
195 }
196 }
197 if(g_csmax4) g_csmax4->fill(fithel.Chisq());
198 if (fithel.Chisq() < csmax_4) {
199 if (iprt) printseg(fithel, pat,amb);
200 appendseg(fithel, pat, amb);
201 goodSegNo++;
202 }
203 }
204 }
205 }
206 if (goodSegNo != 0) continue;
207 nPat = m_segPat.patt3_size;
208 iPat = (sig_mark & 0x0200) ? 0 : 14;
209 for ( ; iPat < nPat; iPat++) {
210 if (iPat > nPat-3) {
211 if ((iPat == nPat-2) && (sig_mark&0x2121 == 0x2121)) continue;
212 if ((iPat == nPat-1) && (sig_mark&0x2122 == 0x2122)) continue;
213 }
214 int pat = m_segPat.patt3[iPat];
215 if ((pat & sig_mark) == pat) {
216 if(3 == m_debug) {
217 cout<<"MdcxFindSegs: in pat "<<std::hex<<pat<<std::dec<<" with wire";
218 for (int tmpi = 0; tmpi < 4; tmpi++) {
219 if (m_segPat.wirePat3[iPat][tmpi] == 0) continue;
220 cout<< " (" << l0+tmpi << "," << w[4*tmpi+m_segPat.wirePat3[iPat][tmpi]-1] << ")";
221 }
222 cout<< endl;
223 }
224 int wn[3];
225 for (int iw = 0, iwp = 0; iwp < 4; iwp++) {
226 int wireNo = m_segPat.wirePat3[iPat][iwp];
227 if( wireNo == 0 ) continue;
228 wn[iw++] = lflag[l0+iwp][w[4*iwp+wireNo-1]] - 1;
229 }
230
231 int namb = m_segPat.ambPat3_size[iPat];
232 for (int iamb = 0; iamb < namb; iamb++) {
233 int amb = m_segPat.ambigPatt3[iPat][iamb];
234 fithel = trial(wn[0], wn[1], wn[2], amb);//FIXME
235 if(3 == m_debug){
236 cout<<"chisq "<<fithel.Chisq()
237 <<" <? csmax3 "<<csmax_3<< endl;
238 if (fithel.Chisq() < csmax_3) {
239 cout<<"Accept this seg"<<endl;
240 }else{
241 cout<<"DROP this seg"<<endl;
242 }
243 }
244 if(g_csmax3) g_csmax3->fill(fithel.Chisq());
245 if (fithel.Chisq() < csmax_3) {
246 if (iprt) printseg(fithel, pat, amb);
247 appendseg(fithel, pat ,amb);
248 }
249 }
250 }
251 }//end of nPat3
252 }
253 }
254
255 if(3 == m_debug){
256 cout << "MdcxFindSegs found " << MdcxSeglist.length() << " segs" << endl;
257 }
258 return;
259}
const int wireNo
const MdcLayer * Layer(unsigned id) const
void appendseg(MdcxFittedHel &fithel, int pat, int amb)
MdcxFittedHel trial(int i1, int i2, int i3, int i4, int amb)
void printseg(MdcxFittedHel &fithel, int pat, int amb, int subtry=0)
#define ix(i)
Definition: minoreval.cpp:387

Referenced by MdcxFindSegs().

◆ process() [2/2]

void MdcxFindSegs::process ( )

◆ setDebug() [1/2]

void MdcxFindSegs::setDebug ( bool  debug = 0)
inline

Definition at line 46 of file InstallArea/include/MdcxReco/MdcxReco/MdcxFindSegs.h.

46{m_debug = debug;}

◆ setDebug() [2/2]

void MdcxFindSegs::setDebug ( bool  debug = 0)
inline

◆ trial() [1/4]

MdcxFittedHel MdcxFindSegs::trial ( int  i1,
int  i2,
int  i3,
int  amb 
)
protected

Definition at line 293 of file MdcxFindSegs.cxx.

293 {
295 MdcxHit* t1 = dchitlist[i1];
296 MdcxHit* t2 = dchitlist[i2];
297 MdcxHit* t3 = dchitlist[i3];
298 seg.append(t1); seg.append(t2); seg.append(t3);
299 double dx,dy,d0;
300 if (amb==0){dx=t3->xneg()-t1->xneg(); dy=t3->yneg()-t1->yneg(); d0=-t1->d();}
301 if (amb==1){dx=t3->xneg()-t1->xpos(); dy=t3->yneg()-t1->ypos(); d0= t1->d();}
302 if (amb==2){dx=t3->xpos()-t1->xneg(); dy=t3->ypos()-t1->yneg(); d0=-t1->d();}
303 if (amb==3){dx=t3->xpos()-t1->xpos(); dy=t3->ypos()-t1->ypos(); d0= t1->d();}
304
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);
307 hel.SetTurnFlag(1);
308 MdcxFittedHel temp(seg,hel,1.0);
309
310 if (3 == m_debug) {
311 cout<<"trial3 amb "<<amb
312 << ": phi0 " << phi0 << " d0 " << d0
313 << " dx " << dx << " dy " << dy << endl;
314 }
315 return temp;
316}
float d(MdcxHel &hel) const
Definition: MdcxHit.cxx:160

◆ trial() [2/4]

MdcxFittedHel MdcxFindSegs::trial ( int  i1,
int  i2,
int  i3,
int  amb 
)
protected

◆ trial() [3/4]

MdcxFittedHel MdcxFindSegs::trial ( int  i1,
int  i2,
int  i3,
int  i4,
int  amb 
)
protected

Definition at line 270 of file MdcxFindSegs.cxx.

270 {
272 MdcxHit* t1 = dchitlist[i1]; MdcxHit* t2 = dchitlist[i2];
273 MdcxHit* t3 = dchitlist[i3]; MdcxHit* t4 = dchitlist[i4];
274 seg.append(t1); seg.append(t2); seg.append(t3); seg.append(t4);
275 double dx, dy, d0;
276 if (amb==0){dx=t4->xneg()-t1->xneg(); dy=t4->yneg()-t1->yneg(); d0=-t1->d();}
277 if (amb==1){dx=t4->xneg()-t1->xpos(); dy=t4->yneg()-t1->ypos(); d0= t1->d();}
278 if (amb==2){dx=t4->xpos()-t1->xneg(); dy=t4->ypos()-t1->yneg(); d0=-t1->d();}
279 if (amb==3){dx=t4->xpos()-t1->xpos(); dy=t4->ypos()-t1->ypos(); d0= t1->d();}
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);
282 hel.SetTurnFlag(1);
283 MdcxFittedHel temp(seg, hel, 1.0);
284 if (3 == m_debug) {
285 cout<<"trial4 amb "<<amb
286 << ": phi0 " << phi0 << " d0 " << d0
287 << " dx " << dx << " dy " << dy << endl;
288 //temp.FitPrint();
289 }
290 return temp;
291}

Referenced by process().

◆ trial() [4/4]

MdcxFittedHel MdcxFindSegs::trial ( int  i1,
int  i2,
int  i3,
int  i4,
int  amb 
)
protected

Member Data Documentation

◆ dchitlist

HepAList< MdcxHit > MdcxFindSegs::dchitlist
protected

◆ fithel

MdcxFittedHel MdcxFindSegs::fithel
protected

◆ gm

const MdcDetector * MdcxFindSegs::gm
protected

◆ m_debug

int MdcxFindSegs::m_debug
protected

◆ m_segPat

MdcxSegPatterns MdcxFindSegs::m_segPat
protected

Definition at line 61 of file InstallArea/include/MdcxReco/MdcxReco/MdcxFindSegs.h.

Referenced by process().

◆ MdcxSeglist

HepAList< MdcxSeg > MdcxFindSegs::MdcxSeglist
protected

◆ nseg

int MdcxFindSegs::nseg
protected

◆ sl

int MdcxFindSegs::sl
protected

◆ wireGroups

int MdcxFindSegs::wireGroups = { { {0} } }
staticprotected

Definition at line 63 of file InstallArea/include/MdcxReco/MdcxReco/MdcxFindSegs.h.

Referenced by initWireGroups(), and process().


The documentation for this class was generated from the following files: