158 |
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
159 |
dbc->Close(); |
dbc->Close(); |
160 |
delete dbc; |
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){ |
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';"; |
169 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
170 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
171 |
// |
// |
172 |
debug = isdeb; |
debug = isdeb; |
173 |
verbose = isverb; |
verbose = isverb; |
273 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
274 |
stringstream myquery; |
stringstream myquery; |
275 |
myquery.str(""); |
myquery.str(""); |
276 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00';"; |
277 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
278 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
279 |
// |
// |
280 |
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
281 |
dbc->Close(); |
dbc->Close(); |
282 |
delete dbc; |
delete dbc; |
283 |
|
dbc = 0; |
284 |
return(sig); |
return(sig); |
285 |
} |
} |
286 |
|
|
600 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
601 |
stringstream myquery; |
stringstream myquery; |
602 |
myquery.str(""); |
myquery.str(""); |
603 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00';"; |
604 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
605 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
606 |
// |
// |
607 |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,usetable); |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,usetable); |
608 |
dbc->Close(); |
dbc->Close(); |
609 |
delete dbc; |
delete dbc; |
610 |
|
dbc = 0; |
611 |
// |
// |
612 |
return(sig); |
return(sig); |
613 |
// |
// |
621 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
622 |
stringstream myquery; |
stringstream myquery; |
623 |
myquery.str(""); |
myquery.str(""); |
624 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00';"; |
625 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
626 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
627 |
// |
// |
628 |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
629 |
dbc->Close(); |
dbc->Close(); |
630 |
delete dbc; |
delete dbc; |
631 |
|
dbc = 0; |
632 |
// |
// |
633 |
return(sig); |
return(sig); |
634 |
// |
// |
749 |
// |
// |
750 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
751 |
// |
// |
752 |
calo->GetEntry(calibno); |
if ( calo->GetEntry(calibno) <= 0) throw -36; |
753 |
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
754 |
// |
// |
755 |
// retrieve calibration table |
// retrieve calibration table |
830 |
// |
// |
831 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
832 |
// |
// |
833 |
calo1->GetEntry(calibno); |
if ( calo1->GetEntry(calibno) <= 0 ) throw -36; |
834 |
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
835 |
// |
// |
836 |
// retrieve calibration table |
// retrieve calibration table |
1168 |
if ( strip6s < 4 && base[l][m][pre] > (-0.015*qp+sbase[l][m][pre]) && sbase[l][m][pre] > 0. ){ |
if ( strip6s < 4 && base[l][m][pre] > (-0.015*qp+sbase[l][m][pre]) && sbase[l][m][pre] > 0. ){ |
1169 |
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); |
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); |
1170 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
1171 |
|
nst = 0; // 9RED BUG |
1172 |
|
qp = 0.; // 9RED BUG |
1173 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1174 |
dexyc[l][m][e] = dexy[l][m][e]; |
dexyc[l][m][e] = dexy[l][m][e]; |
1175 |
}; |
}; |
1176 |
}; |
}; |
1177 |
} else { |
} else { |
1178 |
|
if ( debug ) printf(" reset baseline here if ! ( (strip6s >=2 && process == 2) || (strip6s >= 9 and process > 2) ) \n"); |
1179 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
1180 |
|
nst = 0; // 9RED BUG |
1181 |
|
qp = 0.; // 9RED BUG |
1182 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1183 |
dexyc[l][m][e] = dexy[l][m][e]; |
dexyc[l][m][e] = dexy[l][m][e]; |
1184 |
}; |
}; |
1185 |
}; |
}; |
1186 |
} else { |
} else { |
1187 |
|
if ( debug ) printf(" reset baseline here if no minimum find\n"); |
1188 |
|
nst = 0; // 9RED BUG |
1189 |
|
qp = 0.; // 9RED BUG |
1190 |
process += 2; |
process += 2; |
1191 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
1192 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1194 |
}; |
}; |
1195 |
}; |
}; |
1196 |
}; |
}; |
1197 |
|
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); |
1198 |
} |
} |
1199 |
|
|
1200 |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
1201 |
// |
// |
1202 |
// get entry ei |
// get entry ei |
1203 |
// |
// |
1204 |
l0calo->GetEntry(ei); |
if ( l0calo->GetEntry(ei) <= 0 ) throw -36; |
1205 |
// |
// |
1206 |
// 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. |
1207 |
// |
// |
1218 |
val = 0; |
val = 0; |
1219 |
del = 1000; |
del = 1000; |
1220 |
if ( clevel2->trigty < 2. ){ |
if ( clevel2->trigty < 2. ){ |
1221 |
Bool_t ck = false; |
// Bool_t ck = false; |
1222 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
1223 |
val = (Int_t)de->calselftrig[sec][6]; |
val = (Int_t)de->calselftrig[sec][6]; |
1224 |
del = delay(val); |
del = delay(val); |
1225 |
if ( del < 1000 ){ |
if ( del < 1000 ){ |
1226 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
1227 |
clevel2->trigty = 3.; |
clevel2->trigty = 3.; |
1228 |
ck = true; |
// ck = true; |
1229 |
break; |
break; |
1230 |
}; |
}; |
1231 |
}; |
}; |
1246 |
Int_t se = 5; |
Int_t se = 5; |
1247 |
Int_t done = 0; |
Int_t done = 0; |
1248 |
Int_t pre = -1; |
Int_t pre = -1; |
1249 |
Bool_t isCOMP = false; |
// Bool_t isCOMP = false; |
1250 |
Bool_t isFULL = false; |
// Bool_t isFULL = false; |
1251 |
Bool_t isRAW = false; |
Bool_t isRAW = false; |
1252 |
Float_t ener; |
Float_t ener; |
1253 |
Int_t doneb = 0; |
Int_t doneb = 0; |
1270 |
// |
// |
1271 |
Float_t ener0 = 0.; |
Float_t ener0 = 0.; |
1272 |
Float_t cbase0 = 0.; |
Float_t cbase0 = 0.; |
1273 |
|
Float_t totbase = 0.; |
1274 |
|
Float_t totped = 0.; |
1275 |
Bool_t pproblem = false; |
Bool_t pproblem = false; |
1276 |
Bool_t negbase = false; |
Bool_t negbase = false; |
1277 |
// |
// |
1296 |
// |
// |
1297 |
// determine what kind of event we are going to analyze |
// determine what kind of event we are going to analyze |
1298 |
// |
// |
1299 |
isCOMP = false; |
// isCOMP = false; |
1300 |
isFULL = false; |
// isFULL = false; |
1301 |
isRAW = false; |
isRAW = false; |
1302 |
if ( de->stwerr[se] & (1 << 16) ) isCOMP = true; |
// if ( de->stwerr[se] & (1 << 16) ) isCOMP = true; |
1303 |
if ( de->stwerr[se] & (1 << 17) ) isFULL = true; |
// if ( de->stwerr[se] & (1 << 17) ) isFULL = true; |
1304 |
if ( de->stwerr[se] & (1 << 3) ) isRAW = true; |
if ( de->stwerr[se] & (1 << 3) ) isRAW = true; |
1305 |
if ( !chdone[se] ){ |
if ( !chdone[se] ){ |
1306 |
// |
// |
1386 |
// |
// |
1387 |
pre = -1; |
pre = -1; |
1388 |
ener0 = 0.; |
ener0 = 0.; |
1389 |
|
totbase = 0.; |
1390 |
|
totped = 0.; |
1391 |
for (Int_t i = 0 ; i < 3 ; i++){ |
for (Int_t i = 0 ; i < 3 ; i++){ |
1392 |
ip[i] = 0; |
ip[i] = 0; |
1393 |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
1405 |
// no suitable new baseline, use old ones! |
// no suitable new baseline, use old ones! |
1406 |
// |
// |
1407 |
if ( !done ){ |
if ( !done ){ |
1408 |
|
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]); |
1409 |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
1410 |
ck[l][m][pre] = 1; |
ck[l][m][pre] = 1; |
1411 |
if (pre%2 == 0) { |
if (pre%2 == 0) { |
1456 |
ener = dexyc[l][m][n]; |
ener = dexyc[l][m][n]; |
1457 |
ener0 += ener; |
ener0 += ener; |
1458 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
1459 |
|
totbase += de->base[l][m][pre]/96.; |
1460 |
|
totped += fabs(calped[l][m][n]); |
1461 |
if ( de->base[l][m][pre] < 0 ) negbase = true; |
if ( de->base[l][m][pre] < 0 ) negbase = true; |
1462 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
1463 |
// |
// |
1472 |
// |
// |
1473 |
// 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) |
1474 |
// |
// |
1475 |
|
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]); |
1476 |
if ( clevel1->estrip[n][m][l] > 0. ) qpre[l][m][pre] += clevel1->estrip[n][m][l]; |
if ( clevel1->estrip[n][m][l] > 0. ) qpre[l][m][pre] += clevel1->estrip[n][m][l]; |
1477 |
// |
// |
1478 |
// |
// |
1482 |
}; |
}; |
1483 |
// |
// |
1484 |
// check if there were problems with 5.7 or glitches in the power supply |
// check if there were problems with 5.7 or glitches in the power supply |
1485 |
// |
// |
1486 |
if ( ((ener0 == 0. && cbase0 == 0.) || negbase ) && !pproblem && clevel2->perr[se] == 0){ |
// 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.] |
1487 |
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); |
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.] |
1488 |
|
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); |
1489 |
pproblem = true; |
pproblem = true; |
1490 |
pe++; |
pe++; |
1491 |
}; |
}; |
1517 |
// |
// |
1518 |
// Cross-talk corrections |
// Cross-talk corrections |
1519 |
// |
// |
1520 |
if ( crosst ){ |
if ( crosst ){ |
1521 |
// |
// |
1522 |
// energy on silicon ladders |
// energy on silicon ladders |
1523 |
// |
// |
1534 |
if ( noselfct ){ |
if ( noselfct ){ |
1535 |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
1536 |
ipre = j/16 ; |
ipre = j/16 ; |
1537 |
|
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]); |
1538 |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] -= clevel1->estrip[j][m][l] * ctprecor[l][m][ipre]; |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] -= clevel1->estrip[j][m][l] * ctprecor[l][m][ipre]; |
1539 |
|
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]); |
1540 |
}; |
}; |
1541 |
}; |
}; |
1542 |
// |
// |
1558 |
// |
// |
1559 |
if ( debug ) printf(" CK1 Limit for while: 0.07 \n"); |
if ( debug ) printf(" CK1 Limit for while: 0.07 \n"); |
1560 |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
1561 |
|
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]); |
1562 |
if ( !ctground ){ |
if ( !ctground ){ |
1563 |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * ctprecor[l][m][ipp]; |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * ctprecor[l][m][ipp]; |
1564 |
} else { |
} else { |
1565 |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * 0.00478; |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * 0.00478; |
1566 |
}; |
}; |
1567 |
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
1568 |
|
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]); |
1569 |
}; |
}; |
1570 |
qpre[l][m][ipre] = nqpre; |
qpre[l][m][ipre] = nqpre; |
1571 |
nqpre = 0.; |
nqpre = 0.; |
1576 |
while ( it < 10 && deltaqpre > 0.07 ){ |
while ( it < 10 && deltaqpre > 0.07 ){ |
1577 |
nqpre = 0.; |
nqpre = 0.; |
1578 |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
1579 |
|
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]); |
1580 |
if ( !ctground ){ |
if ( !ctground ){ |
1581 |
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]); |
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]); |
1582 |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * ctprecor[l][m][ipre]; |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * ctprecor[l][m][ipre]; |
1584 |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * 0.00478; |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * 0.00478; |
1585 |
}; |
}; |
1586 |
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
1587 |
|
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]); |
1588 |
}; |
}; |
1589 |
if ( ctground ) it = 100; |
if ( ctground ) it = 100; |
1590 |
it++; |
it++; |
1691 |
nqpre[0] = 0.; |
nqpre[0] = 0.; |
1692 |
nqpre[1] = 0.; |
nqpre[1] = 0.; |
1693 |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
1694 |
|
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]); |
1695 |
ipre = 0; |
ipre = 0; |
1696 |
if ( j > (ladder*32)+15 ) ipre = 1; |
if ( j > (ladder*32)+15 ) ipre = 1; |
1697 |
jpre = j/16 ; |
jpre = j/16 ; |
1707 |
}; |
}; |
1708 |
if ( clevel1->estrip[j][m][l] > 0. ) nqsi += clevel1->estrip[j][m][l] ; |
if ( clevel1->estrip[j][m][l] > 0. ) nqsi += clevel1->estrip[j][m][l] ; |
1709 |
if ( clevel1->estrip[j][m][l] > 0. ) nqpre[ipre] += clevel1->estrip[j][m][l] ; |
if ( clevel1->estrip[j][m][l] > 0. ) nqpre[ipre] += clevel1->estrip[j][m][l] ; |
1710 |
|
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]); |
1711 |
}; |
}; |
1712 |
if ( ctground ) it = 100; |
if ( ctground ) it = 100; |
1713 |
deltaqsi = nqsi-snqsi; |
deltaqsi = nqsi-snqsi; |
|
snqsi = nqsi; |
|
|
it++; |
|
1714 |
deltaqpre[0] = nqpre[0] - qpre[l][m][pre-1]; |
deltaqpre[0] = nqpre[0] - qpre[l][m][pre-1]; |
1715 |
deltaqpre[1] = nqpre[1] - qpre[l][m][pre]; |
deltaqpre[1] = nqpre[1] - qpre[l][m][pre]; |
1716 |
|
// |
1717 |
|
// Check for divergence and stop if it happens! [9RED bug noticed with plane 18X] |
1718 |
|
// |
1719 |
|
if ( deltaqpre[0] > qpre[l][m][pre-1] || deltaqpre[1] > qpre[l][m][pre] || deltaqsi >snqsi ){ |
1720 |
|
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); |
1721 |
|
it = 1000; |
1722 |
|
}; |
1723 |
|
// |
1724 |
|
snqsi = nqsi; |
1725 |
|
it++; |
1726 |
if ( debug ) printf(" BEFORE: qpre 0 %f qpre 1 %f \n",qpre[l][m][pre-1],qpre[l][m][pre]); |
if ( debug ) printf(" BEFORE: qpre 0 %f qpre 1 %f \n",qpre[l][m][pre-1],qpre[l][m][pre]); |
1727 |
qpre[l][m][pre-1] = nqpre[0]; |
qpre[l][m][pre-1] = nqpre[0]; |
1728 |
qpre[l][m][pre] = nqpre[1]; |
qpre[l][m][pre] = nqpre[1]; |
1758 |
jjj++; |
jjj++; |
1759 |
j4++; |
j4++; |
1760 |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
1761 |
if ( crosst ){ |
if ( crosst ){ |
1762 |
// |
// |
1763 |
// "Real" crosstalk effect on the neighbour strips respect to the one which have seen the energy deposit |
// "Real" crosstalk effect on the neighbour strips respect to the one which have seen the energy deposit |
1764 |
// |
// |
1794 |
clevel1->estrip[j4][m][l] = 0.; |
clevel1->estrip[j4][m][l] = 0.; |
1795 |
}; |
}; |
1796 |
// |
// |
1797 |
|
if ( debug ) printf(" STRIP: view %i plane %i strip %i energy: %f \n",l,m,j4,clevel1->estrip[j4][m][l]); |
1798 |
|
// |
1799 |
// code and save the energy for each strip in svstrip |
// code and save the energy for each strip in svstrip |
1800 |
// |
// |
1801 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
1802 |
// |
// |
1803 |
Float_t savel1 = clevel1->estrip[j4][m][l]; |
Float_t savel1 = clevel1->estrip[j4][m][l]; |
1804 |
|
// |
1805 |
|
if ( m == 18 && l == 0 ){ |
1806 |
|
if ( debug ) printf(" Resetting plane 18X for variable calculation: view %i plane %i strip %i \n",l,m,j4); |
1807 |
|
clevel1->estrip[j4][m][l] = 0.; // SAVE STRIPS VALUE FOR PLANE 18 X but DO NOT USE IT FOR VARIABLE CALCULATION |
1808 |
|
}; |
1809 |
|
if ( debug ) printf(" HIT STRIP: view %i plane %i strip %i energy: %f \n",l,m,j4,clevel1->estrip[j4][m][l]); |
1810 |
// if ( dexyc[l][m][j4] == 32767. ){ |
// if ( dexyc[l][m][j4] == 32767. ){ |
1811 |
if ( dexyc[l][m][j4] > 32000. ){ |
if ( dexyc[l][m][j4] > 32000. || savel1 > 5000.){ // CaloLevel1 bug with plane 18X [9RED 14/04/2010] |
1812 |
savel1 += 5000.; |
if ( savel1 > 5000 ){ |
1813 |
|
if ( debug ) printf(" Absurd plane 18X energy... resetting value to 1100 MIP \n"); |
1814 |
|
savel1 = 1100.; // CaloLevel1 bug with plane 18x [9RED 14/04/2010] |
1815 |
|
}; |
1816 |
|
savel1 += 5000.; |
1817 |
clevel2->nsatstrip += 1.; |
clevel2->nsatstrip += 1.; |
1818 |
}; |
}; |
1819 |
// |
// |
1856 |
} else { |
} else { |
1857 |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
1858 |
}; |
}; |
1859 |
|
if ( debug ) printf(" svstrip[%i] = %i fbi %i plo %i j4 %i cle %i \n",istrip,svstrip[istrip],fbi,plo,j4,cle); |
1860 |
// |
// |
1861 |
istrip++; |
istrip++; |
1862 |
}; |
}; |
1946 |
ClearTrkVar(); |
ClearTrkVar(); |
1947 |
} |
} |
1948 |
|
|
1949 |
|
void CaloLevel0::FillTrkVar(TClonesArray *tcl, Int_t nutrk){ |
1950 |
|
// |
1951 |
|
CaloTrkVar *t_ca = new CaloTrkVar(); |
1952 |
|
// |
1953 |
|
t_ca->trkseqno = trkseqno; |
1954 |
|
t_ca->ncore = (Int_t)clevel2->ncore; |
1955 |
|
t_ca->qcore = clevel2->qcore; |
1956 |
|
t_ca->noint = (Int_t)clevel2->noint; |
1957 |
|
t_ca->ncyl = (Int_t)clevel2->ncyl; |
1958 |
|
t_ca->qcyl = clevel2->qcyl; |
1959 |
|
t_ca->qtrack = clevel2->qtrack; |
1960 |
|
t_ca->qtrackx = clevel2->qtrackx; |
1961 |
|
t_ca->qtracky = clevel2->qtracky; |
1962 |
|
t_ca->dxtrack = clevel2->dxtrack; |
1963 |
|
t_ca->dytrack = clevel2->dytrack; |
1964 |
|
t_ca->qlast = clevel2->qlast; |
1965 |
|
t_ca->nlast = (Int_t)clevel2->nlast; |
1966 |
|
t_ca->qpre = clevel2->qpre; |
1967 |
|
t_ca->npre = (Int_t)clevel2->npre; |
1968 |
|
t_ca->qpresh = clevel2->qpresh; |
1969 |
|
t_ca->npresh = (Int_t)clevel2->npresh; |
1970 |
|
t_ca->qtr = clevel2->qtr; |
1971 |
|
t_ca->ntr = (Int_t)clevel2->ntr; |
1972 |
|
t_ca->planetot = (Int_t)clevel2->planetot; |
1973 |
|
t_ca->qmean = clevel2->qmean; |
1974 |
|
t_ca->dX0l = clevel2->dX0l; |
1975 |
|
t_ca->qlow = clevel2->qlow; |
1976 |
|
t_ca->nlow = (Int_t)clevel2->nlow; |
1977 |
|
// |
1978 |
|
memcpy(t_ca->tibar,clevel2->tibar,sizeof(clevel2->tibar)); |
1979 |
|
memcpy(t_ca->tbar,clevel2->tbar,sizeof(clevel2->tbar)); |
1980 |
|
// |
1981 |
|
// |
1982 |
|
TClonesArray &t = *tcl; |
1983 |
|
new(t[nutrk]) CaloTrkVar(*t_ca); |
1984 |
|
// |
1985 |
|
delete t_ca; |
1986 |
|
// |
1987 |
|
ClearTrkVar(); |
1988 |
|
} |
1989 |
|
|
1990 |
void CaloLevel0::GetCommonVar(){ |
void CaloLevel0::GetCommonVar(){ |
1991 |
calol2cm(); |
calol2cm(); |
1992 |
} |
} |
2037 |
}; |
}; |
2038 |
// |
// |
2039 |
} |
} |
2040 |
|
void CaloLevel0::FillCommonVar(CaloLevel1 *c1){ |
2041 |
|
if ( c1 ){ |
2042 |
|
c1->istrip = istrip; |
2043 |
|
c1->estrip = TArrayI(istrip,svstrip); |
2044 |
|
}; |
2045 |
|
// |
2046 |
|
} |
2047 |
|
|
2048 |
void CaloLevel0::ClearStructs(){ |
void CaloLevel0::ClearStructs(){ |
2049 |
ClearTrkVar(); |
ClearTrkVar(); |
2193 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
2194 |
stringstream myquery; |
stringstream myquery; |
2195 |
myquery.str(""); |
myquery.str(""); |
2196 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00';"; |
2197 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
2198 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
2199 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
2200 |
// |
// |
2201 |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
2285 |
// |
// |
2286 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
2287 |
// |
// |
2288 |
calo->GetEntry(calibno[s]); |
if ( calo->GetEntry(calibno[s]) <= 0 ) throw -36; |
2289 |
// |
// |
2290 |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
2291 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
for ( Int_t d=0 ; d<11 ;d++ ){ |