| 1 |
/** |
| 2 |
* \file ToFLevel2.cpp |
| 3 |
* \author Gianfranca DeRosa, Wolfgang Menn |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <ToFLevel2.h> |
| 7 |
|
| 8 |
using namespace std; |
| 9 |
|
| 10 |
ClassImp(ToFPMT); |
| 11 |
ClassImp(ToFTrkVar); |
| 12 |
ClassImp(ToFLevel2); |
| 13 |
|
| 14 |
ToFPMT::ToFPMT(){ |
| 15 |
pmt_id = 0; |
| 16 |
adc = 0.; |
| 17 |
tdc_tw = 0.; |
| 18 |
tdc = 0.; |
| 19 |
} |
| 20 |
|
| 21 |
ToFPMT::ToFPMT(const ToFPMT &t){ |
| 22 |
pmt_id = t.pmt_id; |
| 23 |
adc = t.adc; |
| 24 |
tdc_tw = t.tdc_tw; |
| 25 |
tdc = t.tdc; |
| 26 |
} |
| 27 |
|
| 28 |
void ToFPMT::Clear(Option_t *t){ |
| 29 |
pmt_id = 0; |
| 30 |
adc = 0.; |
| 31 |
tdc_tw = 0.; |
| 32 |
tdc = 0.; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
ToFTrkVar::ToFTrkVar() { |
| 38 |
trkseqno = 0; |
| 39 |
npmttdc = 0; |
| 40 |
npmtadc = 0; |
| 41 |
pmttdc = TArrayI(48); |
| 42 |
pmtadc = TArrayI(48); |
| 43 |
tdcflag = TArrayI(48); // gf: 30 Nov 2006 |
| 44 |
adcflag = TArrayI(48); // gf: 30 Nov 2006 |
| 45 |
dedx = TArrayF(48); |
| 46 |
// |
| 47 |
// |
| 48 |
memset(beta, 0, 13*sizeof(Float_t)); |
| 49 |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
| 50 |
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(Option_t *t) { |
| 57 |
trkseqno = 0; |
| 58 |
npmttdc = 0; |
| 59 |
npmtadc = 0; |
| 60 |
pmttdc.Reset(); |
| 61 |
pmtadc.Reset(); |
| 62 |
tdcflag.Reset(); // gf: 30 Nov 2006 |
| 63 |
adcflag.Reset(); // gf: 30 Nov 2006 |
| 64 |
dedx.Reset(); |
| 65 |
// |
| 66 |
memset(beta, 0, 13*sizeof(Float_t)); |
| 67 |
memset(xtofpos, 0, 3*sizeof(Float_t)); |
| 68 |
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 |
|
| 74 |
ToFTrkVar::ToFTrkVar(const ToFTrkVar &t){ |
| 75 |
|
| 76 |
trkseqno = t.trkseqno; |
| 77 |
// |
| 78 |
npmttdc = t.npmttdc; |
| 79 |
npmtadc = t.npmtadc; |
| 80 |
(t.pmttdc).Copy(pmttdc); |
| 81 |
(t.pmtadc).Copy(pmtadc); |
| 82 |
(t.tdcflag).Copy(tdcflag); // gf: 30 Nov 2006 |
| 83 |
(t.adcflag).Copy(adcflag); // gf: 30 Nov 2006 |
| 84 |
(t.dedx).Copy(dedx); |
| 85 |
// |
| 86 |
memcpy(beta,t.beta,sizeof(beta)); |
| 87 |
memcpy(xtofpos,t.xtofpos,sizeof(xtofpos)); |
| 88 |
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 |
|
| 94 |
ToFLevel2::ToFLevel2() { |
| 95 |
// |
| 96 |
// PMT = new TClonesArray("ToFPMT",12); //ELENA |
| 97 |
// ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
| 98 |
PMT = 0; //ELENA |
| 99 |
ToFTrk = 0; //ELENA |
| 100 |
// |
| 101 |
this->Clear(); |
| 102 |
// |
| 103 |
}; |
| 104 |
|
| 105 |
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 |
| 113 |
if(PMT)PMT->Delete(); //ELENA |
| 114 |
memset(tof_j_flag, 0, 6*sizeof(Int_t)); |
| 115 |
unpackError = 0; |
| 116 |
// |
| 117 |
}; |
| 118 |
|
| 119 |
void ToFLevel2::Delete(Option_t *t){ //ELENA |
| 120 |
// |
| 121 |
if(ToFTrk){ |
| 122 |
ToFTrk->Delete(); //ELENA |
| 123 |
delete ToFTrk; //ELENA |
| 124 |
} |
| 125 |
if(PMT){ |
| 126 |
PMT->Delete(); //ELENA |
| 127 |
delete PMT; //ELENA |
| 128 |
} //ELENA |
| 129 |
// |
| 130 |
}; //ELENA |
| 131 |
|
| 132 |
ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){ |
| 133 |
// |
| 134 |
if(itrk >= ntrk()){ |
| 135 |
printf(" ToFLevel2 ERROR: track related variables set %i does not exists! \n",itrk); |
| 136 |
printf(" stored track related variables = %i \n",ntrk()); |
| 137 |
return(NULL); |
| 138 |
} |
| 139 |
// |
| 140 |
if(!ToFTrk)return 0; //ELENA |
| 141 |
TClonesArray &t = *(ToFTrk); |
| 142 |
ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk]; |
| 143 |
return toftrack; |
| 144 |
} |
| 145 |
|
| 146 |
ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit){ |
| 147 |
// |
| 148 |
if(ihit >= npmt()){ |
| 149 |
printf(" ToFLevel2 ERROR: pmt variables set %i does not exists! \n",ihit); |
| 150 |
printf(" stored pmt variables = %i \n",npmt()); |
| 151 |
return(NULL); |
| 152 |
} |
| 153 |
// |
| 154 |
if(!PMT)return 0; //ELENA |
| 155 |
TClonesArray &t = *(PMT); |
| 156 |
ToFPMT *tofpmt = (ToFPMT*)t[ihit]; |
| 157 |
return tofpmt; |
| 158 |
} |
| 159 |
//-------------------------------------- |
| 160 |
// |
| 161 |
// |
| 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) |
| 165 |
* @param Plane index (0,1,2,3,4,5). |
| 166 |
*/ |
| 167 |
Int_t ToFLevel2::GetToFPlaneID(Int_t ip){ |
| 168 |
if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1; |
| 169 |
else return -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) |
| 173 |
* @param plane Plane ID (11, 12, 21, 22, 31, 32) |
| 174 |
*/ |
| 175 |
Int_t ToFLevel2::GetToFPlaneIndex(Int_t plane_id){ |
| 176 |
if( |
| 177 |
plane_id == 11 || |
| 178 |
plane_id == 12 || |
| 179 |
plane_id == 21 || |
| 180 |
plane_id == 22 || |
| 181 |
plane_id == 31 || |
| 182 |
plane_id == 32 || |
| 183 |
false)return (Int_t)(plane_id/10)*2-1- plane_id%2; |
| 184 |
else return -1; |
| 185 |
}; |
| 186 |
/** |
| 187 |
* Method to know if a given ToF paddle was hit, that is there is a TDC signal |
| 188 |
* 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). |
| 190 |
* @param paddle_id Paddle ID. |
| 191 |
* @return 1 if the paddle was hit. |
| 192 |
*/ |
| 193 |
Bool_t ToFLevel2::HitPaddle(Int_t plane, Int_t paddle_id){ //<<< NEW |
| 194 |
Int_t ip = -1; |
| 195 |
if (plane>=6 ) ip = GetToFPlaneIndex(plane); |
| 196 |
else if(plane>=0 && plane < 6) ip = plane; |
| 197 |
Int_t flag=0; |
| 198 |
if(ip != -1)flag = tof_j_flag[ip] & (int)pow(2.,(double)paddle_id); |
| 199 |
if( |
| 200 |
(ip == 0 && paddle_id < 8 && flag) || |
| 201 |
(ip == 1 && paddle_id < 6 && flag) || |
| 202 |
(ip == 2 && paddle_id < 2 && flag) || |
| 203 |
(ip == 3 && paddle_id < 2 && flag) || |
| 204 |
(ip == 4 && paddle_id < 3 && flag) || |
| 205 |
(ip == 5 && paddle_id < 3 && flag) || |
| 206 |
false) return true; |
| 207 |
else return false; |
| 208 |
}; |
| 209 |
/** |
| 210 |
* Method to get the number of hit paddles on a ToF plane. |
| 211 |
* @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5). |
| 212 |
*/ |
| 213 |
Int_t ToFLevel2::GetNHitPaddles(Int_t plane){ |
| 214 |
Int_t npad=0; |
| 215 |
for(Int_t i=0; i<8; i++)npad = npad + (int)HitPaddle(plane,i); |
| 216 |
return npad; |
| 217 |
}; |
| 218 |
|
| 219 |
|
| 220 |
//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.; |
| 232 |
Float_t PadEdx =0.; |
| 233 |
Int_t SatWarning; |
| 234 |
Int_t pad=-1; |
| 235 |
// |
| 236 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
| 237 |
if(!trk) return 0; //ELENA |
| 238 |
// |
| 239 |
for (Int_t ii=0; ii<GetNPaddle(plane); ii++){ |
| 240 |
Int_t paddleid=ii; |
| 241 |
pad = GetPaddleid(plane,paddleid); |
| 242 |
GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning); |
| 243 |
dedx += PadEdx; |
| 244 |
}; |
| 245 |
// |
| 246 |
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]){ |
| 257 |
// |
| 258 |
for (Int_t aa=0; aa<4;aa++){ |
| 259 |
for (Int_t bb=0; bb<12;bb++){ |
| 260 |
adc[aa][bb] = 1000.; |
| 261 |
tdc[aa][bb] = 4095.; |
| 262 |
}; |
| 263 |
}; |
| 264 |
// |
| 265 |
Int_t pmt_id = 0; |
| 266 |
Int_t hh = 0; |
| 267 |
Int_t kk = 0; |
| 268 |
// |
| 269 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
| 270 |
if(!trk)return; //ELENA |
| 271 |
// |
| 272 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
| 273 |
// |
| 274 |
pmt_id = (trk->pmtadc).At(i); |
| 275 |
// |
| 276 |
GetPMTIndex(pmt_id,hh,kk); |
| 277 |
adc[kk][hh] = (trk->dedx).At(i); |
| 278 |
// |
| 279 |
}; |
| 280 |
// |
| 281 |
for (Int_t i=0; i<npmt(); i++){ |
| 282 |
// |
| 283 |
ToFPMT *pmt = GetToFPMT(i); |
| 284 |
if(!pmt)break; //ELENA |
| 285 |
// |
| 286 |
GetPMTIndex(pmt->pmt_id,hh,kk); |
| 287 |
// |
| 288 |
tdc[kk][hh] = pmt->tdc_tw; |
| 289 |
// |
| 290 |
}; |
| 291 |
// |
| 292 |
return; |
| 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){ |
| 301 |
TString pmtname = GetPMTName(pmt_id); |
| 302 |
pmtname.Resize(3); |
| 303 |
if ( !strcmp(pmtname,"S11") ) return(0); |
| 304 |
if ( !strcmp(pmtname,"S12") ) return(1); |
| 305 |
if ( !strcmp(pmtname,"S21") ) return(2); |
| 306 |
if ( !strcmp(pmtname,"S22") ) return(3); |
| 307 |
if ( !strcmp(pmtname,"S31") ) return(4); |
| 308 |
if ( !strcmp(pmtname,"S32") ) return(5); |
| 309 |
return(-1); |
| 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){ |
| 321 |
// |
| 322 |
short tof[4][24] = { |
| 323 |
{4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4}, |
| 324 |
{1, 3, 5, 7, 10, 12, 2, 4, 2, 4, 6, 8, 10, 12, 1, 5, 3, 9, 7, 9, 11, 1, 5, 9}, |
| 325 |
{2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 2, 1, 2, 1, 2, 2, 2, 3, 3, 4}, |
| 326 |
{6, 8, 12, 10, 8, 6, 4, 2, 12, 10, 8, 6, 4, 2, 9, 7, 11, 11, 5, 3, 1, 3, 7, 11} |
| 327 |
}; |
| 328 |
// |
| 329 |
Int_t ind = 0; |
| 330 |
Int_t k = 0; |
| 331 |
while (k < 24){ |
| 332 |
Int_t j = 0; |
| 333 |
while (j < 2){ |
| 334 |
Int_t ch = tof[2*j][k] - 1; |
| 335 |
Int_t hb = tof[2*j + 1][k] - 1; |
| 336 |
/* tofEvent->tdc[ch][hb] */ |
| 337 |
if( ch == hh && hb == kk ){ |
| 338 |
ind = 2*k + j; |
| 339 |
break; |
| 340 |
}; |
| 341 |
j++; |
| 342 |
}; |
| 343 |
k++; |
| 344 |
}; |
| 345 |
return ind; |
| 346 |
}; |
| 347 |
|
| 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){ |
| 357 |
// |
| 358 |
short tof[4][24] = { |
| 359 |
{4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4}, |
| 360 |
{1, 3, 5, 7, 10, 12, 2, 4, 2, 4, 6, 8, 10, 12, 1, 5, 3, 9, 7, 9, 11, 1, 5, 9}, |
| 361 |
{2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 2, 1, 2, 1, 2, 2, 2, 3, 3, 4}, |
| 362 |
{6, 8, 12, 10, 8, 6, 4, 2, 12, 10, 8, 6, 4, 2, 9, 7, 11, 11, 5, 3, 1, 3, 7, 11} |
| 363 |
}; |
| 364 |
// |
| 365 |
Int_t k = 0; |
| 366 |
while (k < 24){ |
| 367 |
Int_t j = 0; |
| 368 |
while (j < 2){ |
| 369 |
/* tofEvent->tdc[ch][hb] */ |
| 370 |
if( ind == 2*k + j ){ |
| 371 |
ch = tof[2*j][k] - 1; |
| 372 |
hb = tof[2*j + 1][k] - 1; |
| 373 |
return; |
| 374 |
}; |
| 375 |
j++; |
| 376 |
}; |
| 377 |
k++; |
| 378 |
}; |
| 379 |
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 |
// wm jun 08 |
| 512 |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
| 513 |
return GetPaddleIdOfTrack(xtr ,ytr ,plane, 0.4); |
| 514 |
} |
| 515 |
|
| 516 |
// gf Apr 07 |
| 517 |
// wm jun 08 introduced a margin as input parameter |
| 518 |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin){ |
| 519 |
|
| 520 |
Double_t xt,yt,xl,xh,yl,yh; |
| 521 |
|
| 522 |
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
| 523 |
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
| 524 |
Float_t tof21_y[2] = { 3.75,-3.75}; |
| 525 |
Float_t tof22_x[2] = { -4.5,4.5}; |
| 526 |
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
| 527 |
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
| 528 |
|
| 529 |
// S11 8 paddles 33.0 x 5.1 cm |
| 530 |
// S12 6 paddles 40.8 x 5.5 cm |
| 531 |
// S21 2 paddles 18.0 x 7.5 cm |
| 532 |
// S22 2 paddles 15.0 x 9.0 cm |
| 533 |
// S31 3 paddles 15.0 x 6.0 cm |
| 534 |
// S32 3 paddles 18.0 x 5.0 cm |
| 535 |
|
| 536 |
Int_t paddleidoftrack=-1; |
| 537 |
// |
| 538 |
|
| 539 |
//--- S11 ------ |
| 540 |
|
| 541 |
if(plane==0){ |
| 542 |
xt = xtr; |
| 543 |
yt = ytr; |
| 544 |
paddleidoftrack=-1; |
| 545 |
yl = -33.0/2. ; |
| 546 |
yh = 33.0/2. ; |
| 547 |
if ((yt>yl)&&(yt<yh)) { |
| 548 |
for (Int_t i1=0; i1<8;i1++){ |
| 549 |
xl = tof11_x[i1] - (5.1-margin)/2. ; |
| 550 |
xh = tof11_x[i1] + (5.1-margin)/2. ; |
| 551 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
| 552 |
} |
| 553 |
} |
| 554 |
} |
| 555 |
// cout<<"S11 "<<paddleidoftrack[0]<<"\n"; |
| 556 |
|
| 557 |
//--- S12 ------- |
| 558 |
if(plane==1){ |
| 559 |
xt = xtr; |
| 560 |
yt = ytr; |
| 561 |
paddleidoftrack=-1; |
| 562 |
xl = -40.8/2. ; |
| 563 |
xh = 40.8/2. ; |
| 564 |
|
| 565 |
if ((xt>xl)&&(xt<xh)) { |
| 566 |
for (Int_t i1=0; i1<6;i1++){ |
| 567 |
yl = tof12_y[i1] - (5.5-margin)/2. ; |
| 568 |
yh = tof12_y[i1] + (5.5-margin)/2. ; |
| 569 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
| 570 |
} |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
//--- S21 ------ |
| 575 |
|
| 576 |
if(plane==2){ |
| 577 |
xt = xtr; |
| 578 |
yt = ytr; |
| 579 |
paddleidoftrack=-1; |
| 580 |
xl = -18./2. ; |
| 581 |
xh = 18./2. ; |
| 582 |
|
| 583 |
if ((xt>xl)&&(xt<xh)) { |
| 584 |
for (Int_t i1=0; i1<2;i1++){ |
| 585 |
yl = tof21_y[i1] - (7.5-margin)/2. ; |
| 586 |
yh = tof21_y[i1] + (7.5-margin)/2. ; |
| 587 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
| 588 |
} |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
//--- S22 ------ |
| 593 |
if(plane==3){ |
| 594 |
xt = xtr; |
| 595 |
yt = ytr; |
| 596 |
paddleidoftrack=-1; |
| 597 |
yl = -15./2. ; |
| 598 |
yh = 15./2. ; |
| 599 |
|
| 600 |
if ((yt>yl)&&(yt<yh)) { |
| 601 |
for (Int_t i1=0; i1<2;i1++){ |
| 602 |
xl = tof22_x[i1] - (9.0-margin)/2. ; |
| 603 |
xh = tof22_x[i1] + (9.0-margin)/2. ; |
| 604 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
| 605 |
} |
| 606 |
} |
| 607 |
} |
| 608 |
|
| 609 |
//--- S31 ------ |
| 610 |
if(plane==4){ |
| 611 |
xt = xtr; |
| 612 |
yt = ytr; |
| 613 |
paddleidoftrack=-1; |
| 614 |
yl = -15.0/2. ; |
| 615 |
yh = 15.0/2. ; |
| 616 |
|
| 617 |
if ((yt>yl)&&(yt<yh)) { |
| 618 |
for (Int_t i1=0; i1<3;i1++){ |
| 619 |
xl = tof31_x[i1] - (6.0-margin)/2. ; |
| 620 |
xh = tof31_x[i1] + (6.0-margin)/2. ; |
| 621 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
| 622 |
} |
| 623 |
} |
| 624 |
} |
| 625 |
|
| 626 |
//--- S32 ------ |
| 627 |
if(plane==5){ |
| 628 |
xt = xtr; |
| 629 |
yt = ytr; |
| 630 |
paddleidoftrack=-1; |
| 631 |
xl = -18.0/2. ; |
| 632 |
xh = 18.0/2. ; |
| 633 |
|
| 634 |
if ((xt>xl)&&(xt<xh)) { |
| 635 |
for (Int_t i1=0; i1<3;i1++){ |
| 636 |
yl = tof32_y[i1] - (5.0-margin)/2. ; |
| 637 |
yh = tof32_y[i1] + (5.0-margin)/2. ; |
| 638 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
| 639 |
} |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
return paddleidoftrack; |
| 644 |
|
| 645 |
} |
| 646 |
|
| 647 |
// |
| 648 |
|
| 649 |
// gf Apr 07 |
| 650 |
|
| 651 |
void ToFLevel2::GetPMTPaddle(Int_t pmt_id, Int_t &plane, Int_t &paddle){ |
| 652 |
|
| 653 |
plane = GetPlaneIndex(pmt_id); |
| 654 |
|
| 655 |
if(plane == 0){ |
| 656 |
if(pmt_id==0 || pmt_id==1)paddle=0; |
| 657 |
if(pmt_id==2 || pmt_id==3)paddle=1; |
| 658 |
if(pmt_id==4 || pmt_id==5)paddle=2; |
| 659 |
if(pmt_id==6 || pmt_id==7)paddle=3; |
| 660 |
if(pmt_id==8 || pmt_id==9)paddle=4; |
| 661 |
if(pmt_id==10 || pmt_id==11)paddle=5; |
| 662 |
if(pmt_id==12 || pmt_id==13)paddle=6; |
| 663 |
if(pmt_id==14 || pmt_id==15)paddle=7; |
| 664 |
} |
| 665 |
|
| 666 |
if(plane == 1){ |
| 667 |
if(pmt_id==16 || pmt_id==17)paddle=0; |
| 668 |
if(pmt_id==18 || pmt_id==19)paddle=1; |
| 669 |
if(pmt_id==20 || pmt_id==21)paddle=2; |
| 670 |
if(pmt_id==22 || pmt_id==23)paddle=3; |
| 671 |
if(pmt_id==24 || pmt_id==25)paddle=4; |
| 672 |
if(pmt_id==26 || pmt_id==27)paddle=5; |
| 673 |
} |
| 674 |
|
| 675 |
if(plane == 2){ |
| 676 |
if(pmt_id==28 || pmt_id==29)paddle=0; |
| 677 |
if(pmt_id==30 || pmt_id==31)paddle=1; |
| 678 |
} |
| 679 |
|
| 680 |
if(plane == 3){ |
| 681 |
if(pmt_id==32 || pmt_id==33)paddle=0; |
| 682 |
if(pmt_id==34 || pmt_id==35)paddle=1; |
| 683 |
} |
| 684 |
|
| 685 |
if(plane == 4){ |
| 686 |
if(pmt_id==36 || pmt_id==37)paddle=0; |
| 687 |
if(pmt_id==38 || pmt_id==39)paddle=1; |
| 688 |
if(pmt_id==40 || pmt_id==41)paddle=2; |
| 689 |
} |
| 690 |
|
| 691 |
if(plane == 5){ |
| 692 |
if(pmt_id==42 || pmt_id==43)paddle=0; |
| 693 |
if(pmt_id==44 || pmt_id==45)paddle=1; |
| 694 |
if(pmt_id==46 || pmt_id==47)paddle=2; |
| 695 |
} |
| 696 |
return; |
| 697 |
} |
| 698 |
|
| 699 |
// |
| 700 |
|
| 701 |
// gf Apr 07 |
| 702 |
|
| 703 |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
| 704 |
pmtleft=paddle*2; |
| 705 |
pmtright= pmtleft+1; |
| 706 |
return; |
| 707 |
} |
| 708 |
|
| 709 |
// |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
// // gf Apr 07 |
| 714 |
|
| 715 |
void ToFLevel2::GetPaddleGeometry(Int_t plane, Int_t paddle, Float_t &xleft, Float_t &xright, Float_t &yleft, Float_t &yright){ |
| 716 |
|
| 717 |
Int_t i1; |
| 718 |
|
| 719 |
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
| 720 |
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
| 721 |
Float_t tof21_y[2] = { 3.75,-3.75}; |
| 722 |
Float_t tof22_x[2] = { -4.5,4.5}; |
| 723 |
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
| 724 |
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
| 725 |
|
| 726 |
// S11 8 paddles 33.0 x 5.1 cm |
| 727 |
// S12 6 paddles 40.8 x 5.5 cm |
| 728 |
// S21 2 paddles 18.0 x 7.5 cm |
| 729 |
// S22 2 paddles 15.0 x 9.0 cm |
| 730 |
// S31 3 paddles 15.0 x 6.0 cm |
| 731 |
// S32 3 paddles 18.0 x 5.0 cm |
| 732 |
|
| 733 |
if(plane==0) |
| 734 |
{ |
| 735 |
for (i1=0; i1<8;i1++){ |
| 736 |
if(i1 == paddle){ |
| 737 |
xleft = tof11_x[i1] - 5.1/2.; |
| 738 |
xright = tof11_x[i1] + 5.1/2.; |
| 739 |
yleft = -33.0/2.; |
| 740 |
yright = 33.0/2.; |
| 741 |
} |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
if(plane==1) |
| 746 |
{ |
| 747 |
for (i1=0; i1<6;i1++){ |
| 748 |
if(i1 == paddle){ |
| 749 |
xleft = -40.8/2.; |
| 750 |
xright = 40.8/2.; |
| 751 |
yleft = tof12_y[i1] - 5.5/2.; |
| 752 |
yright = tof12_y[i1] + 5.5/2.; |
| 753 |
} |
| 754 |
} |
| 755 |
} |
| 756 |
|
| 757 |
if(plane==2) |
| 758 |
{ |
| 759 |
for (i1=0; i1<2;i1++){ |
| 760 |
if(i1 == paddle){ |
| 761 |
xleft = -18./2.; |
| 762 |
xright = 18./2.; |
| 763 |
yleft = tof21_y[i1] - 7.5/2.; |
| 764 |
yright = tof21_y[i1] + 7.5/2.; |
| 765 |
} |
| 766 |
} |
| 767 |
} |
| 768 |
|
| 769 |
if(plane==3) |
| 770 |
{ |
| 771 |
for (i1=0; i1<2;i1++){ |
| 772 |
if(i1 == paddle){ |
| 773 |
xleft = tof22_x[i1] - 9.0/2.; |
| 774 |
xright = tof22_x[i1] + 9.0/2.; |
| 775 |
yleft = -15./2.; |
| 776 |
yright = 15./2.; |
| 777 |
} |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
if(plane==4) |
| 783 |
{ |
| 784 |
for (i1=0; i1<3;i1++){ |
| 785 |
if(i1 == paddle){ |
| 786 |
xleft = tof31_x[i1] - 6.0/2.; |
| 787 |
xright = tof31_x[i1] + 6.0/2.; |
| 788 |
yleft = -15./2.; |
| 789 |
yright = 15./2.; |
| 790 |
} |
| 791 |
} |
| 792 |
} |
| 793 |
|
| 794 |
if(plane==5) |
| 795 |
{ |
| 796 |
for (i1=0; i1<3;i1++){ |
| 797 |
if(i1 == paddle){ |
| 798 |
xleft = -18.0/2.; |
| 799 |
xright = 18.0/2.; |
| 800 |
yleft = tof32_y[i1] - 5.0/2.; |
| 801 |
yright = tof32_y[i1] + 5.0/2.; |
| 802 |
} |
| 803 |
} |
| 804 |
} |
| 805 |
return; |
| 806 |
} |
| 807 |
|
| 808 |
// gf Apr 07 |
| 809 |
/** |
| 810 |
* Method to get the paddle index (0,...23) if the plane ID and the paddle id in the plane is given. |
| 811 |
* This method is the |
| 812 |
* "reverse" of method "GetPaddlePlane" |
| 813 |
* @param plane (0 - 5) |
| 814 |
* @param paddle (plane=0, paddle = 0,...5) |
| 815 |
* @param padid (0 - 23) |
| 816 |
*/ |
| 817 |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
| 818 |
{ |
| 819 |
Int_t padid=-1; |
| 820 |
Int_t pads[6]={8,6,2,2,3,3}; |
| 821 |
|
| 822 |
int somma=0; |
| 823 |
int np=plane; |
| 824 |
for(Int_t j=0; j<np; j++){ |
| 825 |
somma+=pads[j]; |
| 826 |
} |
| 827 |
padid=paddle+somma; |
| 828 |
return padid; |
| 829 |
} |
| 830 |
|
| 831 |
|
| 832 |
// gf Apr 07 |
| 833 |
/** |
| 834 |
* Method to get the plane ID and the paddle id in the plane if the paddle index (0,...23) is given. |
| 835 |
* This method is the |
| 836 |
* "reverse" of method "GetPaddleid" |
| 837 |
* @param pad (0 - 23) |
| 838 |
* @param plane (0 - 5) |
| 839 |
* @param paddle (plane=0, paddle = 0,...5) |
| 840 |
*/ |
| 841 |
void ToFLevel2::GetPaddlePlane(Int_t pad, Int_t &plane, Int_t &paddle) |
| 842 |
{ |
| 843 |
|
| 844 |
Int_t pads11=8; |
| 845 |
Int_t pads12=6; |
| 846 |
Int_t pads21=2; |
| 847 |
Int_t pads22=2; |
| 848 |
Int_t pads31=3; |
| 849 |
// Int_t pads32=3; |
| 850 |
|
| 851 |
if(pad<8){ |
| 852 |
plane=0; |
| 853 |
paddle=pad; |
| 854 |
return; |
| 855 |
} |
| 856 |
|
| 857 |
if(7<pad<14){ |
| 858 |
plane=1; |
| 859 |
paddle=pad-pads11; |
| 860 |
return; |
| 861 |
} |
| 862 |
|
| 863 |
if(13<pad<16){ |
| 864 |
plane=2; |
| 865 |
paddle=pad-pads11-pads12; |
| 866 |
return; |
| 867 |
} |
| 868 |
|
| 869 |
if(15<pad<18){ |
| 870 |
plane=3; |
| 871 |
paddle=pad-pads11-pads12-pads21; |
| 872 |
return; |
| 873 |
} |
| 874 |
|
| 875 |
if(17<pad<21){ |
| 876 |
plane=4; |
| 877 |
paddle=pad-pads11-pads12-pads21-pads22; |
| 878 |
return; |
| 879 |
} |
| 880 |
|
| 881 |
if(20<pad<24){ |
| 882 |
plane=5; |
| 883 |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
| 884 |
return; |
| 885 |
} |
| 886 |
|
| 887 |
} |
| 888 |
|
| 889 |
|
| 890 |
Int_t ToFLevel2::GetNPaddle(Int_t plane){ |
| 891 |
|
| 892 |
Int_t npaddle=-1; |
| 893 |
|
| 894 |
Int_t pads11=8; |
| 895 |
Int_t pads12=6; |
| 896 |
Int_t pads21=2; |
| 897 |
Int_t pads22=2; |
| 898 |
Int_t pads31=3; |
| 899 |
Int_t pads32=3; |
| 900 |
|
| 901 |
if(plane==0)npaddle=pads11; |
| 902 |
if(plane==1)npaddle=pads12; |
| 903 |
if(plane==2)npaddle=pads21; |
| 904 |
if(plane==3)npaddle=pads22; |
| 905 |
if(plane==4)npaddle=pads31; |
| 906 |
if(plane==5)npaddle=pads32; |
| 907 |
|
| 908 |
return npaddle; |
| 909 |
|
| 910 |
} |
| 911 |
|
| 912 |
/// wm feb 08 |
| 913 |
|
| 914 |
/** |
| 915 |
* Method to calculate Beta from the 12 single measurements |
| 916 |
* we check the individual weights for artificial TDC values, then calculate |
| 917 |
* am mean beta for the first time. In a second step we loop again through |
| 918 |
* the single measurements, checking for the residual from the mean |
| 919 |
* The cut on the residual reject measurements > "x"-sigma. A chi2 value is |
| 920 |
* calculated, furthermore a "quality" value by adding the weights which |
| 921 |
* are finally used. If all measurements are taken, "quality" will be = 22.47. |
| 922 |
* A chi2 cut around 3-4 and a quality-cut > 20 is needed for clean beta |
| 923 |
* measurements like antiprotons etc. |
| 924 |
* The Level2 output is derived in the fortran routines using: 10.,10.,20. |
| 925 |
* @param notrack Track Number |
| 926 |
* @param cut on residual: difference between single measurement and mean |
| 927 |
* @param cut on "quality" |
| 928 |
* @param cut on chi2 |
| 929 |
*/ |
| 930 |
|
| 931 |
Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){ |
| 932 |
|
| 933 |
// cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl; |
| 934 |
|
| 935 |
Float_t bxx = 100.; |
| 936 |
// |
| 937 |
ToFTrkVar *trk = GetToFTrkVar(notrack); |
| 938 |
if(!trk) return 0; //ELENA |
| 939 |
|
| 940 |
|
| 941 |
Float_t chi2,xhelp,beta_mean; |
| 942 |
Float_t w_i[12],quality,sw,sxw,res,betachi,beta_mean_inv; |
| 943 |
Float_t b[12],tdcfl; |
| 944 |
Int_t pmt_id,pmt_plane; |
| 945 |
|
| 946 |
for (Int_t i=0; i<12; i++){ |
| 947 |
b[i] = trk->beta[i]; |
| 948 |
} |
| 949 |
|
| 950 |
|
| 951 |
//======================================================================== |
| 952 |
//--- Find out ToF layers with artificial TDC values & fill vector --- |
| 953 |
//======================================================================== |
| 954 |
|
| 955 |
Float_t w_il[6]; |
| 956 |
|
| 957 |
for (Int_t jj=0; jj<6;jj++) { |
| 958 |
w_il[jj] = 1000.; |
| 959 |
} |
| 960 |
|
| 961 |
|
| 962 |
for (Int_t i=0; i<trk->npmttdc; i++){ |
| 963 |
// |
| 964 |
pmt_id = (trk->pmttdc).At(i); |
| 965 |
pmt_plane = GetPlaneIndex(pmt_id); |
| 966 |
tdcfl = (trk->tdcflag).At(i); |
| 967 |
if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag |
| 968 |
}; |
| 969 |
|
| 970 |
//======================================================================== |
| 971 |
//--- Set weights for the 12 measurements using information for top and bottom: |
| 972 |
//--- if no measurements: weight = set to very high value=> not used |
| 973 |
//--- top or bottom artificial: weight*sqrt(2) |
| 974 |
//--- top and bottom artificial: weight*sqrt(2)*sqrt(2) |
| 975 |
//======================================================================== |
| 976 |
|
| 977 |
Int_t itop[12] = {0,0,1,1,2,2,3,3,0,0,1,1}; |
| 978 |
Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2,3}; |
| 979 |
|
| 980 |
xhelp= 1E09; |
| 981 |
|
| 982 |
for (Int_t jj=0; jj<12;jj++) { |
| 983 |
if (jj<4) xhelp = 0.11; // S1-S3 |
| 984 |
if ((jj>3)&&(jj<8)) xhelp = 0.18; // S2-S3 |
| 985 |
if (jj>7) xhelp = 0.28; // S1-S2 |
| 986 |
if ((w_il[itop[jj]] == 1000.) && (w_il[ibot[jj]] == 1000.)) xhelp = 1E09; |
| 987 |
if ((w_il[itop[jj]] == 1) || (w_il[ibot[jj]] == 1.)) xhelp = xhelp*1.414 ; |
| 988 |
if ((w_il[itop[jj]] == 1) && (w_il[ibot[jj]] == 1.)) xhelp = xhelp*2. ; |
| 989 |
|
| 990 |
w_i[jj] = 1./xhelp; |
| 991 |
} |
| 992 |
|
| 993 |
|
| 994 |
//======================================================================== |
| 995 |
//--- Calculate mean beta for the first time ----------------------------- |
| 996 |
//--- We are using "1/beta" since its error is gaussian ------------------ |
| 997 |
//======================================================================== |
| 998 |
|
| 999 |
Int_t icount=0; |
| 1000 |
sw=0.; |
| 1001 |
sxw=0.; |
| 1002 |
beta_mean=100.; |
| 1003 |
|
| 1004 |
for (Int_t jj=0; jj<12;jj++){ |
| 1005 |
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)) |
| 1006 |
{ |
| 1007 |
icount= icount+1; |
| 1008 |
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
| 1009 |
sw =sw + w_i[jj]*w_i[jj] ; |
| 1010 |
|
| 1011 |
} |
| 1012 |
} |
| 1013 |
|
| 1014 |
if (icount>0) beta_mean=1./(sxw/sw); |
| 1015 |
beta_mean_inv = 1./beta_mean; |
| 1016 |
|
| 1017 |
//======================================================================== |
| 1018 |
//--- Calculate beta for the second time, use residuals of the single |
| 1019 |
//--- measurements to get a chi2 value |
| 1020 |
//======================================================================== |
| 1021 |
|
| 1022 |
icount=0; |
| 1023 |
sw=0.; |
| 1024 |
sxw=0.; |
| 1025 |
betachi = 100.; |
| 1026 |
chi2 = 0.; |
| 1027 |
quality=0.; |
| 1028 |
|
| 1029 |
|
| 1030 |
for (Int_t jj=0; jj<12;jj++){ |
| 1031 |
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)&&(w_i[jj]>0.01)) { |
| 1032 |
res = beta_mean_inv - (1./b[jj]) ; |
| 1033 |
if (fabs(res*w_i[jj])<resmax) {; |
| 1034 |
chi2 = chi2 + pow((res*w_i[jj]),2) ; |
| 1035 |
icount= icount+1; |
| 1036 |
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
| 1037 |
sw =sw + w_i[jj]*w_i[jj] ; |
| 1038 |
} |
| 1039 |
} |
| 1040 |
} |
| 1041 |
quality = sqrt(sw) ; |
| 1042 |
|
| 1043 |
if (icount==0) chi2 = 1000.; |
| 1044 |
if (icount>0) chi2 = chi2/(icount) ; |
| 1045 |
if (icount>0) betachi=1./(sxw/sw); |
| 1046 |
|
| 1047 |
bxx = 100.; |
| 1048 |
if ((chi2 < chi2cut)&&(quality>qualitycut)) bxx = betachi; |
| 1049 |
// |
| 1050 |
return(bxx); |
| 1051 |
}; |
| 1052 |
|
| 1053 |
|
| 1054 |
//////////////////////////////////////////////////// |
| 1055 |
//////////////////////////////////////////////////// |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
/** |
| 1060 |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
| 1061 |
*/ |
| 1062 |
void ToFLevel2::GetLevel2Struct(cToFLevel2 *l2) const{ |
| 1063 |
|
| 1064 |
for(Int_t i=0;i<6;i++) |
| 1065 |
l2->tof_j_flag[i]=tof_j_flag[i]; |
| 1066 |
|
| 1067 |
if(ToFTrk){ //ELENA |
| 1068 |
l2->ntoftrk = ToFTrk->GetEntries(); |
| 1069 |
for(Int_t j=0;j<l2->ntoftrk;j++){ |
| 1070 |
l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno; |
| 1071 |
l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc; |
| 1072 |
for(Int_t i=0;i<l2->npmttdc[j];i++){ |
| 1073 |
l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i); |
| 1074 |
l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006 |
| 1075 |
} |
| 1076 |
for(Int_t i=0;i<13;i++) |
| 1077 |
l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i]; |
| 1078 |
|
| 1079 |
l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc; |
| 1080 |
for(Int_t i=0;i<l2->npmtadc[j];i++){ |
| 1081 |
l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i); |
| 1082 |
l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006 |
| 1083 |
l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i); |
| 1084 |
} |
| 1085 |
for(Int_t i=0;i<3;i++){ |
| 1086 |
l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i]; |
| 1087 |
l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i]; |
| 1088 |
} |
| 1089 |
for(Int_t i=0;i<6;i++){ |
| 1090 |
l2->xtr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtr_tof[i]; |
| 1091 |
l2->ytr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytr_tof[i]; |
| 1092 |
} |
| 1093 |
} |
| 1094 |
} //ELENA |
| 1095 |
|
| 1096 |
if(PMT){ //ELENA |
| 1097 |
l2->npmt = PMT->GetEntries(); |
| 1098 |
for(Int_t j=0;j<l2->npmt;j++){ |
| 1099 |
l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id; |
| 1100 |
l2->adc[j] =((ToFPMT*)PMT->At(j))->adc; |
| 1101 |
l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw; |
| 1102 |
} |
| 1103 |
} //ELENA |
| 1104 |
} |
| 1105 |
|
| 1106 |
|
| 1107 |
// |
| 1108 |
// Reprocessing tool // Emiliano 08/04/07 |
| 1109 |
// |
| 1110 |
Int_t ToFLevel2::Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force){ |
| 1111 |
// |
| 1112 |
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
| 1113 |
// |
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
// |
| 1119 |
// structures to communicate with F77 |
| 1120 |
// |
| 1121 |
extern struct ToFInput tofinput_; |
| 1122 |
extern struct ToFOutput tofoutput_; |
| 1123 |
// |
| 1124 |
// DB connection |
| 1125 |
// |
| 1126 |
TString host; |
| 1127 |
TString user; |
| 1128 |
TString psw; |
| 1129 |
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 1130 |
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 1131 |
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 1132 |
if ( !pamdbhost ) pamdbhost = ""; |
| 1133 |
if ( !pamdbuser ) pamdbuser = ""; |
| 1134 |
if ( !pamdbpsw ) pamdbpsw = ""; |
| 1135 |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 1136 |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 1137 |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 1138 |
// |
| 1139 |
// |
| 1140 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 1141 |
if ( !dbc->IsConnected() ) return 1; |
| 1142 |
stringstream myquery; |
| 1143 |
myquery.str(""); |
| 1144 |
myquery << "SET time_zone='+0:00'"; |
| 1145 |
dbc->Query(myquery.str().c_str()); |
| 1146 |
GL_PARAM *glparam = new GL_PARAM(); |
| 1147 |
glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
| 1148 |
trk->LoadField(glparam->PATH+glparam->NAME); |
| 1149 |
// |
| 1150 |
Bool_t defcal = true; |
| 1151 |
Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
| 1152 |
if ( error<0 ) { |
| 1153 |
return(1); |
| 1154 |
}; |
| 1155 |
printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
| 1156 |
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
| 1157 |
// |
| 1158 |
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
| 1159 |
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
| 1160 |
// |
| 1161 |
Int_t adc[4][12]; |
| 1162 |
Int_t tdc[4][12]; |
| 1163 |
Float_t tdcc[4][12]; |
| 1164 |
// |
| 1165 |
// process tof data |
| 1166 |
// |
| 1167 |
for (Int_t hh=0; hh<12;hh++){ |
| 1168 |
for (Int_t kk=0; kk<4;kk++){ |
| 1169 |
adc[kk][hh] = 4095; |
| 1170 |
tdc[kk][hh] = 4095; |
| 1171 |
tdcc[kk][hh] = 4095.; |
| 1172 |
tofinput_.adc[hh][kk] = 4095; |
| 1173 |
tofinput_.tdc[hh][kk] = 4095; |
| 1174 |
}; |
| 1175 |
}; |
| 1176 |
Int_t ntrkentry = 0; |
| 1177 |
Int_t npmtentry = 0; |
| 1178 |
Int_t gg = 0; |
| 1179 |
Int_t hh = 0; |
| 1180 |
Int_t adcf[48]; |
| 1181 |
memset(adcf, 0, 48*sizeof(Int_t)); |
| 1182 |
Int_t tdcf[48]; |
| 1183 |
memset(tdcf, 0, 48*sizeof(Int_t)); |
| 1184 |
for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
| 1185 |
ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
| 1186 |
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
| 1187 |
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
| 1188 |
}; |
| 1189 |
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
| 1190 |
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
| 1191 |
}; |
| 1192 |
}; |
| 1193 |
// |
| 1194 |
for (Int_t pm=0; pm < this->npmt() ; pm++){ |
| 1195 |
ToFPMT *pmt = this->GetToFPMT(pm); |
| 1196 |
this->GetPMTIndex(pmt->pmt_id, gg, hh); |
| 1197 |
if ( adcf[pmt->pmt_id] == 0 ){ |
| 1198 |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
| 1199 |
adc[hh][gg] = (int)pmt->adc; |
| 1200 |
}; |
| 1201 |
if ( tdcf[pmt->pmt_id] == 0 ){ |
| 1202 |
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
| 1203 |
tdc[hh][gg] = (int)pmt->tdc; |
| 1204 |
}; |
| 1205 |
tdcc[hh][gg] = (float)pmt->tdc_tw; |
| 1206 |
// Int_t pppid = this->GetPMTid(hh,gg); |
| 1207 |
// 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); |
| 1208 |
}; |
| 1209 |
// |
| 1210 |
Int_t unpackError = this->unpackError; |
| 1211 |
// |
| 1212 |
for (Int_t hh=0; hh<5;hh++){ |
| 1213 |
tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
| 1214 |
}; |
| 1215 |
// |
| 1216 |
this->Clear(); |
| 1217 |
// |
| 1218 |
Int_t pmt_id = 0; |
| 1219 |
ToFPMT *t_pmt = new ToFPMT(); |
| 1220 |
if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
| 1221 |
TClonesArray &tpmt = *this->PMT; |
| 1222 |
ToFTrkVar *t_tof = new ToFTrkVar(); |
| 1223 |
if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
| 1224 |
TClonesArray &t = *this->ToFTrk; |
| 1225 |
// |
| 1226 |
// |
| 1227 |
// Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
| 1228 |
// |
| 1229 |
npmtentry = 0; |
| 1230 |
// |
| 1231 |
ntrkentry = 0; |
| 1232 |
// |
| 1233 |
// Calculate tracks informations from ToF alone |
| 1234 |
// |
| 1235 |
tofl2com(); |
| 1236 |
// |
| 1237 |
memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
| 1238 |
// |
| 1239 |
t_tof->trkseqno = -1; |
| 1240 |
// |
| 1241 |
// and now we must copy from the output structure to the level2 class: |
| 1242 |
// |
| 1243 |
t_tof->npmttdc = 0; |
| 1244 |
// |
| 1245 |
for (Int_t hh=0; hh<12;hh++){ |
| 1246 |
for (Int_t kk=0; kk<4;kk++){ |
| 1247 |
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
| 1248 |
pmt_id = this->GetPMTid(kk,hh); |
| 1249 |
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
| 1250 |
t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
| 1251 |
t_tof->npmttdc++; |
| 1252 |
}; |
| 1253 |
}; |
| 1254 |
}; |
| 1255 |
for (Int_t kk=0; kk<13;kk++){ |
| 1256 |
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
| 1257 |
} |
| 1258 |
// |
| 1259 |
t_tof->npmtadc = 0; |
| 1260 |
for (Int_t hh=0; hh<12;hh++){ |
| 1261 |
for (Int_t kk=0; kk<4;kk++){ |
| 1262 |
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
| 1263 |
t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
| 1264 |
pmt_id = this->GetPMTid(kk,hh); |
| 1265 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
| 1266 |
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
| 1267 |
t_tof->npmtadc++; |
| 1268 |
}; |
| 1269 |
}; |
| 1270 |
}; |
| 1271 |
// |
| 1272 |
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
| 1273 |
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
| 1274 |
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
| 1275 |
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
| 1276 |
// |
| 1277 |
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
| 1278 |
ntrkentry++; |
| 1279 |
t_tof->Clear(); |
| 1280 |
// |
| 1281 |
// |
| 1282 |
// |
| 1283 |
t_pmt->Clear(); |
| 1284 |
// |
| 1285 |
for (Int_t hh=0; hh<12;hh++){ |
| 1286 |
for (Int_t kk=0; kk<4;kk++){ |
| 1287 |
// new WM |
| 1288 |
if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
| 1289 |
// if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
| 1290 |
// |
| 1291 |
t_pmt->pmt_id = this->GetPMTid(kk,hh); |
| 1292 |
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
| 1293 |
t_pmt->adc = (Float_t)adc[kk][hh]; |
| 1294 |
t_pmt->tdc = (Float_t)tdc[kk][hh]; |
| 1295 |
// |
| 1296 |
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
| 1297 |
npmtentry++; |
| 1298 |
t_pmt->Clear(); |
| 1299 |
}; |
| 1300 |
}; |
| 1301 |
}; |
| 1302 |
// |
| 1303 |
// Calculate track-related variables |
| 1304 |
// |
| 1305 |
if ( trk->ntrk() > 0 ){ |
| 1306 |
// |
| 1307 |
// We have at least one track |
| 1308 |
// |
| 1309 |
// |
| 1310 |
// Run over tracks |
| 1311 |
// |
| 1312 |
for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
| 1313 |
// |
| 1314 |
TrkTrack *ptt = trk->GetStoredTrack(nt); |
| 1315 |
// |
| 1316 |
// Copy the alpha vector in the input structure |
| 1317 |
// |
| 1318 |
for (Int_t e = 0; e < 5 ; e++){ |
| 1319 |
tofinput_.al_pp[e] = ptt->al[e]; |
| 1320 |
}; |
| 1321 |
// |
| 1322 |
// Get tracker related variables for this track |
| 1323 |
// |
| 1324 |
toftrk(); |
| 1325 |
// |
| 1326 |
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
| 1327 |
// |
| 1328 |
t_tof->npmttdc = 0; |
| 1329 |
for (Int_t hh=0; hh<12;hh++){ |
| 1330 |
for (Int_t kk=0; kk<4;kk++){ |
| 1331 |
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
| 1332 |
pmt_id = this->GetPMTid(kk,hh); |
| 1333 |
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
| 1334 |
t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
| 1335 |
t_tof->npmttdc++; |
| 1336 |
}; |
| 1337 |
}; |
| 1338 |
}; |
| 1339 |
for (Int_t kk=0; kk<13;kk++){ |
| 1340 |
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
| 1341 |
}; |
| 1342 |
// |
| 1343 |
t_tof->npmtadc = 0; |
| 1344 |
for (Int_t hh=0; hh<12;hh++){ |
| 1345 |
for (Int_t kk=0; kk<4;kk++){ |
| 1346 |
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
| 1347 |
t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
| 1348 |
pmt_id = this->GetPMTid(kk,hh); |
| 1349 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
| 1350 |
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
| 1351 |
t_tof->npmtadc++; |
| 1352 |
}; |
| 1353 |
}; |
| 1354 |
}; |
| 1355 |
// |
| 1356 |
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
| 1357 |
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
| 1358 |
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
| 1359 |
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
| 1360 |
// |
| 1361 |
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
| 1362 |
// |
| 1363 |
t_tof->trkseqno = nt; |
| 1364 |
// |
| 1365 |
// create a new object for this event with track-related variables |
| 1366 |
// |
| 1367 |
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
| 1368 |
ntrkentry++; |
| 1369 |
t_tof->Clear(); |
| 1370 |
// |
| 1371 |
}; // loop on all the tracks |
| 1372 |
// |
| 1373 |
this->unpackError = unpackError; |
| 1374 |
if ( defcal ){ |
| 1375 |
this->default_calib = 1; |
| 1376 |
} else { |
| 1377 |
this->default_calib = 0; |
| 1378 |
}; |
| 1379 |
}; |
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
return(0); |
| 1384 |
} |