18#include "TStopwatch.h"
43#ifdef TRIP_PERFORMANCE
46#ifdef DOUB_PERFORMANCE
67inline void L1Algo::f10(
75 const int end_lh = start_lh+n1;
76 for (
int ilh = start_lh, i1 = 0; ilh < end_lh; ilh++, i1++){
82 u_front[i1_V][i1_4] = hitl.
U();
83 u_back [i1_V][i1_4] = hitl.
V();
84 zPos [i1_V][i1_4] = hitl.
Z();
85 if (du_front) du_front[i1_V][i1_4] = hitl.
DU();
86 if (du_back) du_back [i1_V][i1_4] = hitl.
DV();
92inline void L1Algo::f11(
113 for(
int i1_V=0; i1_V<n1_V; i1_V++ ){
119 fvec &u = u_front[i1_V];
120 fvec &
v = u_back [i1_V];
122 fvec zl = zPos [i1_V];
124 fvec dzli = 1./(zl-targZ);
125 StripsToCoor(u,
v, xl, yl, stal);
127 fvec tx = (xl - targX)*dzli;
128 fvec ty = (yl - targY)*dzli;
138 if( istac != istal ){
139 fld0.
Set( l_B, stal.
z, centB, stac.
z, targB, targZ );
142 fld0.
Set( l_B, zstal, targB, targZ );
148 if( istac != istal ){
149 fld1.
Set( m_B, zstam, l_B, zstal, centB, zstac );
152 fld1.
Set( m_B, zstam, l_B, zstal, targB, targZ );
159 fld1.
Set( r_B, zstar, m_B, zstam, l_B, zstal);
164 if ( (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) ) T.
NDF = 0;
171 T.
C22 = T.
C33 = MaxSlope*MaxSlope/9.; T.
C44 = MaxInvMom/3.*MaxInvMom/3.;
174#ifndef BEGIN_FROM_TARGET
184 fvec &du = du_front[i1_V];
185 fvec &dv = du_back [i1_V];
191 fvec det = c_f*s_b - s_f*c_b;
198 T.
C00 = ( s_b*s_b*du*du + s_f*s_f*dv*dv )/det;
199 T.
C10 =-( s_b*c_b*du*du + s_f*c_f*dv*dv )/det;
200 T.
C11 = ( c_b*c_b*du*du + c_f*c_f*dv*dv )/det;
207 fvec eX, eY, J04, J14;
212 J[0]= dz; J[1] = 0; J[2]= J04;
213 J[3] = 0; J[4]= dz; J[5]= J14;
214 L1FilterVtx( T, targX, targY, TargetXYInfo, eX, eY, J );
222 T.
C00 = TargetXYInfo.C00;
223 T.
C10 = TargetXYInfo.C10;
224 T.
C11 = TargetXYInfo.C11;
229 for (
int ista = 0; ista <= istal-1; ista++){
230 if ( (
isec != kAllPrimEIter ) && (
isec != kAllSecEIter ) ) {
242 L1AddMaterial( T, vStations[ista].materialInfo, MaxInvMom, 1, 0.000511f*0.000511f );
252 if ( (
isec != kAllPrimEIter ) && (
isec != kAllSecEIter ) ) {
276inline void L1Algo::f20(
285#ifdef DOUB_PERFORMANCE
286 vector<THitI> &hitsl_2,
288 vector<THitI> &hitsm_2,
289 vector<bool> &lmDuplets
293 for (
int i1 = 0; i1 < n1; i1++){
298 const int n2Saved = n2;
300 const THitI nl = vStsHits_l[hitsl_1[i1]].
N();
301 fvec Pick_m22 = (DOUBLET_CHI2_CUT - T1.
chi2);
305 const fscal iz = 1/T1.
z[i1_4];
308 while( area.GetNext( imh ) ) {
313 const fscal &zm = hitm.
Z();
320 const fscal dy = hitm.
Y() - y[i1_4];
321 const fscal dy2 = dy*dy;
322 if ( dy2 > dy_est2 && dy < 0 )
continue;
325 const unsigned short int nm = hitm.
N();
326 if ( ( nl != nm ) )
continue;
332 const fscal dx = hitm.
X() - x[i1_4];
333 if ( dx*dx > dx_est2 )
continue;
343#ifdef DO_NOT_SELECT_TRIPLETS
344 if (
isec!=TRACKS_FROM_TRIPLETS_ITERATION)
346 if ( chi2[i1_4] > DOUBLET_CHI2_CUT )
continue;
351#ifdef DO_NOT_SELECT_TRIPLETS
352 if (
isec!=TRACKS_FROM_TRIPLETS_ITERATION)
354 if ( chi2[i1_4] > DOUBLET_CHI2_CUT )
continue;
357#ifdef DOUB_PERFORMANCE
358 hitsl_2.push_back(hitsl_1[i1]);
360 hitsm_2.push_back(imh);
365 lmDuplets[hitsl_1[i1]] = (n2Saved < n2);
374inline void L1Algo::f30(
377 int istam,
int istar,
383 vector<THitI> &hitsm_2,
386 const vector<bool> &mrDuplets,
390 vector<THitI> &hitsl_3, vector<THitI> &hitsm_3, vector<THitI> &hitsr_3,
401 int n3_V = 0, n3_4 = 0;
403 T_3.push_back(L1TrackPar_0);
404 u_front_3.push_back(fvec_0);
405 u_back_3.push_back(fvec_0);
406 z_Pos_3.push_back(fvec_0);
409 du_front_3->push_back(fvec_0);
410 du_back_3->push_back(fvec_0);
419 for (
int i2 = 0; i2 < n2;) {
427 fvec du_front_2, du_back_2;
430 for (; n2_4 <
fvecLen && i2 < n2; n2_4++, i2++){
432 if (!mrDuplets[hitsm_2[i2]]) {
438 const int i1 = i1_2[i2];
447 const int imh = hitsm_2[i2];
449 u_front_2[n2_4] = hitm.
U();
450 u_back_2 [n2_4] = hitm.
V();
451 zPos_2 [n2_4] = hitm.
Z();
452 du_front_2[n2_4] = hitm.
DU() * hitm.
DU();
453 du_back_2 [n2_4] = hitm.
DV() * hitm.
DV();
455 hitsl_2[n2_4] = hitsl_1[i1];
456 hitsm_2_tmp[n2_4] = hitsm_2[i2];
467 if ( (
isec != kAllPrimEIter ) && (
isec != kAllSecEIter ) ) {
488 for (
int i2_4 = 0; i2_4 < n2_4; i2_4++){
491 if ( T2.
C00[i2_4] < 0 || T2.
C11[i2_4] < 0 || T2.
C22[i2_4] < 0 || T2.
C33[i2_4] < 0 || T2.
C44[i2_4] < 0 )
continue;
493 fvec Pick_r22 = (TRIPLET_CHI2_CUT - T2.
chi2);
496#ifdef DO_NOT_SELECT_TRIPLETS
497 if (
isec == TRACKS_FROM_TRIPLETS_ITERATION )
498 Pick_r22 = Pick_r2+1;
501 const fscal iz = 1/T2.
z[i2_4];
504 while( area.GetNext( irh ) ) {
508 const fscal zr = hitr.
Z();
509 const fscal yr = hitr.
Y();
516 const fscal dy = yr - y[i2_4];
517 const fscal dy2 = dy*dy;
518 if ( dy2 > dy_est2 && dy < 0 )
continue;
521 if ( dy2 > dy_est2 )
continue;
527 const fscal dx = hitr.
X() - x[i2_4];
528 if ( dx*dx > dx_est2 )
continue;
534 fvec du2 = hitr.
DU(), dv2 = hitr.
DV();
541#ifdef DO_NOT_SELECT_TRIPLETS
542 if (
isec!=TRACKS_FROM_TRIPLETS_ITERATION)
544 if ( chi2[i2_4] > TRIPLET_CHI2_CUT || C00[i2_4] < 0 || C11[i2_4] < 0 )
continue;
549 hitsl_3.push_back(hitsl_2[i2_4]);
550 hitsm_3.push_back(hitsm_2_tmp[i2_4]);
551 hitsr_3.push_back(irh);
554 u_front_3[n3_V][n3_4] = hitr.
U();
555 u_back_3 [n3_V][n3_4] = hitr.
V();
556 z_Pos_3 [n3_V][n3_4] = zr;
559 (*du_front_3)[n3_V][n3_4] = hitr.
DU() * hitr.
DU();
560 (*du_back_3) [n3_V][n3_4] = hitr.
DV() * hitr.
DV();
569 T_3.push_back(L1TrackPar_0);
570 u_front_3.push_back(fvec_0);
571 u_back_3.push_back(fvec_0);
572 z_Pos_3.push_back(fvec_0);
575 du_front_3->push_back(fvec_0);
576 du_back_3->push_back(fvec_0);
590inline void L1Algo::f31(
601 for(
int i3_V=0; i3_V<n3_V; i3_V++){
606 L1Filter( T_3[i3_V], star.
backInfo, u_back [i3_V], ww, &(*du_back2)[i3_V] );
617inline void L1Algo::f32(
620 vector<THitI> &hitsl_3, vector<THitI> &hitsm_3, vector<THitI> &hitsr_3,
625 cout <<
" !!! L1Algo::f32 should not be called !!! " << endl; exit(9);
637 for (
int is = 0; is < NHits; is++){
638 sta[is] = vStations[ista[is]];
641 for(
int i3=0; i3<n3; i3++){
649 THitI ihit[NHits] = {
655 fscal u[NHits],
v[NHits], x[NHits], y[NHits], z[NHits];
656 fvec du2[NHits], dv2[NHits], ww = 1.;
657 for (
int ih = 0; ih < NHits; ih++){
663 StripsToCoor(u[ih],
v[ih], x[ih], y[ih], sta[ih]);
674 fvec dz01 = 1./(z[1]-z[0]);
675 T.
tx = (x[1]-x[0])*dz01;
676 T.
ty = (y[1]-y[0])*dz01;
697 (x[1]-x[0])/(z[1]-z[0]),
698 (x[2]-x[0])/(z[2]-z[0]),
699 (x[2]-x[1])/(z[2]-z[1])
702 (y[1]-y[0])/(z[1]-z[0]),
703 (y[2]-y[0])/(z[2]-z[0]),
704 (y[2]-y[1])/(z[2]-z[1])
706 for (
int ih = 0; ih < NHits; ih++){
707 fvec dz = (sta[ih].
z - z[ih]);
710 fld.Set( B[0], sta[0].z, B[1], sta[1].z, B[2], sta[2].z );
713 for(
int ih = 1; ih < NHits; ih++){
716 if ( (
isec != kAllPrimEIter ) && (
isec != kAllSecEIter ) ) {
729 L1AddMaterial( T, sta[ih].materialInfo, T.
qp, 1, 0.000511f*0.000511f );
737 L1Filter( T, sta[ih].frontInfo, u[ih], ww, &du2[ih]);
738 L1Filter( T, sta[ih].backInfo,
v[ih], ww, &dv2[ih]);
742 for (
int iiter = 0; iiter < nIterations; iiter++){
759 fvec det = c_f*s_b - s_f*c_b;
761 fvec du22 = du2[ih], dv22 = dv2[ih];
764 T.
C00 = ( s_b*s_b*du22 + s_f*s_f*dv22 )/det;
765 T.
C10 =-( s_b*c_b*du22 + s_f*c_f*dv22 )/det;
766 T.
C11 = ( c_b*c_b*du22 + c_f*c_f*dv22 )/det;
777 for( ih = NHits-2; ih >= 0; ih--){
780 if ( (
isec != kAllPrimEIter ) && (
isec != kAllSecEIter ) ) {
792 L1AddMaterial( T, sta[ih].materialInfo, T.
qp, 1, 0.000511f*0.000511f );
799 L1Filter( T, sta[ih].frontInfo, u[ih], ww, &du2[ih]);
800 L1Filter( T, sta[ih].backInfo,
v[ih], ww, &dv2[ih]);
817 det = c_f*s_b - s_f*c_b;
823 T.
C00 = ( s_b*s_b*du22 + s_f*s_f*dv22 )/det;
824 T.
C10 =-( s_b*c_b*du22 + s_f*c_f*dv22 )/det;
825 T.
C11 = ( c_b*c_b*du22 + c_f*c_f*dv22 )/det;
836 for( ih = 1; ih < NHits; ih++){
839 if ( (
isec != kAllPrimEIter ) && (
isec != kAllSecEIter ) ) {
851 L1AddMaterial( T, sta[ih].materialInfo, T.
qp, 1, 0.000511f*0.000511f );
858 L1Filter( T, sta[ih].frontInfo, u[ih], ww, &du2[ih]);
859 L1Filter( T, sta[ih].backInfo,
v[ih], ww, &dv2[ih]);
869inline void L1Algo::f4(
870 int n3,
int istal,
int istam,
int istar,
873 vector<THitI> &hitsl_3, vector<THitI> &hitsm_3, vector<THitI> &hitsr_3,
875 unsigned int &nstaltriplets,
876 std::vector<L1Triplet> &vTriplets_part,
877 unsigned int *TripStartIndexH,
unsigned int *TripStopIndexH
884 for(
int i3=0; i3<n3; i3++){
891#ifdef DO_NOT_SELECT_TRIPLETS
892 if (
isec!=TRACKS_FROM_TRIPLETS_ITERATION)
894 if ( !finite(chi2) || chi2 < 0 || chi2 > TRIPLET_CHI2_CUT )
continue;
898 fscal MaxInvMomS = MaxInvMom[0];
899 fscal qp = MaxInvMomS + T3.
qp[i3_4];
901 if( qp > MaxInvMomS*2 ) qp = MaxInvMomS*2;
904 fscal scale = 255/(MaxInvMom[0]*2);
906 qp = (
static_cast<unsigned int>(qp*scale) )%256;
907 Cqp = (
static_cast<unsigned int>(Cqp*scale))%256;
910 if( Cqp < 0 ) Cqp = 0;
911 if( Cqp > 20 ) Cqp = 20;
912 qp =
static_cast<unsigned char>( qp );
923 trip.
Set( ihitl, ihitm, ihitr,
925 0,
static_cast<unsigned char>( qp ), chi2);
927 trip.
Cqp =
static_cast<unsigned char>( Cqp );
931 vTriplets_part.push_back(trip);
933 if ( TripStopIndexH[ihitl] == 0 )
934 TripStartIndexH[ihitl] = nstaltriplets;
935 TripStopIndexH[ihitl] = ++nstaltriplets;
945inline void L1Algo::f5(
947 unsigned int *TripStartIndexH,
unsigned int *TripStopIndexH,
952#ifdef TRACKS_FROM_TRIPLETS
953 if(
isec != TRACKS_FROM_TRIPLETS_ITERATION )
956 for (
int istal =
NStations - 4; istal >= FIRSTCASTATION; istal--){
957 for (
int tripType = 0; tripType < 3; tripType++) {
958 if ( ( ((
isec != kFastPrimJumpIter) && (
isec != kAllPrimJumpIter) && (
isec != kAllSecJumpIter)) && (tripType != 0) ) ||
959 ( ((
isec == kFastPrimJumpIter) || (
isec == kAllPrimJumpIter) || (
isec == kAllSecJumpIter)) && (tripType != 0) && (istal ==
NStations - 4) )
962 int istam = istal + 1;
963 int istar = istal + 2;
974 unsigned int offset_m = TripStartIndex[istam];
976 for (
int it = TripStartIndex[istal]; it < TripStopIndex[istal]; it++){
978 if ( istam != trip->
GetMSta() )
continue;
979 if ( istar != trip->
GetRSta() )
continue;
981 unsigned char level = 0;
983 unsigned char qp = trip->
GetQp();
993 unsigned int first_triplet;
994 unsigned int last_triplet;
995 unsigned int iN = TripStartIndexH[ihitm];
996 unsigned int lastN = TripStopIndexH[ihitm];
1006 L1_ASSERT(iN >= offset_m, iN <<
" >= " << offset_m);
1018 last_triplet = lastN;
1020 vector<unsigned int> neighCands;
1021 neighCands.reserve(8);
1022 for (iN = first_triplet; iN <= last_triplet; ++iN){
1024 if (vTriplets[iN].GetMSta() != istar)
continue;
1025 if (vTriplets[iN].GetMHit() != ihitr)
continue;
1032 if (
fabs(qp - qp2) > PickNeighbour * (Cqp1 + Cqp2) )
continue;
1035 unsigned char jlevel = tripn->
GetLevel();
1036 if ( level <= jlevel )
level = jlevel + 1;
1037 if (level == jlevel + 1) neighCands.push_back(iN);
1039 for (
unsigned int in = 0; in < neighCands.size(); in++) {
1040 const int nLevel = vTriplets[neighCands[in]].GetLevel();
1041 if (level == nLevel + 1) trip->
neighbours.push_back(neighCands[in] - offset_m);
1047 trip->
Set( ihitl, ihitm, ihitr,
1048 istal, istam, istar,
1060inline void L1Algo::DupletsStaPort(
1061 int istal,
int istam,
1063 vector<int> &n_g1,
unsigned int *portionStopIndex,
1070 vector<bool> &lmDuplets,
1073 vector<THitI> &i1_2,
1074 vector<THitI> &hitsm_2
1101 (ip - portionStopIndex[istal+1]) * Portion, n1, vStsHits_l,
1103 u_front, u_back, zPos,
1108 for (
int i = 0;
i < n1;
i++)
1119 u_front, u_back, zPos,
1127#ifdef DOUB_PERFORMANCE
1128 vector<THitI> hitsl_2;
1133 vStsHits_l, vStsHits_m, NHits_m,
1140#ifdef DOUB_PERFORMANCE
1149 for (
unsigned int i = 0;
i < hitsm_2.size();
i++)
1152#ifdef DOUB_PERFORMANCE
1155 for (
int i = 0;
i < n2;
i++){
1159 RealIHitL[hitsl_2[
i]],
1160 RealIHitM[hitsm_2[
i]]
1162 fL1Eff_doublets->AddOne(iHits);
1171inline void L1Algo::TripletsStaPort(
1172 int istal,
int istam,
int istar,
1175 unsigned int& nstaltriplets,
1180 int &n_2,
unsigned int *portionStopIndex,
1181 vector<THitI> &i1_2,
1182 vector<THitI> &hitsm_2,
1184 const vector<bool> &mrDuplets,
1188 std::vector<L1Triplet> *vTriplets_part,
1189 unsigned int *TripStartIndexH,
unsigned int *TripStopIndexH
1208 vector<THitI> hitsl_3, hitsm_3, hitsr_3;
1217 T_3.reserve(MaxPortionTriplets/
fvecLen);
1218 hitsl_3.reserve(MaxPortionTriplets);
1219 hitsm_3.reserve(MaxPortionTriplets);
1220 hitsr_3.reserve(MaxPortionTriplets);
1221 u_front3.reserve(MaxPortionTriplets/
fvecLen);
1222 u_back3.reserve(MaxPortionTriplets/
fvecLen);
1223 z_pos3.reserve(MaxPortionTriplets/
fvecLen);
1224 du_front3.reserve(MaxPortionTriplets/
fvecLen);
1225 du_back3.reserve(MaxPortionTriplets/
fvecLen);
1230 vStsHits_r, stam, star,
1245 hitsl_3, hitsm_3, hitsr_3,
1246 u_front3, u_back3, z_pos3,
1247 &du_front3, &du_back3
1252 for (
unsigned int i = 0;
i < hitsl_3.size();
i++)
1254 for (
unsigned int i = 0;
i < hitsm_3.size();
i++)
1256 for (
unsigned int i = 0;
i < hitsr_3.size();
i++)
1268 u_front3, u_back3, z_pos3,
1271 &du_front3, &du_back3
1278#ifdef TRIP_PERFORMANCE
1282 for (
int i = 0;
i < n3;
i++){
1286 RealIHitL[hitsl_3[
i]],
1287 RealIHitM[hitsm_3[
i]],
1288 RealIHitR[hitsr_3[
i]]
1291 if ( fL1Eff_triplets->AddOne(iHits) )
1292 fL1Pulls->AddOne(T_3[i_V], i_4, iHits[2]);
1294 fL1Eff_triplets->AddOne(iHits);
1296 if (T_3[i_V].chi2[i_4] < TRIPLET_CHI2_CUT)
1297 fL1Eff_triplets2->AddOne(iHits);
1304 n3, istal, istam, istar,
1306 hitsl_3, hitsm_3, hitsr_3,
1309 vTriplets_part[istal],
1310 TripStartIndexH, TripStopIndexH
1343 fL1Pulls = l1Pulls_;
1346#ifdef TRIP_PERFORMANCE
1348 fL1Eff_triplets = l1Eff_triplets_;
1349 fL1Eff_triplets->
Init();
1351 fL1Eff_triplets2 = l1Eff_triplets2_;
1352 fL1Eff_triplets2->
Init();
1354#ifdef DOUB_PERFORMANCE
1356 fL1Eff_doublets = l1Eff_doublets_;
1357 fL1Eff_doublets->
Init();
1368#if defined(XXX) || defined(COUNTERS)
1369 static unsigned int stat_N = 0;
1374 TStopwatch c_timerG;
1375 TStopwatch c_timerI;
1402 static unsigned int stat_nStartHits = 0;
1403 static unsigned int stat_nHits[fNFindIterations] = {0};
1404 static unsigned int stat_nSinglets[fNFindIterations] = {0};
1406 static unsigned int stat_nTriplets[fNFindIterations] = {0};
1420 for( vector<unsigned char>::iterator is=
vSFlag.begin(); is!=
vSFlag.end(); ++is)
1422 for( vector<unsigned char>::iterator is=
vSFlagB.begin(); is!=
vSFlagB.end(); ++is)
1429 stat_max_trip_size = 0,
1431 stat_max_BranchSize = 0,
1432 stat_max_n_branches = 0;
1445 vector< L1StsHit > vStsDontUsedHits_A;
1446 vector< L1StsHit > vStsDontUsedHits_B;
1448 vector< L1HitPoint > vStsDontUsedHitsxy_A;
1449 vector< L1HitPoint > vStsDontUsedHitsxy_B;
1452 std::vector< L1StsHit > *vStsHitsUnused_buf = &vStsDontUsedHits_A;
1455 std::vector< L1HitPoint > *vStsHitPointsUnused_buf = &vStsDontUsedHitsxy_A;
1457 vStsHitsUnused_buf->clear();
1458 vStsHitPointsUnused_buf->clear();
1459 vector<THitI> RealIHit_v;
1460 RealIHit_v.resize(
vStsHits.size());
1469 for(
int ista = 0; ista <
NStations; ista++){
1474 const L1HitPoint p = CreateHitPoint(hit,ista);
1476 vStsDontUsedHitsxy_B.push_back( p );
1486 vStsDontUsedHitsxy_B.push_back( p1 );
1489 vStsDontUsedHits_B .push_back( hit );
1496 for (
int istal =
NStations - 1; istal >= 0; istal--){
1504 float yStep = 0.5/hitDensity;
1505 if (yStep > 0.3) yStep = 0.3;
1506 const float xStep = yStep*3;
1508 for(
int iS = 0; iS <
NStations; iS++ ) {
1510 grid.
Create(-1,1,-0.6,0.6,xStep,yStep);
1520 for (
int j = 0; j < int(RealIHit_v.size()); ++j)
vStsHits2Unus[RealIHit_v[j]] = j;
1525 gti[
"init "] = c_timerG;
1530 cout <<
" Begin " << endl;
1532 cout <<
" NStartHits = " << stat_nStartHits/stat_N << endl;
1545 unsigned int nSinglets = 0;
1556 for(
int iS = 0; iS <
NStations; iS++ ) {
1570 DOUBLET_CHI2_CUT = 2.706;
1571 TRIPLET_CHI2_CUT = 5;
1574 TRIPLET_CHI2_CUT = 7.815;
1578 TRIPLET_CHI2_CUT = 7.815;
1580 case kAllPrimJumpIter:
1581 TRIPLET_CHI2_CUT = 6.252;
1585 TRIPLET_CHI2_CUT = 6.252;
1590 if ( (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) || (
isec == kAllPrimJumpIter) || (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) )
1594 PickNeighbour = 1.0;
1597 PickNeighbour = 6.0;
1599 MaxInvMom = 1.0/0.5;
1600 if ( (
isec == kAllPrimJumpIter) || (
isec == kAllSecIter) || (
isec == kAllSecJumpIter) ) MaxInvMom = 1.0/0.1;
1601 if ( (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) || (
isec == kAllSecEIter) ) MaxInvMom = 1./0.05;
1605 (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) ) MaxSlope = 1.5;
1608 targX = 0; targY = 0; targZ = 0;
1610 float SigmaTargetX = 0, SigmaTargetY = 0;
1611 if ( (
isec == kFastPrimIter) || (
isec == kFastPrimIter2) || (
isec == kFastPrimJumpIter) ||
1612 (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) || (
isec == kAllPrimJumpIter) ){
1613 targB = vtxFieldValue;
1614 if ( (
isec == kFastPrimIter) || (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) )
1616 SigmaTargetX = SigmaTargetY = 1.0;
1619 SigmaTargetX = SigmaTargetY = 5.0;
1621 if ( (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) ) {
1623 SigmaTargetX = SigmaTargetY = 10;
1630 TargetXYInfo.C00 = SigmaTargetX * SigmaTargetX;
1631 TargetXYInfo.C10 = 0;
1632 TargetXYInfo.C11 = SigmaTargetY * SigmaTargetY;
1638 if ( (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) || (
isec == kAllPrimJumpIter) ||
1639 (
isec == kAllSecIter ) || (
isec == kAllSecEIter)|| (
isec == kAllSecJumpIter ) ) MaxDZ = 0.1;
1647 vector<unsigned int> TripStartIndexH_v, TripStopIndexH_v;
1648 vector<unsigned int> TripStartIndexHG124_v, TripStopIndexHG124_v;
1649 vector<unsigned int> TripStartIndexHG134_v, TripStopIndexHG134_v;
1657 unsigned int *TripStartIndexH = &(TripStartIndexH_v[0]), *TripStopIndexH = &(TripStopIndexH_v[0]);
1658 unsigned int *TripStartIndexHG124 = &(TripStartIndexHG124_v[0]), *TripStopIndexHG124 = &(TripStopIndexHG124_v[0]);
1659 unsigned int *TripStartIndexHG134 = &(TripStartIndexHG134_v[0]), *TripStopIndexHG134 = &(TripStopIndexHG134_v[0]);
1663 TripStartIndexH[
i] = 0;
1664 TripStopIndexH[
i] = 0;
1665 TripStartIndexHG124[
i] = 0;
1666 TripStopIndexHG124[
i] = 0;
1667 TripStartIndexHG134[
i] = 0;
1668 TripStopIndexHG134[
i] = 0;
1679 n_g1.reserve(MaxNPortion);
1683 for (
int istal =
NStations - 1; istal >= 0; istal--){
1692 unsigned int ip = 0;
1694 for (
int istal =
NStations-2; istal >= FIRSTCASTATION; istal--){
1698 int NHits_l_P = NHits_l/Portion;
1700 for(
int ipp = 0; ipp < NHits_l_P; ipp++ ){
1702 n_g1.push_back(Portion);
1704 nSinglets += Portion;
1710 n_g1.push_back(NHits_l - NHits_l_P*Portion);
1712 nSinglets += n_g1.back();
1715 portionStopIndex[istal] = ip;
1721 stat_nSinglets[
isec] += nSinglets;
1727 ti[
isec][
"init "] = c_timer;
1731 const unsigned int vPortion = Portion/
fvecLen;
1734 THitI hitsl_1[Portion];
1737 THitI hitslG_1[Portion];
1740 for (
int istal =
NStations-2; istal >= FIRSTCASTATION; istal--){
1741 unsigned int nstaltriplets = 0;
1742 unsigned int nstaltripletsG124 = 0;
1743 unsigned int nstaltripletsG134 = 0;
1746 lmDuplets[istal].resize(NHitsSta);
1747 lmDupletsG[istal].resize(NHitsSta);
1748 for(
unsigned int ip = portionStopIndex[istal+1]; ip < portionStopIndex[istal]; ip++ ){
1752 vector<THitI> hitsm_2;
1756 hitsm_2.reserve(MaxPortionDoublets);
1757 i1_2.reserve(MaxPortionDoublets);
1762 n_g1, portionStopIndex,
1777 istal, istal + 1, istal + 2,
1783 n_2, portionStopIndex,
1790 TripStartIndexH, TripStopIndexH
1793 if ( (
isec == kFastPrimJumpIter) || (
isec == kAllPrimJumpIter) || (
isec == kAllSecJumpIter) ) {
1794 vector<THitI> hitsmG_2;
1795 vector<THitI> i1G_2;
1797 hitsmG_2.reserve(MaxPortionDoublets);
1798 i1G_2.reserve(MaxPortionDoublets);
1803 n_g1, portionStopIndex,
1816 istal, istal + 1, istal + 3,
1822 n_2, portionStopIndex,
1826 lmDupletsG[istal+1],
1829 TripStartIndexHG124, TripStopIndexHG124
1832 istal, istal + 2, istal + 3,
1838 nG_2, portionStopIndex,
1845 TripStartIndexHG134, TripStopIndexHG134
1852 ti[
isec][
"tripl1"] = c_timer;
1875 for (
int istal =
NStations - 2; istal >= FIRSTCASTATION; istal--){
1876 tSize += vTriplets_part[istal].size();
1877 tSize += vTripletsG124_part[istal].size();
1878 tSize += vTripletsG134_part[istal].size();
1880 vTriplets.reserve(tSize);
1882 for (
int istal =
NStations - 2; istal >= FIRSTCASTATION; istal--){
1883 TripStartIndex[istal] = vTriplets.size();
1885 for (
unsigned int i = 0;
i < vTriplets_part[istal].size();
i++){
1886 vTriplets.push_back(vTriplets_part[istal][
i]);
1888 for (
unsigned int i = 0;
i < vTripletsG124_part[istal].size();
i++){
1889 vTriplets.push_back(vTripletsG124_part[istal][
i]);
1891 for (
unsigned int i = 0;
i < vTripletsG134_part[istal].size();
i++){
1892 vTriplets.push_back(vTripletsG134_part[istal][
i]);
1896 TripStartIndexH[
i] += TripStartIndex[istal];
1897 TripStopIndexH[
i] += TripStartIndex[istal]
1898 + TripStopIndexHG124[
i] - TripStartIndexHG124[
i]
1899 + TripStopIndexHG134[
i] - TripStartIndexHG134[
i];
1902 TripStopIndex[istal] = vTriplets.size();
1908 stat_nTriplets[
isec] += vTriplets.size();
1965 ti[
isec][
"cpTrls"] = c_timer;
1977 for (
int il = 0; il <
NStations; ++il) nlevels[il] = 0;
1981 TripStartIndexH, TripStopIndexH,
1986 ti[
isec][
"nghbrs"] = c_timer;
2004 if ( (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) )
2006#ifdef TRACKS_FROM_TRIPLETS
2007 if (
isec == TRACKS_FROM_TRIPLETS_ITERATION)
2014 for (
int ilev =
NStations-3; ilev >= min_level; ilev--){
2015 vector<L1Branch> vtrackcandidate; vtrackcandidate.clear();
2021 for(
int istaF = FIRSTCASTATION; istaF <=
NStations-3-ilev; istaF++ ){
2026 int trip_first = TripStartIndex[istaF];
2027 int trip_end = TripStopIndex[istaF];
2028 for(
int itrip=trip_first; itrip<trip_end; itrip++ ){
2029 L1Triplet *first_trip = &vTriplets[itrip];
2032#ifndef FIND_GAPED_TRACKS
2033 if( (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) || (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) ) {
2035 if( (
isec == kFastPrimIter) || (
isec == kFastPrimIter2) || (
isec == kFastPrimJumpIter) ||
2036 (
isec == kAllPrimIter) || (
isec == kAllPrimEIter) || (
isec == kAllPrimJumpIter) ||
2037 (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) ) {
2039#ifdef TRACKS_FROM_TRIPLETS
2040 if (
isec != TRACKS_FROM_TRIPLETS_ITERATION)
2043 if (
isec != kFastPrimIter &&
isec != kAllPrimIter &&
isec != kAllPrimEIter &&
isec != kAllSecEIter )
2044 if ( first_trip->
GetLevel() == 0 )
continue;
2048 if ( first_trip->
GetLevel() < ilev )
continue;
2058 unsigned char curr_L = 1;
2062 fscal best_chi2 = curr_chi2;
2063 unsigned char best_L = curr_L;
2065#ifdef TRACKS_FROM_TRIPLETS
2070 CAFindTrack(istaF, best_tr, best_L, best_chi2, curr_trip, curr_tr, curr_L, curr_chi2, NCalls);
2086 if ( best_L < ilev + 2 )
continue;
2087 if ( best_L < min_level + 3 )
continue;
2089 int ndf = best_L*2-5;
2090 best_chi2 = best_chi2/ndf;
2101#ifndef TRACKS_FROM_TRIPLETS
2102 if( fGhostSuppression ){
2105 if( ( (
isec == kAllSecIter) || (
isec == kAllSecEIter) || (
isec == kAllSecJumpIter) ) && (istaF != 0) )
continue;
2106 if( (
isec != kAllSecIter) && (
isec != kAllSecEIter) && (
isec != kAllSecJumpIter) && (best_chi2 > 5.0) )
continue;
2114 best_tr.
Set( istaF, best_L, best_chi2, first_trip->
GetQpOrig(MaxInvMom[0]));
2115 vtrackcandidate.push_back(best_tr);
2125 if (--nlevel == 0)
break;
2128 vector<L1Branch*> vptrackcandidate;
2129 vptrackcandidate.clear();
2131 for (vector<L1Branch>::iterator trIt = vtrackcandidate.begin();
2132 trIt != vtrackcandidate.end(); ++trIt){
2134 vptrackcandidate.push_back(&(*trIt));
2146 for (vector<L1Branch*>::iterator trIt = vptrackcandidate.begin();
2147 trIt != vptrackcandidate.end(); ++trIt){
2150 BranchExtender(*tr);
2155 for (vector<THitI>::iterator phIt = tr->
StsHits.begin();
2156 phIt != tr->
StsHits.end(); ++phIt){
2160#ifdef TRACKS_FROM_TRIPLETS
2161 if (
isec != TRACKS_FROM_TRIPLETS_ITERATION )
2163 if (nused > 0)
continue;
2182 for (vector<THitI>::iterator phitIt = tr->
StsHits.begin();
2183 phitIt != tr->
StsHits.end(); ++phitIt){
2185#ifdef TRACKS_FROM_TRIPLETS
2186 if (
isec != TRACKS_FROM_TRIPLETS_ITERATION )
2192#ifdef TRACKS_FROM_TRIPLETS
2193 if (
isec == TRACKS_FROM_TRIPLETS_ITERATION )
2206#ifdef TRACKS_FROM_TRIPLETS
2208 if (
isec == kAllSecIter || (
isec == kAllSecEIter) )
2210 if (
isec == TRACKS_FROM_TRIPLETS_ITERATION )
2219 unsigned int Bsize=0, nb=0;
2220 for (vector<L1Branch*>::iterator trIt = vptrackcandidate.begin();
2221 trIt != vptrackcandidate.end(); ++trIt){
2227 if( Bsize>stat_max_BranchSize ) stat_max_BranchSize = Bsize;
2228 if( nb>stat_max_n_branches ) stat_max_n_branches = nb;
2236 ti[
isec][
"tracks"] = c_timer;
2244 int StsHitsUnusedStartIndex_temp;
2246 int nDontUsedHits = 0;
2248 vStsHitsUnused_buf->clear();
2249 vStsHitPointsUnused_buf->clear();
2250 vStsHitsUnused_buf->reserve(HSize);
2251 vStsHitPointsUnused_buf->reserve(HSize);
2257 const L1StsHit &hit = (*vStsHitsUnused)[ih];
2259 vStsHitsUnused_buf->push_back(hit);
2272 vStsHitsUnused_buf = vStsHitsUnused_temp;
2275 vStsHitPointsUnused_buf = vStsHitsUnused_temp2;
2277 vStsHitsUnused_buf->clear();
2278 vStsHitPointsUnused_buf->clear();
2284 ti[
isec][
"finish"] = c_timer;
2288 unsigned int tsize = vTriplets.size()*
sizeof(
L1Triplet);
2289 if( stat_max_trip_size < tsize ) stat_max_trip_size = tsize;
2306 cout <<
"iter = " <<
isec << endl;
2307 cout <<
" NSinglets = " << stat_nSinglets[
isec]/stat_N << endl;
2309 cout <<
" NTriplets = " << stat_nTriplets[
isec]/stat_N << endl;
2310 cout <<
" NHitsUnused = " << stat_nHits[
isec]/stat_N << endl;
2317 gti[
"iterts"] = c_timerG;
2321#ifndef TRACKS_FROM_TRIPLETS
2329 gti[
"merge "] = c_timerG;
2340 CATime = (double(c_time.RealTime()));
2345 cout << endl <<
" --- Timers, ms --- " << endl;
2356 static long int NTimes =0, NHits=0, HitSize =0, NStrips=0, StripSize =0, NStripsB=0, StripSizeB =0,
2357 NDup=0, DupSize=0, NTrip=0, TripSize=0, NBranches=0, BranchSize=0, NTracks=0, TrackSize=0 ;
2366 NDup += stat_max_n_dup;
2367 DupSize += stat_max_n_dup*
sizeof( int);
2368 NTrip += stat_max_n_trip;
2369 TripSize += stat_max_trip_size;
2371 NBranches += stat_max_n_branches;
2372 BranchSize += stat_max_BranchSize;
2375 int k = 1024*NTimes;
2377 cout<<
"L1 Event size: \n"
2378 <<HitSize/k<<
"kB for "<<NHits/NTimes<<
" hits, \n"
2379 <<StripSize/k<<
"kB for "<<NStrips/NTimes<<
" strips, \n"
2380 <<StripSizeB/k<<
"kB for "<<NStripsB/NTimes<<
" stripsB, \n"
2381 <<DupSize/k<<
"kB for "<<NDup/NTimes<<
" doublets, \n"
2382 <<TripSize/k<<
"kB for "<<NTrip/NTimes<<
" triplets\n"
2383 <<BranchSize/k<<
"kB for "<<NBranches/NTimes<<
" branches, \n"
2384 <<TrackSize/k<<
"kB for "<<NTracks/NTimes<<
" tracks. "<<endl;
2385 cout<<
" L1 total event size = "
2386 <<( HitSize + StripSize + StripSizeB + DupSize + TripSize + BranchSize + TrackSize )/k
2401 static int iEvee = 0;
2406#ifdef DOUB_PERFORMANCE
2407 fL1Eff_doublets->CalculateEff();
2408 fL1Eff_doublets->Print(
"Doublets performance.",1);
2410#ifdef TRIP_PERFORMANCE
2411 fL1Eff_triplets->CalculateEff();
2412 fL1Eff_triplets->Print(
"Triplet performance",1);
2429void L1Algo::CAFindTrack(
int ista,
2452 if( curr_chi2 > TRACK_CHI2_CUT * (curr_L*2-5) )
return;
2466 if ( (curr_L > best_L ) || ( (curr_L == best_L) && (curr_chi2 < best_chi2) ) ){
2468 best_chi2 = curr_chi2;
2477 int offset = TripStartIndex[curr_trip->
GetMSta()];
2479 for (
int in = 0; in < NNeighs; in++) {
2480 int index = curr_trip->
neighbours[in] + offset;
2481 L1Triplet *new_trip = &vTriplets[index];
2488 Cqp += new_trip->
Cqp;
2489 if ( dqp > PickNeighbour * Cqp )
continue;
2493 if ( ( curr_L > best_L ) || ( (curr_L == best_L) && (curr_chi2 < best_chi2) ) ){
2495 best_chi2 = curr_chi2;
2504 unsigned char new_L = curr_L;
2505 fscal new_chi2 = curr_chi2;
2511 new_chi2 += dqp*dqp;
2515 if( new_chi2 > TRACK_CHI2_CUT * new_L )
continue;
2517 const int new_ista = ista + new_trip->
GetMSta() - new_trip->
GetLSta();
2518 CAFindTrack(new_ista, best_tr, best_L, best_chi2, new_trip, new_tr, new_L, new_chi2, NCalls);
#define L1_ASSERT(v, msg)
void L1AddPipeMaterial(L1TrackPar &T, fvec qp0, fvec w=1, fvec mass2=0.1395679f *0.1395679f)
void L1AddMaterial(L1TrackPar &T, fvec radThick, fvec qp0, fvec w=1, fvec mass2=0.1395679f *0.1395679f)
void L1Filter(L1TrackPar &T, L1UMeasurementInfo &info, fvec u, fvec w=1., fvec *du2=0)
void L1FilterChi2XYC00C10C11(const L1UMeasurementInfo &info, fvec &x, fvec &y, fvec &C00, fvec &C10, fvec &C11, fvec &chi2, const fvec &u, const fvec *du2=0)
void L1FilterChi2(const L1UMeasurementInfo &info, const fvec &x, const fvec &y, const fvec &C00, const fvec &C10, const fvec &C11, fvec &chi2, const fvec &u, const fvec *du2=0)
void L1FilterVtx(L1TrackPar &T, fvec x, fvec y, L1XYMeasurementInfo &info, fvec extrDx, fvec extrDy, fvec J[])
friend F32vec4 sqrt(const F32vec4 &a)
friend F32vec4 fabs(const F32vec4 &a)
void SaveCanvas(TString name)
void InitL1Draw(L1Algo *algo_)
vector< unsigned char > vSFlag
L1Station vStations[MaxNStations] _fvecalignment
THitI StsHitsStopIndex[MaxNStations+1]
vector< L1Strip > vStsStrips
vector< L1HitPoint > vAllHitPoints
vector< L1Track > vTracks
--— Output data --—
vector< unsigned char > vSFlagB
THitI StsHitsUnusedStartIndex[MaxNStations+1]
THitI StsHitsStartIndex[MaxNStations+1]
vector< THitI > vRecoHits
vector< L1StsHit > vStsHits
int isec
— data used during finding iterations
vector< L1StsHit > * vStsHitsUnused
std::vector< L1HitPoint > * vStsHitPointsUnused
vector< L1Strip > vStsStripsB
vector< int > vStsHits2Unus
void CATrackFinder()
The main procedure - find tracks.
THitI StsHitsUnusedStopIndex[MaxNStations+1]
L1Grid vGrid[MaxNStations]
vector< L1Material > fRadThick
void SetOneEntry(const int i0, const L1FieldRegion &f1, const int i1)
void Set(const L1FieldValue &B0, const fvec B0z, const L1FieldValue &B1, const fvec B1z, const L1FieldValue &B2, const fvec B2z)
void GetFieldValue(const fvec &x, const fvec &y, L1FieldValue &B) const
void Create(float yMin, float yMax, float zMin, float zMax, float sy, float sz)
void Fill(const L1HitPoint *points, THitI n)
L1XYMeasurementInfo XYInfo
L1UMeasurementInfo backInfo
L1MaterialInfo materialInfo
L1UMeasurementInfo frontInfo
void SetOneEntry(const int i0, const L1TrackPar &T1, const int i1)
void Set(unsigned int iHitL, unsigned int iHitM, unsigned int iHitR, unsigned int iStaL, unsigned int iStaM, unsigned int iStaR, unsigned char Level, unsigned char Qp, float Chi2)
unsigned char GetQp() const
float GetQpOrig(float MaxInvMom)
unsigned char GetLevel() const
std::vector< unsigned int > neighbours
std::vector< THitI > StsHits
void Set(unsigned char iStation, unsigned char Length, float Chi2, float Qp)
static bool comparePChi2(const L1Branch *a, const L1Branch *b)
contain strips positions and coordinates of hit
unsigned short int N() const