| 56 |
clevel1 = &clevel1_; |
clevel1 = &clevel1_; |
| 57 |
clevel2 = &clevel2_; |
clevel2 = &clevel2_; |
| 58 |
// |
// |
| 59 |
|
// extern struct FlEventi eventi_; |
| 60 |
|
// extern struct FlGruppo gruppo_; |
| 61 |
|
// extern struct FlGruppo2 gruppo2_; |
| 62 |
|
// extern struct FlGruppo4 gruppo4_; |
| 63 |
|
// extern struct FlTaglioen taglioen_; |
| 64 |
|
// extern struct FlAngolo angolo_; |
| 65 |
|
// extern struct FlWhere where_; |
| 66 |
|
// extern struct FlGeneral general_; |
| 67 |
|
// extern struct FlCh ch_; |
| 68 |
|
// extern struct FlCalofit calofit_; |
| 69 |
|
// extern struct FlPawcd pawcd_; |
| 70 |
|
// extern struct FlQuestd questd_; |
| 71 |
|
// eventi = &eventi_; |
| 72 |
|
// gruppo = &gruppo_; |
| 73 |
|
// gruppo2 = &gruppo2_; |
| 74 |
|
// gruppo4 = &gruppo4_; |
| 75 |
|
// taglioen = &taglioen_; |
| 76 |
|
// angolo = &angolo_; |
| 77 |
|
// where = &where_; |
| 78 |
|
// general = &general_; |
| 79 |
|
// ch = &ch_; |
| 80 |
|
// calofit = &calofit_; |
| 81 |
|
// pawcd = &pawcd_; |
| 82 |
|
// questd = &questd_; |
| 83 |
|
// |
| 84 |
trkseqno = 0; |
trkseqno = 0; |
| 85 |
ClearStructs(); |
ClearStructs(); |
| 86 |
// |
// |
| 92 |
memset(obadmask, 0, 2*22*96*sizeof(Int_t)); |
memset(obadmask, 0, 2*22*96*sizeof(Int_t)); |
| 93 |
memset(obadpulsemask, 0, 2*22*6*sizeof(Int_t)); |
memset(obadpulsemask, 0, 2*22*6*sizeof(Int_t)); |
| 94 |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
| 95 |
|
memset(ctsicor, 0, 2*22*9*sizeof(Float_t)); |
| 96 |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
| 97 |
calopar1 = true; |
calopar1 = true; |
| 98 |
calopar2 = true; |
calopar2 = true; |
| 99 |
calopar3 = true; |
calopar3 = true; |
| 100 |
|
calopar4 = true; |
| 101 |
|
calopar5 = true; |
| 102 |
crosst = true; |
crosst = true; |
| 103 |
|
mask18 = false; |
| 104 |
ftcalopar1 = 0; |
ftcalopar1 = 0; |
| 105 |
ttcalopar1 = 0; |
ttcalopar1 = 0; |
| 106 |
ftcalopar2 = 0; |
ftcalopar2 = 0; |
| 107 |
ttcalopar2 = 0; |
ttcalopar2 = 0; |
| 108 |
ftcalopar3 = 0; |
ftcalopar3 = 0; |
| 109 |
ttcalopar3 = 0; |
ttcalopar3 = 0; |
| 110 |
|
ftcalopar4 = 0; |
| 111 |
|
ttcalopar4 = 0; |
| 112 |
|
ftcalopar5 = 0; |
| 113 |
|
ttcalopar5 = 0; |
| 114 |
} |
} |
| 115 |
|
|
| 116 |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
| 121 |
ctground = ct; |
ctground = ct; |
| 122 |
} |
} |
| 123 |
|
|
| 124 |
|
void CaloLevel0::SetCrossTalkType(Int_t ct){ |
| 125 |
|
if ( ct == 0 ) ctground = true; |
| 126 |
|
if ( ct == 1 ){ |
| 127 |
|
ctground = false; |
| 128 |
|
noselfct = false; |
| 129 |
|
}; |
| 130 |
|
if ( ct == 2 ){ |
| 131 |
|
ctground = false; |
| 132 |
|
noselfct = true; |
| 133 |
|
}; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
void CaloLevel0::SetVerbose(Bool_t ct){ |
void CaloLevel0::SetVerbose(Bool_t ct){ |
| 137 |
verbose = ct; |
verbose = ct; |
| 138 |
} |
} |
| 140 |
/** |
/** |
| 141 |
* Initialize CaloLevel0 object |
* Initialize CaloLevel0 object |
| 142 |
**/ |
**/ |
| 143 |
|
void CaloLevel0::ProcessingInit(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
| 144 |
|
if ( !dbc->IsConnected() ) throw -116; |
| 145 |
|
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
/** |
| 149 |
|
* Initialize CaloLevel0 object |
| 150 |
|
**/ |
| 151 |
void CaloLevel0::ProcessingInit(GL_TABLES *glt, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
void CaloLevel0::ProcessingInit(GL_TABLES *glt, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
| 152 |
// |
// |
| 153 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
| 155 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
| 156 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 157 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
| 158 |
|
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
| 159 |
|
dbc->Close(); |
| 160 |
|
delete dbc; |
| 161 |
|
dbc = 0; |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
void CaloLevel0::InitDo(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
| 166 |
stringstream myquery; |
stringstream myquery; |
| 167 |
myquery.str(""); |
myquery.str(""); |
| 168 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
| 243 |
// |
// |
| 244 |
delete glcalo; |
delete glcalo; |
| 245 |
delete glroot; |
delete glroot; |
|
dbc->Close(); |
|
|
delete dbc; |
|
| 246 |
// |
// |
| 247 |
return; |
return; |
| 248 |
// |
// |
| 259 |
return(sgnl); |
return(sgnl); |
| 260 |
} |
} |
| 261 |
|
|
| 262 |
|
Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
| 263 |
|
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
| 264 |
|
return(sig); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
| 268 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
| 269 |
const TString user = glt->CGetUser(); |
const TString user = glt->CGetUser(); |
| 275 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
| 276 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
| 277 |
// |
// |
| 278 |
|
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
| 279 |
|
dbc->Close(); |
| 280 |
|
delete dbc; |
| 281 |
|
dbc = 0; |
| 282 |
|
return(sig); |
| 283 |
|
} |
| 284 |
|
|
| 285 |
|
Int_t CaloLevel0::ChkParamDo(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
| 286 |
|
// |
| 287 |
stringstream calfile; |
stringstream calfile; |
| 288 |
stringstream bmfile; |
stringstream bmfile; |
| 289 |
stringstream aligfile; |
stringstream aligfile; |
| 294 |
// |
// |
| 295 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
| 296 |
// |
// |
|
// |
|
|
// |
|
| 297 |
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
| 298 |
// |
// |
| 299 |
|
if ( calopar1 ){ |
| 300 |
|
// |
| 301 |
|
// determine where I can find calorimeter ADC to MIP conversion file |
| 302 |
|
// |
| 303 |
|
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
| 304 |
|
// |
| 305 |
|
error = 0; |
| 306 |
|
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
| 307 |
|
if ( error < 0 ) return(error); |
| 308 |
|
// |
| 309 |
|
calfile.str(""); |
| 310 |
|
calfile << glparam->PATH.Data() << "/"; |
| 311 |
|
calfile << glparam->NAME.Data(); |
| 312 |
|
// |
| 313 |
|
if ( verbose ) printf("\n Using ADC to MIP conversion file: \n %s \n",calfile.str().c_str()); |
| 314 |
|
f = fopen(calfile.str().c_str(),"rb"); |
| 315 |
|
if ( !f ){ |
| 316 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no ADC to MIP file!\n"); |
| 317 |
|
return(-105); |
| 318 |
|
}; |
| 319 |
|
// |
| 320 |
|
for (Int_t m = 0; m < 2 ; m++ ){ |
| 321 |
|
for (Int_t k = 0; k < 22; k++ ){ |
| 322 |
|
for (Int_t l = 0; l < 96; l++ ){ |
| 323 |
|
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
| 324 |
|
if ( debug ) printf(" %f \n",mip[m][k][l]); |
| 325 |
|
}; |
| 326 |
|
}; |
| 327 |
|
}; |
| 328 |
|
fclose(f); |
| 329 |
|
}; |
| 330 |
|
// |
| 331 |
calopar1 = false; |
calopar1 = false; |
| 332 |
// |
// |
| 333 |
// determine where I can find calorimeter ADC to MIP conversion file |
// flight extra corrections: |
| 334 |
// |
// |
| 335 |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
if ( verbose ) printf(" Querying DB for calorimeter flight ADC to MIP files...\n"); |
| 336 |
// |
// |
| 337 |
error = 0; |
error = 0; |
| 338 |
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
error = glparam->Query_GL_PARAM(runheader,110,dbc); |
| 339 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
| 340 |
// |
// |
| 341 |
calfile.str(""); |
calfile.str(""); |
| 344 |
ftcalopar1 = glparam->FROM_TIME; |
ftcalopar1 = glparam->FROM_TIME; |
| 345 |
ttcalopar1 = glparam->TO_TIME; |
ttcalopar1 = glparam->TO_TIME; |
| 346 |
// |
// |
| 347 |
if ( verbose ) printf("\n Using ADC to MIP conversion file: \n %s \n",calfile.str().c_str()); |
if ( verbose ) printf("\n Using ADC to MIP special conversion file: \n %s \n",calfile.str().c_str()); |
| 348 |
f = fopen(calfile.str().c_str(),"rb"); |
ifstream spfile; |
| 349 |
if ( !f ){ |
spfile.open(calfile.str().c_str()); |
| 350 |
if ( verbose ) printf(" CALORIMETER - ERROR: no ADC to MIP file!\n"); |
if ( !spfile ){ |
| 351 |
return(-105); |
if ( verbose ) printf(" CALORIMETER - ERROR: no special calibration file!\n"); |
| 352 |
|
return(-123); |
| 353 |
}; |
}; |
| 354 |
|
// |
| 355 |
|
Int_t vview = 0; |
| 356 |
|
Int_t vplane = 0; |
| 357 |
|
Int_t vstrip = 0; |
| 358 |
|
Float_t vval = 0.; |
| 359 |
|
while ( spfile >> vview && spfile >> vplane && spfile >> vstrip && spfile >> vval){ |
| 360 |
|
if ( debug ) printf(" Setting ADC to MIP conversion factor: view %i plane %i strip %i mip %f \n",vview,vplane,vstrip,vval); |
| 361 |
|
mip[vview][vplane][vstrip] = vval; |
| 362 |
|
}; |
| 363 |
// |
// |
|
for (Int_t m = 0; m < 2 ; m++ ){ |
|
|
for (Int_t k = 0; k < 22; k++ ){ |
|
|
for (Int_t l = 0; l < 96; l++ ){ |
|
|
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
|
|
if ( debug ) printf(" %f \n",mip[m][k][l]); |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
fclose(f); |
|
| 364 |
}; |
}; |
| 365 |
// |
// |
| 366 |
|
// |
| 367 |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
| 368 |
|
// |
| 369 |
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
| 370 |
calopar2 = false; |
calopar2 = false; |
| 371 |
// |
// |
| 472 |
badfile.close(); |
badfile.close(); |
| 473 |
}; |
}; |
| 474 |
// |
// |
| 475 |
|
// calopar4 |
| 476 |
|
// |
| 477 |
|
if ( calopar4 || ( ttcalopar4 != 0 && ttcalopar4 < runheader ) ){ |
| 478 |
|
// |
| 479 |
|
if ( debug ) printf(" calopar4 %i ftcalopar4 %u ttcalopar4 %u runheader %u \n",calopar4,ftcalopar4,ttcalopar4,runheader); |
| 480 |
|
// |
| 481 |
|
calopar4 = false; |
| 482 |
|
// |
| 483 |
|
// flight extra corrections: |
| 484 |
|
// |
| 485 |
|
if ( verbose ) printf(" Querying DB for calorimeter max rms file...\n"); |
| 486 |
|
// |
| 487 |
|
error = 0; |
| 488 |
|
error = glparam->Query_GL_PARAM(runheader,109,dbc); |
| 489 |
|
if ( error < 0 ) return(error); |
| 490 |
|
// |
| 491 |
|
calfile.str(""); |
| 492 |
|
calfile << glparam->PATH.Data() << "/"; |
| 493 |
|
calfile << glparam->NAME.Data(); |
| 494 |
|
ftcalopar4 = glparam->FROM_TIME; |
| 495 |
|
ttcalopar4 = glparam->TO_TIME; |
| 496 |
|
// |
| 497 |
|
if ( verbose ) printf("\n Using calorimeter max rms file: \n %s \n",calfile.str().c_str()); |
| 498 |
|
ifstream spfile; |
| 499 |
|
spfile.open(calfile.str().c_str()); |
| 500 |
|
if ( !spfile ){ |
| 501 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no max rms file!\n"); |
| 502 |
|
return(-124); |
| 503 |
|
}; |
| 504 |
|
// |
| 505 |
|
Int_t vview = 0; |
| 506 |
|
Int_t vplane = 0; |
| 507 |
|
Int_t vval = 0; |
| 508 |
|
for (Int_t l=0; l<2; l++){ |
| 509 |
|
for (Int_t m=0; m<22; m++){ |
| 510 |
|
maxrms[l][m] = 26; |
| 511 |
|
}; |
| 512 |
|
}; |
| 513 |
|
while ( spfile >> vview && spfile >> vplane && spfile >> vval){ |
| 514 |
|
if ( debug ) printf(" Setting view %i plane %i max rms %i \n",vview,vplane,vval); |
| 515 |
|
maxrms[vview][vplane] = vval; |
| 516 |
|
}; |
| 517 |
|
spfile.close(); |
| 518 |
|
// |
| 519 |
|
}; |
| 520 |
|
// |
| 521 |
|
// calopar5 |
| 522 |
|
// |
| 523 |
|
if ( calopar5 || ( ttcalopar5 != 0 && ttcalopar5 < runheader ) ){ |
| 524 |
|
// |
| 525 |
|
if ( debug ) printf(" calopar5 %i ftcalopar5 %u ttcalopar5 %u runheader %u \n",calopar5,ftcalopar5,ttcalopar5,runheader); |
| 526 |
|
// |
| 527 |
|
calopar5 = false; |
| 528 |
|
// |
| 529 |
|
// flight extra corrections: |
| 530 |
|
// |
| 531 |
|
if ( verbose ) printf(" Querying DB for calorimeter noise to signal threshold file...\n"); |
| 532 |
|
// |
| 533 |
|
error = 0; |
| 534 |
|
error = glparam->Query_GL_PARAM(runheader,111,dbc); |
| 535 |
|
if ( error < 0 ) return(error); |
| 536 |
|
// |
| 537 |
|
calfile.str(""); |
| 538 |
|
calfile << glparam->PATH.Data() << "/"; |
| 539 |
|
calfile << glparam->NAME.Data(); |
| 540 |
|
ftcalopar5 = glparam->FROM_TIME; |
| 541 |
|
ttcalopar5 = glparam->TO_TIME; |
| 542 |
|
// |
| 543 |
|
if ( verbose ) printf("\n Using calorimeter noise to signal threshold file: \n %s \n",calfile.str().c_str()); |
| 544 |
|
ifstream spfile; |
| 545 |
|
spfile.open(calfile.str().c_str()); |
| 546 |
|
if ( !spfile ){ |
| 547 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no noise to signal threshold file!\n"); |
| 548 |
|
return(-125); |
| 549 |
|
}; |
| 550 |
|
// |
| 551 |
|
Int_t vview = 0; |
| 552 |
|
Int_t vplane = 0; |
| 553 |
|
Int_t vstrip = 0; |
| 554 |
|
Float_t vval = 0.; |
| 555 |
|
for (Int_t l=0; l<2; l++){ |
| 556 |
|
for (Int_t m=0; m<22; m++){ |
| 557 |
|
for (Int_t n=0; n<96; n++){ |
| 558 |
|
memin[l][m][n] = 0.7; |
| 559 |
|
}; |
| 560 |
|
}; |
| 561 |
|
}; |
| 562 |
|
while ( spfile >> vview && spfile >> vplane && spfile >> vstrip && spfile >> vval){ |
| 563 |
|
if ( vstrip == -1 ){ |
| 564 |
|
for (Int_t ll=0; ll<96; ll++){ |
| 565 |
|
if ( debug ) printf(" Setting view %i plane %i strip %i noise to signal ratio %f \n",vview,vplane,ll,vval); |
| 566 |
|
memin[vview][vplane][ll] = vval; |
| 567 |
|
}; |
| 568 |
|
} else { |
| 569 |
|
if ( debug ) printf(" Setting view %i plane %i strip %i noise to signal ratio %f \n",vview,vplane,vstrip,vval); |
| 570 |
|
memin[vview][vplane][vstrip] = vval; |
| 571 |
|
}; |
| 572 |
|
}; |
| 573 |
|
spfile.close(); |
| 574 |
|
// |
| 575 |
|
}; |
| 576 |
|
// |
| 577 |
|
// |
| 578 |
delete glparam; |
delete glparam; |
|
dbc->Close(); |
|
|
delete dbc; |
|
| 579 |
// |
// |
| 580 |
return(0); |
return(0); |
| 581 |
} |
} |
| 582 |
|
|
| 583 |
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader){ |
Int_t CaloLevel0::CalcCrossTalkCorr(TSQLServer *dbc, UInt_t runheader, Bool_t ctusetable){ |
| 584 |
|
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,ctusetable); |
| 585 |
|
return(sig); |
| 586 |
|
}; |
| 587 |
|
|
| 588 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(TSQLServer *dbc, UInt_t runheader){ |
| 589 |
|
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
| 590 |
|
return(sig); |
| 591 |
|
} |
| 592 |
|
|
| 593 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader, Bool_t usetable){ |
| 594 |
|
const TString host = glt->CGetHost(); |
| 595 |
|
const TString user = glt->CGetUser(); |
| 596 |
|
const TString psw = glt->CGetPsw(); |
| 597 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 598 |
|
if ( !dbc->IsConnected() ) throw -116; |
| 599 |
|
stringstream myquery; |
| 600 |
|
myquery.str(""); |
| 601 |
|
myquery << "SET time_zone='+0:00'"; |
| 602 |
|
dbc->Query(myquery.str().c_str()); |
| 603 |
// |
// |
| 604 |
if ( ctground ) return(0); |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,usetable); |
| 605 |
|
dbc->Close(); |
| 606 |
|
delete dbc; |
| 607 |
|
dbc = 0; |
| 608 |
// |
// |
| 609 |
|
return(sig); |
| 610 |
|
// |
| 611 |
|
}; |
| 612 |
|
|
| 613 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader){ |
| 614 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
| 615 |
const TString user = glt->CGetUser(); |
const TString user = glt->CGetUser(); |
| 616 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
| 621 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
| 622 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
| 623 |
// |
// |
| 624 |
stringstream bmfile; |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
| 625 |
|
dbc->Close(); |
| 626 |
|
delete dbc; |
| 627 |
|
dbc = 0; |
| 628 |
|
// |
| 629 |
|
return(sig); |
| 630 |
|
// |
| 631 |
|
} |
| 632 |
|
|
| 633 |
|
Int_t CaloLevel0::CalcCrossTalkCorrDo(TSQLServer *dbc, UInt_t runheader, Bool_t usetable){ |
| 634 |
|
// |
| 635 |
|
if ( ctground ) return(0); |
| 636 |
|
// |
| 637 |
Int_t error = 0; |
Int_t error = 0; |
| 638 |
ifstream badfile; |
GL_PARAM *glparam = new GL_PARAM(); |
|
GL_PARAM *glparam = new GL_PARAM(); |
|
| 639 |
// |
// |
| 640 |
// determine where I can find file with offline bad pulser mask |
// determine where I can find file with offline bad pulser mask |
| 641 |
// |
// |
| 642 |
|
stringstream bmfile; |
| 643 |
error = 0; |
error = 0; |
| 644 |
error = glparam->Query_GL_PARAM(runheader,105,dbc); |
error = glparam->Query_GL_PARAM(runheader,105,dbc); |
| 645 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
| 648 |
bmfile << glparam->PATH.Data() << "/"; |
bmfile << glparam->PATH.Data() << "/"; |
| 649 |
bmfile << glparam->NAME.Data(); |
bmfile << glparam->NAME.Data(); |
| 650 |
// |
// |
| 651 |
|
ifstream badfile; |
| 652 |
if ( verbose ) printf("\n Using bad pulser offline mask file: \n %s \n\n",bmfile.str().c_str()); |
if ( verbose ) printf("\n Using bad pulser offline mask file: \n %s \n\n",bmfile.str().c_str()); |
| 653 |
badfile.open(bmfile.str().c_str()); |
badfile.open(bmfile.str().c_str()); |
| 654 |
if ( !badfile ){ |
if ( !badfile ){ |
| 677 |
}; |
}; |
| 678 |
}; |
}; |
| 679 |
// |
// |
|
delete glparam; |
|
| 680 |
badfile.close(); |
badfile.close(); |
| 681 |
// |
if ( !usetable ){ |
|
// Let's start with cross-talk correction calculation |
|
|
// |
|
|
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
|
|
Float_t adcp[2][22][96]; |
|
|
Float_t adcpcal[2][22][96]; |
|
|
memset(adcp , 0, 2*22*96*sizeof(Float_t)); |
|
|
memset(adcpcal , 0, 2*22*96*sizeof(Float_t)); |
|
|
// |
|
|
UInt_t pampli = 0; |
|
|
for (Int_t s=0; s<4; s++){ |
|
|
// |
|
|
// Save into matrix adcp the values of the highest pulse calibration (pulse amplitude = 2) |
|
|
// |
|
|
pampli = 2; |
|
|
error = 0; |
|
|
error = glp->Query_GL_CALOPULSE_CALIB(runheader,s,pampli,dbc); |
|
|
if ( error < 0 ){ |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
UInt_t idcalib = glp->ID_ROOT_L0; |
|
|
UInt_t fromtime = glp->FROM_TIME; |
|
|
UInt_t calibno = glp->EV_ROOT; |
|
|
// |
|
|
// determine path and name and entry of the calibration file |
|
| 682 |
// |
// |
| 683 |
GL_ROOT *glroot = new GL_ROOT(); |
// Let's start with cross-talk correction calculation |
|
if ( verbose ) printf("\n"); |
|
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
|
|
// |
|
|
error = 0; |
|
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
|
|
if ( error < 0 ){ |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
stringstream name; |
|
|
name.str(""); |
|
|
name << glroot->PATH.Data() << "/"; |
|
|
name << glroot->NAME.Data(); |
|
|
// |
|
|
TString fcalname = (TString)name.str().c_str(); |
|
|
ifstream myfile; |
|
|
myfile.open(fcalname.Data()); |
|
|
if ( !myfile ){ |
|
|
return(-107); |
|
|
}; |
|
|
myfile.close(); |
|
|
// |
|
|
TFile *File = new TFile(fcalname.Data()); |
|
|
if ( !File ) return(-108); |
|
|
TTree *tr = (TTree*)File->Get("CalibCalPulse2"); |
|
|
if ( !tr ) return(-119); |
|
|
// |
|
|
TBranch *calo = tr->GetBranch("CalibCalPulse2"); |
|
| 684 |
// |
// |
| 685 |
pamela::CalibCalPulse2Event *ce = 0; |
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
| 686 |
tr->SetBranchAddress("CalibCalPulse2", &ce); |
Float_t adcp[2][22][96]; |
| 687 |
|
Float_t adcpcal[2][22][96]; |
| 688 |
|
memset(adcp , 0, 2*22*96*sizeof(Float_t)); |
| 689 |
|
memset(adcpcal , 0, 2*22*96*sizeof(Float_t)); |
| 690 |
// |
// |
| 691 |
Long64_t ncalibs = calo->GetEntries(); |
UInt_t pampli = 0; |
| 692 |
|
for (Int_t s=0; s<4; s++){ |
| 693 |
|
// |
| 694 |
|
// Save into matrix adcp the values of the highest pulse calibration (pulse amplitude = 2) |
| 695 |
|
// |
| 696 |
|
pampli = 2; |
| 697 |
|
error = 0; |
| 698 |
|
error = glp->Query_GL_CALOPULSE_CALIB(runheader,s,pampli,dbc); |
| 699 |
|
if ( error < 0 ){ |
| 700 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 701 |
|
return(error); |
| 702 |
|
}; |
| 703 |
|
// |
| 704 |
|
UInt_t idcalib = glp->ID_ROOT_L0; |
| 705 |
|
UInt_t fromtime = glp->FROM_TIME; |
| 706 |
|
UInt_t calibno = glp->EV_ROOT; |
| 707 |
|
// |
| 708 |
|
// determine path and name and entry of the calibration file |
| 709 |
|
// |
| 710 |
|
GL_ROOT *glroot = new GL_ROOT(); |
| 711 |
|
if ( verbose ) printf("\n"); |
| 712 |
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
| 713 |
|
// |
| 714 |
|
error = 0; |
| 715 |
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
| 716 |
|
if ( error < 0 ){ |
| 717 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 718 |
|
return(error); |
| 719 |
|
}; |
| 720 |
|
// |
| 721 |
|
stringstream name; |
| 722 |
|
name.str(""); |
| 723 |
|
name << glroot->PATH.Data() << "/"; |
| 724 |
|
name << glroot->NAME.Data(); |
| 725 |
|
// |
| 726 |
|
TString fcalname = (TString)name.str().c_str(); |
| 727 |
|
ifstream myfile; |
| 728 |
|
myfile.open(fcalname.Data()); |
| 729 |
|
if ( !myfile ){ |
| 730 |
|
return(-107); |
| 731 |
|
}; |
| 732 |
|
myfile.close(); |
| 733 |
|
// |
| 734 |
|
TFile *File = new TFile(fcalname.Data()); |
| 735 |
|
if ( !File ) return(-108); |
| 736 |
|
TTree *tr = (TTree*)File->Get("CalibCalPulse2"); |
| 737 |
|
if ( !tr ) return(-119); |
| 738 |
|
// |
| 739 |
|
TBranch *calo = tr->GetBranch("CalibCalPulse2"); |
| 740 |
|
// |
| 741 |
|
pamela::CalibCalPulse2Event *ce = 0; |
| 742 |
|
tr->SetBranchAddress("CalibCalPulse2", &ce); |
| 743 |
|
// |
| 744 |
|
Long64_t ncalibs = calo->GetEntries(); |
| 745 |
|
// |
| 746 |
|
if ( !ncalibs ) return(-110); |
| 747 |
|
// |
| 748 |
|
if ( calo->GetEntry(calibno) <= 0) throw -36; |
| 749 |
|
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
| 750 |
|
// |
| 751 |
|
// retrieve calibration table |
| 752 |
|
// |
| 753 |
|
if ( ce->pstwerr[s] && ce->pperror[s] == 0 && ce->unpackError == 0 ){ |
| 754 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
| 755 |
|
for ( Int_t j=0; j<96 ;j++){ |
| 756 |
|
if ( s == 2 ){ |
| 757 |
|
adcp[0][2*d+1][j] = ce->calpuls[3][d][j]; |
| 758 |
|
}; |
| 759 |
|
if ( s == 3 ){ |
| 760 |
|
adcp[0][2*d][j] = ce->calpuls[1][d][j]; |
| 761 |
|
}; |
| 762 |
|
if ( s == 0 ){ |
| 763 |
|
adcp[1][2*d][j] = ce->calpuls[0][d][j]; |
| 764 |
|
}; |
| 765 |
|
if ( s == 1 ){ |
| 766 |
|
adcp[1][2*d+1][j] = ce->calpuls[2][d][j]; |
| 767 |
|
}; |
| 768 |
|
}; |
| 769 |
|
}; |
| 770 |
|
} else { |
| 771 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
| 772 |
|
return(-111); |
| 773 |
|
}; |
| 774 |
|
// |
| 775 |
|
File->Close(); |
| 776 |
|
delete glroot; |
| 777 |
|
// |
| 778 |
|
// Save into matrix adcpcal the calibrated values of the pulse calibration (subtraction of pulse amplitude = 0 relative to the pulse2 calibration used) |
| 779 |
|
// |
| 780 |
|
pampli = 0; |
| 781 |
|
error = 0; |
| 782 |
|
error = glp->Query_GL_CALOPULSE_CALIB(fromtime,s,pampli,dbc); |
| 783 |
|
if ( error < 0 ){ |
| 784 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 785 |
|
return(error); |
| 786 |
|
}; |
| 787 |
|
// |
| 788 |
|
idcalib = glp->ID_ROOT_L0; |
| 789 |
|
calibno = glp->EV_ROOT; |
| 790 |
|
// |
| 791 |
|
// determine path and name and entry of the calibration file |
| 792 |
|
// |
| 793 |
|
glroot = new GL_ROOT(); |
| 794 |
|
if ( verbose ) printf("\n"); |
| 795 |
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
| 796 |
|
// |
| 797 |
|
error = 0; |
| 798 |
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
| 799 |
|
if ( error < 0 ){ |
| 800 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 801 |
|
return(error); |
| 802 |
|
}; |
| 803 |
|
// |
| 804 |
|
name.str(""); |
| 805 |
|
name << glroot->PATH.Data() << "/"; |
| 806 |
|
name << glroot->NAME.Data(); |
| 807 |
|
// |
| 808 |
|
fcalname = (TString)name.str().c_str(); |
| 809 |
|
myfile.open(fcalname.Data()); |
| 810 |
|
if ( !myfile ){ |
| 811 |
|
return(-107); |
| 812 |
|
}; |
| 813 |
|
myfile.close(); |
| 814 |
|
// |
| 815 |
|
TFile *File1 = new TFile(fcalname.Data()); |
| 816 |
|
if ( !File1 ) return(-108); |
| 817 |
|
TTree *tr1 = (TTree*)File1->Get("CalibCalPulse1"); |
| 818 |
|
if ( !tr1 ) return(-120); |
| 819 |
|
// |
| 820 |
|
TBranch *calo1 = tr1->GetBranch("CalibCalPulse1"); |
| 821 |
|
// |
| 822 |
|
pamela::CalibCalPulse1Event *ce1 = 0; |
| 823 |
|
tr1->SetBranchAddress("CalibCalPulse1", &ce1); |
| 824 |
|
// |
| 825 |
|
ncalibs = calo1->GetEntries(); |
| 826 |
|
// |
| 827 |
|
if ( !ncalibs ) return(-110); |
| 828 |
|
// |
| 829 |
|
if ( calo1->GetEntry(calibno) <= 0 ) throw -36; |
| 830 |
|
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
| 831 |
|
// |
| 832 |
|
// retrieve calibration table |
| 833 |
|
// |
| 834 |
|
if ( ce1->pstwerr[s] && ce1->pperror[s] == 0 && ce1->unpackError == 0 ){ |
| 835 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
| 836 |
|
for ( Int_t j=0; j<96 ;j++){ |
| 837 |
|
if ( s == 2 ){ |
| 838 |
|
adcpcal[0][2*d+1][j] = adcp[0][2*d+1][j] - ce1->calpuls[3][d][j]; |
| 839 |
|
}; |
| 840 |
|
if ( s == 3 ){ |
| 841 |
|
adcpcal[0][2*d][j] = adcp[0][2*d][j] - ce1->calpuls[1][d][j]; |
| 842 |
|
}; |
| 843 |
|
if ( s == 0 ){ |
| 844 |
|
adcpcal[1][2*d][j] = adcp[1][2*d][j] - ce1->calpuls[0][d][j]; |
| 845 |
|
}; |
| 846 |
|
if ( s == 1 ){ |
| 847 |
|
adcpcal[1][2*d+1][j] = adcp[1][2*d+1][j] - ce1->calpuls[2][d][j]; |
| 848 |
|
}; |
| 849 |
|
}; |
| 850 |
|
}; |
| 851 |
|
} else { |
| 852 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
| 853 |
|
return(-111); |
| 854 |
|
}; |
| 855 |
|
// |
| 856 |
|
File1->Close(); |
| 857 |
|
// |
| 858 |
|
delete glroot; |
| 859 |
|
// |
| 860 |
|
};// loop on the four sections |
| 861 |
// |
// |
|
if ( !ncalibs ) return(-110); |
|
| 862 |
// |
// |
| 863 |
calo->GetEntry(calibno); |
delete glp; |
|
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
|
| 864 |
// |
// |
| 865 |
// retrieve calibration table |
// Ok, now we can try to calculate the cross-talk correction for each pre-amplifier |
| 866 |
// |
// |
| 867 |
if ( ce->pstwerr[s] && ce->pperror[s] == 0 && ce->unpackError == 0 ){ |
for ( Int_t v=0; v<2; v++){ |
| 868 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
if ( debug ) printf(" \n\n NEW VIEW \n"); |
| 869 |
for ( Int_t j=0; j<96 ;j++){ |
for ( Int_t p=0; p<22; p++){ |
| 870 |
if ( s == 2 ){ |
for ( Int_t npre=0; npre<6; npre++){ |
| 871 |
adcp[0][2*d+1][j] = ce->calpuls[3][d][j]; |
ctprecor[v][p][npre] = 1000.; |
| 872 |
}; |
ctneigcor[v][p][npre] = 1000.; |
| 873 |
if ( s == 3 ){ |
Int_t str0=npre*16; |
| 874 |
adcp[0][2*d][j] = ce->calpuls[1][d][j]; |
Int_t str16= -1 + (1+npre)*16; |
| 875 |
}; |
// |
| 876 |
if ( s == 0 ){ |
UInt_t neigc = 0; |
| 877 |
adcp[1][2*d][j] = ce->calpuls[0][d][j]; |
UInt_t farc = 0; |
| 878 |
|
UInt_t pulsc = 0; |
| 879 |
|
Float_t sigpulsed = 0.; |
| 880 |
|
Float_t neigbase = 0.; |
| 881 |
|
Float_t farbase = 0.; |
| 882 |
|
// |
| 883 |
|
// Loop over the strip of the pre and sum all signal far away from pulsed strip, signal in the neighbour(s) strip(s) and save the pulsed signal |
| 884 |
|
// moreover count the number of strips in each case |
| 885 |
|
// |
| 886 |
|
for (Int_t s=str0; s<=str16; s++){ |
| 887 |
|
if ( adcpcal[v][p][s] > 10000.){ |
| 888 |
|
sigpulsed = adcpcal[v][p][s]; |
| 889 |
|
pulsc++; |
| 890 |
|
if ( s > str0 ){ |
| 891 |
|
neigbase += adcpcal[v][p][s-1]; |
| 892 |
|
neigc++; |
| 893 |
|
farbase -= adcpcal[v][p][s-1]; |
| 894 |
|
farc--; |
| 895 |
|
}; |
| 896 |
|
if ( s < str16 ){ |
| 897 |
|
neigbase += adcpcal[v][p][s+1]; |
| 898 |
|
neigc++; |
| 899 |
|
farbase -= adcpcal[v][p][s+1]; |
| 900 |
|
farc--; |
| 901 |
|
}; |
| 902 |
|
} else { |
| 903 |
|
farc++; |
| 904 |
|
farbase += adcpcal[v][p][s]; |
| 905 |
|
}; |
| 906 |
}; |
}; |
| 907 |
if ( s == 1 ){ |
// |
| 908 |
adcp[1][2*d+1][j] = ce->calpuls[2][d][j]; |
// Now calculate the corrections |
| 909 |
|
// |
| 910 |
|
Float_t avefarbase = 0.; |
| 911 |
|
if ( farc ) avefarbase = farbase/(Float_t)farc; |
| 912 |
|
Float_t aveneigbase = 0.; |
| 913 |
|
if ( neigc ) aveneigbase = neigbase/(Float_t)neigc; |
| 914 |
|
// |
| 915 |
|
if ( pulsc == 1 && farc && neigc ){ |
| 916 |
|
ctprecor[v][p][npre] = -avefarbase/(sigpulsed+fabs(avefarbase)); |
| 917 |
|
ctneigcor[v][p][npre] = fabs(aveneigbase-avefarbase)/(sigpulsed+fabs(avefarbase)); |
| 918 |
|
if ( debug ) printf(" Cross-talk correction View %i Plane %i Pre %i : pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
| 919 |
|
} else { |
| 920 |
|
// |
| 921 |
|
// did not find the pulsed strip or more than one pulsed strip found! |
| 922 |
|
// |
| 923 |
|
if ( debug ) printf(" Problems finding the cross-talk corrections: \n View %i Plane %i Pre %i number of pulsed strip %i \n Average faraway baseline %f number of strips %i Average neighbour baseline %f number of neighbour strips %i \n",v,p,npre,pulsc,avefarbase,farc,aveneigbase,neigc); |
| 924 |
|
// |
| 925 |
}; |
}; |
| 926 |
}; |
}; |
| 927 |
|
if ( debug ) printf(" \n ==================== \n"); |
| 928 |
}; |
}; |
|
} else { |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
|
|
return(-111); |
|
| 929 |
}; |
}; |
| 930 |
|
} else { |
| 931 |
// |
// |
| 932 |
File->Close(); |
// use pre-amply table |
| 933 |
delete glroot; |
// |
| 934 |
// |
// |
| 935 |
// Save into matrix adcpcal the calibrated values of the pulse calibration (subtraction of pulse amplitude = 0 relative to the pulse2 calibration used) |
// determine where I can find file with offline neighbour correction table |
| 936 |
// |
// |
| 937 |
pampli = 0; |
stringstream bmfile2; |
| 938 |
error = 0; |
error = 0; |
| 939 |
error = glp->Query_GL_CALOPULSE_CALIB(fromtime,s,pampli,dbc); |
error = glparam->Query_GL_PARAM(runheader,106,dbc); |
| 940 |
if ( error < 0 ){ |
if ( error < 0 ) return(error); |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
idcalib = glp->ID_ROOT_L0; |
|
|
calibno = glp->EV_ROOT; |
|
| 941 |
// |
// |
| 942 |
// determine path and name and entry of the calibration file |
bmfile2.str(""); |
| 943 |
|
bmfile2 << glparam->PATH.Data() << "/"; |
| 944 |
|
bmfile2 << glparam->NAME.Data(); |
| 945 |
|
// |
| 946 |
|
ifstream badfile2; |
| 947 |
|
if ( verbose ) printf("\n Using pre-amply neighbour crosstalk table file: \n %s \n\n",bmfile2.str().c_str()); |
| 948 |
|
badfile2.open(bmfile2.str().c_str()); |
| 949 |
|
if ( !badfile2 ){ |
| 950 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no pre-amply neighbour crosstalk table file!\n"); |
| 951 |
|
return(-121); |
| 952 |
|
}; |
| 953 |
|
// |
| 954 |
|
Int_t vview = 0; |
| 955 |
|
Int_t vplane = 0; |
| 956 |
|
Int_t vpre = 0; |
| 957 |
|
Float_t vcorr = 0.; |
| 958 |
|
while ( badfile2 >> vview && badfile2 >> vplane && badfile2 >> vpre && badfile2 >> vcorr){ |
| 959 |
|
if ( debug ) printf(" Pre-amply neighbour correction: view %i plane %i pre %i correction %f \n",vview,vplane,vpre,vcorr); |
| 960 |
|
ctneigcor[vview][vplane][vpre] = vcorr; |
| 961 |
|
}; |
| 962 |
// |
// |
| 963 |
glroot = new GL_ROOT(); |
// determine where I can find file with offline SECOND neighbour correction table |
|
if ( verbose ) printf("\n"); |
|
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
|
| 964 |
// |
// |
| 965 |
|
stringstream bmfile3; |
| 966 |
error = 0; |
error = 0; |
| 967 |
error = glroot->Query_GL_ROOT(idcalib,dbc); |
error = glparam->Query_GL_PARAM(runheader,107,dbc); |
| 968 |
if ( error < 0 ){ |
if ( error < 0 ) return(error); |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
name.str(""); |
|
|
name << glroot->PATH.Data() << "/"; |
|
|
name << glroot->NAME.Data(); |
|
| 969 |
// |
// |
| 970 |
fcalname = (TString)name.str().c_str(); |
bmfile3.str(""); |
| 971 |
myfile.open(fcalname.Data()); |
bmfile3 << glparam->PATH.Data() << "/"; |
| 972 |
if ( !myfile ){ |
bmfile3 << glparam->NAME.Data(); |
| 973 |
return(-107); |
// |
| 974 |
|
ifstream badfile3; |
| 975 |
|
if ( verbose ) printf("\n Using pre-amply second neighbour crosstalk table file: \n %s \n\n",bmfile3.str().c_str()); |
| 976 |
|
badfile3.open(bmfile3.str().c_str()); |
| 977 |
|
if ( !badfile3 ){ |
| 978 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no pre-amply second neighbour crosstalk table file!\n"); |
| 979 |
|
return(-122); |
| 980 |
}; |
}; |
| 981 |
myfile.close(); |
// |
| 982 |
// |
Int_t pview = 0; |
| 983 |
TFile *File1 = new TFile(fcalname.Data()); |
Int_t pplane = 0; |
| 984 |
if ( !File1 ) return(-108); |
Int_t ppre = 0; |
| 985 |
TTree *tr1 = (TTree*)File1->Get("CalibCalPulse1"); |
Float_t pcorr = 0.; |
| 986 |
if ( !tr1 ) return(-120); |
while ( badfile3 >> pview && badfile3 >> pplane && badfile3 >> ppre && badfile3 >> pcorr){ |
| 987 |
// |
if ( debug ) printf(" Pre-amply second neighbour correction: view %i plane %i pre %i correction %f \n",pview,pplane,ppre,-pcorr); |
| 988 |
TBranch *calo1 = tr1->GetBranch("CalibCalPulse1"); |
ctprecor[pview][pplane][ppre] = -pcorr; // data are saved as negatives in the file |
| 989 |
// |
}; |
|
pamela::CalibCalPulse1Event *ce1 = 0; |
|
|
tr1->SetBranchAddress("CalibCalPulse1", &ce1); |
|
|
// |
|
|
ncalibs = calo1->GetEntries(); |
|
|
// |
|
|
if ( !ncalibs ) return(-110); |
|
| 990 |
// |
// |
| 991 |
calo1->GetEntry(calibno); |
// determine where to find the file containing the Silicon crosstalk correction table |
|
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
|
| 992 |
// |
// |
| 993 |
// retrieve calibration table |
stringstream bmfile4; |
| 994 |
|
error = 0; |
| 995 |
|
error = glparam->Query_GL_PARAM(runheader,108,dbc); |
| 996 |
|
if ( error < 0 ) return(error); |
| 997 |
// |
// |
| 998 |
if ( ce1->pstwerr[s] && ce1->pperror[s] == 0 && ce1->unpackError == 0 ){ |
bmfile4.str(""); |
| 999 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
bmfile4 << glparam->PATH.Data() << "/"; |
| 1000 |
for ( Int_t j=0; j<96 ;j++){ |
bmfile4 << glparam->NAME.Data(); |
| 1001 |
if ( s == 2 ){ |
// |
| 1002 |
adcpcal[0][2*d+1][j] = adcp[0][2*d+1][j] - ce1->calpuls[3][d][j]; |
ifstream badfile4; |
| 1003 |
}; |
if ( verbose ) printf("\n Using Silicon crosstalk table file: \n %s \n\n",bmfile4.str().c_str()); |
| 1004 |
if ( s == 3 ){ |
badfile4.open(bmfile4.str().c_str()); |
| 1005 |
adcpcal[0][2*d][j] = adcp[0][2*d][j] - ce1->calpuls[1][d][j]; |
if ( !badfile4 ){ |
| 1006 |
}; |
if ( verbose ) printf(" CALORIMETER - ERROR: no Silicon crosstalk table file!\n"); |
| 1007 |
if ( s == 0 ){ |
return(-125); |
|
adcpcal[1][2*d][j] = adcp[1][2*d][j] - ce1->calpuls[0][d][j]; |
|
|
}; |
|
|
if ( s == 1 ){ |
|
|
adcpcal[1][2*d+1][j] = adcp[1][2*d+1][j] - ce1->calpuls[2][d][j]; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
} else { |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
|
|
return(-111); |
|
| 1008 |
}; |
}; |
| 1009 |
|
// |
| 1010 |
|
Int_t spview = 0; |
| 1011 |
|
Int_t spplane = 0; |
| 1012 |
|
Int_t psil = 0; |
| 1013 |
|
Float_t spcorr = 0.; |
| 1014 |
|
memset(ctsicor, 0, 2*22*9*sizeof(Float_t)); |
| 1015 |
|
while ( badfile4 >> spview && badfile4 >> spplane && badfile4 >> psil && badfile4 >> spcorr){ |
| 1016 |
|
if ( debug ) printf(" Silicon correction: view %i plane %i silicon %i correction %f \n",spview,spplane,psil,-spcorr); |
| 1017 |
|
ctsicor[spview][spplane][psil] = -spcorr; // data are saved as negatives in the file |
| 1018 |
|
}; |
| 1019 |
// |
// |
|
File1->Close(); |
|
|
// |
|
|
delete glroot; |
|
|
// |
|
|
};// loop on the four sections |
|
|
// |
|
|
// |
|
|
delete glp; |
|
|
dbc->Close(); |
|
|
delete dbc; |
|
|
// |
|
|
// Ok, now we can try to calculate the cross-talk correction for each pre-amplifier |
|
|
// |
|
|
for ( Int_t v=0; v<2; v++){ |
|
|
if ( debug ) printf(" \n\n NEW VIEW \n"); |
|
|
for ( Int_t p=0; p<22; p++){ |
|
|
for ( Int_t npre=0; npre<6; npre++){ |
|
|
ctprecor[v][p][npre] = 1000.; |
|
|
ctneigcor[v][p][npre] = 1000.; |
|
|
Int_t str0=npre*16; |
|
|
Int_t str16= -1 + (1+npre)*16; |
|
|
// |
|
|
UInt_t neigc = 0; |
|
|
UInt_t farc = 0; |
|
|
UInt_t pulsc = 0; |
|
|
Float_t sigpulsed = 0.; |
|
|
Float_t neigbase = 0.; |
|
|
Float_t farbase = 0.; |
|
|
// |
|
|
// Loop over the strip of the pre and sum all signal far away from pulsed strip, signal in the neighbour(s) strip(s) and save the pulsed signal |
|
|
// moreover count the number of strips in each case |
|
|
// |
|
|
for (Int_t s=str0; s<=str16; s++){ |
|
|
if ( adcpcal[v][p][s] > 10000.){ |
|
|
sigpulsed = adcpcal[v][p][s]; |
|
|
pulsc++; |
|
|
if ( s > str0 ){ |
|
|
neigbase += adcpcal[v][p][s-1]; |
|
|
neigc++; |
|
|
farbase -= adcpcal[v][p][s-1]; |
|
|
farc--; |
|
|
}; |
|
|
if ( s < str16 ){ |
|
|
neigbase += adcpcal[v][p][s+1]; |
|
|
neigc++; |
|
|
farbase -= adcpcal[v][p][s+1]; |
|
|
farc--; |
|
|
}; |
|
|
} else { |
|
|
farc++; |
|
|
farbase += adcpcal[v][p][s]; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
// Now calculate the corrections |
|
|
// |
|
|
Float_t avefarbase = 0.; |
|
|
if ( farc ) avefarbase = farbase/(Float_t)farc; |
|
|
Float_t aveneigbase = 0.; |
|
|
if ( neigc ) aveneigbase = neigbase/(Float_t)neigc; |
|
|
// |
|
|
if ( pulsc == 1 && farc && neigc ){ |
|
|
ctprecor[v][p][npre] = -avefarbase/(sigpulsed+fabs(avefarbase)); |
|
|
ctneigcor[v][p][npre] = fabs(aveneigbase-avefarbase)/(sigpulsed+fabs(avefarbase)); |
|
|
if ( debug ) printf(" Cross-talk correction View %i Plane %i Pre %i : pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
|
|
} else { |
|
|
// |
|
|
// did not find the pulsed strip or more than one pulsed strip found! |
|
|
// |
|
|
if ( debug ) printf(" Problems finding the cross-talk corrections: \n View %i Plane %i Pre %i number of pulsed strip %i \n Average faraway baseline %f number of strips %i Average neighbour baseline %f number of neighbour strips %i \n",v,p,npre,pulsc,avefarbase,farc,aveneigbase,neigc); |
|
|
// |
|
|
}; |
|
|
}; |
|
|
if ( debug ) printf(" \n ==================== \n"); |
|
|
}; |
|
| 1020 |
}; |
}; |
| 1021 |
// |
// |
| 1022 |
|
delete glparam; |
| 1023 |
|
// |
| 1024 |
// Check the calculated corrections |
// Check the calculated corrections |
| 1025 |
// |
// |
| 1026 |
Int_t opre=0; |
Int_t opre=0; |
| 1061 |
}; |
}; |
| 1062 |
}; |
}; |
| 1063 |
}; |
}; |
| 1064 |
}; |
}; |
| 1065 |
// |
// |
| 1066 |
return(0); |
return(0); |
| 1067 |
} |
} |
| 1068 |
|
|
| 1069 |
|
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre){ |
| 1070 |
|
Int_t n = 0; |
| 1071 |
|
Float_t q = 0; |
| 1072 |
|
this->FindBaseCompress(l,m,pre,n,q); |
| 1073 |
|
} |
| 1074 |
|
|
| 1075 |
|
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ |
| 1076 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 1077 |
|
dexy[l][m][e] = dexyc[l][m][e]; |
| 1078 |
|
}; |
| 1079 |
|
this->FindBaseRaw(l,m,pre,nst,qp); |
| 1080 |
|
} |
| 1081 |
|
|
| 1082 |
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ |
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ |
| 1083 |
Float_t minstrip = 100000.; |
Int_t n = 0; |
| 1084 |
Float_t rms = 0.; |
Float_t q = 0; |
| 1085 |
|
this->FindBaseRaw(l,m,pre,n,q); |
| 1086 |
|
} |
| 1087 |
|
|
| 1088 |
|
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ |
| 1089 |
|
// |
| 1090 |
|
Float_t minstrip = 100000.; |
| 1091 |
|
Float_t rms = 0.; |
| 1092 |
|
Int_t process = 0; |
| 1093 |
|
Int_t onlmask[16]; |
| 1094 |
|
memset(onlmask, 0, 16*sizeof(Int_t)); |
| 1095 |
|
// |
| 1096 |
|
while ( process < 2 ){ |
| 1097 |
|
// |
| 1098 |
|
minstrip = 100000.; |
| 1099 |
|
rms = 0.; |
| 1100 |
base[l][m][pre] = 0.; |
base[l][m][pre] = 0.; |
| 1101 |
|
qp = 0.; |
| 1102 |
|
// |
| 1103 |
|
Int_t spos = -1; |
| 1104 |
|
Int_t ee = 0; |
| 1105 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 1106 |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0.) { |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0. && onlmask[ee] == 0 ) { |
| 1107 |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
| 1108 |
rms = calthr[l][m][pre]; |
rms = calthr[l][m][pre]; |
| 1109 |
}; |
spos = ee; |
| 1110 |
|
}; |
| 1111 |
|
ee++; |
| 1112 |
|
qp += (dexy[l][m][e]-calped[l][m][e]-sbase[l][m][e]); |
| 1113 |
|
}; |
| 1114 |
|
// |
| 1115 |
|
if ( debug && l==0 ){ |
| 1116 |
|
printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n => qp = %f \n",l,m,pre,minstrip,rms,qp); |
| 1117 |
}; |
}; |
| 1118 |
if ( minstrip != 100000. ) { |
if ( minstrip != 100000. ) { |
| 1119 |
Float_t strip6s = 0.; |
Float_t strip6s = 0.; |
| 1120 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 1121 |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
| 1122 |
strip6s += 1.; |
strip6s += 1.; |
| 1123 |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
|
}; |
|
|
// |
|
|
// compression |
|
|
// |
|
|
if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
|
|
dexyc[l][m][e] = 0.; |
|
|
} else { |
|
|
dexyc[l][m][e] = dexy[l][m][e]; |
|
|
}; |
|
| 1124 |
}; |
}; |
| 1125 |
if ( strip6s >= 9. ){ |
// |
| 1126 |
Double_t arro = base[l][m][pre]/strip6s; |
// compression |
| 1127 |
Float_t deci = 1000.*((float)arro - float(int(arro))); |
// |
| 1128 |
if ( deci < 500. ) { |
// if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
| 1129 |
arro = double(int(arro)); |
// dexyc[l][m][e] = 0.; |
| 1130 |
} else { |
// } else { |
| 1131 |
arro = 1. + double(int(arro)); |
dexyc[l][m][e] = dexy[l][m][e]; |
| 1132 |
}; |
// }; |
| 1133 |
base[l][m][pre] = arro; |
}; |
| 1134 |
|
// |
| 1135 |
|
if ( strip6s == 1. && process < 1 ){ |
| 1136 |
|
onlmask[spos] = 1; |
| 1137 |
|
process++; |
| 1138 |
|
if ( debug ) printf(" Warning, only one strip to calculate baseline: minstrip %f rms %f spos %i l %i m %i pre %i \n",minstrip,rms,spos,l,m,pre); |
| 1139 |
|
continue; |
| 1140 |
|
}; |
| 1141 |
|
process += 2; |
| 1142 |
|
nst = (Int_t)strip6s; |
| 1143 |
|
// |
| 1144 |
|
if ( debug ){ |
| 1145 |
|
printf(" strip6s %f \n",strip6s); |
| 1146 |
|
}; |
| 1147 |
|
// if ( strip6s >= 9. ){ |
| 1148 |
|
if ( (strip6s >= 2. && process == 2) || (strip6s >= 9. && process > 2) ){ |
| 1149 |
|
//if ( (strip6s >= 4. && process == 2) || (strip6s >= 9. && process > 2) ){ |
| 1150 |
|
Double_t arro = base[l][m][pre]/strip6s; |
| 1151 |
|
Float_t deci = 1000.*((float)arro - float(int(arro))); |
| 1152 |
|
if ( deci < 500. ) { |
| 1153 |
|
arro = double(int(arro)); |
| 1154 |
} else { |
} else { |
| 1155 |
base[l][m][pre] = 31000.; |
arro = 1. + double(int(arro)); |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
|
|
dexyc[l][m][e] = dexy[l][m][e]; |
|
|
}; |
|
| 1156 |
}; |
}; |
| 1157 |
} else { |
base[l][m][pre] = arro; |
| 1158 |
|
// |
| 1159 |
|
// if too few strips were used to determine the baseline check if it is comparable with the previous event, if not mark it as bad |
| 1160 |
|
// |
| 1161 |
|
if ( debug && process > 2 ) printf(" AGH low strip value was discarded process %i strip6s %f minstrip %f rms %f spos %i\n",process,strip6s,minstrip,rms,spos); |
| 1162 |
|
if ( debug ) printf(" Calculated baseline: base %f sbase-0.02*qp %f \n",base[l][m][pre],(-qp*0.02+sbase[l][m][pre])); |
| 1163 |
|
// |
| 1164 |
|
if ( strip6s < 4 && base[l][m][pre] > (-0.015*qp+sbase[l][m][pre]) && sbase[l][m][pre] > 0. ){ |
| 1165 |
|
if ( debug ) printf(" Suspicious calculated baseline: base %f sbase-0.02*qp %f strip6s %i \n",base[l][m][pre],(-qp*0.02+sbase[l][m][pre]),(Int_t)strip6s); |
| 1166 |
|
base[l][m][pre] = 31000.; |
| 1167 |
|
nst = 0; // 9RED BUG |
| 1168 |
|
qp = 0.; // 9RED BUG |
| 1169 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 1170 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
| 1171 |
|
}; |
| 1172 |
|
}; |
| 1173 |
|
} else { |
| 1174 |
|
if ( debug ) printf(" reset baseline here if ! ( (strip6s >=2 && process == 2) || (strip6s >= 9 and process > 2) ) \n"); |
| 1175 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
| 1176 |
|
nst = 0; // 9RED BUG |
| 1177 |
|
qp = 0.; // 9RED BUG |
| 1178 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 1179 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
| 1180 |
|
}; |
| 1181 |
|
}; |
| 1182 |
|
} else { |
| 1183 |
|
if ( debug ) printf(" reset baseline here if no minimum find\n"); |
| 1184 |
|
nst = 0; // 9RED BUG |
| 1185 |
|
qp = 0.; // 9RED BUG |
| 1186 |
|
process += 2; |
| 1187 |
|
base[l][m][pre] = 31000.; |
| 1188 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 1189 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
| 1190 |
|
}; |
| 1191 |
}; |
}; |
| 1192 |
|
}; |
| 1193 |
|
if ( debug ) printf(" Baseline calculation: baseline for view %i plane %i pre %i is %f nst %i qp %f \n",l,m,pre,base[l][m][pre],nst,qp); |
| 1194 |
} |
} |
| 1195 |
|
|
| 1196 |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
| 1197 |
// |
// |
| 1198 |
// get entry ei |
// get entry ei |
| 1199 |
// |
// |
| 1200 |
l0calo->GetEntry(ei); |
if ( l0calo->GetEntry(ei) <= 0 ) throw -36; |
| 1201 |
// |
// |
| 1202 |
// if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. |
// if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. |
| 1203 |
// |
// |
| 1204 |
|
clevel2->nsatstrip = 0.; |
| 1205 |
Int_t val = 0; |
Int_t val = 0; |
| 1206 |
Int_t del = 1100; |
Int_t del = 1000; |
| 1207 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
| 1208 |
for (Int_t dsec = 0; dsec < 7; dsec++){ |
for (Int_t dsec = 0; dsec < 7; dsec++){ |
| 1209 |
val = (Int_t)de->calselftrig[sec][dsec]; |
val = (Int_t)de->calselftrig[sec][dsec]; |
| 1212 |
}; |
}; |
| 1213 |
}; |
}; |
| 1214 |
val = 0; |
val = 0; |
| 1215 |
del = 1100; |
del = 1000; |
| 1216 |
if ( clevel2->trigty != 2. ){ |
if ( clevel2->trigty < 2. ){ |
| 1217 |
Bool_t ck = false; |
Bool_t ck = false; |
| 1218 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
| 1219 |
val = (Int_t)de->calselftrig[sec][6]; |
val = (Int_t)de->calselftrig[sec][6]; |
| 1220 |
del = delay(val); |
del = delay(val); |
| 1221 |
if ( del < 1100 ){ |
if ( del < 1000 ){ |
| 1222 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
| 1223 |
clevel2->trigty = 3.; |
clevel2->trigty = 3.; |
| 1224 |
ck = true; |
ck = true; |
| 1225 |
break; |
break; |
| 1226 |
}; |
}; |
| 1227 |
}; |
}; |
| 1228 |
if ( !ck ) clevel2->wartrig = 100.; |
// if ( !ck ) clevel2->wartrig = 100.; |
| 1229 |
} else { |
} else { |
| 1230 |
Bool_t ck = false; |
Bool_t ck = false; |
| 1231 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
| 1232 |
val = (Int_t)de->calselftrig[sec][6]; |
val = (Int_t)de->calselftrig[sec][6]; |
| 1233 |
del = delay(val); |
del = delay(val); |
| 1234 |
if ( del < 1100 ){ |
if ( del < 1000 ){ |
| 1235 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
| 1236 |
ck = true; |
ck = true; |
| 1237 |
}; |
}; |
| 1248 |
Float_t ener; |
Float_t ener; |
| 1249 |
Int_t doneb = 0; |
Int_t doneb = 0; |
| 1250 |
Int_t donec = 0; |
Int_t donec = 0; |
| 1251 |
Int_t ck = 0; |
Int_t ck[2][22][6]; |
| 1252 |
|
memset(ck, 0, 2*22*6*sizeof(Int_t)); |
| 1253 |
Int_t ipre = 0; |
Int_t ipre = 0; |
| 1254 |
Int_t ip[3] = {0}; |
// Int_t ip[3] = {0}; |
| 1255 |
|
Int_t ip[3] = {0,0,0}; |
| 1256 |
|
Int_t ipp = 0; |
| 1257 |
Float_t base0, base1, base2; |
Float_t base0, base1, base2; |
| 1258 |
base0 = 0.; |
base0 = 0.; |
| 1259 |
base1 = 0.; |
base1 = 0.; |
| 1260 |
base2 = 0.; |
base2 = 0.; |
| 1261 |
Float_t qpre[6] = {0.,0.,0.,0.,0.,0.}; |
Float_t qpre[2][22][6]; |
| 1262 |
|
memset(qpre, 0, 2*22*6*sizeof(Float_t)); |
| 1263 |
Float_t ene[96]; |
Float_t ene[96]; |
| 1264 |
Int_t chdone[4] = {0,0,0,0}; |
Int_t chdone[4] = {0,0,0,0}; |
| 1265 |
Int_t pe = 0; |
Int_t pe = 0; |
| 1266 |
// |
// |
| 1267 |
Float_t ener0 = 0.; |
Float_t ener0 = 0.; |
| 1268 |
Float_t cbase0 = 0.; |
Float_t cbase0 = 0.; |
| 1269 |
|
Float_t totbase = 0.; |
| 1270 |
|
Float_t totped = 0.; |
| 1271 |
Bool_t pproblem = false; |
Bool_t pproblem = false; |
| 1272 |
|
Bool_t negbase = false; |
| 1273 |
// |
// |
| 1274 |
Float_t tim = 0.; |
Float_t tim = 0.; |
| 1275 |
Int_t plo = 0; |
Int_t plo = 0; |
| 1283 |
// |
// |
| 1284 |
// determine the section number |
// determine the section number |
| 1285 |
// |
// |
| 1286 |
|
negbase = false; |
| 1287 |
se = 5; |
se = 5; |
| 1288 |
if (l == 0 && m%2 == 0) se = 3; |
if (l == 0 && m%2 == 0) se = 3; |
| 1289 |
if (l == 0 && m%2 != 0) se = 2; |
if (l == 0 && m%2 != 0) se = 2; |
| 1309 |
}; |
}; |
| 1310 |
clevel2->perr[se] = 0; |
clevel2->perr[se] = 0; |
| 1311 |
if ( de->perror[se] != 0 ){ |
if ( de->perror[se] != 0 ){ |
| 1312 |
clevel2->perr[se] = 1; |
clevel2->perr[se] = (Int_t)de->perror[se]; |
| 1313 |
pe++; |
pe++; |
| 1314 |
}; |
}; |
| 1315 |
clevel2->swerr[se] = 0; |
clevel2->swerr[se] = 0; |
| 1325 |
pre = -1; |
pre = -1; |
| 1326 |
// |
// |
| 1327 |
for (Int_t nn = 0; nn < 96; nn++){ |
for (Int_t nn = 0; nn < 96; nn++){ |
| 1328 |
ene[nn] = 0.; |
// ene[nn] = 0.; |
| 1329 |
dexy[l][m][nn] = de->dexy[l][m][nn] ; |
dexy[l][m][nn] = de->dexy[l][m][nn] ; |
| 1330 |
dexyc[l][m][nn] = de->dexyc[l][m][nn] ; |
dexyc[l][m][nn] = de->dexyc[l][m][nn] ; |
| 1331 |
}; |
}; |
| 1334 |
// |
// |
| 1335 |
pre = -1; |
pre = -1; |
| 1336 |
cbase0 = 0.; |
cbase0 = 0.; |
| 1337 |
|
Int_t nstt[2]; |
| 1338 |
|
Float_t rqp[2]; |
| 1339 |
for (Int_t i = 0; i < 3; i++){ |
for (Int_t i = 0; i < 3; i++){ |
| 1340 |
|
nstt[0] = 1000; |
| 1341 |
|
nstt[1] = 1000; |
| 1342 |
|
rqp[0] = 0.; |
| 1343 |
|
rqp[1] = 0.; |
| 1344 |
for (Int_t j = 0; j < 2; j++){ |
for (Int_t j = 0; j < 2; j++){ |
| 1345 |
pre = j + i*2; |
pre = j + i*2; |
| 1346 |
// |
// |
| 1347 |
// baseline check and calculation |
// baseline check and calculation |
| 1348 |
// |
// |
| 1349 |
if ( !isRAW ) { |
if ( !isRAW ){ |
| 1350 |
base[l][m][pre] = de->base[l][m][pre] ; |
// |
| 1351 |
|
// if it is a compress event with fully transmitted pre try to calculate the baseline |
| 1352 |
|
// |
| 1353 |
|
if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { |
| 1354 |
|
base[l][m][pre] = de->base[l][m][pre] ; |
| 1355 |
|
} else { |
| 1356 |
|
FindBaseCompress(l,m,pre,nstt[j],rqp[j]); |
| 1357 |
|
}; |
| 1358 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
| 1359 |
} else { |
} else { |
| 1360 |
// |
// |
| 1361 |
// if it is a raw event and we haven't checked |
// if it is a raw event calculate the baseline. |
|
// yet, calculate the baseline. |
|
| 1362 |
// |
// |
| 1363 |
FindBaseRaw(l,m,pre); |
FindBaseRaw(l,m,pre,nstt[j],rqp[j]); |
| 1364 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
| 1365 |
}; |
}; |
| 1366 |
}; |
}; |
| 1367 |
|
// |
| 1368 |
|
// if we are able to calculate the baseline with more than 3 strips on one pre and not in the other one choose the pre with more calculated strips |
| 1369 |
|
// |
| 1370 |
|
if ( nstt[0] < 4 && nstt[1] >= 4 && nstt[0] != 1000 && nstt[1] != 1000 ) base[l][m][pre-1] = 31000.; |
| 1371 |
|
if ( nstt[0] >= 4 && nstt[1] < 4 && nstt[0] != 1000 && nstt[1] != 1000 ) base[l][m][pre] = 31000.; |
| 1372 |
|
// // |
| 1373 |
|
// // if we are NOT able to calculate the baseline with more than 3 strips on both pres take the baseline (if any) of the one which has less energy |
| 1374 |
|
// // |
| 1375 |
|
// if ( nstt[0] < 4 && nstt[1] < 4 ){ |
| 1376 |
|
// if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; |
| 1377 |
|
// if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; |
| 1378 |
|
// }; |
| 1379 |
}; |
}; |
| 1380 |
// |
// |
| 1381 |
// run over strips |
// run over strips |
| 1382 |
// |
// |
| 1383 |
pre = -1; |
pre = -1; |
| 1384 |
ener0 = 0.; |
ener0 = 0.; |
| 1385 |
|
totbase = 0.; |
| 1386 |
|
totped = 0.; |
| 1387 |
for (Int_t i = 0 ; i < 3 ; i++){ |
for (Int_t i = 0 ; i < 3 ; i++){ |
| 1388 |
ip[i] = 0; |
ip[i] = 0; |
| 1389 |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
| 1390 |
if (n%16 == 0) { |
if (n%16 == 0) { |
|
ck = 0; |
|
| 1391 |
done = 0; |
done = 0; |
| 1392 |
doneb = 0; |
doneb = 0; |
| 1393 |
donec = 0; |
donec = 0; |
| 1394 |
pre++; |
pre++; |
| 1395 |
qpre[pre] = 0.; |
ck[l][m][pre] = 0; |
| 1396 |
|
qpre[l][m][pre] = 0.; |
| 1397 |
}; |
}; |
| 1398 |
// |
// |
| 1399 |
// baseline check and calculation |
// baseline check and calculation |
| 1401 |
// no suitable new baseline, use old ones! |
// no suitable new baseline, use old ones! |
| 1402 |
// |
// |
| 1403 |
if ( !done ){ |
if ( !done ){ |
| 1404 |
|
if ( debug ) printf(" l %i m %i pre %i ip[i] %i base %f base ip[i] %f sbase %f \n",l,m,pre,ip[i],base[l][m][pre],base[l][m][ip[i]],sbase[l][m][pre]); |
| 1405 |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
| 1406 |
ck = 1; |
ck[l][m][pre] = 1; |
| 1407 |
if (pre%2 == 0) { |
if (pre%2 == 0) { |
| 1408 |
ip[i] = pre + 1; |
ip[i] = pre + 1; |
| 1409 |
} else { |
} else { |
| 1411 |
}; |
}; |
| 1412 |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
| 1413 |
// |
// |
| 1414 |
ck = 2; |
ck[l][m][pre] = 2; |
| 1415 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
| 1416 |
ck = 3; |
ck[l][m][pre] = 3; |
| 1417 |
}; |
}; |
| 1418 |
}; |
}; |
|
done = 1; |
|
| 1419 |
}; |
}; |
| 1420 |
|
done = 1; |
| 1421 |
}; |
}; |
| 1422 |
// |
// |
| 1423 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
| 1424 |
// |
// |
| 1425 |
if ( !doneb ){ |
if ( !doneb ){ |
| 1426 |
if ( debug ) printf(" ck is %i \n",ck); |
if ( debug ) printf(" ck[l][m][pre] is %i \n",ck[l][m][pre]); |
| 1427 |
switch (ck) { |
switch (ck[l][m][pre]) { |
| 1428 |
case 0: |
case 0: |
| 1429 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
| 1430 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 1431 |
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = base l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,base[l][m][pre],calbase[l][m][pre]); |
| 1432 |
break; |
break; |
| 1433 |
case 1: |
case 1: |
| 1434 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
| 1435 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
| 1436 |
if ( debug ) printf(" base0 = base l m ip(i) = %f base2 = calbase l m ip(i) = %f \n",base[l][m][ip[i]],calbase[l][m][ip[i]]); |
if ( debug ) printf(" base0 = base l%i m%i ip(i)%i = %f base2 = calbase l m ip(i) = %f \n",l,m,ip[i],base[l][m][ip[i]],calbase[l][m][ip[i]]); |
| 1437 |
break; |
break; |
| 1438 |
case 2: |
case 2: |
| 1439 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
| 1440 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 1441 |
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = sbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,sbase[l][m][pre],calbase[l][m][pre]); |
| 1442 |
break; |
break; |
| 1443 |
case 3: |
case 3: |
| 1444 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
| 1445 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 1446 |
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = calbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,calbase[l][m][pre],calbase[l][m][pre]); |
| 1447 |
break; |
break; |
| 1448 |
}; |
}; |
| 1449 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
| 1452 |
ener = dexyc[l][m][n]; |
ener = dexyc[l][m][n]; |
| 1453 |
ener0 += ener; |
ener0 += ener; |
| 1454 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
| 1455 |
|
totbase += de->base[l][m][pre]/96.; |
| 1456 |
|
totped += fabs(calped[l][m][n]); |
| 1457 |
|
if ( de->base[l][m][pre] < 0 ) negbase = true; |
| 1458 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
| 1459 |
// if ( !donec && (base0 - base1 + base2) != 0. ){ |
// |
| 1460 |
// sbase[l][m][pre] = base0 - base1 + base2; |
// save the baseline only if the energy release is "small" |
| 1461 |
if ( !donec && (base0 + base1 - base2) != 0. ){ |
// |
| 1462 |
sbase[l][m][pre] = base0 + base1 - base2; |
if ( !donec && (base0 + base1 - base2) != 0. && (n+1)%16==0 ){ |
| 1463 |
|
if ( qpre[l][m][pre] < 200. ) sbase[l][m][pre] = base0 + base1 - base2; |
| 1464 |
donec = 1; |
donec = 1; |
| 1465 |
}; |
}; |
| 1466 |
if ( ener > 0. ){ |
if ( ener > 0. ){ |
| 1468 |
// |
// |
| 1469 |
// OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) |
// OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) |
| 1470 |
// |
// |
| 1471 |
qpre[pre] += clevel1->estrip[n][m][l]; |
if ( debug && l==0 && (m==17 || m==18) ) printf(" view %i plane %i strip %i ener %f calped %f base0 %f base1 %f base2 %f mip %f ENERGIA %f \n",l,m,n,ener,calped[l][m][n],base0,base1,base2,mip[l][m][n],clevel1->estrip[n][m][l]); |
| 1472 |
|
if ( clevel1->estrip[n][m][l] > 0. ) qpre[l][m][pre] += clevel1->estrip[n][m][l]; |
| 1473 |
// |
// |
| 1474 |
// |
// |
| 1475 |
}; |
}; |
| 1476 |
}; |
}; |
| 1477 |
}; |
}; |
|
if ( crosst ){ |
|
|
if (ck == 1){ |
|
|
if (ip[i]%2 == 0) { |
|
|
ipre = ip[i] + 1; |
|
|
} else { |
|
|
ipre = ip[i] - 1; |
|
|
}; |
|
|
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
|
|
if ( !ctground ){ |
|
|
clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * ctprecor[l][m][ipre]; |
|
|
} else { |
|
|
clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * 0.00478; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
if (ck == 2){ |
|
|
for (Int_t j = i*32 ; j < (i+1)*32 ; j++){ |
|
|
ipre = j/16 + 1; |
|
|
if ( !ctground ){ |
|
|
clevel1->estrip[j][m][l] += qpre[ipre] * ctprecor[l][m][ipre]; |
|
|
} else { |
|
|
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
| 1478 |
}; |
}; |
| 1479 |
// |
// |
| 1480 |
if ( ener0 == 0. && cbase0 == 0. && !pproblem && clevel2->perr[se] == 0){ |
// check if there were problems with 5.7 or glitches in the power supply |
| 1481 |
if ( verbose ) printf(" L0 entry %i : calorimeter power problems! event marked as bad perr %f swerr %X view %i plane %i \n",ei,de->perror[se],de->stwerr[se],l,m); |
// |
| 1482 |
|
// if ( ((ener0 == 0. && cbase0 == 0.) || negbase || totbase > 196600. || totped < 1. ) && !pproblem && clevel2->perr[se] == 0){ // check pedestal and baseline values for one plane, if all zeros calibration is not valid (calorimeter power problems) [8th data reduction bug, fixed on 25/11/2009 by E.M.] |
| 1483 |
|
if ( ((ener0 == 0. && cbase0 == 0.) || negbase || totbase > 32700. || totped < 1. ) && !pproblem && clevel2->perr[se] == 0){ // check pedestal and baseline values for one plane, if all zeros calibration is not valid (calorimeter power problems) [8th data reduction bug, fixed on 25/11/2009 by E.M.] |
| 1484 |
|
if ( verbose ) printf(" L0 entry %i : calorimeter power problems! event marked as bad perr %f swerr %X view %i plane %i negbase %i totbase %f totped %f\n",ei,de->perror[se],de->stwerr[se],l,m, negbase, totbase, totped); |
| 1485 |
pproblem = true; |
pproblem = true; |
| 1486 |
pe++; |
pe++; |
| 1487 |
}; |
}; |
| 1488 |
// |
// |
| 1489 |
Int_t j4 = -4; |
} else { |
| 1490 |
Int_t jjj = -3; |
for (Int_t nn = 0; nn < 96; nn++){ |
| 1491 |
Int_t jj = -2; |
clevel1->estrip[nn][m][l] = 0.; |
| 1492 |
Int_t jjpre = -1; |
}; |
| 1493 |
Int_t jjjpre = -1; |
}; |
| 1494 |
for (Int_t j = 0 ; j < 100 ; j++){ |
}; |
| 1495 |
jj++; |
}; |
| 1496 |
jjj++; |
// |
| 1497 |
j4++; |
// run over views and planes to apply crosstalk corrections |
| 1498 |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
// |
| 1499 |
if ( crosst ){ |
for (Int_t l = 0; l < 2; l++){ |
| 1500 |
if ( jj >= 0 && jj < 96 ){ |
for (Int_t m = 0; m < 22; m++){ |
| 1501 |
if ( !ctground ){ |
// |
| 1502 |
if ( jj%16 == 0 ) jjpre++; |
// determine the section number |
| 1503 |
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
// |
| 1504 |
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
se = 5; |
| 1505 |
} else { |
if (l == 0 && m%2 == 0) se = 3; |
| 1506 |
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; |
if (l == 0 && m%2 != 0) se = 2; |
| 1507 |
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581; |
if (l == 1 && m%2 != 0) se = 1; |
| 1508 |
|
if (l == 1 && m%2 == 0) se = 0; |
| 1509 |
|
// |
| 1510 |
|
// check for any error in the event |
| 1511 |
|
// |
| 1512 |
|
if ( clevel2->crc[se] == 0 && (clevel1->good2 == 1 || clevel2->trigty >= 2) ){ |
| 1513 |
|
// |
| 1514 |
|
// Cross-talk corrections |
| 1515 |
|
// |
| 1516 |
|
if ( crosst ){ |
| 1517 |
|
// |
| 1518 |
|
// energy on silicon ladders |
| 1519 |
|
// |
| 1520 |
|
Float_t qsi[3]; |
| 1521 |
|
qsi[0] = qpre[l][m][0]+qpre[l][m][1]; |
| 1522 |
|
qsi[1] = qpre[l][m][2]+qpre[l][m][3]; |
| 1523 |
|
qsi[2] = qpre[l][m][4]+qpre[l][m][5]; |
| 1524 |
|
// |
| 1525 |
|
for ( pre = 1; pre < 6; pre += 2 ){ |
| 1526 |
|
Int_t ladder = (pre - 1)/2; |
| 1527 |
|
// |
| 1528 |
|
// If the noselfct flag is set the strip doesn't suffer the self crosstalk due to electronics so we must subtract some energy |
| 1529 |
|
// |
| 1530 |
|
if ( noselfct ){ |
| 1531 |
|
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
| 1532 |
|
ipre = j/16 ; |
| 1533 |
|
if ( debug ) printf(" CT STEP1 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctprecor[l][m][ipre]); |
| 1534 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] -= clevel1->estrip[j][m][l] * ctprecor[l][m][ipre]; |
| 1535 |
|
if ( debug ) printf(" CT STEP2 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctprecor[l][m][ipre]); |
| 1536 |
}; |
}; |
| 1537 |
}; |
}; |
| 1538 |
if ( jjj >= 0 && jjj < 96 ){ |
// |
| 1539 |
if ( !ctground ){ |
// Using the neighbour pre baseline |
| 1540 |
if ( jjj%16 == 0 ) jjjpre++; |
// |
| 1541 |
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
if (ck[l][m][pre] == 1 || ck[l][m][pre-1] == 1){ |
| 1542 |
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
// |
| 1543 |
|
// pre-amplifier effect on baseline when using the neighbour pre (ck=1) |
| 1544 |
|
// |
| 1545 |
|
if (ck[l][m][pre] == 1){ |
| 1546 |
|
ipre = pre; |
| 1547 |
|
ipp = pre - 1; |
| 1548 |
} else { |
} else { |
| 1549 |
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * 0.01581; |
ipre = pre - 1; |
| 1550 |
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * 0.01581; |
ipp = pre; |
| 1551 |
|
}; |
| 1552 |
|
Int_t it = 0; |
| 1553 |
|
Float_t nqpre = 0.; |
| 1554 |
|
// |
| 1555 |
|
if ( debug ) printf(" CK1 Limit for while: 0.07 \n"); |
| 1556 |
|
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
| 1557 |
|
if ( debug ) printf(" CT STEP3 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctprecor[l][m][ipp]); |
| 1558 |
|
if ( !ctground ){ |
| 1559 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * ctprecor[l][m][ipp]; |
| 1560 |
|
} else { |
| 1561 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * 0.00478; |
| 1562 |
|
}; |
| 1563 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
| 1564 |
|
if ( debug ) printf(" CT STEP4 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctprecor[l][m][ipp]); |
| 1565 |
|
}; |
| 1566 |
|
qpre[l][m][ipre] = nqpre; |
| 1567 |
|
nqpre = 0.; |
| 1568 |
|
Float_t deltaqpre = qpre[l][m][ipre]; |
| 1569 |
|
// |
| 1570 |
|
// these values are empirically determined, usually the routine converge due to deltaqsi and the latest applied correction is based on less than 1 mip |
| 1571 |
|
// |
| 1572 |
|
while ( it < 10 && deltaqpre > 0.07 ){ |
| 1573 |
|
nqpre = 0.; |
| 1574 |
|
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
| 1575 |
|
if ( debug ) printf(" CT STEP5 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctprecor[l][m][ipre]); |
| 1576 |
|
if ( !ctground ){ |
| 1577 |
|
if ( debug ) printf(" CK1 pre correction: iteration %i deltaqpre %f ctprecor %f TOTAL CORRECTION %f \n",it,deltaqpre,ctprecor[l][m][ipre],deltaqpre * ctprecor[l][m][ipre]); |
| 1578 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * ctprecor[l][m][ipre]; |
| 1579 |
|
} else { |
| 1580 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * 0.00478; |
| 1581 |
|
}; |
| 1582 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
| 1583 |
|
if ( debug ) printf(" CT STEP6 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctprecor[l][m][ipre]); |
| 1584 |
|
}; |
| 1585 |
|
if ( ctground ) it = 100; |
| 1586 |
|
it++; |
| 1587 |
|
deltaqpre = nqpre - qpre[l][m][ipre]; |
| 1588 |
|
if ( debug ) printf(" CK1 BEFORE: qpre %f \n",qpre[l][m][ipre]); |
| 1589 |
|
qpre[l][m][ipre] = nqpre; |
| 1590 |
|
if ( debug ) printf(" CK1 AFTER: qpre %f \n",qpre[l][m][ipre]); |
| 1591 |
}; |
}; |
| 1592 |
|
// |
| 1593 |
}; |
}; |
|
}; |
|
|
if ( j4 >= 0 && j4 < 96 ){ |
|
| 1594 |
// |
// |
| 1595 |
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <=============== IMPORTANT! =================> |
// No baseline calculation due to high energy release |
|
// |
|
|
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
|
|
clevel1->estrip[j4][m][l] = 0.; |
|
|
}; |
|
|
// |
|
|
// code and save the energy for each strip in svstrip |
|
| 1596 |
// |
// |
| 1597 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if (ck[l][m][pre] == 2 && ck[l][m][pre-1] == 2){ |
| 1598 |
// |
// |
| 1599 |
Float_t savel1 = clevel1->estrip[j4][m][l]; |
// y^ |
| 1600 |
if ( dexyc[j4][m][l] == 32767. ) savel1 += 5000.; |
// | |
| 1601 |
|
// | 6 7 8 |
| 1602 |
|
// | 3 4 5 |
| 1603 |
|
// | 0 1 2 |
| 1604 |
|
// | --------------------------------------> x |
| 1605 |
// |
// |
| 1606 |
tim = 100000.; |
Int_t si1 = 0; |
| 1607 |
plo = m; |
Int_t si2 = 0; |
| 1608 |
fbi = 0; |
Int_t si3 = 0; |
| 1609 |
if ( savel1 > 0.99995 ){ |
if ( l == 0 ){ |
| 1610 |
tim = 10000.; |
if ( ladder == 0 ){ |
| 1611 |
plo = m; |
si1 = 0; |
| 1612 |
fbi = 1; |
si2 = 3; |
| 1613 |
}; |
si3 = 6; |
| 1614 |
if ( savel1 > 9.9995 ){ |
}; |
| 1615 |
tim = 1000.; |
if ( ladder == 1 ){ |
| 1616 |
plo = 22 + m; |
si1 = 1; |
| 1617 |
fbi = 1; |
si2 = 4; |
| 1618 |
}; |
si3 = 7; |
| 1619 |
if ( savel1 > 99.995 ){ |
}; |
| 1620 |
tim = 100.; |
if ( ladder == 2 ){ |
| 1621 |
plo = 22 + m; |
si1 = 2; |
| 1622 |
fbi = 0; |
si2 = 5; |
| 1623 |
|
si3 = 8; |
| 1624 |
|
}; |
| 1625 |
|
} else { |
| 1626 |
|
if ( ladder == 0 ){ |
| 1627 |
|
si1 = 0; |
| 1628 |
|
si2 = 1; |
| 1629 |
|
si3 = 2; |
| 1630 |
|
}; |
| 1631 |
|
if ( ladder == 1 ){ |
| 1632 |
|
si1 = 3; |
| 1633 |
|
si2 = 4; |
| 1634 |
|
si3 = 5; |
| 1635 |
|
}; |
| 1636 |
|
if ( ladder == 2 ){ |
| 1637 |
|
si1 = 6; |
| 1638 |
|
si2 = 7; |
| 1639 |
|
si3 = 8; |
| 1640 |
|
}; |
| 1641 |
}; |
}; |
| 1642 |
if ( savel1 > 999.95 ){ |
// |
| 1643 |
tim = 10.; |
// Find the energy distribution along the considered plane looking at the two sandwiching plane of the other view. |
| 1644 |
plo = 44 + m; |
// |
| 1645 |
fbi = 0; |
Float_t sied[3] = {0.,0.,0.}; |
| 1646 |
|
Int_t othv = !l; |
| 1647 |
|
Int_t othpl1 = m - 1; |
| 1648 |
|
Int_t othpl2 = m + 1; |
| 1649 |
|
Float_t oprof[3] = {0.,0.,0.}; |
| 1650 |
|
for(Int_t s=0; s<3; s++){ |
| 1651 |
|
for(Int_t t=(s*32); t<32*(s + 1); t++){ |
| 1652 |
|
if ( othpl1 > -1 ) { |
| 1653 |
|
oprof[s] += clevel1->estrip[othv][othpl1][t]; |
| 1654 |
|
}; |
| 1655 |
|
if ( othpl2 < 22 ) { |
| 1656 |
|
oprof[s] += clevel1->estrip[othv][othpl2][t]; |
| 1657 |
|
}; |
| 1658 |
|
}; |
| 1659 |
}; |
}; |
| 1660 |
if ( savel1 > 9999.5 ){ |
Float_t otote = fabs(oprof[0]) + fabs(oprof[1]) + fabs(oprof[2]); |
| 1661 |
tim = 1.; |
for(Int_t g=0; g<3; g++){ |
| 1662 |
plo = 66 + m; |
if ( otote > 0. ){ |
| 1663 |
fbi = 0; |
sied[g] = fabs(oprof[g])/otote; |
| 1664 |
|
} else { |
| 1665 |
|
sied[g] = 1./3.; |
| 1666 |
|
}; |
| 1667 |
}; |
}; |
| 1668 |
// |
// |
|
cle = (Int_t)lroundf(tim*savel1); |
|
| 1669 |
// |
// |
| 1670 |
if ( l == 0 ){ |
// |
| 1671 |
|
Int_t it = 0; |
| 1672 |
|
Int_t jpre = 0; |
| 1673 |
|
Float_t nqsi = 0.; |
| 1674 |
|
Float_t snqsi = qsi[ladder]; |
| 1675 |
|
Float_t nqpre[2] = {0.,0.}; |
| 1676 |
|
Float_t deltaqsi = qsi[ladder]; |
| 1677 |
|
Float_t deltaqpre[2]; |
| 1678 |
|
deltaqpre[0] = qpre[l][m][pre-1]; |
| 1679 |
|
deltaqpre[1] = qpre[l][m][pre]; |
| 1680 |
|
// |
| 1681 |
|
if ( debug ) printf(" Limit for while: 0.07 it < 10 \n"); |
| 1682 |
|
// |
| 1683 |
|
// these values are empirically determined, usually the routine converge due to deltaqsi and the latest applied correction is based on less than 1 mip |
| 1684 |
|
// |
| 1685 |
|
while ( it < 10 && (deltaqsi > 0.07 || deltaqpre[0] > 0.07 || deltaqpre[1] > 0.07) ){ |
| 1686 |
|
nqsi = 0.; |
| 1687 |
|
nqpre[0] = 0.; |
| 1688 |
|
nqpre[1] = 0.; |
| 1689 |
|
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
| 1690 |
|
if ( debug ) printf(" CT STEP6 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctsicor[l][m][si2]); |
| 1691 |
|
ipre = 0; |
| 1692 |
|
if ( j > (ladder*32)+15 ) ipre = 1; |
| 1693 |
|
jpre = j/16 ; |
| 1694 |
|
// |
| 1695 |
|
// Silicon effect on the baseline when using the same pre previous baseline (ck = 2) + pre-amply effect |
| 1696 |
|
// |
| 1697 |
|
if ( !ctground ){ |
| 1698 |
|
if ( debug ) printf(" silicon correction: iteration %i deltaqsi[%i] %f ctsicor %f %f %f sied %f %f %f si %i %i %i TOTAL CORRECTION %f \n",it,ladder,deltaqsi,ctsicor[l][m][si1],ctsicor[l][m][si2],ctsicor[l][m][si3],sied[0],sied[1],sied[2],si1,si2,si3,deltaqsi * (ctsicor[l][m][si1] * sied[0] + ctsicor[l][m][si2] * sied[1] + ctsicor[l][m][si3] * sied[2])); |
| 1699 |
|
if ( debug ) printf(" pre correction: iteration %i deltaqpre[0] %f deltaqpre[1] %f ctprecor %f TOTAL CORRECTION %f \n",it,deltaqpre[0],deltaqpre[1],ctprecor[l][m][jpre],deltaqpre[ipre] * ctprecor[l][m][jpre]); |
| 1700 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += (deltaqsi * (ctsicor[l][m][si1] * sied[0] + ctsicor[l][m][si2] * sied[1] + ctsicor[l][m][si3] * sied[2])/mip[l][m][j]) + deltaqpre[ipre] * ctprecor[l][m][jpre]; |
| 1701 |
|
} else { |
| 1702 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += 0. + qpre[l][m][jpre] * 0.00478; // no correction |
| 1703 |
|
}; |
| 1704 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqsi += clevel1->estrip[j][m][l] ; |
| 1705 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqpre[ipre] += clevel1->estrip[j][m][l] ; |
| 1706 |
|
if ( debug ) printf(" CT STEP7 %i %i %i estrip %f ctprecor %f \n",j,m,l,clevel1->estrip[j][m][l],ctsicor[l][m][si2]); |
| 1707 |
|
}; |
| 1708 |
|
if ( ctground ) it = 100; |
| 1709 |
|
deltaqsi = nqsi-snqsi; |
| 1710 |
|
deltaqpre[0] = nqpre[0] - qpre[l][m][pre-1]; |
| 1711 |
|
deltaqpre[1] = nqpre[1] - qpre[l][m][pre]; |
| 1712 |
// |
// |
| 1713 |
// +-PPSSmmmm.mmmm |
// Check for divergence and stop if it happens! [9RED bug noticed with plane 18X] |
| 1714 |
// |
// |
| 1715 |
svstrip[istrip] = fbi*1000000000 + plo*10000000 + j4*100000 + cle; |
if ( deltaqpre[0] > qpre[l][m][pre-1] || deltaqpre[1] > qpre[l][m][pre] || deltaqsi >snqsi ){ |
| 1716 |
} else { |
if ( debug ) printf(" WARNING!! DIVERGING CORRECTION EXIT IMMEDIATLY FROM THE LOOP!! dqpre0 %f qpre0 %f // dqpre1 %f qpre1 %f // dqsi %f qsi %f \n",deltaqpre[0],qpre[l][m][pre-1],deltaqpre[1],qpre[l][m][pre],deltaqsi,snqsi); |
| 1717 |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
it = 1000; |
| 1718 |
|
}; |
| 1719 |
|
// |
| 1720 |
|
snqsi = nqsi; |
| 1721 |
|
it++; |
| 1722 |
|
if ( debug ) printf(" BEFORE: qpre 0 %f qpre 1 %f \n",qpre[l][m][pre-1],qpre[l][m][pre]); |
| 1723 |
|
qpre[l][m][pre-1] = nqpre[0]; |
| 1724 |
|
qpre[l][m][pre] = nqpre[1]; |
| 1725 |
|
if ( debug ) printf(" AFTER: qpre 0 %f qpre 1 %f \n",qpre[l][m][pre-1],qpre[l][m][pre]); |
| 1726 |
|
}; |
| 1727 |
|
// |
| 1728 |
|
// |
| 1729 |
|
// |
| 1730 |
|
// for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
| 1731 |
|
// ipre = j/16 ; |
| 1732 |
|
// // |
| 1733 |
|
// // pre-amplifier effect on baseline when using the same pre previous event baseline (ck=2) |
| 1734 |
|
// // |
| 1735 |
|
// if ( !ctground ){ |
| 1736 |
|
// if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += qpre[l][m][ipre] * ctprecor[l][m][ipre]; |
| 1737 |
|
// } else { |
| 1738 |
|
// if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += qpre[l][m][ipre] * 0.00478; |
| 1739 |
|
// }; |
| 1740 |
|
// }; |
| 1741 |
|
}; |
| 1742 |
|
}; |
| 1743 |
|
}; |
| 1744 |
|
}; |
| 1745 |
|
// |
| 1746 |
|
Int_t j4 = -4; |
| 1747 |
|
Int_t jjj = -3; |
| 1748 |
|
Int_t jj = -2; |
| 1749 |
|
Int_t jjpre = -1; |
| 1750 |
|
Int_t jjjpre = -1; |
| 1751 |
|
memset(ene, 0, 96*sizeof(Float_t)); |
| 1752 |
|
for (Int_t j = 0 ; j < 100 ; j++){ |
| 1753 |
|
jj++; |
| 1754 |
|
jjj++; |
| 1755 |
|
j4++; |
| 1756 |
|
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
| 1757 |
|
if ( crosst ){ |
| 1758 |
|
// |
| 1759 |
|
// "Real" crosstalk effect on the neighbour strips respect to the one which have seen the energy deposit |
| 1760 |
|
// |
| 1761 |
|
if ( jj >= 0 && jj < 96 ){ |
| 1762 |
|
if ( !ctground ){ |
| 1763 |
|
if ( jj%16 == 0 ) jjpre++; |
| 1764 |
|
if ( jj != 0 && jj != 32 && jj != 64 && ene[jj-1] != 0. ) ene[jj-1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
| 1765 |
|
if ( jj != 31 && jj != 63 && jj != 95 && ene[jj+1] != 0. ) ene[jj+1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
| 1766 |
|
} else { |
| 1767 |
|
if ( jj != 0 && jj != 32 && jj != 64 && ene[jj-1] != 0. ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; |
| 1768 |
|
if ( jj != 31 && jj != 63 && jj != 95 && ene[jj+1] != 0. ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581; |
| 1769 |
|
}; |
| 1770 |
|
}; |
| 1771 |
|
if ( jjj >= 0 && jjj < 96 ){ |
| 1772 |
|
if ( !ctground ){ |
| 1773 |
|
if ( jjj%16 == 0 ) jjjpre++; |
| 1774 |
|
if ( jjj != 0 && jjj != 32 && jjj != 64 && clevel1->estrip[jjj-1][m][l] != 0. ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
| 1775 |
|
if ( jjj != 31 && jjj != 63 && jjj != 95 && clevel1->estrip[jjj+1][m][l] !=0. ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
| 1776 |
|
} else { |
| 1777 |
|
if ( jjj != 0 && jjj != 32 && jjj != 64 && clevel1->estrip[jjj-1][m][l] != 0. ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * 0.01581; |
| 1778 |
|
if ( jjj != 31 && jjj != 63 && jjj != 95 && clevel1->estrip[jjj+1][m][l] != 0. ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * 0.01581; |
| 1779 |
|
}; |
| 1780 |
|
}; |
| 1781 |
|
}; |
| 1782 |
|
if ( j4 >= 0 && j4 < 96 ){ |
| 1783 |
|
// |
| 1784 |
|
// CALOLEVEL1 CODING AND FILLING |
| 1785 |
|
// |
| 1786 |
|
// |
| 1787 |
|
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <=============== IMPORTANT! =================> // not true anymore, now it trust parameter files |
| 1788 |
|
// |
| 1789 |
|
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || clevel1->estrip[j4][m][l] <= memin[l][m][j4] || calrms[l][m][j4] > maxrms[l][m] || (l==0 && m == 18 && mask18 ) ){ |
| 1790 |
|
clevel1->estrip[j4][m][l] = 0.; |
| 1791 |
|
}; |
| 1792 |
|
// |
| 1793 |
|
if ( debug ) printf(" STRIP: view %i plane %i strip %i energy: %f \n",l,m,j4,clevel1->estrip[j4][m][l]); |
| 1794 |
|
// |
| 1795 |
|
// code and save the energy for each strip in svstrip |
| 1796 |
|
// |
| 1797 |
|
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
| 1798 |
|
// |
| 1799 |
|
Float_t savel1 = clevel1->estrip[j4][m][l]; |
| 1800 |
|
// |
| 1801 |
|
if ( m == 18 && l == 0 ){ |
| 1802 |
|
if ( debug ) printf(" Resetting plane 18X for variable calculation: view %i plane %i strip %i \n",l,m,j4); |
| 1803 |
|
clevel1->estrip[j4][m][l] = 0.; // SAVE STRIPS VALUE FOR PLANE 18 X but DO NOT USE IT FOR VARIABLE CALCULATION |
| 1804 |
|
}; |
| 1805 |
|
if ( debug ) printf(" HIT STRIP: view %i plane %i strip %i energy: %f \n",l,m,j4,clevel1->estrip[j4][m][l]); |
| 1806 |
|
// if ( dexyc[l][m][j4] == 32767. ){ |
| 1807 |
|
if ( dexyc[l][m][j4] > 32000. || savel1 > 5000.){ // CaloLevel1 bug with plane 18X [9RED 14/04/2010] |
| 1808 |
|
if ( savel1 > 5000 ){ |
| 1809 |
|
if ( debug ) printf(" Absurd plane 18X energy... resetting value to 1100 MIP \n"); |
| 1810 |
|
savel1 = 1100.; // CaloLevel1 bug with plane 18x [9RED 14/04/2010] |
| 1811 |
}; |
}; |
| 1812 |
|
savel1 += 5000.; |
| 1813 |
|
clevel2->nsatstrip += 1.; |
| 1814 |
|
}; |
| 1815 |
|
// |
| 1816 |
|
tim = 100000.; |
| 1817 |
|
plo = m; |
| 1818 |
|
fbi = 0; |
| 1819 |
|
if ( savel1 > 0.99995 ){ |
| 1820 |
|
tim = 10000.; |
| 1821 |
|
plo = m; |
| 1822 |
|
fbi = 1; |
| 1823 |
|
}; |
| 1824 |
|
if ( savel1 > 9.9995 ){ |
| 1825 |
|
tim = 1000.; |
| 1826 |
|
plo = 22 + m; |
| 1827 |
|
fbi = 1; |
| 1828 |
|
}; |
| 1829 |
|
if ( savel1 > 99.995 ){ |
| 1830 |
|
tim = 100.; |
| 1831 |
|
plo = 22 + m; |
| 1832 |
|
fbi = 0; |
| 1833 |
|
}; |
| 1834 |
|
if ( savel1 > 999.95 ){ |
| 1835 |
|
tim = 10.; |
| 1836 |
|
plo = 44 + m; |
| 1837 |
|
fbi = 0; |
| 1838 |
|
}; |
| 1839 |
|
if ( savel1 > 9999.5 ){ |
| 1840 |
|
tim = 1.; |
| 1841 |
|
plo = 66 + m; |
| 1842 |
|
fbi = 0; |
| 1843 |
|
}; |
| 1844 |
|
// |
| 1845 |
|
cle = (Int_t)lroundf(tim*savel1); |
| 1846 |
|
// |
| 1847 |
|
if ( l == 0 ){ |
| 1848 |
// |
// |
| 1849 |
// if ( ei >= -770 ) printf(" j %i l %i m %i estrip %f \n",j4,l,m,clevel1->estrip[j4][m][l]); |
// +-PPSSmmmm.mmmm |
|
// if ( ei >= -770 ) printf(" num lim %i fbi %i tim %f plo %i cle %i \n",numeric_limits<Int_t>::max(),fbi,tim,plo,cle); |
|
|
// if ( ei >= -770 ) printf(" svstrip %i \n",svstrip[istrip]); |
|
| 1850 |
// |
// |
| 1851 |
istrip++; |
svstrip[istrip] = fbi*1000000000 + plo*10000000 + j4*100000 + cle; |
| 1852 |
|
} else { |
| 1853 |
|
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
| 1854 |
}; |
}; |
| 1855 |
|
if ( debug ) printf(" svstrip[%i] = %i fbi %i plo %i j4 %i cle %i \n",istrip,svstrip[istrip],fbi,plo,j4,cle); |
| 1856 |
|
// |
| 1857 |
|
istrip++; |
| 1858 |
}; |
}; |
| 1859 |
}; |
}; |
|
// |
|
|
} else { |
|
|
for (Int_t nn = 0; nn < 96; nn++){ |
|
|
clevel1->estrip[nn][m][l] = 0.; |
|
|
}; |
|
| 1860 |
}; |
}; |
| 1861 |
|
// |
| 1862 |
}; |
}; |
| 1863 |
}; |
}; |
| 1864 |
|
// |
| 1865 |
|
// store goodness flag |
| 1866 |
|
// |
| 1867 |
if ( !pe ){ |
if ( !pe ){ |
| 1868 |
clevel2->good = 1; |
clevel2->good = 1; |
| 1869 |
} else { |
} else { |
| 1870 |
clevel2->good = 0; |
clevel2->good = 0; |
| 1871 |
}; |
}; |
| 1872 |
|
// |
| 1873 |
|
// done |
| 1874 |
|
// |
| 1875 |
return(0); |
return(0); |
| 1876 |
} |
} |
| 1877 |
|
|
| 1949 |
void CaloLevel0::FillCommonVar(CaloLevel1 *c1, CaloLevel2 *ca){ |
void CaloLevel0::FillCommonVar(CaloLevel1 *c1, CaloLevel2 *ca){ |
| 1950 |
// |
// |
| 1951 |
ca->good = clevel2->good; |
ca->good = clevel2->good; |
| 1952 |
if ( clevel2->trigty == 2. ){ |
// if ( clevel2->trigty == 2. ){ |
| 1953 |
ca->selftrigger = 1; |
// ca->selftrigger = 1; |
| 1954 |
} else { |
// } else { |
| 1955 |
ca->selftrigger = 0; |
// ca->selftrigger = 0; |
| 1956 |
}; |
// }; |
| 1957 |
// |
// |
| 1958 |
ca->selftrigger += (Int_t)clevel2->wartrig; |
ca->selftrigger = (Int_t)clevel2->trigty + (Int_t)clevel2->wartrig; |
| 1959 |
// |
// |
| 1960 |
memcpy(ca->perr,clevel2->perr,sizeof(clevel2->perr)); |
memcpy(ca->perr,clevel2->perr,sizeof(clevel2->perr)); |
| 1961 |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
| 1962 |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
| 1963 |
ca->nstrip = (Int_t)clevel2->nstrip; |
ca->nstrip = (Int_t)clevel2->nstrip; |
| 1964 |
|
ca->nsatstrip = (Int_t)clevel2->nsatstrip; |
| 1965 |
ca->qtot = clevel2->qtot; |
ca->qtot = clevel2->qtot; |
| 1966 |
// ca->impx = clevel2->impx; |
// ca->impx = clevel2->impx; |
| 1967 |
// ca->impy = clevel2->impy; |
// ca->impy = clevel2->impy; |
| 1998 |
ClearCommonVar(); |
ClearCommonVar(); |
| 1999 |
} |
} |
| 2000 |
|
|
| 2001 |
|
void CaloLevel0::Delete(Option_t *t){ |
| 2002 |
|
if ( de ) delete de; |
| 2003 |
|
delete this; |
| 2004 |
|
} |
| 2005 |
|
|
| 2006 |
|
|
| 2007 |
void CaloLevel0::RunClose(){ |
void CaloLevel0::RunClose(){ |
| 2008 |
l0tr->Delete(); |
l0tr->Delete(); |
| 2009 |
ClearStructs(); |
ClearStructs(); |
| 2013 |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
| 2014 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
| 2015 |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
| 2016 |
|
memset(ctsicor, 0, 2*22*9*sizeof(Float_t)); |
| 2017 |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
| 2018 |
// |
// |
| 2019 |
} |
} |
| 2059 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
| 2060 |
clevel2->good = 0; |
clevel2->good = 0; |
| 2061 |
clevel2->nstrip = 0.; |
clevel2->nstrip = 0.; |
| 2062 |
|
clevel2->nsatstrip = 0.; |
| 2063 |
clevel2->qtot = 0.; |
clevel2->qtot = 0.; |
| 2064 |
// clevel2->impx = 0.; |
// clevel2->impx = 0.; |
| 2065 |
// clevel2->impy = 0.; |
// clevel2->impy = 0.; |
| 2232 |
// |
// |
| 2233 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
| 2234 |
// |
// |
| 2235 |
calo->GetEntry(calibno[s]); |
if ( calo->GetEntry(calibno[s]) <= 0 ) throw -36; |
| 2236 |
// |
// |
| 2237 |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
| 2238 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
for ( Int_t d=0 ; d<11 ;d++ ){ |