21 #include "CbmTofHit.h"
30 #include "FairLogger.h"
31 #include "FairRootManager.h"
32 #include "FairRunAna.h"
33 #include "FairRuntimeDb.h"
36 #include "TClonesArray.h"
37 #include "TDirectory.h"
40 #include "TGeoManager.h"
76 Bool_t writeDataInOut)
77 : FairTask(TString(name), verbose)
84 , fTofPointsColl(NULL)
87 , fbWriteHitsInOut(writeDataInOut)
88 , fbWriteDigisInOut(writeDataInOut)
89 , fTofCalDigisColl(NULL)
91 , fTofDigiMatchColl(NULL)
104 , fhClustBuildTime(NULL)
105 , fhHitsPerTracks(NULL)
107 , fhTimeResSingHits(NULL)
108 , fhTimeResSingHitsB(NULL)
109 , fhTimePtVsHits(NULL)
110 , fhClusterSize(NULL)
111 , fhClusterSizeType(NULL)
113 , fhClusterSizeMulti(NULL)
115 , fhHiTrkMulPos(NULL)
116 , fhAllTrkMulPos(NULL)
117 , fhMultiTrkProbPos(NULL)
118 , fhDigSpacDifClust(NULL)
119 , fhDigTimeDifClust(NULL)
120 , fhDigDistClust(NULL)
121 , fhClustSizeDifX(NULL)
122 , fhClustSizeDifY(NULL)
125 , fhCluMulCorDutSel(NULL)
131 , fhRpcCluDelMatPos()
134 , fhRpcCluDelMatTOff()
146 , fhRpcDTLastHits_Tot()
147 , fhRpcDTLastHits_CluSize()
149 , fhTRpcCluPosition()
160 , fhTRpcCluTOffDTLastHits()
161 , fhTRpcCluTotDTLastHits()
162 , fhTRpcCluSizeDTLastHits()
163 , fhTRpcCluMemMulDTLastHits()
173 , fhNbDigiPerChan(NULL)
214 , fdChannelDeadtime(0.)
217 , fEnableMatchPosScaling(kTRUE)
218 , fEnableAvWalk(kFALSE)
220 , fCalParFileName(
"")
221 , fOutHstFileName(
"")
231 , fbSwapChannelSides(kFALSE)
232 , fiOutputTreeEntry(0)
234 , fbAlternativeBranchNames(kFALSE) {
248 <<
"CbmTofTestBeamClusterizer initializing... expect Digis in ns units! ";
274 LOG(info) <<
"=> Get the digi parameters for tof";
275 LOG(warning) <<
"Return without action";
278 FairRunAna* ana = FairRunAna::Instance();
279 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
321 LOG(debug) <<
"CbmTofTestBeamClusterizer::Exec => New event";
352 FairRootManager* fManager = FairRootManager::Instance();
354 if (NULL == fManager) {
355 LOG(error) <<
"CbmTofTestBeamClusterizer::RegisterInputs => Could not find "
356 "FairRootManager!!!";
376 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"CbmTofDigi");
379 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"CbmTofDigi");
382 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"TofDigiExp");
385 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"TofDigi");
388 LOG(error) <<
"CbmTofTestBeamClusterizer::RegisterInputs => Could not get "
389 "the CbmTofDigi TClonesArray!!!";
396 LOG(info) <<
"CbmTofTestBeamClusterizer::RegisterInputs => Could not get "
397 "the TofTrbHeader Object";
403 FairRootManager*
rootMgr = FairRootManager::Instance();
408 rootMgr->Register(
"TofCalDigi",
412 && IsOutputBranchPersistent(
"TofCalDigi"));
417 TString tHitBranchName;
418 TString tHitDigiMatchBranchName;
421 tHitBranchName =
"ATofHit";
422 tHitDigiMatchBranchName =
"ATofDigiMatch";
424 tHitBranchName =
"TofHit";
425 tHitDigiMatchBranchName =
"TofDigiMatch";
429 rootMgr->Register(tHitBranchName,
433 && IsOutputBranchPersistent(tHitBranchName));
436 rootMgr->Register(tHitDigiMatchBranchName,
440 && IsOutputBranchPersistent(tHitDigiMatchBranchName));
447 Bool_t isSimulation = kFALSE;
449 <<
"CbmTofTestBeamClusterizer::InitParameters - Geometry, Mapping, ... ??";
452 FairRun* ana = FairRun::Instance();
453 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
456 if (
k14a > iGeoVersion) {
457 LOG(error) <<
"CbmTofTestBeamClusterizer::InitParameters => Only "
458 "compatible with geometries after v14a !!!";
465 LOG(error) <<
"CbmTofTestBeamClusterizer::InitParameters => Could not "
466 "obtain the CbmTofDigiPar ";
472 LOG(error) <<
"CbmTofTestBeamClusterizer::InitParameters => Could not "
473 "obtain the CbmTofDigiBdfPar ";
477 rtdb->initContainers(ana->GetRunId());
479 LOG(info) <<
"CbmTofTestBeamClusterizer::InitParameter: currently "
493 LOG(info) <<
" BuildCluster with MaxTimeDist " <<
fdMaxTimeDist
532 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
535 fvCPTOff[iSmType].resize(iNbSm * iNbRpc);
538 fvCPWalk[iSmType].resize(iNbSm * iNbRpc);
540 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
541 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
548 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
549 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] =
554 fvCPTOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
555 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
556 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
557 fvCPWalk[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
559 for (Int_t iCh = 0; iCh < iNbChan; iCh++) {
560 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
561 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
562 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
563 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
564 for (Int_t iSide = 0; iSide < nbSide; iSide++) {
565 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
567 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
569 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
571 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide].resize(
574 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide][iWx] = 0.;
582 LOG(info) <<
"CbmTofTestBeamClusterizer::InitCalibParameter: defaults set";
592 <<
"CbmTofTestBeamClusterizer::InitCalibParameter: read histos from "
600 LOG(fatal) <<
"CbmTofTestBeamClusterizer::InitCalibParameter: "
609 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
613 (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iSmType));
616 TDirectory* curdir = gDirectory;
618 gDirectory->cd(oldir->GetPath());
620 gDirectory->cd(curdir->GetPath());
622 LOG(info) <<
"Svel histogram not found for module type " << iSmType;
625 for (Int_t iPar = 0; iPar < 4; iPar++) {
626 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(
627 Form(
"cl_SmT%01d_Fpar%1d", iSmType, iPar));
628 if (NULL != hFparcur) {
629 gDirectory->cd(oldir->GetPath());
631 gDirectory->cd(curdir->GetPath());
635 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
636 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
640 if (Vscal == 0.) Vscal = 1.;
646 LOG(info) <<
"Modify " << iSmType << iSm << iRpc <<
" Svel by "
650 TH2F* htempPos_pfx = (TH2F*) gDirectory->FindObjectAny(
651 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
652 TH2F* htempTOff_pfx = (TH2F*) gDirectory->FindObjectAny(
653 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
654 TH1D* htempTot_Mean = (TH1D*) gDirectory->FindObjectAny(
655 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
656 TH1D* htempTot_Off = (TH1D*) gDirectory->FindObjectAny(
657 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
658 if (NULL != htempPos_pfx && NULL != htempTOff_pfx
659 && NULL != htempTot_Mean && NULL != htempTot_Off) {
661 Int_t iNbinTot = htempTot_Mean->GetNbinsX();
662 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
663 Double_t YMean = ((TProfile*) htempPos_pfx)
664 ->GetBinContent(iCh + 1);
666 ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
670 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
671 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
673 for (Int_t iSide = 0; iSide < 2; iSide++) {
674 Double_t TotMean = htempTot_Mean->GetBinContent(
675 iCh * 2 + 1 + iSide);
676 if (0.001 < TotMean) {
677 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
680 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
681 htempTot_Off->GetBinContent(iCh * 2 + 1 + iSide);
684 if (5 == iSmType || 8 == iSmType) {
685 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
686 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
687 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
689 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
690 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
693 LOG(debug) <<
"CbmTofTestBeamClusterizer::InitCalibParameter:"
694 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc "
695 << iRpc <<
" Ch " << iCh
696 << Form(
": YMean %f, TMean %f", YMean, TMean) <<
" -> "
699 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
700 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
703 <<
", NbinTot " << iNbinTot;
705 TH1D* htempWalk0 = (TH1D*) gDirectory->FindObjectAny(
706 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
711 TH1D* htempWalk1 = (TH1D*) gDirectory->FindObjectAny(
712 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
717 if (NULL != htempWalk0
718 && NULL != htempWalk1) {
719 LOG(debug) <<
"Initialize Walk correction for "
720 << Form(
" SmT%01d_sm%03d_rpc%03d_Ch%03d",
726 LOG(error) <<
"CbmTofTestBeamClusterizer::InitCalibParameter:"
727 " Inconsistent Walk histograms";
729 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin] =
730 htempWalk0->GetBinContent(iBin + 1);
731 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
732 htempWalk1->GetBinContent(iBin + 1);
734 " SmT%01d_sm%03d_rpc%03d_Ch%03d bin %d walk %f ",
740 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin]);
741 if (5 == iSmType || 8 == iSmType) {
742 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
743 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin];
749 LOG(warning) <<
" Calibration histos "
750 << Form(
"cl_SmT%01d_sm%03d_rpc%03d_XXX",
756 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
757 TH1D* htmpDelTof = (TH1D*) gDirectory->FindObjectAny(
758 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
763 if (NULL == htmpDelTof) {
764 LOG(debug) <<
" Histos "
765 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
773 LOG(debug) <<
" Load DelTof from histos "
774 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
781 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] +=
782 htmpDelTof->GetBinContent(iBx + 1);
787 gDirectory->cd(oldir->GetPath());
788 TH1D* h1DelTof = (TH1D*) htmpDelTof->Clone(
789 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
795 LOG(debug) <<
" copy histo " << h1DelTof->GetName()
796 <<
" to directory " << oldir->GetName();
798 gDirectory->cd(curdir->GetPath());
808 <<
"CbmTofTestBeamClusterizer::InitCalibParameter: initialization done";
813 LOG(info) <<
"CbmTofTestBeamClusterizer::LoadGeometry starting for "
820 LOG(info) <<
"Digi Parameter container contains " << iNrOfCells <<
" cells.";
821 for (Int_t icell = 0; icell < iNrOfCells; ++icell) {
837 LOG(debug) <<
"-I- InitPar " << icell <<
" Id: " << Form(
"0x%08x", cellId)
838 <<
" " << cell <<
" tmcs: " << smtype <<
" " << smodule <<
" "
839 << module <<
" " << cell <<
" x=" << Form(
"%6.2f",
x)
840 <<
" y=" << Form(
"%6.2f",
y) <<
" z=" << Form(
"%6.2f", z)
841 <<
" dx=" << dx <<
" dy=" << dy;
844 gGeoManager->FindNode(
846 LOG(debug2) << Form(
" Node at (%6.1f,%6.1f,%6.1f) : 0x%p",
855 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
860 LOG(info) <<
" DetIndx " << iDetIndx <<
"(" << iNbDet <<
"), SmType "
861 << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
862 <<
" => UniqueId " << Form(
"0x%08x ", iUniqueId)
863 << Form(
" Svel %6.6f ",
871 LOG(debug3) <<
" Cell " << iCell << Form(
" 0x%08x ", iUCellId)
888 fvdX.resize(iNbSmTypes);
889 fvdY.resize(iNbSmTypes);
896 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
903 fvdX[iSmType].resize(iNbRpc);
904 fvdY[iSmType].resize(iNbRpc);
905 fvdDifX[iSmType].resize(iNbRpc);
906 fvdDifY[iSmType].resize(iNbRpc);
908 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
911 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
916 LOG(warning) <<
"CbmTofTestBeamClusterizer::LoadGeometry: "
917 "StoreDigi without channels "
918 << Form(
"SmTy %3d, Sm %3d, NbRpc %3d, Rpc, %3d ",
925 <<
"CbmTofTestBeamClusterizer::LoadGeometry: StoreDigi with "
927 " %3d %3d %3d %3d %5d ", iSmType, iSm, iNbRpc, iRpc, iNbChan);
928 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
929 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
930 fvLastHits[iSmType][iSm][iRpc].resize(iNbChan);
938 LOG(info) <<
"CbmTofTestBeamClusterizer::DeleteGeometry starting";
942 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
945 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
946 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
967 new TH1I(
"TofTestBeamClus_ClustBuildTime",
968 "Time needed to build clusters in each event; Time [s]",
985 Double_t YSCAL = 50.;
1001 "Channel info for module type %d obtained from counter: %d-%d-%d",
1011 LOG(warning) <<
"No DigiPar for SmType "
1012 << Form(
"%d, 0x%08x", iS, iUCellId);
1018 new TH2F(Form(
"cl_SmT%01d_Pos", iS),
1019 Form(
"Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
1027 Double_t TSumMax = 1.E3;
1030 new TH2F(Form(
"cl_SmT%01d_TOff", iS),
1031 Form(
"Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
1039 TProfile* hSvelcur =
1040 (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iS));
1041 if (NULL == hSvelcur) {
1043 Form(
"cl_SmT%01d_Svel", iS),
1044 Form(
"Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
1055 for (Int_t iPar = 0; iPar < 4; iPar++) {
1056 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(
1057 Form(
"cl_SmT%01d_Fpar%1d", iS, iPar));
1058 if (NULL == hFparcur) {
1059 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Fpar%1d", iS, iPar)
1060 <<
" not found, recreate ...";
1062 Form(
"cl_SmT%01d_Fpar%1d", iS, iPar),
1063 Form(
"Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
1070 fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
1076 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1078 new TH2F(Form(
"cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
1079 Form(
"Clu position of SmType %d under Selector %02d; Sm+Rpc# "
1090 new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
1091 Form(
"Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
1102 new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
1103 Form(
"Clu TimeZero in SmType %d under Selector %02d; Event# "
1118 LOG(info) <<
" Define Clusterizer histos for " << iNbDet <<
" detectors ";
1145 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1157 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1160 LOG(info) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId "
1161 << iSmId <<
", RpcId " << iRpcId <<
" => UniqueId "
1162 << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1173 LOG(warning) << Form(
1174 "missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
1179 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
1181 "Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1",
1193 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
1194 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts",
1203 Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
1204 Form(
"Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)",
1213 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
1214 Form(
"Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
1215 "#DeltaT (ns)); counts",
1224 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1225 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1238 Form(
"cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1239 Form(
"Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1251 Double_t YSCAL = 50.;
1255 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1257 "Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]",
1269 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1270 Form(
"Clu position difference of Rpc #%03d in Sm %03d of type "
1271 "%d; Strip []; #Deltaypos(clu) [cm]",
1283 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1284 Form(
"Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1285 "%d; Strip []; #Deltaypos(mat) [cm]",
1296 Double_t TSumMax = 1.E3;
1299 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1301 "Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]",
1313 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1314 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1315 "[]; #DeltaTOff(clu) [ns]",
1327 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1328 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1329 "[]; #DeltaTOff(mat) [ns]",
1341 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1343 "Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]",
1355 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1356 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [ns]",
1368 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1370 "Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]",
1383 Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1384 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1393 Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1394 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1405 for (Int_t iSide = 0; iSide < 2; iSide++) {
1407 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
1413 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
1434 LOG(info) <<
" Define Clusterizer monitoring histos ";
1437 new TH2F(Form(
"hCluMulCorDutSel"),
1438 Form(
"Cluster Multiplicity Correlation of Dut %d%d%d with Sel "
1439 "%d%d%d; Mul(Sel); Mul(Dut)",
1454 new TH1I(
"Clus_DigSpacDifClust",
1455 "Space difference along channel direction between Digi pairs on "
1456 "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
1461 new TH1I(
"Clus_DigTimeDifClust",
1462 "Time difference between Digi pairs on adjacent channels; "
1463 "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1468 "Clus_DigDistClust",
1469 "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
1470 "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1478 new TH2I(
"Clus_ClustSizeDifX",
1479 "Position difference between Point and Hit as function of Cluster "
1480 "Size; Cluster Size [Strips]; dX [cm]",
1488 new TH2I(
"Clus_ClustSizeDifY",
1489 "Position difference between Point and Hit as function of Cluster "
1490 "Size; Cluster Size [Strips]; dY [cm]",
1498 "Position difference between Point and Hit as "
1499 "function of Channel dif; Ch Dif [Strips]; dX [cm]",
1507 "Position difference between Point and Hit as "
1508 "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1516 "How many time per event the 2 digis on a channel "
1517 "were of the same side ; Counts/Event []",
1522 "Nb of Digis per channel; Nb Digis []",
1531 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1532 fhSeldT[iSel] =
new TH2F(Form(
"cl_dt_Sel%02d", iSel),
1533 Form(
"Selector time %02d; dT [ns]", iSel),
1556 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1565 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1568 LOG(debug1) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType
1569 <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1571 << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1591 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1593 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul",
1598 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1599 "under Selector %02d; M []; cnts",
1609 LOG(fatal) <<
" Histo not generated !";
1611 Double_t YSCAL = 50.;
1615 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos",
1620 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d under "
1621 "Selector %02d; Strip []; ypos [cm]",
1633 Double_t TSumMax = 1.E4;
1636 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff",
1641 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1642 "Selector %02d; Strip []; TOff [ns]",
1656 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot",
1661 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1662 "Selector %02d; StripSide []; TOT [ns]",
1675 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size",
1680 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1681 "Selector %02d; Strip []; size [strips]",
1695 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk",
1700 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel",
1714 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
1719 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; TRef-TSel; T-TSel",
1733 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY",
1738 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1756 for (Int_t iSide = 0; iSide < 2; iSide++) {
1758 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk",
1765 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk",
1782 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH",
1787 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1788 "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1801 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH",
1806 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1807 "Selector %02d; log(#DeltaT (ns)); TOT [ns]",
1820 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH",
1825 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1826 "Selector %02d; log(#DeltaT (ns)); size [strips]",
1839 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH",
1844 Form(
"Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1845 "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1861 new TH1I(
"Clus_TofHitPerTrk",
1862 "Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []",
1868 "Distribution of the Number of MCPoints associated "
1869 "to each TofHit; Nb MCPoint []",
1875 new TH1I(
"Clus_TofTimeResClust",
1876 "Time resolution for TofHits containing Digis from a single MC "
1877 "Track; t(1st Mc Point) -tTofHit [ns]",
1882 new TH2I(
"Clus_TofTimeResClustB",
1883 "Time resolution for TofHits containing Digis from a single MC "
1884 "Track; (1st Mc Point) -tTofHit [ns]",
1892 new TH2I(
"Clus_TofTimePtVsHit",
1893 "Time resolution for TofHits containing Digis from a single MC "
1894 "Track; t(1st Mc Point) -tTofHit [ns]",
1903 new TH1I(
"Clus_TofTimeResClust",
1904 "Time resolution for TofHits containing Digis from a single "
1905 "TofPoint; tMcPoint -tTofHit [ns]",
1910 new TH2I(
"Clus_TofTimeResClustB",
1911 "Time resolution for TofHits containing Digis from a single "
1912 "TofPoint; tMcPoint -tTofHit [ns]",
1920 "Time resolution for TofHits containing Digis "
1921 "from a single TofPoint; tMcPoint -tTofHit [ps]",
1930 "Cluster Size distribution; Cluster Size [Strips]",
1935 new TH2I(
"Clus_ClusterSizeType",
1936 "Cluster Size distribution in each (SM type, Rpc) pair; Cluster "
1937 "Size [Strips]; 10*SM Type + Rpc Index []",
1947 "Number of MC tracks generating the cluster; MC Tracks multiplicity []",
1952 "Clus_ClusterSizeMulti",
1953 "Cluster Size distribution as function of Number of MC tracks generating "
1954 "the cluster; Cluster Size [Strips]; MC tracks mul. []",
1962 "Position of Clusters with only 1 MC tracks "
1963 "generating the cluster; X [cm]; Y [cm]",
1971 "Position of Clusters with >1 MC tracks "
1972 "generating the cluster; X [cm]; Y [cm]",
1980 "Clus_AllTrkMulPos",
1981 "Position of all clusters generating the cluster; X [cm]; Y [cm]",
1989 new TH2D(
"Clus_MultiTrkProbPos",
1990 "Probability of having a cluster with multiple tracks as "
1991 "function of position; X [cm]; Y [cm]; Prob. [%]",
2009 + (
fStop.GetNanoSec() -
fStart.GetNanoSec()) / 1e9);
2013 gGeoManager->CdTop();
2015 if (0 < iNbTofHits) {
2018 Double_t dTTrig[
iNSel];
2020 Double_t ddXdZ[
iNSel];
2021 Double_t ddYdZ[
iNSel];
2022 Double_t dSel2dXdYMin[
iNSel];
2024 Int_t iBeamRefMul = 0;
2025 Int_t iBeamAddRefMul = 0;
2029 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos() for " <<
iNSel
2036 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos: Muls: "
2041 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
2056 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2058 if (NULL == pHit)
continue;
2066 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
2069 Int_t iDetIndx = it->second;
2078 <<
", " << dTimeAna;
2082 &&
fvLastHits[iSmType][iSm][iRpc][iCh].size() == 0)
2083 LOG(fatal) << Form(
" <E> hit not stored in memory for TSRC %d%d%d%d",
2091 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2100 LOG(warning) << Form(
"Invalid time ordering in ev %8.0f in list of "
2101 "size %lu for TSRC %d%d%d%d: Delta t %f ",
2111 while (
fvLastHits[iSmType][iSm][iRpc][iCh].size() > 2.
2112 ||
fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime()
2118 <<
" pop from list size "
2119 <<
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2120 << Form(
" outdated hits for ev %8.0f in TSRC %d%d%d%d",
2127 " with tHit - tLast %f ",
2129 -
fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime())
2135 "Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
2143 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
2144 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
2145 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
2150 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2153 Double_t dTotSum = 0.;
2154 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2158 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
2164 std::list<CbmTofHit*>::iterator itL =
2168 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2172 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()));
2174 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2177 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()), dTotSum);
2186 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2188 if (NULL == pHit)
continue;
2197 Double_t TotSum = 0.;
2198 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2202 if (iDigInd0 < fTofCalDigisColl->GetEntries()) {
2205 TotSum += pDig0->
GetTot();
2220 LOG(debug) <<
"CbmTofTestBeamClusterizer::FillHistos: BRefMul: "
2221 << iBeamRefMul <<
", " << iBeamAddRefMul;
2223 if (iBeamRefMul == 0)
2228 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2229 BSel[iSel] = kFALSE;
2237 dSel2dXdYMin[iSel] = 1.E300;
2243 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2246 <<
"CbmTofTestBeamClusterizer::FillHistos(): selector 0: DutMul "
2248 <<
", BRefMul " << iBeamRefMul <<
" TRef: " <<
dTRef
2249 <<
", BeamAddRefMul " << iBeamAddRefMul <<
", "
2253 <<
"CbmTofTestBeamClusterizer::FillHistos(): Found selector 0";
2255 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2257 if (NULL == pHit)
continue;
2262 if (pHit->
GetTime() < dTTrig[iSel]) {
2263 dTTrig[iSel] = pHit->
GetTime();
2270 "Found selector 0 with mul %d from 0x%08x at %f ",
2280 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2283 <<
"CbmTofTestBeamClusterizer::FillHistos(): selector 1: RefMul "
2285 <<
", BRefMul " << iBeamRefMul;
2288 <<
"CbmTofTestBeamClusterizer::FillHistos(): Found selector 1";
2290 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2292 if (NULL == pHit)
continue;
2296 if (pHit->
GetTime() < dTTrig[iSel]) {
2297 dTTrig[iSel] = pHit->
GetTime();
2304 "Found selector 1 with mul %d from 0x%08x at %f ",
2312 LOG(info) <<
"CbmTofTestBeamClusterizer::FillHistos: selection not "
2321 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2323 BSel[iSel] = kFALSE;
2326 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2328 if (NULL == pHit)
continue;
2331 Double_t dzscal = 1.;
2333 dzscal = pHit->
GetZ() / pTrig[iSel]->
GetZ();
2334 Double_t dSEl2dXdz = (pHit->
GetX() - pTrig[iSel]->
GetX())
2335 / (pHit->
GetZ() - pTrig[iSel]->
GetZ());
2336 Double_t dSEl2dYdz = (pHit->
GetY() - pTrig[iSel]->
GetY())
2337 / (pHit->
GetZ() - pTrig[iSel]->
GetZ());
2341 pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(), 2.)
2343 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2346 Double_t dX2Y2 = TMath::Sqrt(dSEl2dXdz * dSEl2dXdz
2347 + dSEl2dYdz * dSEl2dYdz);
2348 if (dX2Y2 < dSel2dXdYMin[iSel]) {
2349 ddXdZ[iSel] = dSEl2dXdz;
2350 ddYdZ[iSel] = dSEl2dYdz;
2351 dSel2dXdYMin[iSel] = dX2Y2;
2395 UInt_t uTriggerPattern = 1;
2399 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2407 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2410 for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
2411 if (uTriggerPattern & (0x1 << uChannel)) {
2420 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2422 if (NULL == pHit)
continue;
2425 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
2428 Int_t iDetIndx = it->second;
2435 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2449 if (iBeamRefMul == 0)
break;
2455 LOG(error) <<
"Invalid Channel Pointer for ChId "
2456 << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
2460 gGeoManager->FindNode(
2463 LOG(debug1) <<
"Hit info: "
2464 << Form(
" 0x%08x %d %f %f %f %f %f %d",
2475 hitpos[0] = pHit->
GetX();
2476 hitpos[1] = pHit->
GetY();
2477 hitpos[2] = pHit->
GetZ();
2478 Double_t hitpos_local[3];
2479 TGeoNode* cNode = gGeoManager->GetCurrentNode();
2480 gGeoManager->MasterToLocal(hitpos, hitpos_local);
2481 LOG(debug1) << Form(
2482 " MasterToLocal for node %p: (%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
2492 (Double_t) iCh, hitpos_local[1]);
2496 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2507 LOG(debug1) <<
" TofDigiMatchColl entries:"
2511 LOG(error) <<
" Inconsistent DigiMatches for Hitind " << iHitInd
2516 LOG(debug1) <<
" got " << digiMatch->
GetNofLinks() <<
" matches for iCh "
2517 << iCh <<
" at iHitInd " << iHitInd;
2522 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2526 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2528 std::list<CbmTofHit*>::iterator itL =
2532 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2536 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2542 Double_t TotSum = 0.;
2543 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2547 if (iDigInd0 < fTofCalDigisColl->GetEntries()) {
2549 TotSum += pDig0->
GetTot();
2552 Double_t dMeanTimeSquared = 0.;
2553 Double_t dNstrips = 0.;
2555 Double_t dDelTof = 0.;
2556 Double_t dTcor[
iNSel];
2557 Double_t dTTcor[
iNSel];
2558 Double_t dZsign[
iNSel];
2559 Double_t dzscal = 1.;
2562 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2567 (digiMatch->
GetLink(iLink + 1)).GetIndex();
2570 if (iDigInd0 < fTofCalDigisColl->GetEntries()
2574 if ((Int_t) pDig0->
GetType() != iSmType) {
2575 LOG(error) << Form(
" Wrong Digi SmType for Tofhit %d in iDetIndx "
2576 "%d, Ch %d with %3.0f strips at Indx %d, %d",
2584 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch "
2587 << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
2588 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side "
2589 << pDig1->
GetSide() <<
", StripSide "
2590 << (Double_t) iCh * 2. + pDig1->
GetSide() <<
", Tot0 "
2602 if (iCh0 != iCh1 || iS0 == iS1) {
2604 " MT2 for Tofhit %d in iDetIndx %d, Ch %d from %3.0f strips: ",
2609 << Form(
" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ",
2614 << Form(
" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ",
2624 " Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
2625 "from %3.0f strips: %d, %d, %d, %d",
2644 dMeanTimeSquared += TMath::Power(
2650 TMath::Log10(0.5 * (pDig0->
GetTot() + pDig1->
GetTot())),
2653 Double_t dTotWeigth = (pDig0->
GetTot() + pDig1->
GetTot()) / TotSum;
2654 Double_t dCorWeigth = 1. - dTotWeigth;
2664 if (0 == pDig0->
GetSide()) dDelPos *= -1.;
2666 pDig0->
GetChannel(), dCorWeigth * (dDelPos - hitpos_local[1]));
2672 - (1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
2679 - (1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
2686 - (1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
2692 - (1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
2696 LOG(debug1) <<
" fhTRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch "
2699 << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
2700 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side "
2701 << pDig1->
GetSide() <<
", StripSide "
2702 << (Double_t) iCh * 2. + pDig1->
GetSide();
2704 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2706 if (NULL == pHit || NULL == pTrig[iSel]) {
2707 LOG(info) <<
" invalid pHit, iSel " << iSel <<
", iDetIndx "
2717 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2719 std::list<CbmTofHit*>::iterator itL =
2723 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2727 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2730 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2736 dzscal = pHit->
GetZ() / pTrig[iSel]->
GetZ();
2738 pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(),
2739 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY());
2741 if (pHit->
GetZ() < pTrig[iSel]->
GetZ()) dZsign[iSel] = -1.;
2747 TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(),
2750 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2756 - (pTrig[iSel]->
GetX()
2758 * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2762 - (pTrig[iSel]->
GetY()
2764 * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2771 && TMath::Abs(
dTRef - dTTrig[iSel])
2789 if (iBx < 0) iBx = 0;
2793 dTentry - ((Double_t) iBx) * dBinWidth;
2795 dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
2796 Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
2797 Double_t w1 = 1. - w0;
2798 if (iBx1 < 0) iBx1 = 0;
2801 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
2802 +
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel]
2806 << Form(
" DelTof for SmT %d, Sm %d, R %d, T %d, dTRef "
2807 "%6.1f, Bx %d, Bx1 %d, DTe %6.1f -> DelT %6.1f",
2812 dTRef - dTTrig[iSel],
2818 dTTcor[iSel] = dDelTof * dZsign[iSel];
2819 dTcor[iSel] = pHit->
GetTime() - dDelTof - dTTrig[iSel];
2824 " TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
2825 "Ch %d,%d, S %d,%d T %f, DelTof %6.1f, W-ent: %6.0f,%6.0f",
2845 << Form(
" Inconsistent walk histograms -> debugging "
2846 "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
2855 LOG(debug1) << Form(
2856 " TRpcCluWalk values side %d: %f, %f, side %d: %f, %f ",
2860 + ((1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
2862 - dTTcor[iSel] - dTTrig[iSel],
2866 + ((1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
2868 - dTTcor[iSel] - dTTrig[iSel]);
2897 (Double_t)(iSm * iNbRpc + iRpc), dTcor[iSel]);
2903 hitpos[0] = pHit->
GetX() - dzscal * pTrig[iSel]->
GetX()
2905 hitpos[1] = pHit->
GetY() - dzscal * pTrig[iSel]->
GetY()
2907 hitpos[2] = pHit->
GetZ();
2908 gGeoManager->MasterToLocal(
2909 hitpos, hitpos_local);
2914 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
2922 <<
"CbmTofTestBeamClusterizer::FillHistos: invalid digi index "
2923 << iDetIndx <<
" digi0,1" << iDigInd0 <<
", " << iDigInd1
2932 Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
2934 Double_t dTrms = TMath::Sqrt(dVar);
2935 LOG(debug) << Form(
" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
2936 "%3.0f strips: %6.3f ns",
2946 LOG(debug1) <<
" Fill Time of iDetIndx " << iDetIndx <<
", hitAddr "
2948 " %08x, y = %5.2f", pHit->
GetAddress(), hitpos_local[1])
2951 if (TMath::Abs(hitpos_local[1])
2955 fhSmCluTOff[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc),
2958 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2960 LOG(debug1) <<
" TRpcCluTOff " << iDetIndx <<
", Sel " << iSel
2961 << Form(
", Dt %7.3f, LHsize %lu ",
2962 pHit->
GetTime() - dTTrig[iSel],
2966 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2968 std::list<CbmTofHit*>::iterator itL =
2972 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2976 << Form(
" %f,", pHit->
GetTime() - (*itL)->GetTime());
2985 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2987 std::list<CbmTofHit*>::iterator itL =
2990 for (Int_t iH = 0; iH < 1; iH++) {
2993 Double_t dTsinceLast = pHit->
GetTime() - (*itL)->GetTime();
2995 LOG(fatal) << Form(
"Invalid Time since last hit on channel "
2996 "TSRC %d%d%d%d: %f > %f",
3005 TMath::Log10(dTsinceLast), pHit->
GetTime() - dTTrig[iSel]);
3007 TMath::Log10(dTsinceLast),
3008 fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1);
3018 LOG(debug1) <<
"CbmTofTestBeamClusterizer::FillHistos: "
3019 << Form(
" %3d %3d %3lu ",
3024 for (UInt_t uCluster = 0;
3027 LOG(debug2) <<
"CbmTofTestBeamClusterizer::FillHistos: "
3028 << Form(
" %3d %3d %3d ", iSmType, iRpc, uCluster);
3038 if (1 ==
fviTrkMul[iSmType][iRpc][uCluster])
3040 fvdY[iSmType][iRpc][uCluster]);
3041 if (1 <
fviTrkMul[iSmType][iRpc][uCluster])
3043 fvdY[iSmType][iRpc][uCluster]);
3045 fvdY[iSmType][iRpc][uCluster]);
3050 fvdDifX[iSmType][iRpc][uCluster]);
3052 fvdDifY[iSmType][iRpc][uCluster]);
3055 fvdDifX[iSmType][iRpc][uCluster]);
3057 fvdDifY[iSmType][iRpc][uCluster]);
3063 fvdX[iSmType][iRpc].clear();
3064 fvdY[iSmType][iRpc].clear();
3065 fvdDifX[iSmType][iRpc].clear();
3066 fvdDifY[iSmType][iRpc].clear();
3077 TDirectory* oldir = gDirectory;
3099 LOG(debug) <<
"Write triggered Histos for Det Ind " << iDetIndx
3101 for (Int_t iSel = 0; iSel <
iNSel;
3112 Int_t iSmAddr = iUniqueId &
DetMask;
3126 LOG(info) <<
"WriteHistos: No entries in Walk histos for "
3127 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
3132 TH2* htempPos = NULL;
3133 TProfile* htempPos_pfx = NULL;
3134 TH1* htempPos_py = NULL;
3135 TProfile* htempTOff_pfx = NULL;
3136 TH1* htempTOff_px = NULL;
3137 TProfile* hAvPos_pfx = NULL;
3138 TProfile* hAvTOff_pfx = NULL;
3141 TH2* htempTot = NULL;
3142 TProfile* htempTot_pfx = NULL;
3143 TH1* htempTot_Mean = NULL;
3144 TH1* htempTot_Off = NULL;
3156 htempTOff_pfx = htempTOff->ProfileX(
3158 htempTOff_px = htempTOff->ProjectionX(
3210 if (NULL == htempPos_pfx) {
3211 LOG(info) <<
"WriteHistos: Projections not available, continue ";
3215 htempTot_Mean = htempTot_pfx->ProjectionX(
"_Mean");
3216 htempTot_Off = htempTot_pfx->ProjectionX(
"_Off");
3218 htempPos_pfx->SetName(
3219 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
3220 htempTOff_pfx->SetName(
3221 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
3222 htempTot_pfx->SetName(
3223 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
3224 htempTot_Mean->SetName(
3225 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
3226 htempTot_Off->SetName(
3227 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
3228 hAvPos_pfx->SetName(Form(
"cl_CorSmT%01d_Pos_pfx", iSmType));
3229 hAvTOff_pfx->SetName(Form(
"cl_CorSmT%01d_TOff_pfx", iSmType));
3233 htempTot_Off->Reset();
3235 Int_t nbins = htempTot->GetNbinsX();
3236 for (
int i = 0;
i < nbins;
i++) {
3237 hbins[
i] = htempTot->ProjectionY(Form(
"bin%d",
i + 1),
i + 1,
i + 1);
3239 Int_t iBmax = hbins[
i]->GetMaximumBin();
3240 TAxis* xaxis = hbins[
i]->GetXaxis();
3241 Double_t Xmax = xaxis->GetBinCenter(iBmax);
3243 XOff = (Double_t)(Int_t) XOff;
3244 if (XOff < 0) XOff = 0;
3245 htempTot_Off->SetBinContent(
i + 1, XOff);
3246 Double_t Xmean = htempTot_Mean->GetBinContent(
i + 1);
3248 LOG(warning) <<
"Inconsistent Tot numbers for "
3250 "SmT%01d_sm%03d_rpc%03d bin%d: mean %f, Off %f",
3258 htempTot_Mean->SetBinContent(
i + 1, (Xmean - XOff));
3259 if (htempTot_Mean->GetBinContent(
i + 1) != (Xmean - XOff))
3261 <<
"Tot numbers not stored properly for "
3262 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, target %f",
3267 htempTot_Mean->GetBinContent(
i + 1),
3270 htempPos_pfx->Write();
3271 htempTOff_pfx->Write();
3273 htempTot_Mean->Write();
3274 htempTot_Off->Write();
3281 <<
"WriteHistos: restore Offsets and Gains and save Walk for "
3282 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3283 <<
" and calSmAddr = " << Form(
" 0x%08x ", TMath::Abs(
fCalSmAddr));
3284 htempPos_pfx->Reset();
3285 htempTOff_pfx->Reset();
3286 htempTot_Mean->Reset();
3287 htempTot_Off->Reset();
3288 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3290 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3291 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3292 Double_t TMean = 0.5
3293 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3294 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3295 htempPos_pfx->Fill(iCh, YMean);
3296 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3297 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
3298 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
3299 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
3300 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
3303 htempTOff_pfx->Fill(iCh, TMean);
3305 for (Int_t iSide = 0; iSide < 2; iSide++) {
3306 htempTot_Mean->SetBinContent(
3307 iCh * 2 + 1 + iSide,
3311 htempTot_Off->SetBinContent(
3312 iCh * 2 + 1 + iSide,
3313 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3317 LOG(debug1) <<
" Offset, gain restoring done ... ";
3318 htempPos_pfx->Write();
3319 htempTOff_pfx->Write();
3321 htempTot_Mean->Write();
3322 htempTot_Off->Write();
3324 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3326 TDirectory* curdir = gDirectory;
3328 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3329 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3334 gDirectory->cd(curdir->GetPath());
3335 if (NULL != hCorDelTof) {
3336 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3337 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3342 hCorDelTofout->Write();
3344 LOG(debug) <<
" No CorDelTof histo "
3345 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3360 <<
"WriteHistos: restore Offsets and Gains and update Walk for "
3361 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3384 if (NULL == h2tmp0) {
3385 LOG(debug) << Form(
"WriteHistos: Walk histo not available for "
3386 "SmT %d, Sm %d, Rpc %d, Ch %d",
3393 Int_t iNEntries = h2tmp0->GetEntries();
3395 LOG(debug) << Form(
" Update Walk correction for SmT %d, Sm %d, "
3396 "Rpc %d, Ch %d, Sel%d: Entries %d",
3406 if (-1 < iNEntries) {
3408 h2tmp0->ProfileX(
"_pfx", 1, h2tmp0->GetNbinsY());
3410 h2tmp1->ProfileX(
"_pfx", 1, h2tmp1->GetNbinsY());
3411 TH1D* h1tmp0 = h2tmp0->ProjectionX(
"_px", 1, h2tmp0->GetNbinsY());
3412 TH1D* h1tmp1 = h2tmp1->ProjectionX(
"_px", 1, h2tmp1->GetNbinsY());
3415 TH1D* h1ytmp1 = h2tmp1->ProjectionY(
"_py", 1,
nbClWalkBinX);
3416 Double_t dWMean0 = h1ytmp0->GetMean();
3417 Double_t dWMean1 = h1ytmp1->GetMean();
3418 Double_t dWMean = 0.5 * (dWMean0 + dWMean1);
3421 if (5 == iSmType || 8 == iSmType)
3427 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin
3428 && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3431 (((TProfile*) htmp0)->GetBinContent(iWx + 1)
3432 + ((TProfile*) htmp1)->GetBinContent(iWx + 1))
3434 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3436 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3441 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin
3442 && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3444 ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3446 ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3447 Double_t dWcor = 0.5 * (dWcor0 + dWcor1);
3448 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3450 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3453 if (iCh == 10 && iSmType == 9 && iSm == 1
3454 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
3456 <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc
3457 <<
"), Rpc " << iRpc <<
", Bin " << iWx <<
", "
3458 << h1tmp0->GetBinContent(iWx + 1) <<
" cts: "
3459 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]
3461 << ((TProfile*) htmp0)->GetBinContent(iWx + 1)
3462 <<
" - " << dWMean0 <<
" -> " << dWcor - dWMean0
3464 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
3466 << ((TProfile*) htmp1)->GetBinContent(iWx + 1)
3467 <<
" - " << dWMean1 <<
" -> " << dWcor - dWMean1;
3471 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin
3472 && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3474 ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3476 ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3478 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3480 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3491 h1tmp0->SetBinContent(
3492 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3493 h1tmp1->SetBinContent(
3494 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3498 && h1tmp0->GetBinContent(iWx + 1)
3499 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3500 h1tmp0->SetBinContent(
3502 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3506 <<
"writing not successful for " << h1tmp0->GetName()
3507 <<
", attempts left: " << iTry <<
", iWx " << iWx
3508 <<
", got " << h1tmp0->GetBinContent(iWx + 1)
3510 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3514 && h1tmp1->GetBinContent(iWx + 1)
3515 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]) {
3516 h1tmp1->SetBinContent(
3518 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3522 <<
"writing not successful for " << h1tmp1->GetName()
3523 <<
", attempts left: " << iTry <<
", iWx " << iWx
3524 <<
", got " << h1tmp1->GetBinContent(iWx + 1)
3526 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx];
3530 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3538 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3553 TH1D* h1tmp0 =
fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX(
3555 TH1D* h1tmp1 =
fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX(
3558 h1tmp0->SetBinContent(
3559 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3560 h1tmp1->SetBinContent(
3561 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3562 if (h1tmp0->GetBinContent(iWx + 1)
3563 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3565 <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3566 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3567 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3570 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3577 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3596 LOG(debug) <<
"WriteHistos: (case 2) update Offsets and keep Gains, "
3597 "Walk and DELTOF for "
3598 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc "
3600 Int_t iB = iSm * iNbRpc + iRpc;
3601 Double_t dVscal = 1.;
3604 fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3605 if (dVscal == 0.) dVscal = 1.;
3607 Double_t YMean = ((TProfile*) hAvPos_pfx)
3608 ->GetBinContent(iB + 1);
3610 htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
3612 LOG(debug1) << Form(
"Determine YMean in %s by fit to %d entries",
3613 htempPos->GetName(),
3614 (Int_t) htempPos_py->GetEntries());
3620 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3624 TF1* ff = htempPos_py->GetFunction(
"YBox");
3626 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries()
3627 <<
" entries in TSR " << iSmType << iSm << iRpc
3628 <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
3630 ", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3631 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3634 2. * ff->GetParameter(1),
3635 2. * ff->GetParError(1),
3636 ff->GetParameter(2),
3638 ff->GetParameter(3),
3639 ff->GetParError(3));
3642 - 2. * ff->GetParameter(1))
3645 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2)
3648 if (TMath::Abs(ff->GetParameter(3) - YMean)
3650 YMean = ff->GetParameter(3);
3652 / (2. * ff->GetParameter(1));
3653 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc),
3660 Double_t TMean = ((TProfile*) hAvTOff_pfx)->GetBinContent(iB + 1);
3661 Double_t TWidth = ((TProfile*) hAvTOff_pfx)->GetBinError(iB + 1);
3669 LOG(debug) << Form(
"<ICor> Correct %d %d %d by TMean=%8.2f, "
3670 "TYOff=%8.2f, TWidth=%8.2f, ",
3679 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3681 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3682 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3684 LOG(debug) <<
"FillCalHist:"
3685 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc
3686 <<
" Ch " << iCh <<
": YMean " << YMean <<
", TMean "
3690 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3691 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
3692 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3693 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3696 htempPos_pfx->Reset();
3697 htempTOff_pfx->Reset();
3698 htempTot_Mean->Reset();
3699 htempTot_Off->Reset();
3700 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3703 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3704 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3705 Double_t TMean = 0.5
3706 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3707 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3708 htempPos_pfx->Fill(iCh, YMean);
3709 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3710 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
3711 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
3712 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
3713 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
3716 htempTOff_pfx->Fill(iCh, TMean);
3718 for (Int_t iSide = 0; iSide < 2; iSide++) {
3719 htempTot_Mean->SetBinContent(
3720 iCh * 2 + 1 + iSide,
3724 htempTot_Off->SetBinContent(
3725 iCh * 2 + 1 + iSide,
3726 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3730 LOG(debug1) <<
" Updating done ... write to file ";
3731 htempPos_pfx->Write();
3732 htempTOff_pfx->Write();
3734 htempTot_Mean->Write();
3735 htempTot_Off->Write();
3738 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName()
3741 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3743 TDirectory* curdir = gDirectory;
3745 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3746 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3751 gDirectory->cd(curdir->GetPath());
3752 if (NULL != hCorDelTof) {
3753 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3754 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3759 hCorDelTofout->Write();
3761 LOG(debug) <<
" No CorDelTof histo "
3762 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3771 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3780 h1tmp0->SetBinContent(
3781 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3782 h1tmp1->SetBinContent(
3783 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3784 if (h1tmp0->GetBinContent(iWx + 1)
3785 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3786 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
3787 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
3789 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3792 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3799 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3816 LOG(info) <<
"WriteHistos (calMode==3): update Offsets and Gains, "
3817 "keep Walk and DelTof for "
3818 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3819 <<
" with " << iNbCh <<
" channels "
3820 <<
" using selector " <<
fCalSel;
3827 Double_t dVscal = 1.;
3832 fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3833 if (dVscal == 0.) dVscal = 1.;
3834 dVW =
fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc
3837 if (dVW < 0.1) dVW = 0.1;
3842 htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
3843 Double_t dYMeanAv = 0.;
3844 Double_t dYMeanFit = 0.;
3846 dYMeanAv = htempPos_py->GetMean();
3847 LOG(debug1) << Form(
"Determine YMeanAv in %s by fit to %d entries",
3848 htempPos->GetName(),
3849 (Int_t) htempPos_py->GetEntries());
3855 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3859 TF1* ff = htempPos_py->GetFunction(
"YBox");
3862 - 2. * ff->GetParameter(1))
3865 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1))
3868 / (2. * ff->GetParameter(1));
3869 LOG(info) <<
"FAvRes YBox " << htempPos_py->GetEntries()
3870 <<
" entries in TSR " << iSmType << iSm << iRpc
3871 <<
", stat: " << gMinuit->fCstatu <<
", chi2 "
3872 << ff->GetChisquare() / ff->GetNDF()
3873 << Form(
", striplen (%5.2f): %7.2f+/-%5.2f, pos res "
3874 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
3876 2. * ff->GetParameter(1),
3877 2. * ff->GetParError(1),
3878 ff->GetParameter(2),
3880 ff->GetParameter(3),
3881 ff->GetParError(3));
3882 if (TMath::Abs(ff->GetParameter(3) - dYMeanAv)
3884 dYMeanFit = ff->GetParameter(3);
3886 (Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3887 for (Int_t iPar = 0; iPar < 4; iPar++)
3889 (Double_t)(iSm * iNbRpc + iRpc),
3890 ff->GetParameter(2 + iPar));
3894 <<
"FAvBad YBox " << htempPos_py->GetEntries()
3895 <<
" entries in " << iSmType << iSm << iRpc <<
", chi2 "
3896 << ff->GetChisquare()
3898 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
3899 "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3902 2. * ff->GetParameter(1),
3903 2. * ff->GetParError(1),
3904 ff->GetParameter(2),
3906 ff->GetParameter(3),
3907 ff->GetParError(3));
3910 LOG(info) <<
"FAvFailed for TSR " << iSmType << iSm << iRpc;
3913 Double_t dYShift = dYMeanFit - dYMeanAv;
3915 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3918 ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1);
3921 htempPos_py = htempPos->ProjectionY(
3922 Form(
"%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
3923 if (htempPos_py->GetEntries() >
fdYFitMin
3925 LOG(debug1) << Form(
3926 "Determine YMean in %s of channel %d by fit to %d entries",
3927 htempPos->GetName(),
3929 (Int_t) htempPos_py->GetEntries());
3935 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3938 Double_t fp[4] = {1., 3 * 0.};
3939 for (Int_t iPar = 2; iPar < 4; iPar++)
3941 fp[iPar] =
fhSmCluFpar[iSmType][iPar]->GetBinContent(
3942 iSm * iNbRpc + iRpc + 1);
3945 Double_t* fpp = &fp[0];
3947 TF1* ff = htempPos_py->GetFunction(
"YBox");
3950 - 2. * ff->GetParameter(1))
3953 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1))
3957 if (TMath::Abs(ff->GetParameter(3) - YMean)
3959 YMean = ff->GetParameter(3);
3961 / (2. * ff->GetParameter(1));
3963 (Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3964 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries()
3965 <<
" entries in " << iSmType << iSm << iRpc << iCh
3966 <<
", chi2 " << ff->GetChisquare()
3967 << Form(
", striplen (%5.2f), %4.2f -> %4.2f, "
3968 "%4.1f: %7.2f+/-%5.2f, pos res "
3969 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
3974 2. * ff->GetParameter(1),
3975 2. * ff->GetParError(1),
3976 ff->GetParameter(2),
3978 ff->GetParameter(3),
3979 ff->GetParError(3));
3980 for (Int_t iPar = 0; iPar < 4; iPar++)
3982 (Double_t)(iSm * iNbRpc + iRpc),
3983 ff->GetParameter(2 + iPar));
3988 <<
"FBad YBox " << htempPos_py->GetEntries()
3989 <<
" entries in " << iSmType << iSm << iRpc << iCh
3990 <<
", chi2 " << ff->GetChisquare()
3991 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3992 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3995 2. * ff->GetParameter(1),
3996 2. * ff->GetParError(1),
3997 ff->GetParameter(2),
3999 ff->GetParameter(3),
4000 ff->GetParError(3));
4006 ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
4013 TMean -= ((TProfile*) hAvTOff_pfx)
4014 ->GetBinContent(iSm * iNbRpc + iRpc + 1);
4017 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
4018 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
4019 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
4021 "Calib: TSRC %d%d%d%d, hits %6.0f, dTY %8.3f, TM %8.3f -> new "
4027 htempTOff_px->GetBinContent(iCh + 1),
4030 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4031 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4040 for (Int_t iSide = 0; iSide < 2; iSide++) {
4041 Int_t ib = iCh * 2 + 1 + iSide;
4042 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
4043 if (100 > hbin->GetEntries())
4046 Int_t iBmax = hbin->GetMaximumBin();
4047 TAxis* xaxis = hbin->GetXaxis();
4049 xaxis->GetBinCenter(iBmax)
4050 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4055 <<
"XOff changed for "
4056 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f",
4062 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4065 Double_t TotMean = hbin->GetMean();
4066 if (15 == iSmType) {
4069 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4070 "gain %f, modg %f ",
4076 htempTot_Mean->GetBinContent(ib),
4077 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide],
4080 if (0.001 < TotMean) {
4081 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
4086 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4087 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh]
4090 <<
"CbmTofTestBeamClusterizer::FillCalHist:"
4091 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc
4092 <<
" Ch " << iCh <<
": YMean " << YMean <<
", TMean " << TMean
4094 << Form(
" %f %f %f %f ",
4095 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4096 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4097 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4098 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4101 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4102 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4105 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4106 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4107 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4108 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4109 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4110 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4115 htempPos_pfx->Reset();
4116 htempTOff_pfx->Reset();
4117 htempTot_Mean->Reset();
4118 htempTot_Off->Reset();
4119 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4122 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4123 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4124 Double_t TMean = 0.5
4125 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4126 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4127 htempPos_pfx->Fill(iCh, YMean);
4128 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4129 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
4130 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
4131 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4132 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
4135 htempTOff_pfx->Fill(iCh, TMean);
4137 for (Int_t iSide = 0; iSide < 2; iSide++) {
4138 htempTot_Mean->SetBinContent(
4139 iCh * 2 + 1 + iSide,
4141 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4142 htempTot_Off->SetBinContent(
4143 iCh * 2 + 1 + iSide,
4144 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4150 LOG(debug1) <<
" Updating done ... write to file ";
4151 htempPos_pfx->Write();
4152 htempTOff_pfx->Write();
4154 htempTot_Mean->Write();
4155 htempTot_Off->Write();
4158 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName()
4161 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4163 TDirectory* curdir = gDirectory;
4165 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4166 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4171 gDirectory->cd(curdir->GetPath());
4172 if (NULL != hCorDelTof) {
4173 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4174 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4179 hCorDelTofout->Write();
4181 LOG(debug) <<
" No CorDelTof histo "
4182 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4190 LOG(debug) <<
" Store old walk histos to file ";
4192 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4202 h1tmp0->SetBinContent(
4203 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4204 h1tmp1->SetBinContent(
4205 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4206 if (h1tmp0->GetBinContent(iWx + 1)
4207 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4208 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
4209 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
4211 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4214 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4221 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4235 <<
"WriteHistos: restore Offsets, Gains and Walk, save DelTof for "
4236 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
4237 htempPos_pfx->Reset();
4238 htempTOff_pfx->Reset();
4239 htempTot_Mean->Reset();
4240 htempTot_Off->Reset();
4241 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
4243 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4244 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4245 Double_t TMean = 0.5
4246 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4247 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4248 htempPos_pfx->Fill(iCh, YMean);
4249 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4250 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
4251 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
4252 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4253 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
4256 htempTOff_pfx->Fill(iCh, TMean);
4258 for (Int_t iSide = 0; iSide < 2; iSide++) {
4259 htempTot_Mean->SetBinContent(
4260 iCh * 2 + 1 + iSide,
4264 htempTot_Off->SetBinContent(
4265 iCh * 2 + 1 + iSide,
4266 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4270 LOG(debug1) <<
" Restoring of Offsets and Gains done ... ";
4271 htempPos_pfx->Write();
4272 htempTOff_pfx->Write();
4274 htempTot_Mean->Write();
4275 htempTot_Off->Write();
4278 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4288 h1tmp0->SetBinContent(
4289 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4290 h1tmp1->SetBinContent(
4291 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4292 if (h1tmp0->GetBinContent(iWx + 1)
4293 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4294 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
4295 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
4297 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4300 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4307 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4324 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4326 if (NULL == h2tmp) {
4328 "WriteHistos: histo not available for SmT %d, Sm %d, Rpc %d",
4334 Int_t iNEntries = h2tmp->GetEntries();
4337 TProfile* htmp = h2tmp->ProfileX(
"_pfx", 1, h2tmp->GetNbinsY());
4338 TH1D* h1tmp = h2tmp->ProjectionX(
"_px", 1, h2tmp->GetNbinsY());
4343 Double_t dNEntries = h1tmp->GetBinContent(iBx + 1);
4346 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] +=
4347 ((TProfile*) htmp)->GetBinContent(iBx + 1);
4348 dDelMean +=
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel];
4352 LOG(debug) << Form(
" Update DelTof correction for SmT %d, Sm %d, "
4353 "Rpc %d, Sel%d: Entries %d, Mean shift %6.1f",
4363 h1tmp->SetBinContent(
4364 iBx + 1,
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel]);
4366 h1tmp->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4374 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4376 TDirectory* curdir = gDirectory;
4378 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4379 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4384 gDirectory->cd(curdir->GetPath());
4385 if (NULL != hCorDelTof) {
4386 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4387 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4392 LOG(debug) <<
" Save existing CorDelTof histo "
4393 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4398 hCorDelTofout->Write();
4400 LOG(debug) <<
" No CorDelTof histo "
4401 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4417 LOG(info) <<
"WriteHistos (calMode==3): update Offsets and Gains, "
4418 "keep Walk and DelTof for "
4419 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
4420 <<
" with " << iNbCh <<
" channels "
4421 <<
" using selector " <<
fCalSel;
4423 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4425 Double_t YMean = ((TProfile*) htempPos_pfx)
4426 ->GetBinContent(iCh + 1);
4427 Double_t TMean = 0.;
4432 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
4433 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
4434 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
4436 LOG(debug3) << Form(
4437 "Calib: TSRC %d%d%d%d, hits %6.0f, new Off %8.0f,%8.0f ",
4442 htempTOff_px->GetBinContent(iCh + 1),
4443 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4444 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4453 for (Int_t iSide = 0; iSide < 2; iSide++) {
4454 Int_t ib = iCh * 2 + 1 + iSide;
4455 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
4456 if (100 > hbin->GetEntries())
4459 Int_t iBmax = hbin->GetMaximumBin();
4460 TAxis* xaxis = hbin->GetXaxis();
4462 xaxis->GetBinCenter(iBmax)
4463 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4468 <<
"XOff changed for "
4469 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f",
4475 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4478 Double_t TotMean = hbin->GetMean();
4479 if (15 == iSmType) {
4482 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4483 "gain %f, modg %f ",
4489 htempTot_Mean->GetBinContent(ib),
4490 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide],
4493 if (0.001 < TotMean) {
4494 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
4499 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4500 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh]
4503 <<
"CbmTofTestBeamClusterizer::FillCalHist:"
4504 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc
4505 <<
" Ch " << iCh <<
": YMean " << YMean <<
", TMean " << TMean
4507 << Form(
" %f %f %f %f ",
4508 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4509 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4510 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4511 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4514 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4515 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4518 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4519 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4520 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4521 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4522 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4523 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4528 htempPos_pfx->Reset();
4529 htempTOff_pfx->Reset();
4530 htempTot_Mean->Reset();
4531 htempTot_Off->Reset();
4532 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4535 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4536 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4537 Double_t TMean = 0.5
4538 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4539 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4540 htempPos_pfx->Fill(iCh, YMean);
4541 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4542 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
4543 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
4544 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4545 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
4548 htempTOff_pfx->Fill(iCh, TMean);
4550 for (Int_t iSide = 0; iSide < 2; iSide++) {
4551 htempTot_Mean->SetBinContent(
4552 iCh * 2 + 1 + iSide,
4554 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4555 htempTot_Off->SetBinContent(
4556 iCh * 2 + 1 + iSide,
4557 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4563 LOG(debug1) <<
" Updating done ... write to file ";
4564 htempPos_pfx->Write();
4565 htempTOff_pfx->Write();
4567 htempTot_Mean->Write();
4568 htempTot_Off->Write();
4571 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName()
4574 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4576 TDirectory* curdir = gDirectory;
4578 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4579 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4584 gDirectory->cd(curdir->GetPath());
4585 if (NULL != hCorDelTof) {
4586 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4587 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4592 hCorDelTofout->Write();
4594 LOG(debug) <<
" No CorDelTof histo "
4595 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4603 LOG(debug) <<
" Store old walk histos to file ";
4605 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4615 h1tmp0->SetBinContent(
4616 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4617 h1tmp1->SetBinContent(
4618 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4619 if (h1tmp0->GetBinContent(iWx + 1)
4620 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4621 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
4622 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
4624 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4627 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4634 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4646 LOG(debug) <<
"WriteHistos: update mode " <<
fCalMode
4647 <<
" not yet implemented";
4691 for (Int_t iPar = 0; iPar < 4; iPar++)
4694 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4702 gDirectory->cd(oldir->GetPath());
4749 gGeoManager->CdTop();
4752 LOG(info) <<
" No CalDigis defined ! Check! ";
4756 LOG(debug) <<
"CbmTofTestBeamClusterizer::BuildClusters from "
4764 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
4766 LOG(debug1) << iDigInd <<
" " << pDigi
4767 << Form(
" Address : 0x%08x ", pDigi->
GetAddress()) <<
" SmT "
4768 << pDigi->
GetType() <<
" Sm " << pDigi->
GetSm() <<
" Rpc "
4785 LOG(warning) << Form(
4786 " DigiCor Histo for DetIndx %d derived from 0x%08x not found",
4795 for (Int_t iDigI2 = 0; iDigI2 < iNbTofDigi; iDigI2++) {
4809 Double_t dTDif = TMath::Abs(pDigi->
GetTime() - pDigi2->
GetTime());
4810 if (dTDif < dTDifMin) {
4819 for (; iDigI3 < iNbTofDigi; iDigI3++) {
4825 if (iDigI3 == iNbTofDigi)
4832 LOG(debug2) << Form(
"shift channel %d%d%d%d%d and ",
4834 (Int_t) pDigi->
GetSm(),
4838 << Form(
" %d%d%d%d%d ",
4840 (Int_t) pDigi2->
GetSm(),
4841 (Int_t) pDigi2->
GetRpc(),
4858 LOG(debug2) << Form(
"resultchannel %d%d%d%d%d and ",
4860 (Int_t) pDigi->
GetSm(),
4864 << Form(
" %d%d%d%d%d ",
4866 (Int_t) pDigi2->
GetSm(),
4867 (Int_t) pDigi2->
GetRpc(),
4873 new ((*fTofDigisColl)[iNbTofDigi++])
CbmTofDigi(*pDigi);
4882 new ((*fTofDigisColl)[iNbTofDigi++])
CbmTofDigi(*pDigi2);
4898 if (pDigi2Min != NULL) {
4908 LOG(warning) << Form(
"BuildClusters: invalid ChannelInfo for 0x%08x",
4921 <<
" BuildClusters: Inconsistent duplicated digis in event "
4923 LOG(warning) <<
" " << pDigi->
ToString();
4924 LOG(warning) <<
" " << pDigi2Min->
ToString();
4955 Int_t iDigIndCal = -1;
4957 std::map<Int_t, Double_t> mChannelDeadTime;
4959 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
4967 (0 == pDigi->
GetSide()) ? 1 : 0,
4973 LOG(debug1) <<
"BC "
4974 << Form(
"0x%08x", pDigi->
GetAddress()) <<
" TSRC "
4976 << Form(
"%2d", (Int_t) pDigi->
GetChannel()) <<
" "
4978 <<
" " << pDigi->
GetTot();
4986 Bool_t bValid = kTRUE;
4987 std::map<Int_t, Double_t>::iterator it;
4988 it = mChannelDeadTime.find(iAddr);
4989 if (it != mChannelDeadTime.end()) {
4990 LOG(debug1) <<
"CCT found valid ChannelDeadtime entry "
4991 << mChannelDeadTime[iAddr] <<
", DeltaT "
4992 << pDigi->
GetTime() - mChannelDeadTime[iAddr];
4993 if ((bValid = (pDigi->
GetTime()
4995 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
4997 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
4999 mChannelDeadTime[iAddr] = pDigi->
GetTime();
5000 if (!bValid)
continue;
5002 LOG(debug1) <<
"DC "
5003 << Form(
"0x%08x", pDigi->
GetAddress()) <<
" TSRC "
5005 << Form(
"%2d", (Int_t) pDigi->
GetChannel()) <<
" "
5007 <<
" " << pDigi->
GetTot();
5023 LOG(debug2) <<
" CluCal-Init: " << pDigi->
ToString();
5030 LOG(debug2) <<
" CluCal-TOff: " << pCalDigi->
ToString();
5037 if (dTot < 0.001) dTot = 0.001;
5047 Int_t iWx = (Int_t)((pCalDigi->
GetTot() -
fdTOTMin) / dTotBinSize);
5048 if (0 > iWx) iWx = 0;
5051 (pCalDigi->
GetTot() -
fdTOTMin) / dTotBinSize - (Double_t) iWx - 0.5;
5065 [pCalDigi->
GetSide()][iWx + 1]
5080 [pCalDigi->
GetSide()][iWx - 1]
5090 LOG(debug2) <<
" CluCal-Walk: " << pCalDigi->
ToString();
5094 <<
"CbmTofTestBeamClusterizer::BuildClusters: CalDigi "
5095 << iDigIndCal <<
", T " << pCalDigi->
GetType() <<
", Sm "
5096 << pCalDigi->
GetSm() <<
", R " << pCalDigi->
GetRpc() <<
", Ch "
5111 <<
", Walk " << iWx <<
": "
5118 LOG(info) <<
" dDTot " << dDTot <<
" BinSize: " << dTotBinSize
5124 [pCalDigi->
GetSide()][iWx - 1]
5136 [pCalDigi->
GetSide()][iWx + 1]
5137 <<
" -> dWT = " << dWT;
5140 LOG(info) <<
"Skip1 Digi "
5141 <<
" Type " << pDigi->
GetType() <<
" "
5144 << pDigi->
GetRpc() <<
" "
5153 new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pCalDigi);
5173 LOG(debug) <<
"CbmTofTestBeamClusterizer::BuildClusters: Sort "
5175 if (iNbTofDigi > 1) {
5179 LOG(warning) <<
"CbmTofTestBeamClusterizer::BuildClusters: Sorting not "
5185 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
5187 LOG(debug1) <<
"AC "
5188 << Form(
"0x%08x", pDigi->
GetAddress()) <<
" TSRC "
5190 << Form(
"%2d", (Int_t) pDigi->
GetChannel()) <<
" "
5192 <<
" " << pDigi->
GetTot();
5207 .push_back(iDigInd);
5209 LOG(info) <<
"Skip2 Digi "
5210 <<
" Type " << pDigi->
GetType() <<
" "
5213 << pDigi->
GetRpc() <<
" "
5257 Double_t dWeightedTime = 0.0;
5258 Double_t dWeightedPosX = 0.0;
5259 Double_t dWeightedPosY = 0.0;
5260 Double_t dWeightedPosZ = 0.0;
5261 Double_t dWeightsSum = 0.0;
5266 Int_t iNbChanInHit = 0;
5268 Int_t iLastChan = -1;
5269 Double_t dLastPosX =
5271 Double_t dLastPosY = 0.0;
5272 Double_t dLastTime = 0.0;
5274 Double_t dPosX = 0.0;
5275 Double_t dPosY = 0.0;
5276 Double_t dPosZ = 0.0;
5277 Double_t dTime = 0.0;
5278 Double_t dTimeDif = 0.0;
5279 Double_t dTotS = 0.0;
5282 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
5285 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
5286 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
5289 LOG(debug2) <<
"RPC - Loop "
5290 << Form(
" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
5295 dWeightedTime = 0.0;
5296 dWeightedPosX = 0.0;
5297 dWeightedPosY = 0.0;
5298 dWeightedPosZ = 0.0;
5307 LOG(debug2) <<
"ChanOrient "
5308 << Form(
" %3d %3d %3d %3d %3d ",
5320 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
5324 " T %3d Sm %3d R %3d Ch %3d Size %3lu ",
5329 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5330 if (0 ==
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].size())
5332 if (0 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
5334 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5337 1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
5339 while ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])
5341 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
5345 if (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()
5348 <<
"SameSide Digis! on TSRC " << iSmType << iSm << iRpc
5349 << iCh <<
", Times: "
5360 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
5373 <<
"3 consecutive SameSide Digis! on TSRC " << iSmType
5374 << iSm << iRpc << iCh <<
", Times: "
5417 "Ev %8.0f, digis not properly time ordered, TSRCS "
5439 <<
"SameSide Erase fStor entries(d) " << iSmType
5440 <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5448 if (2 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5455 <<
"digis processing for "
5456 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ",
5463 if (2 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5466 "Leaving digi processing for TSRC %d%d%d%d, size %3lu",
5471 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5482 LOG(debug1) << Form(
5483 " TSRC %d%d%d%d size %3lu ",
5488 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
5489 << Form(
" ChId: 0x%08x 0x%08x ", iChId, iUCellId);
5493 LOG(error) <<
"CbmTofTestBeamClusterizer::BuildClusters: "
5494 "no geometry info! "
5495 << Form(
" %3d %3d %3d %3d 0x%08x 0x%08x ",
5509 LOG(debug2) << Form(
" Node at (%6.1f,%6.1f,%6.1f) : %p",
5521 LOG(debug2) <<
" " << xDigiA->
ToString();
5522 LOG(debug2) <<
" " << xDigiB->
ToString();
5525 if (5 == iSmType && dTimeDif != 0.) {
5527 LOG(debug) <<
"CbmTofTestBeamClusterizer::BuildClusters: "
5529 << iSm <<
" with inconsistent digits "
5531 <<
" -> " << dTimeDif;
5532 LOG(debug) <<
" " << xDigiA->
ToString();
5533 LOG(debug) <<
" " << xDigiB->
ToString();
5545 &&
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()
5548 <<
"Hit candidate outside correlation window, check for "
5549 "better possible digis, "
5551 <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
5555 Double_t dPosYN = 0.;
5556 Double_t dTimeDifN = 0;
5569 if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
5571 <<
"Replace digi on side " << xDigiC->
GetSide()
5572 <<
", yPosNext " << dPosYN <<
" old: " << dPosY;
5573 dTimeDif = dTimeDifN;
5599 <<
"Wrong combinations of digis "
5612 dPosX = ((Double_t)(-iNbCh / 2 + iCh) + 0.5)
5618 << Form(
" %3d %3d %3d %3d %3d 0x%p %1.0f Time %f PosX %f "
5636 if (0 < iNbChanInHit) {
5637 if (iLastChan == iCh - 1) {
5648 && iLastChan == iCh - 1
5651 dWeightedTime += dTime * dTotS;
5652 dWeightedPosX += dPosX * dTotS;
5653 dWeightedPosY += dPosY * dTotS;
5654 dWeightedPosZ += dPosZ * dTotS;
5655 dWeightsSum += dTotS;
5664 <<
" Add Digi and erase fStor entries(a): NbChanInHit "
5665 << iNbChanInHit <<
", " << iSmType <<
", SR "
5666 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5684 dWeightedTime /= dWeightsSum;
5685 dWeightedPosX /= dWeightsSum;
5686 dWeightedPosY /= dWeightsSum;
5687 dWeightedPosZ /= dWeightsSum;
5690 Double_t hitpos_local[3];
5691 hitpos_local[0] = dWeightedPosX;
5692 hitpos_local[1] = dWeightedPosY;
5693 hitpos_local[2] = dWeightedPosZ;
5696 TGeoNode* cNode = gGeoManager->GetCurrentNode();
5697 gGeoManager->GetCurrentMatrix();
5701 gGeoManager->LocalToMaster(hitpos_local, hitpos);
5703 << Form(
" LocalToMaster for node %p: "
5704 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
5713 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
5736 if (iChm < 0) iChm = 0;
5737 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
5739 iSm, iRpc, iChm, 0, iSmType);
5744 LOG(debug) <<
"Save Hit "
5745 << Form(
" %3d %3d 0x%08x %3d %3d %3d %f %f",
5766 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits
5767 <<
": vDigiIndRef.size()";
5773 && dWeightedTime == pHitL->
GetTime()) {
5774 LOG(debug) <<
"Store Hit twice? "
5775 <<
" fiNbHits " <<
fiNbHits <<
", "
5776 << Form(
"0x%08x", iDetId);
5782 LOG(debug) <<
" Digi " << pDigiC->
ToString();
5792 LOG(debug) <<
" DigiL " << pDigiC->
ToString();
5805 Int_t(dWeightsSum * 10.));
5811 LH_store(iSmType, iSm, iRpc, iChm, pHit);
5835 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
5836 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
5846 dWeightedTime = dTime * dTotS;
5847 dWeightedPosX = dPosX * dTotS;
5848 dWeightedPosY = dPosY * dTotS;
5849 dWeightedPosZ = dPosZ * dTotS;
5850 dWeightsSum = dTotS;
5856 <<
" Next fStor Digi " << iSmType <<
", SR "
5857 << iSm * iNbRpc + iRpc <<
", Ch" << iCh <<
", Dig0 "
5858 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0])
5860 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
5867 <<
" Erase fStor entries(b) " << iSmType <<
", SR "
5868 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5896 LOG(debug) << Form(
"1.Hit on channel %d, time: %f, PosY %f",
5902 dWeightedTime = dTime * dTotS;
5903 dWeightedPosX = dPosX * dTotS;
5904 dWeightedPosY = dPosY * dTotS;
5905 dWeightedPosZ = dPosZ * dTotS;
5906 dWeightsSum = dTotS;
5917 <<
" Erase fStor entries(c) " << iSmType <<
", SR "
5918 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5920 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5922 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5924 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5926 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5955 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
5956 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
5958 LOG(debug2) <<
"finished V-RPC"
5959 << Form(
" %3d %3d %3d %d %f %fx",
5970 <<
"=> Cluster building "
5971 <<
"from digis to hits not implemented for pads, Sm type "
5972 << iSmType <<
" Rpc " << iRpc;
5978 if (0 < iNbChanInHit) {
5979 LOG(debug1) <<
"Process cluster " << iNbChanInHit;
5983 LOG(debug1) <<
"H-Hit ";
5986 LOG(debug2) <<
"V-Hit ";
5988 dWeightedTime /= dWeightsSum;
5989 dWeightedPosX /= dWeightsSum;
5990 dWeightedPosY /= dWeightsSum;
5991 dWeightedPosZ /= dWeightsSum;
5994 Double_t hitpos_local[3] = {3 * 0.};
5995 hitpos_local[0] = dWeightedPosX;
5996 hitpos_local[1] = dWeightedPosY;
5997 hitpos_local[2] = dWeightedPosZ;
6000 TGeoNode* cNode = gGeoManager->GetCurrentNode();
6001 gGeoManager->GetCurrentMatrix();
6005 gGeoManager->LocalToMaster(hitpos_local, hitpos);
6006 LOG(debug1) << Form(
" LocalToMaster for V-node %p: "
6007 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
6016 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
6038 if (iChm < 0) iChm = 0;
6039 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
6045 LOG(debug) <<
"Save V-Hit "
6046 << Form(
" %3d %3d 0x%08x %3d 0x%08x",
6054 LOG(debug) <<
", DigiInds: ";
6065 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits
6066 <<
": vDigiIndRef.size()";
6071 && dWeightedTime == pHitL->
GetTime())
6072 LOG(debug) <<
"Store Hit twice? "
6073 <<
" fiNbHits " <<
fiNbHits <<
", "
6074 << Form(
"0x%08x", iDetId);
6085 Int_t(dWeightsSum * 10.));
6092 LH_store(iSmType, iSm, iRpc, iChm, pHit);
6115 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
6116 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
6126 LOG(debug2) <<
" Fini-A "
6127 << Form(
" %3d %3d %3d M%3d",
6133 LOG(debug2) <<
" Fini-B " << Form(
" %3d ", iSmType);
6137 LOG(error) <<
" Compressed Digis not implemented ... ";
6145 LOG(info) <<
" No Hits defined ! Check! ";
6149 for (Int_t iHitInd = 0; iHitInd <
fTofHitsColl->GetEntries(); iHitInd++) {
6151 if (NULL == pHit)
continue;
6156 if (iSmType != 5 && iSmType != 8)
continue;
6157 LOG(debug) <<
"MergeClusters: in SmT " << iSmType <<
" for " << iNbRpc
6166 LOG(debug) <<
"MergeClusters: Check for mergers in "
6167 << Form(
" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d",
6173 for (Int_t iHitInd2 = iHitInd + 1; iHitInd2 <
fTofHitsColl->GetEntries();
6176 if (NULL == pHit2)
continue;
6179 if (iSmType2 == iSmType) {
6181 if (iSm2 == iSm || iSmType == 5) {
6183 if (TMath::Abs(iRpc - iRpc2) == 1
6188 Double_t xPos = pHit->
GetX();
6189 Double_t yPos = pHit->
GetY();
6190 Double_t tof = pHit->
GetTime();
6191 Double_t xPos2 = pHit2->
GetX();
6192 Double_t yPos2 = pHit2->
GetY();
6193 Double_t tof2 = pHit2->
GetTime();
6194 LOG(debug) <<
"MergeClusters: Found hit in neighbour "
6195 << Form(
" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d",
6201 << Form(
" DX %6.1f, DY %6.1f, DT %6.1f",
6214 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
6218 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
6219 if (iDigInd0 < fTofCalDigisColl->GetEntries()
6233 for (Int_t iLink = 0; iLink < digiMatch2->
GetNofLinks();
6237 Int_t iDigInd1 = (digiMatch2->
GetLink(iLink + 1)).GetIndex();
6238 if (iDigInd0 < fTofCalDigisColl->GetEntries()
6244 dTot2 += pDig0->
GetTot();
6245 dTot2 += pDig1->
GetTot();
6256 LOG(debug) <<
"MergeClusters: Found merger in neighbour "
6257 << Form(
" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d(%d)",
6264 << Form(
" DX %6.1f, DY %6.1f, DT %6.1f",
6268 << Form(
" Tots %6.1f - %6.1f", dTot, dTot2);
6269 Double_t dTotSum = dTot + dTot2;
6270 Double_t dxPosM = (xPos * dTot + xPos2 * dTot2) / dTotSum;
6271 Double_t dyPosM = (yPos * dTot + yPos2 * dTot2) / dTotSum;
6272 Double_t dtofM = (tof * dTot + tof2 * dTot2) / dTotSum;
6283 LOG(debug) <<
"MergeClusters: Compress TClonesArrays to "
6306 double wx = 1. - par[4] * TMath::Power(xx + par[5], 2);
6307 double xboxe = par[0] * 0.25
6308 * (1. + TMath::Erf((xx + par[1] - par[3]) / par[2]))
6309 * (1. + TMath::Erf((-xx + par[1] + par[3]) / par[2]));
6315 h1 = (TH1*) gROOT->FindObjectAny(hname);
6316 if (NULL != h1) {
fit_ybox(h1, 0.); }
6320 Double_t* fpar = NULL;
6326 Double_t* fpar = NULL) {
6327 TAxis* xaxis = h1->GetXaxis();
6328 Double_t Ymin = xaxis->GetXmin();
6329 Double_t Ymax = xaxis->GetXmax();
6330 TF1* f1 =
new TF1(
"YBox",
f1_xboxe, Ymin, Ymax, 6);
6331 Double_t yini = (h1->GetMaximum() + h1->GetMinimum()) * 0.5;
6332 if (ysize == 0.) ysize = Ymax * 0.8;
6333 f1->SetParameters(yini, ysize * 0.5, 1., 0., 0., 0.);
6335 f1->SetParLimits(2, 0.2, 3.);
6336 f1->SetParLimits(3, -4., 4.);
6339 for (Int_t
i = 0;
i < 4;
i++)
6341 for (Int_t
i = 0;
i < 4;
i++)
6342 f1->SetParameter(2 +
i, fp[
i]);
6343 LOG(debug) <<
"Ini Fpar for " << h1->GetName() <<
" with "
6344 << Form(
" %6.3f %6.3f %6.3f %6.3f ", fp[0], fp[1], fp[2], fp[3]);
6347 h1->Fit(
"YBox",
"Q");
6351 res[9] = f1->GetChisquare();
6353 for (
int i = 0;
i < 6;
i++) {
6354 res[
i] = f1->GetParameter(
i);
6355 err[
i] = f1->GetParError(
i);
6358 LOG(debug) <<
"YBox Fit of " << h1->GetName()
6359 <<
" ended with chi2 = " << res[9]
6360 << Form(
", strip length %7.2f +/- %5.2f, position resolution "
6361 "%7.2f +/- %5.2f at y_cen = %7.2f +/- %5.2f",
6372 LOG(fatal) << Form(
"Inconsistent LH Smtype size %lu, %d ",
6379 LOG(fatal) << Form(
"Inconsistent LH Sm size %lu, %d T %d",
6386 LOG(fatal) << Form(
"Inconsistent LH Rpc size %lu, %d TS %d%d ",
6395 "Inconsistent LH RpcChannel size %lu, %d TSR %d%d%d ",
6402 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size() > 0) {
6409 "Inconsistent address for Ev %8.0f in list of size %lu for "
6410 "TSRC %d%d%d%d: 0x%08x, time %f",
6418 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
6423 LOG(debug) << Form(
"LH check passed for event %8.0f",
fdEvent);
6428 LOG(fatal) << Form(
"Inconsistent LH Smtype size %lu, %d ",
6434 LOG(fatal) << Form(
"Inconsistent LH Sm size %lu, %d T %d",
6441 LOG(fatal) << Form(
"Inconsistent LH Rpc size %lu, %d TS %d%d ",
6450 "Inconsistent LH RpcChannel size %lu, %d TSR %d%d%d ",
6457 while (
fvLastHits[iSmType][iSm][iRpc][iCh].size() > 0) {
6464 "Inconsistent address for Ev %8.0f in list of size %lu for "
6465 "TSRC %d%d%d%d: 0x%08x, time %f",
6473 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
6474 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
6475 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
6480 LOG(info) << Form(
"LH cleaning done after %8.0f events",
fdEvent);
6490 Double_t dLastTotS) {
6496 Int_t iCh = iLastChan + 1;
6497 LOG(debug) << Form(
"Inspect channel TSRC %d%d%d%d at time %f, pos %f, size ",
6504 <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
6505 if (iCh == iNbCh)
return kFALSE;
6506 if (0 ==
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
6508 if (0 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
6510 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
6511 if (1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
6512 Bool_t AddedHit = kFALSE;
6514 i1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size() - 1;
6516 if (AddedHit)
break;
6519 && i2 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
6520 LOG(debug) <<
"check digi pair " << i1 <<
"," << i2 <<
" with size "
6521 <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
6523 if ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i1])->GetSide()
6524 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i2])
6540 gGeoManager->FindNode(
6544 Double_t dPosY = 0.;
6551 if (TMath::Abs(dPosY - dLastPosY)
6554 Double_t dNClHits = (Double_t)(
vDigiIndRef.size() / 2);
6558 Double_t dNewTotS = (dLastTotS + dTotS);
6559 dLastPosX = (dLastPosX * dLastTotS + dPosX * dTotS) / dNewTotS;
6560 dLastPosY = (dLastPosY * dLastTotS + dPosY * dTotS) / dNewTotS;
6561 dLastTime = (dLastTime * dLastTotS + dTime * dTotS) / dNewTotS;
6562 dLastTotS = dNewTotS;
6564 Int_t Ind1 =
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i1];
6565 Int_t Ind2 =
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i2];
6570 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
6572 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
6574 std::vector<int>::iterator it;
6575 it = find(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin(),
6578 if (it !=
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].end()) {
6580 it -
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin();
6581 LOG(debug) <<
"Found i2 " << i2 <<
" with Ind2 " << Ind2
6582 <<
" at position " << ipos;
6584 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
6586 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
6588 LOG(fatal) <<
" Did not find i2 " << i2 <<
" with Ind2 " << Ind2;
6592 if (iCh != (iNbCh - 1)
6601 LOG(debug) <<
"Added Strip " << iCh <<
" to cluster of size "
6612 Double_t hitpos_local[3] = {3 * 0.};
6613 hitpos_local[0] = dLastPosX;
6614 hitpos_local[1] = dLastPosY;
6615 hitpos_local[2] = 0.;
6617 gGeoManager->GetCurrentNode();
6618 gGeoManager->GetCurrentMatrix();
6619 gGeoManager->LocalToMaster(hitpos_local, hitpos);
6620 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
6621 TVector3 hitPosErr(0.5, 0.5, 0.5);
6623 if (iChm < 0) iChm = 0;
6624 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
6630 LOG(debug) <<
"Save A-Hit "
6631 << Form(
"%2d %2d 0x%08x %3d t %f, y %f ",
6639 LOG(debug) <<
", DigiInds: ";
6654 Int_t(dLastTotS * 10.));
6658 LH_store(iSmType, iSm, iRpc, iChm, pHit);
6681 if (
fvLastHits[iSmType][iSm][iRpc][iChm].size() == 0)
6682 fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit);
6684 Double_t dLastTime = pHit->
GetTime();
6685 if (dLastTime >=
fvLastHits[iSmType][iSm][iRpc][iChm].back()->GetTime()) {
6686 fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit);
6688 " Store LH from Ev %8.0f for TSRC %d%d%d%d, size %lu, addr 0x%08x, "
6698 dLastTime -
fvLastHits[iSmType][iSm][iRpc][iChm].front()->GetTime());
6704 std::list<CbmTofHit*>::iterator it;
6705 for (it =
fvLastHits[iSmType][iSm][iRpc][iChm].begin();
6706 it !=
fvLastHits[iSmType][iSm][iRpc][iChm].end();
6708 if ((*it)->GetTime() > dLastTime)
break;
6709 fvLastHits[iSmType][iSm][iRpc][iChm].insert(--it, pHit);
6710 Double_t deltaTime = dLastTime - (*it)->GetTime();
6711 LOG(debug) << Form(
"Hit inserted into LH from Ev %8.0f for TSRC "
6712 "%d%d%d%d, size %lu, addr 0x%08x, delta time %f ",
6722 Double_t deltaTime =
6723 dLastTime -
fvLastHits[iSmType][iSm][iRpc][iChm].front()->GetTime();
6724 LOG(debug) << Form(
"first LH from Ev %8.0f for TSRC %d%d%d%d, size "
6725 "%lu, addr 0x%08x, delta time %f ",
6734 if (deltaTime == 0.) {
6738 fvLastHits[iSmType][iSm][iRpc][iChm].push_front(pHit);