829 TFile* oldFile = gFile;
830 TDirectory* oldDir = gDirectory;
833 new TH1I(
"TofCosmicClus_ClustBuildTime",
"Time needed to build clusters in each event; Time [s]", 4000, 0.0, 4.0);
847 Double_t YSCAL = 50.;
852 LOG(warning) <<
"No DigiPar for SmType " << Form(
"%d, 0x%08x", iS, iUCellId);
858 new TH2F(Form(
"cl_SmT%01d_Pos", iS), Form(
"Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
862 Double_t TSumMax = 1.E3;
865 new TH2F(Form(
"cl_SmT%01d_TOff", iS), Form(
"Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
868 99, -TSumMax, TSumMax);
870 TProfile* hSvelcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iS));
871 if (NULL == hSvelcur) {
873 new TProfile(Form(
"cl_SmT%01d_Svel", iS), Form(
"Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
882 for (Int_t iPar = 0; iPar < 4; iPar++) {
883 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar));
884 if (NULL == hFparcur) {
885 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Fpar%1d", iS, iPar) <<
" not found, recreate ...";
886 fhSmCluFpar[iS][iPar] =
new TProfile(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar),
887 Form(
"Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
892 fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
898 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
899 fhTSmCluPosition[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
900 Form(
"Clu position of SmType %d under Selector %02d; Sm+Rpc# "
905 fhTSmCluTOff[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
906 Form(
"Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
911 fhTSmCluTRun[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
912 Form(
"Clu TimeZero in SmType %d under Selector %02d; Event# "
921 LOG(info) <<
" Define Clusterizer histos for " << iNbDet <<
" detectors ";
950 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
961 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
964 LOG(info) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
965 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx " <<
fChannelInfo->
GetSizex()
973 if (NULL ==
fChannelInfo) LOG(warning) << Form(
"missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
978 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
979 Form(
"Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1", iRpcId, iSmId, iSmType),
984 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
985 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts", iRpcId, iSmId, iSmType),
989 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
990 Form(
"Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType), 3600.,
993 fhRpcDTLastHits[iDetIndx] =
new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
994 Form(
"Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
995 "#DeltaT (ns)); counts",
996 iRpcId, iSmId, iSmType),
999 fhRpcDTLastHits_Tot[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1000 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1002 iRpcId, iSmId, iSmType),
1005 fhRpcDTLastHits_CluSize[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1006 Form(
"Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1008 iRpcId, iSmId, iSmType),
1009 100, 0., 10., 16, 0.5, 16.5);
1011 Double_t YSCAL = 50.;
1015 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1016 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]", iRpcId, iSmId, iSmType),
1019 fhRpcCluPositionEvol[iDetIndx] =
new TProfile(Form(
"cl_SmT%01d_sm%03d_rpc%03d_PosEvol", iSmType, iSmId, iRpcId),
1020 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Analysis Time "
1022 iRpcId, iSmId, iSmType),
1023 1000, 0., 1.E5, -100., 100.);
1025 fhRpcCluTimeEvol[iDetIndx] =
new TProfile(Form(
"cl_SmT%01d_sm%03d_rpc%03d_TimeEvol", iSmType, iSmId, iRpcId),
1026 Form(
"Clu time of Rpc #%03d in Sm %03d of type %d; Analysis Time [s]; dT "
1028 iRpcId, iSmId, iSmType),
1029 1000, 0., 1.E5, -10., 10.);
1032 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1033 Form(
"Clu position difference of Rpc #%03d in Sm %03d of type "
1034 "%d; Strip []; #Deltaypos(clu) [cm]",
1035 iRpcId, iSmId, iSmType),
1039 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1040 Form(
"Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1041 "%d; Strip []; #Deltaypos(mat) [cm]",
1042 iRpcId, iSmId, iSmType),
1045 Double_t TSumMax = 1.E3;
1048 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1049 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]", iRpcId, iSmId, iSmType),
1053 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1054 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1055 "[]; #DeltaTOff(clu) [ns]",
1056 iRpcId, iSmId, iSmType),
1060 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1061 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1062 "[]; #DeltaTOff(mat) [ns]",
1063 iRpcId, iSmId, iSmType),
1067 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1068 Form(
"Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]", iRpcId, iSmId, iSmType),
1072 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1073 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [a.u.]", iRpcId, iSmId, iSmType),
1078 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1079 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]", iRpcId, iSmId, iSmType),
1083 fhRpcCluAvWalk[iDetIndx] =
new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1084 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1088 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1089 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
nbClWalkBinX,
1095 for (Int_t iSide = 0; iSide < 2; iSide++) {
1097 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1098 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1109 LOG(info) <<
" Define Clusterizer monitoring histos ";
1112 Form(
"Cluster Multiplicity Correlation of Dut %d%d%d with Sel "
1113 "%d%d%d; Mul(Sel); Mul(Dut)",
1115 32, 0, 32, 32, 0, 32);
1118 "Space difference along channel direction between Digi pairs on "
1119 "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
1122 "Time difference between Digi pairs on adjacent channels; "
1123 "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1126 "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
1127 "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1128 5000, -10.0, 10.0, 2000, -5.0, 5.0);
1130 "Position difference between Point and Hit as function of Cluster "
1131 "Size; Cluster Size [Strips]; dX [cm]",
1132 100, 0.5, 100.5, 500, -50, 50);
1134 "Position difference between Point and Hit as function of Cluster "
1135 "Size; Cluster Size [Strips]; dY [cm]",
1136 100, 0.5, 100.5, 500, -50, 50);
1138 "Position difference between Point and Hit as "
1139 "function of Channel dif; Ch Dif [Strips]; dX [cm]",
1140 101, -50.5, 50.5, 500, -50, 50);
1142 "Position difference between Point and Hit as "
1143 "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1144 101, -50.5, 50.5, 500, -50, 50);
1146 "How many time per event the 2 digis on a channel "
1147 "were of the same side ; Counts/Event []",
1149 fhNbDigiPerChan =
new TH1I(
"Clus_NbDigiPerChan",
"Nb of Digis per channel; Nb Digis []", 100, 0.0, 100.0);
1155 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1157 new TH2F(Form(
"cl_dt_Sel%02d", iSel), Form(
"Selector time %02d; dT [ns]", iSel), 99, -50., 50., 16, -0.5, 15.5);
1175 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1183 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1186 LOG(debug1) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1187 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1206 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1208 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul", iSmType, iSmId, iRpcId, iSel),
1209 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1210 "under Selector %02d; M []; cnts",
1211 iRpcId, iSmId, iSmType, iSel),
1214 if (NULL ==
fhTRpcCluMul[iDetIndx][iSel]) LOG(fatal) <<
" Histo not generated !";
1216 Double_t YSCAL = 50.;
1220 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos", iSmType, iSmId, iRpcId, iSel),
1221 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d under "
1222 "Selector %02d; Strip []; ypos [cm]",
1223 iRpcId, iSmId, iSmType, iSel),
1226 Double_t TSumMax = 1.E4;
1229 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff", iSmType, iSmId, iRpcId, iSel),
1230 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1231 "Selector %02d; Strip []; TOff [ns]",
1232 iRpcId, iSmId, iSmType, iSel),
1237 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot", iSmType, iSmId, iRpcId, iSel),
1238 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1239 "Selector %02d; StripSide []; TOT [a.u.]",
1240 iRpcId, iSmId, iSmType, iSel),
1245 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size", iSmType, iSmId, iRpcId, iSel),
1246 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1247 "Selector %02d; Strip []; size [strips]",
1248 iRpcId, iSmId, iSmType, iSel),
1253 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk", iSmType, iSmId, iRpcId, iSel),
1254 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel", iSmType, iSmId, iRpcId, iSel),
1259 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSmId, iRpcId, iSel),
1260 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; DistSel; T-TSel", iSmType, iSmId, iRpcId, iSel),
1268 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY", iSmType, iSmId, iRpcId, iSel),
1269 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1271 iSmType, iSmId, iRpcId, iSel),
1275 new TH3F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2", iSmType, iSmId, iRpcId, iSel),
1276 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2", iSmType, iSmId, iRpcId, iSel),
nbClWalkBinX,
1284 for (Int_t iSide = 0; iSide < 2; iSide++) {
1286 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide, iSel),
1287 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide,
1294 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH", iSmType, iSmId, iRpcId, iSel),
1295 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1296 "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1297 iRpcId, iSmId, iSmType, iSel),
1298 100, 0., 10., 99, -TSumMax, TSumMax);
1301 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH", iSmType, iSmId, iRpcId, iSel),
1302 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1303 "Selector %02d; log(#DeltaT (ns)); TOT [a.u.]",
1304 iRpcId, iSmId, iSmType, iSel),
1308 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH", iSmType, iSmId, iRpcId, iSel),
1309 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1310 "Selector %02d; log(#DeltaT (ns)); size [strips]",
1311 iRpcId, iSmId, iSmType, iSel),
1312 100, 0., 10., 10, 0.5, 10.5);
1315 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH", iSmType, iSmId, iRpcId, iSel),
1316 Form(
"Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1317 "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1318 iRpcId, iSmId, iSmType, iSel),
1319 100, 0., 10., 10, 0, 10);
1325 new TH1I(
"Clus_TofHitPerTrk",
"Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []", 2000, 0.0, 20.0);
1328 "Distribution of the Number of MCPoints associated "
1329 "to each TofHit; Nb MCPoint []",
1333 "Time resolution for TofHits containing Digis from a single MC "
1334 "Track; t(1st Mc Point) -tTofHit [ns]",
1335 10000, -25.0, 25.0);
1337 "Time resolution for TofHits containing Digis from a single MC "
1338 "Track; (1st Mc Point) -tTofHit [ns]",
1339 5000, -25.0, 25.0, 6, 0, 6);
1341 "Time resolution for TofHits containing Digis from a single MC "
1342 "Track; t(1st Mc Point) -tTofHit [ns]",
1343 2000, 0.0, 50.0, 2000, 0.0, 50.0);
1347 "Time resolution for TofHits containing Digis from a single "
1348 "TofPoint; tMcPoint -tTofHit [ns]",
1349 10000, -25.0, 25.0);
1351 "Time resolution for TofHits containing Digis from a single "
1352 "TofPoint; tMcPoint -tTofHit [ns]",
1353 5000, -25.0, 25.0, 6, 0, 6);
1355 "Time resolution for TofHits containing Digis "
1356 "from a single TofPoint; tMcPoint -tTofHit [ps]",
1357 2000, 0.0, 50.0, 2000, 0.0, 50.0);
1359 fhClusterSize =
new TH1I(
"Clus_ClusterSize",
"Cluster Size distribution; Cluster Size [Strips]", 100, 0.5, 100.5);
1361 new TH2I(
"Clus_ClusterSizeType",
1362 "Cluster Size distribution in each (SM type, Rpc) pair; Cluster "
1363 "Size [Strips]; 10*SM Type + Rpc Index []",
1366 fhTrackMul =
new TH1I(
"Clus_TrackMul",
"Number of MC tracks generating the cluster; MC Tracks multiplicity []", 100,
1369 "Cluster Size distribution as function of Number of MC tracks generating "
1370 "the cluster; Cluster Size [Strips]; MC tracks mul. []",
1371 100, 0.5, 100.5, 100, 0.5, 100.5);
1373 "Position of Clusters with only 1 MC tracks "
1374 "generating the cluster; X [cm]; Y [cm]",
1375 1500, -750, 750, 1000, -500, 500);
1377 "Position of Clusters with >1 MC tracks "
1378 "generating the cluster; X [cm]; Y [cm]",
1379 1500, -750, 750, 1000, -500, 500);
1380 fhAllTrkMulPos =
new TH2D(
"Clus_AllTrkMulPos",
"Position of all clusters generating the cluster; X [cm]; Y [cm]",
1381 1500, -750, 750, 1000, -500, 500);
1383 "Probability of having a cluster with multiple tracks as "
1384 "function of position; X [cm]; Y [cm]; Prob. [%]",
1385 1500, -750, 750, 1000, -500, 500);
1391 gDirectory = oldDir;
1402 gGeoManager->CdTop();
1404 if (0 < iNbTofHits) {
1407 Double_t dTTrig[
iNSel];
1410 Double_t ddXdZ[
iNSel];
1411 Double_t ddYdZ[
iNSel];
1412 Double_t dSel2dXdYMin[
iNSel];
1422 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1435 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1437 if (NULL == pHit)
continue;
1444 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
1446 Int_t iDetIndx = it->second;
1455 << Form(
" Addr 0x%08x, t %f, tspill %f ", pHit->
GetAddress(), pHit->
GetTime(), dTimeAna);
1459 LOG(fatal) << Form(
" <E> hit not stored in memory for TSRC %d%d%d%d", iSmType, iSm, iRpc, iCh);
1471 LOG(warning) << Form(
"Invalid time ordering in ev %8.0f in list of "
1472 "size %lu for TSRC %d%d%d%d: Delta t %f ",
1481 LOG(debug) <<
" pop from list size " <<
fvLastHits[iSmType][iSm][iRpc][iCh].size()
1482 << Form(
" outdated hits for ev %8.0f in TSRC %d%d%d%d",
fdEvent, iSmType, iSm, iRpc, iCh)
1483 << Form(
" with tHit - tLast %f ",
1488 LOG(fatal) << Form(
"Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
1490 fvLastHits[iSmType][iSm][iRpc][iCh].
size(), iSmType, iSm, iRpc, iCh,
1491 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
1492 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
1493 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
1494 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
1501 Double_t dTotSum = 0.;
1502 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
1505 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
1511 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
1513 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
1530 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1532 if (NULL == pHit)
continue;
1538 Double_t TotSum = 0.;
1539 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
1542 if (iDigInd0 < fTofCalDigisColl->GetEntriesFast()) {
1544 TotSum += pDig0->
GetTot();
1558 LOG(debug) <<
"CbmTofCosmicClusterizer::FillHistos: Sel2Mul: " << iSel2Mul;
1561 if (iSel2Mul == 0)
return kFALSE;
1563 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1564 BSel[iSel] = kFALSE;
1572 dSel2dXdYMin[iSel] = 1.E300;
1580 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
1583 <<
", Sel2Mul " << iSel2Mul <<
" TRef: " <<
dTRef;
1586 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1588 if (NULL == pHit)
continue;
1591 if (pHit->
GetTime() < dTTrig[iSel]) {
1592 dTTrig[iSel] = pHit->
GetTime();
1598 LOG(debug) << Form(
"Found selector 0 with mul %d from 0x%08x at %f ", iDutMul, pTrig[iSel]->GetAddress(),
1608 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
1611 <<
", Sel2Mul " << iSel2Mul;
1613 LOG(debug1) <<
"Found selector 1";
1615 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1617 if (NULL == pHit)
continue;
1620 if (pHit->
GetTime() < dTTrig[iSel]) {
1621 dTTrig[iSel] = pHit->
GetTime();
1627 LOG(debug) << Form(
"Found selector 1 with mul %d from 0x%08x at %f ", iRefMul, pTrig[iSel]->GetAddress(),
1633 LOG(info) <<
"CbmTofCosmicClusterizer::FillHistos: selection not "
1639 if (
pRef == NULL)
return kFALSE;
1640 dTTrig[iSel] =
dTRef;
1646 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1648 BSel[iSel] = kFALSE;
1650 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1652 if (NULL == pHit)
continue;
1655 Double_t dzscal = 1.;
1657 Double_t dSEl2dXdz = (pHit->
GetX() - pTrig[iSel]->GetX()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
1658 Double_t dSEl2dYdz = (pHit->
GetY() - pTrig[iSel]->GetY()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
1660 if (TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
1661 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
1664 Double_t dX2Y2 = TMath::Sqrt(dSEl2dXdz * dSEl2dXdz + dSEl2dYdz * dSEl2dYdz);
1665 if (dX2Y2 < dSel2dXdYMin[iSel]) {
1666 ddXdZ[iSel] = dSEl2dXdz;
1667 ddYdZ[iSel] = dSEl2dYdz;
1668 dSel2dXdYMin[iSel] = dX2Y2;
1678 UInt_t uTriggerPattern = 0;
1682 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1687 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1690 for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
1691 if (uTriggerPattern & (0x1 << uChannel)) {
1700 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1702 if (NULL == pHit)
continue;
1705 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
1707 Int_t iDetIndx = it->second;
1717 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1732 LOG(error) <<
"Invalid Channel Pointer for ChId " << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
1738 LOG(debug1) <<
"Hit info: "
1739 << Form(
" 0x%08x %d %f %f %f %f %f %d", iChId, iCh, pHit->
GetX(), pHit->
GetY(), pHit->
GetTime(),
1743 hitpos[0] = pHit->
GetX();
1744 hitpos[1] = pHit->
GetY();
1745 hitpos[2] = pHit->
GetZ();
1746 Double_t hitpos_local[3];
1747 TGeoNode* cNode = gGeoManager->GetCurrentNode();
1748 gGeoManager->MasterToLocal(hitpos, hitpos_local);
1749 LOG(debug1) << Form(
" MasterToLocal for node %p: (%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)", cNode, hitpos[0],
1750 hitpos[1], hitpos[2], hitpos_local[0], hitpos_local[1], hitpos_local[2]);
1753 fhSmCluPosition[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
1759 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1763 fhTSmCluPosition[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
1767 LOG(debug1) <<
" TofDigiMatchColl entries:" <<
fTofDigiMatchColl->GetEntriesFast();
1770 LOG(error) <<
" Inconsistent DigiMatches for Hitind " << iHitInd
1775 LOG(debug1) <<
" got " << digiMatch->
GetNofLinks() <<
" matches for iCh " << iCh <<
" at iHitInd " << iHitInd;
1779 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1783 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
1785 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
1804 Double_t dMeanTimeSquared = 0.;
1805 Double_t dNstrips = 0.;
1807 Double_t dDelTof = 0.;
1808 Double_t dTcor[
iNSel];
1809 Double_t dTTcor[
iNSel];
1810 Double_t dZsign[
iNSel];
1811 Double_t dzscal = 1.;
1812 Double_t dDist = 0.;
1814 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
1817 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
1820 if (iDigInd0 < fTofCalDigisColl->GetEntriesFast() && iDigInd1 < fTofCalDigisColl->GetEntriesFast()) {
1823 if ((Int_t) pDig0->
GetType() != iSmType) {
1824 LOG(error) << Form(
" Wrong Digi SmType for Tofhit %d in iDetIndx "
1825 "%d, Ch %d with %3.0f strips at Indx %d, %d",
1826 iHitInd, iDetIndx, iCh, dNstrips, iDigInd0, iDigInd1);
1828 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch " << pDig0->
GetChannel() <<
", Side "
1829 << pDig0->
GetSide() <<
", StripSide " << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
1830 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side " << pDig1->
GetSide() <<
", StripSide "
1831 << (Double_t) iCh * 2. + pDig1->
GetSide() <<
", Tot0 " << pDig0->
GetTot() <<
", Tot1 "
1841 if (iCh0 != iCh1 || iS0 == iS1) {
1842 LOG(fatal) << Form(
" MT2 for Tofhit %d in iDetIndx %d, Ch %d from %3.0f strips: ", iHitInd, iDetIndx, iCh,
1844 << Form(
" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd0, iCh0, iS0, pDig0->
GetTime())
1845 << Form(
" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd1, iCh1, iS1, pDig1->
GetTime());
1850 LOG(error) << Form(
" Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
1851 "from %3.0f strips: %d, %d, %d, %d",
1852 iHitInd, iDetIndx, iCh, iDigInd0, iDigInd1, dNstrips, iCh0, iCh1, iS0, iS1);
1866 Double_t dCorWeigth = 1.;
1874 if (0 == pDig0->
GetSide()) dDelPos *= -1.;
1888 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch " << pDig0->
GetChannel() <<
", Side "
1889 << pDig0->
GetSide() <<
", StripSide " << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
1890 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side " << pDig1->
GetSide() <<
", StripSide "
1891 << (Double_t) iCh * 2. + pDig1->
GetSide();
1895 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
1897 if (NULL == pHit || NULL == pTrig[iSel]) {
1898 LOG(info) <<
" invalid pHit, iSel " << iSel <<
", iDetIndx " << iDetIndx;
1906 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
1908 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
1919 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY());
1921 dDist = TMath::Sqrt(TMath::Power(pHit->
GetX() - pTrig[iSel]->
GetX(), 2.)
1922 + TMath::Power(pHit->
GetY() - pTrig[iSel]->
GetY(), 2.)
1923 + TMath::Power(pHit->
GetZ() - pTrig[iSel]->
GetZ(), 2.));
1924 dDelTof = dDist /
cLight;
1925 pHit->
GetZ() < pTrig[iSel]->
GetZ() ? dZsign[iSel] = -1. : dZsign[iSel] = 1.;
1927 dTTcor[iSel] = dDelTof * dZsign[iSel];
1932 || TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
1933 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
1937 TMath::Power(pHit->
GetX()
1938 - (pTrig[iSel]->
GetX() + ddXdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
1940 + TMath::Power(pHit->
GetY()
1941 - (pTrig[iSel]->
GetY() + ddYdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
1961 Double_t dTentry = dDist;
1963 if (iBx < 0) iBx = 0;
1967 Double_t dDTentry = dTentry - ((Double_t) iBx) * dBinWidth;
1969 dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
1970 Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
1971 Double_t w1 = 1. - w0;
1972 if (iBx1 < 0) iBx1 = 0;
1974 dDelTof =
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
1975 +
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel] * w1;
1977 LOG(debug1) << Form(
" DelTof for SmT %d, Sm %d, R %d, T %d, dTRef "
1978 "%6.1f, Bx %d, Bx1 %d, DTe %6.1f -> DelT %6.1f",
1979 iSmType, iSm, iRpc, iSel,
dTRef - dTTrig[iSel], iBx, iBx1, dDTentry, dDelTof);
1982 dTTcor[iSel] += dDelTof * dZsign[iSel];
1983 dTcor[iSel] = (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel];
1987 LOG(debug) << Form(
"TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
1988 "Ch %d,%d, S %d,%d Tcor %8.3f, LocT %6.1f, W-ent: "
1991 iCh0, iCh1, iS0, iS1, dTcor[iSel],
1998 LOG(error) << Form(
" Inconsistent walk histograms -> debugging "
1999 "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
2000 fiNevtBuild, iDetIndx, iSel, iCh0, iCh1, iS0, iS1);
2003 "TRpcCluWalk values side %d: %5.2f, %7.3f, %6.3f, "
2004 " side %d: %5.2f, %7.3f, %6.3f",
2041 fhTSmCluTOff[iSmType][iSel]->Fill((Double_t)(iSm), dTcor[iSel]);
2044 != (pTrig[iSel]->GetAddress()
2048 hitpos[2] = pHit->
GetZ();
2049 gGeoManager->MasterToLocal(hitpos, hitpos_local);
2052 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
2060 LOG(error) <<
"CbmTofCosmicClusterizer::FillHistos: invalid digi index " << iDetIndx <<
" digi0,1" << iDigInd0
2069 Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
2071 Double_t dTrms = TMath::Sqrt(dVar);
2072 LOG(debug) << Form(
" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
2073 "%3.0f strips: %6.3f ns",
2074 iHitInd, iDetIndx, iCh, dNstrips, dTrms);
2079 LOG(debug1) <<
" Fill Time of iDetIndx " << iDetIndx <<
", hitAddr "
2080 << Form(
" %08x, y = %5.2f", pHit->
GetAddress(), hitpos_local[1]) <<
" for |y| <"
2082 if (TMath::Abs(hitpos_local[1]) < (
fhRpcCluPosition[iDetIndx]->GetYaxis()->GetXmax())) {
2086 TMath::Sqrt(TMath::Power(pHit->
GetX() -
pRef->GetX(), 2.) + TMath::Power(pHit->
GetY() -
pRef->GetY(), 2.)
2087 + TMath::Power(pHit->
GetZ() -
pRef->GetZ(), 2.));
2088 dDelTof = dDist /
cLight;
2089 Double_t dZsgn = 1.;
2090 if (pHit->
GetZ() <
pRef->GetZ()) dZsgn = -1.;
2097 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2099 LOG(debug1) <<
" TRpcCluTOff " << iDetIndx <<
", Sel " << iSel
2100 << Form(
", Dt %7.3f, LHsize %lu ", (pHit->
GetTime() - dTTrig[iSel]),
2105 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2107 for (
size_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
2109 LOG(debug1) << Form(
" %f,", pHit->
GetTime() - (*itL)->GetTime());
2115 (pHit->
GetTime() - dTTrig[iSel])
2118 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
2120 for (Int_t iH = 0; iH < 1; iH++) {
2123 Double_t dTsinceLast = pHit->
GetTime() - (*itL)->GetTime();
2125 LOG(fatal) << Form(
"Invalid Time since last hit on channel "
2126 "TSRC %d%d%d%d: %f > %f",
2130 (pHit->
GetTime() - dTTrig[iSel]));
2142 LOG(debug1) <<
"CbmTofCosmicClusterizer::FillHistos: "
2145 for (UInt_t uCluster = 0; uCluster <
fviClusterSize[iSmType][iRpc].size(); uCluster++) {
2146 LOG(debug2) <<
"CbmTofCosmicClusterizer::FillHistos: " << Form(
" %3d %3d %3d ", iSmType, iRpc, uCluster);
2150 40 * iSmType + iRpc);
2165 fvdX[iSmType][iRpc].clear();
2166 fvdY[iSmType][iRpc].clear();
2167 fvdDifX[iSmType][iRpc].clear();
2168 fvdDifY[iSmType][iRpc].clear();
2181 TFile* oldFile = gFile;
2182 TDirectory* oldDir = gDirectory;
2205 LOG(debug) <<
"Write triggered Histos for Det Ind " << iDetIndx
2207 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2220 Int_t iSmAddr = iUniqueId &
ModMask;
2232 LOG(info) <<
"WriteHistos: No entries in Walk histos for "
2233 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
2237 TH2* htempPos = NULL;
2238 TProfile* htempPos_pfx = NULL;
2239 TH1* htempPos_py = NULL;
2240 TProfile* htempTOff_pfx = NULL;
2241 TH1* htempTOff_px = NULL;
2242 TProfile* hAvPos_pfx = NULL;
2243 TProfile* hAvTOff_pfx = NULL;
2244 TH2* htempTOff = NULL;
2245 TH2* htempTot = NULL;
2246 TProfile* htempTot_pfx = NULL;
2247 TH1* htempTot_Mean = NULL;
2248 TH1* htempTot_Off = NULL;
2257 htempTOff_px = htempTOff->ProjectionX(
"_px", 1,
fhTRpcCluTOff[iDetIndx][
fCalSel]->GetNbinsY());
2298 if (NULL == htempPos_pfx) {
2299 LOG(info) <<
"WriteHistos: Projections not available, continue ";
2303 htempTot_Mean = htempTot_pfx->ProjectionX(
"_Mean");
2304 htempTot_Off = htempTot_pfx->ProjectionX(
"_Off");
2306 htempPos_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
2307 htempTOff_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
2308 htempTot_pfx->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
2309 htempTot_Mean->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
2310 htempTot_Off->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
2311 hAvPos_pfx->SetName(Form(
"cl_CorSmT%01d_Pos_pfx", iSmType));
2312 hAvTOff_pfx->SetName(Form(
"cl_CorSmT%01d_TOff_pfx", iSmType));
2316 htempTot_Off->Reset();
2318 Int_t nbins = htempTot->GetNbinsX();
2319 for (
int i = 0; i < nbins; i++) {
2320 hbins[i] = htempTot->ProjectionY(Form(
"bin%d", i + 1), i + 1, i + 1);
2322 Int_t iBmax = hbins[i]->GetMaximumBin();
2323 TAxis* xaxis = hbins[i]->GetXaxis();
2324 Double_t Xmax = xaxis->GetBinCenter(iBmax);
2326 XOff = (Double_t)(Int_t) XOff;
2327 if (XOff < 0) XOff = 0;
2328 htempTot_Off->SetBinContent(i + 1, XOff);
2329 Double_t Xmean = htempTot_Mean->GetBinContent(i + 1);
2331 LOG(warning) <<
"Inconsistent Tot numbers for "
2332 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, Off %f", iSmType, iSm, iRpc, i, Xmean, XOff);
2334 htempTot_Mean->SetBinContent(i + 1, (Xmean - XOff));
2335 if (htempTot_Mean->GetBinContent(i + 1) != (Xmean - XOff))
2336 LOG(warning) <<
"Tot numbers not stored properly for "
2337 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, target %f", iSmType, iSm, iRpc, i,
2338 htempTot_Mean->GetBinContent(i + 1), Xmean - XOff);
2340 htempPos_pfx->Write();
2341 htempTOff_pfx->Write();
2343 htempTot_Mean->Write();
2344 htempTot_Off->Write();
2350 LOG(info) <<
"WriteHistos: restore Offsets and Gains and save Walk for "
2351 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
2352 <<
" and calSmAddr = " << Form(
" 0x%08x ", TMath::Abs(
fCalSmAddr));
2353 htempPos_pfx->Reset();
2354 htempTOff_pfx->Reset();
2355 htempTot_Mean->Reset();
2356 htempTot_Off->Reset();
2357 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
2360 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2362 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2363 htempPos_pfx->Fill(iCh, YMean);
2364 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
2365 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
2366 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
2367 <<
", expected " << YMean;
2369 htempTOff_pfx->Fill(iCh, TMean);
2371 for (Int_t iSide = 0; iSide < 2; iSide++) {
2372 htempTot_Mean->SetBinContent(
2373 iCh * 2 + 1 + iSide,
2375 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2379 LOG(debug1) <<
" Offset, gain restoring done ... ";
2380 htempPos_pfx->Write();
2381 htempTOff_pfx->Write();
2383 htempTot_Mean->Write();
2384 htempTot_Off->Write();
2386 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2388 TDirectory* curdir = gDirectory;
2390 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
2391 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2392 gDirectory->cd(curdir->GetPath());
2393 if (NULL != hCorDelTof) {
2394 TH1D* hCorDelTofout =
2395 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2396 hCorDelTofout->Write();
2399 LOG(debug) <<
" No CorDelTof histo "
2400 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
2408 LOG(info) <<
"restore Offsets and Gains and update Walk for "
2409 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with "
2434 if (NULL == h2tmp0) {
2435 LOG(info) << Form(
"WriteHistos: Walk histo not available for SmT "
2436 "%d, Sm %d, Rpc %d, Ch %d",
2437 iSmType, iSm, iRpc, iCh);
2440 Int_t iNEntries = h2tmp0->GetEntries();
2442 LOG(info) << Form(
" Update Walk correction for SmT %d, Sm %d, Rpc "
2443 "%d, Ch %d, Sel%d: Entries %d",
2444 iSmType, iSm, iRpc, iCh,
fCalSel, iNEntries);
2448 if (-1 < iNEntries) {
2449 TProfile* htmp0 = h2tmp0->ProfileX(
"_pfx", 1, h2tmp0->GetNbinsY());
2450 TProfile* htmp1 = h2tmp1->ProfileX(
"_pfx", 1, h2tmp1->GetNbinsY());
2451 TH1D* h1tmp0 = h2tmp0->ProjectionX(
"_px", 1, h2tmp0->GetNbinsY());
2452 TH1D* h1tmp1 = h2tmp1->ProjectionX(
"_px", 1, h2tmp1->GetNbinsY());
2453 TH1D* h1ytmp0 = h2tmp0->ProjectionY(
"_py", 1,
nbClWalkBinX);
2454 TH1D* h1ytmp1 = h2tmp1->ProjectionY(
"_py", 1,
nbClWalkBinX);
2455 Double_t dWMean0 = h1ytmp0->GetMean();
2456 Double_t dWMean1 = h1ytmp1->GetMean();
2457 Double_t dWMean = 0.5 * (dWMean0 + dWMean1);
2460 if (5 == iSmType || 8 == iSmType)
2465 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
2468 (((TProfile*) htmp0)->GetBinContent(iWx + 1) + ((TProfile*) htmp1)->GetBinContent(iWx + 1))
2470 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor - dWMean;
2471 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor - dWMean;
2475 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
2476 Double_t dWcor0 = ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
2477 Double_t dWcor1 = ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
2478 Double_t dWcor = 0.5 * (dWcor0 + dWcor1);
2479 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor;
2480 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor;
2482 if (iCh == 10 && iSmType == 0 && iSm == 1 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
2483 LOG(debug) <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc <<
"), Rpc " << iRpc <<
", Bin "
2484 << iWx <<
", " << h1tmp0->GetBinContent(iWx + 1)
2485 <<
" cts: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] <<
" + "
2486 << ((TProfile*) htmp0)->GetBinContent(iWx + 1) <<
" - " << dWMean0 <<
" -> "
2487 << dWcor - dWMean0 <<
", S1: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
2488 <<
" + " << ((TProfile*) htmp1)->GetBinContent(iWx + 1) <<
" - " << dWMean1 <<
" -> "
2493 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
2494 Double_t dWcor0 = ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
2495 Double_t dWcor1 = ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
2497 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] += dWcor0;
2498 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] += dWcor1;
2500 if (iCh == 10 && iSmType == 0 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
2501 LOG(info) <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc <<
"), Rpc " << iRpc <<
", Bin " << iWx
2502 <<
", " << h1tmp0->GetBinContent(iWx + 1)
2503 <<
" cts: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] <<
" + "
2504 << ((TProfile*) htmp0)->GetBinContent(iWx + 1) <<
" - " << dWMean0 <<
" -> "
2505 << dWcor0 - dWMean0 <<
", S1: " <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
2506 <<
" + " << ((TProfile*) htmp1)->GetBinContent(iWx + 1) <<
" - " << dWMean1 <<
" -> "
2507 << dWcor1 - dWMean1;
2517 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2518 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2521 && h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
2522 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2525 LOG(error) <<
"writing not successful for " << h1tmp0->GetName() <<
", attempts left: " << iTry
2526 <<
", iWx " << iWx <<
", got " << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
2527 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
2530 && h1tmp1->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]) {
2531 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2534 LOG(error) <<
"writing not successful for " << h1tmp1->GetName() <<
", attempts left: " << iTry
2535 <<
", iWx " << iWx <<
", got " << h1tmp1->GetBinContent(iWx + 1) <<
", expected "
2536 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx];
2539 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
2542 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
2556 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2557 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2558 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
2559 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
2560 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
2561 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
2564 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
2567 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
2580 LOG(debug) <<
"WriteHistos: (case 2) update Offsets and keep Gains, "
2581 "Walk and DELTOF for "
2582 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
2583 Int_t iB = iSm * iNbRpc + iRpc;
2584 Double_t dVscal = 1.;
2586 if (dVscal == 0.) dVscal = 1.;
2588 Double_t YMean = ((TProfile*) hAvPos_pfx)->GetBinContent(iB + 1);
2589 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
2591 LOG(debug1) << Form(
"Determine YMean in %s by fit to %d entries", htempPos->GetName(),
2592 (Int_t) htempPos_py->GetEntries());
2597 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
2601 TF1* ff = htempPos_py->GetFunction(
"YBox");
2603 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm << iRpc
2604 <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
2605 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
2606 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
2608 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2611 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2)
2615 YMean = ff->GetParameter(3);
2617 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV);
2624 Double_t TMean = ((TProfile*) hAvTOff_pfx)->GetBinContent(iSm + 1);
2625 Double_t TWidth = ((TProfile*) hAvTOff_pfx)->GetBinError(iSm + 1);
2632 LOG(debug) << Form(
"<ICor> Correct %d %d %d by TMean=%8.2f, "
2633 "TYOff=%8.2f, TWidth=%8.2f, ",
2634 iSmType, iSm, iRpc, TMean, dTYOff, TWidth);
2637 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2639 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
2640 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
2642 LOG(debug) <<
"FillCalHist:"
2643 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean " << YMean
2644 <<
", TMean " << TMean <<
" -> "
2645 << Form(
" %f, %f, %f, %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2646 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
2647 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2648 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2651 htempPos_pfx->Reset();
2652 htempTOff_pfx->Reset();
2653 htempTot_Mean->Reset();
2654 htempTot_Off->Reset();
2655 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2659 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2661 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2662 htempPos_pfx->Fill(iCh, YMean);
2663 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
2664 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
2665 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
2666 <<
", expected " << YMean;
2668 htempTOff_pfx->Fill(iCh, TMean);
2670 for (Int_t iSide = 0; iSide < 2; iSide++) {
2671 htempTot_Mean->SetBinContent(
2672 iCh * 2 + 1 + iSide,
2674 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2678 LOG(debug1) <<
" Updating done ... write to file ";
2679 htempPos_pfx->Write();
2680 htempTOff_pfx->Write();
2682 htempTot_Mean->Write();
2683 htempTot_Off->Write();
2686 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
2688 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2690 TDirectory* curdir = gDirectory;
2692 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
2693 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2694 gDirectory->cd(curdir->GetPath());
2695 if (NULL != hCorDelTof) {
2696 TH1D* hCorDelTofout =
2697 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2698 hCorDelTofout->Write();
2701 LOG(debug) <<
" No CorDelTof histo "
2702 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
2707 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2714 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
2715 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
2716 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
2717 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
2718 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
2719 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
2722 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
2725 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
2736 LOG(info) << Form(
"calMode==3: update Offsets and Gains, keep Walk "
2737 "and DelTof for 0x%08x, ",
2739 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with " << iNbCh <<
" channels "
2740 <<
" using selector " <<
fCalSel;
2747 Double_t dVscal = 1.;
2751 dVscal =
fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
2752 if (dVscal == 0.) dVscal = 1.;
2753 dVW =
fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc + iRpc + 1);
2755 if (dVW < 0.1) dVW = 0.1;
2759 htempPos_py = htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
2760 LOG(info) << Form(
"Inspect histo %s with %d entries", htempPos->GetName(), (Int_t) htempPos_py->GetEntries());
2761 Double_t dYMeanAv = 0.;
2762 Double_t dYMeanFit = 0.;
2764 dYMeanAv = htempPos_py->GetMean();
2765 LOG(debug1) << Form(
"Determine YMeanAv in %s by fit to %d entries", htempPos->GetName(),
2766 (Int_t) htempPos_py->GetEntries());
2771 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
2775 TF1* ff = htempPos_py->GetFunction(
"YBox");
2778 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2) {
2780 LOG(info) <<
"FAvRes YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm << iRpc
2781 <<
", stat: " << gMinuit->fCstatu <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
2782 << Form(
", striplen (%5.2f): %7.2f+/-%5.2f, pos res "
2783 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
2785 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2787 dYMeanFit = ff->GetParameter(3);
2788 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
2789 for (Int_t iPar = 0; iPar < 4; iPar++)
2790 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc), ff->GetParameter(2 + iPar));
2794 LOG(info) <<
"FAvBad YBox " << htempPos_py->GetEntries() <<
" entries in TSR " << iSmType << iSm << iRpc
2795 <<
", chi2 " << ff->GetChisquare()
2797 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
2798 "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
2800 ff->GetParameter(2), ff->GetParError(2), ff->GetParameter(3), ff->GetParError(3));
2804 LOG(info) <<
"FAvFailed for TSR " << iSmType << iSm << iRpc;
2807 Double_t dYShift = dYMeanFit - dYMeanAv;
2810 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2812 Double_t YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
2815 htempPos_py = htempPos->ProjectionY(Form(
"%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
2817 LOG(debug1) << Form(
"Determine YMean in %s of channel %d by fit to %d entries", htempPos->GetName(),
2818 iCh, (Int_t) htempPos_py->GetEntries());
2823 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
2826 Double_t fp[4] = {1., 3 * 0.};
2827 for (Int_t iPar = 2; iPar < 4; iPar++)
2829 fp[iPar] =
fhSmCluFpar[iSmType][iPar]->GetBinContent(iSm * iNbRpc + iRpc + 1);
2832 Double_t* fpp = &fp[0];
2834 TF1* ff = htempPos_py->GetFunction(
"YBox");
2837 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.05)
2841 YMean = ff->GetParameter(3);
2843 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
2844 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm << iRpc
2845 << iCh <<
", chi2 " << ff->GetChisquare()
2846 << Form(
", striplen (%5.2f), %4.2f -> %4.2f, %4.1f: "
2847 "%7.2f+/-%5.2f, pos res %5.2f+/-%5.2f at y_cen "
2850 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
2851 ff->GetParameter(3), ff->GetParError(3));
2852 for (Int_t iPar = 0; iPar < 4; iPar++)
2853 fhSmCluFpar[iSmType][iPar]->Fill((Double_t)(iSm * iNbRpc + iRpc), ff->GetParameter(2 + iPar));
2858 LOG(info) <<
"FBad YBox " << htempPos_py->GetEntries() <<
" entries in " << iSmType << iSm << iRpc
2859 << iCh <<
", chi2 " << ff->GetChisquare()
2860 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
2861 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
2863 2. * ff->GetParError(1), ff->GetParameter(2), ff->GetParError(2),
2864 ff->GetParameter(3), ff->GetParError(3));
2869 Double_t TMean = ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
2880 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
2881 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
2882 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
2884 LOG(info) << Form(
"Calib: TSRC %d%d%d%d, hits %6.0f, dTY %8.3f, TM "
2885 "%8.3f -> new Off %8.3f,%8.3f ",
2886 iSmType, iSm, iRpc, iCh, htempTOff_px->GetBinContent(iCh + 1), dTYOff, TMean,
2887 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2888 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2897 for (Int_t iSide = 0; iSide < 2; iSide++) {
2898 Int_t ib = iCh * 2 + 1 + iSide;
2899 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
2900 if (100 > hbin->GetEntries())
continue;
2902 Int_t iBmax = hbin->GetMaximumBin();
2903 TAxis* xaxis = hbin->GetXaxis();
2904 Double_t Xmax = xaxis->GetBinCenter(iBmax) /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
2907 LOG(warning) <<
"XOff changed for "
2908 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f", iSmType, iSm, iRpc, iSide,
2909 XOff,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2912 Double_t TotMean = hbin->GetMean();
2913 if (15 == iSmType) {
2914 LOG(warning) <<
"Gain for "
2915 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
2916 "gain %f, modg %f ",
2917 iSmType, iSm, iRpc, iSide, TotMean, htempTot_Mean->GetBinContent(ib),
2920 if (0.001 < TotMean) {
2925 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
2926 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) {
2927 LOG(warning) <<
"CbmTofCosmicClusterizer::FillCalHist:"
2928 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
2929 << YMean <<
", TMean " << TMean <<
" -> "
2930 << Form(
" %f %f %f %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2931 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
2932 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
2933 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2936 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2937 Double_t dGain = 0.5
2938 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
2939 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
2940 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
2941 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
2942 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
2943 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
2948 htempPos_pfx->Reset();
2949 htempTOff_pfx->Reset();
2950 htempTot_Mean->Reset();
2951 htempTot_Off->Reset();
2952 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
2956 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2958 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
2959 htempPos_pfx->Fill(iCh, YMean);
2960 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
2961 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
2962 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
2963 <<
", expected " << YMean;
2965 htempTOff_pfx->Fill(iCh, TMean);
2967 for (Int_t iSide = 0; iSide < 2; iSide++) {
2968 htempTot_Mean->SetBinContent(iCh * 2 + 1 + iSide,
2970 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
2976 LOG(debug1) <<
" Updating done ... write to file ";
2977 htempPos_pfx->Write();
2978 htempTOff_pfx->Write();
2980 htempTot_Mean->Write();
2981 htempTot_Off->Write();
2984 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
2986 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2988 TDirectory* curdir = gDirectory;
2990 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
2991 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2992 gDirectory->cd(curdir->GetPath());
2993 if (NULL != hCorDelTof) {
2994 TH1D* hCorDelTofout =
2995 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
2996 hCorDelTofout->Write();
2999 LOG(debug) <<
" No CorDelTof histo "
3000 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3004 LOG(debug) <<
" Store old walk histos to file ";
3006 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3014 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3015 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3016 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3017 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3018 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3019 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3022 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3025 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3035 LOG(debug) <<
"WriteHistos: restore Offsets, Gains and Walk, save DelTof for "
3036 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
3037 htempPos_pfx->Reset();
3038 htempTOff_pfx->Reset();
3039 htempTot_Mean->Reset();
3040 htempTot_Off->Reset();
3041 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3044 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3046 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3047 htempPos_pfx->Fill(iCh, YMean);
3048 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3049 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
3050 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
3051 <<
", expected " << YMean;
3053 htempTOff_pfx->Fill(iCh, TMean);
3055 for (Int_t iSide = 0; iSide < 2; iSide++) {
3056 htempTot_Mean->SetBinContent(
3057 iCh * 2 + 1 + iSide,
3059 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3063 LOG(debug1) <<
" Restoring of Offsets and Gains done ... ";
3064 htempPos_pfx->Write();
3065 htempTOff_pfx->Write();
3067 htempTot_Mean->Write();
3068 htempTot_Off->Write();
3071 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3079 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3080 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3081 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3082 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3083 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3084 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3087 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3090 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3101 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3103 if (NULL == h2tmp) {
3104 LOG(debug) << Form(
"WriteHistos: histo not available for SmT %d, Sm %d, Rpc %d", iSmType, iSm, iRpc);
3107 Int_t iNEntries = h2tmp->GetEntries();
3110 TProfile* htmp = h2tmp->ProfileX(
"_pfx", 1, h2tmp->GetNbinsY());
3111 TH1D* h1tmp = h2tmp->ProjectionX(
"_px", 1, h2tmp->GetNbinsY());
3116 Double_t dNEntries = h1tmp->GetBinContent(iBx + 1);
3118 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] += ((TProfile*) htmp)->GetBinContent(iBx + 1);
3119 dDelMean +=
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel];
3123 LOG(debug) << Form(
" Update DelTof correction for SmT %d, Sm %d, "
3124 "Rpc %d, Sel%d: Entries %d, Mean shift %6.1f",
3125 iSmType, iSm, iRpc, iSel, iNEntries, dDelMean);
3129 h1tmp->SetBinContent(iBx + 1,
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel]);
3131 h1tmp->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3136 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3138 TDirectory* curdir = gDirectory;
3140 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3141 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3142 gDirectory->cd(curdir->GetPath());
3143 if (NULL != hCorDelTof) {
3144 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3145 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3146 LOG(debug) <<
" Save existing CorDelTof histo "
3147 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3148 hCorDelTofout->Write();
3151 LOG(debug) <<
" No CorDelTof histo "
3152 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3162 LOG(info) <<
"WriteHistos (calMode==3): update Offsets and Gains, "
3163 "keep Walk and DelTof for "
3164 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc <<
" with " << iNbCh <<
" channels "
3165 <<
" using selector " <<
fCalSel;
3167 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3169 Double_t YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
3170 Double_t TMean = 0.;
3174 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
3175 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3176 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3178 LOG(debug3) << Form(
"Calib: TSRC %d%d%d%d, hits %6.0f, new Off %8.0f,%8.0f ", iSmType, iSm, iRpc, iCh,
3179 htempTOff_px->GetBinContent(iCh + 1),
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3180 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3189 for (Int_t iSide = 0; iSide < 2; iSide++) {
3190 Int_t ib = iCh * 2 + 1 + iSide;
3191 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
3192 if (100 > hbin->GetEntries())
continue;
3194 Int_t iBmax = hbin->GetMaximumBin();
3195 TAxis* xaxis = hbin->GetXaxis();
3196 Double_t Xmax = xaxis->GetBinCenter(iBmax) /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
3199 LOG(warning) <<
"XOff changed for "
3200 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f", iSmType, iSm, iRpc, iSide, XOff,
3201 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3204 Double_t TotMean = hbin->GetMean();
3205 if (15 == iSmType) {
3206 LOG(warning) <<
"Gain for "
3207 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
3208 "gain %f, modg %f ",
3209 iSmType, iSm, iRpc, iSide, TotMean, htempTot_Mean->GetBinContent(ib),
3212 if (0.001 < TotMean) {
3217 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
3218 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]) {
3219 LOG(warning) <<
"CbmTofCosmicClusterizer::FillCalHist:"
3220 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh <<
": YMean "
3221 << YMean <<
", TMean " << TMean <<
" -> "
3222 << Form(
" %f %f %f %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3223 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
3224 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3225 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3227 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3228 Double_t dGain = 0.5
3229 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
3230 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3231 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
3232 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
3233 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
3234 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
3239 htempPos_pfx->Reset();
3240 htempTOff_pfx->Reset();
3241 htempTot_Mean->Reset();
3242 htempTot_Off->Reset();
3243 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3247 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3249 0.5 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3250 htempPos_pfx->Fill(iCh, YMean);
3251 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3252 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh <<
" got " << htempPos_pfx->GetBinContent(iCh)
3253 <<
"," << htempPos_pfx->GetBinContent(iCh + 1) <<
"," << htempPos_pfx->GetBinContent(iCh + 2)
3254 <<
", expected " << YMean;
3256 htempTOff_pfx->Fill(iCh, TMean);
3258 for (Int_t iSide = 0; iSide < 2; iSide++) {
3259 htempTot_Mean->SetBinContent(iCh * 2 + 1 + iSide,
3261 htempTot_Off->SetBinContent(iCh * 2 + 1 + iSide,
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3267 LOG(debug1) <<
" Updating done ... write to file ";
3268 htempPos_pfx->Write();
3269 htempTOff_pfx->Write();
3271 htempTot_Mean->Write();
3272 htempTot_Off->Write();
3275 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName() <<
" to file ";
3277 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3279 TDirectory* curdir = gDirectory;
3281 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3282 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3283 gDirectory->cd(curdir->GetPath());
3284 if (NULL != hCorDelTof) {
3285 TH1D* hCorDelTofout =
3286 (TH1D*) hCorDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
3287 hCorDelTofout->Write();
3290 LOG(debug) <<
" No CorDelTof histo "
3291 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel);
3295 LOG(debug) <<
" Store old walk histos to file ";
3297 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3305 h1tmp0->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3306 h1tmp1->SetBinContent(iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3307 if (h1tmp0->GetBinContent(iWx + 1) !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3308 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3309 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3310 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3313 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
3316 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
3323 default: LOG(debug) <<
"WriteHistos: update mode " <<
fCalMode <<
" not yet implemented";
3367 for (Int_t iPar = 0; iPar < 4; iPar++)
3370 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3379 gDirectory = oldDir;
3428 gGeoManager->CdTop();
3431 LOG(info) <<
" No CalDigis defined ! Check! ";
3435 LOG(debug) <<
"CbmTofCosmicClusterizer::BuildClusters from " <<
fTofDigisColl->GetEntriesFast() <<
" digis in event "
3442 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
3462 LOG(warning) << Form(
" DigiCor Histo for DetIndx %d derived from 0x%08x not found", iDetIndx,
3470 for (Int_t iDigI2 = 0; iDigI2 < iNbTofDigi; iDigI2++) {
3483 Double_t dTDif = TMath::Abs(pDigi->
GetTime() - pDigi2->
GetTime());
3484 if (dTDif < dTDifMin) {
3492 LOG(debug) << Form(
"Missing digi cor %d for TSRC %d%d%d%d ?",
fiCorMode, (Int_t) pDigi->
GetType(),
3495 for (; iDigI3 < iNbTofDigi; iDigI3++) {
3500 if (iDigI3 == iNbTofDigi)
3507 LOG(debug2) << Form(
"shift channel %d%d%d%d%d and ", (Int_t) pDigi->
GetType(),
3510 << Form(
" %d%d%d%d%d ", (Int_t) pDigi2->
GetType(), (Int_t) pDigi2->
GetSm(),
3521 LOG(debug2) << Form(
"resultchannel %d%d%d%d%d and ", (Int_t) pDigi->
GetType(),
3524 << Form(
" %d%d%d%d%d ", (Int_t) pDigi2->
GetType(), (Int_t) pDigi2->
GetSm(),
3534 LOG(debug) << Form(
"InsertDigi TSRCS %d%d%d%d%d and ", (Int_t) pDigiN->
GetType(),
3542 LOG(debug) << Form(
"InsertDigi2 TSRCS %d%d%d%d%d and ", (Int_t) pDigiN2->
GetType(),
3543 (Int_t) pDigiN2->
GetSm(), (Int_t) pDigiN2->
GetRpc(),
3553 if (pDigi2Min != NULL) {
3559 LOG(warning) << Form(
"BuildClusters: invalid ChannelInfo for 0x%08x", iChId);
3568 LOG(warning) <<
" BuildClusters: Inconsistent duplicated digis in event " <<
fiNevtBuild
3569 <<
", Ind: " << iDigInd;
3570 LOG(warning) <<
" " << pDigi->
ToString();
3571 LOG(warning) <<
" " << pDigi2Min->
ToString();
3602 Int_t iDigIndCal = -1;
3604 std::map<Int_t, Double_t> mChannelDeadTime;
3606 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
3610 LOG(debug1) <<
"BC "
3616 if (pDigi->
GetSide() == 1)
continue;
3618 Bool_t bValid = kTRUE;
3619 std::map<Int_t, Double_t>::iterator it;
3620 it = mChannelDeadTime.find(iAddr);
3621 if (it != mChannelDeadTime.end()) {
3622 LOG(debug1) <<
"CCT found valid ChannelDeadtime entry " << mChannelDeadTime[iAddr] <<
", DeltaT "
3623 << pDigi->
GetTime() - mChannelDeadTime[iAddr];
3625 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
3628 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
3630 mChannelDeadTime[iAddr] = pDigi->
GetTime();
3631 if (!bValid)
continue;
3643 LOG(debug1) <<
"DC "
3653 LOG(debug2) <<
" CluCal-Init: " << pDigi->
ToString();
3658 LOG(debug2) <<
" CluCal-TOff: " << pCalDigi->
ToString();
3660 Double_t dTot = pCalDigi->
GetTot() -
3663 if (dTot < 0.001) dTot = 0.001;
3670 Int_t iWx = (Int_t)((pCalDigi->
GetTot() -
fdTOTMin) / dTotBinSize);
3671 if (0 > iWx) iWx = 0;
3673 Double_t dDTot = (pCalDigi->
GetTot() -
fdTOTMin) / dTotBinSize - (Double_t) iWx - 0.5;
3703 LOG(debug2) <<
" CluCal-Walk: " << pCalDigi->
ToString();
3707 <<
"CbmTofCosmicClusterizer::BuildClusters: CalDigi " << iDigIndCal <<
", T " << pCalDigi->
GetType()
3708 <<
", Sm " << pCalDigi->
GetSm() <<
", R " << pCalDigi->
GetRpc() <<
", Ch " << pCalDigi->
GetChannel()
3709 <<
", S " << pCalDigi->
GetSide() <<
", T " << pCalDigi->
GetTime() <<
", Tot " << pCalDigi->
GetTot()
3716 <<
", Walk " << iWx <<
": "
3721 <<
" dDTot " << dDTot <<
" BinSize: " << dTotBinSize <<
", CPWalk "
3730 <<
" -> dWT = " << dWT;
3734 LOG(info) <<
"Skip1 Digi "
3741 || pCalDigi->
GetType() == 8) {
3753 LOG(debug) <<
"CbmTofCosmicClusterizer::BuildClusters: Sort " <<
fTofCalDigisColl->GetEntriesFast()
3754 <<
" calibrated digis ";
3755 if (iNbTofDigi > 1) {
3758 LOG(warning) <<
"CbmTofCosmicClusterizer::BuildClusters: Sorting not successful ";
3763 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
3765 LOG(debug1) <<
"AC "
3779 .push_back(iDigInd);
3782 LOG(info) <<
"Skip2 Digi "
3827 Double_t dWeightedTime = 0.0;
3828 Double_t dWeightedPosX = 0.0;
3829 Double_t dWeightedPosY = 0.0;
3830 Double_t dWeightedPosZ = 0.0;
3831 Double_t dWeightsSum = 0.0;
3835 Int_t iNbChanInHit = 0;
3837 Int_t iLastChan = -1;
3838 Double_t dLastPosX = 0.0;
3839 Double_t dLastPosY = 0.0;
3840 Double_t dLastTime = 0.0;
3842 Double_t dPosX = 0.0;
3843 Double_t dPosY = 0.0;
3844 Double_t dPosZ = 0.0;
3845 Double_t dTime = 0.0;
3846 Double_t dTimeDif = 0.0;
3847 Double_t dTotS = 0.0;
3850 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
3853 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
3854 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
3857 LOG(debug2) <<
"RPC - Loop " << Form(
" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
3862 dWeightedTime = 0.0;
3863 dWeightedPosX = 0.0;
3864 dWeightedPosY = 0.0;
3865 dWeightedPosZ = 0.0;
3873 LOG(debug2) <<
"ChanOrient "
3882 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3883 LOG(debug3) <<
"VDigisize "
3884 << Form(
" T %3d Sm %3d R %3d Ch %3d Size %3lu ", iSmType, iSm, iRpc, iCh,
3892 while ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetSide()
3893 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetSide()) {
3897 LOG(debug) <<
"SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh <<
", Times: "
3898 << Form(
"%f", (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()) <<
", "
3899 << Form(
"%f", (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime())
3901 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
3902 - (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
3903 <<
", array size: " <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
3904 if (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetSide()
3905 ==
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide()) {
3906 LOG(debug) <<
"3 consecutive SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh
3907 <<
", Times: " << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
3908 <<
", " << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
3910 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
3911 - (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
3912 <<
", array size: " <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
3914 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3916 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3919 if (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
3920 -
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetTime()
3921 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
3922 -
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1]->GetTime()) {
3924 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3926 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3929 LOG(debug) << Form(
"Ev %8.0f, digis not properly time ordered, TSRCS "
3931 fdEvent, iSmType, iSm, iRpc, iCh,
3932 (Int_t)
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide());
3934 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
3936 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
3941 LOG(debug2) <<
"SameSide Erase fStor entries(d) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc
3944 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3946 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
3952 LOG(debug2) <<
"digis processing for "
3953 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ", iSmType, iSm, iRpc, iCh,
3956 LOG(debug) << Form(
"Leaving digi processing for TSRC %d%d%d%d, size %3lu", iSmType, iSm, iRpc, iCh,
3966 LOG(debug1) << Form(
" TSRC %d%d%d%d size %3lu ", iSmType, iSm, iRpc, iCh,
3968 << Form(
" ChId: 0x%08x 0x%08x ", iChId, iUCellId);
3972 LOG(error) <<
"CbmTofCosmicClusterizer::BuildClusters: no "
3974 << Form(
" %3d %3d %3d %3d 0x%08x 0x%08x ", iSmType, iSm, iRpc, iCh, iChId, iUCellId);
3987 LOG(debug2) <<
" " << xDigiA->
ToString();
3988 LOG(debug2) <<
" " << xDigiB->
ToString();
3991 if (5 == iSmType && dTimeDif != 0.) {
3993 LOG(debug) <<
"CbmTofCosmicClusterizer::BuildClusters: "
3995 << iSm <<
" with inconsistent digits " << xDigiA->
GetTime() <<
", " << xDigiB->
GetTime()
3996 <<
" -> " << dTimeDif;
3997 LOG(debug) <<
" " << xDigiA->
ToString();
3998 LOG(debug) <<
" " << xDigiB->
ToString();
4008 &&
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size() > 2) {
4009 LOG(debug) <<
"Hit candidate outside correlation window, check for "
4010 "better possible digis, "
4011 <<
" mul " <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
4014 Double_t dPosYN = 0.;
4015 Double_t dTimeDifN = 0;
4026 if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
4027 LOG(debug) <<
"Replace digi on side " << xDigiC->
GetSide() <<
", yPosNext " << dPosYN
4028 <<
" old: " << dPosY;
4029 dTimeDif = dTimeDifN;
4034 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4036 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4041 ++(
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
4043 ++(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
4049 LOG(fatal) <<
"Wrong combinations of digis " <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4050 <<
"," <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1];
4063 LOG(debug1) <<
"NbChanInHit "
4064 << Form(
" %3d %3d %3d %3d %3d 0x%p %1.0f Time %f PosX %f "
4066 iNbChanInHit, iSmType, iRpc, iCh, iLastChan, xDigiA, xDigiA->
GetSide(), dTime,
4073 if (0 < iNbChanInHit) {
4074 if (iLastChan == iCh - 1) {
4083 if (TMath::Abs(dTime - dLastTime) <
fdMaxTimeDist && iLastChan == iCh - 1
4086 dWeightedTime += dTime * dTotS;
4087 dWeightedPosX += dPosX * dTotS;
4088 dWeightedPosY += dPosY * dTotS;
4089 dWeightedPosZ += dPosZ * dTotS;
4090 dWeightsSum += dTotS;
4096 LOG(debug1) <<
" Add Digi and erase fStor entries(a): NbChanInHit " << iNbChanInHit <<
", "
4097 << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
4100 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4102 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4104 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4106 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4111 dWeightedTime /= dWeightsSum;
4112 dWeightedPosX /= dWeightsSum;
4113 dWeightedPosY /= dWeightsSum;
4114 dWeightedPosZ /= dWeightsSum;
4117 Double_t hitpos_local[3];
4118 hitpos_local[0] = dWeightedPosX;
4119 hitpos_local[1] = dWeightedPosY;
4120 hitpos_local[2] = dWeightedPosZ;
4123 TGeoNode* cNode = gGeoManager->GetCurrentNode();
4124 gGeoManager->GetCurrentMatrix();
4128 gGeoManager->LocalToMaster(hitpos_local, hitpos);
4129 LOG(debug1) << Form(
" LocalToMaster for node %p: "
4130 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
4131 cNode, hitpos_local[0], hitpos_local[1], hitpos_local[2], hitpos[0],
4132 hitpos[1], hitpos[2]);
4134 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
4139 TVector3 hitPosErr(0.5, 0.5, 0.5);
4153 if (iChm < 0) iChm = 0;
4154 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
4158 LOG(debug) <<
"Save Hit "
4159 << Form(
" %3d %3d 0x%08x %3d %3d %3d %f %f",
fiNbHits, iNbChanInHit, iDetId, iChm,
4160 iLastChan, iRefId, dWeightedTime, dWeightedPosY)
4161 <<
", DigiSize: " <<
vDigiIndRef.size() <<
", DigiInds: ";
4171 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits <<
": vDigiIndRef.size()";
4176 LOG(debug) <<
"Store Hit twice? "
4177 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
4181 LOG(debug) <<
" Digi " << pDigiC->
ToString();
4184 for (Int_t i = 0; i < digiMatchL->
GetNofLinks(); i++) {
4188 LOG(debug) <<
" DigiL " << pDigiC->
ToString();
4197 Int_t(dWeightsSum * 10.));
4203 LH_store(iSmType, iSm, iRpc, iChm, pHit);
4221 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
4222 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
4227 dWeightedTime = dTime * dTotS;
4228 dWeightedPosX = dPosX * dTotS;
4229 dWeightedPosY = dPosY * dTotS;
4230 dWeightedPosZ = dPosZ * dTotS;
4231 dWeightsSum = dTotS;
4235 LOG(debug2) <<
" Next fStor Digi " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh
4236 <<
", Dig0 " << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]) <<
", Dig1 "
4237 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4241 LOG(debug2) <<
" Erase fStor entries(b) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch"
4244 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4246 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4248 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4250 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4256 LOG(debug) << Form(
"1.Hit on channel %d, time: %f, PosY %f", iCh, dTime, dPosY);
4259 dWeightedTime = dTime * dTotS;
4260 dWeightedPosX = dPosX * dTotS;
4261 dWeightedPosY = dPosY * dTotS;
4262 dWeightedPosZ = dPosZ * dTotS;
4263 dWeightsSum = dTotS;
4269 LOG(debug2) <<
" Erase fStor entries(c) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch"
4272 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4274 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4276 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4278 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
4285 if (
AddNextChan(iSmType, iSm, iRpc, iLastChan, dLastPosX, dLastPosY, dLastTime, dWeightsSum)) {
4289 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
4290 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
4292 LOG(debug2) <<
"finished V-RPC"
4293 << Form(
" %3d %3d %3d %d %f %fx", iSmType, iSm, iRpc,
fTofHitsColl->GetEntriesFast(),
4294 dLastPosX, dLastPosY);
4298 LOG(error) <<
"=> Cluster building "
4299 <<
"from digis to hits not implemented for pads, Sm type " << iSmType <<
" Rpc " << iRpc;
4305 if (0 < iNbChanInHit) {
4306 LOG(debug1) <<
"Process cluster " << iNbChanInHit;
4310 LOG(debug1) <<
"H-Hit ";
4313 LOG(debug2) <<
"V-Hit ";
4315 dWeightedTime /= dWeightsSum;
4316 dWeightedPosX /= dWeightsSum;
4317 dWeightedPosY /= dWeightsSum;
4318 dWeightedPosZ /= dWeightsSum;
4321 Double_t hitpos_local[3] = {3 * 0.};
4322 hitpos_local[0] = dWeightedPosX;
4323 hitpos_local[1] = dWeightedPosY;
4324 hitpos_local[2] = dWeightedPosZ;
4327 TGeoNode* cNode = gGeoManager->GetCurrentNode();
4328 gGeoManager->GetCurrentMatrix();
4332 gGeoManager->LocalToMaster(hitpos_local, hitpos);
4333 LOG(debug1) << Form(
" LocalToMaster for V-node %p: "
4334 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
4335 cNode, hitpos_local[0], hitpos_local[1], hitpos_local[2], hitpos[0], hitpos[1],
4338 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
4342 TVector3 hitPosErr(0.5, 0.5, 0.5);
4354 if (iChm < 0) iChm = 0;
4355 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
4358 LOG(debug) <<
"Save V-Hit "
4359 << Form(
" %3d %3d 0x%08x %3d 0x%08x",
4360 fiNbHits, iNbChanInHit, iDetId, iLastChan, iRefId)
4363 LOG(debug) <<
", DigiInds: ";
4373 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits <<
": vDigiIndRef.size()";
4378 LOG(debug) <<
"Store Hit twice? "
4379 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
4387 Int_t(dWeightsSum * 10.));
4394 LH_store(iSmType, iSm, iRpc, iChm, pHit);
4413 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
4414 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
4418 LOG(debug2) <<
" Fini-A " << Form(
" %3d %3d %3d M%3d", iSmType, iSm, iRpc,
fviClusterMul[iSmType][iSm][iRpc]);
4420 LOG(debug2) <<
" Fini-B " << Form(
" %3d ", iSmType);
4424 LOG(error) <<
" Compressed Digis not implemented ... ";