| 1 |
#include <TObject.h> |
/** |
| 2 |
|
* \file ToFLevel2.cpp |
| 3 |
|
* \author Gianfranca DeRosa, Wolfgang Menn |
| 4 |
|
*/ |
| 5 |
|
|
| 6 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
| 7 |
#include <iostream> |
|
| 8 |
using namespace std; |
using namespace std; |
| 9 |
|
|
| 10 |
ClassImp(ToFPMT); |
ClassImp(ToFPMT); |
| 11 |
ClassImp(ToFTrkVar); |
ClassImp(ToFTrkVar); |
| 12 |
ClassImp(ToFLevel2); |
ClassImp(ToFLevel2); |
| 15 |
pmt_id = 0; |
pmt_id = 0; |
| 16 |
adc = 0.; |
adc = 0.; |
| 17 |
tdc_tw = 0.; |
tdc_tw = 0.; |
| 18 |
|
tdc = 0.; |
| 19 |
} |
} |
| 20 |
|
|
| 21 |
ToFPMT::ToFPMT(const ToFPMT &t){ |
ToFPMT::ToFPMT(const ToFPMT &t){ |
| 22 |
pmt_id = t.pmt_id; |
pmt_id = t.pmt_id; |
| 23 |
adc = t.adc; |
adc = t.adc; |
| 24 |
tdc_tw = t.tdc_tw; |
tdc_tw = t.tdc_tw; |
| 25 |
|
tdc = t.tdc; |
| 26 |
} |
} |
| 27 |
|
|
| 28 |
void ToFPMT::Clear(){ |
void ToFPMT::Clear(Option_t *t){ |
| 29 |
pmt_id = 0; |
pmt_id = 0; |
| 30 |
adc = 0.; |
adc = 0.; |
| 31 |
tdc_tw = 0.; |
tdc_tw = 0.; |
| 32 |
|
tdc = 0.; |
| 33 |
} |
} |
| 34 |
|
|
| 35 |
|
|
| 48 |
memset(beta, 0, 13*sizeof(Float_t)); |
memset(beta, 0, 13*sizeof(Float_t)); |
| 49 |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
| 50 |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
| 51 |
|
memset(xtr_tof, 0, 6*sizeof(Float_t)); |
| 52 |
|
memset(ytr_tof, 0, 6*sizeof(Float_t)); |
| 53 |
// |
// |
| 54 |
}; |
}; |
| 55 |
|
|
| 56 |
void ToFTrkVar::Clear() { |
void ToFTrkVar::Clear(Option_t *t) { |
| 57 |
trkseqno = 0; |
trkseqno = 0; |
| 58 |
npmttdc = 0; |
npmttdc = 0; |
| 59 |
npmtadc = 0; |
npmtadc = 0; |
| 66 |
memset(beta, 0, 13*sizeof(Float_t)); |
memset(beta, 0, 13*sizeof(Float_t)); |
| 67 |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
| 68 |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
memset(ytofpos, 0, 3*sizeof(Float_t)); |
| 69 |
|
memset(xtr_tof, 0, 6*sizeof(Float_t)); |
| 70 |
|
memset(ytr_tof, 0, 6*sizeof(Float_t)); |
| 71 |
// |
// |
| 72 |
}; |
}; |
| 73 |
|
|
| 86 |
memcpy(beta,t.beta,sizeof(beta)); |
memcpy(beta,t.beta,sizeof(beta)); |
| 87 |
memcpy(xtofpos,t.xtofpos,sizeof(xtofpos)); |
memcpy(xtofpos,t.xtofpos,sizeof(xtofpos)); |
| 88 |
memcpy(ytofpos,t.ytofpos,sizeof(ytofpos)); |
memcpy(ytofpos,t.ytofpos,sizeof(ytofpos)); |
| 89 |
|
memcpy(xtr_tof,t.xtr_tof,sizeof(xtr_tof)); |
| 90 |
|
memcpy(ytr_tof,t.ytr_tof,sizeof(ytr_tof)); |
| 91 |
// |
// |
| 92 |
}; |
}; |
| 93 |
|
|
| 102 |
// |
// |
| 103 |
}; |
}; |
| 104 |
|
|
| 105 |
void ToFLevel2::Clear(){ |
void ToFLevel2::Set(){//ELENA |
| 106 |
|
if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA |
| 107 |
|
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
| 108 |
|
}//ELENA |
| 109 |
|
|
| 110 |
|
void ToFLevel2::Clear(Option_t *t){ |
| 111 |
// |
// |
| 112 |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
| 113 |
if(PMT)PMT->Delete(); //ELENA |
if(PMT)PMT->Delete(); //ELENA |
| 116 |
// |
// |
| 117 |
}; |
}; |
| 118 |
|
|
| 119 |
void ToFLevel2::Delete(){ //ELENA |
void ToFLevel2::Delete(Option_t *t){ //ELENA |
| 120 |
// |
// |
| 121 |
if(ToFTrk){ |
if(ToFTrk){ |
| 122 |
ToFTrk->Delete(); //ELENA |
ToFTrk->Delete(); //ELENA |
| 162 |
//-------------------------------------- |
//-------------------------------------- |
| 163 |
/** |
/** |
| 164 |
* Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5) |
* Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5) |
| 165 |
|
* @param Plane index (0,1,2,3,4,5). |
| 166 |
*/ |
*/ |
| 167 |
Int_t ToFLevel2::GetToFPlaneID(Int_t ip){ |
Int_t ToFLevel2::GetToFPlaneID(Int_t ip){ |
| 168 |
if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1; |
if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1; |
| 170 |
}; |
}; |
| 171 |
/** |
/** |
| 172 |
* Method to get the plane index (0 1 2 3 4 5) from the plane ID (11 12 21 22 31 32) |
* Method to get the plane index (0 1 2 3 4 5) from the plane ID (11 12 21 22 31 32) |
| 173 |
|
* @param plane Plane ID (11, 12, 21, 22, 31, 32) |
| 174 |
*/ |
*/ |
| 175 |
Int_t ToFLevel2::GetToFPlaneIndex(Int_t plane_id){ |
Int_t ToFLevel2::GetToFPlaneIndex(Int_t plane_id){ |
| 176 |
if( |
if( |
| 185 |
}; |
}; |
| 186 |
/** |
/** |
| 187 |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal |
| 188 |
* from both PMTs |
* from both PMTs. The method uses the "tof_j_flag" variable. |
| 189 |
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
| 190 |
* @param paddle_id Paddle ID. |
* @param paddle_id Paddle ID. |
| 191 |
* @return 1 if the paddle was hit. |
* @return 1 if the paddle was hit. |
| 217 |
}; |
}; |
| 218 |
|
|
| 219 |
|
|
| 220 |
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){ |
//gf Apr 07 |
| 221 |
|
/** |
| 222 |
|
* Method to get the mean dEdx from a given ToF plane. This current version |
| 223 |
|
* is just summing up all PMT signals, which will not give proper results, |
| 224 |
|
* and needs a revision. |
| 225 |
|
* @param notrack Track Number |
| 226 |
|
* @param plane Plane index (0,1,2,3,4,5) |
| 227 |
|
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
| 228 |
|
*/ |
| 229 |
|
Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){ |
| 230 |
|
|
| 231 |
Float_t dedx = 0.; |
Float_t dedx = 0.; |
| 232 |
Int_t ip = 0; |
Float_t PadEdx =0.; |
| 233 |
Int_t pmt_id = 0; |
Int_t SatWarning; |
| 234 |
Int_t pl = 0; |
Int_t pad=-1; |
|
if ( plane >= 6 ){ |
|
|
ip = GetToFPlaneIndex(plane); |
|
|
} else { |
|
|
ip = plane; |
|
|
}; |
|
| 235 |
// |
// |
| 236 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
| 237 |
if(!trk) return 0; //ELENA |
if(!trk) return 0; //ELENA |
| 238 |
// |
// |
| 239 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
| 240 |
// |
Int_t paddleid=ii; |
| 241 |
pmt_id = (trk->pmtadc).At(i); |
pad = GetPaddleid(plane,paddleid); |
| 242 |
// |
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
| 243 |
pl = GetPlaneIndex(pmt_id); |
dedx += PadEdx; |
|
// |
|
|
if ( pl == ip ){ |
|
|
// // --- patch --- |
|
|
// bool ISNULL=false; |
|
|
// for(Int_t im=0; im< this->npmt(); im++){ |
|
|
// if(this->GetToFPMT(im)->pmt_id == pmt_id && this->GetToFPMT(im)->adc == 4095){ |
|
|
// cout << " ToFLevel2::GetdEdx(Int_t,Int_t) --> **warning** ADC(PMT="<<pmt_id<<") = 4095"<<endl; |
|
|
// ISNULL=true; |
|
|
// } |
|
|
// } |
|
|
// // --- patch --- |
|
|
// dedx += (trk->dedx).At(i)*(Int_t)(!ISNULL); |
|
|
dedx += (trk->dedx).At(i); |
|
|
} |
|
|
// |
|
| 244 |
}; |
}; |
| 245 |
// |
// |
| 246 |
return(dedx); |
return(dedx); |
| 247 |
}; |
}; |
| 248 |
|
|
| 249 |
|
/** |
| 250 |
|
* Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix |
| 251 |
|
* with the time-walk corrected TDC values. |
| 252 |
|
* @param notrack Track Number |
| 253 |
|
* @param adc ADC_C matrix with dEdx values |
| 254 |
|
* @param tdc TDC matrix |
| 255 |
|
*/ |
| 256 |
void ToFLevel2::GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]){ |
void ToFLevel2::GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]){ |
| 257 |
// |
// |
| 258 |
for (Int_t aa=0; aa<4;aa++){ |
for (Int_t aa=0; aa<4;aa++){ |
| 293 |
}; |
}; |
| 294 |
|
|
| 295 |
|
|
| 296 |
|
/** |
| 297 |
|
* Method to get the plane index (0 - 5) for the PMT_ID as input |
| 298 |
|
* @param pmt_id PMT_ID (0 - 47) |
| 299 |
|
*/ |
| 300 |
Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){ |
Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){ |
| 301 |
TString pmtname = GetPMTName(pmt_id); |
TString pmtname = GetPMTName(pmt_id); |
| 302 |
pmtname.Resize(3); |
pmtname.Resize(3); |
| 310 |
}; |
}; |
| 311 |
|
|
| 312 |
|
|
| 313 |
|
/** |
| 314 |
|
* Method to get the PMT_ID if the index (4,12) is given. We have 4 channels on |
| 315 |
|
* each of the 12 half-boards, this method decodes which PMT is cables to which |
| 316 |
|
* channel. |
| 317 |
|
* @param hh Channel |
| 318 |
|
* @param kk HalfBoard |
| 319 |
|
*/ |
| 320 |
Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){ |
Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){ |
| 321 |
// |
// |
| 322 |
short tof[4][24] = { |
short tof[4][24] = { |
| 345 |
return ind; |
return ind; |
| 346 |
}; |
}; |
| 347 |
|
|
|
TString ToFLevel2::GetPMTName(Int_t ind){ |
|
|
|
|
|
TString pmtname = " "; |
|
|
|
|
|
TString photoS[48] = { |
|
|
"S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", "S11_4B", |
|
|
"S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", "S11_8B", |
|
|
"S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", "S12_4B", "S12_5A", "S12_5B", "S12_6A", "S12_6B", |
|
|
"S21_1A", "S21_1B", "S21_2A", "S21_2B", |
|
|
"S22_1A", "S22_1B", "S22_2A", "S22_2B", |
|
|
"S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B", |
|
|
"S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B" |
|
|
}; |
|
|
|
|
|
|
|
|
pmtname = photoS[ind].Data(); |
|
|
|
|
|
return pmtname; |
|
|
}; |
|
|
|
|
| 348 |
|
|
| 349 |
|
/** |
| 350 |
|
* Method to get the PMT index if the PMT ID is given. This method is the |
| 351 |
|
* "reverse" of method "GetPMTid" |
| 352 |
|
* @param ind PMT_ID (0 - 47) |
| 353 |
|
* @param hb HalfBoard |
| 354 |
|
* @param ch Channel |
| 355 |
|
*/ |
| 356 |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){ |
| 357 |
// |
// |
| 358 |
short tof[4][24] = { |
short tof[4][24] = { |
| 379 |
return; |
return; |
| 380 |
}; |
}; |
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
/// gf Apr 07 |
| 386 |
|
|
| 387 |
|
/** |
| 388 |
|
* Method to get the dEdx from a given ToF paddle. |
| 389 |
|
* @param notrack Track Number |
| 390 |
|
* @param Paddle index (0,1,...,23). |
| 391 |
|
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
| 392 |
|
* @param PadEdx dEdx from a given ToF paddle |
| 393 |
|
* @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000) |
| 394 |
|
*/ |
| 395 |
|
void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
| 396 |
|
|
| 397 |
|
PadEdx = 0.; |
| 398 |
|
SatWarning = 1000; |
| 399 |
|
|
| 400 |
|
Float_t dEdx[48] = {0}; |
| 401 |
|
Int_t pmt_id = -1; |
| 402 |
|
Float_t adcraw[48]; |
| 403 |
|
// |
| 404 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
| 405 |
|
if(!trk) return; //ELENA |
| 406 |
|
// |
| 407 |
|
|
| 408 |
|
Int_t pmtleft=-1; |
| 409 |
|
Int_t pmtright=-1; |
| 410 |
|
GetPaddlePMT(paddleid, pmtleft, pmtright); |
| 411 |
|
|
| 412 |
|
adcraw[pmtleft] = 4095; |
| 413 |
|
adcraw[pmtright] = 4095; |
| 414 |
|
|
| 415 |
|
|
| 416 |
|
for (Int_t jj=0; jj<npmt(); jj++){ |
| 417 |
|
|
| 418 |
|
ToFPMT *pmt = GetToFPMT(jj); |
| 419 |
|
if(!pmt)break; //ELENA |
| 420 |
|
|
| 421 |
|
pmt_id = pmt->pmt_id; |
| 422 |
|
if(pmt_id==pmtleft){ |
| 423 |
|
adcraw[pmtleft] = pmt->adc; |
| 424 |
|
} |
| 425 |
|
|
| 426 |
|
if(pmt_id==pmtright){ |
| 427 |
|
adcraw[pmtright] = pmt->adc; |
| 428 |
|
} |
| 429 |
|
} |
| 430 |
|
|
| 431 |
|
for (Int_t i=0; i<trk->npmtadc; i++){ |
| 432 |
|
|
| 433 |
|
if((trk->adcflag).At(i)==0 || adcfl==100){ |
| 434 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = (trk->dedx).At(i); |
| 435 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = (trk->dedx).At(i); |
| 436 |
|
}else{ |
| 437 |
|
if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = 0.; |
| 438 |
|
if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = 0.; |
| 439 |
|
} |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; |
| 443 |
|
|
| 444 |
|
if(dEdx[pmtleft]!=0 && dEdx[pmtright]!=0){ |
| 445 |
|
PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
| 446 |
|
} |
| 447 |
|
if(dEdx[pmtleft]==0 && dEdx[pmtright]!=0){ |
| 448 |
|
PadEdx = dEdx[pmtright]; |
| 449 |
|
} |
| 450 |
|
if(dEdx[pmtleft]!=0 && dEdx[pmtright]==0){ |
| 451 |
|
PadEdx = dEdx[pmtleft]; |
| 452 |
|
} |
| 453 |
|
|
| 454 |
|
return; |
| 455 |
|
}; |
| 456 |
|
// |
| 457 |
|
|
| 458 |
|
|
| 459 |
|
// gf Apr 07 |
| 460 |
|
|
| 461 |
|
/** |
| 462 |
|
* Method to get the PMT name (like "S11_1A") if the PMT_ID is given. |
| 463 |
|
* Indexes of corresponding plane, paddle and pmt are also given as output. |
| 464 |
|
* @param ind PMT_ID (0 - 47) |
| 465 |
|
* @param iplane plane index (0 - 5) |
| 466 |
|
* @param ipaddle paddle index (relative to the plane) |
| 467 |
|
* @param ipmt pmt index (0(A), 1(B)) |
| 468 |
|
*/ |
| 469 |
|
TString ToFLevel2::GetPMTName(Int_t ind, Int_t &iplane, Int_t &ipaddle,Int_t &ipmt){ |
| 470 |
|
|
| 471 |
|
TString pmtname = " "; |
| 472 |
|
|
| 473 |
|
TString photoS[48] = { |
| 474 |
|
"S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", |
| 475 |
|
"S11_4B", |
| 476 |
|
"S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", |
| 477 |
|
"S11_8B", |
| 478 |
|
"S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", |
| 479 |
|
"S12_4B", "S12_5A", "S12_5B", "S12_6A", "S12_6B", |
| 480 |
|
"S21_1A", "S21_1B", "S21_2A", "S21_2B", |
| 481 |
|
"S22_1A", "S22_1B", "S22_2A", "S22_2B", |
| 482 |
|
"S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B", |
| 483 |
|
"S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B" |
| 484 |
|
}; |
| 485 |
|
|
| 486 |
|
|
| 487 |
|
pmtname = photoS[ind].Data(); |
| 488 |
|
|
| 489 |
|
TString ss = pmtname(1,2); |
| 490 |
|
iplane = (int)(atoi(ss.Data())/10)*2-3+atoi(ss.Data())%10; |
| 491 |
|
ss = pmtname(4); |
| 492 |
|
ipaddle = atoi(ss.Data())-1 ; |
| 493 |
|
if( pmtname.Contains("A") )ipmt=0; |
| 494 |
|
if( pmtname.Contains("B") )ipmt=1; |
| 495 |
|
|
| 496 |
|
return pmtname; |
| 497 |
|
}; |
| 498 |
|
/** |
| 499 |
|
* Method to get the PMT name (like "S11_1A") if the PMT_ID is given |
| 500 |
|
* @param ind PMT_ID (0 - 47) |
| 501 |
|
*/ |
| 502 |
|
TString ToFLevel2::GetPMTName(Int_t ind){ |
| 503 |
|
|
| 504 |
|
Int_t iplane = -1; |
| 505 |
|
Int_t ipaddle = -1; |
| 506 |
|
Int_t ipmt = -1; |
| 507 |
|
return GetPMTName(ind,iplane,ipaddle,ipmt); |
| 508 |
|
|
| 509 |
|
}; |
| 510 |
|
|
| 511 |
|
|
| 512 |
|
// gf Apr 07 |
| 513 |
|
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
| 514 |
|
|
| 515 |
|
Double_t xt,yt,xl,xh,yl,yh; |
| 516 |
|
|
| 517 |
|
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
| 518 |
|
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
| 519 |
|
Float_t tof21_y[2] = { 3.75,-3.75}; |
| 520 |
|
Float_t tof22_x[2] = { -4.5,4.5}; |
| 521 |
|
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
| 522 |
|
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
| 523 |
|
|
| 524 |
|
// S11 8 paddles 33.0 x 5.1 cm |
| 525 |
|
// S12 6 paddles 40.8 x 5.5 cm |
| 526 |
|
// S21 2 paddles 18.0 x 7.5 cm |
| 527 |
|
// S22 2 paddles 15.0 x 9.0 cm |
| 528 |
|
// S31 3 paddles 15.0 x 6.0 cm |
| 529 |
|
// S32 3 paddles 18.0 x 5.0 cm |
| 530 |
|
|
| 531 |
|
Int_t paddleidoftrack=-1; |
| 532 |
|
// |
| 533 |
|
|
| 534 |
|
//--- S11 ------ |
| 535 |
|
|
| 536 |
|
if(plane==0){ |
| 537 |
|
xt = xtr; |
| 538 |
|
yt = ytr; |
| 539 |
|
paddleidoftrack=-1; |
| 540 |
|
yl = -33.0/2. ; |
| 541 |
|
yh = 33.0/2. ; |
| 542 |
|
if ((yt>yl)&&(yt<yh)) { |
| 543 |
|
for (Int_t i1=0; i1<8;i1++){ |
| 544 |
|
xl = tof11_x[i1] - (5.1-0.4)/2. ; |
| 545 |
|
xh = tof11_x[i1] + (5.1-0.4)/2. ; |
| 546 |
|
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
| 547 |
|
} |
| 548 |
|
} |
| 549 |
|
} |
| 550 |
|
// cout<<"S11 "<<paddleidoftrack[0]<<"\n"; |
| 551 |
|
|
| 552 |
|
//--- S12 ------- |
| 553 |
|
if(plane==1){ |
| 554 |
|
xt = xtr; |
| 555 |
|
yt = ytr; |
| 556 |
|
paddleidoftrack=-1; |
| 557 |
|
xl = -40.8/2. ; |
| 558 |
|
xh = 40.8/2. ; |
| 559 |
|
|
| 560 |
|
if ((xt>xl)&&(xt<xh)) { |
| 561 |
|
for (Int_t i1=0; i1<6;i1++){ |
| 562 |
|
yl = tof12_y[i1] - (5.5-0.4)/2. ; |
| 563 |
|
yh = tof12_y[i1] + (5.5-0.4)/2. ; |
| 564 |
|
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
| 565 |
|
} |
| 566 |
|
} |
| 567 |
|
} |
| 568 |
|
|
| 569 |
|
//--- S21 ------ |
| 570 |
|
|
| 571 |
|
if(plane==2){ |
| 572 |
|
xt = xtr; |
| 573 |
|
yt = ytr; |
| 574 |
|
paddleidoftrack=-1; |
| 575 |
|
xl = -18./2. ; |
| 576 |
|
xh = 18./2. ; |
| 577 |
|
|
| 578 |
|
if ((xt>xl)&&(xt<xh)) { |
| 579 |
|
for (Int_t i1=0; i1<2;i1++){ |
| 580 |
|
yl = tof21_y[i1] - (7.5-0.4)/2. ; |
| 581 |
|
yh = tof21_y[i1] + (7.5-0.4)/2. ; |
| 582 |
|
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
| 583 |
|
} |
| 584 |
|
} |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
//--- S22 ------ |
| 588 |
|
if(plane==3){ |
| 589 |
|
xt = xtr; |
| 590 |
|
yt = ytr; |
| 591 |
|
paddleidoftrack=-1; |
| 592 |
|
yl = -15./2. ; |
| 593 |
|
yh = 15./2. ; |
| 594 |
|
|
| 595 |
|
if ((yt>yl)&&(yt<yh)) { |
| 596 |
|
for (Int_t i1=0; i1<2;i1++){ |
| 597 |
|
xl = tof22_x[i1] - (9.0-0.4)/2. ; |
| 598 |
|
xh = tof22_x[i1] + (9.0-0.4)/2. ; |
| 599 |
|
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
| 600 |
|
} |
| 601 |
|
} |
| 602 |
|
} |
| 603 |
|
|
| 604 |
|
//--- S31 ------ |
| 605 |
|
if(plane==4){ |
| 606 |
|
xt = xtr; |
| 607 |
|
yt = ytr; |
| 608 |
|
paddleidoftrack=-1; |
| 609 |
|
yl = -15.0/2. ; |
| 610 |
|
yh = 15.0/2. ; |
| 611 |
|
|
| 612 |
|
if ((yt>yl)&&(yt<yh)) { |
| 613 |
|
for (Int_t i1=0; i1<3;i1++){ |
| 614 |
|
xl = tof31_x[i1] - (6.0-0.4)/2. ; |
| 615 |
|
xh = tof31_x[i1] + (6.0-0.4)/2. ; |
| 616 |
|
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
| 617 |
|
} |
| 618 |
|
} |
| 619 |
|
} |
| 620 |
|
|
| 621 |
|
//--- S32 ------ |
| 622 |
|
if(plane==5){ |
| 623 |
|
xt = xtr; |
| 624 |
|
yt = ytr; |
| 625 |
|
paddleidoftrack=-1; |
| 626 |
|
xl = -18.0/2. ; |
| 627 |
|
xh = 18.0/2. ; |
| 628 |
|
|
| 629 |
|
if ((xt>xl)&&(xt<xh)) { |
| 630 |
|
for (Int_t i1=0; i1<3;i1++){ |
| 631 |
|
yl = tof32_y[i1] - (5.0-0.4)/2. ; |
| 632 |
|
yh = tof32_y[i1] + (5.0-0.4)/2. ; |
| 633 |
|
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
| 634 |
|
} |
| 635 |
|
} |
| 636 |
|
} |
| 637 |
|
|
| 638 |
|
return paddleidoftrack; |
| 639 |
|
|
| 640 |
|
} |
| 641 |
|
|
| 642 |
|
// |
| 643 |
|
|
| 644 |
|
// gf Apr 07 |
| 645 |
|
|
| 646 |
|
void ToFLevel2::GetPMTPaddle(Int_t pmt_id, Int_t &plane, Int_t &paddle){ |
| 647 |
|
|
| 648 |
|
plane = GetPlaneIndex(pmt_id); |
| 649 |
|
|
| 650 |
|
if(plane == 0){ |
| 651 |
|
if(pmt_id==0 || pmt_id==1)paddle=0; |
| 652 |
|
if(pmt_id==2 || pmt_id==3)paddle=1; |
| 653 |
|
if(pmt_id==4 || pmt_id==5)paddle=2; |
| 654 |
|
if(pmt_id==6 || pmt_id==7)paddle=3; |
| 655 |
|
if(pmt_id==8 || pmt_id==9)paddle=4; |
| 656 |
|
if(pmt_id==10 || pmt_id==11)paddle=5; |
| 657 |
|
if(pmt_id==12 || pmt_id==13)paddle=6; |
| 658 |
|
if(pmt_id==14 || pmt_id==15)paddle=7; |
| 659 |
|
} |
| 660 |
|
|
| 661 |
|
if(plane == 1){ |
| 662 |
|
if(pmt_id==16 || pmt_id==17)paddle=0; |
| 663 |
|
if(pmt_id==18 || pmt_id==19)paddle=1; |
| 664 |
|
if(pmt_id==20 || pmt_id==21)paddle=2; |
| 665 |
|
if(pmt_id==22 || pmt_id==23)paddle=3; |
| 666 |
|
if(pmt_id==24 || pmt_id==25)paddle=4; |
| 667 |
|
if(pmt_id==26 || pmt_id==27)paddle=5; |
| 668 |
|
} |
| 669 |
|
|
| 670 |
|
if(plane == 2){ |
| 671 |
|
if(pmt_id==28 || pmt_id==29)paddle=0; |
| 672 |
|
if(pmt_id==30 || pmt_id==31)paddle=1; |
| 673 |
|
} |
| 674 |
|
|
| 675 |
|
if(plane == 3){ |
| 676 |
|
if(pmt_id==32 || pmt_id==33)paddle=0; |
| 677 |
|
if(pmt_id==34 || pmt_id==35)paddle=1; |
| 678 |
|
} |
| 679 |
|
|
| 680 |
|
if(plane == 4){ |
| 681 |
|
if(pmt_id==36 || pmt_id==37)paddle=0; |
| 682 |
|
if(pmt_id==38 || pmt_id==39)paddle=1; |
| 683 |
|
if(pmt_id==40 || pmt_id==41)paddle=2; |
| 684 |
|
} |
| 685 |
|
|
| 686 |
|
if(plane == 5){ |
| 687 |
|
if(pmt_id==42 || pmt_id==43)paddle=0; |
| 688 |
|
if(pmt_id==44 || pmt_id==45)paddle=1; |
| 689 |
|
if(pmt_id==46 || pmt_id==47)paddle=2; |
| 690 |
|
} |
| 691 |
|
return; |
| 692 |
|
} |
| 693 |
|
|
| 694 |
|
// |
| 695 |
|
|
| 696 |
|
// gf Apr 07 |
| 697 |
|
|
| 698 |
|
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
| 699 |
|
pmtleft=paddle*2; |
| 700 |
|
pmtright= pmtleft+1; |
| 701 |
|
return; |
| 702 |
|
} |
| 703 |
|
|
| 704 |
|
// |
| 705 |
|
|
| 706 |
|
|
| 707 |
|
|
| 708 |
|
// // gf Apr 07 |
| 709 |
|
|
| 710 |
|
void ToFLevel2::GetPaddleGeometry(Int_t plane, Int_t paddle, Float_t &xleft, Float_t &xright, Float_t &yleft, Float_t &yright){ |
| 711 |
|
|
| 712 |
|
Int_t i1; |
| 713 |
|
|
| 714 |
|
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
| 715 |
|
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
| 716 |
|
Float_t tof21_y[2] = { 3.75,-3.75}; |
| 717 |
|
Float_t tof22_x[2] = { -4.5,4.5}; |
| 718 |
|
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
| 719 |
|
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
| 720 |
|
|
| 721 |
|
// S11 8 paddles 33.0 x 5.1 cm |
| 722 |
|
// S12 6 paddles 40.8 x 5.5 cm |
| 723 |
|
// S21 2 paddles 18.0 x 7.5 cm |
| 724 |
|
// S22 2 paddles 15.0 x 9.0 cm |
| 725 |
|
// S31 3 paddles 15.0 x 6.0 cm |
| 726 |
|
// S32 3 paddles 18.0 x 5.0 cm |
| 727 |
|
|
| 728 |
|
if(plane==0) |
| 729 |
|
{ |
| 730 |
|
for (i1=0; i1<8;i1++){ |
| 731 |
|
if(i1 == paddle){ |
| 732 |
|
xleft = tof11_x[i1] - 5.1/2.; |
| 733 |
|
xright = tof11_x[i1] + 5.1/2.; |
| 734 |
|
yleft = -33.0/2.; |
| 735 |
|
yright = 33.0/2.; |
| 736 |
|
} |
| 737 |
|
} |
| 738 |
|
} |
| 739 |
|
|
| 740 |
|
if(plane==1) |
| 741 |
|
{ |
| 742 |
|
for (i1=0; i1<6;i1++){ |
| 743 |
|
if(i1 == paddle){ |
| 744 |
|
xleft = -40.8/2.; |
| 745 |
|
xright = 40.8/2.; |
| 746 |
|
yleft = tof12_y[i1] - 5.5/2.; |
| 747 |
|
yright = tof12_y[i1] + 5.5/2.; |
| 748 |
|
} |
| 749 |
|
} |
| 750 |
|
} |
| 751 |
|
|
| 752 |
|
if(plane==2) |
| 753 |
|
{ |
| 754 |
|
for (i1=0; i1<2;i1++){ |
| 755 |
|
if(i1 == paddle){ |
| 756 |
|
xleft = -18./2.; |
| 757 |
|
xright = 18./2.; |
| 758 |
|
yleft = tof21_y[i1] - 7.5/2.; |
| 759 |
|
yright = tof21_y[i1] + 7.5/2.; |
| 760 |
|
} |
| 761 |
|
} |
| 762 |
|
} |
| 763 |
|
|
| 764 |
|
if(plane==3) |
| 765 |
|
{ |
| 766 |
|
for (i1=0; i1<2;i1++){ |
| 767 |
|
if(i1 == paddle){ |
| 768 |
|
xleft = tof22_x[i1] - 9.0/2.; |
| 769 |
|
xright = tof22_x[i1] + 9.0/2.; |
| 770 |
|
yleft = -15./2.; |
| 771 |
|
yright = 15./2.; |
| 772 |
|
} |
| 773 |
|
} |
| 774 |
|
} |
| 775 |
|
|
| 776 |
|
|
| 777 |
|
if(plane==4) |
| 778 |
|
{ |
| 779 |
|
for (i1=0; i1<3;i1++){ |
| 780 |
|
if(i1 == paddle){ |
| 781 |
|
xleft = tof31_x[i1] - 6.0/2.; |
| 782 |
|
xright = tof31_x[i1] + 6.0/2.; |
| 783 |
|
yleft = -15./2.; |
| 784 |
|
yright = 15./2.; |
| 785 |
|
} |
| 786 |
|
} |
| 787 |
|
} |
| 788 |
|
|
| 789 |
|
if(plane==5) |
| 790 |
|
{ |
| 791 |
|
for (i1=0; i1<3;i1++){ |
| 792 |
|
if(i1 == paddle){ |
| 793 |
|
xleft = -18.0/2.; |
| 794 |
|
xright = 18.0/2.; |
| 795 |
|
yleft = tof32_y[i1] - 5.0/2.; |
| 796 |
|
yright = tof32_y[i1] + 5.0/2.; |
| 797 |
|
} |
| 798 |
|
} |
| 799 |
|
} |
| 800 |
|
return; |
| 801 |
|
} |
| 802 |
|
|
| 803 |
|
// gf Apr 07 |
| 804 |
|
/** |
| 805 |
|
* Method to get the paddle index (0,...23) if the plane ID and the paddle id in the plane is given. |
| 806 |
|
* This method is the |
| 807 |
|
* "reverse" of method "GetPaddlePlane" |
| 808 |
|
* @param plane (0 - 5) |
| 809 |
|
* @param paddle (plane=0, paddle = 0,...5) |
| 810 |
|
* @param padid (0 - 23) |
| 811 |
|
*/ |
| 812 |
|
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
| 813 |
|
{ |
| 814 |
|
Int_t padid=-1; |
| 815 |
|
Int_t pads[6]={8,6,2,2,3,3}; |
| 816 |
|
|
| 817 |
|
int somma=0; |
| 818 |
|
int np=plane; |
| 819 |
|
for(Int_t j=0; j<np; j++){ |
| 820 |
|
somma+=pads[j]; |
| 821 |
|
} |
| 822 |
|
padid=paddle+somma; |
| 823 |
|
return padid; |
| 824 |
|
} |
| 825 |
|
|
| 826 |
|
|
| 827 |
|
// gf Apr 07 |
| 828 |
|
/** |
| 829 |
|
* Method to get the plane ID and the paddle id in the plane if the paddle index (0,...23) is given. |
| 830 |
|
* This method is the |
| 831 |
|
* "reverse" of method "GetPaddleid" |
| 832 |
|
* @param pad (0 - 23) |
| 833 |
|
* @param plane (0 - 5) |
| 834 |
|
* @param paddle (plane=0, paddle = 0,...5) |
| 835 |
|
*/ |
| 836 |
|
void ToFLevel2::GetPaddlePlane(Int_t pad, Int_t &plane, Int_t &paddle) |
| 837 |
|
{ |
| 838 |
|
|
| 839 |
|
Int_t pads11=8; |
| 840 |
|
Int_t pads12=6; |
| 841 |
|
Int_t pads21=2; |
| 842 |
|
Int_t pads22=2; |
| 843 |
|
Int_t pads31=3; |
| 844 |
|
// Int_t pads32=3; |
| 845 |
|
|
| 846 |
|
if(pad<8){ |
| 847 |
|
plane=0; |
| 848 |
|
paddle=pad; |
| 849 |
|
return; |
| 850 |
|
} |
| 851 |
|
|
| 852 |
|
if(7<pad<14){ |
| 853 |
|
plane=1; |
| 854 |
|
paddle=pad-pads11; |
| 855 |
|
return; |
| 856 |
|
} |
| 857 |
|
|
| 858 |
|
if(13<pad<16){ |
| 859 |
|
plane=2; |
| 860 |
|
paddle=pad-pads11-pads12; |
| 861 |
|
return; |
| 862 |
|
} |
| 863 |
|
|
| 864 |
|
if(15<pad<18){ |
| 865 |
|
plane=3; |
| 866 |
|
paddle=pad-pads11-pads12-pads21; |
| 867 |
|
return; |
| 868 |
|
} |
| 869 |
|
|
| 870 |
|
if(17<pad<21){ |
| 871 |
|
plane=4; |
| 872 |
|
paddle=pad-pads11-pads12-pads21-pads22; |
| 873 |
|
return; |
| 874 |
|
} |
| 875 |
|
|
| 876 |
|
if(20<pad<24){ |
| 877 |
|
plane=5; |
| 878 |
|
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
| 879 |
|
return; |
| 880 |
|
} |
| 881 |
|
|
| 882 |
|
} |
| 883 |
|
|
| 884 |
|
|
| 885 |
|
Int_t ToFLevel2::GetNPaddle(Int_t plane){ |
| 886 |
|
|
| 887 |
|
Int_t npaddle=-1; |
| 888 |
|
|
| 889 |
|
Int_t pads11=8; |
| 890 |
|
Int_t pads12=6; |
| 891 |
|
Int_t pads21=2; |
| 892 |
|
Int_t pads22=2; |
| 893 |
|
Int_t pads31=3; |
| 894 |
|
Int_t pads32=3; |
| 895 |
|
|
| 896 |
|
if(plane==0)npaddle=pads11; |
| 897 |
|
if(plane==1)npaddle=pads12; |
| 898 |
|
if(plane==2)npaddle=pads21; |
| 899 |
|
if(plane==3)npaddle=pads22; |
| 900 |
|
if(plane==4)npaddle=pads31; |
| 901 |
|
if(plane==5)npaddle=pads32; |
| 902 |
|
|
| 903 |
|
return npaddle; |
| 904 |
|
|
| 905 |
|
} |
| 906 |
|
|
| 907 |
|
/// wm feb 08 |
| 908 |
|
|
| 909 |
|
/** |
| 910 |
|
* Method to calculate Beta from the 12 single measurements |
| 911 |
|
* we check the individual weights for artificial TDC values, then calculate |
| 912 |
|
* am mean beta for the first time. In a second step we loop again through |
| 913 |
|
* the single measurements, checking for the residual from the mean |
| 914 |
|
* The cut on the residual reject measurements > "x"-sigma. A chi2 value is |
| 915 |
|
* calculated, furthermore a "quality" value by adding the weights which |
| 916 |
|
* are finally used. If all measurements are taken, "quality" will be = 22.47. |
| 917 |
|
* A chi2 cut around 3-4 and a quality-cut > 20 is needed for clean beta |
| 918 |
|
* measurements like antiprotons etc. |
| 919 |
|
* The Level2 output is derived in the fortran routines using: 10.,10.,20. |
| 920 |
|
* @param notrack Track Number |
| 921 |
|
* @param cut on residual: difference between single measurement and mean |
| 922 |
|
* @param cut on "quality" |
| 923 |
|
* @param cut on chi2 |
| 924 |
|
*/ |
| 925 |
|
|
| 926 |
|
Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){ |
| 927 |
|
|
| 928 |
|
// cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl; |
| 929 |
|
|
| 930 |
|
Float_t bxx = 100.; |
| 931 |
|
// |
| 932 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
| 933 |
|
if(!trk) return 0; //ELENA |
| 934 |
|
|
| 935 |
|
|
| 936 |
|
Float_t chi2,xhelp,beta_mean; |
| 937 |
|
Float_t w_i[12],quality,sw,sxw,res,betachi,beta_mean_inv; |
| 938 |
|
Float_t b[12],tdcfl; |
| 939 |
|
Int_t pmt_id,pmt_plane; |
| 940 |
|
|
| 941 |
|
for (Int_t i=0; i<12; i++){ |
| 942 |
|
b[i] = trk->beta[i]; |
| 943 |
|
} |
| 944 |
|
|
| 945 |
|
|
| 946 |
|
//======================================================================== |
| 947 |
|
//--- Find out ToF layers with artificial TDC values & fill vector --- |
| 948 |
|
//======================================================================== |
| 949 |
|
|
| 950 |
|
Float_t w_il[6]; |
| 951 |
|
|
| 952 |
|
for (Int_t jj=0; jj<6;jj++) { |
| 953 |
|
w_il[jj] = 1000.; |
| 954 |
|
} |
| 955 |
|
|
| 956 |
|
|
| 957 |
|
for (Int_t i=0; i<trk->npmttdc; i++){ |
| 958 |
|
// |
| 959 |
|
pmt_id = (trk->pmttdc).At(i); |
| 960 |
|
pmt_plane = GetPlaneIndex(pmt_id); |
| 961 |
|
tdcfl = (trk->tdcflag).At(i); |
| 962 |
|
if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag |
| 963 |
|
}; |
| 964 |
|
|
| 965 |
|
//======================================================================== |
| 966 |
|
//--- Set weights for the 12 measurements using information for top and bottom: |
| 967 |
|
//--- if no measurements: weight = set to very high value=> not used |
| 968 |
|
//--- top or bottom artificial: weight*sqrt(2) |
| 969 |
|
//--- top and bottom artificial: weight*sqrt(2)*sqrt(2) |
| 970 |
|
//======================================================================== |
| 971 |
|
|
| 972 |
|
Int_t itop[12] = {0,0,1,1,2,2,3,3,0,0,1,1}; |
| 973 |
|
Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2,3}; |
| 974 |
|
|
| 975 |
|
xhelp= 1E09; |
| 976 |
|
|
| 977 |
|
for (Int_t jj=0; jj<12;jj++) { |
| 978 |
|
if (jj<4) xhelp = 0.11; // S1-S3 |
| 979 |
|
if ((jj>3)&&(jj<8)) xhelp = 0.18; // S2-S3 |
| 980 |
|
if (jj>7) xhelp = 0.28; // S1-S2 |
| 981 |
|
if ((w_il[itop[jj]] == 1000.) && (w_il[ibot[jj]] == 1000.)) xhelp = 1E09; |
| 982 |
|
if ((w_il[itop[jj]] == 1) || (w_il[ibot[jj]] == 1.)) xhelp = xhelp*1.414 ; |
| 983 |
|
if ((w_il[itop[jj]] == 1) && (w_il[ibot[jj]] == 1.)) xhelp = xhelp*2. ; |
| 984 |
|
|
| 985 |
|
w_i[jj] = 1./xhelp; |
| 986 |
|
} |
| 987 |
|
|
| 988 |
|
|
| 989 |
|
//======================================================================== |
| 990 |
|
//--- Calculate mean beta for the first time ----------------------------- |
| 991 |
|
//--- We are using "1/beta" since its error is gaussian ------------------ |
| 992 |
|
//======================================================================== |
| 993 |
|
|
| 994 |
|
Int_t icount=0; |
| 995 |
|
sw=0.; |
| 996 |
|
sxw=0.; |
| 997 |
|
beta_mean=100.; |
| 998 |
|
|
| 999 |
|
for (Int_t jj=0; jj<12;jj++){ |
| 1000 |
|
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)) |
| 1001 |
|
{ |
| 1002 |
|
icount= icount+1; |
| 1003 |
|
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
| 1004 |
|
sw =sw + w_i[jj]*w_i[jj] ; |
| 1005 |
|
|
| 1006 |
|
} |
| 1007 |
|
} |
| 1008 |
|
|
| 1009 |
|
if (icount>0) beta_mean=1./(sxw/sw); |
| 1010 |
|
beta_mean_inv = 1./beta_mean; |
| 1011 |
|
|
| 1012 |
|
//======================================================================== |
| 1013 |
|
//--- Calculate beta for the second time, use residuals of the single |
| 1014 |
|
//--- measurements to get a chi2 value |
| 1015 |
|
//======================================================================== |
| 1016 |
|
|
| 1017 |
|
icount=0; |
| 1018 |
|
sw=0.; |
| 1019 |
|
sxw=0.; |
| 1020 |
|
betachi = 100.; |
| 1021 |
|
chi2 = 0.; |
| 1022 |
|
quality=0.; |
| 1023 |
|
|
| 1024 |
|
|
| 1025 |
|
for (Int_t jj=0; jj<12;jj++){ |
| 1026 |
|
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)&&(w_i[jj]>0.01)) { |
| 1027 |
|
res = beta_mean_inv - (1./b[jj]) ; |
| 1028 |
|
if (fabs(res*w_i[jj])<resmax) {; |
| 1029 |
|
chi2 = chi2 + pow((res*w_i[jj]),2) ; |
| 1030 |
|
icount= icount+1; |
| 1031 |
|
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
| 1032 |
|
sw =sw + w_i[jj]*w_i[jj] ; |
| 1033 |
|
} |
| 1034 |
|
} |
| 1035 |
|
} |
| 1036 |
|
quality = sqrt(sw) ; |
| 1037 |
|
|
| 1038 |
|
if (icount==0) chi2 = 1000.; |
| 1039 |
|
if (icount>0) chi2 = chi2/(icount) ; |
| 1040 |
|
if (icount>0) betachi=1./(sxw/sw); |
| 1041 |
|
|
| 1042 |
|
bxx = 100.; |
| 1043 |
|
if ((chi2 < chi2cut)&&(quality>qualitycut)) bxx = betachi; |
| 1044 |
|
// |
| 1045 |
|
return(bxx); |
| 1046 |
|
}; |
| 1047 |
|
|
| 1048 |
|
|
| 1049 |
|
//////////////////////////////////////////////////// |
| 1050 |
|
//////////////////////////////////////////////////// |
| 1051 |
|
|
| 1052 |
|
|
| 1053 |
|
|
| 1054 |
/** |
/** |
| 1055 |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
| 1056 |
*/ |
*/ |
| 1081 |
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
| 1082 |
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
| 1083 |
} |
} |
| 1084 |
|
for(Int_t i=0;i<6;i++){ |
| 1085 |
|
l2->xtr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtr_tof[i]; |
| 1086 |
|
l2->ytr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytr_tof[i]; |
| 1087 |
|
} |
| 1088 |
} |
} |
| 1089 |
} //ELENA |
} //ELENA |
| 1090 |
|
|
| 1097 |
} |
} |
| 1098 |
} //ELENA |
} //ELENA |
| 1099 |
} |
} |
| 1100 |
|
|
| 1101 |
|
|
| 1102 |
|
// |
| 1103 |
|
// Reprocessing tool // Emiliano 08/04/07 |
| 1104 |
|
// |
| 1105 |
|
Int_t ToFLevel2::Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force){ |
| 1106 |
|
// |
| 1107 |
|
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
| 1108 |
|
// |
| 1109 |
|
|
| 1110 |
|
|
| 1111 |
|
|
| 1112 |
|
|
| 1113 |
|
// |
| 1114 |
|
// structures to communicate with F77 |
| 1115 |
|
// |
| 1116 |
|
extern struct ToFInput tofinput_; |
| 1117 |
|
extern struct ToFOutput tofoutput_; |
| 1118 |
|
// |
| 1119 |
|
// DB connection |
| 1120 |
|
// |
| 1121 |
|
TString host; |
| 1122 |
|
TString user; |
| 1123 |
|
TString psw; |
| 1124 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 1125 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 1126 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 1127 |
|
if ( !pamdbhost ) pamdbhost = ""; |
| 1128 |
|
if ( !pamdbuser ) pamdbuser = ""; |
| 1129 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 1130 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 1131 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 1132 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 1133 |
|
// |
| 1134 |
|
// |
| 1135 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 1136 |
|
if ( !dbc->IsConnected() ) return 1; |
| 1137 |
|
stringstream myquery; |
| 1138 |
|
myquery.str(""); |
| 1139 |
|
myquery << "SET time_zone='+0:00'"; |
| 1140 |
|
dbc->Query(myquery.str().c_str()); |
| 1141 |
|
GL_PARAM *glparam = new GL_PARAM(); |
| 1142 |
|
glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
| 1143 |
|
trk->LoadField(glparam->PATH+glparam->NAME); |
| 1144 |
|
// |
| 1145 |
|
Bool_t defcal = true; |
| 1146 |
|
Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
| 1147 |
|
if ( error<0 ) { |
| 1148 |
|
return(1); |
| 1149 |
|
}; |
| 1150 |
|
printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
| 1151 |
|
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
| 1152 |
|
// |
| 1153 |
|
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
| 1154 |
|
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
| 1155 |
|
// |
| 1156 |
|
Int_t adc[4][12]; |
| 1157 |
|
Int_t tdc[4][12]; |
| 1158 |
|
Float_t tdcc[4][12]; |
| 1159 |
|
// |
| 1160 |
|
// process tof data |
| 1161 |
|
// |
| 1162 |
|
for (Int_t hh=0; hh<12;hh++){ |
| 1163 |
|
for (Int_t kk=0; kk<4;kk++){ |
| 1164 |
|
adc[kk][hh] = 4095; |
| 1165 |
|
tdc[kk][hh] = 4095; |
| 1166 |
|
tdcc[kk][hh] = 4095.; |
| 1167 |
|
tofinput_.adc[hh][kk] = 4095; |
| 1168 |
|
tofinput_.tdc[hh][kk] = 4095; |
| 1169 |
|
}; |
| 1170 |
|
}; |
| 1171 |
|
Int_t ntrkentry = 0; |
| 1172 |
|
Int_t npmtentry = 0; |
| 1173 |
|
Int_t gg = 0; |
| 1174 |
|
Int_t hh = 0; |
| 1175 |
|
Int_t adcf[48]; |
| 1176 |
|
memset(adcf, 0, 48*sizeof(Int_t)); |
| 1177 |
|
Int_t tdcf[48]; |
| 1178 |
|
memset(tdcf, 0, 48*sizeof(Int_t)); |
| 1179 |
|
for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
| 1180 |
|
ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
| 1181 |
|
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
| 1182 |
|
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
| 1183 |
|
}; |
| 1184 |
|
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
| 1185 |
|
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
| 1186 |
|
}; |
| 1187 |
|
}; |
| 1188 |
|
// |
| 1189 |
|
for (Int_t pm=0; pm < this->npmt() ; pm++){ |
| 1190 |
|
ToFPMT *pmt = this->GetToFPMT(pm); |
| 1191 |
|
this->GetPMTIndex(pmt->pmt_id, gg, hh); |
| 1192 |
|
if ( adcf[pmt->pmt_id] == 0 ){ |
| 1193 |
|
tofinput_.adc[gg][hh] = (int)pmt->adc; |
| 1194 |
|
adc[hh][gg] = (int)pmt->adc; |
| 1195 |
|
}; |
| 1196 |
|
if ( tdcf[pmt->pmt_id] == 0 ){ |
| 1197 |
|
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
| 1198 |
|
tdc[hh][gg] = (int)pmt->tdc; |
| 1199 |
|
}; |
| 1200 |
|
tdcc[hh][gg] = (float)pmt->tdc_tw; |
| 1201 |
|
// Int_t pppid = this->GetPMTid(hh,gg); |
| 1202 |
|
// printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc); |
| 1203 |
|
}; |
| 1204 |
|
// |
| 1205 |
|
Int_t unpackError = this->unpackError; |
| 1206 |
|
// |
| 1207 |
|
for (Int_t hh=0; hh<5;hh++){ |
| 1208 |
|
tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
| 1209 |
|
}; |
| 1210 |
|
// |
| 1211 |
|
this->Clear(); |
| 1212 |
|
// |
| 1213 |
|
Int_t pmt_id = 0; |
| 1214 |
|
ToFPMT *t_pmt = new ToFPMT(); |
| 1215 |
|
if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
| 1216 |
|
TClonesArray &tpmt = *this->PMT; |
| 1217 |
|
ToFTrkVar *t_tof = new ToFTrkVar(); |
| 1218 |
|
if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
| 1219 |
|
TClonesArray &t = *this->ToFTrk; |
| 1220 |
|
// |
| 1221 |
|
// |
| 1222 |
|
// Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
| 1223 |
|
// |
| 1224 |
|
npmtentry = 0; |
| 1225 |
|
// |
| 1226 |
|
ntrkentry = 0; |
| 1227 |
|
// |
| 1228 |
|
// Calculate tracks informations from ToF alone |
| 1229 |
|
// |
| 1230 |
|
tofl2com(); |
| 1231 |
|
// |
| 1232 |
|
memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
| 1233 |
|
// |
| 1234 |
|
t_tof->trkseqno = -1; |
| 1235 |
|
// |
| 1236 |
|
// and now we must copy from the output structure to the level2 class: |
| 1237 |
|
// |
| 1238 |
|
t_tof->npmttdc = 0; |
| 1239 |
|
// |
| 1240 |
|
for (Int_t hh=0; hh<12;hh++){ |
| 1241 |
|
for (Int_t kk=0; kk<4;kk++){ |
| 1242 |
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
| 1243 |
|
pmt_id = this->GetPMTid(kk,hh); |
| 1244 |
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
| 1245 |
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
| 1246 |
|
t_tof->npmttdc++; |
| 1247 |
|
}; |
| 1248 |
|
}; |
| 1249 |
|
}; |
| 1250 |
|
for (Int_t kk=0; kk<13;kk++){ |
| 1251 |
|
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
| 1252 |
|
} |
| 1253 |
|
// |
| 1254 |
|
t_tof->npmtadc = 0; |
| 1255 |
|
for (Int_t hh=0; hh<12;hh++){ |
| 1256 |
|
for (Int_t kk=0; kk<4;kk++){ |
| 1257 |
|
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
| 1258 |
|
t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
| 1259 |
|
pmt_id = this->GetPMTid(kk,hh); |
| 1260 |
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
| 1261 |
|
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
| 1262 |
|
t_tof->npmtadc++; |
| 1263 |
|
}; |
| 1264 |
|
}; |
| 1265 |
|
}; |
| 1266 |
|
// |
| 1267 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
| 1268 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
| 1269 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
| 1270 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
| 1271 |
|
// |
| 1272 |
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
| 1273 |
|
ntrkentry++; |
| 1274 |
|
t_tof->Clear(); |
| 1275 |
|
// |
| 1276 |
|
// |
| 1277 |
|
// |
| 1278 |
|
t_pmt->Clear(); |
| 1279 |
|
// |
| 1280 |
|
for (Int_t hh=0; hh<12;hh++){ |
| 1281 |
|
for (Int_t kk=0; kk<4;kk++){ |
| 1282 |
|
// new WM |
| 1283 |
|
if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
| 1284 |
|
// if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
| 1285 |
|
// |
| 1286 |
|
t_pmt->pmt_id = this->GetPMTid(kk,hh); |
| 1287 |
|
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
| 1288 |
|
t_pmt->adc = (Float_t)adc[kk][hh]; |
| 1289 |
|
t_pmt->tdc = (Float_t)tdc[kk][hh]; |
| 1290 |
|
// |
| 1291 |
|
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
| 1292 |
|
npmtentry++; |
| 1293 |
|
t_pmt->Clear(); |
| 1294 |
|
}; |
| 1295 |
|
}; |
| 1296 |
|
}; |
| 1297 |
|
// |
| 1298 |
|
// Calculate track-related variables |
| 1299 |
|
// |
| 1300 |
|
if ( trk->ntrk() > 0 ){ |
| 1301 |
|
// |
| 1302 |
|
// We have at least one track |
| 1303 |
|
// |
| 1304 |
|
// |
| 1305 |
|
// Run over tracks |
| 1306 |
|
// |
| 1307 |
|
for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
| 1308 |
|
// |
| 1309 |
|
TrkTrack *ptt = trk->GetStoredTrack(nt); |
| 1310 |
|
// |
| 1311 |
|
// Copy the alpha vector in the input structure |
| 1312 |
|
// |
| 1313 |
|
for (Int_t e = 0; e < 5 ; e++){ |
| 1314 |
|
tofinput_.al_pp[e] = ptt->al[e]; |
| 1315 |
|
}; |
| 1316 |
|
// |
| 1317 |
|
// Get tracker related variables for this track |
| 1318 |
|
// |
| 1319 |
|
toftrk(); |
| 1320 |
|
// |
| 1321 |
|
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
| 1322 |
|
// |
| 1323 |
|
t_tof->npmttdc = 0; |
| 1324 |
|
for (Int_t hh=0; hh<12;hh++){ |
| 1325 |
|
for (Int_t kk=0; kk<4;kk++){ |
| 1326 |
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
| 1327 |
|
pmt_id = this->GetPMTid(kk,hh); |
| 1328 |
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
| 1329 |
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
| 1330 |
|
t_tof->npmttdc++; |
| 1331 |
|
}; |
| 1332 |
|
}; |
| 1333 |
|
}; |
| 1334 |
|
for (Int_t kk=0; kk<13;kk++){ |
| 1335 |
|
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
| 1336 |
|
}; |
| 1337 |
|
// |
| 1338 |
|
t_tof->npmtadc = 0; |
| 1339 |
|
for (Int_t hh=0; hh<12;hh++){ |
| 1340 |
|
for (Int_t kk=0; kk<4;kk++){ |
| 1341 |
|
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
| 1342 |
|
t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
| 1343 |
|
pmt_id = this->GetPMTid(kk,hh); |
| 1344 |
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
| 1345 |
|
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
| 1346 |
|
t_tof->npmtadc++; |
| 1347 |
|
}; |
| 1348 |
|
}; |
| 1349 |
|
}; |
| 1350 |
|
// |
| 1351 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
| 1352 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
| 1353 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
| 1354 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
| 1355 |
|
// |
| 1356 |
|
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
| 1357 |
|
// |
| 1358 |
|
t_tof->trkseqno = nt; |
| 1359 |
|
// |
| 1360 |
|
// create a new object for this event with track-related variables |
| 1361 |
|
// |
| 1362 |
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
| 1363 |
|
ntrkentry++; |
| 1364 |
|
t_tof->Clear(); |
| 1365 |
|
// |
| 1366 |
|
}; // loop on all the tracks |
| 1367 |
|
// |
| 1368 |
|
this->unpackError = unpackError; |
| 1369 |
|
if ( defcal ){ |
| 1370 |
|
this->default_calib = 1; |
| 1371 |
|
} else { |
| 1372 |
|
this->default_calib = 0; |
| 1373 |
|
}; |
| 1374 |
|
}; |
| 1375 |
|
|
| 1376 |
|
|
| 1377 |
|
|
| 1378 |
|
return(0); |
| 1379 |
|
} |