871 TDirectory* oldir = gDirectory;
874 new TH1I(
"TofTestBeamClus_ClustBuildTime",
"Time needed to build clusters in each event; Time [s]", 4000, 0.0, 4.0);
888 Double_t YSCAL = 50.;
903 LOG(info) << Form(
"Channel info for module type %d obtained from counter: %d-%d-%d", iS, iS, iSM, 0);
909 LOG(warning) <<
"No DigiPar for SmType " << Form(
"%d, 0x%08x", iS, iUCellId);
915 new TH2F(Form(
"cl_SmT%01d_Pos", iS), Form(
"Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
919 Double_t TSumMax = 1.E3;
922 new TH2F(Form(
"cl_SmT%01d_TOff", iS), Form(
"Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
926 TProfile* hSvelcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iS));
927 if (NULL == hSvelcur) {
929 new TProfile(Form(
"cl_SmT%01d_Svel", iS), Form(
"Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
938 for (Int_t iPar = 0; iPar < 4; iPar++) {
939 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar));
940 if (NULL == hFparcur) {
941 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Fpar%1d", iS, iPar) <<
" not found, recreate ...";
942 fhSmCluFpar[iS][iPar] =
new TProfile(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar),
943 Form(
"Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
948 fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
954 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
955 fhTSmCluPosition[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
956 Form(
"Clu position of SmType %d under Selector %02d; Sm+Rpc# "
961 fhTSmCluTOff[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
962 Form(
"Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
967 fhTSmCluTRun[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
968 Form(
"Clu TimeZero in SmType %d under Selector %02d; Event# "
977 LOG(info) <<
" Define Clusterizer histos for " << iNbDet <<
" detectors ";
1004 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1015 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1018 LOG(info) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1019 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx " <<
fChannelInfo->
GetSizex()
1027 if (NULL ==
fChannelInfo) LOG(warning) << Form(
"missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
1032 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
1033 Form(
"Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1", iRpcId, iSmId, iSmType),
1038 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
1039 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts", iRpcId, iSmId, iSmType),
1043 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
1044 Form(
"Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType), 3600.,
1047 fhRpcDTLastHits[iDetIndx] =
new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
1048 Form(
"Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
1049 "#DeltaT (ns)); counts",
1050 iRpcId, iSmId, iSmType),
1053 fhRpcDTLastHits_Tot[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1054 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1056 iRpcId, iSmId, iSmType),
1059 fhRpcDTLastHits_CluSize[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1060 Form(
"Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1062 iRpcId, iSmId, iSmType),
1063 100, 0., 10., 16, 0.5, 16.5);
1065 Double_t YSCAL = 50.;
1069 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1070 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]", iRpcId, iSmId, iSmType),
1074 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1075 Form(
"Clu position difference of Rpc #%03d in Sm %03d of type "
1076 "%d; Strip []; #Deltaypos(clu) [cm]",
1077 iRpcId, iSmId, iSmType),
1081 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1082 Form(
"Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1083 "%d; Strip []; #Deltaypos(mat) [cm]",
1084 iRpcId, iSmId, iSmType),
1087 Double_t TSumMax = 1.E3;
1090 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1091 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]", iRpcId, iSmId, iSmType),
1095 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1096 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1097 "[]; #DeltaTOff(clu) [ns]",
1098 iRpcId, iSmId, iSmType),
1102 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1103 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1104 "[]; #DeltaTOff(mat) [ns]",
1105 iRpcId, iSmId, iSmType),
1109 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1110 Form(
"Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]", iRpcId, iSmId, iSmType),
1114 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1115 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [ns]", iRpcId, iSmId, iSmType),
1120 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1121 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]", iRpcId, iSmId, iSmType),
1125 fhRpcCluAvWalk[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1126 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1130 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1131 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
nbClWalkBinX,
1137 for (Int_t iSide = 0; iSide < 2; iSide++) {
1139 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1140 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1151 LOG(info) <<
" Define Clusterizer monitoring histos ";
1154 Form(
"Cluster Multiplicity Correlation of Dut %d%d%d with Sel "
1155 "%d%d%d; Mul(Sel); Mul(Dut)",
1157 32, 0, 32, 32, 0, 32);
1160 "Space difference along channel direction between Digi pairs on "
1161 "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
1164 "Time difference between Digi pairs on adjacent channels; "
1165 "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1168 "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
1169 "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1170 5000, -10.0, 10.0, 2000, -5.0, 5.0);
1172 "Position difference between Point and Hit as function of Cluster "
1173 "Size; Cluster Size [Strips]; dX [cm]",
1174 100, 0.5, 100.5, 500, -50, 50);
1176 "Position difference between Point and Hit as function of Cluster "
1177 "Size; Cluster Size [Strips]; dY [cm]",
1178 100, 0.5, 100.5, 500, -50, 50);
1180 "Position difference between Point and Hit as "
1181 "function of Channel dif; Ch Dif [Strips]; dX [cm]",
1182 101, -50.5, 50.5, 500, -50, 50);
1184 "Position difference between Point and Hit as "
1185 "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1186 101, -50.5, 50.5, 500, -50, 50);
1188 "How many time per event the 2 digis on a channel "
1189 "were of the same side ; Counts/Event []",
1191 fhNbDigiPerChan =
new TH1I(
"Clus_NbDigiPerChan",
"Nb of Digis per channel; Nb Digis []", 100, 0.0, 100.0);
1197 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1198 fhSeldT[iSel] =
new TH2F(Form(
"cl_dt_Sel%02d", iSel), Form(
"Selector time %02d; dT [ns]", iSel), 99,
1216 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1224 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1227 LOG(debug1) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1228 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1246 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1248 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul", iSmType, iSmId, iRpcId, iSel),
1249 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1250 "under Selector %02d; M []; cnts",
1251 iRpcId, iSmId, iSmType, iSel),
1254 if (NULL ==
fhTRpcCluMul[iDetIndx][iSel]) LOG(fatal) <<
" Histo not generated !";
1256 Double_t YSCAL = 50.;
1260 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos", iSmType, iSmId, iRpcId, iSel),
1261 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d under "
1262 "Selector %02d; Strip []; ypos [cm]",
1263 iRpcId, iSmId, iSmType, iSel),
1266 Double_t TSumMax = 1.E4;
1269 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff", iSmType, iSmId, iRpcId, iSel),
1270 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1271 "Selector %02d; Strip []; TOff [ns]",
1272 iRpcId, iSmId, iSmType, iSel),
1277 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot", iSmType, iSmId, iRpcId, iSel),
1278 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1279 "Selector %02d; StripSide []; TOT [ns]",
1280 iRpcId, iSmId, iSmType, iSel),
1285 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size", iSmType, iSmId, iRpcId, iSel),
1286 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1287 "Selector %02d; Strip []; size [strips]",
1288 iRpcId, iSmId, iSmType, iSel),
1293 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk", iSmType, iSmId, iRpcId, iSel),
1294 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel", iSmType, iSmId, iRpcId, iSel),
1299 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSmId, iRpcId, iSel),
1300 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; TRef-TSel; T-TSel", iSmType, iSmId, iRpcId, iSel),
1305 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY", iSmType, iSmId, iRpcId, iSel),
1306 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1308 iSmType, iSmId, iRpcId, iSel),
1314 for (Int_t iSide = 0; iSide < 2; iSide++) {
1316 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide, iSel),
1317 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide,
1324 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH", iSmType, iSmId, iRpcId, iSel),
1325 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1326 "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1327 iRpcId, iSmId, iSmType, iSel),
1328 100, 0., 10., 99, -TSumMax, TSumMax);
1331 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH", iSmType, iSmId, iRpcId, iSel),
1332 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1333 "Selector %02d; log(#DeltaT (ns)); TOT [ns]",
1334 iRpcId, iSmId, iSmType, iSel),
1338 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH", iSmType, iSmId, iRpcId, iSel),
1339 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1340 "Selector %02d; log(#DeltaT (ns)); size [strips]",
1341 iRpcId, iSmId, iSmType, iSel),
1342 100, 0., 10., 10, 0.5, 10.5);
1345 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH", iSmType, iSmId, iRpcId, iSel),
1346 Form(
"Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1347 "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1348 iRpcId, iSmId, iSmType, iSel),
1349 100, 0., 10., 10, 0, 10);
1355 new TH1I(
"Clus_TofHitPerTrk",
"Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []", 2000, 0.0, 20.0);
1358 "Distribution of the Number of MCPoints associated "
1359 "to each TofHit; Nb MCPoint []",
1363 "Time resolution for TofHits containing Digis from a single MC "
1364 "Track; t(1st Mc Point) -tTofHit [ns]",
1365 10000, -25.0, 25.0);
1367 "Time resolution for TofHits containing Digis from a single MC "
1368 "Track; (1st Mc Point) -tTofHit [ns]",
1369 5000, -25.0, 25.0, 6, 0, 6);
1371 "Time resolution for TofHits containing Digis from a single MC "
1372 "Track; t(1st Mc Point) -tTofHit [ns]",
1373 2000, 0.0, 50.0, 2000, 0.0, 50.0);
1377 "Time resolution for TofHits containing Digis from a single "
1378 "TofPoint; tMcPoint -tTofHit [ns]",
1379 10000, -25.0, 25.0);
1381 "Time resolution for TofHits containing Digis from a single "
1382 "TofPoint; tMcPoint -tTofHit [ns]",
1383 5000, -25.0, 25.0, 6, 0, 6);
1385 "Time resolution for TofHits containing Digis "
1386 "from a single TofPoint; tMcPoint -tTofHit [ps]",
1387 2000, 0.0, 50.0, 2000, 0.0, 50.0);
1389 fhClusterSize =
new TH1I(
"Clus_ClusterSize",
"Cluster Size distribution; Cluster Size [Strips]", 100, 0.5, 100.5);
1391 new TH2I(
"Clus_ClusterSizeType",
1392 "Cluster Size distribution in each (SM type, Rpc) pair; Cluster "
1393 "Size [Strips]; 10*SM Type + Rpc Index []",
1396 fhTrackMul =
new TH1I(
"Clus_TrackMul",
"Number of MC tracks generating the cluster; MC Tracks multiplicity []", 100,
1399 "Cluster Size distribution as function of Number of MC tracks generating "
1400 "the cluster; Cluster Size [Strips]; MC tracks mul. []",
1401 100, 0.5, 100.5, 100, 0.5, 100.5);
1403 "Position of Clusters with only 1 MC tracks "
1404 "generating the cluster; X [cm]; Y [cm]",
1405 1500, -750, 750, 1000, -500, 500);
1407 "Position of Clusters with >1 MC tracks "
1408 "generating the cluster; X [cm]; Y [cm]",
1409 1500, -750, 750, 1000, -500, 500);
1410 fhAllTrkMulPos =
new TH2D(
"Clus_AllTrkMulPos",
"Position of all clusters generating the cluster; X [cm]; Y [cm]",
1411 1500, -750, 750, 1000, -500, 500);
1413 "Probability of having a cluster with multiple tracks as "
1414 "function of position; X [cm]; Y [cm]; Prob. [%]",
1415 1500, -750, 750, 1000, -500, 500);
1418 gDirectory->cd(oldir->GetPath());
1429 gGeoManager->CdTop();
1431 if (0 < iNbTofHits) {
1434 Double_t dTTrig[
iNSel];
1436 Double_t ddXdZ[
iNSel];
1437 Double_t ddYdZ[
iNSel];
1438 Double_t dSel2dXdYMin[
iNSel];
1440 Int_t iBeamRefMul = 0;
1441 Int_t iBeamAddRefMul = 0;
1445 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos() for " <<
iNSel <<
" triggers"
1453 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1466 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1468 if (NULL == pHit)
continue;
1475 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
1477 Int_t iDetIndx = it->second;
1489 LOG(fatal) << Form(
" <E> hit not stored in memory for TSRC %d%d%d%d", iSmType, iSm, iRpc, iCh);
1501 LOG(warning) << Form(
"Invalid time ordering in ev %8.0f in list of "
1502 "size %lu for TSRC %d%d%d%d: Delta t %f ",
1511 LOG(debug) <<
" pop from list size " <<
fvLastHits[iSmType][iSm][iRpc][iCh].size()
1512 << Form(
" outdated hits for ev %8.0f in TSRC %d%d%d%d",
fdEvent, iSmType, iSm, iRpc, iCh)
1513 << Form(
" with tHit - tLast %f ",
1518 LOG(fatal) << Form(
"Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
1520 fvLastHits[iSmType][iSm][iRpc][iCh].
size(), iSmType, iSm, iRpc, iCh,
1521 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
1522 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
1523 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
1524 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
1531 Double_t dTotSum = 0.;
1532 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
1535 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
1541 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
1543 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
1557 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1559 if (NULL == pHit)
continue;
1566 Double_t TotSum = 0.;
1567 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
1570 if (iDigInd0 < fTofCalDigisColl->GetEntriesFast()) {
1572 TotSum += pDig0->
GetTot();
1588 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos: BRefMul: " << iBeamRefMul <<
", " << iBeamAddRefMul;
1590 if (iBeamRefMul == 0)
return kFALSE;
1593 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1594 BSel[iSel] = kFALSE;
1602 dSel2dXdYMin[iSel] = 1.E300;
1610 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
1612 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos(): selector 0: DutMul "
1616 LOG(debug1) <<
"CbmTofTestBeamClusterizer::FillHistos(): Found selector 0";
1618 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1620 if (NULL == pHit)
continue;
1625 if (pHit->
GetTime() < dTTrig[iSel]) {
1626 dTTrig[iSel] = pHit->
GetTime();
1632 LOG(debug) << Form(
"Found selector 0 with mul %d from 0x%08x at %f ", iDutMul, pTrig[iSel]->GetAddress(),
1642 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
1644 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos(): selector 1: RefMul "
1647 LOG(debug1) <<
"CbmTofTestBeamClusterizer::FillHistos(): Found selector 1";
1649 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1651 if (NULL == pHit)
continue;
1655 if (pHit->
GetTime() < dTTrig[iSel]) {
1656 dTTrig[iSel] = pHit->
GetTime();
1662 LOG(debug) << Form(
"Found selector 1 with mul %d from 0x%08x at %f ", iRefMul, pTrig[iSel]->GetAddress(),
1668 LOG(info) <<
"CbmTofTestBeamClusterizer::FillHistos: selection not "
1674 dTTrig[iSel] =
dTRef;
1679 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1681 BSel[iSel] = kFALSE;
1684 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1686 if (NULL == pHit)
continue;
1689 Double_t dzscal = 1.;
1691 Double_t dSEl2dXdz = (pHit->
GetX() - pTrig[iSel]->GetX()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
1692 Double_t dSEl2dYdz = (pHit->
GetY() - pTrig[iSel]->GetY()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
1694 if (TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
1695 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
1698 Double_t dX2Y2 = TMath::Sqrt(dSEl2dXdz * dSEl2dXdz + dSEl2dYdz * dSEl2dYdz);
1699 if (dX2Y2 < dSel2dXdYMin[iSel]) {
1700 ddXdZ[iSel] = dSEl2dXdz;
1701 ddYdZ[iSel] = dSEl2dYdz;
1702 dSel2dXdYMin[iSel] = dX2Y2;
1746 UInt_t uTriggerPattern = 1;
1750 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1755 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1758 for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
1759 if (uTriggerPattern & (0x1 << uChannel)) {
1768 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1770 if (NULL == pHit)
continue;
1773 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
1775 Int_t iDetIndx = it->second;
1782 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1794 if (iBeamRefMul == 0)
break;
1800 LOG(error) <<
"Invalid Channel Pointer for ChId " << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
1806 LOG(debug1) <<
"Hit info: "
1807 << Form(
" 0x%08x %d %f %f %f %f %f %d", iChId, iCh, pHit->
GetX(), pHit->
GetY(), pHit->
GetTime(),
1811 hitpos[0] = pHit->
GetX();
1812 hitpos[1] = pHit->
GetY();
1813 hitpos[2] = pHit->
GetZ();
1814 Double_t hitpos_local[3];
1815 TGeoNode* cNode = gGeoManager->GetCurrentNode();
1816 gGeoManager->MasterToLocal(hitpos, hitpos_local);
1817 LOG(debug1) << Form(
" MasterToLocal for node %p: (%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)", cNode, hitpos[0],
1818 hitpos[1], hitpos[2], hitpos_local[0], hitpos_local[1], hitpos_local[2]);
1821 fhSmCluPosition[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
1823 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1827 fhTSmCluPosition[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
1831 LOG(debug1) <<
" TofDigiMatchColl entries:" <<
fTofDigiMatchColl->GetEntriesFast();
1834 LOG(error) <<
" Inconsistent DigiMatches for Hitind " << iHitInd
1839 LOG(debug1) <<
" got " << digiMatch->
GetNofLinks() <<
" matches for iCh " << iCh <<
" at iHitInd " << iHitInd;
1843 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1847 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
1849 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
1857 Double_t TotSum = 0.;
1858 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink++) {
1861 if (iDigInd0 < fTofCalDigisColl->GetEntriesFast()) {
1863 TotSum += pDig0->
GetTot();
1866 Double_t dMeanTimeSquared = 0.;
1867 Double_t dNstrips = 0.;
1869 Double_t dDelTof = 0.;
1870 Double_t dTcor[
iNSel];
1871 Double_t dTTcor[
iNSel];
1872 Double_t dZsign[
iNSel];
1873 Double_t dzscal = 1.;
1876 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
1879 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
1882 if (iDigInd0 < fTofCalDigisColl->GetEntriesFast() && iDigInd1 < fTofCalDigisColl->GetEntriesFast()) {
1885 if ((Int_t) pDig0->
GetType() != iSmType) {
1886 LOG(error) << Form(
" Wrong Digi SmType for Tofhit %d in iDetIndx "
1887 "%d, Ch %d with %3.0f strips at Indx %d, %d",
1888 iHitInd, iDetIndx, iCh, dNstrips, iDigInd0, iDigInd1);
1890 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch " << pDig0->
GetChannel() <<
", Side "
1891 << pDig0->
GetSide() <<
", StripSide " << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
1892 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side " << pDig1->
GetSide() <<
", StripSide "
1893 << (Double_t) iCh * 2. + pDig1->
GetSide() <<
", Tot0 " << pDig0->
GetTot() <<
", Tot1 "
1903 if (iCh0 != iCh1 || iS0 == iS1) {
1904 LOG(fatal) << Form(
" MT2 for Tofhit %d in iDetIndx %d, Ch %d from %3.0f strips: ", iHitInd, iDetIndx, iCh,
1906 << Form(
" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd0, iCh0, iS0, pDig0->
GetTime())
1907 << Form(
" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd1, iCh1, iS1, pDig1->
GetTime());
1912 LOG(error) << Form(
" Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
1913 "from %3.0f strips: %d, %d, %d, %d",
1914 iHitInd, iDetIndx, iCh, iDigInd0, iDigInd1, dNstrips, iCh0, iCh1, iS0, iS1);
1928 Double_t dTotWeigth = (pDig0->
GetTot() + pDig1->
GetTot()) / TotSum;
1929 Double_t dCorWeigth = 1. - dTotWeigth;
1935 if (0 == pDig0->
GetSide()) dDelPos *= -1.;
1952 - (1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
1956 - (1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
1960 LOG(debug1) <<
" fhTRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch " << pDig0->
GetChannel() <<
", Side "
1961 << pDig0->
GetSide() <<
", StripSide " << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
1962 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side " << pDig1->
GetSide() <<
", StripSide "
1963 << (Double_t) iCh * 2. + pDig1->
GetSide();
1965 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1967 if (NULL == pHit || NULL == pTrig[iSel]) {
1968 LOG(info) <<
" invalid pHit, iSel " << iSel <<
", iDetIndx " << iDetIndx;
1976 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
1978 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
1989 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY());
1991 if (pHit->
GetZ() < pTrig[iSel]->
GetZ()) dZsign[iSel] = -1.;
1996 || TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
1997 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2001 TMath::Power(pHit->
GetX()
2002 - (pTrig[iSel]->
GetX() + ddXdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2004 + TMath::Power(pHit->
GetY()
2005 - (pTrig[iSel]->
GetY() + ddYdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2025 if (iBx < 0) iBx = 0;
2028 Double_t dDTentry = dTentry - ((Double_t) iBx) * dBinWidth;
2030 dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
2031 Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
2032 Double_t w1 = 1. - w0;
2033 if (iBx1 < 0) iBx1 = 0;
2035 dDelTof =
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
2036 +
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel] * w1;
2038 LOG(debug1) << Form(
" DelTof for SmT %d, Sm %d, R %d, T %d, dTRef "
2039 "%6.1f, Bx %d, Bx1 %d, DTe %6.1f -> DelT %6.1f",
2040 iSmType, iSm, iRpc, iSel,
dTRef - dTTrig[iSel], iBx, iBx1, dDTentry, dDelTof);
2042 dTTcor[iSel] = dDelTof * dZsign[iSel];
2043 dTcor[iSel] = pHit->
GetTime() - dDelTof - dTTrig[iSel];
2047 LOG(debug) << Form(
" TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
2048 "Ch %d,%d, S %d,%d T %f, DelTof %6.1f, W-ent: %6.0f,%6.0f",
2050 iCh0, iCh1, iS0, iS1, dTTrig[iSel], dDelTof,
2056 LOG(error) << Form(
" Inconsistent walk histograms -> debugging "
2057 "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
2058 fiNevtBuild, iDetIndx, iSel, iCh0, iCh1, iS0, iS1);
2060 LOG(debug1) << Form(
2061 " TRpcCluWalk values side %d: %f, %f, side %d: %f, %f ", iS0, pDig0->
GetTot(),
2064 - dTTcor[iSel] - dTTrig[iSel],
2068 - dTTcor[iSel] - dTTrig[iSel]);
2095 fhTSmCluTOff[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), dTcor[iSel]);
2098 != (pTrig[iSel]->GetAddress()
2102 hitpos[2] = pHit->
GetZ();
2103 gGeoManager->MasterToLocal(hitpos, hitpos_local);
2106 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
2114 LOG(error) <<
"CbmTofTestBeamClusterizer::FillHistos: invalid digi index " << iDetIndx <<
" digi0,1"
2115 << iDigInd0 <<
", " << iDigInd1 <<
" - max:" <<
fTofCalDigisColl->GetEntriesFast()
2123 Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
2125 Double_t dTrms = TMath::Sqrt(dVar);
2126 LOG(debug) << Form(
" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
2127 "%3.0f strips: %6.3f ns",
2128 iHitInd, iDetIndx, iCh, dNstrips, dTrms);
2133 LOG(debug1) <<
" Fill Time of iDetIndx " << iDetIndx <<
", hitAddr "
2134 << Form(
" %08x, y = %5.2f", pHit->
GetAddress(), hitpos_local[1]) <<
" for |y| <"
2136 if (TMath::Abs(hitpos_local[1]) < (
fhRpcCluPosition[iDetIndx]->GetYaxis()->GetXmax())) {
2141 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2143 LOG(debug1) <<
" TRpcCluTOff " << iDetIndx <<
", Sel " << iSel
2144 << Form(
", Dt %7.3f, LHsize %lu ", pHit->
GetTime() - dTTrig[iSel],
2149 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2151 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
2153 LOG(debug1) << Form(
" %f,", pHit->
GetTime() - (*itL)->GetTime());
2162 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2164 for (Int_t iH = 0; iH < 1; iH++) {
2167 Double_t dTsinceLast = pHit->
GetTime() - (*itL)->GetTime();
2169 LOG(fatal) << Form(
"Invalid Time since last hit on channel "
2170 "TSRC %d%d%d%d: %f > %f",
2174 pHit->
GetTime() - dTTrig[iSel]);
2186 LOG(debug1) <<
"CbmTofTestBeamClusterizer::FillHistos: "
2189 for (UInt_t uCluster = 0; uCluster <
fviClusterSize[iSmType][iRpc].size(); uCluster++) {
2190 LOG(debug2) <<
"CbmTofTestBeamClusterizer::FillHistos: " << Form(
" %3d %3d %3d ", iSmType, iRpc, uCluster);
2194 40 * iSmType + iRpc);
2198 if (1 ==
fviTrkMul[iSmType][iRpc][uCluster])
2200 if (1 <
fviTrkMul[iSmType][iRpc][uCluster])
2216 fvdX[iSmType][iRpc].clear();
2217 fvdY[iSmType][iRpc].clear();
2218 fvdDifX[iSmType][iRpc].clear();
2219 fvdDifY[iSmType][iRpc].clear();
2232 TFile* oldFile = gFile;
2233 TDirectory* oldDir = gDirectory;
2255 LOG(debug) <<
"Write triggered Histos for Det Ind " << iDetIndx
2257 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2267 Int_t iSmAddr = iUniqueId &
DetMask;
2282 LOG(info) <<
"WriteHistos: No entries in Walk histos for "
2283 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
2288 TH2* htempPos = NULL;
2289 TProfile* htempPos_pfx = NULL;
2290 TH1* htempPos_py = NULL;
2291 TProfile* htempTOff_pfx = NULL;
2292 TH1* htempTOff_px = NULL;
2293 TProfile* hAvPos_pfx = NULL;
2294 TProfile* hAvTOff_pfx = NULL;
2295 TH2* htempTOff = NULL;
2296 TH2* htempTot = NULL;
2297 TProfile* htempTot_pfx = NULL;
2298 TH1* htempTot_Mean = NULL;
2299 TH1* htempTot_Off = NULL;
2308 htempTOff_px = htempTOff->ProjectionX(
"_px", 1,
fhTRpcCluTOff[iDetIndx][
fCalSel]->GetNbinsY());
2349 if (NULL == htempPos_pfx) {
2350 LOG(info) <<
"WriteHistos: Projections not available, continue ";
2354 htempTot_Mean = htempTot_pfx->ProjectionX(
"_Mean");
2355 htempTot_Off = htempTot_pfx->ProjectionX(
"_Off");
2357 htempPos_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
2358 htempTOff_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
2359 htempTot_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
2360 htempTot_Mean->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
2361 htempTot_Off->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
2362 hAvPos_pfx->SetName(Form(
"cl_CorSmT%01d_Pos_pfx", iSmType));
2363 hAvTOff_pfx->SetName(Form(
"cl_CorSmT%01d_TOff_pfx", iSmType));
2367 htempTot_Off->Reset();
2369 Int_t nbins = htempTot->GetNbinsX();
2370 for (
int i = 0; i < nbins; i++) {
2371 hbins[i] = htempTot->ProjectionY(Form(
"bin%d", i + 1), i + 1, i + 1);
2373 Int_t iBmax = hbins[i]->GetMaximumBin();
2374 TAxis* xaxis = hbins[i]->GetXaxis();
2375 Double_t Xmax = xaxis->GetBinCenter(iBmax);
2377 XOff = (Double_t)(Int_t) XOff;
2378 if (XOff < 0) XOff = 0;
2379 htempTot_Off->SetBinContent(i + 1, XOff);
2380 Double_t Xmean = htempTot_Mean->GetBinContent(i + 1);
2382 LOG(warning) <<
"Inconsistent Tot numbers for "
2383 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, Off %f", iSmType, iSm, iRpc, i, Xmean, XOff);
2385 htempTot_Mean->SetBinContent(i + 1, (Xmean - XOff));
2386 if (htempTot_Mean->GetBinContent(i + 1) != (Xmean - XOff))
2387 LOG(warning) <<
"Tot numbers not stored properly for "
2388 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, target %f", iSmType, iSm, iRpc, i,
2389 htempTot_Mean->GetBinContent(i + 1), Xmean - XOff);
2391 htempPos_pfx->Write();
2392 htempTOff_pfx->Write();
2394 htempTot_Mean->Write();
2395 htempTot_Off->Write();
2401 LOG(debug) <<
"WriteHistos: restore Offsets and Gains and save Walk for "
2402 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
2403 <<
" and calSmAddr = " << Form(
" 0x%08x ", TMath::Abs(
fCalSmAddr));
2404 htempPos_pfx->Reset();
2405 htempTOff_pfx->Reset();
2406 htempTot_Mean->Reset();
2407 htempTot_Off->Reset();
2408 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
2411 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2413 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2414 htempPos_pfx->Fill(iCh, YMean);
2415 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
2416 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
2417 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
2418 <<
", expected " << YMean;
2420 htempTOff_pfx->Fill(iCh, TMean);
2422 for (Int_t iSide = 0; iSide < 2; iSide++) {
2423 htempTot_Mean->SetBinContent(
2424 iCh * 2 + 1 + iSide,
2426 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2430 LOG(debug1) <<
" Offset, gain restoring done ... ";
2431 htempPos_pfx->Write();
2432 htempTOff_pfx->Write();
2434 htempTot_Mean->Write();
2435 htempTot_Off->Write();
2437 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2439 TDirectory* curdir = gDirectory;
2441 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
2442 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2443 gDirectory->cd(curdir->GetPath());
2444 if (NULL != hCorDelTof) {
2445 TH1D* hCorDelTofout =
2446 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2447 hCorDelTofout->Write();
2450 LOG(debug) <<
" No CorDelTof histo "
2451 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
2459 LOG(debug) <<
"WriteHistos: restore Offsets and Gains and update Walk for "
2460 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with "
2485 if (NULL == h2tmp0) {
2486 LOG(debug) << Form(
"WriteHistos: Walk histo not available for "
2487 "SmT %d, Sm %d, Rpc %d, Ch %d",
2488 iSmType, iSm, iRpc, iCh);
2491 Int_t iNEntries = h2tmp0->GetEntries();
2493 LOG(debug) << Form(
" Update Walk correction for SmT %d, Sm %d, "
2494 "Rpc %d, Ch %d, Sel%d: Entries %d",
2495 iSmType, iSm, iRpc, iCh,
fCalSel, iNEntries);
2499 if (-1 < iNEntries) {
2500 TProfile* htmp0 = h2tmp0->ProfileX(
"_pfx", 1, h2tmp0->GetNbinsY());
2501 TProfile* htmp1 = h2tmp1->ProfileX(
"_pfx", 1, h2tmp1->GetNbinsY());
2502 TH1D* h1tmp0 = h2tmp0->ProjectionX(
"_px", 1, h2tmp0->GetNbinsY());
2503 TH1D* h1tmp1 = h2tmp1->ProjectionX(
"_px", 1, h2tmp1->GetNbinsY());
2504 TH1D* h1ytmp0 = h2tmp0->ProjectionY(
"_py", 1,
nbClWalkBinX);
2505 TH1D* h1ytmp1 = h2tmp1->ProjectionY(
"_py", 1,
nbClWalkBinX);
2506 Double_t dWMean0 = h1ytmp0->GetMean();
2507 Double_t dWMean1 = h1ytmp1->GetMean();
2508 Double_t dWMean = 0.5 * (dWMean0 + dWMean1);
2511 if (5 == iSmType || 8 == iSmType)
2516 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
2519 (((TProfile*) htmp0)->GetBinContent(iWx + 1) + ((TProfile*) htmp1)->GetBinContent(iWx + 1))
2521 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor - dWMean;
2522 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor - dWMean;
2526 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
2527 Double_t dWcor0 = ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
2528 Double_t dWcor1 = ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
2529 Double_t dWcor = 0.5 * (dWcor0 + dWcor1);
2530 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor;
2531 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor;
2533 if (iCh == 10 && iSmType == 9 && iSm == 1 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
2534 LOG(debug) <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc <<
"), Rpc " << iRpc <<
", Bin "
2535 << iWx <<
", " << h1tmp0->GetBinContent(iWx + 1)
2536 <<
" cts: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] <<
" + "
2537 << ((TProfile*) htmp0)->GetBinContent(iWx + 1) <<
" - " << dWMean0 <<
" -> "
2538 << dWcor - dWMean0 <<
", S1: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
2539 <<
" + " << ((TProfile*) htmp1)->GetBinContent(iWx + 1) <<
" - " << dWMean1 <<
" -> "
2544 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
2545 Double_t dWcor0 = ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
2546 Double_t dWcor1 = ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
2548 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor0;
2549 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor1;
2559 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2560 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2563 && h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
2564 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2567 LOG(error) <<
"writing not successful for " << h1tmp0->GetName() <<
", attempts left: " << iTry
2568 <<
", iWx " << iWx <<
", got " << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
2569 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
2572 && h1tmp1->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]) {
2573 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2576 LOG(error) <<
"writing not successful for " << h1tmp1->GetName() <<
", attempts left: " << iTry
2577 <<
", iWx " << iWx <<
", got " << h1tmp1->GetBinContent(iWx + 1) <<
", expected "
2578 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx];
2581 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
2584 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
2598 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2599 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2600 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
2601 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
2602 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
2603 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
2606 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
2609 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
2622 LOG(debug) <<
"WriteHistos: (case 2) update Offsets and keep Gains, "
2623 "Walk and DELTOF for "
2624 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
2625 Int_t iB = iSm * iNbRpc + iRpc;
2626 Double_t dVscal = 1.;
2628 if (dVscal == 0.) dVscal = 1.;
2630 Double_t YMean = ((TProfile*) hAvPos_pfx)->GetBinContent(iB + 1);
2631 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
2633 LOG(debug1) << Form(
"Determine YMean in %s by fit to %d entries", htempPos->GetName(),
2634 (Int_t) htempPos_py->GetEntries());
2639 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
2643 TF1* ff = htempPos_py->GetFunction(
"YBox");
2645 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm << iRpc
2646 <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
2647 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
2648 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
2650 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2653 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2)
2657 YMean = ff->GetParameter(3);
2659 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV);
2665 Double_t TMean = ((TProfile*) hAvTOff_pfx)->GetBinContent(iB + 1);
2666 Double_t TWidth = ((TProfile*) hAvTOff_pfx)->GetBinError(iB + 1);
2673 LOG(debug) << Form(
"<ICor> Correct %d %d %d by TMean=%8.2f, "
2674 "TYOff=%8.2f, TWidth=%8.2f, ",
2675 iSmType, iSm, iRpc, TMean, dTYOff, TWidth);
2678 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2680 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
2681 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
2683 LOG(debug) <<
"FillCalHist:"
2684 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean " << YMean
2685 <<
", TMean " << TMean <<
" -> "
2686 << Form(
" %f, %f, %f, %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2687 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
2688 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2689 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2692 htempPos_pfx->Reset();
2693 htempTOff_pfx->Reset();
2694 htempTot_Mean->Reset();
2695 htempTot_Off->Reset();
2696 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2700 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2702 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2703 htempPos_pfx->Fill(iCh, YMean);
2704 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
2705 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
2706 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
2707 <<
", expected " << YMean;
2709 htempTOff_pfx->Fill(iCh, TMean);
2711 for (Int_t iSide = 0; iSide < 2; iSide++) {
2712 htempTot_Mean->SetBinContent(
2713 iCh * 2 + 1 + iSide,
2715 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2719 LOG(debug1) <<
" Updating done ... write to file ";
2720 htempPos_pfx->Write();
2721 htempTOff_pfx->Write();
2723 htempTot_Mean->Write();
2724 htempTot_Off->Write();
2727 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
2729 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2731 TDirectory* curdir = gDirectory;
2733 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
2734 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2735 gDirectory->cd(curdir->GetPath());
2736 if (NULL != hCorDelTof) {
2737 TH1D* hCorDelTofout =
2738 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2739 hCorDelTofout->Write();
2742 LOG(debug) <<
" No CorDelTof histo "
2743 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
2748 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2755 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2756 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2757 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
2758 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
2759 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
2760 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
2763 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
2766 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
2777 LOG(info) <<
"WriteHistos (calMode==3): update Offsets and Gains, "
2778 "keep Walk and DelTof for "
2779 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with " << iNbCh <<
" channels "
2780 <<
" using selector " <<
fCalSel;
2787 Double_t dVscal = 1.;
2791 dVscal =
fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
2792 if (dVscal == 0.) dVscal = 1.;
2793 dVW =
fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc + iRpc + 1);
2795 if (dVW < 0.1) dVW = 0.1;
2799 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
2800 Double_t dYMeanAv = 0.;
2801 Double_t dYMeanFit = 0.;
2803 dYMeanAv = htempPos_py->GetMean();
2804 LOG(debug1) << Form(
"Determine YMeanAv in %s by fit to %d entries", htempPos->GetName(),
2805 (Int_t) htempPos_py->GetEntries());
2810 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
2814 TF1* ff = htempPos_py->GetFunction(
"YBox");
2817 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2) {
2819 LOG(info) <<
"FAvRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm << iRpc
2820 <<
", stat: " << gMinuit->fCstatu <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
2821 << Form(
", striplen (%5.2f): %7.2f+/-%5.2f, pos res "
2822 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
2824 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2826 dYMeanFit = ff->GetParameter(3);
2827 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
2828 for (Int_t iPar = 0; iPar < 4; iPar++)
2829 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc), ff->GetParameter(2 + iPar));
2833 LOG(info) <<
"FAvBad YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm << iRpc
2834 <<
", chi2 " << ff->GetChisquare()
2836 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
2837 "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
2839 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2843 LOG(info) <<
"FAvFailed for TSR " << iSmType << iSm << iRpc;
2846 Double_t dYShift = dYMeanFit - dYMeanAv;
2848 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2850 Double_t YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
2853 htempPos_py = htempPos->ProjectionY(Form(
"%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
2855 LOG(debug1) << Form(
"Determine YMean in %s of channel %d by fit to %d entries", htempPos->GetName(), iCh,
2856 (Int_t) htempPos_py->GetEntries());
2861 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
2864 Double_t fp[4] = {1., 3 * 0.};
2865 for (Int_t iPar = 2; iPar < 4; iPar++)
2867 fp[iPar] =
fhSmCluFpar[iSmType][iPar]->GetBinContent(iSm * iNbRpc + iRpc + 1);
2870 Double_t* fpp = &fp[0];
2872 TF1* ff = htempPos_py->GetFunction(
"YBox");
2875 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.05)
2879 YMean = ff->GetParameter(3);
2881 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
2882 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm << iRpc
2883 << iCh <<
", chi2 " << ff->GetChisquare()
2884 << Form(
", striplen (%5.2f), %4.2f -> %4.2f, "
2885 "%4.1f: %7.2f+/-%5.2f, pos res "
2886 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
2888 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
2889 ff->GetParameter(3), ff->GetParError(3));
2890 for (Int_t iPar = 0; iPar < 4; iPar++)
2891 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc), ff->GetParameter(2 + iPar));
2896 LOG(info) <<
"FBad YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm << iRpc
2897 << iCh <<
", chi2 " << ff->GetChisquare()
2898 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
2899 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
2901 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2906 Double_t TMean = ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
2911 TMean -= ((TProfile*) hAvTOff_pfx)->GetBinContent(iSm * iNbRpc + iRpc + 1);
2914 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
2915 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
2916 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
2917 LOG(debug) << Form(
"Calib: TSRC %d%d%d%d, hits %6.0f, dTY %8.3f, TM %8.3f -> new "
2919 iSmType, iSm, iRpc, iCh, htempTOff_px->GetBinContent(iCh + 1), dTYOff, TMean,
2920 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2921 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2930 for (Int_t iSide = 0; iSide < 2; iSide++) {
2931 Int_t ib = iCh * 2 + 1 + iSide;
2932 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
2933 if (100 > hbin->GetEntries())
continue;
2935 Int_t iBmax = hbin->GetMaximumBin();
2936 TAxis* xaxis = hbin->GetXaxis();
2937 Double_t Xmax = xaxis->GetBinCenter(iBmax) /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
2940 LOG(warning) <<
"XOff changed for "
2941 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f", iSmType, iSm, iRpc, iSide, XOff,
2942 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2945 Double_t TotMean = hbin->GetMean();
2946 if (15 == iSmType) {
2947 LOG(warning) <<
"Gain for "
2948 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
2949 "gain %f, modg %f ",
2950 iSmType, iSm, iRpc, iSide, TotMean, htempTot_Mean->GetBinContent(ib),
2953 if (0.001 < TotMean) {
2958 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
2959 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) {
2960 LOG(warning) <<
"CbmTofTestBeamClusterizer::FillCalHist:"
2961 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
2962 << YMean <<
", TMean " << TMean <<
" -> "
2963 << Form(
" %f %f %f %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2964 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
2965 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2966 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2968 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2969 Double_t dGain = 0.5
2970 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
2971 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2972 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
2973 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
2974 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
2975 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
2980 htempPos_pfx->Reset();
2981 htempTOff_pfx->Reset();
2982 htempTot_Mean->Reset();
2983 htempTot_Off->Reset();
2984 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2988 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2990 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2991 htempPos_pfx->Fill(iCh, YMean);
2992 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
2993 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
2994 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
2995 <<
", expected " << YMean;
2997 htempTOff_pfx->Fill(iCh, TMean);
2999 for (Int_t iSide = 0; iSide < 2; iSide++) {
3000 htempTot_Mean->SetBinContent(iCh * 2 + 1 + iSide,
3002 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3008 LOG(debug1) <<
" Updating done ... write to file ";
3009 htempPos_pfx->Write();
3010 htempTOff_pfx->Write();
3012 htempTot_Mean->Write();
3013 htempTot_Off->Write();
3016 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
3018 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3020 TDirectory* curdir = gDirectory;
3022 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3023 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3024 gDirectory->cd(curdir->GetPath());
3025 if (NULL != hCorDelTof) {
3026 TH1D* hCorDelTofout =
3027 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3028 hCorDelTofout->Write();
3031 LOG(debug) <<
" No CorDelTof histo "
3032 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3036 LOG(debug) <<
" Store old walk histos to file ";
3038 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3046 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3047 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3048 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3049 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3050 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3051 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3054 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3057 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3066 LOG(debug) <<
"WriteHistos: restore Offsets, Gains and Walk, save DelTof for "
3067 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
3068 htempPos_pfx->Reset();
3069 htempTOff_pfx->Reset();
3070 htempTot_Mean->Reset();
3071 htempTot_Off->Reset();
3072 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3075 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3077 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3078 htempPos_pfx->Fill(iCh, YMean);
3079 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3080 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
3081 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
3082 <<
", expected " << YMean;
3084 htempTOff_pfx->Fill(iCh, TMean);
3086 for (Int_t iSide = 0; iSide < 2; iSide++) {
3087 htempTot_Mean->SetBinContent(
3088 iCh * 2 + 1 + iSide,
3090 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3094 LOG(debug1) <<
" Restoring of Offsets and Gains done ... ";
3095 htempPos_pfx->Write();
3096 htempTOff_pfx->Write();
3098 htempTot_Mean->Write();
3099 htempTot_Off->Write();
3102 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3110 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3111 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3112 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3113 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3114 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3115 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3118 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3121 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3132 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3134 if (NULL == h2tmp) {
3135 LOG(debug) << Form(
"WriteHistos: histo not available for SmT %d, Sm %d, Rpc %d", iSmType, iSm, iRpc);
3138 Int_t iNEntries = h2tmp->GetEntries();
3141 TProfile* htmp = h2tmp->ProfileX(
"_pfx", 1, h2tmp->GetNbinsY());
3142 TH1D* h1tmp = h2tmp->ProjectionX(
"_px", 1, h2tmp->GetNbinsY());
3147 Double_t dNEntries = h1tmp->GetBinContent(iBx + 1);
3149 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] += ((TProfile*) htmp)->GetBinContent(iBx + 1);
3150 dDelMean +=
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel];
3154 LOG(debug) << Form(
" Update DelTof correction for SmT %d, Sm %d, "
3155 "Rpc %d, Sel%d: Entries %d, Mean shift %6.1f",
3156 iSmType, iSm, iRpc, iSel, iNEntries, dDelMean);
3160 h1tmp->SetBinContent(iBx + 1,
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel]);
3162 h1tmp->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3167 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3169 TDirectory* curdir = gDirectory;
3171 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3172 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3173 gDirectory->cd(curdir->GetPath());
3174 if (NULL != hCorDelTof) {
3175 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3176 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3177 LOG(debug) <<
" Save existing CorDelTof histo "
3178 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3179 hCorDelTofout->Write();
3182 LOG(debug) <<
" No CorDelTof histo "
3183 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3193 LOG(info) <<
"WriteHistos (calMode==3): update Offsets and Gains, "
3194 "keep Walk and DelTof for "
3195 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with " << iNbCh <<
" channels "
3196 <<
" using selector " <<
fCalSel;
3198 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3200 Double_t YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
3201 Double_t TMean = 0.;
3205 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
3206 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3207 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3209 LOG(debug3) << Form(
"Calib: TSRC %d%d%d%d, hits %6.0f, new Off %8.0f,%8.0f ", iSmType, iSm, iRpc, iCh,
3210 htempTOff_px->GetBinContent(iCh + 1),
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3211 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3220 for (Int_t iSide = 0; iSide < 2; iSide++) {
3221 Int_t ib = iCh * 2 + 1 + iSide;
3222 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
3223 if (100 > hbin->GetEntries())
continue;
3225 Int_t iBmax = hbin->GetMaximumBin();
3226 TAxis* xaxis = hbin->GetXaxis();
3227 Double_t Xmax = xaxis->GetBinCenter(iBmax) /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
3230 LOG(warning) <<
"XOff changed for "
3231 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f", iSmType, iSm, iRpc, iSide, XOff,
3232 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3235 Double_t TotMean = hbin->GetMean();
3236 if (15 == iSmType) {
3237 LOG(warning) <<
"Gain for "
3238 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
3239 "gain %f, modg %f ",
3240 iSmType, iSm, iRpc, iSide, TotMean, htempTot_Mean->GetBinContent(ib),
3243 if (0.001 < TotMean) {
3248 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
3249 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) {
3250 LOG(warning) <<
"CbmTofTestBeamClusterizer::FillCalHist:"
3251 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
3252 << YMean <<
", TMean " << TMean <<
" -> "
3253 << Form(
" %f %f %f %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3254 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
3255 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3256 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3258 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3259 Double_t dGain = 0.5
3260 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
3261 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3262 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
3263 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
3264 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
3265 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
3270 htempPos_pfx->Reset();
3271 htempTOff_pfx->Reset();
3272 htempTot_Mean->Reset();
3273 htempTot_Off->Reset();
3274 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3278 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3280 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3281 htempPos_pfx->Fill(iCh, YMean);
3282 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3283 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
3284 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
3285 <<
", expected " << YMean;
3287 htempTOff_pfx->Fill(iCh, TMean);
3289 for (Int_t iSide = 0; iSide < 2; iSide++) {
3290 htempTot_Mean->SetBinContent(iCh * 2 + 1 + iSide,
3292 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3298 LOG(debug1) <<
" Updating done ... write to file ";
3299 htempPos_pfx->Write();
3300 htempTOff_pfx->Write();
3302 htempTot_Mean->Write();
3303 htempTot_Off->Write();
3306 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
3308 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3310 TDirectory* curdir = gDirectory;
3312 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3313 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3314 gDirectory->cd(curdir->GetPath());
3315 if (NULL != hCorDelTof) {
3316 TH1D* hCorDelTofout =
3317 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3318 hCorDelTofout->Write();
3321 LOG(debug) <<
" No CorDelTof histo "
3322 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3326 LOG(debug) <<
" Store old walk histos to file ";
3328 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3336 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3337 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3338 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3339 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3340 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3341 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3344 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3347 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3354 default: LOG(debug) <<
"WriteHistos: update mode " <<
fCalMode <<
" not yet implemented";
3398 for (Int_t iPar = 0; iPar < 4; iPar++)
3401 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3410 gDirectory = oldDir;
3459 gGeoManager->CdTop();
3462 LOG(info) <<
" No CalDigis defined ! Check! ";
3466 LOG(debug) <<
"CbmTofTestBeamClusterizer::BuildClusters from " <<
fTofDigisColl->GetEntriesFast()
3473 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
3475 LOG(debug1) << iDigInd <<
" " << pDigi << Form(
" Address : 0x%08x ", pDigi->
GetAddress()) <<
" SmT "
3476 << pDigi->
GetType() <<
" Sm " << pDigi->
GetSm() <<
" Rpc " << pDigi->
GetRpc() <<
" Ch "
3491 LOG(warning) << Form(
" DigiCor Histo for DetIndx %d derived from 0x%08x not found", iDetIndx,
3499 for (Int_t iDigI2 = 0; iDigI2 < iNbTofDigi; iDigI2++) {
3512 Double_t dTDif = TMath::Abs(pDigi->
GetTime() - pDigi2->
GetTime());
3513 if (dTDif < dTDifMin) {
3522 for (; iDigI3 < iNbTofDigi; iDigI3++) {
3526 if (iDigI3 == iNbTofDigi)
3533 LOG(debug2) << Form(
"shift channel %d%d%d%d%d and ", (Int_t) pDigi->
GetType(),
3536 << Form(
" %d%d%d%d%d ", (Int_t) pDigi2->
GetType(), (Int_t) pDigi2->
GetSm(),
3547 LOG(debug2) << Form(
"resultchannel %d%d%d%d%d and ", (Int_t) pDigi->
GetType(),
3550 << Form(
" %d%d%d%d%d ", (Int_t) pDigi2->
GetType(), (Int_t) pDigi2->
GetSm(),
3573 if (pDigi2Min != NULL) {
3579 LOG(warning) << Form(
"BuildClusters: invalid ChannelInfo for 0x%08x", iChId);
3588 LOG(warning) <<
" BuildClusters: Inconsistent duplicated digis in event " <<
fiNevtBuild
3589 <<
", Ind: " << iDigInd;
3590 LOG(warning) <<
" " << pDigi->
ToString();
3591 LOG(warning) <<
" " << pDigi2Min->
ToString();
3622 Int_t iDigIndCal = -1;
3624 std::map<Int_t, Double_t> mChannelDeadTime;
3626 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
3636 LOG(debug1) <<
"BC "
3642 if (pDigi->
GetSide() == 1)
continue;
3644 Bool_t bValid = kTRUE;
3645 std::map<Int_t, Double_t>::iterator it;
3646 it = mChannelDeadTime.find(iAddr);
3647 if (it != mChannelDeadTime.end()) {
3648 LOG(debug1) <<
"CCT found valid ChannelDeadtime entry " << mChannelDeadTime[iAddr] <<
", DeltaT "
3649 << pDigi->
GetTime() - mChannelDeadTime[iAddr];
3651 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
3654 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
3656 mChannelDeadTime[iAddr] = pDigi->
GetTime();
3657 if (!bValid)
continue;
3659 LOG(debug1) <<
"DC "
3674 LOG(debug2) <<
" CluCal-Init: " << pDigi->
ToString();
3679 LOG(debug2) <<
" CluCal-TOff: " << pCalDigi->
ToString();
3681 Double_t dTot = pCalDigi->
GetTot() -
3684 if (dTot < 0.001) dTot = 0.001;
3691 Int_t iWx = (Int_t)((pCalDigi->
GetTot() -
fdTOTMin) / dTotBinSize);
3692 if (0 > iWx) iWx = 0;
3694 Double_t dDTot = (pCalDigi->
GetTot() -
fdTOTMin) / dTotBinSize - (Double_t) iWx - 0.5;
3724 LOG(debug2) <<
" CluCal-Walk: " << pCalDigi->
ToString();
3728 <<
"CbmTofTestBeamClusterizer::BuildClusters: CalDigi " << iDigIndCal <<
", T " << pCalDigi->
GetType()
3729 <<
", Sm " << pCalDigi->
GetSm() <<
", R " << pCalDigi->
GetRpc() <<
", Ch " << pCalDigi->
GetChannel()
3730 <<
", S " << pCalDigi->
GetSide() <<
", T " << pCalDigi->
GetTime() <<
", Tot " << pCalDigi->
GetTot()
3737 <<
", Walk " << iWx <<
": "
3742 <<
" dDTot " << dDTot <<
" BinSize: " << dTotBinSize <<
", CPWalk "
3751 <<
" -> dWT = " << dWT;
3755 LOG(info) <<
"Skip1 Digi "
3762 || pCalDigi->
GetType() == 8) {
3774 LOG(debug) <<
"CbmTofTestBeamClusterizer::BuildClusters: Sort " <<
fTofCalDigisColl->GetEntriesFast()
3775 <<
" calibrated digis ";
3776 if (iNbTofDigi > 1) {
3779 LOG(warning) <<
"CbmTofTestBeamClusterizer::BuildClusters: Sorting not "
3785 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
3787 LOG(debug1) <<
"AC "
3801 .push_back(iDigInd);
3804 LOG(info) <<
"Skip2 Digi "
3849 Double_t dWeightedTime = 0.0;
3850 Double_t dWeightedPosX = 0.0;
3851 Double_t dWeightedPosY = 0.0;
3852 Double_t dWeightedPosZ = 0.0;
3853 Double_t dWeightsSum = 0.0;
3858 Int_t iNbChanInHit = 0;
3860 Int_t iLastChan = -1;
3861 Double_t dLastPosX = 0.0;
3862 Double_t dLastPosY = 0.0;
3863 Double_t dLastTime = 0.0;
3865 Double_t dPosX = 0.0;
3866 Double_t dPosY = 0.0;
3867 Double_t dPosZ = 0.0;
3868 Double_t dTime = 0.0;
3869 Double_t dTimeDif = 0.0;
3870 Double_t dTotS = 0.0;
3873 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
3876 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
3877 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
3880 LOG(debug2) <<
"RPC - Loop " << Form(
" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
3885 dWeightedTime = 0.0;
3886 dWeightedPosX = 0.0;
3887 dWeightedPosY = 0.0;
3888 dWeightedPosZ = 0.0;
3897 LOG(debug2) <<
"ChanOrient "
3906 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3907 LOG(debug3) <<
"VDigisize "
3908 << Form(
" T %3d Sm %3d R %3d Ch %3d Size %3lu ", iSmType, iSm, iRpc, iCh,
3916 while ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetSide()
3917 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetSide()) {
3921 LOG(debug) <<
"SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh <<
", Times: "
3922 << Form(
"%f", (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()) <<
", "
3923 << Form(
"%f", (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime())
3925 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
3926 - (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
3927 <<
", array size: " <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
3928 if (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetSide()
3929 ==
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide()) {
3930 LOG(debug) <<
"3 consecutive SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh
3931 <<
", Times: " << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
3932 <<
", " << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
3934 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
3935 - (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
3936 <<
", array size: " <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
3938 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3940 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3943 if (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
3944 -
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetTime()
3945 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
3946 -
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1]->GetTime()) {
3948 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3950 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3953 LOG(debug) << Form(
"Ev %8.0f, digis not properly time ordered, TSRCS "
3955 fdEvent, iSmType, iSm, iRpc, iCh,
3956 (Int_t)
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide());
3958 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
3960 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
3965 LOG(debug2) <<
"SameSide Erase fStor entries(d) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc
3968 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3970 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3976 LOG(debug2) <<
"digis processing for "
3977 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ", iSmType, iSm, iRpc, iCh,
3980 LOG(debug) << Form(
"Leaving digi processing for TSRC %d%d%d%d, size %3lu", iSmType, iSm, iRpc, iCh,
3990 LOG(debug1) << Form(
" TSRC %d%d%d%d size %3lu ", iSmType, iSm, iRpc, iCh,
3992 << Form(
" ChId: 0x%08x 0x%08x ", iChId, iUCellId);
3996 LOG(error) <<
"CbmTofTestBeamClusterizer::BuildClusters: "
3997 "no geometry info! "
3998 << Form(
" %3d %3d %3d %3d 0x%08x 0x%08x ", iSmType, iSm, iRpc, iCh, iChId, iUCellId);
4011 LOG(debug2) <<
" " << xDigiA->
ToString();
4012 LOG(debug2) <<
" " << xDigiB->
ToString();
4015 if (5 == iSmType && dTimeDif != 0.) {
4017 LOG(debug) <<
"CbmTofTestBeamClusterizer::BuildClusters: "
4019 << iSm <<
" with inconsistent digits " << xDigiA->
GetTime() <<
", " << xDigiB->
GetTime()
4020 <<
" -> " << dTimeDif;
4021 LOG(debug) <<
" " << xDigiA->
ToString();
4022 LOG(debug) <<
" " << xDigiB->
ToString();
4032 &&
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size() > 2) {
4033 LOG(debug) <<
"Hit candidate outside correlation window, check for "
4034 "better possible digis, "
4035 <<
" mul " <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
4038 Double_t dPosYN = 0.;
4039 Double_t dTimeDifN = 0;
4050 if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
4051 LOG(debug) <<
"Replace digi on side " << xDigiC->
GetSide() <<
", yPosNext " << dPosYN
4052 <<
" old: " << dPosY;
4053 dTimeDif = dTimeDifN;
4058 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4060 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4065 ++(
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
4067 ++(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
4073 LOG(fatal) <<
"Wrong combinations of digis " <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4074 <<
"," <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1];
4087 LOG(debug1) <<
"NbChanInHit "
4088 << Form(
" %3d %3d %3d %3d %3d 0x%p %1.0f Time %f PosX %f "
4090 iNbChanInHit, iSmType, iRpc, iCh, iLastChan, xDigiA, xDigiA->
GetSide(), dTime,
4097 if (0 < iNbChanInHit) {
4098 if (iLastChan == iCh - 1) {
4107 if (TMath::Abs(dTime - dLastTime) <
fdMaxTimeDist && iLastChan == iCh - 1
4110 dWeightedTime += dTime * dTotS;
4111 dWeightedPosX += dPosX * dTotS;
4112 dWeightedPosY += dPosY * dTotS;
4113 dWeightedPosZ += dPosZ * dTotS;
4114 dWeightsSum += dTotS;
4120 LOG(debug1) <<
" Add Digi and erase fStor entries(a): NbChanInHit " << iNbChanInHit <<
", "
4121 << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
4124 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4126 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4128 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4130 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4135 dWeightedTime /= dWeightsSum;
4136 dWeightedPosX /= dWeightsSum;
4137 dWeightedPosY /= dWeightsSum;
4138 dWeightedPosZ /= dWeightsSum;
4141 Double_t hitpos_local[3];
4142 hitpos_local[0] = dWeightedPosX;
4143 hitpos_local[1] = dWeightedPosY;
4144 hitpos_local[2] = dWeightedPosZ;
4147 TGeoNode* cNode = gGeoManager->GetCurrentNode();
4148 gGeoManager->GetCurrentMatrix();
4152 gGeoManager->LocalToMaster(hitpos_local, hitpos);
4153 LOG(debug1) << Form(
" LocalToMaster for node %p: "
4154 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
4155 cNode, hitpos_local[0], hitpos_local[1], hitpos_local[2], hitpos[0],
4156 hitpos[1], hitpos[2]);
4158 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
4163 TVector3 hitPosErr(0.5, 0.5, 0.5);
4178 if (iChm < 0) iChm = 0;
4179 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
4185 LOG(debug) <<
"Save Hit "
4186 << Form(
" %3d %3d 0x%08x %3d %3d %3d %f %f",
fiNbHits, iNbChanInHit, iDetId, iChm,
4187 iLastChan, iRefId, dWeightedTime, dWeightedPosY)
4188 <<
", DigiSize: " <<
vDigiIndRef.size() <<
", DigiInds: ";
4198 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits <<
": vDigiIndRef.size()";
4203 LOG(debug) <<
"Store Hit twice? "
4204 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
4208 LOG(debug) <<
" Digi " << pDigiC->
ToString();
4211 for (Int_t i = 0; i < digiMatchL->
GetNofLinks(); i++) {
4215 LOG(debug) <<
" DigiL " << pDigiC->
ToString();
4226 Int_t(dWeightsSum * 10.));
4232 LH_store(iSmType, iSm, iRpc, iChm, pHit);
4251 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
4252 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
4262 dWeightedTime = dTime * dTotS;
4263 dWeightedPosX = dPosX * dTotS;
4264 dWeightedPosY = dPosY * dTotS;
4265 dWeightedPosZ = dPosZ * dTotS;
4266 dWeightsSum = dTotS;
4271 LOG(debug2) <<
" Next fStor Digi " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh
4272 <<
", Dig0 " << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]) <<
", Dig1 "
4273 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4277 LOG(debug2) <<
" Erase fStor entries(b) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch"
4280 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4282 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4284 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4286 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4302 LOG(debug) << Form(
"1.Hit on channel %d, time: %f, PosY %f", iCh, dTime, dPosY);
4305 dWeightedTime = dTime * dTotS;
4306 dWeightedPosX = dPosX * dTotS;
4307 dWeightedPosY = dPosY * dTotS;
4308 dWeightedPosZ = dPosZ * dTotS;
4309 dWeightsSum = dTotS;
4317 LOG(debug2) <<
" Erase fStor entries(c) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch"
4320 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4322 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4324 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4326 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4344 if (
AddNextChan(iSmType, iSm, iRpc, iLastChan, dLastPosX, dLastPosY, dLastTime, dWeightsSum)) {
4348 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
4349 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
4351 LOG(debug2) <<
"finished V-RPC"
4352 << Form(
" %3d %3d %3d %d %f %fx", iSmType, iSm, iRpc,
fTofHitsColl->GetEntriesFast(),
4353 dLastPosX, dLastPosY);
4357 LOG(error) <<
"=> Cluster building "
4358 <<
"from digis to hits not implemented for pads, Sm type " << iSmType <<
" Rpc " << iRpc;
4364 if (0 < iNbChanInHit) {
4365 LOG(debug1) <<
"Process cluster " << iNbChanInHit;
4369 LOG(debug1) <<
"H-Hit ";
4372 LOG(debug2) <<
"V-Hit ";
4374 dWeightedTime /= dWeightsSum;
4375 dWeightedPosX /= dWeightsSum;
4376 dWeightedPosY /= dWeightsSum;
4377 dWeightedPosZ /= dWeightsSum;
4380 Double_t hitpos_local[3] = {3 * 0.};
4381 hitpos_local[0] = dWeightedPosX;
4382 hitpos_local[1] = dWeightedPosY;
4383 hitpos_local[2] = dWeightedPosZ;
4386 TGeoNode* cNode = gGeoManager->GetCurrentNode();
4387 gGeoManager->GetCurrentMatrix();
4391 gGeoManager->LocalToMaster(hitpos_local, hitpos);
4392 LOG(debug1) << Form(
" LocalToMaster for V-node %p: "
4393 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
4394 cNode, hitpos_local[0], hitpos_local[1], hitpos_local[2], hitpos[0], hitpos[1],
4397 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
4401 TVector3 hitPosErr(0.5, 0.5, 0.5);
4417 if (iChm < 0) iChm = 0;
4418 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
4422 LOG(debug) <<
"Save V-Hit "
4423 << Form(
" %3d %3d 0x%08x %3d 0x%08x",
4424 fiNbHits, iNbChanInHit, iDetId, iLastChan,
4428 LOG(debug) <<
", DigiInds: ";
4438 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits <<
": vDigiIndRef.size()";
4443 LOG(debug) <<
"Store Hit twice? "
4444 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
4453 Int_t(dWeightsSum * 10.));
4460 LH_store(iSmType, iSm, iRpc, iChm, pHit);
4480 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
4481 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
4491 LOG(debug2) <<
" Fini-A " << Form(
" %3d %3d %3d M%3d", iSmType, iSm, iRpc,
fviClusterMul[iSmType][iSm][iRpc]);
4493 LOG(debug2) <<
" Fini-B " << Form(
" %3d ", iSmType);
4497 LOG(error) <<
" Compressed Digis not implemented ... ";