| 18 |
// YODA headers |
// YODA headers |
| 19 |
// |
// |
| 20 |
#include <PamelaRun.h> |
#include <PamelaRun.h> |
|
#include <RegistryEvent.h> |
|
| 21 |
#include <physics/calorimeter/CalorimeterEvent.h> |
#include <physics/calorimeter/CalorimeterEvent.h> |
| 22 |
#include <CalibCalPedEvent.h> |
#include <CalibCalPedEvent.h> |
| 23 |
// |
// |
| 66 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
| 67 |
calopar1 = true; |
calopar1 = true; |
| 68 |
calopar2 = true; |
calopar2 = true; |
| 69 |
ftcalopar1 = 0ULL; |
calopar3 = true; |
| 70 |
ttcalopar1 = 0ULL; |
ftcalopar1 = 0; |
| 71 |
ftcalopar2 = 0ULL; |
ttcalopar1 = 0; |
| 72 |
ttcalopar2 = 0ULL; |
ftcalopar2 = 0; |
| 73 |
|
ttcalopar2 = 0; |
| 74 |
|
ftcalopar3 = 0; |
| 75 |
|
ttcalopar3 = 0; |
| 76 |
} |
} |
| 77 |
|
|
| 78 |
/** |
/** |
| 79 |
* Initialize CaloProcessing object |
* Initialize CaloProcessing object |
| 80 |
**/ |
**/ |
| 81 |
void CaloProcessing::ProcessingInit(TSQLServer *dbc, ULong64_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
void CaloProcessing::ProcessingInit(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
| 82 |
// |
// |
| 83 |
debug = isdeb; |
debug = isdeb; |
| 84 |
verbose = isverb; |
verbose = isverb; |
| 94 |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
| 95 |
// |
// |
| 96 |
sgnl = 0; |
sgnl = 0; |
| 97 |
|
UInt_t uptime = 0; |
| 98 |
// |
// |
| 99 |
for (Int_t s = 0; s < 4; s++){ |
for (Int_t s = 0; s < 4; s++){ |
| 100 |
idcalib[s] = 0ULL; |
idcalib[s] = 0; |
| 101 |
fromtime[s] = 0ULL; |
fromtime[s] = 0; |
| 102 |
totime[s] = 0ULL; |
totime[s] = 0; |
| 103 |
calibno[s] = 0; |
calibno[s] = 0; |
| 104 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 105 |
// |
// |
| 106 |
sgnl = glcalo->Query_GL_CALO_CALIB(hs,s,dbc); |
sgnl = glcalo->Query_GL_CALO_CALIB(hs,uptime,s,dbc); |
| 107 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
| 108 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 109 |
return; |
return; |
| 110 |
}; |
}; |
| 111 |
// |
// |
| 112 |
idcalib[s] = glcalo->ID_REG_CALIBCALPED; |
idcalib[s] = glcalo->ID_ROOT_L0; |
| 113 |
fromtime[s] = glcalo->FROM_TIME; |
fromtime[s] = glcalo->FROM_TIME; |
| 114 |
totime[s] = glcalo->TO_TIME; |
if ( glcalo->TO_TIME < hs ){ // calibration is corrupted and we are using the one that preceed the good one |
| 115 |
calibno[s] = glcalo->EV_REG_CALIBCALPED; |
totime[s] = uptime; |
| 116 |
// |
} else { |
| 117 |
if ( totime[s] == 0ULL){ |
totime[s] = glcalo->TO_TIME; |
| 118 |
|
}; |
| 119 |
|
calibno[s] = glcalo->EV_ROOT; |
| 120 |
|
// |
| 121 |
|
if ( totime[s] == 0 ){ |
| 122 |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
| 123 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 124 |
sgnl = 100; |
sgnl = 100; |
| 131 |
if ( verbose ) printf("\n"); |
if ( verbose ) printf("\n"); |
| 132 |
for (Int_t s = 0; s < 4; s++){ |
for (Int_t s = 0; s < 4; s++){ |
| 133 |
if ( verbose ) printf(" ** SECTION %i **\n",s); |
if ( verbose ) printf(" ** SECTION %i **\n",s); |
| 134 |
if ( totime[s] > 0ULL ){ |
if ( totime[s] > 0 ){ |
| 135 |
// |
// |
| 136 |
sgnl = glroot->Query_GL_ROOT(idcalib[s],dbc); |
sgnl = glroot->Query_GL_ROOT(idcalib[s],dbc); |
| 137 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
| 138 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 139 |
return; |
return; |
| 140 |
}; |
}; |
| 141 |
// |
// |
| 142 |
stringstream name; |
stringstream name; |
| 143 |
name.str(""); |
name.str(""); |
| 144 |
name << glroot->PATH.Data() << "/"; |
name << glroot->PATH.Data() << "/"; |
| 145 |
name << glroot->NAME.Data(); |
name << glroot->NAME.Data(); |
| 146 |
// |
// |
| 147 |
fcalname[s] = (TString)name.str().c_str(); |
fcalname[s] = (TString)name.str().c_str(); |
| 148 |
if ( verbose ) printf(" - runheader at time %llu. From time %llu to time %llu \n use file %s \n calibration at entry %i \n\n",hs,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
if ( verbose ) printf(" - runheader at time %u. From time %u to time %u \n use file %s \n calibration at entry %i \n\n",hs,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
| 149 |
} else { |
} else { |
| 150 |
if ( verbose ) printf(" - runheader at time %llu. NO CALIBRATION INCLUDE THE RUNHEADER! ",hs); |
if ( verbose ) printf(" - runheader at time %u. NO CALIBRATION INCLUDE THE RUNHEADER! ",hs); |
| 151 |
}; |
}; |
| 152 |
sgnl = LoadCalib(s); |
sgnl = LoadCalib(s); |
| 153 |
if ( sgnl ) break; |
if ( sgnl ) break; |
| 160 |
// |
// |
| 161 |
} |
} |
| 162 |
|
|
| 163 |
Int_t CaloProcessing::ChkCalib(TSQLServer *dbc, ULong64_t atime){ |
Int_t CaloProcessing::ChkCalib(TSQLServer *dbc, UInt_t atime){ |
| 164 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
| 165 |
for ( Int_t s = 0; s < 4; s++){ |
for ( Int_t s = 0; s < 4; s++){ |
| 166 |
if ( atime > totime[s] ){ |
if ( atime > totime[s] ){ |
| 171 |
return(sgnl); |
return(sgnl); |
| 172 |
} |
} |
| 173 |
|
|
| 174 |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, ULong64_t runheader){ |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
| 175 |
stringstream calfile; |
stringstream calfile; |
| 176 |
|
stringstream bmfile; |
| 177 |
stringstream aligfile; |
stringstream aligfile; |
| 178 |
Int_t error = 0; |
Int_t error = 0; |
| 179 |
FILE *f = 0; |
FILE *f = 0; |
| 180 |
|
ifstream badfile; |
| 181 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
| 182 |
// |
// |
| 183 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
| 188 |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
| 189 |
// |
// |
| 190 |
error = 0; |
error = 0; |
| 191 |
error = glparam->Query_GL_PARAM(runheader,"Calorimeter ADC to MIP",dbc); |
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
| 192 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
| 193 |
// |
// |
| 194 |
calfile.str(""); |
calfile.str(""); |
| 221 |
// |
// |
| 222 |
// |
// |
| 223 |
error = 0; |
error = 0; |
| 224 |
error = glparam->Query_GL_PARAM(runheader,"Calorimeter alignement",dbc); |
error = glparam->Query_GL_PARAM(runheader,102,dbc); |
| 225 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
| 226 |
// |
// |
| 227 |
aligfile.str(""); |
aligfile.str(""); |
| 230 |
ftcalopar2 = glparam->FROM_TIME; |
ftcalopar2 = glparam->FROM_TIME; |
| 231 |
ttcalopar2 = glparam->TO_TIME; |
ttcalopar2 = glparam->TO_TIME; |
| 232 |
// |
// |
| 233 |
if ( verbose ) printf("\n Using alignment file: \n %s \n\n",aligfile.str().c_str()); |
if ( verbose ) printf("\n Using alignment file: \n %s \n",aligfile.str().c_str()); |
| 234 |
f = fopen(aligfile.str().c_str(),"rb"); |
f = fopen(aligfile.str().c_str(),"rb"); |
| 235 |
if ( !f ){ |
if ( !f ){ |
| 236 |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
| 249 |
fclose(f); |
fclose(f); |
| 250 |
}; |
}; |
| 251 |
// |
// |
| 252 |
|
// Load offline bad strip mask |
| 253 |
|
// |
| 254 |
|
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
| 255 |
|
calopar3 = false; |
| 256 |
|
// |
| 257 |
|
// determine where I can find calorimeter alignment file |
| 258 |
|
// |
| 259 |
|
// |
| 260 |
|
error = 0; |
| 261 |
|
error = glparam->Query_GL_PARAM(runheader,103,dbc); |
| 262 |
|
if ( error < 0 ) return(error); |
| 263 |
|
// |
| 264 |
|
bmfile.str(""); |
| 265 |
|
bmfile << glparam->PATH.Data() << "/"; |
| 266 |
|
bmfile << glparam->NAME.Data(); |
| 267 |
|
ftcalopar3 = glparam->FROM_TIME; |
| 268 |
|
ttcalopar3 = glparam->TO_TIME; |
| 269 |
|
// |
| 270 |
|
if ( verbose ) printf("\n Using bad strip offline mask file: \n %s \n\n",bmfile.str().c_str()); |
| 271 |
|
badfile.open(bmfile.str().c_str()); |
| 272 |
|
if ( !badfile ){ |
| 273 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no bad strip offline mask file!\n"); |
| 274 |
|
return(-115); |
| 275 |
|
}; |
| 276 |
|
// |
| 277 |
|
Bool_t isdone = false; |
| 278 |
|
Int_t bad = 0; |
| 279 |
|
Int_t view = 1; |
| 280 |
|
Int_t strip = 0; |
| 281 |
|
Int_t plane = 21; |
| 282 |
|
while ( !isdone ) { |
| 283 |
|
badfile >> bad; |
| 284 |
|
obadmask[view][plane][strip] = bad; |
| 285 |
|
if ( debug && bad ) printf(" SETTING view %i plane %i strip %i BAD = %i \n",view,plane,strip,bad); |
| 286 |
|
strip++; |
| 287 |
|
if ( strip > 95 ){ |
| 288 |
|
strip = 0; |
| 289 |
|
plane--; |
| 290 |
|
if ( plane < 0 ){ |
| 291 |
|
plane = 21; |
| 292 |
|
view--; |
| 293 |
|
}; |
| 294 |
|
if ( view < 0 ) isdone = true; |
| 295 |
|
}; |
| 296 |
|
}; |
| 297 |
|
// |
| 298 |
|
badfile.close(); |
| 299 |
|
}; |
| 300 |
|
// |
| 301 |
delete glparam; |
delete glparam; |
|
// delete f; |
|
| 302 |
// |
// |
| 303 |
return(0); |
return(0); |
| 304 |
} |
} |
| 310 |
Float_t rms = 0.; |
Float_t rms = 0.; |
| 311 |
base[l][m][pre] = 0.; |
base[l][m][pre] = 0.; |
| 312 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 313 |
if ( calgood[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.) { |
| 314 |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
| 315 |
rms = calthr[l][m][pre]; |
rms = calthr[l][m][pre]; |
| 316 |
}; |
}; |
| 393 |
Int_t chdone[4] = {0,0,0,0}; |
Int_t chdone[4] = {0,0,0,0}; |
| 394 |
Int_t pe = 0; |
Int_t pe = 0; |
| 395 |
// |
// |
| 396 |
|
Float_t ener0 = 0.; |
| 397 |
|
Float_t cbase0 = 0.; |
| 398 |
|
Bool_t pproblem = false; |
| 399 |
|
// |
| 400 |
|
Float_t tim = 0.; |
| 401 |
|
Int_t plo = 0; |
| 402 |
|
Int_t fbi = 0; |
| 403 |
|
Int_t cle = 0; |
| 404 |
|
// |
| 405 |
// run over views and planes |
// run over views and planes |
| 406 |
// |
// |
| 407 |
for (Int_t l = 0; l < 2; l++){ |
for (Int_t l = 0; l < 2; l++){ |
| 458 |
// run over preamplifiers |
// run over preamplifiers |
| 459 |
// |
// |
| 460 |
pre = -1; |
pre = -1; |
| 461 |
|
cbase0 = 0.; |
| 462 |
for (Int_t i = 0; i < 3; i++){ |
for (Int_t i = 0; i < 3; i++){ |
| 463 |
for (Int_t j = 0; j < 2; j++){ |
for (Int_t j = 0; j < 2; j++){ |
| 464 |
pre = j + i*2; |
pre = j + i*2; |
| 467 |
// |
// |
| 468 |
if ( !isRAW ) { |
if ( !isRAW ) { |
| 469 |
base[l][m][pre] = de->base[l][m][pre] ; |
base[l][m][pre] = de->base[l][m][pre] ; |
| 470 |
|
cbase0 += base[l][m][pre]; |
| 471 |
} else { |
} else { |
| 472 |
// |
// |
| 473 |
// if it is a raw event and we haven't checked |
// if it is a raw event and we haven't checked |
| 474 |
// yet, calculate the baseline. |
// yet, calculate the baseline. |
| 475 |
// |
// |
| 476 |
FindBaseRaw(l,m,pre); |
FindBaseRaw(l,m,pre); |
| 477 |
|
cbase0 += base[l][m][pre]; |
| 478 |
}; |
}; |
| 479 |
}; |
}; |
| 480 |
}; |
}; |
| 482 |
// run over strips |
// run over strips |
| 483 |
// |
// |
| 484 |
pre = -1; |
pre = -1; |
| 485 |
|
ener0 = 0.; |
| 486 |
for (Int_t i = 0 ; i < 3 ; i++){ |
for (Int_t i = 0 ; i < 3 ; i++){ |
| 487 |
ip[i] = 0; |
ip[i] = 0; |
| 488 |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
| 543 |
doneb = 1; |
doneb = 1; |
| 544 |
}; |
}; |
| 545 |
ener = dexyc[l][m][n]; |
ener = dexyc[l][m][n]; |
| 546 |
|
ener0 += ener; |
| 547 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
| 548 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
| 549 |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
| 575 |
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
| 576 |
}; |
}; |
| 577 |
}; |
}; |
| 578 |
}; |
}; |
| 579 |
|
// |
| 580 |
|
if ( ener0 == 0. && cbase0 == 0. && !pproblem ){ |
| 581 |
|
if ( verbose ) printf(" Calorimeter power problems! event marked as bad \n"); |
| 582 |
|
pproblem = true; |
| 583 |
|
pe++; |
| 584 |
|
}; |
| 585 |
// |
// |
| 586 |
Int_t j4 = -4; |
Int_t j4 = -4; |
| 587 |
Int_t jjj = -3; |
Int_t jjj = -3; |
| 601 |
}; |
}; |
| 602 |
if ( j4 >= 0 && j4 < 96 ){ |
if ( j4 >= 0 && j4 < 96 ){ |
| 603 |
// |
// |
| 604 |
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <===V============ IMPORTANT! =================> |
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <=============== IMPORTANT! =================> |
| 605 |
// |
// |
| 606 |
if ( clevel1->estrip[j4][m][l]!=0. && ( clevel1->estrip[j4][m][l] < clevel1->emin || calrms[l][m][j4] > 26 )){ |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
| 607 |
clevel1->estrip[j4][m][l] = 0.; |
clevel1->estrip[j4][m][l] = 0.; |
| 608 |
}; |
}; |
| 609 |
|
// |
| 610 |
|
// code and save the energy for each strip in svstrip |
| 611 |
|
// |
| 612 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
| 613 |
|
// |
| 614 |
|
tim = 100000.; |
| 615 |
|
plo = m; |
| 616 |
|
fbi = 0; |
| 617 |
|
if ( clevel1->estrip[j4][m][l] > 1. ){ |
| 618 |
|
tim = 10000.; |
| 619 |
|
plo = m; |
| 620 |
|
fbi = 1; |
| 621 |
|
}; |
| 622 |
|
if ( clevel1->estrip[j4][m][l] > 10. ){ |
| 623 |
|
tim = 1000.; |
| 624 |
|
plo = 22 + m; |
| 625 |
|
fbi = 1; |
| 626 |
|
}; |
| 627 |
|
if ( clevel1->estrip[j4][m][l] > 100. ){ |
| 628 |
|
tim = 100.; |
| 629 |
|
plo = 22 + m; |
| 630 |
|
fbi = 0; |
| 631 |
|
}; |
| 632 |
|
if ( clevel1->estrip[j4][m][l] > 1000. ){ |
| 633 |
|
tim = 10.; |
| 634 |
|
plo = 44 + m; |
| 635 |
|
fbi = 0; |
| 636 |
|
}; |
| 637 |
|
if ( clevel1->estrip[j4][m][l] > 10000. ){ |
| 638 |
|
tim = 1.; |
| 639 |
|
plo = 66 + m; |
| 640 |
|
fbi = 0; |
| 641 |
|
}; |
| 642 |
|
// |
| 643 |
|
cle = (Int_t)lroundf(tim*clevel1->estrip[j4][m][l]); |
| 644 |
|
// |
| 645 |
if ( l == 0 ){ |
if ( l == 0 ){ |
| 646 |
// |
// |
| 647 |
// +-PPSSmmmm.mmmm |
// +-PPSSmmmm.mmmm |
| 648 |
// |
// |
| 649 |
svstrip[istrip] = ((Float_t)m)*1000000. + ((Float_t)j4)*10000. + clevel1->estrip[j4][m][l]; |
svstrip[istrip] = fbi*1000000000 + plo*10000000 + j4*100000 + cle; |
| 650 |
} else { |
} else { |
| 651 |
svstrip[istrip] = -(((Float_t)m)*1000000. + ((Float_t)j4)*10000. + clevel1->estrip[j4][m][l]); |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
| 652 |
}; |
}; |
| 653 |
|
// if ( ei == 770 ) printf(" j %i l %i m %i estrip %f \n",j4,l,m,clevel1->estrip[j4][m][l]); |
| 654 |
|
// 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); |
| 655 |
|
// if ( ei == 770 ) printf(" svstrip %i \n",svstrip[istrip]); |
| 656 |
|
// |
| 657 |
istrip++; |
istrip++; |
| 658 |
}; |
}; |
| 659 |
}; |
}; |
| 747 |
memcpy(ca->perr,clevel2->perr,sizeof(clevel2->perr)); |
memcpy(ca->perr,clevel2->perr,sizeof(clevel2->perr)); |
| 748 |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
| 749 |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
|
ca->estrip = TArrayF(0,svstrip); |
|
| 750 |
ca->nstrip = (Int_t)clevel2->nstrip; |
ca->nstrip = (Int_t)clevel2->nstrip; |
| 751 |
ca->qtot = clevel2->qtot; |
ca->qtot = clevel2->qtot; |
| 752 |
ca->impx = clevel2->impx; |
ca->impx = clevel2->impx; |
| 758 |
ca->qmax = clevel2->qmax; |
ca->qmax = clevel2->qmax; |
| 759 |
ca->elen = clevel2->elen; |
ca->elen = clevel2->elen; |
| 760 |
ca->selen = clevel2->selen; |
ca->selen = clevel2->selen; |
| 761 |
ca->estrip = TArrayF(ca->nstrip,svstrip); |
ca->estrip = TArrayI(ca->nstrip,svstrip); |
| 762 |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
| 763 |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
| 764 |
memcpy(ca->varcfit,clevel2->varcfit,sizeof(clevel2->varcfit)); |
memcpy(ca->varcfit,clevel2->varcfit,sizeof(clevel2->varcfit)); |
| 894 |
return; |
return; |
| 895 |
} |
} |
| 896 |
|
|
| 897 |
Int_t CaloProcessing::Update(TSQLServer *dbc, ULong64_t atime, Int_t s){ |
Int_t CaloProcessing::Update(TSQLServer *dbc, UInt_t atime, Int_t s){ |
| 898 |
// |
// |
| 899 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
| 900 |
// |
// |
| 902 |
// |
// |
| 903 |
sgnl = 0; |
sgnl = 0; |
| 904 |
// |
// |
| 905 |
idcalib[s] = 0ULL; |
idcalib[s] = 0; |
| 906 |
fromtime[s] = 0ULL; |
fromtime[s] = 0; |
| 907 |
totime[s] = 0ULL; |
totime[s] = 0; |
| 908 |
calibno[s] = 0; |
calibno[s] = 0; |
| 909 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 910 |
// |
// |
| 911 |
sgnl = glcalo->Query_GL_CALO_CALIB(atime,s,dbc); |
UInt_t uptime = 0; |
| 912 |
|
// |
| 913 |
|
sgnl = glcalo->Query_GL_CALO_CALIB(atime,uptime,s,dbc); |
| 914 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
| 915 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 916 |
return(sgnl); |
return(sgnl); |
| 917 |
}; |
}; |
| 918 |
// |
// |
| 919 |
idcalib[s] = glcalo->ID_REG_CALIBCALPED; |
idcalib[s] = glcalo->ID_ROOT_L0; |
| 920 |
fromtime[s] = glcalo->FROM_TIME; |
fromtime[s] = glcalo->FROM_TIME; |
| 921 |
totime[s] = glcalo->TO_TIME; |
if ( glcalo->TO_TIME < atime ){ // calibration is corrupted and we are using the one that preceed the good one |
| 922 |
calibno[s] = glcalo->EV_REG_CALIBCALPED; |
totime[s] = uptime; |
| 923 |
|
} else { |
| 924 |
|
totime[s] = glcalo->TO_TIME; |
| 925 |
|
}; |
| 926 |
|
// totime[s] = glcalo->TO_TIME; |
| 927 |
|
calibno[s] = glcalo->EV_ROOT; |
| 928 |
// |
// |
| 929 |
if ( totime[s] == 0ULL){ |
if ( totime[s] == 0 ){ |
| 930 |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
| 931 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 932 |
sgnl = 100; |
sgnl = 100; |
| 950 |
name << glroot->NAME.Data(); |
name << glroot->NAME.Data(); |
| 951 |
// |
// |
| 952 |
fcalname[s] = (TString)name.str().c_str(); |
fcalname[s] = (TString)name.str().c_str(); |
| 953 |
if ( verbose ) printf(" - event at time %llu. From time %llu to time %llu \n use file %s \n calibration at entry %i \n\n",atime,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
if ( verbose ) printf(" - event at time %u. From time %u to time %u \n use file %s \n calibration at entry %i \n\n",atime,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
| 954 |
// |
// |
| 955 |
sgnl = LoadCalib(s); |
sgnl = LoadCalib(s); |
| 956 |
// |
// |
| 976 |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
| 977 |
if ( !tr ) return(-109); |
if ( !tr ) return(-109); |
| 978 |
// |
// |
|
TBranch *registry = tr->GetBranch("Registry"); |
|
| 979 |
TBranch *calo = tr->GetBranch("CalibCalPed"); |
TBranch *calo = tr->GetBranch("CalibCalPed"); |
| 980 |
// |
// |
|
pamela::RegistryEvent *reg = 0; |
|
| 981 |
pamela::CalibCalPedEvent *ce = 0; |
pamela::CalibCalPedEvent *ce = 0; |
| 982 |
tr->SetBranchAddress("CalibCalPed", &ce); |
tr->SetBranchAddress("CalibCalPed", &ce); |
|
tr->SetBranchAddress("Registry", ®); |
|
| 983 |
// |
// |
| 984 |
Long64_t ncalibs = registry->GetEntries(); |
Long64_t ncalibs = calo->GetEntries(); |
| 985 |
// |
// |
| 986 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
| 987 |
// |
// |
| 988 |
registry->GetEntry(calibno[s]); |
calo->GetEntry(calibno[s]); |
|
// |
|
|
calo->GetEntry(reg->event); |
|
| 989 |
// |
// |
| 990 |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
| 991 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
for ( Int_t d=0 ; d<11 ;d++ ){ |