18 int gl3Track::addTrack (
gl3Track* piece ){
20 double w1 = 1./ ( dpt * dpt ) ;
21 double w2 = 1./ ( piece->dpt * piece->dpt ) ;
22 double wsum = w1 + w2 ;
23 pt = ( w1 * pt + w2 * piece->pt ) / wsum ;
26 w1 = 1./ ( dpsi * dpsi ) ;
27 w2 = 1./ ( piece->dpsi * piece->dpsi ) ;
29 psi = ( w1 * psi + w2 * piece->psi ) / wsum ;
30 dpsi = 1./sqrt(wsum) ;
32 w1 = 1./ ( dtanl * dtanl ) ;
33 w2 = 1./ ( piece->dtanl * piece->dtanl ) ;
35 tanl = ( w1 * tanl + w2 * piece->tanl ) / wsum ;
36 dtanl = 1./sqrt(wsum);
38 w1 = 1./ ( dz0 * dz0 ) ;
39 w2 = 1./ ( piece->dz0 * piece->dz0 ) ;
41 z0 = ( w1 * z0 + w2 * piece->z0 ) / wsum ;
44 if ( piece->innerMostRow < innerMostRow ) innerMostRow = piece->innerMostRow ;
45 if ( piece->outerMostRow > outerMostRow ) outerMostRow = piece->outerMostRow ;
47 nHits += piece->nHits ;
51 chi2[0] += piece->chi2[0] ;
52 chi2[1] += piece->chi2[1] ;
63 void gl3Track::dropHits (
int rest,
int rowMin,
int rowMax ) {
75 while ( counter < nHits && cHit ) {
76 if ( ( rest > 0 && cHit->getRowSector()%2 == rest ) ||
77 cHit->getRowSector()%100 < rowMin ||
78 cHit->getRowSector()%100 > rowMax ) {
81 cHit = (
gl3Hit *)(cHit->nextHit) ;
82 if ( previousHit ) previousHit->nextHit = cHit ;
84 deleteHit->trackId = 0 ;
85 deleteHit->nextHit = 0 ;
88 if ( newCounter == 0 ) firstHit = cHit ;
90 cHit = (
gl3Hit *)(cHit->nextHit) ;
111 register int areaIndex ;
119 i_phi = (int)(( psi - getPara()->phiMinTrack ) / getPara()->phiSliceTrack + 1 );
124 if ( i_phi >= getPara()->nPhiTrackPlusOne ) {
126 i_phi = getPara()->nPhiTrack ;
131 i_eta = (int)(( eta - getPara()->etaMinTrack ) / getPara()->etaSliceTrack + 1 );
136 if ( i_eta >= getPara()->nEtaTrackPlusOne ) {
138 i_eta = getPara()->nEtaTrack ;
145 for ( ip = max(i_phi-1,1) ; ip < min(i_phi+2,getPara()->nPhiTrackPlusOne) ; ip++ ) {
146 for ( ie = max(i_eta-1,1) ; ie < min(i_eta+2,getPara()->nEtaTrackPlusOne) ; ie++ ) {
147 areaIndex = ip * getPara()->nEtaTrackPlusOne + ie ;
151 for ( i_track = (
gl3Track *)trackArea[areaIndex].first ;
152 i_track != 0 && !track_merged ;
153 i_track = i_track->getNextTrack() ) {
157 if ( i_track->flag < 0 ) continue ;
164 short p1 = i_track->innerMostRow ;
165 short p2 = i_track->outerMostRow ;
166 short t1 = innerMostRow ;
167 short t2 = outerMostRow ;
168 if ( p1 < t1 && p2 > t1 ) continue ;
169 if ( p1 < t2 && p2 > t2 ) continue ;
170 if ( p1 > t1 && p2 < t2 ) continue ;
171 if ( t1 < p1 && t2 > p1 ) continue ;
172 if ( t1 < p2 && t2 > p2 ) continue ;
173 if ( t1 > p1 && t2 < p2 ) continue ;
177 double dr0 = fabs(r0-i_track->r0) ;
181 if ( dr0 < getPara()->distanceMerge ) {
182 if ( fabs(eta-i_track->eta) > getPara()->detaMerge ) continue ;
184 delta_psi = fabs(psi - i_track->psi) ;
185 if ( delta_psi > getPara()->dphiMerge && delta_psi < twoPi - getPara()->dphiMerge ) continue ;
189 double dx0 = fabs(r0*cos(phi0)-i_track->r0*cos(i_track->phi0));
190 if ( dx0 > getPara()->distanceMerge ) continue ;
191 double dy0 = fabs(r0*sin(phi0)-i_track->r0*sin(i_track->phi0));
192 if ( dy0 > getPara()->distanceMerge ) continue ;
193 double dz0 = fabs(z0-i_track->z0);
194 if ( dz0 > getPara()->distanceMerge ) continue ;
200 i_track->addTrack (
this ) ;
201 track_merged = i_track ;
209 short whichTrack = 0 ;
210 if ( r0 > i_track->r0 ) {
211 originalTrack = *this ;
214 updateToRadius ( i_track->r0 ) ;
218 originalTrack = *i_track ;
220 i_track->updateToRadius ( r0 ) ;
226 if ( fabs(r0*cos(phi0)-i_track->r0*cos(i_track->phi0)) < getPara()->distanceMerge
227 && fabs(r0*sin(phi0)-i_track->r0*sin(i_track->phi0)) < getPara()->distanceMerge
228 && fabs(z0-i_track->z0) < getPara()->distanceMerge ) {
232 if ( fabs(eta-i_track->eta) < 0.9 && fabs(psi - i_track->psi) < 0.9
233 && fabs(psi - i_track->psi) < 5.9 ) {
239 i_track->addTrack (
this ) ;
240 track_merged = i_track ;
248 *
this = originalTrack ;
250 *i_track = originalTrack ;
254 if ( getPara()->debugLevel > 1 )
255 LOG(ERR,
" \n Track %d merge into %d ", this->
id, i_track->id,0,0,0 ) ;
262 if ( !track_merged ) {
263 areaIndex = i_phi * getPara()->nEtaTrackPlusOne + i_eta ;
264 if ( trackArea[areaIndex].first == 0 )
265 trackArea[areaIndex].first =
266 trackArea[areaIndex].last = (
void *)
this ;
268 ((
gl3Track *)trackArea[areaIndex].last)->nextTrack = this ;
269 trackArea[areaIndex].last = (
void *)
this ;
272 return track_merged ;
277 void gl3Track::Print (
int level )
285 pmom = (double)sqrt ( pz * pz + pt * pt ) ;
286 LOG(ERR,
" =======> Track %d <======== \n",
id ,0,0,0,0) ;
287 LOG(ERR,
" p, pt, q %7.2f %7.2f %2d \n", pmom, pt, q ,0,0) ;
290 LOG(ERR,
" r0, z0, nHits %7.2f %7.2f %d \n ", r0, z0, nHits,0,0 ) ;
291 LOG(ERR,
" phi0, psi, tanl %7.2f %7.2f %7.2f \n", phi0, psi, tanl,0,0 ) ;
295 LOG(ERR,
" chi2 (s,z) %6.2e %6.2e \n", chi2[0], chi2[1],0,0,0 ) ;
298 if ( fmod((
double)level,10.) > 0 ) {
299 LOG(ERR,
" *** Clusters in this track *** \n",0,0,0,0,0 ) ;
300 for ( startLoop() ; done() ; nextHit() ) {
301 ((
gl3Hit *)currentHit)->print ( ) ;
310 Ftf3DHit closest = closestApproach(vertex.x,vertex.y);
311 dca = sqrt((closest.x - vertex.x)*(closest.x - vertex.x) +
312 (closest.y - vertex.y)*(closest.y - vertex.y) +
313 (closest.z - vertex.z)*(closest.z - vertex.z));