| 259 |
* @param plane Plane index (0,1,2,3,4,5) |
* @param plane Plane index (0,1,2,3,4,5) |
| 260 |
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
| 261 |
*/ |
*/ |
| 262 |
|
Float_t ToFLevel2::GetdEdx(ToFTrkVar *trk, Int_t plane, Int_t adcfl){ |
| 263 |
|
// printf("fiffi\n"); |
| 264 |
|
Float_t dedx = 0.; |
| 265 |
|
Float_t PadEdx =0.; |
| 266 |
|
Int_t SatWarning; |
| 267 |
|
Int_t pad=-1; |
| 268 |
|
// |
| 269 |
|
if(!trk) return 0; //ELENA |
| 270 |
|
// |
| 271 |
|
if ( trk->trkseqno == -1 ){ //standalone, only paddles along the track, or about... |
| 272 |
|
// printf("ciccio\n"); |
| 273 |
|
Float_t xleft=0; |
| 274 |
|
Float_t xright=0; |
| 275 |
|
Float_t yleft=0; |
| 276 |
|
Float_t yright=0; |
| 277 |
|
Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.}; |
| 278 |
|
Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.}; |
| 279 |
|
ToFTrkVar *t_tof = trk; |
| 280 |
|
|
| 281 |
|
xtof_temp[0]=t_tof->xtofpos[0]; |
| 282 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
| 283 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
| 284 |
|
ytof_temp[1]=t_tof->ytofpos[0]; |
| 285 |
|
|
| 286 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
| 287 |
|
ytof_temp[2]=t_tof->ytofpos[1]; |
| 288 |
|
xtof_temp[3]=t_tof->xtofpos[1]; |
| 289 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
| 290 |
|
|
| 291 |
|
xtof_temp[4]=t_tof->xtofpos[2]; |
| 292 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
| 293 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
| 294 |
|
ytof_temp[5]=t_tof->ytofpos[2]; |
| 295 |
|
|
| 296 |
|
if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){ |
| 297 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
| 298 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
| 299 |
|
}else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){ |
| 300 |
|
ytof_temp[0]=t_tof->ytofpos[0]; |
| 301 |
|
this->GetPaddleGeometry(0,(Int_t)log2(this->tof_j_flag[0]),xleft, xright, yleft, yright); |
| 302 |
|
xtof_temp[1]=xleft+2.55; |
| 303 |
|
}else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){ |
| 304 |
|
xtof_temp[1]=t_tof->xtofpos[0]; |
| 305 |
|
this->GetPaddleGeometry(1,(Int_t)log2(this->tof_j_flag[1]),xleft, xright, yleft, yright); |
| 306 |
|
ytof_temp[0]=yleft+2.75; |
| 307 |
|
} |
| 308 |
|
|
| 309 |
|
if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){ |
| 310 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
| 311 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
| 312 |
|
}else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){ |
| 313 |
|
ytof_temp[3]=t_tof->ytofpos[1]; |
| 314 |
|
this->GetPaddleGeometry(3,(Int_t)log2(this->tof_j_flag[3]),xleft, xright, yleft, yright); |
| 315 |
|
xtof_temp[2]=xleft+4.5; |
| 316 |
|
}else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){ |
| 317 |
|
xtof_temp[2]=t_tof->xtofpos[1]; |
| 318 |
|
this->GetPaddleGeometry(2,(Int_t)log2(this->tof_j_flag[2]),xleft, xright, yleft, yright); |
| 319 |
|
ytof_temp[3]=yleft+3.75; |
| 320 |
|
} |
| 321 |
|
|
| 322 |
|
if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){ |
| 323 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
| 324 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
| 325 |
|
}else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){ |
| 326 |
|
ytof_temp[4]=t_tof->ytofpos[2]; |
| 327 |
|
this->GetPaddleGeometry(4,(Int_t)log2(this->tof_j_flag[4]),xleft, xright, yleft, yright); |
| 328 |
|
xtof_temp[5]=xleft+3; |
| 329 |
|
}else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){ |
| 330 |
|
xtof_temp[5]=t_tof->xtofpos[2]; |
| 331 |
|
this->GetPaddleGeometry(5,(Int_t)log2(this->tof_j_flag[5]),xleft, xright, yleft, yright); |
| 332 |
|
ytof_temp[4]=yleft+2.5; |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
if ( (xtof_temp[0])> 17.85 && fabs(xtof_temp[0])<17.85+4. ) xtof_temp[0] =17.84; |
| 336 |
|
if ( (xtof_temp[1])> 17.85 && fabs(xtof_temp[1])<17.85+4. ) xtof_temp[1] =17.84; |
| 337 |
|
if ( (ytof_temp[0])> 13.75 && fabs(ytof_temp[0])<13.75+4. ) ytof_temp[0] =13.74; |
| 338 |
|
if ( (ytof_temp[1])> 13.75 && fabs(ytof_temp[1])<13.75+4. ) ytof_temp[1] =13.74; |
| 339 |
|
if ( (xtof_temp[0])< -17.85 && fabs(xtof_temp[0])>-(17.85+4.) ) xtof_temp[0] =-17.84; |
| 340 |
|
if ( (xtof_temp[1])< -17.85 && fabs(xtof_temp[1])>-(17.85+4.) ) xtof_temp[1] =-17.84; |
| 341 |
|
if ( (ytof_temp[0])< -13.75 && fabs(ytof_temp[0])>-(13.75+4.) ) ytof_temp[0] =-13.74; |
| 342 |
|
if ( (ytof_temp[1])< -13.75 && fabs(ytof_temp[1])>-(13.75+4.) ) ytof_temp[1] =-13.74; |
| 343 |
|
|
| 344 |
|
if ( (xtof_temp[2])> 4.5 && (xtof_temp[2])<4.5+4. ) xtof_temp[2] =4.4; |
| 345 |
|
if ( (xtof_temp[3])> 4.45 && (xtof_temp[3])<4.5+4. ) xtof_temp[3] =4.4; |
| 346 |
|
if ( (ytof_temp[2])> 3.75 && (ytof_temp[2])<3.75+4. ) ytof_temp[2] =3.74; |
| 347 |
|
if ( (ytof_temp[3])> 3.75 && (ytof_temp[3])<3.75+4. ) ytof_temp[3] =3.74; |
| 348 |
|
if ( (xtof_temp[2])< -4.5 && (xtof_temp[2])>-(4.5+4.) ) xtof_temp[2] =-4.4; |
| 349 |
|
if ( (xtof_temp[3])< -4.45 && (xtof_temp[3])>-(4.5+4.) ) xtof_temp[3] =-4.4; |
| 350 |
|
if ( (ytof_temp[2])< -3.75 && (ytof_temp[2])>-(3.75+4.) ) ytof_temp[2] =-3.74; |
| 351 |
|
if ( (ytof_temp[3])< -3.75 && (ytof_temp[3])>-(3.75+4.) ) ytof_temp[3] =-3.74; |
| 352 |
|
|
| 353 |
|
if ( (xtof_temp[4])> 6. && (xtof_temp[4])<6.+4. ) xtof_temp[2] =5.9; |
| 354 |
|
if ( (xtof_temp[5])> 6. && (xtof_temp[5])<6.+4. ) xtof_temp[3] =5.9; |
| 355 |
|
if ( (ytof_temp[4])> 5. && (ytof_temp[4])<5.+4. ) ytof_temp[2] =4.9; |
| 356 |
|
if ( (ytof_temp[5])> 5. && (ytof_temp[5])<5.+4. ) ytof_temp[3] =4.9; |
| 357 |
|
if ( (xtof_temp[4])< -6. && (xtof_temp[4])>-(6.+4.) ) xtof_temp[2] =-5.9; |
| 358 |
|
if ( (xtof_temp[5])< -6. && (xtof_temp[5])>-(6.+4.) ) xtof_temp[3] =-5.9; |
| 359 |
|
if ( (ytof_temp[4])< -5. && (ytof_temp[4])>-(5.+4.) ) ytof_temp[2] =-4.9; |
| 360 |
|
if ( (ytof_temp[5])< -5. && (ytof_temp[5])>-(5.+4.) ) ytof_temp[3] =-4.9; |
| 361 |
|
|
| 362 |
|
|
| 363 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
| 364 |
|
Int_t paddleid=ii; |
| 365 |
|
pad = GetPaddleid(plane,paddleid); |
| 366 |
|
Int_t IpaddleT=-1; |
| 367 |
|
IpaddleT=this->GetPaddleIdOfTrack(xtof_temp[plane],ytof_temp[plane], plane,0.0); |
| 368 |
|
// printf("SSS %i %i %f %f %f %f \n",IpaddleT,paddleid,xtof_temp[plane],ytof_temp[plane],t_tof->xtofpos[plane],t_tof->ytofpos[plane]); |
| 369 |
|
// if ( IpaddleT == paddleid || IpaddleT-1 == paddleid || IpaddleT+1 == paddleid ){ |
| 370 |
|
if ( IpaddleT == paddleid || GetTrueNHitPaddles(plane) == 1 ){ |
| 371 |
|
//IpaddleT-1 == paddleid || IpaddleT+1 == paddleid ){ |
| 372 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
| 373 |
|
dedx += PadEdx; |
| 374 |
|
} |
| 375 |
|
}; |
| 376 |
|
} else { |
| 377 |
|
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
| 378 |
|
Int_t paddleid=ii; |
| 379 |
|
pad = GetPaddleid(plane,paddleid); |
| 380 |
|
GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning); |
| 381 |
|
dedx += PadEdx; |
| 382 |
|
// printf("TTT %i %i %f\n",paddleid,plane,PadEdx); |
| 383 |
|
}; |
| 384 |
|
} |
| 385 |
|
// |
| 386 |
|
return(dedx); |
| 387 |
|
}; |
| 388 |
|
|
| 389 |
|
|
| 390 |
|
//wm Nov 08 |
| 391 |
|
//gf Apr 07 |
| 392 |
|
/** |
| 393 |
|
* Method to get the mean dEdx from a ToF layer - ATTENTION: |
| 394 |
|
* It will sum up the dEdx of all the paddles, but since by definition |
| 395 |
|
* only the paddle hitted by the track gets a dEdx value and the other |
| 396 |
|
* paddles are set to zero, the output is just the dEdx of the hitted |
| 397 |
|
* paddle in each layer! |
| 398 |
|
* The "adcfl" option is not very useful (an artificial dEdx is per |
| 399 |
|
* definition= 1 mip and not a real measurement), anyway left in the code |
| 400 |
|
* @param notrack Track Number |
| 401 |
|
* @param plane Plane index (0,1,2,3,4,5) |
| 402 |
|
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
| 403 |
|
*/ |
| 404 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
| 405 |
// printf("fiffi\n"); |
// printf("fiffi\n"); |
| 406 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
| 764 |
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
| 765 |
|
|
| 766 |
}; |
}; |
| 767 |
|
|
| 768 |
// |
// |
| 769 |
|
// wm Nov 08 revision - saturation values included |
| 770 |
|
/// gf Apr 07 |
| 771 |
|
/** |
| 772 |
|
* Method to get the dEdx from a given ToF paddle. |
| 773 |
|
* If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise |
| 774 |
|
* just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000 |
| 775 |
|
* @param notrack Track Number |
| 776 |
|
* @param Paddle index (0,1,...,23). |
| 777 |
|
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
| 778 |
|
* @param PadEdx dEdx from a given ToF paddle |
| 779 |
|
* @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000) |
| 780 |
|
*/ |
| 781 |
|
void ToFLevel2::GetdEdxPaddle(ToFTrkVar *trk, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
| 782 |
|
|
| 783 |
|
/* |
| 784 |
|
Float_t PMTsat[48] = { |
| 785 |
|
3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, |
| 786 |
|
3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03, |
| 787 |
|
3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, |
| 788 |
|
3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98, |
| 789 |
|
3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66, |
| 790 |
|
3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ; |
| 791 |
|
*/ |
| 792 |
|
|
| 793 |
|
// new values from Napoli dec 2008 |
| 794 |
|
Float_t PMTsat[48] = { |
| 795 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
| 796 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
| 797 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
| 798 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
| 799 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
| 800 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
| 801 |
|
|
| 802 |
|
for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.; // safety margin |
| 803 |
|
|
| 804 |
|
|
| 805 |
|
PadEdx = 0.; |
| 806 |
|
// SatWarning = 1000; |
| 807 |
|
SatWarning = 0; // 0=good, increase for each bad PMT |
| 808 |
|
|
| 809 |
|
Float_t dEdx[48] = {0}; |
| 810 |
|
Int_t pmt_id = -1; |
| 811 |
|
Float_t adcraw[48]; |
| 812 |
|
// |
| 813 |
|
if(!trk) return; //ELENA |
| 814 |
|
// |
| 815 |
|
|
| 816 |
|
Int_t pmtleft=-1; |
| 817 |
|
Int_t pmtright=-1; |
| 818 |
|
GetPaddlePMT(paddleid, pmtleft, pmtright); |
| 819 |
|
|
| 820 |
|
adcraw[pmtleft] = 4095; |
| 821 |
|
adcraw[pmtright] = 4095; |
| 822 |
|
|
| 823 |
|
|
| 824 |
|
for (Int_t jj=0; jj<npmt(); jj++){ |
| 825 |
|
|
| 826 |
|
ToFPMT *pmt = GetToFPMT(jj); |
| 827 |
|
if(!pmt)break; //ELENA |
| 828 |
|
|
| 829 |
|
pmt_id = pmt->pmt_id; |
| 830 |
|
if(pmt_id==pmtleft){ |
| 831 |
|
adcraw[pmtleft] = pmt->adc; |
| 832 |
|
} |
| 833 |
|
|
| 834 |
|
if(pmt_id==pmtright){ |
| 835 |
|
adcraw[pmtright] = pmt->adc; |
| 836 |
|
} |
| 837 |
|
} |
| 838 |
|
|
| 839 |
|
|
| 840 |
|
for (Int_t i=0; i<trk->npmtadc; i++){ |
| 841 |
|
|
| 842 |
|
if((trk->adcflag).At(i)==0 || adcfl==100){ |
| 843 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = (trk->dedx).At(i); |
| 844 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = (trk->dedx).At(i); |
| 845 |
|
}else{ |
| 846 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = 0.; |
| 847 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = 0.; |
| 848 |
|
} |
| 849 |
|
} |
| 850 |
|
|
| 851 |
|
|
| 852 |
|
// if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; //old version |
| 853 |
|
|
| 854 |
|
// Increase SatWarning Counter for each PMT>Sat |
| 855 |
|
if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++; |
| 856 |
|
if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++; |
| 857 |
|
|
| 858 |
|
// if ADC > sat set dEdx=1000 |
| 859 |
|
if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.; |
| 860 |
|
if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ; |
| 861 |
|
|
| 862 |
|
// if two PMT are good, take mean dEdx, otherwise only the good dEdx |
| 863 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
| 864 |
|
if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright]; |
| 865 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
| 866 |
|
|
| 867 |
|
}; |
| 868 |
|
|
| 869 |
// gf Apr 07 |
// gf Apr 07 |
| 870 |
|
|
| 1550 |
// if ( !dbc->IsConnected() ) return 1; |
// if ( !dbc->IsConnected() ) return 1; |
| 1551 |
// stringstream myquery; |
// stringstream myquery; |
| 1552 |
// myquery.str(""); |
// myquery.str(""); |
| 1553 |
// myquery << "SET time_zone='+0:00'"; |
// myquery << "SET time_zone='+0:00'; SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"; |
| 1554 |
// dbc->Query(myquery.str().c_str()); |
// dbc->Query(myquery.str().c_str()); |
| 1555 |
// GL_PARAM *glparam = new GL_PARAM(); |
// GL_PARAM *glparam = new GL_PARAM(); |
| 1556 |
// glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
// glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |