780 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
783 fvCPTOff[iSmType].resize(iNbSm * iNbRpc);
786 fvCPWalk[iSmType].resize(iNbSm * iNbRpc);
788 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
789 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
795 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
796 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] = 0.;
800 fvCPTOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
801 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
802 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
803 fvCPWalk[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
805 for (Int_t iCh = 0; iCh < iNbChan; iCh++) {
806 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
807 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
808 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
809 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
810 for (Int_t iSide = 0; iSide < nbSide; iSide++) {
811 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = 0.;
812 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = 1.;
813 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = 0.;
816 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide][iWx] = 0.;
823 LOG(info) <<
"defaults set";
827 TFile* oldFile = gFile;
828 TDirectory* oldDir = gDirectory;
832 LOG(info) <<
"InitCalibParameter: read histos from "
840 LOG(error) <<
"InitCalibParameter: "
842 ChangeState(fair::mq::Transition::Stop);
849 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
852 TProfile*
hSvel = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iSmType));
855 TDirectory* curdir = gDirectory;
857 gDirectory->cd(oldDir->GetPath());
860 gDirectory->cd(curdir->GetPath());
863 LOG(info) <<
"Svel histogram not found for module type " << iSmType;
866 for (Int_t iPar = 0; iPar < 4; iPar++) {
867 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Fpar%1d", iSmType, iPar));
868 if (NULL != hFparcur) {
869 gDirectory->cd(oldDir->GetPath());
872 gDirectory->cd(curdir->GetPath());
876 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
877 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
881 if (Vscal == 0.) Vscal = 1.;
883 LOG(info) <<
"Modify " << iSmType << iSm << iRpc <<
" Svel by " << Vscal <<
" to "
887 (TH2F*) gDirectory->FindObjectAny(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
888 TH2F* htempTOff_pfx =
889 (TH2F*) gDirectory->FindObjectAny(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
890 TH1D* htempTot_Mean =
891 (TH1D*) gDirectory->FindObjectAny(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
893 (TH1D*) gDirectory->FindObjectAny(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
894 if (NULL != htempPos_pfx && NULL != htempTOff_pfx && NULL != htempTot_Mean && NULL != htempTot_Off) {
896 Int_t iNbinTot = htempTot_Mean->GetNbinsX();
897 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
898 Double_t YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
899 Double_t TMean = ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
902 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
903 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
905 for (Int_t iSide = 0; iSide < 2; iSide++) {
906 Double_t TotMean = htempTot_Mean->GetBinContent(iCh * 2 + 1 + iSide);
907 if (0.001 < TotMean) {
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
fdTTotMean / TotMean; }
908 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = htempTot_Off->GetBinContent(iCh * 2 + 1 + iSide);
911 if (5 == iSmType || 8 == iSmType) {
912 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
914 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
917 LOG(debug) <<
"InitCalibParameter:"
918 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc <<
" Ch " << iCh
919 << Form(
": YMean %f, TMean %f", YMean, TMean) <<
" -> "
920 << Form(
" %f, %f, %f, %f ",
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
921 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
924 <<
", NbinTot " << iNbinTot;
925 TH1D* htempWalk0 = (TH1D*) gDirectory->FindObjectAny(
926 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
927 TH1D* htempWalk1 = (TH1D*) gDirectory->FindObjectAny(
928 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
929 if (NULL != htempWalk0 && NULL != htempWalk1) {
930 LOG(debug) <<
"Initialize Walk correction for "
931 << Form(
" SmT%01d_sm%03d_rpc%03d_Ch%03d", iSmType, iSm, iRpc, iCh);
933 LOG(error) <<
"InitCalibParameter: Inconsistent Walk histograms";
935 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin] = htempWalk0->GetBinContent(iBin + 1);
936 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] = htempWalk1->GetBinContent(iBin + 1);
939 if (5 == iSmType || 8 == iSmType) {
940 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
941 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin];
948 LOG(warn) <<
" Calibration histos " << Form(
"cl_SmT%01d_sm%03d_rpc%03d_XXX", iSmType, iSm, iRpc)
951 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
952 TH1D* htmpDelTof = (TH1D*) gDirectory->FindObjectAny(
953 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
954 if (NULL == htmpDelTof) {
955 LOG(debug) <<
" Histos " << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel)
959 LOG(debug) <<
" Load DelTof from histos "
960 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel) <<
".";
962 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] += htmpDelTof->GetBinContent(iBx + 1);
967 gDirectory->cd(oldDir->GetPath());
969 (TH1D*) htmpDelTof->Clone(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSm, iRpc, iSel));
971 LOG(debug) <<
" copy histo " << h1DelTof->GetName() <<
" to directory " << oldDir->GetName();
972 gDirectory->cd(curdir->GetPath());
983 LOG(info) <<
"InitCalibParameter: initialization done";
992 TDirectory* oldir = gDirectory;
995 fhEvDetMul =
new TH1F(
"hEvDetMul",
"Detector multiplicity of Selector; Mul", 50, 0, 50);
996 fhEvDigiMul =
new TH1F(
"hEvDigiMul",
"Digi multiplicity of Selector; Mul", 1000, 0, 10000);
997 fhEvRateIn =
new TH1F(
"hEvRateIn",
"Incoming Event rate; time (s); rate (Hz)", 10000, 0, 10000);
998 fhEvRateOut =
new TH1F(
"hEvRateOut",
"Outgoing Event rate; time (s); rate (Hz)", 10000, 0, 10000);
999 fhPulMul =
new TH1F(
"hPulMul",
"Pulser multiplicity; Mul", 110, 0, 110);
1000 fhDigiTdif =
new TH1F(
"hDigiTdif",
"Digi time difference; #Deltat ns)", 8000, -20, 20);
1005 for (Int_t iModTyp = 0; iModTyp < 10; iModTyp++)
1008 fhPulserTimesRaw =
new TH2F(Form(
"hPulserTimesRaw"), Form(
"Pulser Times uncorrected; Det# []; t - t0 [ns]"),
1009 iNDet * 2, 0, iNDet * 2, 999, -
dTmax,
dTmax);
1012 for (Int_t iDetSide = 0; iDetSide < iNDet * 2; iDetSide++) {
1014 Form(
"hPulserTimeRawEvo_%d", iDetSide),
1015 Form(
"Raw Pulser TimeEvolution %d; PulserEvent# ; DeltaT [ns] ", iDetSide), 1000, 0., 1.E5, -
dTmax,
dTmax);
1018 fhPulserTimesCor =
new TH2F(Form(
"hPulserTimesCor"), Form(
"Pulser Times corrected; Det# []; t - t0 [ns]"), iNDet * 2,
1019 0, iNDet * 2, 999, -10., 10.);
1021 fhDigiTimesRaw =
new TH2F(Form(
"hDigiTimesRaw"), Form(
"Digi Times uncorrected; Det# []; t - t0 [ns]"), iNDet * 2, 0,
1024 fhDigiTimesCor =
new TH2F(Form(
"hDigiTimesCor"), Form(
"Digi Times corrected; Det# []; t - t0 [ns]"), iNDet * 2, 0,
1027 fhBucDigiCor =
new TH2F(Form(
"hBucDigiCor"), Form(
"Buc Digi Correlation; ch1 []; ch2 []"), 128, 0, 128, 128, 0, 128);
1034 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1041 LOG(info) <<
"Index map entry " << iDetIndx <<
": TSR " << iSmType << iSmId << iRpcId
1042 << Form(
", addr 0x%08x", iUniqueId);
1045 Form(
"hDigiTot_SmT%01d_sm%03d_rpc%03d", iSmType, iSmId, iRpcId),
1046 Form(
"Digi Tot of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1", iRpcId, iSmId, iSmType),
1050 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
1051 Form(
"Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1", iRpcId, iSmId, iSmType),
1068 Double_t YSCAL = 50.;
1086 LOG(warn) <<
"No DigiPar for SmType " << Form(
"%d, 0x%08x", iS, iUCellId);
1092 new TH2F(Form(
"cl_SmT%01d_Pos", iS), Form(
"Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
1096 Double_t TSumMax = 1.E3;
1099 new TH2F(Form(
"cl_SmT%01d_TOff", iS), Form(
"Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
1103 TProfile* hSvelcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iS));
1104 if (NULL == hSvelcur) {
1106 new TProfile(Form(
"cl_SmT%01d_Svel", iS), Form(
"Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
1115 for (Int_t iPar = 0; iPar < 4; iPar++) {
1116 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar));
1117 if (NULL == hFparcur) {
1118 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Fpar%1d", iS, iPar) <<
" not found, recreate ...";
1119 fhSmCluFpar[iS][iPar] =
new TProfile(Form(
"cl_SmT%01d_Fpar%1d", iS, iPar),
1120 Form(
"Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
1125 fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
1131 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1132 fhTSmCluPosition[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
1133 Form(
"Clu position of SmType %d under Selector %02d; Sm+Rpc# "
1138 fhTSmCluTOff[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
1139 Form(
"Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
1144 fhTSmCluTRun[iS][iSel] =
new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
1145 Form(
"Clu TimeZero in SmType %d under Selector %02d; Event# "
1153 LOG(info) <<
" Define Clusterizer histos for " << iNbDet <<
" detectors ";
1177 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1185 LOG(warn) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1188 LOG(info) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1189 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx " <<
fChannelInfo->
GetSizex()
1197 if (NULL ==
fChannelInfo) LOG(warn) << Form(
"missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
1203 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
1204 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts", iRpcId, iSmId, iSmType),
1208 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
1209 Form(
"Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType), 3600.,
1212 fhRpcDTLastHits[iDetIndx] =
new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
1213 Form(
"Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
1214 "#DeltaT (ns)); counts",
1215 iRpcId, iSmId, iSmType),
1218 fhRpcDTLastHits_Tot[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1219 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1221 iRpcId, iSmId, iSmType),
1224 fhRpcDTLastHits_CluSize[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1225 Form(
"Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1227 iRpcId, iSmId, iSmType),
1228 100, 0., 10., 16, 0.5, 16.5);
1230 Double_t YSCAL = 50.;
1234 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1235 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]", iRpcId, iSmId, iSmType),
1239 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1240 Form(
"Clu position difference of Rpc #%03d in Sm %03d of type "
1241 "%d; Strip []; #Deltaypos(clu) [cm]",
1242 iRpcId, iSmId, iSmType),
1246 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1247 Form(
"Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1248 "%d; Strip []; #Deltaypos(mat) [cm]",
1249 iRpcId, iSmId, iSmType),
1252 Double_t TSumMax = 1.E3;
1255 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1256 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]", iRpcId, iSmId, iSmType),
1260 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1261 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1262 "[]; #DeltaTOff(clu) [ns]",
1263 iRpcId, iSmId, iSmType),
1267 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1268 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1269 "[]; #DeltaTOff(mat) [ns]",
1270 iRpcId, iSmId, iSmType),
1274 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1275 Form(
"Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]", iRpcId, iSmId, iSmType),
1279 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1280 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [ns]", iRpcId, iSmId, iSmType),
1285 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1286 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]", iRpcId, iSmId, iSmType),
1290 fhRpcCluAvWalk[iDetIndx] =
new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1291 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1295 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1296 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
nbClWalkBinX,
1302 for (Int_t iSide = 0; iSide < 2; iSide++) {
1304 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1305 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk", iSmType, iSmId, iRpcId, iCh, iSide),
1318 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1319 fhSeldT[iSel] =
new TH2F(Form(
"cl_dt_Sel%02d", iSel), Form(
"Selector time %02d; dT [ns]", iSel), 99,
1337 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1345 LOG(warn) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1348 LOG(debug) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1349 <<
" => UniqueId " << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1367 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1369 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul", iSmType, iSmId, iRpcId, iSel),
1370 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1371 "under Selector %02d; M []; cnts",
1372 iRpcId, iSmId, iSmType, iSel),
1375 if (NULL ==
fhTRpcCluMul[iDetIndx][iSel]) LOG(error) <<
" Histo not generated !";
1377 Double_t YSCAL = 50.;
1381 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos", iSmType, iSmId, iRpcId, iSel),
1382 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d under "
1383 "Selector %02d; Strip []; ypos [cm]",
1384 iRpcId, iSmId, iSmType, iSel),
1387 Double_t TSumMax = 1.E4;
1390 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff", iSmType, iSmId, iRpcId, iSel),
1391 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1392 "Selector %02d; Strip []; TOff [ns]",
1393 iRpcId, iSmId, iSmType, iSel),
1398 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot", iSmType, iSmId, iRpcId, iSel),
1399 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1400 "Selector %02d; StripSide []; TOT [ns]",
1401 iRpcId, iSmId, iSmType, iSel),
1406 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size", iSmType, iSmId, iRpcId, iSel),
1407 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1408 "Selector %02d; Strip []; size [strips]",
1409 iRpcId, iSmId, iSmType, iSel),
1414 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk", iSmType, iSmId, iRpcId, iSel),
1415 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel", iSmType, iSmId, iRpcId, iSel),
1420 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof", iSmType, iSmId, iRpcId, iSel),
1421 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; TRef-TSel; T-TSel", iSmType, iSmId, iRpcId, iSel),
1426 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY", iSmType, iSmId, iRpcId, iSel),
1427 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1429 iSmType, iSmId, iRpcId, iSel),
1435 for (Int_t iSide = 0; iSide < 2; iSide++) {
1437 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide, iSel),
1438 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk", iSmType, iSmId, iRpcId, iCh, iSide,
1445 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH", iSmType, iSmId, iRpcId, iSel),
1446 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1447 "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1448 iRpcId, iSmId, iSmType, iSel),
1449 100, 0., 10., 99, -TSumMax, TSumMax);
1452 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH", iSmType, iSmId, iRpcId, iSel),
1453 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1454 "Selector %02d; log(#DeltaT (ns)); TOT [ns]",
1455 iRpcId, iSmId, iSmType, iSel),
1459 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH", iSmType, iSmId, iRpcId, iSel),
1460 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1461 "Selector %02d; log(#DeltaT (ns)); size [strips]",
1462 iRpcId, iSmId, iSmType, iSel),
1463 100, 0., 10., 10, 0.5, 10.5);
1466 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH", iSmType, iSmId, iRpcId, iSel),
1467 Form(
"Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1468 "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1469 iRpcId, iSmId, iSmType, iSel),
1470 100, 0., 10., 10, 0, 10);
1475 gDirectory->cd(oldir->GetPath());
1862 Double_t dWeightedTime = 0.0;
1863 Double_t dWeightedPosX = 0.0;
1864 Double_t dWeightedPosY = 0.0;
1865 Double_t dWeightedPosZ = 0.0;
1866 Double_t dWeightsSum = 0.0;
1871 Int_t iNbChanInHit = 0;
1873 Int_t iLastChan = -1;
1874 Double_t dLastPosX = 0.0;
1875 Double_t dLastPosY = 0.0;
1876 Double_t dLastTime = 0.0;
1878 Double_t dPosX = 0.0;
1879 Double_t dPosY = 0.0;
1880 Double_t dPosZ = 0.0;
1881 Double_t dTime = 0.0;
1882 Double_t dTimeDif = 0.0;
1883 Double_t dTotS = 0.0;
1884 Int_t fiNbSameSide = 0;
1887 gGeoManager->SetTopVolume(gGeoManager->FindVolumeFast(
"cave"));
1888 gGeoManager->CdTop();
1891 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
1894 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
1895 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
1909 dWeightedTime = 0.0;
1910 dWeightedPosX = 0.0;
1911 dWeightedPosY = 0.0;
1912 dWeightedPosZ = 0.0;
1928 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
1932 if (0 ==
fStorDigi[iSmType][iSm * iNbRpc + iRpc].
size())
continue;
1937 while (1 <
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size()) {
1939 while ((
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetSide()
1940 == (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetSide()) {
1943 if (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size() > 2) {
1944 LOG(debug) <<
"SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh <<
", Times: "
1945 << Form(
"%f", (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()) <<
", "
1946 << Form(
"%f", (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime())
1948 << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
1949 - (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
1950 <<
", array size: " <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
1951 if (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetSide()
1952 ==
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide()) {
1953 LOG(debug) <<
"3 consecutive SameSide Digis! on TSRC " << iSmType << iSm << iRpc << iCh
1954 <<
", Times: " << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
1955 <<
", " << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
1957 << (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1])->GetTime()
1958 - (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0])->GetTime()
1959 <<
", array size: " <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
1960 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
1961 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1963 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1966 if (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
1967 -
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetTime()
1968 >
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]->GetTime()
1969 -
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][1]->GetTime()) {
1970 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
1971 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1973 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1976 LOG(debug) << Form(
"Ev %8.0f, digis not properly time ordered, TSRCS "
1978 fdEvent, iSmType, iSm, iRpc, iCh,
1979 (Int_t)
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][0]->GetSide());
1980 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
1981 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
1983 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1);
1988 LOG(debug) <<
"SameSide Erase fStor entries(d) " << iSmType <<
", SR " << iSm * iNbRpc + iRpc
1990 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
1991 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1993 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1995 if (2 >
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size())
break;
1998 LOG(debug) <<
"digis processing for "
1999 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ", iSmType, iSm, iRpc, iCh,
2001 if (2 >
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size()) {
2002 LOG(debug) << Form(
"Leaving digi processing for TSRC %d%d%d%d, size %3lu", iSmType, iSm, iRpc, iCh,
2012 LOG(debug) << Form(
"TSRC %d%d%d%d size %3lu ", iSmType, iSm, iRpc, iCh,
2014 << Form(
" ChId: 0x%08x 0x%08x ", iChId, iUCellId);
2018 LOG(error) <<
"BuildHits: no geometry info! "
2019 << Form(
" %3d %3d %3d %3d 0x%08x 0x%08x ", iSmType, iSm, iRpc, iCh, iChId, iUCellId);
2026 if (NULL == fNode) {
2029 ChangeState(fair::mq::Transition::Stop);
2036 if (5 == iSmType && dTimeDif != 0.) {
2038 LOG(debug) <<
"BuildHits: Diamond hit in " << iSm <<
" with inconsistent digits "
2039 << xDigiA->
GetTime() <<
", " << xDigiB->
GetTime() <<
" -> " << dTimeDif;
2053 &&
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size() > 2) {
2054 LOG(debug) <<
"Hit candidate outside correlation window, check for "
2055 "better possible digis, "
2056 <<
" mul " <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
2059 Double_t dPosYN = 0.;
2060 Double_t dTimeDifN = 0;
2069 if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
2070 LOG(debug) <<
"Replace digi on side " << xDigiC->
GetSide() <<
", yPosNext " << dPosYN
2071 <<
" old: " << dPosY;
2072 dTimeDif = dTimeDifN;
2076 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2077 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2079 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2083 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2084 ++(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
2086 ++(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + 1));
2091 LOG(error) <<
"Wrong combinations of digis " <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]
2092 <<
"," <<
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1];
2115 if (0 < iNbChanInHit) {
2116 if (iLastChan == iCh - 1) {
2128 if (TMath::Abs(dTime - dLastTime) <
fdMaxTimeDist && iLastChan == iCh - 1
2131 dWeightedTime += dTime * dTotS;
2132 dWeightedPosX += dPosX * dTotS;
2133 dWeightedPosY += dPosY * dTotS;
2134 dWeightedPosZ += dPosZ * dTotS;
2135 dWeightsSum += dTotS;
2141 LOG(debug) <<
" Add Digi and erase fStor entries(a): NbChanInHit " << iNbChanInHit <<
", "
2142 << iSmType <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
2144 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2145 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2146 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2147 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2149 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2151 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2156 dWeightedTime /= dWeightsSum;
2157 dWeightedPosX /= dWeightsSum;
2158 dWeightedPosY /= dWeightsSum;
2159 dWeightedPosZ /= dWeightsSum;
2162 Double_t hitpos_local[3];
2163 hitpos_local[0] = dWeightedPosX;
2164 hitpos_local[1] = dWeightedPosY;
2165 hitpos_local[2] = dWeightedPosZ;
2169 gGeoManager->GetCurrentNode();
2170 gGeoManager->GetCurrentMatrix();
2173 gGeoManager->LocalToMaster(hitpos_local, hitpos);
2180 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
2185 TVector3 hitPosErr(0.5, 0.5, 0.5);
2201 if (iChm < 0) iChm = 0;
2202 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
2227 LOG(debug) <<
"Store Hit twice? "
2228 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
2238 Int_t(dWeightsSum * 10.));
2261 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
2262 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
2272 dWeightedTime = dTime * dTotS;
2273 dWeightedPosX = dPosX * dTotS;
2274 dWeightedPosY = dPosY * dTotS;
2275 dWeightedPosZ = dPosZ * dTotS;
2276 dWeightsSum = dTotS;
2286 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2287 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2288 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2289 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2291 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2293 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2297 LOG(debug) << Form(
"1.Hit on channel %d, time: %f, PosY %f", iCh, dTime, dPosY);
2300 dWeightedTime = dTime * dTotS;
2301 dWeightedPosX = dPosX * dTotS;
2302 dWeightedPosY = dPosY * dTotS;
2303 dWeightedPosZ = dPosZ * dTotS;
2304 dWeightsSum = dTotS;
2314 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2315 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2316 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
2317 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2319 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2321 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
2328 if (
AddNextChan(iSmType, iSm, iRpc, iLastChan, dLastPosX, dLastPosY, dLastTime, dWeightsSum)) {
2332 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
2333 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
2340 LOG(error) <<
"=> Cluster building "
2341 <<
"from digis to hits not implemented for pads, Sm type " << iSmType <<
" Rpc " << iRpc;
2347 if (0 < iNbChanInHit) {
2359 dWeightedTime /= dWeightsSum;
2360 dWeightedPosX /= dWeightsSum;
2361 dWeightedPosY /= dWeightsSum;
2362 dWeightedPosZ /= dWeightsSum;
2365 Double_t hitpos_local[3] = {3 * 0.};
2366 hitpos_local[0] = dWeightedPosX;
2367 hitpos_local[1] = dWeightedPosY;
2368 hitpos_local[2] = dWeightedPosZ;
2372 gGeoManager->GetCurrentNode();
2373 gGeoManager->GetCurrentMatrix();
2377 gGeoManager->LocalToMaster(hitpos_local, hitpos);
2385 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
2389 TVector3 hitPosErr(0.5, 0.5, 0.5);
2396 if (iChm < 0) iChm = 0;
2397 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
2418 LOG(debug) <<
"Store Hit twice? "
2419 <<
" fiNbHits " <<
fiNbHits <<
", " << Form(
"0x%08x", iDetId);
2428 Int_t(dWeightsSum * 10.));
2452 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
2453 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
2590 Double_t dLastPosY, Double_t dLastTime, Double_t dLastTotS)
2597 Int_t iCh = iLastChan + 1;
2598 LOG(debug) << Form(
"Inspect channel TSRC %d%d%d%d at time %f, pos %f, size ", iSmType, iSm, iRpc, iCh, dLastTime,
2600 <<
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size();
2601 if (iCh == iNbCh)
return kFALSE;
2602 if (0 ==
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size())
return kFALSE;
2605 if (1 <
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size()) {
2606 Bool_t AddedHit = kFALSE;
2607 for (Int_t i1 = 0; i1 < (Int_t)
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].size() - 1; i1++) {
2608 if (AddedHit)
break;
2610 while (!AddedHit && i2 < (Int_t)
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].
size()) {
2613 if ((
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][i1])->GetSide()
2614 == (
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][i2])->GetSide()) {
2629 Double_t dPosY = 0.;
2636 Double_t dNClHits = (Double_t)(
vDigiIndRef.size() / 2);
2639 Double_t dNewTotS = (dLastTotS + dTotS);
2640 dLastPosX = (dLastPosX * dLastTotS + dPosX * dTotS) / dNewTotS;
2641 dLastPosY = (dLastPosY * dLastTotS + dPosY * dTotS) / dNewTotS;
2642 dLastTime = (dLastTime * dLastTotS + dTime * dTotS) / dNewTotS;
2643 dLastTotS = dNewTotS;
2645 Int_t Ind1 =
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i1];
2646 Int_t Ind2 =
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i2];
2650 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin()
2653 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
2655 std::vector<int>::iterator it;
2656 it = find(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin(),
2657 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].end(), Ind2);
2658 if (it !=
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].end()) {
2659 auto ipos = it -
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin();
2660 LOG(debug) <<
"Found i2 " << i2 <<
" with Ind2 " << Ind2 <<
" at position " << ipos;
2661 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh].begin()
2664 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
2667 LOG(error) <<
" Did not find i2 " << i2 <<
" with Ind2 " << Ind2;
2671 if (iCh != (iNbCh - 1)
2672 &&
AddNextChan(iSmType, iSm, iRpc, iCh, dLastPosX, dLastPosY, dLastTime, dLastTotS)) {
2673 LOG(debug) <<
"Added Strip " << iCh <<
" to cluster of size " << dNClHits;
2683 Double_t hitpos_local[3] = {3 * 0.};
2684 hitpos_local[0] = dLastPosX;
2685 hitpos_local[1] = dLastPosY;
2686 hitpos_local[2] = 0.;
2689 TGeoNode* cNode = gGeoManager->GetCurrentNode();
2690 if (NULL == cNode) {
2693 ChangeState(fair::mq::Transition::Stop);
2696 gGeoManager->GetCurrentMatrix();
2697 gGeoManager->LocalToMaster(hitpos_local, hitpos);
2698 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
2699 TVector3 hitPosErr(0.5, 0.5, 0.5);
2701 if (iChm < 0) iChm = 0;
2702 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
2722 Int_t(dLastTotS * 10.));
2726 LH_store(iSmType, iSm, iRpc, iChm, pHit);
2732 for (Int_t i = 0; i < (Int_t)
vDigiIndRef.size(); i++) {
3058 gGeoManager->CdTop();
3060 if (0 < iNbTofHits) {
3062 Double_t dTTrig[
iNSel];
3064 Double_t ddXdZ[
iNSel];
3065 Double_t ddYdZ[
iNSel];
3066 Double_t dSel2dXdYMin[
iNSel];
3068 Int_t iBeamRefMul = 0;
3069 Int_t iBeamAddRefMul = 0;
3073 LOG(debug) <<
"FillHistos() for " <<
iNSel <<
" triggers"
3085 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
3096 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
3098 if (NULL == pHit)
continue;
3104 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
3106 Int_t iDetIndx = it->second;
3118 LOG(error) << Form(
" <E> hit not stored in memory for TSRC %d%d%d%d", iSmType, iSm, iRpc, iCh);
3129 LOG(warn) << Form(
"Invalid time ordering in ev %8.0f in list of "
3130 "size %lu for TSRC %d%d%d%d: Delta t %f ",
3136 LOG(debug) <<
" pop from list size " <<
fvLastHits[iSmType][iSm][iRpc][iCh].size()
3137 << Form(
" outdated hits for ev %8.0f in TSRC %d%d%d%d",
fdEvent, iSmType, iSm, iRpc, iCh)
3138 << Form(
" with tHit - tLast %f ",
3143 LOG(error) << Form(
"Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
3145 fvLastHits[iSmType][iSm][iRpc][iCh].
size(), iSmType, iSm, iRpc, iCh,
3146 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
3147 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
3148 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
3149 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
3156 Double_t dTotSum = 0.;
3157 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
3160 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
3166 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
3168 for (UInt_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
3181 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
3183 if (NULL == pHit)
continue;
3190 Double_t TotSum = 0.;
3191 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
3196 TotSum += pDig0->
GetTot();
3210 LOG(debug) <<
"FillHistos: BRefMul: " << iBeamRefMul <<
", " << iBeamAddRefMul;
3211 if (iBeamRefMul == 0)
return kFALSE;
3214 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3215 BSel[iSel] = kFALSE;
3223 dSel2dXdYMin[iSel] = 1.E300;
3232 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
3235 <<
", BRefMul " << iBeamRefMul <<
" TRef: " <<
dTRef <<
", BeamAddRefMul " << iBeamAddRefMul
3240 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
3242 if (NULL == pHit)
continue;
3249 if (pHit->
GetTime() < dTTrig[iSel]) {
3250 dTTrig[iSel] = pHit->
GetTime();
3256 LOG(debug) << Form(
"Found selector 0 with mul %d from 0x%08x at %f ", iDutMul, pTrig[iSel]->GetAddress(),
3267 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
3270 << iRefMul <<
", BRefMul " << iBeamRefMul;
3274 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
3276 if (NULL == pHit)
continue;
3280 if (pHit->
GetTime() < dTTrig[iSel]) {
3281 dTTrig[iSel] = pHit->
GetTime();
3287 LOG(debug) << Form(
"Found selector 1 with mul %d from 0x%08x at %f ", iRefMul, pTrig[iSel]->GetAddress(),
3292 default: LOG(info) <<
"FillHistos: selection not implemented " << iSel; ;
3298 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3300 BSel[iSel] = kFALSE;
3303 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
3305 if (NULL == pHit)
continue;
3308 Double_t dzscal = 1.;
3310 Double_t dSEl2dXdz = (pHit->
GetX() - pTrig[iSel]->GetX()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
3311 Double_t dSEl2dYdz = (pHit->
GetY() - pTrig[iSel]->GetY()) / (pHit->
GetZ() - pTrig[iSel]->GetZ());
3313 if (TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
3314 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
3317 Double_t dX2Y2 = TMath::Sqrt(dSEl2dXdz * dSEl2dXdz + dSEl2dYdz * dSEl2dYdz);
3318 if (dX2Y2 < dSel2dXdYMin[iSel]) {
3319 ddXdZ[iSel] = dSEl2dXdz;
3320 ddYdZ[iSel] = dSEl2dYdz;
3321 dSel2dXdYMin[iSel] = dX2Y2;
3330 UInt_t uTriggerPattern = 1;
3332 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
3337 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3340 for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
3341 if (uTriggerPattern & (0x1 << uChannel)) {
fhSeldT[iSel]->Fill(dTTrig[iSel] -
dTRef, uChannel); }
3348 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
3350 if (NULL == pHit)
continue;
3353 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
3355 Int_t iDetIndx = it->second;
3362 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
3365 if (w == 0.) w = 1.;
3373 if (iBeamRefMul == 0)
break;
3379 LOG(error) <<
"Invalid Channel Pointer for ChId " << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
3391 hitpos[0] = pHit->
GetX();
3392 hitpos[1] = pHit->
GetY();
3393 hitpos[2] = pHit->
GetZ();
3394 Double_t hitpos_local[3];
3396 gGeoManager->GetCurrentNode();
3397 gGeoManager->MasterToLocal(hitpos, hitpos_local);
3406 fhSmCluPosition[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
3408 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
3412 fhTSmCluPosition[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), hitpos_local[1]);
3422 LOG(error) <<
" Inconsistent DigiMatches for Hitind " << iHitInd
3433 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
3437 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
3439 for (UInt_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
3447 Double_t TotSum = 0.;
3448 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink++) {
3453 TotSum += pDig0->
GetTot();
3456 Double_t dMeanTimeSquared = 0.;
3457 Double_t dNstrips = 0.;
3459 Double_t dDelTof = 0.;
3460 Double_t dTcor[
iNSel];
3461 Double_t dTTcor[
iNSel];
3462 Double_t dZsign[
iNSel];
3463 Double_t dzscal = 1.;
3466 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks(); iLink += 2) {
3469 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
3475 if ((Int_t) pDig0->
GetType() != iSmType) {
3476 LOG(error) << Form(
" Wrong Digi SmType for Tofhit %d in iDetIndx "
3477 "%d, Ch %d with %3.0f strips at Indx %d, %d",
3478 iHitInd, iDetIndx, iCh, dNstrips, iDigInd0, iDigInd1);
3494 if (iCh0 != iCh1 || iS0 == iS1) {
3495 LOG(error) << Form(
" MT2 for Tofhit %d in iDetIndx %d, Ch %d from %3.0f strips: ", iHitInd, iDetIndx, iCh,
3497 << Form(
" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd0, iCh0, iS0, pDig0->
GetTime())
3498 << Form(
" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ", iDigInd1, iCh1, iS1, pDig1->
GetTime());
3503 LOG(error) << Form(
" Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
3504 "from %3.0f strips: %d, %d, %d, %d",
3505 iHitInd, iDetIndx, iCh, iDigInd0, iDigInd1, dNstrips, iCh0, iCh1, iS0, iS1);
3518 Double_t dTotWeigth = (pDig0->
GetTot() + pDig1->
GetTot()) / TotSum;
3519 Double_t dCorWeigth = 1. - dTotWeigth;
3525 if (0 == pDig0->
GetSide()) dDelPos *= -1.;
3541 - (1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
3545 - (1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
3555 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
3557 if (NULL == pHit || NULL == pTrig[iSel]) {
3558 LOG(info) <<
" invalid pHit, iSel " << iSel <<
", iDetIndx " << iDetIndx;
3566 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
3568 for (UInt_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
3579 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY());
3581 if (pHit->
GetZ() < pTrig[iSel]->
GetZ()) dZsign[iSel] = -1.;
3586 || TMath::Sqrt(TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
3587 + TMath::Power(pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
3591 TMath::Power(pHit->
GetX()
3592 - (pTrig[iSel]->
GetX() + ddXdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
3594 + TMath::Power(pHit->
GetY()
3595 - (pTrig[iSel]->
GetY() + ddYdZ[iSel] * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
3615 if (iBx < 0) iBx = 0;
3618 Double_t dDTentry = dTentry - ((Double_t) iBx) * dBinWidth;
3620 dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
3621 Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
3622 Double_t w1 = 1. - w0;
3623 if (iBx1 < 0) iBx1 = 0;
3625 dDelTof =
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
3626 +
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel] * w1;
3634 dTTcor[iSel] = dDelTof * dZsign[iSel];
3635 dTcor[iSel] = pHit->
GetTime() - dDelTof - dTTrig[iSel];
3639 LOG(debug) << Form(
" TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
3640 "Ch %d,%d, S %d,%d T %f, DelTof %6.1f, W-ent: %6.0f,%6.0f",
3642 iCh0, iCh1, iS0, iS1, dTTrig[iSel], dDelTof,
3648 LOG(error) << Form(
" Inconsistent walk histograms -> debugging "
3649 "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
3650 fiNevtBuild, iDetIndx, iSel, iCh0, iCh1, iS0, iS1);
3684 fhTSmCluTOff[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc), dTcor[iSel]);
3687 != (pTrig[iSel]->GetAddress()
3691 hitpos[2] = pHit->
GetZ();
3692 gGeoManager->MasterToLocal(hitpos, hitpos_local);
3695 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
3703 LOG(error) <<
"FillHistos: invalid digi index " << iDetIndx <<
" digi0,1" << iDigInd0 <<
", " << iDigInd1
3711 Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
3713 Double_t dTrms = TMath::Sqrt(dVar);
3714 LOG(debug) << Form(
" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
3715 "%3.0f strips: %6.3f ns",
3716 iHitInd, iDetIndx, iCh, dNstrips, dTrms);
3727 if (TMath::Abs(hitpos_local[1]) < (
fhRpcCluPosition[iDetIndx]->GetYaxis()->GetXmax())) {
3732 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
3742 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
3744 for (UInt_t iH = 0; iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1; iH++) {
3755 std::list<CbmTofHit*>::iterator itL =
fvLastHits[iSmType][iSm][iRpc][iCh].end();
3757 for (Int_t iH = 0; iH < 1; iH++) {
3760 Double_t dTsinceLast = pHit->
GetTime() - (*itL)->GetTime();
3762 LOG(error) << Form(
"Invalid Time since last hit on channel "
3763 "TSRC %d%d%d%d: %f > %f",
3767 pHit->
GetTime() - dTTrig[iSel]);