BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcSegFinder Class Reference

#include <MdcSegFinder.h>

Public Member Functions

 MdcSegFinder (int useAllAmbig)
 
 ~MdcSegFinder ()
 
int createSegs (const MdcDetector *gm, MdcSegList &segs, const MdcMap< const MdcHit *, MdcSegUsage * > &usedHits, const MdcHitMap *map, double tbunch)
 
MdcSegPatternsthePattList ()
 

Detailed Description

Definition at line 36 of file MdcSegFinder.h.

Constructor & Destructor Documentation

◆ MdcSegFinder()

MdcSegFinder::MdcSegFinder ( int  useAllAmbig)

Definition at line 60 of file MdcSegFinder.cxx.

60 :
61 patternList(useAllAmbig) {
62 //-------------------------------------------------------------------------
63
64 }

◆ ~MdcSegFinder()

MdcSegFinder::~MdcSegFinder ( )
inline

Definition at line 40 of file MdcSegFinder.h.

40{ };

Member Function Documentation

◆ createSegs()

int MdcSegFinder::createSegs ( const MdcDetector gm,
MdcSegList segs,
const MdcMap< const MdcHit *, MdcSegUsage * > &  usedHits,
const MdcHitMap map,
double  tbunch 
)

Definition at line 67 of file MdcSegFinder.cxx.

69 {
70 //-------------------------------------------------------------------------
71 // Forms all possible Segs of hits to act as candidate tracks
72 // Construct group of 8 hits; translate hit wires into bit-mapped word
73 // and look up valid patterns (if any) for this group.
74
75 _addHits = segs.segPar()->addHits;
76 int nSegs = 0;
77 int newSegs;
78 unsigned int groupWord;
79 MdcHit *groupHits[8];
80 int lPrevHit = 0; // flags that 2nd layer was hit in last group
81 //which layer/wire to look at for each hit in group
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 // Loop through the superlayers
87 const MdcSuperLayer *slayer = gm->firstSlay();
88 while (slayer != 0) {
89 const MdcLayer *layArray[4];
90 int wireIndex[4];
91
92
93 // layArray[0] = slayer->firstLayer();
94 // for (int i = 1; i < 4; i++) layArray[i] = gm->nextLayer(layArray[i-1]);
95 int nslay = slayer->nLayers();
96 for (int i = 0; i < nslay; i++) layArray[i] = slayer->layer(i);
97 if(nslay != 4) layArray[3] = 0;
98
99
100 // std::cout<<"-------------super layer----- "<<slayer->Id() << " nlayer "<<nslay<<std::endl;
101 //for (int i = 0; i < nslay; i++) std::cerr<<layArray[i]->Id()<<" "<<layArray[i]->nWires()<<"\n";
102 //slayer = slayer->next();continue;
103
104
105
106 // Loop over cells (index refers to cells in 2nd layer of superlayer)
107 for (int cellIndex = 0; cellIndex < layArray[1]->nWires(); cellIndex++) {
108 //yzhang change FIXME
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;//nWires over No.4 slayer is uniform
113 if ( (slayer->slayNum() > 9) && (i==3) ) break;//stop when get last layer
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 //zhangy change
129 wireIndex[i] = mdcWrapWire(wireIndex[i], layArray[i]->nWires());
130 }
131 // Form group of 8 wires
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()); //handle wrap-around
143 MdcHit* thisHit = map->hitWire(laynum, wire);
144 if (thisHit != 0) {
145 if ( !usedHits.get(thisHit)->deadHit() ) {
146 groupHits[ii] = thisHit;
147 groupWord |= bitWord;
148 nGroup++;
149 } else {
150 // cout << "Skipping hit " << endl;
151 }
152 }
153 // Quit if no hits in 1st 2 layers or 1 hit in 3 layers
154 if ( (ii == 2 && nGroup < 1) || (ii == 4 && nGroup < 2) ) break;
155 bitWord <<= 1;
156 }
157 if (nGroup < 3) continue;
158
159 //int lastWire = mdcWrapWire(cellIndex - 1, layArray[1]->nWires());//2011-08-10
160 int lastWire = mdcWrapWire(cellIndex - 1, layArray[0]->nWires());
161 if (map->hitWire(layArray[1]->layNum(), lastWire) != 0) lPrevHit = 1;
162 // if (layArray[1]->hitWire(lastWire) != 0) lPrevHit = 1;
163 else lPrevHit = 0;
164
165 // Try all allowed 4-hit patterns for this group (if any)
166 int nPatt = patternList.npatt4[groupWord];
167
168 if ((layArray[1]->layNum()==5) && (cellIndex ==46)) {
169 for(int i=0;i<4;i++){
170 //std::cout<<__FILE__<<" "<<__LINE__<<"====("<<layArray[i]->layNum()<<","<< wireIndex[i]<<")" << std::endl;
171 }
172 //std::cout<<__FILE__<<" "<<__LINE__<< " groupWord:"<<groupWord<<" nPatt:"<<nPatt<< std::endl;
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 // If unsuccessful, try 3-hit patterns ???? may want to try 2nd pass here
184 if (!segs.segPar()->find3[slayer->index()]) continue;
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 } // cellIndex loop
202
203 slayer = slayer->next();
204 } //superlayer loop
205
206 if (nSegs > 0) {
207 segs.massageSegs();
208 segs.resetSeed(gm);
209 }
210
211 nSegs = segs.count();
212
213 if (5 == segs.segPar()->lPrint){
214 cout << "Number of Segs found: " << nSegs << "\n";
215 }
216
217 return nSegs;
218}
const MdcSuperLayer * firstSlay(void) const
Definition: MdcDetector.h:46
MdcHit * hitWire(int lay, int wire) const
Definition: MdcHitMap.h:34
Definition: MdcHit.h:44
MdcSWire * getWire(int wire) const
Definition: MdcLayer.h:52
int nWires(void) const
Definition: MdcLayer.h:30
int layNum(void) const
Definition: MdcLayer.h:29
bool get(const K &theKey, V &theAnswer) const
double phiE(void) const
Definition: MdcSWire.h:51
int count() const
Definition: MdcSegList.cxx:419
void resetSeed(const MdcDetector *gm)
Definition: MdcSegList.cxx:57
MdcSegParams * segPar()
Definition: MdcSegList.h:38
int find3[11]
Definition: MdcSegParams.h:31
int * allowedPatt3[256]
int * allowedPatt4[256]
const MdcSuperLayer * next(void) const
Definition: MdcSuperLayer.h:39
int nLayers(void) const
Definition: MdcSuperLayer.h:44
const MdcLayer * layer(int i) const
Definition: MdcSuperLayer.h:45
int index(void) const
Definition: MdcSuperLayer.h:20
int slayNum(void) const
Definition: MdcSuperLayer.h:43
int mdcWrapWire(int wireIn, int nCell)
Definition: mdcWrapWire.h:6

◆ thePattList()

MdcSegPatterns * MdcSegFinder::thePattList ( )
inline

Definition at line 43 of file MdcSegFinder.h.

43{return &patternList;}

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