8#include "GaudiKernel/StatusCode.h"
9#include "GaudiKernel/Bootstrap.h"
34 {11.9, 9.72, 6.26, 4.86, 3.81, 2.37, 2.08, 1.76, 1.53, 2.33, 1.88};
47 if (_complecated_segments) _complecated_segments->
deleteAll();
58 int n = _segments.
length();
59 for (
int i = 0; i^n; i++){
64 int stat =
s->examine();
83 _complecated_segments->
append(
s);
92 connect_short_segments(inner_short,outer_short);
93 connect_singleHit(inner_short);
94 connect_singleHit(outer_short);
95 connect_singleHit(mid_short);
98 for (
int i = 0; i^n; i++){
99 _segments[i]->update();
101 _segments[i]->printout();
110 if( _superLayerId>9 )
return;
112 int n = _segments.
length();
115 float tdc[30][4]={0.},r[4]={0.},phi[4]={0.};
119 StatusCode sc = Gaudi::svcLocator()->service(
"MdcGeomSvc", mdcGeomSvc);
121 float T1=0.5*0.1*(mdcGeomSvc->
Layer(4*_superLayerId+0)->
PCSiz())/0.004;
122 float T2=0.5*0.1*(mdcGeomSvc->
Layer(4*_superLayerId+1)->
PCSiz())/0.004;
123 float T3=0.5*0.1*(mdcGeomSvc->
Layer(4*_superLayerId+2)->
PCSiz())/0.004;
124 float T4=0.5*0.1*(mdcGeomSvc->
Layer(4*_superLayerId+3)->
PCSiz())/0.004;
126 for (
int i = 0; i^n; i++){
136 for(
int j=0;j<hits.
length();j++){
147 phi[layerId%4]=h.
phi();
151 tdc[i][layerId%4]=h.
time();
152 r[layerId%4]=h.
layer().
r();
156 if(tdc[i][0]!=0 && tdc[i][1]!=0 && tdc[i][2]!=0 && tdc[i][3]!=0 && (wireId[0]==wireId[1]&& wireId[0]==wireId[2] && wireId[0]==wireId[3] || wireId[0]==wireId[1]-1 && wireId[0]==wireId[2]&& wireId[1]==wireId[3])){
159 float r0=r[0]-r[1]-(r[2]-r[1])/2;
160 float r1=-(r[2]-r[1])/2;
161 float r2=(r[2]-r[1])/2;
162 float r3=r[3]-r[2]+(r[2]-r[1])/2;
164 float t_i = tdc[i][0]+tdc[i][2];
165 float t_j = tdc[i][1]+tdc[i][3];
169 float r_2k= r0*r0+r1*r1+r2*r2+r3*r3;
170 float rt_i = r0*tdc[i][0]+r2*tdc[i][2];
171 float rt_j = r1*tdc[i][1]+r3*tdc[i][3];
172 float rl_j = r1*T2+r3*T4;
174 float deno= 4*r_2k-2*(r_i*r_i+r_j*r_j);
177 float Pa=(4*(rt_i-rt_j+rl_j)-(t_i+t_j-l_j)*(r_i-r_j)-(t_i-t_j+l_j)*(r_i+r_j))/deno;
178 float Pb= 0.25*(t_i-t_j+l_j-(r_i+r_j) * Pa);
179 float Ang=fabs(90.-fabs(atan(Pa)*180./3.141593));
181 t0c = -0.25*((r_i-r_j)*Pa-t_i-t_j+l_j);
183 float pa1=(tdc[i][0]-tdc[i][2])/(r0-r2);
184 float pa2=(T4-T2-tdc[i][3]+tdc[i][1])/(r3-r1);
193 chi2=(tdc[i][0]-t0c-r0 * Pa-Pb)*(tdc[i][0]-t0c-r0 * Pa-Pb)+(T2-tdc[i][1]+t0c-r1 * Pa-Pb)*(T2-tdc[i][1]+t0c-r1 * Pa-Pb)+(tdc[i][2]-t0c-r2 * Pa-Pb)*(tdc[i][2]-t0c-r2 * Pa-Pb) + (T4-tdc[i][3]+t0c-r3 * Pa-Pb)*(T4-tdc[i][3]+t0c-r3 * Pa-Pb);
203 float pa=-((r[0]+r[2]-2*r[1])*(tdc[i][0]+tdc[i][2])-2*(r[0]-r[1])*tdc[i][0]-2*(r[2]-r[1])*tdc[i][2])/((r[0]-r[2])*(r[0]-r[2]));
204 //float pa=(tdc[i][2]-tdc[i][0])/(r[2]-r[0]);
205 float pb=0.25*(tdc[i][0]-2*tdc[i][1]+tdc[i][2]+2.*T2-(r[0]+r[2]-2*r[1])*pa);
206 float Ang=fabs(90.-fabs(atan(pa)*180./3.141593));
208 t0c=-((r[0]+r[2]-2*r[1])*pa + 3.*pb - tdc[i][0]+tdc[i][1]-tdc[i][2]-T2);
209 //t0c=0.5*(tdc[i][1]+tdc[i][2]-(r[1]-r[2])*pa-T2);
210 chi2=(tdc[i][0]-t0c-pa*(r[0]-r[1])-pb)*(tdc[i][0]-t0c-pa*(r[0]-r[1])-pb)+(T2-tdc[i][1]+t0c-pb)*(T2-tdc[i][1]+t0c-pb)+(tdc[i][2]-t0c-pa*(r[2]-r[1])-pb)*(tdc[i][2]-t0c-pa*(r[2]-r[1])-pb);
213 else if(tdc[i][1]!=0 && tdc[i][2]!=0 && tdc[i][3]!=0 && (wireId[1]==wireId[2]||wireId[1]==wireId[2]+1) && wireId[3]==wireId[1]){
216 float pa=-((r[1]+r[3]-2*r[2])*(tdc[i][1]+tdc[i][3])-2*(r[1]-r[2])*tdc[i][1]-2*(r[3]-r[2])*tdc[i][3])/((r[1]-r[3])*(r[1]-r[3]));
217 float pb=0.25*(tdc[i][1]-2*tdc[i][2]+tdc[i][3]+2.*T3-(r[1]+r[3]-2*r[2])*pa);
219 t0c=-((r[1]+r[3]-2*r[2])*pa + 3.*pb - tdc[i][1]+tdc[i][2]-tdc[i][3]-T3);
220 chi2=(tdc[i][1]-t0c-pa*(r[1]-r[2])-pb)*(tdc[i][1]-t0c-pa*(r[1]-r[2])-pb)+(T3-tdc[i][2]+t0c-pb)*(T3-tdc[i][2]+t0c-pb)+(tdc[i][3]-t0c-pa*(r[3]-r[2])-pb)*(tdc[i][3]-t0c-pa*(r[3]-r[2])-pb);
233 Estime[_superLayerId].append(t0c);
239 _complecated_segments->
append(_segments[i]);
240 for(
int k=0;k<4;k++){
249FTSuperLayer::clustering(
void)
259 if (!_wireHits.
length())
return;
264 }
while((hptr++)!=last);
272 int n = hits->
append(*hptr);
274 for (
int j = 0; j^n; j++){
275 const unsigned int checked = (*hits)[j]->state();
291 _singleHits.
append(*hptr);
294 }
while((hptr++)!=last);
303 int n = inner_short.
length();
304 int m = outer_short.
length();
305 for (
int i = 0; i^n; i++){
308 const FTLayer & in_outerBound = in_outerBoundHit.
layer();
311 int min_dphi_index = -1;
312 float min_dphi = 2*
M_PI;
313 int dLayer_cache = -1;
314 float out_innerPhi, D_phi;
315 for (
int j = 0; j^m; j++) {
316 const int out_innerLayerId
317 = (outer_short[j]->innerBoundHits().
first())->layer().localLayerId();
318 int dLayer_cache_tmp = out_innerLayerId - in_outerBound.
localLayerId();
319 if (dLayer_cache_tmp < 1)
continue;
320 out_innerPhi = outer_short[j]->incomingPhi();
321 D_phi= fabs(in_outerPhi - out_innerPhi);
322 if (D_phi >
M_PI) D_phi = 2*
M_PI - D_phi;
323 if (D_phi < min_dphi) {
326 dLayer_cache = dLayer_cache_tmp;
329 if (min_dphi_index < 0)
continue;
331 switch (dLayer_cache) {
333 if (min_dphi >
_maxDphi[_superLayerId]*
M_PI/180.)
continue;
336 if (min_dphi >
_maxDphi[_superLayerId]*
M_PI/120.)
continue;
339 if (min_dphi >
_maxDphi[_superLayerId]*
M_PI/80.)
continue;
345 FTSegment * outer = outer_short[min_dphi_index];
346 n = inner_short.
remove(i);
347 m = outer_short.
remove(min_dphi_index);
361 int n = short_sgmnts.
length();
362 int m = _singleHits.
length();
363 for (
int i = 0; i^n; i++){
365 const FTWire & outerBoundHit = *
s.outerBoundHits().first();
366 const FTWire & innerBoundHit = *
s.innerBoundHits().first();
369 float outerPhi =
s.outgoingPhi();
370 float innerPhi =
s.incomingPhi();
372 int min_dphi_index = -1;
373 float min_dphi = 2*
M_PI;
374 int dLayer_cache = -1;
375 bool inner_flag_cache;
376 for (
int j = 0; j^m; j++) {
377 const FTWire * h = _singleHits[j];
379 int dLayer_cache_tmp = -1;
380 bool inner_flag_cache_tmp;
383 if ((dLayer_cache_tmp=innerBound.
localLayerId()-hLocalLayerId) > 0) {
384 D_phi = fabs(innerPhi - h->
phi());
385 inner_flag_cache_tmp =
true;
386 }
else if ((dLayer_cache_tmp=hLocalLayerId-outerBound.
localLayerId()) > 0) {
387 D_phi = fabs(outerPhi - h->
phi());
388 inner_flag_cache_tmp =
false;
392 if (D_phi >
M_PI) D_phi = 2*
M_PI - D_phi;
394 if (D_phi < min_dphi) {
397 dLayer_cache = dLayer_cache_tmp;
398 inner_flag_cache = inner_flag_cache_tmp;
403 if (min_dphi_index >= 0) {
404 switch (dLayer_cache) {
406 if (min_dphi <
_maxDphi[_superLayerId]*
M_PI/180.) not_append = 0;
409 if (min_dphi <
_maxDphi[_superLayerId]*
M_PI/120.) not_append = 0;
412 if (min_dphi <
_maxDphi[_superLayerId]*
M_PI/80.) not_append = 0;
420 if (inner_flag_cache) {
421 s.connect_inner(_singleHits[min_dphi_index]);
423 s.connect_outer(_singleHits[min_dphi_index]);
426 m = _singleHits.
remove(min_dphi_index);
431 if (!_superLayerId) _complecated_segments->
append(&
s);
442 int n = _segments.
length();
443 for (
int i = 0; i^n; i++){
444 if (_segments[i]->track())
continue;
445 _complecated_segments->
append(_segments[i]);
453FTSuperLayer::showBinary(
unsigned src)
457 unsigned bit = (mask&src) ? 1 : 0;
#define FTWireHitAppended
#define FTWireHitAppendedOrInvalid
const float r(void) const
returns r form origin
const int localLayerId(void) const
returns local-layer ID
const int layerId(void) const
returns layer ID
T & first(void) const
returns the first object in the list
void deleteAll(void)
delete all object and clear(allocated memory remains same)
void clear(void)
clear lists but the allocated memory remains same
int remove(int &)
remove objects by index and returns decremented index and length
T * lastPtr(void) const
returns the pointer of last object
int length(void) const
returns the length of the list
int append(const T &x)
append an object into the end of the list
T * firstPtr(void) const
returns the pointer of first object
float outgoingPhi(void) const
returns phi of outgoing position
FTList< FTWire * > & wireHits(void) const
returns wire-hit list
void connect_outer(const FTList< FTWire * > &, const FTList< FTWire * > &)
connect short segments
FTList< FTWire * > & outerBoundHits(void) const
returns outerBoundHits
static const float _maxDphi[11]
static MdcParameter * param
const int superLayerId(void) const
returns super-layer ID
void mkSegmentList(void)
create segment lists
void reduce_noise(FTList< float >(&Estime)[10])
calculate t0 and Chi2 from segment-fit in every superlayer
void reAppendSalvage(void)
append segments which are not used for tracks to the list for salvage
void clear(void)
clear object
float phi(void) const
returns phi
FTWire ** neighborPtr(void)
returns pointer of neighbor array
unsigned state(void) const
returns state
const FTLayer & layer(void) const
returns layer
void chk_left_and_right(void)
check neighbors of phi-side and raise invalid flag if both hits
const int localId(void) const
returns local ID
float time(void) const
rerurns TDC time(after t0 subtraction)
virtual const MdcGeoLayer *const Layer(unsigned id)=0
static MdcParameter * instance()