54 #define TRG_VERSION 0x32
61 #include "fcfClass.hh"
63 #include <evpReader.hh>
65 #include <DAQ_READER/daqReader.h>
66 #include <DAQ_READER/daq_dta.h>
68 #include <rtsSystems.h>
69 #include <daqFormats.h>
70 #ifndef OLD_DAQ_READER
71 #include <DAQ_TPC/daq_tpc.h>
80 int FtfSl3::canItBeMerged (
FtfTrack* tTrack ) {
81 double rTpcMin = 50. ;
82 double rTpcMax = 210. ;
84 if ( nHits < 15 )
return 0 ;
91 double x0 = tTrack->r0 * cos (tTrack->phi0);
92 double y0 = tTrack->r0 * sin (tTrack->phi0);
93 double rc = tTrack->pt / (bFactor * para.bField);
94 double trackPhi0 = tTrack->psi + tTrack->q * 0.5 * M_PI / fabs ((
double) tTrack->q);
95 double xc = x0 - rc * cos (trackPhi0);
96 double yc = y0 - rc * sin (trackPhi0);
101 localPhi[0] = para.phiMin ;
102 localPhi[1] = para.phiMax ;
105 double sinPhi, cosPhi, tanPhi ;
106 double a, b, c, b2minus4ac ;
107 double x1, y1, x2, y2, r1, r2 ;
108 c = xc * xc + yc * yc - rc * rc ;
109 for (
int i = 0 ; i < 2 ; i++ ) {
110 sinPhi = sin(localPhi[i]);
111 cosPhi = cos(localPhi[i]);
112 tanPhi = tan(localPhi[i]);
113 a = 1. + tanPhi * tanPhi ;
114 b = -2. * xc - 2. * yc * tanPhi ;
116 b2minus4ac = b * b - 4. * a * c ;
117 if ( b2minus4ac > 0 ) {
118 double rootB2Minus4ac = sqrt(b2minus4ac);
120 x1 = 0.5 * (-b + rootB2Minus4ac) / a ;
122 r1 = sqrt(x1*x1+y1*y1);
126 if ( cosPhi != 0 ) ratiox = x1/cosPhi ;
128 if ( sinPhi != 0 ) ratiox = y1/sinPhi ;
130 if ( ratiox >= 0 && ratioy >= 0 &&
131 r1 > rTpcMin && r1 < rTpcMax ) {
136 x2 = 0.5 * (-b - rootB2Minus4ac) / a ;
138 r2 = sqrt(x2*x2+y2*y2);
140 if ( cosPhi != 0 ) ratiox = x2/cosPhi ;
142 if ( sinPhi != 0 ) ratioy = y2/sinPhi ;
145 if ( ratiox >= 0 && ratioy >= 0 &&
146 r2 > rTpcMin && r2 < rTpcMax ) {
156 double zMembrane = 0 ;
157 double sToMembrane = (zMembrane - tTrack->z0 ) / tTrack->tanl ;
158 double dangle = sToMembrane / rc ;
159 double angle = dangle + trackPhi0 ;
160 double xMembrane = xc + rc * cos(angle) ;
161 double yMembrane = yc + rc * sin(angle) ;
162 double rMembrane = sqrt(xMembrane*xMembrane+yMembrane*yMembrane);
163 if ( rMembrane > rTpcMin && rMembrane < rTpcMax ) {
173 int FtfSl3::fillHits (
unsigned int maxBytes,
char* buff,
unsigned int token ) {
178 LOG (ERR,
"FtfSl3::fillHits: buffer with %d bytes too small \n", maxBytes ) ;
186 head->nrClusters_in_sector = nHits ;
188 memcpy(head->bh.bank_type,CHAR_L3_SECCD,8);
189 head->bh.bank_id = sectorNr;
190 head->bh.format_ver = DAQ_RAW_FORMAT_VERSION ;
191 head->bh.byte_order = DAQ_RAW_FORMAT_ORDER ;
192 head->bh.format_number = 0;
193 head->bh.token = token;
194 head->bh.w9 = DAQ_RAW_FORMAT_WORD9;
204 for ( i = 0 ; i < nTracks ; i++ ) {
207 nextHit = (
FtfHit *)nextHit->nextTrackHit) {
208 hitP->padrow = nextHit->row ;
209 hitP->pad = nextHit->buffer1 ;
210 hitP->time = nextHit->buffer2 ;
211 hitP->flags = nextHit->flags ;
212 hitP->charge = (short)nextHit->q ;
213 hitP->RB_MZ = (
short)nextHit->hardwareId ;
214 hitP->trackId =
track[i].id ;
215 if ( !(nextHit->track) ) {
216 LOG (ERR,
"FtfSl3:fillHits: we got a problem track %d row hit %d \n",
217 track[i].
id, hitP->padrow ) ;
226 for ( i = 0 ; i < nHits ; i++ ) {
227 nextHit = &(
hit[i]) ;
228 if ( nextHit->track ) continue ;
229 hitP->padrow = nextHit->row ;
230 hitP->pad = nextHit->buffer1 ;
231 hitP->time = nextHit->buffer2 ;
232 hitP->flags = nextHit->flags ;
233 hitP->charge = (short)nextHit->q ;
234 hitP->RB_MZ = (
short)nextHit->hardwareId ;
240 if ( counter != nHits ) {
241 LOG (ERR,
"FtfSl3:fillHits: Warning! Actual number of hits written %d total nHits %d \n",
245 head->bh.length = ((
char *)hitP-buff) / 4 ;
247 return ((
char *)hitP-buff) ;
252 int FtfSl3::fillTracks (
int maxBytes,
char* buff,
unsigned int token ) {
256 LOG(ERR,
"ERROR: trying to fill NULL buffer");
260 LOG(DBG,
"fill nTracks = %d", nTracks);
261 int counter = nTracks ;
263 unsigned int headSize;
271 char *pointer = buff +
sizeof(
struct L3_SECTP) ;
273 char *endOfData = pointer + headSize
276 int nBytes = (endOfData-buff) ;
277 if ( nBytes > maxBytes ) {
278 LOG(ERR,
"FtfSl3::fillTracks: %d bytes needed, %d max, too short a buffer \n ",
290 memcpy(head->bh.bank_type,CHAR_L3_SECTP,8);
291 head->bh.length =
sizeof(
struct L3_SECTP) / 4 ;
292 head->bh.bank_id = sectorNr;
293 LOG(DBG,
"set bank_id to %d", sectorNr);
294 head->bh.format_ver = DAQ_RAW_FORMAT_VERSION ;
295 head->bh.byte_order = DAQ_RAW_FORMAT_ORDER ;
296 head->bh.format_number = 1;
297 head->bh.token = token;
298 head->bh.w9 = DAQ_RAW_FORMAT_WORD9;
301 head->nHits = (
unsigned int)nHits ;
302 head->nTracks = (
unsigned int)nTracks ;
303 head->cpuTime = (
unsigned int)rint(cpuTime * 1000000);
304 head->realTime = (
unsigned int)rint(realTime * 1000000) ;
305 head->xVert = (int)rint(para.xVertex * 1000000);
306 head->yVert = (int)rint(para.yVertex * 1000000);
307 head->zVert = (int)rint(para.zVertex * 1000000);
309 head->banks[0].off = (pointer-buff) / 4;
310 head->banks[0].len = (endOfData-pointer)/ 4 ;
311 head->banks[1].off = 0 ;
312 head->banks[1].len = 0 ;
313 head->banks[2].off = 0 ;
314 head->banks[2].len = 0 ;
328 memcpy(LTD->bh.bank_type, CHAR_L3_LTD, 8);
331 LTD->bh.bank_id = sectorNr ;
332 LTD->bh.format_ver = DAQ_RAW_FORMAT_VERSION ;
333 LTD->bh.byte_order = DAQ_RAW_FORMAT_ORDER ;
334 LTD->bh.format_number = 0 ;
335 LTD->bh.token = token ;
336 LTD->bh.w9 = DAQ_RAW_FORMAT_WORD9 ;
340 for (
int i = 0 ; i < nTracks ; i++ ) {
342 uSTrack->id =
track[i].id ;
343 if ( canItBeMerged ( &(
track[i]) ) ) {
346 uSTrack->nHits =
track[i].nHits ;
347 uSTrack->ndedx =
track[i].nDedx;
348 uSTrack->innerMostRow =
track[i].innerMostRow ;
349 uSTrack->outerMostRow =
track[i].outerMostRow ;
350 uSTrack->xy_chisq = (
unsigned short)rint(10 *
track[i].chi2[0]
351 /
float(
track[i].nHits));
352 uSTrack->sz_chisq = (
unsigned short)rint(10 *
track[i].chi2[1]
353 /
float(
track[i].nHits));
354 uSTrack->dedx =
track[i].dedx ;
355 uSTrack->pt =
track[i].pt * float(
track[i].q) ;
356 uSTrack->psi =
track[i].psi ;
357 uSTrack->tanl =
track[i].tanl ;
358 uSTrack->r0 =
track[i].r0 ;
359 uSTrack->phi0 =
track[i].phi0 ;
360 uSTrack->z0 =
track[i].z0 ;
361 uSTrack->trackLength =
track[i].length ;
362 uSTrack->dpt = (short)(32768. *
track[i].dpt /
track[i].pt ) ;
364 uSTrack->dtanl =
track[i].CompressOver1(64.*
track[i].dtanl,
track[i].tanl);
365 uSTrack->dz0 = (short)(1024. *
track[i].dz0 ) ;
383 int FtfSl3::getNrTracks (
void) {
389 int FtfSl3::setup (
int maxHitsIn,
int maxTracksIn ) {
394 para.setDefaults ( ) ;
402 double toRad = acos(-1.)/180. ;
404 sectorG[ 0].phiMin = 45. * toRad ;
405 sectorG[ 1].phiMin = 15. * toRad ;
406 sectorG[ 2].phiMin = 345. * toRad ;
407 sectorG[ 3].phiMin = 315. * toRad ;
408 sectorG[ 4].phiMin = 285. * toRad ;
409 sectorG[ 5].phiMin = 255. * toRad ;
410 sectorG[ 6].phiMin = 225. * toRad ;
411 sectorG[ 7].phiMin = 195. * toRad ;
412 sectorG[ 8].phiMin = 165. * toRad ;
413 sectorG[ 9].phiMin = 135. * toRad ;
414 sectorG[10].phiMin = 105. * toRad ;
415 sectorG[11].phiMin = 75. * toRad ;
416 sectorG[12].phiMin = 105. * toRad ;
417 sectorG[13].phiMin = 135. * toRad ;
418 sectorG[14].phiMin = 165. * toRad ;
419 sectorG[15].phiMin = 195. * toRad ;
420 sectorG[16].phiMin = 225. * toRad ;
421 sectorG[17].phiMin = 255. * toRad ;
422 sectorG[18].phiMin = 285. * toRad ;
423 sectorG[19].phiMin = 315. * toRad ;
424 sectorG[20].phiMin = 345. * toRad ;
425 sectorG[21].phiMin = 15. * toRad ;
426 sectorG[22].phiMin = 45. * toRad ;
427 sectorG[23].phiMin = 75. * toRad ;
429 sectorG[ 0].phiMax = 75. * toRad ;
430 sectorG[ 1].phiMax = 45. * toRad ;
431 sectorG[ 2].phiMax = 15. * toRad ;
432 sectorG[ 3].phiMax = 345. * toRad ;
433 sectorG[ 4].phiMax = 315. * toRad ;
434 sectorG[ 5].phiMax = 285. * toRad ;
435 sectorG[ 6].phiMax = 255. * toRad ;
436 sectorG[ 7].phiMax = 225. * toRad ;
437 sectorG[ 8].phiMax = 195. * toRad ;
438 sectorG[ 9].phiMax = 165. * toRad ;
439 sectorG[10].phiMax = 135. * toRad ;
440 sectorG[11].phiMax = 105. * toRad ;
441 sectorG[12].phiMax = 135. * toRad ;
442 sectorG[13].phiMax = 165. * toRad ;
443 sectorG[14].phiMax = 195. * toRad ;
444 sectorG[15].phiMax = 225. * toRad ;
445 sectorG[16].phiMax = 255. * toRad ;
446 sectorG[17].phiMax = 285. * toRad ;
447 sectorG[18].phiMax = 315. * toRad ;
448 sectorG[19].phiMax = 345. * toRad ;
449 sectorG[20].phiMax = 15. * toRad ;
450 sectorG[21].phiMax = 45. * toRad ;
451 sectorG[22].phiMax = 75. * toRad ;
452 sectorG[23].phiMax = 105. * toRad ;
454 double etaMin = 0.4 ;
455 double etaMax = 2.3 ;
457 for (
int sector = 0 ; sector < 24 ; sector++ ) {
458 sectorG[sector].phiShift = 0 ;
460 sectorG[sector].etaMin = -1. * etaMin ;
461 sectorG[sector].etaMax = etaMax ;
464 sectorG[sector].etaMin = -1. * etaMax ;
465 sectorG[sector].etaMax = etaMin ;
468 sectorG[ 2].phiShift = 16. * toRad ;
469 sectorG[20].phiShift = 16. * toRad ;
477 maxHits = maxHitsIn ;
478 maxTracks = maxTracksIn ;
482 para.phiMin = 0.F * pi / 180.F ;
483 para.phiMax =360.F * pi / 180.F ;
487 para.trackDebug = 24 ;
488 para.debugLevel = 1 ;
502 int FtfSl3::readMezzanine (
int sector,
int readOutBoard,
511 if(mzcld->bh.length <= 10) {
525 if ( !checkByteOrder(mzcld->bh.byte_order) ) swapByte = 1 ;
527 tmp32 = mzcld->padrowFiller ;
530 if ( swapByte ) rows = swap32(rows);
534 for (i=0; i<rows; i++) {
549 if((row<0) || (row>45)){
550 LOG(ERR,
"ERROR: row (%i) is wrong in TPCMZCLD, len=%d\n",
555 for ( j=0; j<len; j++) {
558 unsigned short time ;
559 unsigned short charge;
562 unsigned short flags = 0;
571 unsigned short flags ;
572 unsigned short charge ;
575 xt = (
struct xt *) tmp32++ ;
576 c = (
struct c *) tmp32++ ;
591 pad = swap16(xt->x) ;
592 time = swap16(xt->t) ;
594 fla = swap16(c->flags) ;
595 charge = swap16(c->charge) ;
600 if(pad & 0x8000) flags |= FCF_DOUBLE_PAD ;
601 if(pad & 0x4000) flags |= FCF_DEAD_EDGE ;
602 if(time & 0x8000) flags |= FCF_ONEPAD ;
603 if(fla & 0x8000) flags |= FCF_ROW_EDGE ;
604 if(fla & 0x4000) flags |= FCF_BROKEN_EDGE ;
609 fp = (double)pad / 64. ;
610 ft = (double)time/ 64. ;
613 LOG(DBG,
"**************************************MZ*********************************");
615 if ( ft < minTimeBin ) continue ;
616 if ( ft > maxTimeBin ) continue ;
617 if ( c->charge < minClusterCharge ) continue ;
618 if ( c->charge > maxClusterCharge ) continue ;
621 LOG(ERR,
"FtfSl3:readMezzaninne row %d \n", row ) ;
622 LOG (ERR,
"ft %f min max %d %d \n", ft, minTimeBin, maxTimeBin ) ;
623 LOG (ERR
"charge %d min max %d %d \n", c->charge, minClusterCharge, maxClusterCharge ) ;
634 PTRS.Setptrs((
double)fp, (
double)ft,(
double)row, (
double)sector) ;
635 getCoordinateTransformer()->raw_to_global(PTRS,XYZ) ;
639 hitP->id = nHits+counter ;
641 hitP->sector = sector ;
643 hitP->x = (float) XYZ.Getx();
644 hitP->y = (float) XYZ.Gety();
645 hitP->z = (float) XYZ.Getz();
651 hitP->buffer1 = pad ;
652 hitP->buffer2 = time ;
654 hitP->flags = (flags | (1<<7) );
656 hitP->flags = flags ;
658 hitP->hardwareId = readOutBoard * 16 + mezzanninneNr ;
671 if ( (nHits+counter)>maxHits ) {
672 LOG(ERR,
"Error - FtfSl3:read: Hit array too small: %d + %d > %d \n",
673 nHits, counter, maxHits ) ;
688 int FtfSl3::readSector (
struct bankHeader *bank ) {
705 if ( 0 == strncmp(bank->bank_type, CHAR_TPCSECLP, 8 ) ){
711 }
else if ( 0 == strncmp(bank->bank_type, CHAR_TPCSECP, 8 ) ){
715 if(bank->byte_order == DAQ_RAW_FORMAT_ORDER)
716 seclp = (
TPCSECLP *)((
char*)bank + 4*bank->w9);
718 seclp = (
TPCSECLP *)((
char*)bank + 4*swap32(bank->w9));
724 strncpy(type, bank->bank_type, 8);
726 LOG(ERR,
"readSector: Unknown bank type: '%s'\n", type);
738 if ( !checkByteOrder(seclp->bh.byte_order) ) swapByte = 1 ;
742 sector = (
unsigned int)seclp->bh.bank_id ;
743 if ( swapByte ) sector = swap32(sector) ;
746 LOG(DBG,
"Set sectorNr to %d", sectorNr);
747 if ( sectorNr < 1 || sectorNr > 24 ) {
748 LOG(ERR,
"Error - FtfSl3::readSector: Wrong sector %d!\n",sectorNr);
753 para.phiMin = sectorG[sector-1].phiMin ;
754 para.phiMax = sectorG[sector-1].phiMax ;
755 para.etaMin = sectorG[sector-1].etaMin ;
756 para.etaMax = sectorG[sector-1].etaMax ;
759 for (iRb=0; iRb<SB_RB_NUM; iRb++) {
766 para.phiShift = 0.8 ;
768 else if ( sector == 22 ) {
771 para.phiShift = 0.27 ;
774 if ( sectorG[sector-1].phiMin < para.phiMin )
775 para.phiMin = sectorG[sector-1].phiMin ;
776 if ( sectorG[sector-1].phiMax > para.phiMax )
777 para.phiMax = sectorG[sector-1].phiMax ;
780 if ( sectorG[sector-1].etaMin < para.etaMin )
781 para.etaMin = sectorG[sector-1].etaMin ;
782 if ( sectorG[sector-1].etaMax > para.etaMax )
783 para.etaMax = sectorG[sector-1].etaMax ;
789 int off = (
unsigned int)seclp->rb[iRb].off;
790 if ( swapByte ) off = swap32(off);
791 if ( !off ) continue ;
792 rbclp = (
struct TPCRBCLP *)((
char *)seclp + off * 4) ;
794 int swapByteMezzaninne = 0 ;
795 if ( !checkByteOrder(rbclp->bh.byte_order) ) swapByteMezzaninne = 1 ;
798 for (kMz=0; kMz<RB_MZ_NUM; kMz++) {
800 if (!rbclp->mz[kMz].off)
continue;
801 off = rbclp->mz[kMz].off ;
802 if ( swapByteMezzaninne ) off = swap32(off);
805 if(strncmp((
char*)mzcld,
"TPCMZCLD",8)!=0){
806 if (swapByteMezzaninne) {
807 LOG(ERR,
"ERROR: TPCMZCLD header not found off=%d len=%d\n",
808 swap32(rbclp->mz[kMz].off), swap32(rbclp->mz[kMz].len));
810 LOG(ERR,
"ERROR: TPCMZCLD header not found off=%d len=%d\n",
811 rbclp->mz[kMz].off, rbclp->mz[kMz].len);
816 nHitsOfMz = readMezzanine (sector, iRb, kMz, mzcld);
818 if (swapByteMezzaninne) {
819 LOG(ERR,
"ERROR: wrong reading mezzanine off=%d len=%d\n",
820 swap32(rbclp->mz[kMz].off), swap32(rbclp->mz[kMz].len));
822 LOG(ERR,
"ERROR: wrong reading mezzanine off=%d len=%d\n",
823 rbclp->mz[kMz].off, rbclp->mz[kMz].len);
845 int FtfSl3::setTrackingAngles(
int sector)
847 if(sector < 1 || sector > 24) {
848 LOG(ERR,
"Bad sector = %d",sector,0,0,0,0);
854 para.phiMin = sectorG[sector-1].phiMin ;
855 para.phiMax = sectorG[sector-1].phiMax ;
856 para.etaMin = sectorG[sector-1].etaMin ;
857 para.etaMax = sectorG[sector-1].etaMax ;
866 else if ( sector == 22 ) {
869 para.phiShift = 0.27;
872 if ( sectorG[sector-1].phiMin < para.phiMin )
873 para.phiMin = sectorG[sector-1].phiMin ;
874 if ( sectorG[sector-1].phiMax > para.phiMax )
875 para.phiMax = sectorG[sector-1].phiMax ;
879 if ( sectorG[sector-1].etaMin < para.etaMin )
880 para.etaMin = sectorG[sector-1].etaMin ;
881 if ( sectorG[sector-1].etaMax > para.etaMax )
882 para.etaMax = sectorG[sector-1].etaMax ;
896 void FtfSl3::setClustersFromGl3Event(
gl3Event *event,
int sector) {
897 int filtered_out = 0;
900 LOG(DBG,
"set sectorNr to %d maxHits=%d nhits=%d", sector, maxHits, event->nHits);
902 for(
int i=event->sectorFirstHit[sector]; i < event->nHits; i++) {
904 LOG(ERR,
"Too many hits for sector %d, (%d/%d) truncating", sector, i, maxHits);
908 gl3Hit *gl3 = &
event->hit[i];
909 if((gl3->rowSector / 100) != sector)
return;
914 hitP->row = gl3->rowSector % 100;
915 hitP->sector = sector;
916 hitP->x = gl3->getX();
917 hitP->y = gl3->getY();
918 hitP->z = gl3->getZ();
925 hitP->flags = gl3->flags;
927 hitP->q = gl3->charge;
928 hitP->hardwareId = 0;
933 if(hitP->q < minClusterCharge) { filtered_out++;
continue; }
934 if(hitP->q > maxClusterCharge) { filtered_out++;
continue; }
941 LOG(DBG,
"sect = %d (%d) nhits = %d (%d)", sector, event->sectorFirstHit[sector], nHits, filtered_out);
1104 int FtfSl3::readSector (
DATAP *datap,
int sector) {
1106 if ( sector < 1 && sector > 24 ) {
1107 LOG(ERR,
"Error - FtfSl3::readSector: Wrong sector %d!\n",sectorNr);
1115 if(datap->bh.byte_order != DAQ_RAW_FORMAT_ORDER) swapdatap = 1;
1116 len = qswap32(swapdatap, datap->det[TPC_ID].len);
1117 off = qswap32(swapdatap, datap->det[TPC_ID].off);
1118 if(len == 0)
return -1;
1119 if(off == 0)
return -1;
1121 TPCP *tpcp = (
TPCP *)((u_int *)datap + off) ;
1123 if(checkBank((
char *)tpcp,
"TPCP") < 0)
return -1;
1124 if(tpcp->bh.byte_order != DAQ_RAW_FORMAT_ORDER) swaptpcp = 1;
1125 len = qswap32(swaptpcp, tpcp->sb[sector-1].len);
1126 off = qswap32(swaptpcp, tpcp->sb[sector-1].off);
1127 if(len == 0)
return -1;
1128 if(off == 0)
return -1;
1132 if(checkBank((
char *)secp,
"TPCSECP") < 0)
return -1;
1133 if(secp->bh.byte_order != DAQ_RAW_FORMAT_ORDER) swapsecp = 1;
1134 off = qswap32(swapsecp, secp->bh.w9);
1135 if(off == 0)
return -1;
1138 if(checkBank((
char *)seclp,
"TPCSECLP") < 0)
return -1;
1152 int FtfSl3::readSector (
struct TPCSECLP *seclp1,
struct TPCSECLP *seclp2 ) {
1157 int sector,tmpsector;
1167 short swapByte1 = 0 ;
1168 short swapByte2 = 0;
1169 if ( !checkByteOrder(seclp1->bh.byte_order) ) swapByte1 = 1 ;
1170 if ( !checkByteOrder(seclp2->bh.byte_order) ) swapByte2 = 1 ;
1174 sector = (
unsigned int)seclp1->bh.bank_id ;
1175 if ( swapByte1 ) sector = swap32(sector) ;
1176 tmpsector = (
unsigned int)seclp2->bh.bank_id ;
1177 if ( swapByte2 ) tmpsector = swap32(tmpsector) ;
1179 if(tmpsector != sector){
1180 LOG(ERR,
"Error in embedding got different sectors to read in\n");
1183 LOG(ERR,
"sector: %i\n",sector);
1187 para.phiMin = sectorG[sector-1].phiMin ;
1188 para.phiMax = sectorG[sector-1].phiMax ;
1189 para.etaMin = sectorG[sector-1].etaMin ;
1190 para.etaMax = sectorG[sector-1].etaMax ;
1194 if ( sectorNr < 0 && sectorNr > 24 ) {
1195 LOG(ERR,
"Error - FtfSl3::readSector: Wrong sector %d!\n",sectorNr);
1200 swapByte = swapByte1;
1203 for(
int embed=0;embed<2;embed++){
1209 for (iRb=0; iRb<SB_RB_NUM; iRb++) {
1213 if ( sector == 4 ) {
1216 para.phiShift = 0.8 ;
1218 else if ( sector == 22 ) {
1221 para.phiShift = 0.27 ;
1224 if ( sectorG[sector-1].phiMin < para.phiMin ) para.phiMin = sectorG[sector-1].phiMin ;
1225 if ( sectorG[sector-1].phiMax > para.phiMax ) para.phiMax = sectorG[sector-1].phiMax ;
1228 if ( sectorG[sector-1].etaMin < para.etaMin ) para.etaMin = sectorG[sector-1].etaMin ;
1229 if ( sectorG[sector-1].etaMax > para.etaMax ) para.etaMax = sectorG[sector-1].etaMax ;
1234 if ( !(
unsigned int)seclp->rb[iRb].off) continue ;
1236 int off = (
unsigned int)seclp->rb[iRb].off;
1237 if ( swapByte ) off = swap32(off);
1238 rbclp = (
struct TPCRBCLP *)((
char *)seclp + off * 4) ;
1239 int swapByteMezzaninne = 0 ;
1240 if ( !checkByteOrder(rbclp->bh.byte_order) ) swapByteMezzaninne = 1 ;
1243 for (kMz=0; kMz<RB_MZ_NUM; kMz++) {
1245 if( ! rbclp->mz[kMz].off) {
1250 if ( debugLevel > 1 ) {
1251 LOG(ERR,
"FtfSl3::readSector: MZCLD %d exists!\n", kMz+1) ;
1256 off = rbclp->mz[kMz].off ;
1257 if ( swapByteMezzaninne ) off = swap32(off);
1258 if (off == 0)
continue;
1262 if(strncmp((
char*)mzcld,
"TPCMZCLD",8)!=0){
1263 LOG(ERR,
"ERROR: TPCMZCLD header not found\n");
1267 nHitsOfMz = readMezzanine (sector, iRb, kMz, mzcld);
1269 LOG(ERR,
"FtfSl3:readSector: wrong reading mezzanine \n" ) ;
1279 swapByte = swapByte2;
1296 int FtfSl3::processSector ( ){
1300 for (
int h = 0 ; h < nHits ; h++ ) {
1303 para.eventReset = 1 ;
1305 if(process()==1)
return 1 ;
1306 if (para.dEdx) dEdx();
1308 if ( debugLevel > 0 )
1309 LOG(ERR,
" FtfSl3::process: tracks %i Time: real %f cpu %f\n",
1310 nTracks, realTime, cpuTime ) ;
1319 int FtfSl3::processData(
TPCSECLP* seclp,
char* trackBuffer,
1320 int maxTrackBytes,
int& nTrackBytes,
1321 char* hitBuffer,
int maxHitBytes,
int& nHitBytes)
1325 if (!checkByteOrder(seclp->bh.byte_order)) swapByte = 1;
1327 int token = (
unsigned int)seclp->bh.token;
1328 if (swapByte) token = swap32(token);
1335 int ret = fillTracks(maxTrackBytes, trackBuffer, token);
1336 if (ret>0) nTrackBytes = ret;
1341 int ret = fillHits(maxHitBytes, hitBuffer, token);
1342 if (ret>0) nHitBytes = ret;
1352 int FtfSl3::dEdx ( ) {
1354 for (
int i = 0 ; i<nTracks ; i++ ){
1355 if (
track[i].nHits<para.minHitsForDedx) {
1360 fDedx->TruncatedMean(&
track[i]);
1367 int FtfSl3::setParameters ( ) {
1373 para.hitChi2Cut = 50. ;
1374 para.goodHitChi2 = 20. ;
1375 para.trackChi2Cut = 10. ;
1376 para.maxChi2Primary = 50. ;
1377 para.segmentRowSearchRange = 2 ;
1378 para.trackRowSearchRange = 3 ;
1381 para.dphiMerge = 0.01F ;
1382 para.detaMerge = 0.02F ;
1383 para.etaMinTrack = -2.2F ;
1384 para.etaMaxTrack = 2.2F ;
1388 para.getErrors = 0 ;
1389 para.goBackwards = 1 ;
1390 para.goodDistance = 5.F ;
1391 para.mergePrimaries = 0 ;
1392 para.maxDistanceSegment = 50.F ;
1393 para.minHitsPerTrack = 5 ;
1394 para.nHitsForSegment = 2 ;
1396 para.nEtaTrack = 40 ;
1398 para.nPhiTrack = 40 ;
1399 para.nPrimaryPasses = 1 ;
1400 para.nSecondaryPasses = 0 ;
1401 para.xyErrorScale = 1.0F ;
1402 para.szErrorScale = 1.0F ;
1403 para.phiClosed = 0 ;
1406 para.ptMinHelixFit = 0.1 ;
1407 para.rVertex = 0.F ;
1408 para.xVertex = 0.F ;
1409 para.yVertex = 0.F ;
1410 para.zVertex = 0.F ;
1411 para.dxVertex = 0.05F ;
1412 para.dyVertex = 0.05F ;
1413 para.phiVertex = 0.F ;