1 #include "Stl3Util/gl3/gl3Track.h"
3 #include "Stl3Util/base/FtfLog.h"
21 int gl3Track::addTrack (
gl3Track* piece ){
23 double w1 = 1./ ( dpt * dpt ) ;
24 double w2 = 1./ ( piece->dpt * piece->dpt ) ;
25 double wsum = w1 + w2 ;
26 pt = ( w1 * pt + w2 * piece->pt ) / wsum ;
27 dpt = 1./::sqrt(wsum);
29 w1 = 1./ ( dpsi * dpsi ) ;
30 w2 = 1./ ( piece->dpsi * piece->dpsi ) ;
32 psi = ( w1 * psi + w2 * piece->psi ) / wsum ;
33 dpsi = 1./::sqrt(wsum) ;
35 w1 = 1./ ( dtanl * dtanl ) ;
36 w2 = 1./ ( piece->dtanl * piece->dtanl ) ;
38 tanl = ( w1 * tanl + w2 * piece->tanl ) / wsum ;
39 dtanl = 1./::sqrt(wsum);
41 w1 = 1./ ( dz0 * dz0 ) ;
42 w2 = 1./ ( piece->dz0 * piece->dz0 ) ;
44 z0 = ( w1 * z0 + w2 * piece->z0 ) / wsum ;
45 dz0 = 1./::sqrt(wsum);
47 if ( piece->innerMostRow < innerMostRow ) innerMostRow = piece->innerMostRow ;
48 if ( piece->outerMostRow > outerMostRow ) outerMostRow = piece->outerMostRow ;
50 nHits += piece->nHits ;
54 chi2[0] += piece->chi2[0] ;
55 chi2[1] += piece->chi2[1] ;
66 void gl3Track::dropHits (
int rest,
int rowMin,
int rowMax ) {
76 while ( counter < nHits && cHit ) {
77 if ( ( rest > 0 && cHit->getRowSector()%2 == rest ) ||
78 cHit->getRowSector()%100 < rowMin ||
79 cHit->getRowSector()%100 > rowMax ) {
82 cHit = (
gl3Hit *)(cHit->nextHit) ;
83 if ( previousHit ) previousHit->nextHit = cHit ;
85 deleteHit->trackId = 0 ;
86 deleteHit->nextHit = 0 ;
89 if ( newCounter == 0 ) firstHit = cHit ;
91 cHit = (
gl3Hit *)(cHit->nextHit) ;
112 register int areaIndex ;
120 i_phi = (int)(( psi - getPara()->phiMinTrack ) / getPara()->phiSliceTrack + 1 );
125 if ( i_phi >= getPara()->nPhiTrackPlusOne ) {
127 i_phi = getPara()->nPhiTrack ;
132 i_eta = (int)(( eta - getPara()->etaMinTrack ) / getPara()->etaSliceTrack + 1 );
137 if ( i_eta >= getPara()->nEtaTrackPlusOne ) {
139 i_eta = getPara()->nEtaTrack ;
146 for ( ip = max(i_phi-1,1) ; ip < min(i_phi+2,getPara()->nPhiTrackPlusOne) ; ip++ ) {
147 for ( ie = max(i_eta-1,1) ; ie < min(i_eta+2,getPara()->nEtaTrackPlusOne) ; ie++ ) {
148 areaIndex = ip * getPara()->nEtaTrackPlusOne + ie ;
152 for ( i_track = (
gl3Track *)trackArea[areaIndex].first ;
153 i_track != 0 && !track_merged ;
154 i_track = i_track->getNextTrack() ) {
158 if ( i_track->flag < 0 ) continue ;
165 short p1 = i_track->innerMostRow ;
166 short p2 = i_track->outerMostRow ;
167 short t1 = innerMostRow ;
168 short t2 = outerMostRow ;
169 if ( p1 < t1 && p2 > t1 ) continue ;
170 if ( p1 < t2 && p2 > t2 ) continue ;
171 if ( p1 > t1 && p2 < t2 ) continue ;
172 if ( t1 < p1 && t2 > p1 ) continue ;
173 if ( t1 < p2 && t2 > p2 ) continue ;
174 if ( t1 > p1 && t2 < p2 ) continue ;
178 double dr0 = fabs(r0-i_track->r0) ;
182 if ( dr0 < getPara()->distanceMerge ) {
183 if ( fabs(eta-i_track->eta) > getPara()->detaMerge ) continue ;
185 delta_psi = fabs(psi - i_track->psi) ;
186 if ( delta_psi > getPara()->dphiMerge && delta_psi < twoPi - getPara()->dphiMerge ) continue ;
190 double dx0 = fabs(r0*cos(phi0)-i_track->r0*cos(i_track->phi0));
191 if ( dx0 > getPara()->distanceMerge ) continue ;
192 double dy0 = fabs(r0*sin(phi0)-i_track->r0*sin(i_track->phi0));
193 if ( dy0 > getPara()->distanceMerge ) continue ;
194 double dz0 = fabs(z0-i_track->z0);
195 if ( dz0 > getPara()->distanceMerge ) continue ;
201 i_track->addTrack (
this ) ;
202 track_merged = i_track ;
210 short whichTrack = 0 ;
211 if ( r0 > i_track->r0 ) {
212 originalTrack = *this ;
215 updateToRadius ( i_track->r0 ) ;
219 originalTrack = *i_track ;
221 i_track->updateToRadius ( r0 ) ;
227 if ( fabs(r0*cos(phi0)-i_track->r0*cos(i_track->phi0)) < getPara()->distanceMerge
228 && fabs(r0*sin(phi0)-i_track->r0*sin(i_track->phi0)) < getPara()->distanceMerge
229 && fabs(z0-i_track->z0) < getPara()->distanceMerge ) {
233 if ( fabs(eta-i_track->eta) < 0.9 && fabs(psi - i_track->psi) < 0.9
234 && fabs(psi - i_track->psi) < 5.9 ) {
240 i_track->addTrack (
this ) ;
241 track_merged = i_track ;
249 *
this = originalTrack ;
251 *i_track = originalTrack ;
255 if ( getPara()->debugLevel > 1 )
256 ftfLog (
" \n Track %d merge into %d ", this->
id, i_track->id ) ;
263 if ( !track_merged ) {
264 areaIndex = i_phi * getPara()->nEtaTrackPlusOne + i_eta ;
265 if ( trackArea[areaIndex].first == 0 )
266 trackArea[areaIndex].first =
267 trackArea[areaIndex].last = (
void *)
this ;
269 ((
gl3Track *)trackArea[areaIndex].last)->nextTrack = this ;
270 trackArea[areaIndex].last = (
void *)
this ;
273 return track_merged ;
278 void gl3Track::Print (
int level )
286 pmom = (double)sqrt ( pz * pz + pt * pt ) ;
287 ftfLog (
" =======> Track %d <======== \n",
id ) ;
288 ftfLog (
" p, pt, q %7.2f %7.2f %2d \n", pmom, pt, q ) ;
291 ftfLog (
" r0, z0, nHits %7.2f %7.2f %d \n ", r0, z0, nHits ) ;
292 ftfLog (
" phi0, psi, tanl %7.2f %7.2f %7.2f \n", phi0, psi, tanl ) ;
294 else ftfLog (
"\n " ) ;
297 ftfLog (
" chi2 (s,z) %6.2e %6.2e \n", chi2[0], chi2[1] ) ;
299 else ftfLog (
"\n " ) ;
302 if ( fmod((
double)level,10.) > 0 ) {
303 ftfLog (
" *** Clusters in this track *** \n" ) ;
304 for ( startLoop() ; done() ; nextHit() ) {
305 ((
gl3Hit *)currentHit)->print ( ) ;