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 |
|
|
278 |
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
279 |
dbc->Close(); |
dbc->Close(); |
280 |
delete dbc; |
delete dbc; |
281 |
|
dbc = 0; |
282 |
return(sig); |
return(sig); |
283 |
} |
} |
284 |
|
|
604 |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,usetable); |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,usetable); |
605 |
dbc->Close(); |
dbc->Close(); |
606 |
delete dbc; |
delete dbc; |
607 |
|
dbc = 0; |
608 |
// |
// |
609 |
return(sig); |
return(sig); |
610 |
// |
// |
624 |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
625 |
dbc->Close(); |
dbc->Close(); |
626 |
delete dbc; |
delete dbc; |
627 |
|
dbc = 0; |
628 |
// |
// |
629 |
return(sig); |
return(sig); |
630 |
// |
// |
745 |
// |
// |
746 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
747 |
// |
// |
748 |
calo->GetEntry(calibno); |
if ( calo->GetEntry(calibno) <= 0) throw -36; |
749 |
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()); |
750 |
// |
// |
751 |
// retrieve calibration table |
// retrieve calibration table |
826 |
// |
// |
827 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
828 |
// |
// |
829 |
calo1->GetEntry(calibno); |
if ( calo1->GetEntry(calibno) <= 0 ) throw -36; |
830 |
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()); |
831 |
// |
// |
832 |
// retrieve calibration table |
// retrieve calibration table |
1164 |
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. ){ |
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); |
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.; |
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++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1170 |
dexyc[l][m][e] = dexy[l][m][e]; |
dexyc[l][m][e] = dexy[l][m][e]; |
1171 |
}; |
}; |
1172 |
}; |
}; |
1173 |
} else { |
} 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++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1179 |
dexyc[l][m][e] = dexy[l][m][e]; |
dexyc[l][m][e] = dexy[l][m][e]; |
1180 |
}; |
}; |
1181 |
}; |
}; |
1182 |
} else { |
} 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; |
process += 2; |
1187 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
1188 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; 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 |
// |
// |
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[l][m][pre] = 1; |
ck[l][m][pre] = 1; |
1407 |
if (pre%2 == 0) { |
if (pre%2 == 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 |
|
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]; |
if ( clevel1->estrip[n][m][l] > 0. ) qpre[l][m][pre] += clevel1->estrip[n][m][l]; |
1473 |
// |
// |
1474 |
// |
// |
1513 |
// |
// |
1514 |
// Cross-talk corrections |
// Cross-talk corrections |
1515 |
// |
// |
1516 |
if ( crosst ){ |
if ( crosst ){ |
1517 |
// |
// |
1518 |
// energy on silicon ladders |
// energy on silicon ladders |
1519 |
// |
// |
1530 |
if ( noselfct ){ |
if ( noselfct ){ |
1531 |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
1532 |
ipre = j/16 ; |
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]; |
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 |
// |
// |
1554 |
// |
// |
1555 |
if ( debug ) printf(" CK1 Limit for while: 0.07 \n"); |
if ( debug ) printf(" CK1 Limit for while: 0.07 \n"); |
1556 |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
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 ){ |
if ( !ctground ){ |
1559 |
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]; |
1560 |
} else { |
} else { |
1561 |
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; |
1562 |
}; |
}; |
1563 |
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] ; |
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; |
qpre[l][m][ipre] = nqpre; |
1567 |
nqpre = 0.; |
nqpre = 0.; |
1572 |
while ( it < 10 && deltaqpre > 0.07 ){ |
while ( it < 10 && deltaqpre > 0.07 ){ |
1573 |
nqpre = 0.; |
nqpre = 0.; |
1574 |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
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 ){ |
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]); |
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]; |
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * ctprecor[l][m][ipre]; |
1580 |
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; |
1581 |
}; |
}; |
1582 |
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] ; |
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; |
if ( ctground ) it = 100; |
1586 |
it++; |
it++; |
1687 |
nqpre[0] = 0.; |
nqpre[0] = 0.; |
1688 |
nqpre[1] = 0.; |
nqpre[1] = 0.; |
1689 |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
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; |
ipre = 0; |
1692 |
if ( j > (ladder*32)+15 ) ipre = 1; |
if ( j > (ladder*32)+15 ) ipre = 1; |
1693 |
jpre = j/16 ; |
jpre = j/16 ; |
1703 |
}; |
}; |
1704 |
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] ; |
1705 |
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] ; |
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; |
if ( ctground ) it = 100; |
1709 |
deltaqsi = nqsi-snqsi; |
deltaqsi = nqsi-snqsi; |
|
snqsi = nqsi; |
|
|
it++; |
|
1710 |
deltaqpre[0] = nqpre[0] - qpre[l][m][pre-1]; |
deltaqpre[0] = nqpre[0] - qpre[l][m][pre-1]; |
1711 |
deltaqpre[1] = nqpre[1] - qpre[l][m][pre]; |
deltaqpre[1] = nqpre[1] - qpre[l][m][pre]; |
1712 |
|
// |
1713 |
|
// Check for divergence and stop if it happens! [9RED bug noticed with plane 18X] |
1714 |
|
// |
1715 |
|
if ( deltaqpre[0] > qpre[l][m][pre-1] || deltaqpre[1] > qpre[l][m][pre] || deltaqsi >snqsi ){ |
1716 |
|
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 |
|
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]); |
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]; |
qpre[l][m][pre-1] = nqpre[0]; |
1724 |
qpre[l][m][pre] = nqpre[1]; |
qpre[l][m][pre] = nqpre[1]; |
1754 |
jjj++; |
jjj++; |
1755 |
j4++; |
j4++; |
1756 |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
1757 |
if ( crosst ){ |
if ( crosst ){ |
1758 |
// |
// |
1759 |
// "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 |
1760 |
// |
// |
1804 |
}; |
}; |
1805 |
if ( debug ) printf(" HIT STRIP: view %i plane %i strip %i energy: %f \n",l,m,j4,clevel1->estrip[j4][m][l]); |
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. ){ |
// if ( dexyc[l][m][j4] == 32767. ){ |
1807 |
if ( dexyc[l][m][j4] > 32000. ){ |
if ( dexyc[l][m][j4] > 32000. || savel1 > 5000.){ // CaloLevel1 bug with plane 18X [9RED 14/04/2010] |
1808 |
savel1 += 5000.; |
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.; |
clevel2->nsatstrip += 1.; |
1814 |
}; |
}; |
1815 |
// |
// |
1852 |
} else { |
} else { |
1853 |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
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++; |
istrip++; |
1858 |
}; |
}; |
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++ ){ |