| 87 |
/** |
/** |
| 88 |
* Initialize CaloLevel0 object |
* Initialize CaloLevel0 object |
| 89 |
**/ |
**/ |
| 90 |
void CaloLevel0::ProcessingInit(TSQLServer *dbc, 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){ |
| 91 |
|
// |
| 92 |
|
const TString host = glt->CGetHost(); |
| 93 |
|
const TString user = glt->CGetUser(); |
| 94 |
|
const TString psw = glt->CGetPsw(); |
| 95 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 96 |
|
if ( !dbc->IsConnected() ) throw -116; |
| 97 |
// |
// |
| 98 |
debug = isdeb; |
debug = isdeb; |
| 99 |
verbose = isverb; |
verbose = isverb; |
| 170 |
// |
// |
| 171 |
delete glcalo; |
delete glcalo; |
| 172 |
delete glroot; |
delete glroot; |
| 173 |
|
dbc->Close(); |
| 174 |
|
delete dbc; |
| 175 |
// |
// |
| 176 |
return; |
return; |
| 177 |
// |
// |
| 178 |
} |
} |
| 179 |
|
|
| 180 |
Int_t CaloLevel0::ChkCalib(TSQLServer *dbc, UInt_t atime){ |
Int_t CaloLevel0::ChkCalib(GL_TABLES *glt, UInt_t atime){ |
| 181 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
| 182 |
for ( Int_t s = 0; s < 4; s++){ |
for ( Int_t s = 0; s < 4; s++){ |
| 183 |
if ( atime > totime[s] ){ |
if ( atime > totime[s] ){ |
| 184 |
if ( !dbc->IsConnected() ) throw -116; |
sgnl = Update(glt,atime,s); |
|
sgnl = Update(dbc,atime,s); |
|
| 185 |
if ( sgnl < 0 ) return(sgnl); |
if ( sgnl < 0 ) return(sgnl); |
| 186 |
}; |
}; |
| 187 |
}; |
}; |
| 188 |
return(sgnl); |
return(sgnl); |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
| 192 |
|
const TString host = glt->CGetHost(); |
| 193 |
|
const TString user = glt->CGetUser(); |
| 194 |
|
const TString psw = glt->CGetPsw(); |
| 195 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 196 |
|
if ( !dbc->IsConnected() ) throw -116; |
| 197 |
|
// |
| 198 |
stringstream calfile; |
stringstream calfile; |
| 199 |
stringstream bmfile; |
stringstream bmfile; |
| 200 |
stringstream aligfile; |
stringstream aligfile; |
| 204 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
| 205 |
// |
// |
| 206 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
| 207 |
|
// |
| 208 |
|
// |
| 209 |
|
// |
| 210 |
|
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
| 211 |
|
// |
| 212 |
calopar1 = false; |
calopar1 = false; |
| 213 |
// |
// |
| 214 |
// determine where I can find calorimeter ADC to MIP conversion file |
// determine where I can find calorimeter ADC to MIP conversion file |
| 236 |
for (Int_t k = 0; k < 22; k++ ){ |
for (Int_t k = 0; k < 22; k++ ){ |
| 237 |
for (Int_t l = 0; l < 96; l++ ){ |
for (Int_t l = 0; l < 96; l++ ){ |
| 238 |
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
| 239 |
|
if ( debug ) printf(" %f \n",mip[m][k][l]); |
| 240 |
}; |
}; |
| 241 |
}; |
}; |
| 242 |
}; |
}; |
| 244 |
}; |
}; |
| 245 |
// |
// |
| 246 |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
| 247 |
|
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
| 248 |
calopar2 = false; |
calopar2 = false; |
| 249 |
// |
// |
| 250 |
// determine where I can find calorimeter alignment file |
// determine where I can find calorimeter alignment file |
| 260 |
ftcalopar2 = glparam->FROM_TIME; |
ftcalopar2 = glparam->FROM_TIME; |
| 261 |
ttcalopar2 = glparam->TO_TIME; |
ttcalopar2 = glparam->TO_TIME; |
| 262 |
// |
// |
| 263 |
if ( verbose ) printf("\n Using alignment file: \n %s \n",aligfile.str().c_str()); |
if ( verbose ) printf("\n Using parameter file: \n %s \n",aligfile.str().c_str()); |
| 264 |
f = fopen(aligfile.str().c_str(),"rb"); |
f = fopen(aligfile.str().c_str(),"rb"); |
| 265 |
if ( !f ){ |
if ( !f ){ |
| 266 |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: no parameter file!\n"); |
| 267 |
return(-106); |
return(-106); |
| 268 |
}; |
}; |
| 269 |
// |
// |
| 270 |
fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); |
if ( !mechal ){ |
| 271 |
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
// |
| 272 |
fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); |
fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); |
| 273 |
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
| 274 |
fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); |
fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); |
| 275 |
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
| 276 |
|
fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); |
| 277 |
|
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
| 278 |
|
} else { |
| 279 |
|
if ( verbose ) printf("\n Using MECHANICAL alignement parameters \n"); |
| 280 |
|
// |
| 281 |
|
CaloStrip cs = CaloStrip(); |
| 282 |
|
cs.UseMechanicalAlig(); |
| 283 |
|
clevel1->xalig = cs.GetXalig(); |
| 284 |
|
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
| 285 |
|
clevel1->yalig = cs.GetYalig(); |
| 286 |
|
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
| 287 |
|
clevel1->zalig = cs.GetZalig(); |
| 288 |
|
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
| 289 |
|
// |
| 290 |
|
Float_t tmp = 0; |
| 291 |
|
fread(&tmp,sizeof(clevel1->xalig),1,f); |
| 292 |
|
fread(&tmp,sizeof(clevel1->yalig),1,f); |
| 293 |
|
fread(&tmp,sizeof(clevel1->zalig),1,f); |
| 294 |
|
// |
| 295 |
|
}; |
| 296 |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
| 297 |
if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); |
if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); |
| 298 |
// |
// |
| 302 |
// Load offline bad strip mask |
// Load offline bad strip mask |
| 303 |
// |
// |
| 304 |
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
| 305 |
|
if ( debug ) printf(" calopar3 %i ftcalopar3 %u ttcalopar3 %u runheader %u \n",calopar3,ftcalopar3,ttcalopar3,runheader); |
| 306 |
calopar3 = false; |
calopar3 = false; |
| 307 |
// |
// |
| 308 |
// determine where I can find calorimeter alignment file |
// determine where I can find calorimeter alignment file |
| 350 |
}; |
}; |
| 351 |
// |
// |
| 352 |
delete glparam; |
delete glparam; |
| 353 |
|
dbc->Close(); |
| 354 |
|
delete dbc; |
| 355 |
// |
// |
| 356 |
return(0); |
return(0); |
| 357 |
} |
} |
| 414 |
// |
// |
| 415 |
Int_t val = 0; |
Int_t val = 0; |
| 416 |
Int_t del = 1100; |
Int_t del = 1100; |
| 417 |
|
for (Int_t sec = 0; sec < 4; sec++){ |
| 418 |
|
for (Int_t dsec = 0; dsec < 7; dsec++){ |
| 419 |
|
val = (Int_t)de->calselftrig[sec][dsec]; |
| 420 |
|
del = delay(val); |
| 421 |
|
clevel2->selfdelay[sec][dsec] = del; |
| 422 |
|
}; |
| 423 |
|
}; |
| 424 |
|
val = 0; |
| 425 |
|
del = 1100; |
| 426 |
if ( clevel2->trigty != 2. ){ |
if ( clevel2->trigty != 2. ){ |
| 427 |
Bool_t ck = false; |
Bool_t ck = false; |
| 428 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
| 484 |
for (Int_t l = 0; l < 2; l++){ |
for (Int_t l = 0; l < 2; l++){ |
| 485 |
for (Int_t m = 0; m < 22; m++){ |
for (Int_t m = 0; m < 22; m++){ |
| 486 |
// |
// |
| 487 |
// determine the section number |
// determine the section number |
| 488 |
// |
// |
| 489 |
se = 5; |
se = 5; |
| 490 |
if (l == 0 && m%2 == 0) se = 3; |
if (l == 0 && m%2 == 0) se = 3; |
| 491 |
if (l == 0 && m%2 != 0) se = 2; |
if (l == 0 && m%2 != 0) se = 2; |
| 492 |
if (l == 1 && m%2 == 0) se = 1; |
if (l == 1 && m%2 != 0) se = 1; |
| 493 |
if (l == 1 && m%2 != 0) se = 0; |
if (l == 1 && m%2 == 0) se = 0; |
| 494 |
// |
// |
| 495 |
// determine what kind of event we are going to analyze |
// determine what kind of event we are going to analyze |
| 496 |
// |
// |
| 584 |
} else { |
} else { |
| 585 |
ip[i] = pre - 1; |
ip[i] = pre - 1; |
| 586 |
}; |
}; |
| 587 |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0.) ){ |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
| 588 |
// |
// |
| 589 |
ck = 2; |
ck = 2; |
| 590 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
| 598 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
| 599 |
// |
// |
| 600 |
if ( !doneb ){ |
if ( !doneb ){ |
| 601 |
|
if ( debug ) printf(" ck is %i \n",ck); |
| 602 |
switch (ck) { |
switch (ck) { |
| 603 |
case 0: |
case 0: |
| 604 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
| 605 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 606 |
|
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
| 607 |
break; |
break; |
| 608 |
case 1: |
case 1: |
| 609 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
| 610 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
| 611 |
|
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]]); |
| 612 |
break; |
break; |
| 613 |
case 2: |
case 2: |
| 614 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
| 615 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 616 |
|
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
| 617 |
break; |
break; |
| 618 |
case 3: |
case 3: |
| 619 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
| 620 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 621 |
|
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
| 622 |
break; |
break; |
| 623 |
}; |
}; |
| 624 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
| 628 |
ener0 += ener; |
ener0 += ener; |
| 629 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
| 630 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
| 631 |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
// if ( !donec && (base0 - base1 + base2) != 0. ){ |
| 632 |
sbase[l][m][pre] = base0 - base1 + base2; |
// sbase[l][m][pre] = base0 - base1 + base2; |
| 633 |
|
if ( !donec && (base0 + base1 - base2) != 0. ){ |
| 634 |
|
sbase[l][m][pre] = base0 + base1 - base2; |
| 635 |
donec = 1; |
donec = 1; |
| 636 |
}; |
}; |
| 637 |
if ( ener > 0. ){ |
if ( ener > 0. ){ |
| 640 |
// 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) |
| 641 |
// |
// |
| 642 |
qpre[pre] += clevel1->estrip[n][m][l]; |
qpre[pre] += clevel1->estrip[n][m][l]; |
| 643 |
|
// |
| 644 |
|
// |
| 645 |
}; |
}; |
| 646 |
}; |
}; |
| 647 |
}; |
}; |
| 810 |
memcpy(t_ca->tibar,clevel2->cibar,sizeof(clevel2->cibar)); |
memcpy(t_ca->tibar,clevel2->cibar,sizeof(clevel2->cibar)); |
| 811 |
memcpy(t_ca->tbar,clevel2->cbar,sizeof(clevel2->cbar)); |
memcpy(t_ca->tbar,clevel2->cbar,sizeof(clevel2->cbar)); |
| 812 |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
| 813 |
|
memcpy(ca->selfdelay,clevel2->selfdelay,sizeof(clevel2->selfdelay)); |
| 814 |
ca->varcfit[2] = clevel2->varcfit[0]; |
ca->varcfit[2] = clevel2->varcfit[0]; |
| 815 |
ca->varcfit[3] = clevel2->varcfit[1]; |
ca->varcfit[3] = clevel2->varcfit[1]; |
| 816 |
ca->npcfit[2] = clevel2->npcfit[0]; |
ca->npcfit[2] = clevel2->npcfit[0]; |
| 863 |
ca->selen = clevel2->selen; |
ca->selen = clevel2->selen; |
| 864 |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
| 865 |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
| 866 |
|
memcpy(ca->selfdelay,clevel2->selfdelay,sizeof(clevel2->selfdelay)); |
| 867 |
ca->varcfit[0] = clevel2->varcfit[0]; |
ca->varcfit[0] = clevel2->varcfit[0]; |
| 868 |
ca->varcfit[1] = clevel2->varcfit[1]; |
ca->varcfit[1] = clevel2->varcfit[1]; |
| 869 |
ca->npcfit[0] = clevel2->npcfit[0]; |
ca->npcfit[0] = clevel2->npcfit[0]; |
| 954 |
memset(clevel2->varcfit, 0, 4*sizeof(Float_t)); |
memset(clevel2->varcfit, 0, 4*sizeof(Float_t)); |
| 955 |
memset(clevel2->npcfit, 0, 4*sizeof(Int_t)); |
memset(clevel2->npcfit, 0, 4*sizeof(Int_t)); |
| 956 |
memset(clevel2->planemax, 0, 2*sizeof(Int_t)); |
memset(clevel2->planemax, 0, 2*sizeof(Int_t)); |
| 957 |
|
memset(clevel2->selfdelay, 0, 4*7*sizeof(Int_t)); |
| 958 |
memset(clevel2->fmode, 0, 2*sizeof(Int_t)); |
memset(clevel2->fmode, 0, 2*sizeof(Int_t)); |
| 959 |
memset(clevel2->cibar, 0, 2*22*sizeof(Int_t)); |
memset(clevel2->cibar, 0, 2*22*sizeof(Int_t)); |
| 960 |
memset(clevel2->cbar, 0, 2*22*sizeof(Float_t)); |
memset(clevel2->cbar, 0, 2*22*sizeof(Float_t)); |
| 1011 |
return; |
return; |
| 1012 |
} |
} |
| 1013 |
|
|
| 1014 |
Int_t CaloLevel0::Update(TSQLServer *dbc, UInt_t atime, Int_t s){ |
Int_t CaloLevel0::Update(GL_TABLES *glt, UInt_t atime, Int_t s){ |
| 1015 |
// |
// |
| 1016 |
|
const TString host = glt->CGetHost(); |
| 1017 |
|
const TString user = glt->CGetUser(); |
| 1018 |
|
const TString psw = glt->CGetPsw(); |
| 1019 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 1020 |
|
if ( !dbc->IsConnected() ) throw -116; |
| 1021 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
| 1022 |
// |
// |
| 1023 |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |