1324 TDirectory* oldir = gDirectory;
1327 new TH1I(
"TofEventClus_ClustBuildTime",
"Time needed to build clusters in each event; Time [s]", 4000, 0.0, 4.0);
1330 new TH2D(Form(
"hClustHitsDigi"), Form(
"Hits vs. CalDigis; Mul_{Digi}; Mul_{Hits}"), 100, 0, 500, 100, 0, 200);
1337 for (
Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1348 LOG(info) << GetName() <<
": Skip booking of calibration histograms ";
1362 Double_t YSCAL = 50.;
1387 LOG(warning) <<
"No DigiPar for SmType " << Form(
"%d, 0x%08x", iS, iUCellId);
1393 new TH2D(Form(
"cl_SmT%01d_Pos", iS), Form(
"Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
1397 Double_t TSumMax = 1.E3;
1400 new TH2D(Form(
"cl_SmT%01d_TOff", iS), Form(
"Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
1405 TProfile* hSvelcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iS));
1406 if (NULL == hSvelcur) {
1407 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Svel", iS) <<
" not found, recreate ...";
1409 new TProfile(Form(
"cl_SmT%01d_Svel", iS), Form(
"Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
1416 LOG(info) <<
fhSmCluSvel[iS]->GetName() <<
" cloned from " << gDirectory->GetName();
1421 for (
Int_t iPar = 0; iPar < 4; iPar++) {
1422 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar));
1423 if (NULL == hFparcur) {
1424 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Fpar%1d", iS, iPar) <<
" not found, recreate ...";
1425 fhSmCluFpar[iS][iPar] =
new TProfile(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar),
1426 Form(
"Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
1431 fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
1438 fhTSmCluPosition[iS][iSel] =
new TH2D(Form(
"cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
1439 Form(
"Clu position of SmType %d under Selector %02d; Sm+Rpc# "
1444 fhTSmCluTOff[iS][iSel] =
new TH2D(Form(
"cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
1445 Form(
"Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
1450 fhTSmCluTRun[iS][iSel] =
new TH2D(Form(
"cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
1451 Form(
"Clu TimeZero in SmType %d under Selector %02d; Event# "
1458 LOG(info) <<
" Define Clusterizer histos for " << iNbDet <<
" detectors ";
1493 for (
Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1502 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1505 LOG(debug) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1506 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1514 if (NULL ==
fChannelInfo) LOG(warning) << Form(
"missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
1519 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
1520 Form(
"Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1", iRpcId, iSmId, iSmType),
1525 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiMul", iSmType, iSmId, iRpcId),
1526 Form(
"Digi Multiplicity of Rpc #%03d in Sm %03d of type %d; strip #; "
1528 iRpcId, iSmId, iSmType),
1532 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiStatus", iSmType, iSmId, iRpcId),
1533 Form(
"Digi Status of Rpc #%03d in Sm %03d of type %d; strip #; digi status", iRpcId, iSmId, iSmType),
1536 const Int_t NLogbin = 40;
1537 Double_t edge[NLogbin + 1];
1538 for (
Int_t i = 0; i < NLogbin + 1; i++)
1539 edge[i] = TMath::Power(2, i);
1540 fhRpcDigiDTLD[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiDTLD", iSmType, iSmId, iRpcId),
1541 Form(
"Time distance to last digi of Rpc #%03d in Sm %03d of type %d; "
1542 "channel; t_{digi} - t_{previous digi} (ns)",
1543 iRpcId, iSmId, iSmType),
1547 fhRpcDigiDTFD[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiDTFD", iSmType, iSmId, iRpcId),
1548 Form(
"Time distance to first digi of Rpc #%03d in Sm %03d of type %d; "
1549 "channel; t_{digi} - t_{first digi} (ns)",
1550 iRpcId, iSmId, iSmType),
1554 fhRpcDigiDTMul[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiDTMul", iSmType, iSmId, iRpcId),
1555 Form(
"Multiplicity of digi of Rpc #%03d in Sm %03d of type %d; "
1556 "channel; Multiplicity",
1557 iRpcId, iSmId, iSmType),
1561 new TH1D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSmId, iRpcId),
1562 Form(
"Digi rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType),
1566 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
1567 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts", iRpcId, iSmId, iSmType),
1571 new TH1D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
1572 Form(
"Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType), 36000.,
1575 fhRpcCluRate10s[iDetIndx] =
new TH1D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSmId, iRpcId),
1576 Form(
" Clu rate of Rpc #%03d in Sm %03d of type %d in last "
1577 "10s; Time (s); Counts per 100 #mus",
1578 iRpcId, iSmId, iSmType),
1581 fhRpcDTLastHits[iDetIndx] =
new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
1582 Form(
"Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
1583 "#DeltaT (ns)); counts",
1584 iRpcId, iSmId, iSmType),
1587 fhRpcDTLastHits_Tot[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1588 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1590 iRpcId, iSmId, iSmType),
1593 fhRpcDTLastHits_CluSize[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1594 Form(
"Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1596 iRpcId, iSmId, iSmType),
1597 100, 0., 10., 16, 0.5, 16.5);
1599 Double_t YSCAL = 50.;
1603 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1604 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]", iRpcId, iSmId, iSmType),
1608 Form(
"cl_SmT%01d_sm%03d_rpc%03d_GloPos", iSmType, iSmId, iRpcId),
1609 Form(
"Clu global position of Rpc #%03d in Sm %03d of type %d; xpos [cm]; ypos [cm]", iRpcId, iSmId, iSmType), 200,
1610 -100, 100, 200, -100, 100);
1612 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_Left", iSmType, iSmId, iRpcId),
1613 Form(
"Digi Tot of Rpc #%03d in Sm %03d of type %d; Tot; ypos [cm]", iRpcId, iSmId, iSmType), 100,
1617 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_Right", iSmType, iSmId, iRpcId),
1618 Form(
"Digi Tot of Rpc #%03d in Sm %03d of type %d; Tot; ypos [cm]", iRpcId, iSmId, iSmType), 100,
1622 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_Diff", iSmType, iSmId, iRpcId),
1623 Form(
"Digi Tot of Rpc #%03d in Sm %03d of type %d; Tot; ypos [cm]", iRpcId, iSmId, iSmType), 200,
1627 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_Map", iSmType, iSmId, iRpcId),
1628 Form(
"Digi Tot left vs Tot right of Rpc #%03d in Sm %03d of type %d; Tot; ypos [cm]", iRpcId, iSmId, iSmType),
1631 fhRpcCluPositionEvol[iDetIndx] =
new TProfile(Form(
"cl_SmT%01d_sm%03d_rpc%03d_PosEvol", iSmType, iSmId, iRpcId),
1632 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Analysis Time "
1634 iRpcId, iSmId, iSmType),
1635 1000, -1., 1.E4, -100., 100.);
1637 fhRpcCluTimeEvol[iDetIndx] =
new TProfile(Form(
"cl_SmT%01d_sm%03d_rpc%03d_TimeEvol", iSmType, iSmId, iRpcId),
1638 Form(
"Clu time of Rpc #%03d in Sm %03d of type %d; Analysis Time [s]; dT "
1640 iRpcId, iSmId, iSmType),
1641 1000, -1., 1.E4, -10., 10.);
1644 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1645 Form(
"Clu position difference of Rpc #%03d in Sm %03d of type "
1646 "%d; Strip []; #Deltaypos(clu) [cm]",
1647 iRpcId, iSmId, iSmType),
1651 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1652 Form(
"Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1653 "%d; Strip []; #Deltaypos(mat) [cm]",
1654 iRpcId, iSmId, iSmType),
1657 Double_t TSumMax = 1.E3;
1660 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1661 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]", iRpcId, iSmId, iSmType),
1664 fhRpcCluDelTOff[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1665 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1666 "[]; #DeltaTOff(clu) [ns]",
1667 iRpcId, iSmId, iSmType),
1672 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1673 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1674 "[]; #DeltaTOff(mat) [ns]",
1675 iRpcId, iSmId, iSmType),
1679 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1680 Form(
"Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]", iRpcId, iSmId, iSmType),
1684 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1685 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [a.u.]", iRpcId, iSmId, iSmType),
1690 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1691 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]", iRpcId, iSmId, iSmType),
1696 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1697 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvWalk; Tot [a.u.]; #DeltaT [ns]", iSmType, iSmId, iRpcId),
1700 fhRpcCluAvLnWalk[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1701 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk; log_{10}Tot [a.u.]; "
1703 iSmType, iSmId, iRpcId),
1710 for (
Int_t iSide = 0; iSide < 2; iSide++) {
1712 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1713 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk; Tot "
1714 "[a.u.]; #DeltaT [ns]",
1715 iSmType, iSmId, iRpcId, iCh, iSide),
1726 LOG(info) <<
" Define Clusterizer monitoring histos ";
1729 Form(
"Cluster Multiplicity Correlation of Dut %d%d%d with Sel "
1730 "%d%d%d; Mul(Sel); Mul(Dut)",
1732 32, 0, 32, 32, 0, 32);
1734 fhEvCluMul =
new TH2D(Form(
"hEvCluMul"), Form(
"Time Evolution of Cluster Multiplicity in Event; Time (s); Mul"), 1800,
1735 0, 1800, 100, 0, 100);
1738 "Space difference along channel direction between Digi pairs on "
1739 "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
1742 "Time difference between Digi pairs on adjacent channels; "
1743 "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1746 "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
1747 "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1748 5000, -10.0, 10.0, 2000, -5.0, 5.0);
1750 "Position difference between Point and Hit as function of Cluster "
1751 "Size; Cluster Size [Strips]; dX [cm]",
1752 100, 0.5, 100.5, 500, -50, 50);
1754 "Position difference between Point and Hit as function of Cluster "
1755 "Size; Cluster Size [Strips]; dY [cm]",
1756 100, 0.5, 100.5, 500, -50, 50);
1758 "Position difference between Point and Hit as "
1759 "function of Channel dif; Ch Dif [Strips]; dX [cm]",
1760 101, -50.5, 50.5, 500, -50, 50);
1762 "Position difference between Point and Hit as "
1763 "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1764 101, -50.5, 50.5, 500, -50, 50);
1766 "How many time per event the 2 digis on a channel "
1767 "were of the same side ; Counts/Event []",
1769 fhNbDigiPerChan =
new TH1I(
"Clus_NbDigiPerChan",
"Nb of Digis per channel; Nb Digis []", 100, 0.0, 100.0);
1776 fhSeldT[iSel] =
new TH2D(Form(
"cl_dt_Sel%02d", iSel), Form(
"Selector time %02d; dT [ns]", iSel), 99,
1798 for (
Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1806 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1809 LOG(debug1) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1810 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1834 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul", iSmType, iSmId, iRpcId, iSel),
1835 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1836 "under Selector %02d; M []; cnts",
1837 iRpcId, iSmId, iSmType, iSel),
1840 if (NULL ==
fhTRpcCluMul[iDetIndx][iSel]) LOG(fatal) <<
" Histo not generated !";
1842 Double_t YSCAL = 50.;
1846 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos", iSmType, iSmId, iRpcId, iSel),
1847 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d under "
1848 "Selector %02d; Strip []; ypos [cm]",
1849 iRpcId, iSmId, iSmType, iSel),
1852 Double_t TSumMax = 1.E4;
1854 if (iSmType == 5) TSumMax *= 2.;
1856 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff", iSmType, iSmId, iRpcId, iSel),
1857 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1858 "Selector %02d; Strip []; TOff [ns]",
1859 iRpcId, iSmId, iSmType, iSel),
1863 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TofOff", iSmType, iSmId, iRpcId, iSel),
1864 Form(
"Clu TimeDeviation of Rpc #%03d in Sm %03d of type %d "
1865 "under Selector %02d; Strip []; TOff [ns]",
1866 iRpcId, iSmId, iSmType, iSel),
1868 -TSumMax * 4., TSumMax * 4.);
1872 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot", iSmType, iSmId, iRpcId, iSel),
1873 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1874 "Selector %02d; StripSide []; TOT [a.u.]",
1875 iRpcId, iSmId, iSmType, iSel),
1880 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size", iSmType, iSmId, iRpcId, iSel),
1881 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1882 "Selector %02d; Strip []; size [strips]",
1883 iRpcId, iSmId, iSmType, iSel),
1888 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk", iSmType, iSmId, iRpcId, iSel),
1889 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel", iSmType, iSmId, iRpcId, iSel),
1894 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSmId, iRpcId, iSel),
1895 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; TRef-TSel; T-TSel", iSmType, iSmId, iRpcId, iSel),
1900 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY", iSmType, iSmId, iRpcId, iSel),
1901 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1903 iSmType, iSmId, iRpcId, iSel),
1908 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_QASY", iSmType, iSmId, iRpcId, iSel),
1909 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_QASY; Tot_{asy} []; Y [cm];", iSmType, iSmId, iRpcId, iSel), 50,
1910 -1, 1, 100, -YDMAX, YDMAX);
1913 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2", iSmType, iSmId, iRpcId, iSel),
1914 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2; Tot_1; Tot_2; #Delta t[ns]", iSmType, iSmId, iRpcId, iSel),
1918 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Q2DT", iSmType, iSmId, iRpcId, iSel),
1919 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_Q2DT; Tot_1; Tot_2; #Delta t[ns]", iSmType, iSmId, iRpcId, iSel),
1926 for (
Int_t iSide = 0; iSide < 2; iSide++) {
1928 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide, iSel),
1929 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide,
1936 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH", iSmType, iSmId, iRpcId, iSel),
1937 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1938 "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1939 iRpcId, iSmId, iSmType, iSel),
1940 100, 0., 10., 99, -TSumMax, TSumMax);
1943 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH", iSmType, iSmId, iRpcId, iSel),
1944 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1945 "Selector %02d; log(#DeltaT (ns)); TOT [a.u.]",
1946 iRpcId, iSmId, iSmType, iSel),
1950 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH", iSmType, iSmId, iRpcId, iSel),
1951 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1952 "Selector %02d; log(#DeltaT (ns)); size [strips]",
1953 iRpcId, iSmId, iSmType, iSel),
1954 100, 0., 10., 10, 0.5, 10.5);
1957 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH", iSmType, iSmId, iRpcId, iSel),
1958 Form(
"Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1959 "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1960 iRpcId, iSmId, iSmType, iSel),
1961 100, 0., 10., 10, 0, 10);
1967 new TH1I(
"Clus_TofHitPerTrk",
"Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []", 2000, 0.0, 20.0);
1970 "Distribution of the Number of MCPoints associated "
1971 "to each TofHit; Nb MCPoint []",
1975 "Time resolution for TofHits containing Digis from a single MC "
1976 "Track; t(1st Mc Point) -tTofHit [ns]",
1977 10000, -25.0, 25.0);
1979 "Time resolution for TofHits containing Digis from a single MC "
1980 "Track; (1st Mc Point) -tTofHit [ns]",
1981 5000, -25.0, 25.0, 6, 0, 6);
1983 "Time resolution for TofHits containing Digis from a single MC "
1984 "Track; t(1st Mc Point) -tTofHit [ns]",
1985 2000, 0.0, 50.0, 2000, 0.0, 50.0);
1989 "Time resolution for TofHits containing Digis from a single "
1990 "TofPoint; tMcPoint -tTofHit [ns]",
1991 10000, -25.0, 25.0);
1993 "Time resolution for TofHits containing Digis from a single "
1994 "TofPoint; tMcPoint -tTofHit [ns]",
1995 5000, -25.0, 25.0, 6, 0, 6);
1997 "Time resolution for TofHits containing Digis "
1998 "from a single TofPoint; tMcPoint -tTofHit [ps]",
1999 2000, 0.0, 50.0, 2000, 0.0, 50.0);
2031 gDirectory->cd(oldir->GetPath());
2041 if (
fDutId < 0)
return kTRUE;
2045 if (NULL == tEvent) {
2047 if (iNbTofHits > 0) {
2055 if (
fCalMode % 10 == 9)
return kTRUE;
2058 gGeoManager->CdTop();
2060 if (0 < iNbTofHits) {
2061 Double_t dCluMul = 0.;
2063 Double_t dTTrig[
iNSel];
2065 Double_t ddXdZ[
iNSel];
2066 Double_t ddYdZ[
iNSel];
2067 Double_t dSel2dXdYMin[
iNSel];
2069 Int_t iBeamRefMul = 0;
2070 Int_t iBeamAddRefMul = 0;
2075 LOG(debug) <<
"CbmTofEventClusterizer::FillHistos() for " <<
iNSel <<
" triggers"
2085 for (
Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
2099 LOG(fatal) <<
" Invalid Id: Sel " <<
fSelId <<
", Dut " <<
fDutId <<
" in event " <<
fdEvent;
2104 LOG(fatal) <<
" Invalid SelSm " <<
fSelSm <<
" in event " <<
fdEvent;
2109 LOG(fatal) <<
" Invalid SelRpc " <<
fSelRpc <<
" in event " <<
fdEvent;
2115 LOG(fatal) <<
" Invalid DutSm " <<
fDutSm <<
" in event " <<
fdEvent;
2120 LOG(fatal) <<
" Invalid DutRpc " <<
fDutRpc <<
" in event " <<
fdEvent;
2130 for (
Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2132 if (NULL == pHit)
continue;
2140 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
2142 Int_t iDetIndx = it->second;
2167 LOG(debug) <<
"Resetting 10s rate histo for spill " <<
iNSpill <<
" at " <<
fdStartAna10s / 1.E9
2168 <<
"s after " << dDTLEvt / 1.E9 <<
" s without events";
2182 LOG(fatal) << Form(
" <E> hit not stored in memory for TSRC %d%d%d%d", iSmType, iSm, iRpc, iCh);
2194 LOG(warning) << Form(
"Invalid time ordering in ev %8.0f in list of "
2195 "size %lu for TSRC %d%d%d%d: Delta t %f ",
2204 LOG(debug) <<
" pop from list size " <<
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2205 << Form(
" outdated hits for ev %8.0f in TSRC %d%d%d%d",
fdEvent, iSmType, iSm, iRpc, iCh)
2206 << Form(
" with tHit - tLast %f ",
2211 LOG(fatal) << Form(
"Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
2213 fvLastHits[iSmType][iSm][iRpc][iCh].
size(), iSmType, iSm, iRpc, iCh,
2214 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
2215 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
2216 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
2217 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
2224 Double_t dTotSum = 0.;
2228 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
2236 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2238 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
2251 Double_t dTRefAv = 0.;
2252 std::vector<CbmTofHit*> pvBeamRef;
2254 for (
Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2256 if (NULL == pHit)
continue;
2267 LOG(debug) <<
"Reference module multiplicity " << iBRefMul;
2288 pvBeamRef.push_back(pHit);
2293 dTRefAv = (dTRefAv * iBeamRefMul + pHit->
GetTime()) / (iBeamRefMul + 1);
2300 if (iBeamRefMul > 2) {
2304 for (UInt_t i = 0; i < pvBeamRef.size(); i++) {
2306 if (TMath::Abs(pvBeamRef[i]->GetTime() - dTRefAv) < dTDist) {
2307 pBeamRef = pvBeamRef[i];
2309 dTDist = TMath::Abs(
dTRef - dTRefAv);
2314 LOG(debug) <<
"CbmTofEventClusterizer::FillHistos: BRefMul: " << iBeamRefMul <<
", " << iBeamAddRefMul;
2316 if (iBeamRefMul == 0)
return kFALSE;
2318 if (NULL == pBeamRef)
return kFALSE;
2324 BSel[iSel] = kFALSE;
2332 dSel2dXdYMin[iSel] = 1.E300;
2342 for (
Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2345 <<
", BRefMul " << iBeamRefMul <<
" TRef: " <<
dTRef <<
", BeamAddRefMul " << iBeamAddRefMul
2349 LOG(debug1) <<
"Found selector 0, NbHits " << iNbTofHits;
2350 for (
Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2352 if (NULL == pHit)
continue;
2355 LOG(debug1) << Form(
" Det 0x%08x, Dut 0x%08x, T %f, TTrig %f", iDetId,
fDutAddr, pHit->
GetTime(),
2359 if (pHit->
GetTime() < dTTrig[iSel]) {
2362 dTTrig[iSel] = pHit->
GetTime();
2370 LOG(debug) << Form(
"Found selector 0 with mul %d from 0x%08x at %f ", iDutMul,
2371 pTrig[iSel]->GetAddress(), dTTrig[iSel]);
2381 for (
Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2383 LOG(debug) <<
"CbmTofEventClusterizer::FillHistos(): selector 1: RefMul "
2386 LOG(debug1) <<
"CbmTofEventClusterizer::FillHistos(): Found "
2387 "selector 1, BeamRef at"
2390 for (
Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2392 if (NULL == pHit)
continue;
2396 LOG(debug1) <<
"Check hit " << iHitInd <<
", sel " << iSel <<
", t: " << pHit->
GetTime()
2397 <<
", TT " << dTTrig[iSel];
2399 if (pHit->
GetTime() < dTTrig[iSel]) {
2402 dTTrig[iSel] = pHit->
GetTime();
2405 LOG(debug1) <<
"Accept hit " << iHitInd <<
", sel " << iSel <<
", t: " << pHit->
GetTime()
2406 <<
", TT " << dTTrig[iSel];
2412 LOG(debug) << Form(
"Found selector 1 with mul %d from 0x%08x at %f ", iRefMul,
2413 pTrig[iSel]->GetAddress(), dTTrig[iSel]);
2418 LOG(info) <<
"CbmTofEventClusterizer::FillHistos: selection not "
2424 dTTrig[iSel] =
dTRef;
2426 if (iDetMul < iReqMul) BSel[iSel] = 0;
2431 LOG(debug1) <<
"selector loop passed, continue with Sel2Id " <<
fSel2Id
2432 << Form(
", BSel %d %d ", (
Int_t) BSel[0], (
Int_t) BSel[1]);
2437 BSel[iSel] = kFALSE;
2440 for (
Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2442 if (NULL == pHit)
continue;
2445 Double_t dzscal = 1.;
2447 Double_t dSEl2dXdz = (pHit->
GetX() - pTrig[iSel]->GetX()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
2448 Double_t dSEl2dYdz = (pHit->
GetY() - pTrig[iSel]->GetY()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
2451 || (TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
2452 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2455 Double_t dX2Y2 = TMath::Sqrt(dSEl2dXdz * dSEl2dXdz + dSEl2dYdz * dSEl2dYdz);
2456 if (dX2Y2 < dSel2dXdYMin[iSel]) {
2457 ddXdZ[iSel] = dSEl2dXdz;
2458 ddYdZ[iSel] = dSEl2dYdz;
2459 dSel2dXdYMin[iSel] = dX2Y2;
2503 LOG(debug1) <<
"Generate trigger pattern";
2504 UInt_t uTriggerPattern = 1;
2513 LOG(debug1) <<
"Inspect trigger pattern";
2517 for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
2518 if (uTriggerPattern & (0x1 << uChannel)) {
2527 LOG(debug1) <<
"start filling histos ";
2529 for (
Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2531 if (NULL == pHit)
continue;
2534 LOG(debug1) <<
"Process Hit " << iHitInd <<
", DetId " << iDetId;
2536 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
2538 Int_t iDetIndx = it->second;
2557 if (iBeamRefMul == 0)
break;
2563 LOG(error) <<
"Invalid Channel Pointer for ChId " << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
2569 LOG(debug1) <<
"Hit info: "
2570 << Form(
" 0x%08x %d %f %f %f %f %f %d", iChId, iCh, pHit->
GetX(), pHit->
GetY(), pHit->
GetTime(),
2574 hitpos[0] = pHit->
GetX();
2575 hitpos[1] = pHit->
GetY();
2576 hitpos[2] = pHit->
GetZ();
2577 Double_t hitpos_local[3];
2579 fCellIdGeoMap[iChId]->GetMatrix()->MasterToLocal(hitpos, hitpos_local);
2592 fhSmCluPosition[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
2598 fhTSmCluPosition[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
2608 LOG(debug1) <<
" TofDigiMatchColl entries:" <<
fTofDigiMatchColl->GetEntriesFast();
2611 LOG(error) <<
" Inconsistent DigiMatches for Hitind " << iHitInd
2616 LOG(debug1) <<
" got " << digiMatch->
GetNofLinks() <<
" matches for iCh " << iCh <<
" at iHitInd " << iHitInd;
2624 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2626 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
2647 Double_t dMeanTimeSquared = 0.;
2648 Double_t dNstrips = 0.;
2650 Double_t dDelTof = 0.;
2651 Double_t dTcor[
iNSel];
2652 Double_t dTTcor[
iNSel];
2653 Double_t dZsign[
iNSel];
2654 Double_t dzscal = 1.;
2660 UInt_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
2664 if (iDigInd0 < fTofCalDigiVec->
size() && iDigInd1 < fTofCalDigiVec->
size()) {
2670 LOG(error) << Form(
" Wrong Digi SmType for Tofhit %d in iDetIndx "
2671 "%d, Ch %d with %3.0f strips at Indx %d, %d",
2672 iHitInd, iDetIndx, iCh, dNstrips, iDigInd0, iDigInd1);
2674 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch " << pDig0->
GetChannel() <<
", Side "
2675 << pDig0->
GetSide() <<
", StripSide " << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
2676 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side " << pDig1->
GetSide() <<
", StripSide "
2677 << (Double_t) iCh * 2. + pDig1->
GetSide() <<
", Tot0 " << pDig0->
GetTot() <<
", Tot1 "
2689 if (iS0 == 1) pDigS0 = pDig1;
2691 if (iS1 == 0) pDigS1 = pDig0;
2698 if (iCh0 != iCh1 || iS0 == iS1) {
2699 LOG(error) << Form(
" MT2 for Tofhit %d in iDetIndx %d, Ch %d from "
2702 << Form(
" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd0, iCh0, iS0, pDig0->
GetTime())
2703 << Form(
" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd1, iCh1, iS1, pDig1->
GetTime());
2708 LOG(error) << Form(
" Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
2709 "from %3.0f strips: %d, %d, %d, %d",
2710 iHitInd, iDetIndx, iCh, iDigInd0, iDigInd1, dNstrips, iCh0, iCh1, iS0, iS1);
2725 Double_t dCorWeight = 1.;
2731 if (0 == pDig0->
GetSide()) dDelPos *= -1.;
2748 - (1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
2752 - (1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
2756 LOG(debug1) <<
" fhTRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch " << pDig0->
GetChannel() <<
", Side "
2757 << pDig0->
GetSide() <<
", StripSide " << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
2758 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side " << pDig1->
GetSide() <<
", StripSide "
2759 << (Double_t) iCh * 2. + pDig1->
GetSide();
2763 if (NULL == pHit || NULL == pTrig[iSel]) {
2764 LOG(info) <<
" invalid pHit, iSel " << iSel <<
", iDetIndx " << iDetIndx;
2772 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2774 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
2789 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY());
2803 if (pHit->
GetZ() < pTrig[iSel]->
GetZ()) dZsign[iSel] = -1.;
2807 || TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
2808 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2812 TMath::Power(pHit->
GetX()
2813 - (pTrig[iSel]->
GetX() + ddXdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2815 + TMath::Power(pHit->
GetY()
2816 - (pTrig[iSel]->
GetY() + ddYdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2836 if (iBx < 0) iBx = 0;
2839 Double_t dDTentry = dTentry - ((Double_t) iBx) * dBinWidth;
2841 dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
2842 Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
2843 Double_t w1 = 1. - w0;
2844 if (iBx1 < 0) iBx1 = 0;
2846 dDelTof =
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
2847 +
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel] * w1;
2849 LOG(debug1) << Form(
" DelTof for SmT %d, Sm %d, R %d, T %d, dTRef "
2850 "%6.1f, Bx %d, Bx1 %d, DTe %6.1f -> DelT %6.1f",
2851 iSmType, iSm, iRpc, iSel,
dTRef - dTTrig[iSel], iBx, iBx1, dDTentry, dDelTof);
2853 dTTcor[iSel] = dDelTof * dZsign[iSel];
2854 dTcor[iSel] = pHit->
GetTime() - dDelTof - dTTrig[iSel];
2857 if (dTcor[iSel] == 0.)
continue;
2858 LOG(debug) << Form(
" TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
2859 "Ch %d,%d, S %d,%d T %f, DelTof %6.1f, W-ent: %6.0f,%6.0f",
2861 iCh0, iCh1, iS0, iS1, dTTrig[iSel], dDelTof,
2867 LOG(error) << Form(
" Inconsistent walk histograms -> debugging "
2868 "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
2869 fiNevtBuild, iDetIndx, iSel, iCh0, iCh1, iS0, iS1);
2871 LOG(debug1) << Form(
2872 " TRpcCluWalk values side %d: %f, %f, side %d: %f, %f ", iS0, pDig0->
GetTot(),
2875 - dTTcor[iSel] - dTTrig[iSel],
2879 - dTTcor[iSel] - dTTrig[iSel]);
2910 fhTSmCluTOff[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), dTcor[iSel]);
2913 != (pTrig[iSel]->GetAddress()
2917 hitpos[2] = pHit->
GetZ();
2918 gGeoManager->MasterToLocal(hitpos,
2922 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
2930 LOG(error) <<
"CbmTofEventClusterizer::FillHistos: invalid digi index " << iDetIndx <<
" digi0,1" << iDigInd0
2942 Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
2944 Double_t dTrms = TMath::Sqrt(dVar);
2945 LOG(debug) << Form(
" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
2946 "%3.0f strips: %6.3f ns",
2947 iHitInd, iDetIndx, iCh, dNstrips, dTrms);
2952 LOG(debug1) <<
" Fill Time of iDetIndx " << iDetIndx <<
", hitAddr "
2953 << Form(
" %08x, y = %5.2f", pHit->
GetAddress(), hitpos_local[1]) <<
" for |y| <"
2955 << Form(
", TRef %8.3f, BSel %d %d",
dTRef, (
Int_t) BSel[0], (
Int_t) BSel[1]);
2957 if (TMath::Abs(hitpos_local[1]) < (
fhRpcCluPosition[iDetIndx]->GetYaxis()->GetXmax())) {
2964 LOG(debug1) <<
" TRpcCluTOff " << iDetIndx <<
", Sel " << iSel
2965 << Form(
", Dt %7.3f, LHsize %lu ", pHit->
GetTime() - dTTrig[iSel],
2970 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2972 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
2974 LOG(debug1) << Form(
" %f,", pHit->
GetTime() - (*itL)->GetTime());
2978 if (pBeamRef != NULL)
2999 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
3001 for (
Int_t iH = 0; iH < 1; iH++) {
3004 Double_t dTsinceLast = pHit->
GetTime() - (*itL)->GetTime();
3006 LOG(fatal) << Form(
"Invalid Time since last hit on channel "
3007 "TSRC %d%d%d%d: %f > %f",
3011 pHit->
GetTime() - dTTrig[iSel]);
3024 LOG(debug1) <<
"CbmTofEventClusterizer::FillHistos: "
3027 for (UInt_t uCluster = 0; uCluster <
fviClusterSize[iSmType][iRpc].size(); uCluster++) {
3028 LOG(debug2) <<
"CbmTofEventClusterizer::FillHistos: " << Form(
" %3d %3d %3d ", iSmType, iRpc, uCluster);
3032 40 * iSmType + iRpc);
3037 if (1 ==
fviTrkMul[iSmType][iRpc][uCluster])
3039 if (1 <
fviTrkMul[iSmType][iRpc][uCluster])
3055 fvdX[iSmType][iRpc].clear();
3056 fvdY[iSmType][iRpc].clear();
3057 fvdDifX[iSmType][iRpc].clear();
3058 fvdDifY[iSmType][iRpc].clear();
3070 if (
fDutId < 0)
return kTRUE;
3072 TFile* oldFile = gFile;
3073 TDirectory* oldDir = gDirectory;
3077 Double_t dTBeamRefMean = 0.;
3079 Double_t dTBeamRefW = 0.;
3082 for (
Int_t iFindT0 = 0; iFindT0 < 2; iFindT0++)
3106 LOG(debug) <<
"WriteHistos: No entries in Walk histos for "
3107 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
3112 TH2* htempPos = NULL;
3113 TProfile* htempPos_pfx = NULL;
3114 TH1* htempPos_py = NULL;
3115 TProfile* htempTOff_pfx = NULL;
3116 TH1* htempTOff_px = NULL;
3117 TProfile* hAvPos_pfx = NULL;
3118 TProfile* hAvTOff_pfx = NULL;
3119 TH2* htempTOff = NULL;
3120 TH2* htempTot = NULL;
3121 TProfile* htempTot_pfx = NULL;
3122 TH1* htempTot_Mean = NULL;
3123 TH1* htempTot_Off = NULL;
3133 htempTOff_px = htempTOff->ProjectionX(
"_px", 1,
fhTRpcCluTOff[iDetIndx][
fCalSel]->GetNbinsY());
3134 for (
Int_t iCh = 0; iCh < htempTOff->GetNbinsX(); iCh++) {
3135 TH1* htempTOff_py = htempTOff->ProjectionY(
"_py", iCh + 1, iCh + 1);
3136 Double_t Ymax = htempTOff_py->GetMaximum();
3138 Int_t iBmax = htempTOff_py->GetMaximumBin();
3139 Double_t dTOffmax = htempTOff_py->GetXaxis()->GetBinCenter(iBmax);
3140 if (TMath::Abs(dTOffmax) > 0.3 * htempTOff_py->GetXaxis()->GetXmax()) {
3141 LOG(debug) <<
"Use Maximum of TOff in ch " << iCh <<
" of histo " << htempTOff->GetName() <<
": "
3142 << dTOffmax <<
", " << htempTOff_py->GetXaxis()->GetXmax() <<
" instead of "
3143 << htempTOff_pfx->GetBinContent(iCh + 1);
3144 htempTOff_pfx->SetBinContent(iCh + 1, dTOffmax);
3145 htempTOff_pfx->SetBinEntries(iCh + 1, 1);
3214 if (NULL == htempPos_pfx) {
3215 LOG(debug) <<
"WriteHistos: Projections not available, continue ";
3219 htempTot_Mean = htempTot_pfx->ProjectionX(
"_Mean");
3220 htempTot_Off = htempTot_pfx->ProjectionX(
"_Off");
3222 htempPos_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
3223 htempTOff_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
3224 htempTot_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
3225 htempTot_Mean->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
3226 htempTot_Off->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
3227 hAvPos_pfx->SetName(Form(
"cl_CorSmT%01d_Pos_pfx", iSmType));
3228 hAvTOff_pfx->SetName(Form(
"cl_CorSmT%01d_TOff_pfx", iSmType));
3235 for (
Int_t iCh = 0; iCh < iNbCh; iCh++) {
3236 Double_t dWCh = ((TH1*) htempTOff_px)->GetBinContent(iCh + 1);
3238 Double_t dW = dTBeamRefW;
3239 dTBeamRefMean *= dW;
3243 TH1* hTy = (TH1*) htempTOff->ProjectionY(Form(
"%s_py%d", htempTOff->GetName(), iCh), iCh + 1, iCh + 1);
3244 Double_t dFMean = hTy->GetBinCenter(hTy->GetMaximumBin());
3245 Double_t dFLim = 1.;
3246 Double_t dBinSize = hTy->GetBinWidth(1);
3247 dFLim = TMath::Max(dFLim, 10. * dBinSize);
3252 TF1* mgaus =
new TF1(
"mgaus",
"gaus", dFMean - dFLim, dFMean + dFLim);
3253 mgaus->SetParameters(dWCh * 0.5, dFMean, dFLim * 0.5);
3254 TFitResultPtr fRes = hTy->Fit(
"mgaus",
"SQM",
"", dFMean - dFLim, dFMean + dFLim);
3256 if (!gMinuit->fCstatu.Contains(
"OK") && !gMinuit->fCstatu.Contains(
"CONVERGED")) {
3257 LOG(info) <<
"CalibC (ch ignored) " << gMinuit->fCstatu
3258 << Form(
" TSRC %d%d%d%d gaus %8.2f %8.2f %8.2f ", iSmType, iSm, iRpc, iCh,
3259 fRes->Parameter(0), fRes->Parameter(1), fRes->Parameter(2));
3264 if (fRes->Parameter(2) < 2.) {
3265 dTBeamRefMean += fRes->Parameter(1) * dWCh;
3269 dTBeamRefMean += ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1) * dWCh;
3275 dTBeamRefMean += ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1) * dWCh;
3278 dTBeamRefMean +=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] * dWCh;
3279 if (dTBeamRefW > 0) {
3280 dTBeamRefMean /= dTBeamRefW;
3284 if (htempTOff_px->GetBinContent(iCh + 1) > 0.)
3286 LOG(info) << Form(
"CalibA %d,%2d,%2d: TSRC %d%d%d%d, hits %6.0f , "
3287 "TAV %8.3f, TBeamRefMean %8.3f ",
3289 htempTOff_px->GetBinContent(iCh + 1),
3290 ((TProfile*) hAvTOff_pfx)->GetBinContent(iSm * iNbRpc + iRpc + 1), dTBeamRefMean);
3298 assert(iFindT0 == 1);
3302 htempTot_Off->Reset();
3304 Int_t nbins = htempTot->GetNbinsX();
3305 for (
int i = 0; i < nbins; i++) {
3306 hbins[i] = htempTot->ProjectionY(Form(
"bin%d", i + 1), i + 1, i + 1);
3308 Int_t iBmax = hbins[i]->GetMaximumBin();
3309 TAxis* xaxis = hbins[i]->GetXaxis();
3310 Double_t Xmax = xaxis->GetBinCenter(iBmax);
3312 XOff = (Double_t)(
Int_t) XOff;
3313 if (XOff < 0) XOff = 0;
3314 htempTot_Off->SetBinContent(i + 1, XOff);
3315 Double_t Xmean = htempTot_Mean->GetBinContent(i + 1);
3317 LOG(warning) <<
"Inconsistent Tot numbers for "
3318 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, Off %f", iSmType, iSm, iRpc, i, Xmean, XOff);
3320 htempTot_Mean->SetBinContent(i + 1, (Xmean - XOff));
3321 if (htempTot_Mean->GetBinContent(i + 1) != (Xmean - XOff))
3322 LOG(warning) <<
"Tot numbers not stored properly for "
3323 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, target %f", iSmType, iSm, iRpc, i,
3324 htempTot_Mean->GetBinContent(i + 1), Xmean - XOff);
3326 htempPos_pfx->Write();
3327 htempTOff_pfx->Write();
3329 htempTot_Mean->Write();
3330 htempTot_Off->Write();
3337 LOG(debug) <<
"WriteHistos: restore Offsets and Gains and save Walk for "
3338 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3339 <<
" and calSmAddr = " << Form(
" 0x%08x ", TMath::Abs(
fCalSmAddr));
3340 htempPos_pfx->Reset();
3341 htempTOff_pfx->Reset();
3342 htempTot_Mean->Reset();
3343 htempTot_Off->Reset();
3344 for (
Int_t iCh = 0; iCh < iNbCh; iCh++) {
3347 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3349 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3350 htempPos_pfx->Fill(iCh, YMean);
3351 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3352 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got "
3353 << htempPos_pfx->GetBinContent(iCh) <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
","
3354 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected " << YMean;
3356 htempTOff_pfx->Fill(iCh, TMean);
3358 for (
Int_t iSide = 0; iSide < 2; iSide++) {
3359 htempTot_Mean->SetBinContent(
3360 iCh * 2 + 1 + iSide,
3362 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3366 LOG(debug1) <<
" Offset, gain restoring done ... ";
3367 htempPos_pfx->Write();
3368 htempTOff_pfx->Write();
3370 htempTot_Mean->Write();
3371 htempTot_Off->Write();
3375 TDirectory* curdir = gDirectory;
3377 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3378 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3379 gDirectory->cd(curdir->GetPath());
3380 if (NULL != hCorDelTof) {
3381 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3382 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3383 hCorDelTofout->Write();
3386 LOG(debug) <<
" No CorDelTof histo "
3387 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3395 LOG(debug) <<
"WriteHistos: restore Offsets and Gains and update Walk for "
3396 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with "
3421 if (NULL == h2tmp0) {
3422 LOG(debug) << Form(
"WriteHistos: Walk histo not available for "
3423 "SmT %d, Sm %d, Rpc %d, Ch %d",
3424 iSmType, iSm, iRpc, iCh);
3427 Int_t iNEntries = h2tmp0->GetEntries();
3429 LOG(debug) << Form(
" Update Walk correction for SmT %d, Sm %d, "
3430 "Rpc %d, Ch %d, Sel%d: Entries %d",
3431 iSmType, iSm, iRpc, iCh,
fCalSel, iNEntries);
3435 if (-1 < iNEntries) {
3436 TProfile* htmp0 = h2tmp0->ProfileX(
"_pfx", 1, h2tmp0->GetNbinsY());
3437 TProfile* htmp1 = h2tmp1->ProfileX(
"_pfx", 1, h2tmp1->GetNbinsY());
3438 TH1D* h1tmp0 = h2tmp0->ProjectionX(
"_px", 1, h2tmp0->GetNbinsY());
3439 TH1D* h1tmp1 = h2tmp1->ProjectionX(
"_px", 1, h2tmp1->GetNbinsY());
3440 TH1D* h1ytmp0 = h2tmp0->ProjectionY(
"_py", 1,
3442 TH1D* h1ytmp1 = h2tmp1->ProjectionY(
"_py", 1,
nbClWalkBinX);
3443 Double_t dWMean0 = h1ytmp0->GetMean();
3444 Double_t dWMean1 = h1ytmp1->GetMean();
3445 Double_t dWMean = 0.5 * (dWMean0 + dWMean1);
3448 if (5 == iSmType || 8 == iSmType)
3453 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3456 (((TProfile*) htmp0)->GetBinContent(iWx + 1) + ((TProfile*) htmp1)->GetBinContent(iWx + 1))
3458 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor - dWMean;
3459 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor - dWMean;
3460 LOG(debug) << Form(
"Walk for TSR %d%d%d%d Tot %d set to %f", iSmType, iSm, iRpc, iCh, iWx,
3461 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3465 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3466 Double_t dWcor0 = ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3467 Double_t dWcor1 = ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3468 Double_t dWcor = 0.5 * (dWcor0 + dWcor1);
3469 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor;
3470 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor;
3472 if (iCh == 0 && iSmType == 9 && iSm == 0 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
3473 LOG(debug) <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc <<
"), Rpc " << iRpc <<
", Bin "
3474 << iWx <<
", " << h1tmp0->GetBinContent(iWx + 1)
3475 <<
" cts: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] <<
" + "
3476 << ((TProfile*) htmp0)->GetBinContent(iWx + 1) <<
" - " << dWMean0 <<
" -> "
3478 <<
", S1: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] <<
" + "
3479 << ((TProfile*) htmp1)->GetBinContent(iWx + 1) <<
" - " << dWMean1 <<
" -> "
3484 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3485 Double_t dWcor0 = ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3486 Double_t dWcor1 = ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3488 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor0;
3489 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor1;
3499 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3500 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3503 && h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3504 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3507 LOG(error) <<
"writing not successful for " << h1tmp0->GetName() <<
", attempts left: " << iTry
3508 <<
", iWx " << iWx <<
", got " << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3509 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3512 && h1tmp1->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]) {
3513 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3516 LOG(error) <<
"writing not successful for " << h1tmp1->GetName() <<
", attempts left: " << iTry
3517 <<
", iWx " << iWx <<
", got " << h1tmp1->GetBinContent(iWx + 1) <<
", expected "
3518 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx];
3521 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3524 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3538 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3539 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3540 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3541 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3542 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3543 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3546 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3549 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3562 LOG(debug) <<
"WriteHistos: (case 2) update Offsets and keep Gains, "
3563 "Walk and DELTOF for "
3564 << Form(
" 0x%08x ", TMath::Abs(
fCalSmAddr)) <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc "
3566 Int_t iB = iSm * iNbRpc + iRpc;
3567 Double_t dVscal = 1.;
3569 dVscal =
fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3570 if (dVscal == 0.) dVscal = 1.;
3572 Double_t YMean = ((TProfile*) hAvPos_pfx)->GetBinContent(iB + 1);
3573 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
3575 LOG(debug1) << Form(
"Determine YMean in %s by fit to %d entries", htempPos->GetName(),
3576 (
Int_t) htempPos_py->GetEntries());
3581 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3585 TF1* ff = htempPos_py->GetFunction(
"YBox");
3587 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm << iRpc
3588 <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
3589 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3590 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3592 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
3595 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2) {
3597 YMean = ff->GetParameter(3);
3599 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV);
3605 TH1* hAvTOff_py =
fhSmCluTOff[iSmType]->ProjectionY(
"_py", iB + 1, iB + 1);
3606 Double_t Ymax = hAvTOff_py->GetMaximum();
3607 Double_t dTOffmax = 0.;
3609 Int_t iBmax = hAvTOff_py->GetMaximumBin();
3610 dTOffmax = hAvTOff_py->GetXaxis()->GetBinCenter(iBmax);
3612 Double_t TMean = ((TProfile*) hAvTOff_pfx)->GetBinContent(iB + 1);
3613 if (TMath::Abs(dTOffmax - TMean) > 2. * TMean) {
3615 LOG(debug) <<
"Use peak position for TOff of TSR " << iSmType << iSm << iRpc <<
", B= " << iB <<
": "
3618 Double_t TWidth = ((TProfile*) hAvTOff_pfx)->GetBinError(iB + 1);
3622 LOG(debug) << Form(
"<ICor> Correct TSR %d%d%d by TMean=%8.2f, "
3623 "TYOff=%8.2f, TWidth=%8.2f, ",
3624 iSmType, iSm, iRpc, TMean, dTYOff, TWidth);
3626 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
3628 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3629 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3631 LOG(debug) <<
"FillCalHist:"
3632 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
3633 << YMean <<
", TMean " << TMean <<
" -> "
3634 << Form(
" %f, %f, %f, %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3635 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
3636 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3637 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3640 htempPos_pfx->Reset();
3641 htempTOff_pfx->Reset();
3642 htempTot_Mean->Reset();
3643 htempTot_Off->Reset();
3644 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
3648 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3650 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3651 htempPos_pfx->Fill(iCh, YMean);
3652 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3653 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got "
3654 << htempPos_pfx->GetBinContent(iCh) <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
","
3655 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected " << YMean;
3657 htempTOff_pfx->Fill(iCh, TMean);
3659 for (
Int_t iSide = 0; iSide < 2; iSide++) {
3660 htempTot_Mean->SetBinContent(
3661 iCh * 2 + 1 + iSide,
3663 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3667 LOG(debug1) <<
" Updating done ... write to file ";
3668 htempPos_pfx->Write();
3669 htempTOff_pfx->Write();
3671 htempTot_Mean->Write();
3672 htempTot_Off->Write();
3675 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
3679 TDirectory* curdir = gDirectory;
3681 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3682 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3683 gDirectory->cd(curdir->GetPath());
3684 if (NULL != hCorDelTof) {
3685 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3686 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3687 hCorDelTofout->Write();
3690 LOG(debug) <<
" No CorDelTof histo "
3691 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3696 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
3703 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3704 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3705 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3706 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3707 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3708 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3711 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3714 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3725 LOG(info) <<
"Write (calMode==3): update Offsets and Gains, keep Walk and DelTof for "
3726 << Form(
"Addr 0x%08x ", TMath::Abs(
fCalSmAddr)) <<
"TSR " << iSmType << iSm << iRpc <<
" with "
3727 << iNbCh <<
" channels "
3728 <<
", using selector " <<
fCalSel <<
", " << iFindT0 <<
" and TRefMode " <<
fTRefMode <<
", TRef "
3731 Double_t dVscal = 1.;
3735 dVscal =
fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3736 if (dVscal == 0.) dVscal = 1.;
3737 dVW =
fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc + iRpc + 1);
3739 if (dVW < 0.1) dVW = 0.1;
3742 Double_t dYMeanAv = 0.;
3743 Double_t dYMeanFit = 0.;
3744 Double_t dYLenFit = 0.;
3745 Double_t YMean = 0.;
3746 Double_t dYShift = 0;
3750 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
3753 dYMeanAv = htempPos_py->GetMean();
3754 LOG(debug1) << Form(
"Determine YMeanAv in %s by fit to %d entries", htempPos->GetName(),
3755 (
Int_t) htempPos_py->GetEntries());
3760 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3764 TF1* ff = htempPos_py->GetFunction(
"YBox");
3765 if (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED")) {
3768 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2) {
3770 LOG(info) <<
"FAvRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm
3771 << iRpc <<
", stat: " << gMinuit->fCstatu
3772 << Form(
", chi2 %6.2f, striplen (%5.2f): "
3773 "%7.2f+/-%5.2f, pos res "
3774 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
3776 2. * ff->GetParameter(1), 2. * ff->GetParError(1), ff->GetParameter(2),
3777 ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
3779 dYMeanFit = ff->GetParameter(3);
3780 dYLenFit = 2. * ff->GetParameter(1);
3781 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3782 for (
Int_t iPar = 0; iPar < 4; iPar++)
3783 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc), ff->GetParameter(2 + iPar));
3787 LOG(info) <<
"FAvBad YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm << iRpc
3788 <<
", chi2 " << ff->GetChisquare()
3789 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
3790 "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3792 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
3793 ff->GetParameter(3), ff->GetParError(3));
3797 LOG(info) <<
"FAvFailed for TSR " << iSmType << iSm << iRpc <<
" with " << gMinuit->fCstatu;
3800 dYShift = dYMeanFit - dYMeanAv;
3801 LOG(debug) << Form(
"CalibY for TSR %d%d%d: DY %5.2f, Fit %5.2f, Av %5.2f ", iSmType, iSm, iRpc, dYShift,
3802 dYMeanFit, dYMeanAv);
3805 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
3807 Double_t dTYOff = 0;
3809 YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
3812 if (
fPosYMaxScal < 1.1 && iSmType != 5 && iSmType != 8) {
3813 htempPos_py = htempPos->ProjectionY(Form(
"%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
3814 if (htempPos_py->GetEntries() >
fdYFitMin) {
3815 LOG(debug1) << Form(
"Determine YMean in %s of channel %d by "
3816 "length fit with %6.3f to %d entries",
3817 htempPos->GetName(), iCh, dYLenFit, (
Int_t) htempPos_py->GetEntries());
3822 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3825 Double_t fp[4] = {1., 3 * 0.};
3827 for (
Int_t iPar = 2; iPar < 4; iPar++)
3829 fp[iPar] =
fhSmCluFpar[iSmType][iPar]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3832 Double_t* fpp = &fp[0];
3833 fit_ybox(htempPos_py, dYLenFit, fpp);
3834 TF1* ff = htempPos_py->GetFunction(
"YBox");
3836 LOG(debug1) << Form(
"FitPar1 %6.3f Err %6.3f, Par3 %6.3f Err %6.3f ", ff->GetParameter(1),
3837 ff->GetParError(1), ff->GetParameter(3), ff->GetParError(3));
3840 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.05) {
3842 YMean = ff->GetParameter(3);
3844 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3845 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in TSRC " << iSmType
3846 << iSm << iRpc << iCh <<
", chi2 " << ff->GetChisquare()
3847 << Form(
", striplen (%5.2f), %4.2f -> %4.2f, "
3848 "%4.1f: %7.2f+/-%5.2f, pos res "
3849 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
3851 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
3852 ff->GetParameter(3), ff->GetParError(3));
3854 for (
Int_t iPar = 0; iPar < 4; iPar++)
3855 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc),
3856 ff->GetParameter(2 + iPar));
3861 LOG(info) <<
"FBad YBox " << htempPos_py->GetEntries() <<
" entries in TSRC " << iSmType << iSm
3862 << iRpc << iCh <<
", chi2 " << ff->GetChisquare()
3863 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3864 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3866 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
3867 ff->GetParameter(3), ff->GetParError(3));
3876 ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) /
fDigiBdfPar->
GetSigVel(iSmType, iSm, iRpc);
3879 TH1* hTy = (TH1*) htempPos->ProjectionY(Form(
"%s_py%d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
3881 Double_t dNPeak = hTy->GetBinContent(hTy->GetMaximumBin());
3883 Double_t dFMean = hTy->GetBinCenter(hTy->GetMaximumBin());
3884 Double_t dFLim = 2.0;
3885 Double_t dBinSize = hTy->GetBinWidth(1);
3886 dFLim = TMath::Max(dFLim, 5. * dBinSize);
3887 TFitResultPtr fRes = hTy->Fit(
"gaus",
"SQM",
"", dFMean - dFLim, dFMean + dFLim);
3889 if (fRes != 0 && (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED"))) {
3891 LOG(warn) <<
"CalibY "
3892 << Form(
"TSRC %d%d%d%d gaus %8.2f %8.2f %8.2f for TM %8.2f, YM %6.2f", iSmType, iSm,
3893 iRpc, iCh, fRes->Parameter(0), fRes->Parameter(1), fRes->Parameter(2),
3899 LOG(info) <<
"CalibY3BAD " << hTy->GetName()
3900 << Form(
" TSRC %d%d%d%d, stat: %s", iSmType, iSm, iRpc, iCh, gMinuit->fCstatu.Data());
3903 if (iSmType == 0 && iSm == 2 && iRpc == 0 && iCh == 10)
3904 LOG(info) <<
"CalibY3 "
3905 << Form(
"TSRC %d%d%d%d TY %8.2f, %8.2f, YM %6.2f", iSmType, iSm, iRpc, iCh,
3906 ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1)
3912 if (iSmType == 0 && iSm == 2 && iRpc == 0 && iCh == 10)
3913 LOG(info) <<
"CalibYP " << Form(
"%s TY %8.3f, YM %6.3f ", htempPos->GetName(), dTYOff, YMean);
3915 Double_t TMean = ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
3917 TH1* hTy = (TH1*) htempTOff->ProjectionY(Form(
"%s_py%d", htempTOff->GetName(), iCh), iCh + 1, iCh + 1);
3919 Double_t dNPeak = hTy->GetBinContent(hTy->GetMaximumBin());
3921 Double_t dFMean = hTy->GetBinCenter(hTy->GetMaximumBin());
3922 Double_t dFLim = 2.0;
3923 Double_t dBinSize = hTy->GetBinWidth(1);
3924 dFLim = TMath::Max(dFLim, 10. * dBinSize);
3925 TFitResultPtr fRes = hTy->Fit(
"gaus",
"SQM",
"", dFMean - dFLim, dFMean + dFLim);
3927 if (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED")) {
3930 LOG(info) <<
"CalibF "
3931 << Form(
"TSRC %d%d%d%d, %s gaus %8.2f %8.2f %8.2f for "
3932 "TM %8.2f, TRef %6.2f",
3933 iSmType, iSm, iRpc, iCh, htempTOff->GetName(), fRes->Parameter(0),
3934 fRes->Parameter(1), fRes->Parameter(2), TMean, dTBeamRefMean);
3935 TMean = fRes->Parameter(1);
3942 LOG(info) << Form(
"CalibR TSRC %d%d%d%d: ", iSmType, iSm, iRpc, iCh) <<
"TM " << TMean <<
", Ref "
3944 TMean -= dTBeamRefMean;
3947 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
3948 Double_t dOff0 =
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
3949 Double_t dOff1 =
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1];
3950 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3951 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3956 LOG(info) << Form(
"CalibB %d,%2d,%2d: TSRC %d%d%d%d, hits %6.0f, YM %6.3f"
3957 ", dTY %6.3f, TM %8.3f %8.3f, Off %8.3f,%8.3f -> %8.3f,%8.3f ",
3959 htempTOff_px->GetBinContent(iCh + 1), YMean, dTYOff, TMean, dTBeamRefMean, dOff0,
3960 dOff1,
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3961 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3971 for (
Int_t iSide = 0; iSide < 2; iSide++) {
3972 Int_t ib = iCh * 2 + 1 + iSide;
3973 TH1* hbin = htempTot->ProjectionY(Form(
"%s_bin%d", htempTot->GetName(), ib), ib, ib);
3974 if (100 > hbin->GetEntries())
continue;
3976 Int_t iBmax = hbin->GetMaximumBin();
3977 TAxis* xaxis = hbin->GetXaxis();
3978 Double_t Xmax = xaxis->GetBinCenter(iBmax) /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
3981 LOG(warning) <<
"XOff changed for "
3982 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f", iSmType, iSm, iRpc, iSide,
3983 XOff,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3986 Double_t TotMean = hbin->GetMean();
3987 Double_t dCtsTot = hbin->GetEntries();
3990 if (hbin->GetBinContent(hbin->GetNbinsX() > 0))
3991 TotMean = xaxis->GetBinCenter(hbin->GetNbinsX() - 1);
3992 LOG(info) <<
"TotInvalid " << hbin->GetName() <<
": " << TotMean;
3994 double dFMean = hbin->GetBinCenter(iBmax);
3995 double dFLim = dFMean * 0.5;
3996 LOG(info) << Form(
"FitTot TSRC %d%d%d%2d: Mean %6.2f, Width %6.2f ", iSmType, iSm, iRpc, ib,
3999 TFitResultPtr fRes = hbin->Fit(
"gaus",
"SQM",
"", dFMean - dFLim, dFMean + dFLim);
4000 if (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED")) {
4001 TotMean = fRes->Parameter(1);
4005 LOG(warn) <<
"TotFitFail " << hbin->GetName() <<
": " << TotMean <<
", wid " << dFLim <<
", "
4006 << gMinuit->fCstatu;
4013 TotMean = xaxis->GetBinCenter(hbin->GetNbinsX() - 1);
4014 LOG(warn) <<
"TotooR " << hbin->GetName() <<
": " << TotMean <<
", gain "
4015 <<
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] <<
", ovfl "
4016 << hbin->GetBinContent(hbin->GetNbinsX());
4019 if (15 == iSmType) {
4020 LOG(warning) <<
"Gain for "
4021 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4022 "gain %f, modg %f ",
4023 iSmType, iSm, iRpc, iSide, TotMean, htempTot_Mean->GetBinContent(ib),
4026 if (0.001 < TotMean) {
4031 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4032 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) {
4033 LOG(warning) <<
"CbmTofEventClusterizer::FillCalHist:"
4034 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
4035 << YMean <<
", TMean " << TMean <<
" -> "
4036 << Form(
" %f %f %f %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4037 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4038 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4039 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4042 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4048 Double_t dGain0 =
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0];
4049 Double_t dGain1 =
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1];
4050 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4051 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4052 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain0;
4053 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain1;
4058 htempPos_pfx->Reset();
4059 htempTOff_pfx->Reset();
4060 htempTot_Mean->Reset();
4061 htempTot_Off->Reset();
4063 Double_t TOff0_mean = 0.;
4064 Double_t TOff1_mean = 0.;
4065 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4067 TOff0_mean +=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
4068 TOff1_mean +=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1];
4070 TOff0_mean /= (Double_t) iNbCh;
4071 TOff1_mean /= (Double_t) iNbCh;
4073 const Double_t TMaxDev = TMath::Max(20., htempTOff->GetYaxis()->GetXmax());
4074 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4076 if (TMath::Abs(TOff0_mean -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]) > TMaxDev) {
4077 LOG(warn) << Form(
"TSRC0 %d%d%d%d limit %8.3f %8.3f %8.3f ", iSmType, iSm, iRpc, iCh,
4078 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0], TOff0_mean, TMaxDev);
4079 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = TOff0_mean;
4081 if (TMath::Abs(TOff1_mean -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) > TMaxDev) {
4082 LOG(warn) << Form(
"TSRC1 %d%d%d%d limit %8.3f %8.3f %8.3f", iSmType, iSm, iRpc, iCh,
4083 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1], TOff1_mean, TMaxDev);
4084 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = TOff1_mean;
4088 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4092 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4094 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4095 htempPos_pfx->Fill(iCh, YMean);
4096 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4097 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got "
4098 << htempPos_pfx->GetBinContent(iCh) <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4099 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected " << YMean;
4101 htempTOff_pfx->Fill(iCh, TMean);
4102 if (iSmType == 9 && iSm == 0 && iRpc == 0 && iCh == 10)
4103 LOG(info) << Form(
"CalibU %d,%2d,%2d: TSRC %d%d%d%d, hits %6.0f, YM %6.3f"
4104 ", TM %8.3f, OffM %8.3f,%8.3f ",
4106 htempTOff_px->GetBinContent(iCh + 1), YMean, TMean, TOff0_mean, TOff1_mean);
4108 for (
Int_t iSide = 0; iSide < 2; iSide++) {
4109 htempTot_Mean->SetBinContent(iCh * 2 + 1 + iSide,
4111 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4116 LOG(debug1) <<
" Updating done ... write to file ";
4117 htempPos_pfx->Write();
4118 htempTOff_pfx->Write();
4120 htempTot_Mean->Write();
4121 htempTot_Off->Write();
4124 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
4128 TDirectory* curdir = gDirectory;
4130 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4131 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4132 gDirectory->cd(curdir->GetPath());
4133 if (NULL != hCorDelTof) {
4134 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4135 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4136 hCorDelTofout->Write();
4139 LOG(debug) <<
" No CorDelTof histo "
4140 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
4144 LOG(debug) <<
" Store old walk histos to file ";
4146 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4154 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4155 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4156 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4157 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
4158 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
4159 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4162 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
4165 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
4174 LOG(debug) <<
"WriteHistos: restore Offsets, Gains and Walk, save DelTof for "
4175 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
4176 htempPos_pfx->Reset();
4177 htempTOff_pfx->Reset();
4178 htempTot_Mean->Reset();
4179 htempTot_Off->Reset();
4180 for (
Int_t iCh = 0; iCh < iNbCh; iCh++) {
4183 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4185 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4186 htempPos_pfx->Fill(iCh, YMean);
4187 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4188 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got "
4189 << htempPos_pfx->GetBinContent(iCh) <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4190 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected " << YMean;
4192 htempTOff_pfx->Fill(iCh, TMean);
4194 for (
Int_t iSide = 0; iSide < 2; iSide++) {
4195 htempTot_Mean->SetBinContent(
4196 iCh * 2 + 1 + iSide,
4198 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4202 LOG(debug1) <<
" Restoring of Offsets and Gains done ... ";
4203 htempPos_pfx->Write();
4204 htempTOff_pfx->Write();
4206 htempTot_Mean->Write();
4207 htempTot_Off->Write();
4210 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4218 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4219 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4220 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4221 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
4222 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
4223 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4226 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
4229 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
4242 if (NULL == h2tmp) {
4243 LOG(debug) << Form(
"WriteHistos: histo not available for SmT %d, Sm %d, Rpc %d", iSmType, iSm, iRpc);
4246 Int_t iNEntries = h2tmp->GetEntries();
4249 TProfile* htmp = h2tmp->ProfileX(
"_pfx", 1, h2tmp->GetNbinsY());
4250 TH1D* h1tmp = h2tmp->ProjectionX(
"_px", 1, h2tmp->GetNbinsY());
4254 Double_t dNEntriesSum = 0.;
4256 Double_t dNEntries = h1tmp->GetBinContent(iBx + 1);
4258 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] += ((TProfile*) htmp)->GetBinContent(iBx + 1);
4259 dDelMean +=
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * dNEntries;
4260 dNEntriesSum += dNEntries;
4262 dDelMean /= dNEntriesSum;
4264 LOG(debug) << Form(
" Update DelTof correction for SmT %d, Sm %d, "
4265 "Rpc %d, Sel%d: Entries %d, Mean shift %6.1f",
4266 iSmType, iSm, iRpc, iSel, iNEntries, dDelMean);
4269 h1tmp->SetBinContent(iBx + 1,
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] - dDelMean);
4272 h1tmp->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4279 TDirectory* curdir = gDirectory;
4281 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4282 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4283 gDirectory->cd(curdir->GetPath());
4284 if (NULL != hCorDelTof) {
4285 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4286 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4287 LOG(debug) <<
" Save existing CorDelTof histo "
4288 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
4289 hCorDelTofout->Write();
4292 LOG(debug) <<
" No CorDelTof histo "
4293 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
4303 Int_t iYCalMode = 0;
4305 LOG(debug) <<
"WriteHistos (calMode==5): update Offsets and Gains, "
4306 "keep Walk and DelTof for "
4307 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with " << iNbCh <<
" channels "
4308 <<
" using selector " <<
fCalSel;
4310 Double_t dVscal = 1.;
4314 dVscal =
fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
4315 if (dVscal == 0.) dVscal = 1.;
4316 dVW =
fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc + iRpc + 1);
4318 if (dVW < 0.1) dVW = 0.1;
4320 Double_t dYShift = 0;
4321 Double_t dYMeanAv = 0.;
4322 Double_t dYMeanFit = 0.;
4323 Double_t dYLenFit = 0.;
4324 Double_t YMean = 0.;
4327 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
4330 dYMeanAv = htempPos_py->GetMean();
4331 LOG(debug1) << Form(
"Determine YMeanAv in %s by fit to %d entries", htempPos->GetName(),
4332 (
Int_t) htempPos_py->GetEntries());
4337 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
4340 switch (iYCalMode) {
4343 TF1* ff = htempPos_py->GetFunction(
"YBox");
4344 if (NULL != ff && (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED"))) {
4347 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2) {
4349 LOG(info) <<
"FAvRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm
4350 << iRpc <<
", stat: " << gMinuit->fCstatu
4351 << Form(
", chi2 %6.2f, striplen (%5.2f): "
4352 "%7.2f+/-%5.2f, pos res "
4353 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
4355 2. * ff->GetParameter(1), 2. * ff->GetParError(1), ff->GetParameter(2),
4356 ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
4358 dYMeanFit = ff->GetParameter(3);
4359 dYLenFit = 2. * ff->GetParameter(1);
4360 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
4361 for (
Int_t iPar = 0; iPar < 4; iPar++)
4362 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc),
4363 ff->GetParameter(2 + iPar));
4367 LOG(info) <<
"FAvBad YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm
4368 << iRpc <<
", chi2 " << ff->GetChisquare() <<
", stat: " << gMinuit->fCstatu
4369 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
4370 "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
4372 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
4373 ff->GetParameter(3), ff->GetParError(3));
4377 LOG(info) <<
"FAvFailed for TSR " << iSmType << iSm << iRpc <<
", status: " << gMinuit->fCstatu
4378 <<
" of " << htempPos->GetName();
4380 dYShift = dYMeanFit - dYMeanAv;
4381 LOG(debug) << Form(
"CalibY for TSR %d%d%d: DY %5.2f, Fit %5.2f, Av %5.2f ", iSmType, iSm, iRpc,
4382 dYShift, dYMeanFit, dYMeanAv);
4387 LOG(debug) << Form(
"EdgeY for %s, TSR %d%d%d: DY %5.2f, Len %5.2f, Size %5.2f ",
4388 htempPos_py->GetName(), iSmType, iSm, iRpc, dRes[1], dRes[0],
4399 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4401 Double_t dTYOff = 0;
4402 Double_t TMean = 0.;
4408 htempPos_py = htempPos->ProjectionY(Form(
"%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
4409 if (htempPos_py->GetEntries() >
fdYFitMin) {
4410 LOG(info) << Form(
"Determine YMean in %s of channel %d by length fit with %6.3f to %d entries",
4411 htempPos->GetName(), iCh, dYLenFit, (
Int_t) htempPos_py->GetEntries());
4416 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
4420 switch (iYCalMode) {
4422 Double_t fp[4] = {1., 3 * 0.};
4424 for (
Int_t iPar = 2; iPar < 4; iPar++)
4426 fp[iPar] =
fhSmCluFpar[iSmType][iPar]->GetBinContent(iSm * iNbRpc + iRpc + 1);
4429 Double_t* fpp = &fp[0];
4430 fit_ybox(htempPos_py, dYLenFit, fpp);
4431 TF1* ff = htempPos_py->GetFunction(
"YBox");
4433 LOG(debug1) <<
"FStat: " << gMinuit->fCstatu
4434 << Form(
", FPar1 %6.3f Err %6.3f, Par3 %6.3f Err %6.3f ", ff->GetParameter(1),
4435 ff->GetParError(1), ff->GetParameter(3), ff->GetParError(3));
4438 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.05) {
4440 YMean = ff->GetParameter(3);
4442 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
4443 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in TSRC " << iSmType
4444 << iSm << iRpc << iCh <<
", chi2 " << ff->GetChisquare()
4445 << Form(
", striplen (%5.2f), %4.2f -> %4.2f, "
4446 "%4.1f: %7.2f+/-%5.2f, pos res "
4447 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
4449 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
4450 ff->GetParameter(3), ff->GetParError(3));
4452 for (
Int_t iPar = 0; iPar < 4; iPar++)
4453 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc),
4454 ff->GetParameter(2 + iPar));
4459 LOG(info) <<
"FBad YBox " << htempPos_py->GetEntries() <<
" entries in TSRC " << iSmType
4460 << iSm << iRpc << iCh <<
", chi2 " << ff->GetChisquare()
4461 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
4462 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
4464 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
4465 ff->GetParameter(3), ff->GetParError(3));
4472 double dXrange = 2 * htempPos_py->GetXaxis()->GetXmax();
4473 double dNbinsX = htempPos_py->GetNbinsX();
4475 htempPos_py->Integral(htempPos_py->GetXaxis()->GetXmin(), htempPos_py->GetXaxis()->GetXmax());
4476 double dBinWidth = dXrange / dNbinsX;
4478 double dCtsPerBin = dEntries / dNbinFillExpect;
4479 double dThr = dCtsPerBin / 10.;
4481 LOG(warn) <<
"Few entries in " << htempPos_py->GetName() <<
": " << dEntries <<
", "
4482 << htempPos_py->GetEntries() <<
" -> thr " << dThr;
4488 "EdgeY Thr %4.1f, TSRC %d%d%d%02d: DY %5.2f, Len %5.2f, Size %5.2f: dev %6.3f ", dThr,
4502 ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) /
fDigiBdfPar->
GetSigVel(iSmType, iSm, iRpc);
4504 if (iSmType != 5 && iSmType != 8) {
4505 TH1* hTy = (TH1*) htempPos->ProjectionY(Form(
"%s_py%d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
4507 Double_t dNPeak = hTy->GetBinContent(hTy->GetMaximumBin());
4509 Double_t dFMean = hTy->GetBinCenter(hTy->GetMaximumBin());
4510 Double_t dFLim = 2.0;
4511 Double_t dBinSize = hTy->GetBinWidth(1);
4512 dFLim = TMath::Max(dFLim, 5. * dBinSize);
4513 TFitResultPtr fRes = hTy->Fit(
"gaus",
"SQM",
"", dFMean - dFLim, dFMean + dFLim);
4514 if (fRes == 0 && (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED"))) {
4517 LOG(warn) <<
"CalibY5 "
4518 << Form(
"TSRC %d%d%d%d gaus %8.2f %8.2f %8.2f for TM %8.2f, YM %6.2f", iSmType, iSm,
4519 iRpc, iCh, fRes->Parameter(0), fRes->Parameter(1), fRes->Parameter(2),
4525 LOG(info) <<
"CalibY5BAD "
4526 << Form(
"TSRC %d%d%d%d, stat: %s for %s", iSmType, iSm, iRpc, iCh,
4527 gMinuit->fCstatu.Data(), htempPos->GetName());
4535 (TH1*) htempTOff->ProjectionY(Form(
"%s_py%d", htempTOff->GetName(), iCh), iCh + 1, iCh + 1);
4537 Double_t dNPeak = hTy->GetBinContent(hTy->GetMaximumBin());
4539 Double_t dFMean = hTy->GetBinCenter(hTy->GetMaximumBin());
4540 Double_t dFLim = 0.5;
4541 Double_t dBinSize = hTy->GetBinWidth(1);
4542 dFLim = TMath::Max(dFLim, 5. * dBinSize);
4543 TFitResultPtr fRes = hTy->Fit(
"gaus",
"SQM",
"", dFMean - dFLim, dFMean + dFLim);
4544 if (fRes == 0 && (gMinuit->fCstatu.Contains(
"OK") || gMinuit->fCstatu.Contains(
"CONVERGED"))) {
4545 if (TMath::Abs(TMean - fRes->Parameter(1)) > 0.6)
4546 LOG(debug) <<
"CalibF5 "
4547 << Form(
"TSRC %d%d%d%d gaus %8.2f %8.2f %8.2f for "
4548 "TM %8.2f, YM %6.2f",
4549 iSmType, iSm, iRpc, iCh, fRes->Parameter(0), fRes->Parameter(1),
4550 fRes->Parameter(2), TMean, YMean);
4551 TMean = fRes->Parameter(1);
4554 LOG(info) <<
"CalibF5BAD "
4555 << Form(
"TSRC %d%d%d%d, stat: %s for %s", iSmType, iSm, iRpc, iCh,
4556 gMinuit->fCstatu.Data(), htempTOff->GetName());
4563 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
4564 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
4565 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
4567 if (iSmType == 9 && iSm == 0 && iRpc == 0 && iCh == 10)
4568 LOG(info) << Form(
"Calib: TSRC %d%d%d%d, hits %6.0f, TY %8.3f, TM %8.3f -> new Off %8.0f,%8.0f ",
4569 iSmType, iSm, iRpc, iCh, htempTOff_px->GetBinContent(iCh + 1), dTYOff, TMean,
4570 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4571 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4582 for (
Int_t iSide = 0; iSide < 2; iSide++) {
4583 Int_t ib = iCh * 2 + 1 + iSide;
4584 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
4585 if (100 > hbin->GetEntries())
continue;
4587 Int_t iBmax = hbin->GetMaximumBin();
4588 TAxis* xaxis = hbin->GetXaxis();
4589 Double_t Xmax = xaxis->GetBinCenter(iBmax) /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4592 LOG(warning) <<
"XOff changed for "
4593 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f", iSmType, iSm, iRpc, iSide,
4594 XOff,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4597 Double_t TotMean = hbin->GetMean();
4598 if (15 == iSmType) {
4599 LOG(warning) <<
"Gain for "
4600 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4601 "gain %f, modg %f ",
4602 iSmType, iSm, iRpc, iSide, TotMean, htempTot_Mean->GetBinContent(ib),
4605 if (0.001 < TotMean) {
4610 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4611 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) {
4612 LOG(warning) <<
"CbmTofEventClusterizer::FillCalHist:"
4613 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
4614 << YMean <<
", TMean " << TMean <<
" -> "
4615 << Form(
" %f %f %f %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4616 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4617 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4618 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4621 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4622 Double_t dGain = 0.5
4623 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4624 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4625 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4626 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4627 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4628 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4633 htempPos_pfx->Reset();
4634 htempTOff_pfx->Reset();
4635 htempTot_Mean->Reset();
4636 htempTot_Off->Reset();
4637 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4641 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4643 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4644 htempPos_pfx->Fill(iCh, YMean);
4645 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4646 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got "
4647 << htempPos_pfx->GetBinContent(iCh) <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4648 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected " << YMean;
4650 htempTOff_pfx->Fill(iCh, TMean);
4652 for (
Int_t iSide = 0; iSide < 2; iSide++) {
4653 htempTot_Mean->SetBinContent(iCh * 2 + 1 + iSide,
4655 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4660 LOG(debug1) <<
" Updating done ... write to file ";
4661 htempPos_pfx->Write();
4662 htempTOff_pfx->Write();
4664 htempTot_Mean->Write();
4665 htempTot_Off->Write();
4668 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
4672 TDirectory* curdir = gDirectory;
4674 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4675 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4676 gDirectory->cd(curdir->GetPath());
4677 if (NULL != hCorDelTof) {
4678 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4679 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
4680 hCorDelTofout->Write();
4683 LOG(debug) <<
" No CorDelTof histo "
4684 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
4688 LOG(debug) <<
" Store old walk histos to file ";
4690 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
4698 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4699 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4700 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4701 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
4702 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
4703 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4706 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
4709 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
4715 default: LOG(debug) <<
"WriteHistos: update mode " <<
fCalMode <<
" not yet implemented";
4758 for (
Int_t iPar = 0; iPar < 4; iPar++)
4770 gDirectory = oldDir;
5672 Double_t dWeightedTime = 0.0;
5673 Double_t dWeightedPosX = 0.0;
5674 Double_t dWeightedPosY = 0.0;
5675 Double_t dWeightedPosZ = 0.0;
5676 Double_t dWeightsSum = 0.0;
5681 Int_t iNbChanInHit = 0;
5683 Int_t iLastChan = -1;
5684 Double_t dLastPosX = 0.0;
5685 Double_t dLastPosY = 0.0;
5686 Double_t dLastTime = 0.0;
5688 Double_t dPosX = 0.0;
5689 Double_t dPosY = 0.0;
5690 Double_t dPosZ = 0.0;
5691 Double_t dTime = 0.0;
5692 Double_t dTimeDif = 0.0;
5693 Double_t dTotS = 0.0;
5696 for (
Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
5699 for (
Int_t iSm = 0; iSm < iNbSm; iSm++)
5700 for (
Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
5703 LOG(debug2) <<
"RPC - Loop " << Form(
" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
5711 dWeightedTime = 0.0;
5712 dWeightedPosX = 0.0;
5713 dWeightedPosY = 0.0;
5714 dWeightedPosZ = 0.0;
5723 LOG(debug2) <<
"ChanOrient "
5731 for (
Int_t iCh = 0; iCh < iNbCh; iCh++) {
5732 LOG(debug3) <<
"VDigisize "
5733 << Form(
" T %3d Sm %3d R %3d Ch %3d Size %3lu ", iSmType, iSm, iRpc, iCh,
5735 if (0 ==
fStorDigi[iSmType][iSm * iNbRpc + iRpc].
size())
continue;
5737 if (0 <
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size())
5740 while (1 <
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size()) {
5742 while ((
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetSide()
5743 == (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetSide()) {
5746 if (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size() > 2) {
5747 LOG(debug) <<
"SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh <<
", Times: "
5748 << Form(
"%f", (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()) <<
", "
5749 << Form(
"%f", (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime())
5751 << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
5752 - (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
5753 <<
", array size: " <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
5754 if (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetSide()
5755 ==
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide()) {
5756 LOG(debug) <<
"3 consecutive SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh
5757 <<
", Times: " << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
5758 <<
", " << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
5760 << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
5761 - (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
5762 <<
", array size: " <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
5763 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5764 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5766 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5769 if (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
5770 -
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetTime()
5771 >
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
5772 -
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1]->GetTime()) {
5773 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5774 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5776 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5779 LOG(debug) << Form(
"Ev %8.0f, digis not properly time ordered, TSRCS "
5781 fdEvent, iSmType, iSm, iRpc, iCh,
5782 (
Int_t)
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide());
5783 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5784 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
5786 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
5791 LOG(debug2) <<
"SameSide Erase fStor entries(d) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc
5793 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5794 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5796 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5798 if (2 >
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size())
break;
5802 LOG(debug2) <<
"digis processing for "
5803 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ", iSmType, iSm, iRpc, iCh,
5805 if (2 >
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size()) {
5806 LOG(debug) << Form(
"Leaving digi processing for TSRC %d%d%d%d, size %3lu", iSmType, iSm, iRpc, iCh,
5824 LOG(error) <<
"CbmTofEventClusterizer::BuildClusters: no geometry info! "
5825 << Form(
" %3d %3d %3d %3d 0x%08x", iSmType, iSm, iRpc, iCh, iChId);
5831 if (iChId == 0x13800036) {
5832 const double local[3] = {3 * 0};
5834 fCellIdGeoMap[iChId]->GetMatrix()->LocalToMaster(local, global);
5835 LOG(info) <<
"GeoTest3: " << global[0] <<
", " << global[1] <<
", " << global[2];
5844 LOG(debug2) <<
" " << xDigiA->
ToString();
5845 LOG(debug2) <<
" " << xDigiB->
ToString();
5848 if ((5 == iSmType || 8 == iSmType) && dTimeDif != 0.) {
5850 LOG(error) <<
"BuildHits: Pad hit in TSRC " << iSmType << iSm << iRpc << iCh <<
" inconsistent, "
5851 <<
"t " << xDigiA->
GetTime() <<
", " << xDigiB->
GetTime() <<
" -> " << dTimeDif
5852 <<
", Tot " << xDigiA->
GetTot() <<
", " << xDigiB->
GetTot();
5853 LOG(debug) <<
" " << xDigiA->
ToString();
5854 LOG(debug) <<
" " << xDigiB->
ToString();
5864 &&
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size() > 2) {
5865 LOG(debug) <<
"Hit candidate outside correlation window, check for "
5866 "better possible digis, "
5867 <<
" mul " <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
5870 Double_t dPosYN = 0.;
5871 Double_t dTimeDifN = 0;
5882 if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
5883 LOG(debug) <<
"Replace digi on side " << xDigiC->
GetSide() <<
", yPosNext " << dPosYN
5884 <<
" old: " << dPosY;
5885 dTimeDif = dTimeDifN;
5889 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5890 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5892 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5896 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5897 ++(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
5899 ++(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
5907 LOG(fatal) <<
"Wrong combinations of digis " <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]
5908 <<
"," <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1];
5912 LOG(debug1) <<
"Remove digis on TSRC " << iSmType << iSm << iRpc << iCh <<
" with dPosY " << dPosY
5914 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5915 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5917 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5931 LOG(debug1) <<
"NbChanInHit "
5932 << Form(
" %3d %3d %3d %3d %3d 0x%p %1.0f Time %f PosX %f "
5934 iNbChanInHit, iSmType, iRpc, iCh, iLastChan, xDigiA, xDigiA->
GetSide(), dTime,
5941 if (0 < iNbChanInHit) {
5942 if (iLastChan == iCh - 1) {
5953 if (TMath::Abs(dTime - dLastTime) <
fdMaxTimeDist && iLastChan == iCh - 1
5956 dWeightedTime += dTime * dTotS;
5957 dWeightedPosX += dPosX * dTotS;
5958 dWeightedPosY += dPosY * dTotS;
5959 dWeightedPosZ += dPosZ * dTotS;
5960 dWeightsSum += dTotS;
5966 LOG(debug1) <<
" Add Digi and erase fStor entries(a): NbChanInHit " << iNbChanInHit <<
", "
5967 << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5969 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5970 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5971 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5972 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5974 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5976 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5981 dWeightedTime /= dWeightsSum;
5982 dWeightedPosX /= dWeightsSum;
5983 dWeightedPosY /= dWeightsSum;
5984 dWeightedPosZ /= dWeightsSum;
5987 Double_t hitpos_local[3];
5988 hitpos_local[0] = dWeightedPosX;
5989 hitpos_local[1] = dWeightedPosY;
5990 hitpos_local[2] = dWeightedPosZ;
5997 Double_t hitpos[3] = {3 * 0.};
5999 fCellIdGeoMap[iChId]->GetMatrix()->LocalToMaster(hitpos_local, hitpos);
6006 LOG(debug1) << Form(
" LocalToMaster: (%6.1f,%6.1f,%6.1f) "
6007 "->(%6.1f,%6.1f,%6.1f)",
6008 hitpos_local[0], hitpos_local[1], hitpos_local[2], hitpos[0], hitpos[1],
6011 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
6016 TVector3 hitPosErr(0.5, 0.5, 0.5);
6030 if (iChm < 0) iChm = 0;
6031 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
6041 LOG(debug) <<
"Save Hit "
6042 << Form(
" %3d %3d 0x%08x %3d %3d %3d %f %f",
fiNbHits, iNbChanInHit, iDetId, iChm,
6043 iLastChan, iRefId, dWeightedTime, dWeightedPosY)
6044 <<
", DigiSize: " <<
vDigiIndRef.size() <<
", DigiInds: " << sRef;
6049 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits <<
": vDigiIndRef.size()";
6055 LOG(debug) <<
"Store Hit twice? "
6056 <<
" fiNbHits " <<
fiNbHits <<
", "
6057 << Form(
"0x%08x, MatchCollSize %d, IndRefSize %lu ", iDetId,
6063 LOG(debug) <<
" Digi " << i <<
" " << pDigiC->
ToString();
6067 <<
"Insufficient CalDigiVec size for i " << i <<
", Ind " <<
vDigiIndRef.at(i);
6077 LOG(fatal) <<
"DigiMatchColl has insufficient size "
6081 if (NULL != digiMatchL)
6084 LOG(debug) <<
"report link " << i <<
"(" << digiMatchL->
GetNofLinks() <<
"), ind "
6089 LOG(warn) << Form(
"Invalid DigiRefInd for det 0x%08x", iDetId);
6094 LOG(warn) <<
"Invalid CalDigiInd";
6098 LOG(debug) <<
" DigiL " << pDigiC->
ToString();
6101 LOG(warn) <<
"Invalid digMatch Link at Index " <<
fiNbHits - 1;
6104 LOG(debug) <<
"Current HitsColl length " <<
fTofHitsColl->GetEntriesFast();
6113 Int_t(dWeightsSum * 10.));
6121 LH_store(iSmType, iSm, iRpc, iChm, pHit);
6149 dWeightedTime = dTime * dTotS;
6150 dWeightedPosX = dPosX * dTotS;
6151 dWeightedPosY = dPosY * dTotS;
6152 dWeightedPosZ = dPosZ * dTotS;
6153 dWeightsSum = dTotS;
6158 LOG(debug2) <<
" Next fStor Digi " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh
6159 <<
", Dig0 " << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]) <<
", Dig1 "
6160 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
6164 LOG(debug2) <<
" Erase fStor entries(b) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch"
6166 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6167 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6168 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6169 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6171 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6173 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6189 LOG(debug) << Form(
"1.Hit on TSRC %d%d%d%d, time: %f, PosY %f, Tdif %f ", iSmType, iSm, iRpc, iCh,
6190 dTime, dPosY, dTimeDif);
6193 dWeightedTime = dTime * dTotS;
6194 dWeightedPosX = dPosX * dTotS;
6195 dWeightedPosY = dPosY * dTotS;
6196 dWeightedPosZ = dPosZ * dTotS;
6197 dWeightsSum = dTotS;
6205 LOG(debug2) <<
" Erase fStor entries(c) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch"
6207 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6208 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6209 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6210 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6212 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6214 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
6232 if (
AddNextChan(iSmType, iSm, iRpc, iLastChan, dLastPosX, dLastPosY, dLastTime, dWeightsSum)) {
6236 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
6237 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
6239 LOG(debug2) <<
"finished V-RPC"
6240 << Form(
" %3d %3d %3d %d %f %fx", iSmType, iSm, iRpc,
fTofHitsColl->GetEntriesFast(),
6241 dLastPosX, dLastPosY);
6245 LOG(error) <<
"=> Cluster building "
6246 <<
"from digis to hits not implemented for pads, Sm type " << iSmType <<
" Rpc " << iRpc;
6252 if (0 < iNbChanInHit) {
6253 LOG(debug1) <<
"Process cluster " << iNbChanInHit;
6257 LOG(debug1) <<
"H-Hit ";
6260 LOG(debug2) <<
"V-Hit ";
6262 dWeightedTime /= dWeightsSum;
6263 dWeightedPosX /= dWeightsSum;
6264 dWeightedPosY /= dWeightsSum;
6265 dWeightedPosZ /= dWeightsSum;
6268 Double_t hitpos_local[3] = {3 * 0.};
6269 hitpos_local[0] = dWeightedPosX;
6270 hitpos_local[1] = dWeightedPosY;
6271 hitpos_local[2] = dWeightedPosZ;
6278 Double_t hitpos[3] = {3 * 0.};
6280 fCellIdGeoMap[iChId]->GetMatrix()->LocalToMaster(hitpos_local, hitpos);
6287 LOG(debug1) << Form(
" LocalToMaster for V-node: "
6288 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
6289 hitpos_local[0], hitpos_local[1], hitpos_local[2], hitpos[0], hitpos[1], hitpos[2]);
6291 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
6295 TVector3 hitPosErr(0.5, 0.5, 0.5);
6311 if (iChm < 0) iChm = 0;
6312 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
6316 TString cstr =
"Save V-Hit ";
6317 cstr += Form(
" %3d %3d 0x%08x TSR %d%d%d Ch %2d %8.2f %6.2f",
6318 fiNbHits, iNbChanInHit, iDetId, iSmType, iSm, iRpc, iChm, dWeightedTime, dWeightedPosY);
6321 cstr +=
", DigiInds: ";
6331 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits <<
": vDigiIndRef.size()";
6337 LOG(debug) <<
"Store Hit twice? "
6338 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
6347 Int_t(dWeightsSum * 10.));
6355 LH_store(iSmType, iSm, iRpc, iChm, pHit);
6383 LOG(debug2) <<
" Fini-A " << Form(
" %3d %3d %3d M%3d", iSmType, iSm, iRpc,
fviClusterMul[iSmType][iSm][iRpc]);
6385 LOG(debug2) <<
" Fini-B " << Form(
" %3d ", iSmType);