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"
75 Bool_t writeDataInOut)
76 : FairTask(TString(name), verbose)
83 , fTofPointsColl(NULL)
86 , fbWriteHitsInOut(writeDataInOut)
87 , fbWriteDigisInOut(writeDataInOut)
88 , fTofCalDigisColl(NULL)
90 , fTofDigiMatchColl(NULL)
103 , fhClustBuildTime(NULL)
104 , fhHitsPerTracks(NULL)
106 , fhTimeResSingHits(NULL)
107 , fhTimeResSingHitsB(NULL)
108 , fhTimePtVsHits(NULL)
109 , fhClusterSize(NULL)
110 , fhClusterSizeType(NULL)
112 , fhClusterSizeMulti(NULL)
114 , fhHiTrkMulPos(NULL)
115 , fhAllTrkMulPos(NULL)
116 , fhMultiTrkProbPos(NULL)
117 , fhDigSpacDifClust(NULL)
118 , fhDigTimeDifClust(NULL)
119 , fhDigDistClust(NULL)
120 , fhClustSizeDifX(NULL)
121 , fhClustSizeDifY(NULL)
124 , fhCluMulCorDutSel(NULL)
129 , fhRpcCluPositionEvol()
132 , fhRpcCluDelMatPos()
135 , fhRpcCluDelMatTOff()
147 , fhRpcDTLastHits_Tot()
148 , fhRpcDTLastHits_CluSize()
150 , fhTRpcCluPosition()
162 , fhTRpcCluTOffDTLastHits()
163 , fhTRpcCluTotDTLastHits()
164 , fhTRpcCluSizeDTLastHits()
165 , fhTRpcCluMemMulDTLastHits()
175 , fhNbDigiPerChan(NULL)
212 , fdChannelDeadtime(0.)
217 , fEnableMatchPosScaling(kTRUE)
218 , fEnableAvWalk(kFALSE)
220 , fCalParFileName(
"")
221 , fOutHstFileName(
"")
244 <<
"CbmTofCosmicClusterizer initializing... expect Digis in ns units! ";
263 LOG(info) <<
"Init() completed for " <<
iNSel <<
" triggers"
275 LOG(info) <<
"=> Get the digi parameters for tof";
276 LOG(warning) <<
"Return without action";
279 FairRunAna* ana = FairRunAna::Instance();
280 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
300 LOG(debug) <<
"CbmTofCosmicClusterizer::Exec => New event";
331 FairRootManager* fManager = FairRootManager::Instance();
333 if (NULL == fManager) {
334 LOG(error) <<
"CbmTofCosmicClusterizer::RegisterInputs => Could not find "
335 "FairRootManager!!!";
355 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"CbmTofDigi");
358 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"CbmTofDigi");
361 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"TofDigiExp");
364 fTofDigisColl = (TClonesArray*) fManager->GetObject(
"TofDigi");
367 LOG(error) <<
"CbmTofCosmicClusterizer::RegisterInputs => Could not get "
368 "the CbmTofDigi TClonesArray!!!";
375 LOG(info) <<
"CbmTofCosmicClusterizer::RegisterInputs => Could not get the "
376 "TofTrbHeader Object";
382 FairRootManager*
rootMgr = FairRootManager::Instance();
403 Bool_t isSimulation = kFALSE;
405 <<
"CbmTofCosmicClusterizer::InitParameters - Geometry, Mapping, ... ??";
408 FairRun* ana = FairRun::Instance();
409 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
412 if (
k14a > iGeoVersion) {
413 LOG(error) <<
"CbmTofCosmicClusterizer::InitParameters => Only compatible "
414 "with geometries after v14a !!!";
421 LOG(error) <<
"CbmTofCosmicClusterizer::InitParameters => Could not obtain "
422 "the CbmTofDigiPar ";
428 LOG(error) <<
"CbmTofCosmicClusterizer::InitParameters => Could not obtain "
429 "the CbmTofDigiBdfPar ";
433 rtdb->initContainers(ana->GetRunId());
435 LOG(info) <<
"CbmTofCosmicClusterizer::InitParameter: currently "
449 LOG(info) <<
" BuildCluster with MaxTimeDist " <<
fdMaxTimeDist
457 LOG(info) <<
"<I> Sel2Type = " <<
fSel2Id <<
", Sm " <<
fSel2Sm <<
", Det "
475 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
478 fvCPTOff[iSmType].resize(iNbSm * iNbRpc);
481 fvCPWalk[iSmType].resize(iNbSm * iNbRpc);
483 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
484 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
491 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
492 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] =
497 fvCPTOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
498 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
499 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
500 fvCPWalk[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
502 for (Int_t iCh = 0; iCh < iNbChan; iCh++) {
503 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
504 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
505 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
506 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
507 for (Int_t iSide = 0; iSide < nbSide; iSide++) {
508 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
510 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
512 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
514 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide].resize(
517 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide][iWx] = 0.;
525 LOG(info) <<
"CbmTofCosmicClusterizer::InitCalibParameter: defaults set";
535 <<
"CbmTofCosmicClusterizer::InitCalibParameter: read histos from "
543 LOG(fatal) <<
"CbmTofCosmicClusterizer::InitCalibParameter: "
552 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
556 (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iSmType));
559 TDirectory* curdir = gDirectory;
561 gDirectory->cd(oldir->GetPath());
563 gDirectory->cd(curdir->GetPath());
565 LOG(info) <<
"Svel histogram not found for module type " << iSmType;
568 for (Int_t iPar = 0; iPar < 4; iPar++) {
569 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(
570 Form(
"cl_SmT%01d_Fpar%1d", iSmType, iPar));
571 if (NULL != hFparcur) {
572 gDirectory->cd(oldir->GetPath());
574 gDirectory->cd(curdir->GetPath());
578 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
579 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
583 if (Vscal == 0.) Vscal = 1.;
589 LOG(info) <<
"Modify " << iSmType << iSm << iRpc <<
" Svel by "
593 TH2F* htempPos_pfx = (TH2F*) gDirectory->FindObjectAny(
594 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
595 TH2F* htempTOff_pfx = (TH2F*) gDirectory->FindObjectAny(
596 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
597 TH1D* htempTot_Mean = (TH1D*) gDirectory->FindObjectAny(
598 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
599 TH1D* htempTot_Off = (TH1D*) gDirectory->FindObjectAny(
600 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
601 if (NULL != htempPos_pfx && NULL != htempTOff_pfx
602 && NULL != htempTot_Mean && NULL != htempTot_Off) {
604 Int_t iNbinTot = htempTot_Mean->GetNbinsX();
605 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
606 Double_t YMean = ((TProfile*) htempPos_pfx)
607 ->GetBinContent(iCh + 1);
609 ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
613 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
614 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
616 for (Int_t iSide = 0; iSide < 2; iSide++) {
617 Double_t TotMean = htempTot_Mean->GetBinContent(
618 iCh * 2 + 1 + iSide);
619 if (0.001 < TotMean) {
620 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
623 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
624 htempTot_Off->GetBinContent(iCh * 2 + 1 + iSide);
627 if (5 == iSmType || 8 == iSmType) {
628 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
629 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
630 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
632 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
633 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
636 LOG(debug) <<
"CbmTofCosmicClusterizer::InitCalibParameter:"
637 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc "
638 << iRpc <<
" Ch " << iCh
639 << Form(
": YMean %f, TMean %f", YMean, TMean) <<
" -> "
642 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
643 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
646 <<
", NbinTot " << iNbinTot;
648 TH1D* htempWalk0 = (TH1D*) gDirectory->FindObjectAny(
649 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
654 TH1D* htempWalk1 = (TH1D*) gDirectory->FindObjectAny(
655 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
660 if (NULL != htempWalk0
661 && NULL != htempWalk1) {
662 LOG(debug) <<
"Initialize Walk correction for "
663 << Form(
" SmT%01d_sm%03d_rpc%03d_Ch%03d",
669 LOG(error) <<
"CbmTofCosmicClusterizer::InitCalibParameter: "
670 "Inconsistent Walk histograms";
672 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin] =
673 htempWalk0->GetBinContent(iBin + 1);
674 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
675 htempWalk1->GetBinContent(iBin + 1);
677 " SmT%01d_sm%03d_rpc%03d_Ch%03d bin %d walk %f ",
683 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin]);
684 if (5 == iSmType || 8 == iSmType) {
685 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
686 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin];
692 LOG(warning) <<
" Calibration histos "
693 << Form(
"cl_SmT%01d_sm%03d_rpc%03d_XXX",
699 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
700 TH1D* htmpDelTof = (TH1D*) gDirectory->FindObjectAny(
701 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
706 if (NULL == htmpDelTof) {
707 LOG(debug) <<
" Histos "
708 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
716 LOG(debug) <<
" Load DelTof from histos "
717 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
724 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] +=
725 htmpDelTof->GetBinContent(iBx + 1);
730 gDirectory->cd(oldir->GetPath());
731 TH1D* h1DelTof = (TH1D*) htmpDelTof->Clone(
732 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
738 LOG(debug) <<
" copy histo " << h1DelTof->GetName()
739 <<
" to directory " << oldir->GetName();
741 gDirectory->cd(curdir->GetPath());
751 <<
"CbmTofCosmicClusterizer::InitCalibParameter: initialization done";
756 LOG(info) <<
"CbmTofCosmicClusterizer::LoadGeometry starting for "
763 LOG(info) <<
"Digi Parameter container contains " << iNrOfCells <<
" cells.";
764 for (Int_t icell = 0; icell < iNrOfCells; ++icell) {
780 LOG(debug) <<
"-I- InitPar " << icell <<
" Id: " << Form(
"0x%08x", cellId)
781 <<
" " << cell <<
" tmcs: " << smtype <<
" " << smodule <<
" "
782 << module <<
" " << cell <<
" x=" << Form(
"%6.2f",
x)
783 <<
" y=" << Form(
"%6.2f",
y) <<
" z=" << Form(
"%6.2f", z)
784 <<
" dx=" << dx <<
" dy=" << dy;
787 gGeoManager->FindNode(
789 LOG(debug2) << Form(
" Node at (%6.1f,%6.1f,%6.1f) : 0x%p",
798 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
803 LOG(info) <<
" DetIndx " << iDetIndx <<
"(" << iNbDet <<
"), SmType "
804 << iSmType <<
", SmId " << iSmId <<
", RpcId " << iRpcId
805 <<
" => UniqueId " << Form(
"0x%08x ", iUniqueId)
806 << Form(
" Svel %6.6f ",
814 LOG(debug3) <<
" Cell " << iCell << Form(
" 0x%08x ", iUCellId)
831 fvdX.resize(iNbSmTypes);
832 fvdY.resize(iNbSmTypes);
839 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
846 fvdX[iSmType].resize(iNbRpc);
847 fvdY[iSmType].resize(iNbRpc);
848 fvdDifX[iSmType].resize(iNbRpc);
849 fvdDifY[iSmType].resize(iNbRpc);
851 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
854 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
859 LOG(warning) <<
"CbmTofCosmicClusterizer::LoadGeometry: StoreDigi "
861 << Form(
"SmTy %3d, Sm %3d, NbRpc %3d, Rpc, %3d ",
868 <<
"CbmTofCosmicClusterizer::LoadGeometry: StoreDigi with "
870 " %3d %3d %3d %3d %5d ", iSmType, iSm, iNbRpc, iRpc, iNbChan);
871 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
872 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
873 fvLastHits[iSmType][iSm][iRpc].resize(iNbChan);
882 LOG(info) <<
"CbmTofCosmicClusterizer::DeleteGeometry starting";
886 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
889 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
890 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
912 new TH1I(
"TofCosmicClus_ClustBuildTime",
913 "Time needed to build clusters in each event; Time [s]",
930 Double_t YSCAL = 50.;
935 LOG(warning) <<
"No DigiPar for SmType "
936 << Form(
"%d, 0x%08x", iS, iUCellId);
942 new TH2F(Form(
"cl_SmT%01d_Pos", iS),
943 Form(
"Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
951 Double_t TSumMax = 1.E3;
954 new TH2F(Form(
"cl_SmT%01d_TOff", iS),
955 Form(
"Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
964 (TProfile*) gDirectory->FindObjectAny(Form(
"cl_SmT%01d_Svel", iS));
965 if (NULL == hSvelcur) {
967 Form(
"cl_SmT%01d_Svel", iS),
968 Form(
"Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
979 for (Int_t iPar = 0; iPar < 4; iPar++) {
980 TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(
981 Form(
"cl_SmT%01d_Fpar%1d", iS, iPar));
982 if (NULL == hFparcur) {
983 LOG(info) <<
"Histo " << Form(
"cl_SmT%01d_Fpar%1d", iS, iPar)
984 <<
" not found, recreate ...";
986 Form(
"cl_SmT%01d_Fpar%1d", iS, iPar),
987 Form(
"Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
994 fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
1000 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1002 new TH2F(Form(
"cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
1003 Form(
"Clu position of SmType %d under Selector %02d; Sm+Rpc# "
1014 new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
1015 Form(
"Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
1026 new TH2F(Form(
"cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
1027 Form(
"Clu TimeZero in SmType %d under Selector %02d; Event# "
1042 LOG(info) <<
" Define Clusterizer histos for " << iNbDet <<
" detectors ";
1071 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1083 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1086 LOG(info) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType <<
", SmId "
1087 << iSmId <<
", RpcId " << iRpcId <<
" => UniqueId "
1088 << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1099 LOG(warning) << Form(
1100 "missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
1105 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
1107 "Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1",
1119 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
1120 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts",
1129 Form(
"cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
1130 Form(
"Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)",
1139 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
1140 Form(
"Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
1141 "#DeltaT (ns)); counts",
1150 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1151 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1164 Form(
"cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1165 Form(
"Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1177 Double_t YSCAL = 50.;
1181 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1183 "Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]",
1195 Form(
"cl_SmT%01d_sm%03d_rpc%03d_PosEvol", iSmType, iSmId, iRpcId),
1196 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d; Analysis Time "
1208 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TimeEvol", iSmType, iSmId, iRpcId),
1209 Form(
"Clu time of Rpc #%03d in Sm %03d of type %d; Analysis Time [s]; dT "
1221 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1222 Form(
"Clu position difference of Rpc #%03d in Sm %03d of type "
1223 "%d; Strip []; #Deltaypos(clu) [cm]",
1235 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1236 Form(
"Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1237 "%d; Strip []; #Deltaypos(mat) [cm]",
1248 Double_t TSumMax = 1.E3;
1251 Form(
"cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1253 "Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]",
1265 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1266 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1267 "[]; #DeltaTOff(clu) [ns]",
1279 Form(
"cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1280 Form(
"Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1281 "[]; #DeltaTOff(mat) [ns]",
1293 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1295 "Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]",
1307 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1309 "Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [a.u.]",
1321 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1323 "Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]",
1336 Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1337 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1346 Form(
"cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1347 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1358 for (Int_t iSide = 0; iSide < 2; iSide++) {
1360 new TH2D(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
1366 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
1387 LOG(info) <<
" Define Clusterizer monitoring histos ";
1390 new TH2F(Form(
"hCluMulCorDutSel"),
1391 Form(
"Cluster Multiplicity Correlation of Dut %d%d%d with Sel "
1392 "%d%d%d; Mul(Sel); Mul(Dut)",
1407 new TH1I(
"Clus_DigSpacDifClust",
1408 "Space difference along channel direction between Digi pairs on "
1409 "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
1414 new TH1I(
"Clus_DigTimeDifClust",
1415 "Time difference between Digi pairs on adjacent channels; "
1416 "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1421 "Clus_DigDistClust",
1422 "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
1423 "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1431 new TH2I(
"Clus_ClustSizeDifX",
1432 "Position difference between Point and Hit as function of Cluster "
1433 "Size; Cluster Size [Strips]; dX [cm]",
1441 new TH2I(
"Clus_ClustSizeDifY",
1442 "Position difference between Point and Hit as function of Cluster "
1443 "Size; Cluster Size [Strips]; dY [cm]",
1451 "Position difference between Point and Hit as "
1452 "function of Channel dif; Ch Dif [Strips]; dX [cm]",
1460 "Position difference between Point and Hit as "
1461 "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1469 "How many time per event the 2 digis on a channel "
1470 "were of the same side ; Counts/Event []",
1475 "Nb of Digis per channel; Nb Digis []",
1484 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1485 fhSeldT[iSel] =
new TH2F(Form(
"cl_dt_Sel%02d", iSel),
1486 Form(
"Selector time %02d; dT [ns]", iSel),
1510 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1519 LOG(warning) <<
"No DigiPar for Det " << Form(
"0x%08x", iUCellId);
1522 LOG(debug1) <<
"DetIndx " << iDetIndx <<
", SmType " << iSmType
1523 <<
", SmId " << iSmId <<
", RpcId " << iRpcId
1525 << Form(
"(0x%08x, 0x%08x)", iUniqueId, iUCellId) <<
", dx "
1546 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
1548 new TH1F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul",
1553 Form(
"Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1554 "under Selector %02d; M []; cnts",
1564 LOG(fatal) <<
" Histo not generated !";
1566 Double_t YSCAL = 50.;
1570 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos",
1575 Form(
"Clu position of Rpc #%03d in Sm %03d of type %d under "
1576 "Selector %02d; Strip []; ypos [cm]",
1588 Double_t TSumMax = 1.E4;
1591 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff",
1596 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1597 "Selector %02d; Strip []; TOff [ns]",
1611 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot",
1616 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1617 "Selector %02d; StripSide []; TOT [a.u.]",
1630 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size",
1635 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1636 "Selector %02d; Strip []; size [strips]",
1650 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk",
1655 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel",
1669 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
1674 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; DistSel; T-TSel",
1690 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY",
1695 Form(
"SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1709 new TH3F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2",
1714 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2",
1736 for (Int_t iSide = 0; iSide < 2; iSide++) {
1738 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk",
1745 Form(
"Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk",
1762 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH",
1767 Form(
"Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1768 "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1781 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH",
1786 Form(
"Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1787 "Selector %02d; log(#DeltaT (ns)); TOT [a.u.]",
1800 new TH2F(Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH",
1805 Form(
"Clu size of Rpc #%03d in Sm %03d of type %d under "
1806 "Selector %02d; log(#DeltaT (ns)); size [strips]",
1819 Form(
"cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH",
1824 Form(
"Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1825 "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1841 new TH1I(
"Clus_TofHitPerTrk",
1842 "Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []",
1848 "Distribution of the Number of MCPoints associated "
1849 "to each TofHit; Nb MCPoint []",
1855 new TH1I(
"Clus_TofTimeResClust",
1856 "Time resolution for TofHits containing Digis from a single MC "
1857 "Track; t(1st Mc Point) -tTofHit [ns]",
1862 new TH2I(
"Clus_TofTimeResClustB",
1863 "Time resolution for TofHits containing Digis from a single MC "
1864 "Track; (1st Mc Point) -tTofHit [ns]",
1872 new TH2I(
"Clus_TofTimePtVsHit",
1873 "Time resolution for TofHits containing Digis from a single MC "
1874 "Track; t(1st Mc Point) -tTofHit [ns]",
1883 new TH1I(
"Clus_TofTimeResClust",
1884 "Time resolution for TofHits containing Digis from a single "
1885 "TofPoint; tMcPoint -tTofHit [ns]",
1890 new TH2I(
"Clus_TofTimeResClustB",
1891 "Time resolution for TofHits containing Digis from a single "
1892 "TofPoint; tMcPoint -tTofHit [ns]",
1900 "Time resolution for TofHits containing Digis "
1901 "from a single TofPoint; tMcPoint -tTofHit [ps]",
1910 "Cluster Size distribution; Cluster Size [Strips]",
1915 new TH2I(
"Clus_ClusterSizeType",
1916 "Cluster Size distribution in each (SM type, Rpc) pair; Cluster "
1917 "Size [Strips]; 10*SM Type + Rpc Index []",
1927 "Number of MC tracks generating the cluster; MC Tracks multiplicity []",
1932 "Clus_ClusterSizeMulti",
1933 "Cluster Size distribution as function of Number of MC tracks generating "
1934 "the cluster; Cluster Size [Strips]; MC tracks mul. []",
1942 "Position of Clusters with only 1 MC tracks "
1943 "generating the cluster; X [cm]; Y [cm]",
1951 "Position of Clusters with >1 MC tracks "
1952 "generating the cluster; X [cm]; Y [cm]",
1960 "Clus_AllTrkMulPos",
1961 "Position of all clusters generating the cluster; X [cm]; Y [cm]",
1969 new TH2D(
"Clus_MultiTrkProbPos",
1970 "Probability of having a cluster with multiple tracks as "
1971 "function of position; X [cm]; Y [cm]; Prob. [%]",
1989 + (
fStop.GetNanoSec() -
fStart.GetNanoSec()) / 1e9);
1993 gGeoManager->CdTop();
1995 if (0 < iNbTofHits) {
1998 Double_t dTTrig[
iNSel];
2001 Double_t ddXdZ[
iNSel];
2002 Double_t ddYdZ[
iNSel];
2003 Double_t dSel2dXdYMin[
iNSel];
2009 LOG(debug) <<
"CbmTofCosmicClusterizer::FillHistos: Muls: "
2014 for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
2029 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2031 if (NULL == pHit)
continue;
2039 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
2042 Int_t iDetIndx = it->second;
2051 << Form(
" Addr 0x%08x, t %f, tspill %f ",
2058 &&
fvLastHits[iSmType][iSm][iRpc][iCh].size() == 0)
2059 LOG(fatal) << Form(
" <E> hit not stored in memory for TSRC %d%d%d%d",
2067 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2076 LOG(warning) << Form(
"Invalid time ordering in ev %8.0f in list of "
2077 "size %lu for TSRC %d%d%d%d: Delta t %f ",
2087 while (
fvLastHits[iSmType][iSm][iRpc][iCh].size() > 2.
2088 ||
fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime()
2094 <<
" pop from list size "
2095 <<
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2096 << Form(
" outdated hits for ev %8.0f in TSRC %d%d%d%d",
2103 " with tHit - tLast %f ",
2105 -
fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime())
2111 "Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
2119 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
2120 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
2121 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
2126 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2129 Double_t dTotSum = 0.;
2130 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2134 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
2140 std::list<CbmTofHit*>::iterator itL =
2144 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2148 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()));
2150 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2153 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()), dTotSum);
2163 Double_t dMatXYScal =
2166 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2168 if (NULL == pHit)
continue;
2175 Double_t TotSum = 0.;
2176 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2180 if (iDigInd0 < fTofCalDigisColl->GetEntries()) {
2183 TotSum += pDig0->
GetTot();
2198 LOG(debug) <<
"CbmTofCosmicClusterizer::FillHistos: Sel2Mul: "
2206 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2207 BSel[iSel] = kFALSE;
2215 dSel2dXdYMin[iSel] = 1.E300;
2221 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2223 LOG(debug) <<
"selector 0: DutMul "
2225 << iDutMul <<
", Sel2Mul " << iSel2Mul
2226 <<
" TRef: " <<
dTRef;
2229 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2231 if (NULL == pHit)
continue;
2234 if (pHit->
GetTime() < dTTrig[iSel]) {
2235 dTTrig[iSel] = pHit->
GetTime();
2242 "Found selector 0 with mul %d from 0x%08x at %f ",
2252 for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2254 LOG(debug) <<
"selector 1: RefMul "
2256 << iRefMul <<
", Sel2Mul " << iSel2Mul;
2258 LOG(debug1) <<
"Found selector 1";
2260 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2262 if (NULL == pHit)
continue;
2265 if (pHit->
GetTime() < dTTrig[iSel]) {
2266 dTTrig[iSel] = pHit->
GetTime();
2273 "Found selector 1 with mul %d from 0x%08x at %f ",
2281 LOG(info) <<
"CbmTofCosmicClusterizer::FillHistos: selection not "
2287 if (
pRef == NULL)
return kFALSE;
2288 dTTrig[iSel] =
dTRef;
2294 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2296 BSel[iSel] = kFALSE;
2298 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2300 if (NULL == pHit)
continue;
2303 Double_t dzscal = 1.;
2305 dzscal = pHit->
GetZ() / pTrig[iSel]->
GetZ();
2306 Double_t dSEl2dXdz = (pHit->
GetX() - pTrig[iSel]->
GetX())
2307 / (pHit->
GetZ() - pTrig[iSel]->
GetZ());
2308 Double_t dSEl2dYdz = (pHit->
GetY() - pTrig[iSel]->
GetY())
2309 / (pHit->
GetZ() - pTrig[iSel]->
GetZ());
2312 TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(),
2315 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2319 TMath::Sqrt(dSEl2dXdz * dSEl2dXdz + dSEl2dYdz * dSEl2dYdz);
2320 if (dX2Y2 < dSel2dXdYMin[iSel]) {
2321 ddXdZ[iSel] = dSEl2dXdz;
2322 ddYdZ[iSel] = dSEl2dYdz;
2323 dSel2dXdYMin[iSel] = dX2Y2;
2333 UInt_t uTriggerPattern = 0;
2337 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2345 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
2348 for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
2349 if (uTriggerPattern & (0x1 << uChannel)) {
2358 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2360 if (NULL == pHit)
continue;
2363 std::map<UInt_t, UInt_t>::iterator it =
fDetIdIndexMap.find(iDetId);
2366 Int_t iDetIndx = it->second;
2377 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2393 LOG(error) <<
"Invalid Channel Pointer for ChId "
2394 << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
2398 gGeoManager->FindNode(
2401 LOG(debug1) <<
"Hit info: "
2402 << Form(
" 0x%08x %d %f %f %f %f %f %d",
2413 hitpos[0] = pHit->
GetX();
2414 hitpos[1] = pHit->
GetY();
2415 hitpos[2] = pHit->
GetZ();
2416 Double_t hitpos_local[3];
2417 TGeoNode* cNode = gGeoManager->GetCurrentNode();
2418 gGeoManager->MasterToLocal(hitpos, hitpos_local);
2419 LOG(debug1) << Form(
2420 " MasterToLocal for node %p: (%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
2430 (Double_t) iCh, hitpos_local[1]);
2439 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2450 LOG(debug1) <<
" TofDigiMatchColl entries:"
2454 LOG(error) <<
" Inconsistent DigiMatches for Hitind " << iHitInd
2459 LOG(debug1) <<
" got " << digiMatch->
GetNofLinks() <<
" matches for iCh "
2460 << iCh <<
" at iHitInd " << iHitInd;
2465 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2469 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2471 std::list<CbmTofHit*>::iterator itL =
2475 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2479 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2485 Double_t TotSum = 0.;
2486 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2490 if (iDigInd0 < fTofCalDigisColl->GetEntries()) {
2492 TotSum += pDig0->
GetTot();
2495 Double_t dMeanTimeSquared = 0.;
2496 Double_t dNstrips = 0.;
2498 Double_t dDelTof = 0.;
2499 Double_t dTcor[
iNSel];
2500 Double_t dTTcor[
iNSel];
2501 Double_t dZsign[
iNSel];
2502 Double_t dzscal = 1.;
2503 Double_t dDist = 0.;
2505 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
2510 (digiMatch->
GetLink(iLink + 1)).GetIndex();
2513 if (iDigInd0 < fTofCalDigisColl->GetEntries()
2517 if ((Int_t) pDig0->
GetType() != iSmType) {
2518 LOG(error) << Form(
" Wrong Digi SmType for Tofhit %d in iDetIndx "
2519 "%d, Ch %d with %3.0f strips at Indx %d, %d",
2527 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch "
2530 << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
2531 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side "
2532 << pDig1->
GetSide() <<
", StripSide "
2533 << (Double_t) iCh * 2. + pDig1->
GetSide() <<
", Tot0 "
2545 if (iCh0 != iCh1 || iS0 == iS1) {
2547 " MT2 for Tofhit %d in iDetIndx %d, Ch %d from %3.0f strips: ",
2552 << Form(
" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ",
2557 << Form(
" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ",
2567 " Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
2568 "from %3.0f strips: %d, %d, %d, %d",
2587 dMeanTimeSquared += TMath::Power(
2595 Double_t dCorWeigth = 1.;
2600 TMath::Log10(0.5 * (pDig0->
GetTot() + pDig1->
GetTot())), dTDigi);
2603 dCorWeigth * dTDigi);
2607 if (0 == pDig0->
GetSide()) dDelPos *= -1.;
2609 pDig0->
GetChannel(), dCorWeigth * (dDelPos - hitpos_local[1]));
2622 LOG(debug1) <<
" fhRpcCluTot: Digi 0 " << iDigInd0 <<
": Ch "
2625 << (Double_t) iCh * 2. + pDig0->
GetSide() <<
" Digi 1 "
2626 << iDigInd1 <<
": Ch " << pDig1->
GetChannel() <<
", Side "
2627 << pDig1->
GetSide() <<
", StripSide "
2628 << (Double_t) iCh * 2. + pDig1->
GetSide();
2632 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2634 if (NULL == pHit || NULL == pTrig[iSel]) {
2635 LOG(info) <<
" invalid pHit, iSel " << iSel <<
", iDetIndx "
2645 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2647 std::list<CbmTofHit*>::iterator itL =
2651 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2655 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2658 TMath::Log10(pHit->
GetTime() - (*itL)->GetTime()),
2664 dzscal = pHit->
GetZ() / pTrig[iSel]->
GetZ();
2666 pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(),
2667 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY());
2669 dDist = TMath::Sqrt(
2670 TMath::Power(pHit->
GetX() - pTrig[iSel]->
GetX(), 2.)
2671 + TMath::Power(pHit->
GetY() - pTrig[iSel]->
GetY(), 2.)
2672 + TMath::Power(pHit->
GetZ() - pTrig[iSel]->
GetZ(), 2.));
2675 pHit->
GetZ() < pTrig[iSel]->
GetZ() ? dZsign[iSel] = -1.
2676 : dZsign[iSel] = 1.;
2681 dDelTof * dZsign[iSel];
2687 TMath::Power(pHit->
GetX() - dzscal * pTrig[iSel]->
GetX(),
2690 pHit->
GetY() - dzscal * pTrig[iSel]->
GetY(), 2.))
2696 - (pTrig[iSel]->
GetX()
2698 * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2702 - (pTrig[iSel]->
GetY()
2704 * (pHit->
GetZ() - (pTrig[iSel]->
GetZ()))),
2728 Double_t dTentry = dDist;
2730 if (iBx < 0) iBx = 0;
2735 dTentry - ((Double_t) iBx) * dBinWidth;
2737 dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
2738 Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
2739 Double_t w1 = 1. - w0;
2740 if (iBx1 < 0) iBx1 = 0;
2743 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
2744 +
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel]
2748 << Form(
" DelTof for SmT %d, Sm %d, R %d, T %d, dTRef "
2749 "%6.1f, Bx %d, Bx1 %d, DTe %6.1f -> DelT %6.1f",
2754 dTRef - dTTrig[iSel],
2762 dDelTof * dZsign[iSel];
2764 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel];
2769 "TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
2770 "Ch %d,%d, S %d,%d Tcor %8.3f, LocT %6.1f, W-ent: "
2792 << Form(
" Inconsistent walk histograms -> debugging "
2793 "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
2803 << Form(
"TRpcCluWalk values side %d: %5.2f, %7.3f, %6.3f, "
2804 " side %d: %5.2f, %7.3f, %6.3f",
2808 - TMath::Floor(pDig0->
GetTime() / 1000.) * 1000.,
2810 + (1. - 2. * pDig0->
GetSide()) * hitpos_local[1]
2815 - TMath::Floor(pDig1->
GetTime() / 1000.) * 1000.,
2817 + (1. - 2. * pDig1->
GetSide()) * hitpos_local[1]
2857 hitpos[0] = pHit->
GetX() - dzscal * pTrig[iSel]->
GetX()
2859 hitpos[1] = pHit->
GetY() - dzscal * pTrig[iSel]->
GetY()
2861 hitpos[2] = pHit->
GetZ();
2862 gGeoManager->MasterToLocal(
2863 hitpos, hitpos_local);
2868 (pHit->
GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
2876 <<
"CbmTofCosmicClusterizer::FillHistos: invalid digi index "
2877 << iDetIndx <<
" digi0,1" << iDigInd0 <<
", " << iDigInd1
2886 Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
2888 Double_t dTrms = TMath::Sqrt(dVar);
2889 LOG(debug) << Form(
" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
2890 "%3.0f strips: %6.3f ns",
2900 LOG(debug1) <<
" Fill Time of iDetIndx " << iDetIndx <<
", hitAddr "
2902 " %08x, y = %5.2f", pHit->
GetAddress(), hitpos_local[1])
2905 if (TMath::Abs(hitpos_local[1])
2909 dDist = TMath::Sqrt(TMath::Power(pHit->
GetX() -
pRef->GetX(), 2.)
2910 + TMath::Power(pHit->
GetY() -
pRef->GetY(), 2.)
2911 + TMath::Power(pHit->
GetZ() -
pRef->GetZ(), 2.));
2914 Double_t dZsgn = 1.;
2915 if (pHit->
GetZ() <
pRef->GetZ()) dZsgn = -1.;
2924 for (Int_t iSel = 0; iSel <
iNSel; iSel++)
2926 LOG(debug1) <<
" TRpcCluTOff " << iDetIndx <<
", Sel " << iSel
2927 << Form(
", Dt %7.3f, LHsize %lu ",
2928 (pHit->
GetTime() - dTTrig[iSel]),
2932 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2934 std::list<CbmTofHit*>::iterator itL =
2938 iH <
fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2942 << Form(
" %f,", pHit->
GetTime() - (*itL)->GetTime());
2949 (pHit->
GetTime() - dTTrig[iSel])
2951 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size()
2953 std::list<CbmTofHit*>::iterator itL =
2956 for (Int_t iH = 0; iH < 1; iH++) {
2959 Double_t dTsinceLast = pHit->
GetTime() - (*itL)->GetTime();
2961 LOG(fatal) << Form(
"Invalid Time since last hit on channel "
2962 "TSRC %d%d%d%d: %f > %f",
2971 TMath::Log10(dTsinceLast),
2972 (pHit->
GetTime() - dTTrig[iSel]));
2974 TMath::Log10(dTsinceLast),
2975 fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1);
2985 LOG(debug1) <<
"CbmTofCosmicClusterizer::FillHistos: "
2986 << Form(
" %3d %3d %3lu ",
2991 for (UInt_t uCluster = 0;
2994 LOG(debug2) <<
"CbmTofCosmicClusterizer::FillHistos: "
2995 << Form(
" %3d %3d %3d ", iSmType, iRpc, uCluster);
3005 fvdDifX[iSmType][iRpc][uCluster]);
3007 fvdDifY[iSmType][iRpc][uCluster]);
3011 fvdDifX[iSmType][iRpc][uCluster]);
3013 fvdDifY[iSmType][iRpc][uCluster]);
3019 fvdX[iSmType][iRpc].clear();
3020 fvdY[iSmType][iRpc].clear();
3021 fvdDifX[iSmType][iRpc].clear();
3022 fvdDifY[iSmType][iRpc].clear();
3033 TDirectory* oldir = gDirectory;
3055 LOG(debug) <<
"Write triggered Histos for Det Ind " << iDetIndx
3057 for (Int_t iSel = 0; iSel <
iNSel;
3071 Int_t iSmAddr = iUniqueId &
ModMask;
3082 LOG(info) <<
"WriteHistos: No entries in Walk histos for "
3083 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
3087 TH2* htempPos = NULL;
3088 TProfile* htempPos_pfx = NULL;
3089 TH1* htempPos_py = NULL;
3090 TProfile* htempTOff_pfx = NULL;
3091 TH1* htempTOff_px = NULL;
3092 TProfile* hAvPos_pfx = NULL;
3093 TProfile* hAvTOff_pfx = NULL;
3096 TH2* htempTot = NULL;
3097 TProfile* htempTot_pfx = NULL;
3098 TH1* htempTot_Mean = NULL;
3099 TH1* htempTot_Off = NULL;
3111 htempTOff_pfx = htempTOff->ProfileX(
3113 htempTOff_px = htempTOff->ProjectionX(
3165 if (NULL == htempPos_pfx) {
3166 LOG(info) <<
"WriteHistos: Projections not available, continue ";
3170 htempTot_Mean = htempTot_pfx->ProjectionX(
"_Mean");
3171 htempTot_Off = htempTot_pfx->ProjectionX(
"_Off");
3173 htempPos_pfx->SetName(
3174 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
3175 htempTOff_pfx->SetName(
3176 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
3177 htempTot_pfx->SetName(
3178 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
3179 htempTot_Mean->SetName(
3180 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
3181 htempTot_Off->SetName(
3182 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
3183 hAvPos_pfx->SetName(Form(
"cl_CorSmT%01d_Pos_pfx", iSmType));
3184 hAvTOff_pfx->SetName(Form(
"cl_CorSmT%01d_TOff_pfx", iSmType));
3188 htempTot_Off->Reset();
3190 Int_t nbins = htempTot->GetNbinsX();
3191 for (
int i = 0;
i < nbins;
i++) {
3192 hbins[
i] = htempTot->ProjectionY(Form(
"bin%d",
i + 1),
i + 1,
i + 1);
3194 Int_t iBmax = hbins[
i]->GetMaximumBin();
3195 TAxis* xaxis = hbins[
i]->GetXaxis();
3196 Double_t Xmax = xaxis->GetBinCenter(iBmax);
3198 XOff = (Double_t)(Int_t) XOff;
3199 if (XOff < 0) XOff = 0;
3200 htempTot_Off->SetBinContent(
i + 1, XOff);
3201 Double_t Xmean = htempTot_Mean->GetBinContent(
i + 1);
3203 LOG(warning) <<
"Inconsistent Tot numbers for "
3205 "SmT%01d_sm%03d_rpc%03d bin%d: mean %f, Off %f",
3213 htempTot_Mean->SetBinContent(
i + 1, (Xmean - XOff));
3214 if (htempTot_Mean->GetBinContent(
i + 1) != (Xmean - XOff))
3216 <<
"Tot numbers not stored properly for "
3217 << Form(
"SmT%01d_sm%03d_rpc%03d bin%d: mean %f, target %f",
3222 htempTot_Mean->GetBinContent(
i + 1),
3225 htempPos_pfx->Write();
3226 htempTOff_pfx->Write();
3228 htempTot_Mean->Write();
3229 htempTot_Off->Write();
3235 LOG(info) <<
"WriteHistos: restore Offsets and Gains and save Walk for "
3236 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3237 <<
" and calSmAddr = "
3239 htempPos_pfx->Reset();
3240 htempTOff_pfx->Reset();
3241 htempTot_Mean->Reset();
3242 htempTot_Off->Reset();
3243 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3245 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3246 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3247 Double_t TMean = 0.5
3248 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3249 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3250 htempPos_pfx->Fill(iCh, YMean);
3251 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3252 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
3253 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
3254 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
3255 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
3258 htempTOff_pfx->Fill(iCh, TMean);
3260 for (Int_t iSide = 0; iSide < 2; iSide++) {
3261 htempTot_Mean->SetBinContent(
3262 iCh * 2 + 1 + iSide,
3266 htempTot_Off->SetBinContent(
3267 iCh * 2 + 1 + iSide,
3268 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3272 LOG(debug1) <<
" Offset, gain restoring done ... ";
3273 htempPos_pfx->Write();
3274 htempTOff_pfx->Write();
3276 htempTot_Mean->Write();
3277 htempTot_Off->Write();
3279 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3281 TDirectory* curdir = gDirectory;
3283 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3284 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3289 gDirectory->cd(curdir->GetPath());
3290 if (NULL != hCorDelTof) {
3291 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3292 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3297 hCorDelTofout->Write();
3299 LOG(debug) <<
" No CorDelTof histo "
3300 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3314 LOG(info) <<
"restore Offsets and Gains and update Walk for "
3315 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3339 if (NULL == h2tmp0) {
3340 LOG(info) << Form(
"WriteHistos: Walk histo not available for SmT "
3341 "%d, Sm %d, Rpc %d, Ch %d",
3348 Int_t iNEntries = h2tmp0->GetEntries();
3350 LOG(info) << Form(
" Update Walk correction for SmT %d, Sm %d, Rpc "
3351 "%d, Ch %d, Sel%d: Entries %d",
3361 if (-1 < iNEntries) {
3363 h2tmp0->ProfileX(
"_pfx", 1, h2tmp0->GetNbinsY());
3365 h2tmp1->ProfileX(
"_pfx", 1, h2tmp1->GetNbinsY());
3366 TH1D* h1tmp0 = h2tmp0->ProjectionX(
"_px", 1, h2tmp0->GetNbinsY());
3367 TH1D* h1tmp1 = h2tmp1->ProjectionX(
"_px", 1, h2tmp1->GetNbinsY());
3370 TH1D* h1ytmp1 = h2tmp1->ProjectionY(
"_py", 1,
nbClWalkBinX);
3371 Double_t dWMean0 = h1ytmp0->GetMean();
3372 Double_t dWMean1 = h1ytmp1->GetMean();
3373 Double_t dWMean = 0.5 * (dWMean0 + dWMean1);
3376 if (5 == iSmType || 8 == iSmType)
3382 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin
3383 && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3386 (((TProfile*) htmp0)->GetBinContent(iWx + 1)
3387 + ((TProfile*) htmp1)->GetBinContent(iWx + 1))
3389 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3391 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3396 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin
3397 && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3399 ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3401 ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3402 Double_t dWcor = 0.5 * (dWcor0 + dWcor1);
3403 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3405 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3408 if (iCh == 10 && iSmType == 0 && iSm == 1
3409 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
3411 <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc
3412 <<
"), Rpc " << iRpc <<
", Bin " << iWx <<
", "
3413 << h1tmp0->GetBinContent(iWx + 1) <<
" cts: "
3414 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]
3416 << ((TProfile*) htmp0)->GetBinContent(iWx + 1)
3417 <<
" - " << dWMean0 <<
" -> " << dWcor - dWMean0
3419 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
3421 << ((TProfile*) htmp1)->GetBinContent(iWx + 1)
3422 <<
" - " << dWMean1 <<
" -> " << dWcor - dWMean1;
3426 if (h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin
3427 && h1tmp1->GetBinContent(iWx + 1) >
WalkNHmin) {
3429 ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3431 ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3433 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3435 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3438 if (iCh == 10 && iSmType == 0
3439 && h1tmp0->GetBinContent(iWx + 1) >
WalkNHmin)
3441 <<
"Update Walk Sm = " << iSm <<
"(" << iNbRpc
3442 <<
"), Rpc " << iRpc <<
", Bin " << iWx <<
", "
3443 << h1tmp0->GetBinContent(iWx + 1) <<
" cts: "
3444 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]
3446 << ((TProfile*) htmp0)->GetBinContent(iWx + 1)
3447 <<
" - " << dWMean0 <<
" -> " << dWcor0 - dWMean0
3449 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
3451 << ((TProfile*) htmp1)->GetBinContent(iWx + 1)
3452 <<
" - " << dWMean1 <<
" -> " << dWcor1 - dWMean1;
3462 h1tmp0->SetBinContent(
3463 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3464 h1tmp1->SetBinContent(
3465 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3469 && h1tmp0->GetBinContent(iWx + 1)
3470 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3471 h1tmp0->SetBinContent(
3473 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3477 <<
"writing not successful for " << h1tmp0->GetName()
3478 <<
", attempts left: " << iTry <<
", iWx " << iWx
3479 <<
", got " << h1tmp0->GetBinContent(iWx + 1)
3481 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3485 && h1tmp1->GetBinContent(iWx + 1)
3486 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]) {
3487 h1tmp1->SetBinContent(
3489 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3493 <<
"writing not successful for " << h1tmp1->GetName()
3494 <<
", attempts left: " << iTry <<
", iWx " << iWx
3495 <<
", got " << h1tmp1->GetBinContent(iWx + 1)
3497 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx];
3501 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3509 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3524 TH1D* h1tmp0 =
fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX(
3526 TH1D* h1tmp1 =
fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX(
3529 h1tmp0->SetBinContent(
3530 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3531 h1tmp1->SetBinContent(
3532 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3533 if (h1tmp0->GetBinContent(iWx + 1)
3534 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3536 <<
"WriteHistos: restore unsuccessful! iWx " << iWx <<
" got "
3537 << h1tmp0->GetBinContent(iWx + 1) <<
", expected "
3538 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3541 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3548 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3567 LOG(debug) <<
"WriteHistos: (case 2) update Offsets and keep Gains, "
3568 "Walk and DELTOF for "
3569 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc "
3571 Int_t iB = iSm * iNbRpc + iRpc;
3572 Double_t dVscal = 1.;
3575 fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3576 if (dVscal == 0.) dVscal = 1.;
3578 Double_t YMean = ((TProfile*) hAvPos_pfx)
3579 ->GetBinContent(iB + 1);
3581 htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
3583 LOG(debug1) << Form(
"Determine YMean in %s by fit to %d entries",
3584 htempPos->GetName(),
3585 (Int_t) htempPos_py->GetEntries());
3591 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3595 TF1* ff = htempPos_py->GetFunction(
"YBox");
3597 LOG(info) <<
"FRes YBox " << htempPos_py->GetEntries()
3598 <<
" entries in TSR " << iSmType << iSm << iRpc
3599 <<
", chi2 " << ff->GetChisquare() / ff->GetNDF()
3601 ", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3602 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3605 2. * ff->GetParameter(1),
3606 2. * ff->GetParError(1),
3607 ff->GetParameter(2),
3609 ff->GetParameter(3),
3610 ff->GetParError(3));
3613 - 2. * ff->GetParameter(1))
3616 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2)
3619 if (TMath::Abs(ff->GetParameter(3) - YMean)
3621 YMean = ff->GetParameter(3);
3623 / (2. * ff->GetParameter(1));
3624 fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc),
3632 Double_t TMean = ((TProfile*) hAvTOff_pfx)->GetBinContent(iSm + 1);
3633 Double_t TWidth = ((TProfile*) hAvTOff_pfx)->GetBinError(iSm + 1);
3640 LOG(debug) << Form(
"<ICor> Correct %d %d %d by TMean=%8.2f, "
3641 "TYOff=%8.2f, TWidth=%8.2f, ",
3650 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3652 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3653 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3655 LOG(debug) <<
"FillCalHist:"
3656 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc
3657 <<
" Ch " << iCh <<
": YMean " << YMean <<
", TMean "
3661 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3662 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
3663 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3664 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3667 htempPos_pfx->Reset();
3668 htempTOff_pfx->Reset();
3669 htempTot_Mean->Reset();
3670 htempTot_Off->Reset();
3671 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3674 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3675 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3676 Double_t TMean = 0.5
3677 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3678 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3679 htempPos_pfx->Fill(iCh, YMean);
3680 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3681 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
3682 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
3683 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
3684 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
3687 htempTOff_pfx->Fill(iCh, TMean);
3689 for (Int_t iSide = 0; iSide < 2; iSide++) {
3690 htempTot_Mean->SetBinContent(
3691 iCh * 2 + 1 + iSide,
3695 htempTot_Off->SetBinContent(
3696 iCh * 2 + 1 + iSide,
3697 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3701 LOG(debug1) <<
" Updating done ... write to file ";
3702 htempPos_pfx->Write();
3703 htempTOff_pfx->Write();
3705 htempTot_Mean->Write();
3706 htempTot_Off->Write();
3709 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName()
3712 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
3714 TDirectory* curdir = gDirectory;
3716 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3717 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3722 gDirectory->cd(curdir->GetPath());
3723 if (NULL != hCorDelTof) {
3724 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3725 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3730 hCorDelTofout->Write();
3732 LOG(debug) <<
" No CorDelTof histo "
3733 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3742 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3751 h1tmp0->SetBinContent(
3752 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3753 h1tmp1->SetBinContent(
3754 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3755 if (h1tmp0->GetBinContent(iWx + 1)
3756 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3757 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
3758 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
3760 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3763 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3770 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3787 LOG(info) << Form(
"calMode==3: update Offsets and Gains, keep Walk "
3788 "and DelTof for 0x%08x, ",
3790 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
3791 <<
" with " << iNbCh <<
" channels "
3792 <<
" using selector " <<
fCalSel;
3799 Double_t dVscal = 1.;
3804 fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3805 if (dVscal == 0.) dVscal = 1.;
3806 dVW =
fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc
3809 if (dVW < 0.1) dVW = 0.1;
3814 htempPos->ProjectionY(Form(
"%s_py", htempPos->GetName()), 1, iNbCh);
3815 LOG(info) << Form(
"Inspect histo %s with %d entries",
3816 htempPos->GetName(),
3817 (Int_t) htempPos_py->GetEntries());
3818 Double_t dYMeanAv = 0.;
3819 Double_t dYMeanFit = 0.;
3821 dYMeanAv = htempPos_py->GetMean();
3822 LOG(debug1) << Form(
"Determine YMeanAv in %s by fit to %d entries",
3823 htempPos->GetName(),
3824 (Int_t) htempPos_py->GetEntries());
3830 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3834 TF1* ff = htempPos_py->GetFunction(
"YBox");
3837 - 2. * ff->GetParameter(1))
3840 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1))
3843 / (2. * ff->GetParameter(1));
3844 LOG(info) <<
"FAvRes YBox " << htempPos_py->GetEntries()
3845 <<
" entries in TSR " << iSmType << iSm << iRpc
3846 <<
", stat: " << gMinuit->fCstatu <<
", chi2 "
3847 << ff->GetChisquare() / ff->GetNDF()
3848 << Form(
", striplen (%5.2f): %7.2f+/-%5.2f, pos res "
3849 "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
3851 2. * ff->GetParameter(1),
3852 2. * ff->GetParError(1),
3853 ff->GetParameter(2),
3855 ff->GetParameter(3),
3856 ff->GetParError(3));
3857 if (TMath::Abs(ff->GetParameter(3) - dYMeanAv)
3859 dYMeanFit = ff->GetParameter(3);
3861 (Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3862 for (Int_t iPar = 0; iPar < 4; iPar++)
3864 (Double_t)(iSm * iNbRpc + iRpc),
3865 ff->GetParameter(2 + iPar));
3869 <<
"FAvBad YBox " << htempPos_py->GetEntries()
3870 <<
" entries in TSR " << iSmType << iSm << iRpc <<
", chi2 "
3871 << ff->GetChisquare()
3873 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
3874 "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3877 2. * ff->GetParameter(1),
3878 2. * ff->GetParError(1),
3879 ff->GetParameter(2),
3881 ff->GetParameter(3),
3882 ff->GetParError(3));
3885 LOG(info) <<
"FAvFailed for TSR " << iSmType << iSm << iRpc;
3888 Double_t dYShift = dYMeanFit - dYMeanAv;
3892 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
3894 Double_t YMean = ((TProfile*) htempPos_pfx)
3895 ->GetBinContent(iCh + 1);
3898 htempPos_py = htempPos->ProjectionY(
3899 Form(
"%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
3900 if (htempPos_py->GetEntries() >
fdYFitMin
3902 LOG(debug1) << Form(
3903 "Determine YMean in %s of channel %d by fit to %d entries",
3904 htempPos->GetName(),
3906 (Int_t) htempPos_py->GetEntries());
3912 LOG(warning) << Form(
"invalid ChannelInfo for 0x%08x", iChId);
3915 Double_t fp[4] = {1., 3 * 0.};
3916 for (Int_t iPar = 2; iPar < 4; iPar++)
3918 fp[iPar] =
fhSmCluFpar[iSmType][iPar]->GetBinContent(
3919 iSm * iNbRpc + iRpc + 1);
3922 Double_t* fpp = &fp[0];
3924 TF1* ff = htempPos_py->GetFunction(
"YBox");
3927 - 2. * ff->GetParameter(1))
3930 && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1))
3934 if (TMath::Abs(ff->GetParameter(3) - YMean)
3936 YMean = ff->GetParameter(3);
3938 / (2. * ff->GetParameter(1));
3940 (Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3942 <<
"FRes YBox " << htempPos_py->GetEntries()
3943 <<
" entries in " << iSmType << iSm << iRpc << iCh
3944 <<
", chi2 " << ff->GetChisquare()
3945 << Form(
", striplen (%5.2f), %4.2f -> %4.2f, %4.1f: "
3946 "%7.2f+/-%5.2f, pos res %5.2f+/-%5.2f at y_cen "
3952 2. * ff->GetParameter(1),
3953 2. * ff->GetParError(1),
3954 ff->GetParameter(2),
3956 ff->GetParameter(3),
3957 ff->GetParError(3));
3958 for (Int_t iPar = 0; iPar < 4; iPar++)
3960 (Double_t)(iSm * iNbRpc + iRpc),
3961 ff->GetParameter(2 + iPar));
3966 <<
"FBad YBox " << htempPos_py->GetEntries()
3967 <<
" entries in " << iSmType << iSm << iRpc << iCh
3968 <<
", chi2 " << ff->GetChisquare()
3969 << Form(
", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3970 "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3973 2. * ff->GetParameter(1),
3974 2. * ff->GetParError(1),
3975 ff->GetParameter(2),
3977 ff->GetParameter(3),
3978 ff->GetParError(3));
3984 ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
3996 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
3997 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +=
3999 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +=
4003 << Form(
"Calib: TSRC %d%d%d%d, hits %6.0f, dTY %8.3f, TM "
4004 "%8.3f -> new Off %8.3f,%8.3f ",
4009 htempTOff_px->GetBinContent(iCh + 1),
4012 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4013 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4022 for (Int_t iSide = 0; iSide < 2; iSide++) {
4023 Int_t ib = iCh * 2 + 1 + iSide;
4024 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
4025 if (100 > hbin->GetEntries())
4028 Int_t iBmax = hbin->GetMaximumBin();
4029 TAxis* xaxis = hbin->GetXaxis();
4031 xaxis->GetBinCenter(iBmax)
4032 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4037 <<
"XOff changed for "
4039 "SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f",
4045 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4048 Double_t TotMean = hbin->GetMean();
4049 if (15 == iSmType) {
4053 "SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4054 "gain %f, modg %f ",
4060 htempTot_Mean->GetBinContent(ib),
4061 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide],
4064 if (0.001 < TotMean) {
4065 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
4070 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4071 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh]
4074 <<
"CbmTofCosmicClusterizer::FillCalHist:"
4075 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc
4076 <<
" Ch " << iCh <<
": YMean " << YMean <<
", TMean " << TMean
4078 << Form(
" %f %f %f %f ",
4079 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4080 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4081 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4082 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4085 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4086 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4089 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4090 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4091 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4092 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4093 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4094 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4099 htempPos_pfx->Reset();
4100 htempTOff_pfx->Reset();
4101 htempTot_Mean->Reset();
4102 htempTot_Off->Reset();
4103 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4106 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4107 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4108 Double_t TMean = 0.5
4109 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4110 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4111 htempPos_pfx->Fill(iCh, YMean);
4112 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4113 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
4114 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
4115 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4116 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
4119 htempTOff_pfx->Fill(iCh, TMean);
4121 for (Int_t iSide = 0; iSide < 2; iSide++) {
4122 htempTot_Mean->SetBinContent(
4123 iCh * 2 + 1 + iSide,
4125 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4126 htempTot_Off->SetBinContent(
4127 iCh * 2 + 1 + iSide,
4128 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4134 LOG(debug1) <<
" Updating done ... write to file ";
4135 htempPos_pfx->Write();
4136 htempTOff_pfx->Write();
4138 htempTot_Mean->Write();
4139 htempTot_Off->Write();
4142 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName()
4145 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4147 TDirectory* curdir = gDirectory;
4149 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4150 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4155 gDirectory->cd(curdir->GetPath());
4156 if (NULL != hCorDelTof) {
4157 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4158 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4163 hCorDelTofout->Write();
4165 LOG(debug) <<
" No CorDelTof histo "
4166 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4174 LOG(debug) <<
" Store old walk histos to file ";
4176 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4186 h1tmp0->SetBinContent(
4187 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4188 h1tmp1->SetBinContent(
4189 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4190 if (h1tmp0->GetBinContent(iWx + 1)
4191 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4192 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
4193 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
4195 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4198 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4205 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4220 <<
"WriteHistos: restore Offsets, Gains and Walk, save DelTof for "
4221 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc;
4222 htempPos_pfx->Reset();
4223 htempTOff_pfx->Reset();
4224 htempTot_Mean->Reset();
4225 htempTot_Off->Reset();
4226 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
4228 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4229 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4230 Double_t TMean = 0.5
4231 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4232 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4233 htempPos_pfx->Fill(iCh, YMean);
4234 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4235 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
4236 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
4237 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4238 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
4241 htempTOff_pfx->Fill(iCh, TMean);
4243 for (Int_t iSide = 0; iSide < 2; iSide++) {
4244 htempTot_Mean->SetBinContent(
4245 iCh * 2 + 1 + iSide,
4249 htempTot_Off->SetBinContent(
4250 iCh * 2 + 1 + iSide,
4251 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4255 LOG(debug1) <<
" Restoring of Offsets and Gains done ... ";
4256 htempPos_pfx->Write();
4257 htempTOff_pfx->Write();
4259 htempTot_Mean->Write();
4260 htempTot_Off->Write();
4263 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4273 h1tmp0->SetBinContent(
4274 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4275 h1tmp1->SetBinContent(
4276 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4277 if (h1tmp0->GetBinContent(iWx + 1)
4278 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4279 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
4280 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
4282 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4285 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4292 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4309 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4311 if (NULL == h2tmp) {
4313 "WriteHistos: histo not available for SmT %d, Sm %d, Rpc %d",
4319 Int_t iNEntries = h2tmp->GetEntries();
4322 TProfile* htmp = h2tmp->ProfileX(
"_pfx", 1, h2tmp->GetNbinsY());
4323 TH1D* h1tmp = h2tmp->ProjectionX(
"_px", 1, h2tmp->GetNbinsY());
4328 Double_t dNEntries = h1tmp->GetBinContent(iBx + 1);
4331 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] +=
4332 ((TProfile*) htmp)->GetBinContent(iBx + 1);
4333 dDelMean +=
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel];
4337 LOG(debug) << Form(
" Update DelTof correction for SmT %d, Sm %d, "
4338 "Rpc %d, Sel%d: Entries %d, Mean shift %6.1f",
4348 h1tmp->SetBinContent(
4349 iBx + 1,
fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel]);
4351 h1tmp->SetName(Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4359 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4361 TDirectory* curdir = gDirectory;
4363 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4364 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4369 gDirectory->cd(curdir->GetPath());
4370 if (NULL != hCorDelTof) {
4371 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4372 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4377 LOG(debug) <<
" Save existing CorDelTof histo "
4378 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4383 hCorDelTofout->Write();
4385 LOG(debug) <<
" No CorDelTof histo "
4386 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4402 LOG(info) <<
"WriteHistos (calMode==3): update Offsets and Gains, "
4403 "keep Walk and DelTof for "
4404 <<
"Smtype" << iSmType <<
", Sm " << iSm <<
", Rpc " << iRpc
4405 <<
" with " << iNbCh <<
" channels "
4406 <<
" using selector " <<
fCalSel;
4408 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4410 Double_t YMean = ((TProfile*) htempPos_pfx)
4411 ->GetBinContent(iCh + 1);
4412 Double_t TMean = 0.;
4417 if (htempTOff_px->GetBinContent(iCh + 1) >
WalkNHmin) {
4418 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
4419 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
4421 LOG(debug3) << Form(
4422 "Calib: TSRC %d%d%d%d, hits %6.0f, new Off %8.0f,%8.0f ",
4427 htempTOff_px->GetBinContent(iCh + 1),
4428 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4429 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4438 for (Int_t iSide = 0; iSide < 2; iSide++) {
4439 Int_t ib = iCh * 2 + 1 + iSide;
4440 TH1* hbin = htempTot->ProjectionY(Form(
"bin%d", ib), ib, ib);
4441 if (100 > hbin->GetEntries())
4444 Int_t iBmax = hbin->GetMaximumBin();
4445 TAxis* xaxis = hbin->GetXaxis();
4447 xaxis->GetBinCenter(iBmax)
4448 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4453 <<
"XOff changed for "
4454 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f",
4460 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4463 Double_t TotMean = hbin->GetMean();
4464 if (15 == iSmType) {
4467 << Form(
"SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4468 "gain %f, modg %f ",
4474 htempTot_Mean->GetBinContent(ib),
4475 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide],
4478 if (0.001 < TotMean) {
4479 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
4484 &&
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4485 !=
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh]
4488 <<
"CbmTofCosmicClusterizer::FillCalHist:"
4489 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc " << iRpc
4490 <<
" Ch " << iCh <<
": YMean " << YMean <<
", TMean " << TMean
4492 << Form(
" %f %f %f %f ",
4493 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4494 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4495 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4496 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4499 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4500 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4503 * (
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4504 +
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4505 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4506 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4507 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4508 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4513 htempPos_pfx->Reset();
4514 htempTOff_pfx->Reset();
4515 htempTot_Mean->Reset();
4516 htempTot_Off->Reset();
4517 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4520 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4521 -
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4522 Double_t TMean = 0.5
4523 * (
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4524 +
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4525 htempPos_pfx->Fill(iCh, YMean);
4526 if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4527 LOG(error) <<
"WriteHistos: restore unsuccessful! ch " << iCh
4528 <<
" got " << htempPos_pfx->GetBinContent(iCh) <<
","
4529 << htempPos_pfx->GetBinContent(iCh + 1) <<
","
4530 << htempPos_pfx->GetBinContent(iCh + 2) <<
", expected "
4533 htempTOff_pfx->Fill(iCh, TMean);
4535 for (Int_t iSide = 0; iSide < 2; iSide++) {
4536 htempTot_Mean->SetBinContent(
4537 iCh * 2 + 1 + iSide,
4539 /
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4540 htempTot_Off->SetBinContent(
4541 iCh * 2 + 1 + iSide,
4542 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4548 LOG(debug1) <<
" Updating done ... write to file ";
4549 htempPos_pfx->Write();
4550 htempTOff_pfx->Write();
4552 htempTot_Mean->Write();
4553 htempTot_Off->Write();
4556 LOG(debug) <<
" Copy old DelTof histos from " << gDirectory->GetName()
4559 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4561 TDirectory* curdir = gDirectory;
4563 TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4564 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4569 gDirectory->cd(curdir->GetPath());
4570 if (NULL != hCorDelTof) {
4571 TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4572 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4577 hCorDelTofout->Write();
4579 LOG(debug) <<
" No CorDelTof histo "
4580 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4588 LOG(debug) <<
" Store old walk histos to file ";
4590 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
4600 h1tmp0->SetBinContent(
4601 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4602 h1tmp1->SetBinContent(
4603 iWx + 1,
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4604 if (h1tmp0->GetBinContent(iWx + 1)
4605 !=
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4606 LOG(error) <<
"WriteHistos: restore unsuccessful! iWx " << iWx
4607 <<
" got " << h1tmp0->GetBinContent(iWx + 1)
4609 <<
fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4612 h1tmp0->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4619 h1tmp1->SetName(Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4631 LOG(debug) <<
"WriteHistos: update mode " <<
fCalMode
4632 <<
" not yet implemented";
4676 for (Int_t iPar = 0; iPar < 4; iPar++)
4679 for (Int_t iSel = 0; iSel <
iNSel; iSel++) {
4687 gDirectory->cd(oldir->GetPath());
4734 gGeoManager->CdTop();
4737 LOG(info) <<
" No CalDigis defined ! Check! ";
4741 LOG(debug) <<
"CbmTofCosmicClusterizer::BuildClusters from "
4749 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
4771 LOG(warning) << Form(
4772 " DigiCor Histo for DetIndx %d derived from 0x%08x not found",
4781 for (Int_t iDigI2 = 0; iDigI2 < iNbTofDigi; iDigI2++) {
4795 Double_t dTDif = TMath::Abs(pDigi->
GetTime() - pDigi2->
GetTime());
4796 if (dTDif < dTDifMin) {
4804 LOG(debug) << Form(
"Missing digi cor %d for TSRC %d%d%d%d ?",
4807 (Int_t) pDigi->
GetSm(),
4811 for (; iDigI3 < iNbTofDigi; iDigI3++) {
4818 if (iDigI3 == iNbTofDigi)
4825 LOG(debug2) << Form(
"shift channel %d%d%d%d%d and ",
4827 (Int_t) pDigi->
GetSm(),
4831 << Form(
" %d%d%d%d%d ",
4833 (Int_t) pDigi2->
GetSm(),
4834 (Int_t) pDigi2->
GetRpc(),
4851 LOG(debug2) << Form(
"resultchannel %d%d%d%d%d and ",
4853 (Int_t) pDigi->
GetSm(),
4857 << Form(
" %d%d%d%d%d ",
4859 (Int_t) pDigi2->
GetSm(),
4860 (Int_t) pDigi2->
GetRpc(),
4867 new ((*fTofDigisColl)[iNbTofDigi++])
CbmTofDigi(*pDigi);
4874 LOG(debug) << Form(
"InsertDigi TSRCS %d%d%d%d%d and ",
4876 (Int_t) pDigiN->
GetSm(),
4877 (Int_t) pDigiN->
GetRpc(),
4882 new ((*fTofDigisColl)[iNbTofDigi++])
CbmTofDigi(*pDigi2);
4889 LOG(debug) << Form(
"InsertDigi2 TSRCS %d%d%d%d%d and ",
4891 (Int_t) pDigiN2->
GetSm(),
4892 (Int_t) pDigiN2->
GetRpc(),
4903 if (pDigi2Min != NULL) {
4913 LOG(warning) << Form(
"BuildClusters: invalid ChannelInfo for 0x%08x",
4926 <<
" BuildClusters: Inconsistent duplicated digis in event "
4928 LOG(warning) <<
" " << pDigi->
ToString();
4929 LOG(warning) <<
" " << pDigi2Min->
ToString();
4960 Int_t iDigIndCal = -1;
4962 std::map<Int_t, Double_t> mChannelDeadTime;
4964 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
4968 LOG(debug1) <<
"BC "
4969 << Form(
"0x%08x", pDigi->
GetAddress()) <<
" TSRC "
4971 << Form(
"%2d", (Int_t) pDigi->
GetChannel()) <<
" "
4973 <<
" " << pDigi->
GetTot();
4981 Bool_t bValid = kTRUE;
4982 std::map<Int_t, Double_t>::iterator it;
4983 it = mChannelDeadTime.find(iAddr);
4984 if (it != mChannelDeadTime.end()) {
4985 LOG(debug1) <<
"CCT found valid ChannelDeadtime entry "
4986 << mChannelDeadTime[iAddr] <<
", DeltaT "
4987 << pDigi->
GetTime() - mChannelDeadTime[iAddr];
4988 if ((bValid = (pDigi->
GetTime()
4990 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
4992 pCalDigi =
new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pDigi);
4994 mChannelDeadTime[iAddr] = pDigi->
GetTime();
4995 if (!bValid)
continue;
5009 LOG(debug1) <<
"DC "
5010 << Form(
"0x%08x", pDigi->
GetAddress()) <<
" TSRC "
5012 << Form(
"%2d", (Int_t) pDigi->
GetChannel()) <<
" "
5014 <<
" " << 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 <<
"CbmTofCosmicClusterizer::BuildClusters: CalDigi " << iDigIndCal
5095 <<
", T " << pCalDigi->
GetType() <<
", Sm " << pCalDigi->
GetSm()
5097 <<
", S " << pCalDigi->
GetSide() <<
", T " << pCalDigi->
GetTime()
5098 <<
", Tot " << pCalDigi->
GetTot() <<
", TotGain "
5110 <<
", Walk " << iWx <<
": "
5117 LOG(info) <<
" dDTot " << dDTot <<
" BinSize: " << dTotBinSize
5123 [pCalDigi->
GetSide()][iWx - 1]
5135 [pCalDigi->
GetSide()][iWx + 1]
5136 <<
" -> dWT = " << dWT;
5139 LOG(info) <<
"Skip1 Digi "
5140 <<
" Type " << pDigi->
GetType() <<
" "
5143 << pDigi->
GetRpc() <<
" "
5152 new ((*fTofCalDigisColl)[++iDigIndCal])
CbmTofDigi(*pCalDigi);
5172 LOG(debug) <<
"CbmTofCosmicClusterizer::BuildClusters: Sort "
5174 if (iNbTofDigi > 1) {
5179 <<
"CbmTofCosmicClusterizer::BuildClusters: Sorting not successful ";
5184 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
5186 LOG(debug1) <<
"AC "
5187 << Form(
"0x%08x", pDigi->
GetAddress()) <<
" TSRC "
5189 << Form(
"%2d", (Int_t) pDigi->
GetChannel()) <<
" "
5191 <<
" " << pDigi->
GetTot();
5206 .push_back(iDigInd);
5208 LOG(info) <<
"Skip2 Digi "
5209 <<
" Type " << pDigi->
GetType() <<
" "
5212 << pDigi->
GetRpc() <<
" "
5256 Double_t dWeightedTime = 0.0;
5257 Double_t dWeightedPosX = 0.0;
5258 Double_t dWeightedPosY = 0.0;
5259 Double_t dWeightedPosZ = 0.0;
5260 Double_t dWeightsSum = 0.0;
5264 Int_t iNbChanInHit = 0;
5266 Int_t iLastChan = -1;
5267 Double_t dLastPosX =
5269 Double_t dLastPosY = 0.0;
5270 Double_t dLastTime = 0.0;
5272 Double_t dPosX = 0.0;
5273 Double_t dPosY = 0.0;
5274 Double_t dPosZ = 0.0;
5275 Double_t dTime = 0.0;
5276 Double_t dTimeDif = 0.0;
5277 Double_t dTotS = 0.0;
5280 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
5283 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
5284 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
5287 LOG(debug2) <<
"RPC - Loop "
5288 << Form(
" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
5293 dWeightedTime = 0.0;
5294 dWeightedPosX = 0.0;
5295 dWeightedPosY = 0.0;
5296 dWeightedPosZ = 0.0;
5304 LOG(debug2) <<
"ChanOrient "
5305 << Form(
" %3d %3d %3d %3d %3d ",
5317 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
5321 " T %3d Sm %3d R %3d Ch %3d Size %3lu ",
5326 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5327 if (0 ==
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].size())
5329 if (0 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
5331 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5334 1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
5336 while ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])
5338 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
5342 if (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()
5345 <<
"SameSide Digis! on TSRC " << iSmType << iSm << iRpc
5346 << iCh <<
", Times: "
5357 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
5370 <<
"3 consecutive SameSide Digis! on TSRC " << iSmType
5371 << iSm << iRpc << iCh <<
", Times: "
5414 "Ev %8.0f, digis not properly time ordered, TSRCS "
5436 <<
"SameSide Erase fStor entries(d) " << iSmType
5437 <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5445 if (2 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5452 <<
"digis processing for "
5453 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ",
5460 if (2 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5463 "Leaving digi processing for TSRC %d%d%d%d, size %3lu",
5468 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5479 LOG(debug1) << Form(
5480 " TSRC %d%d%d%d size %3lu ",
5485 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
5486 << Form(
" ChId: 0x%08x 0x%08x ", iChId, iUCellId);
5490 LOG(error) <<
"CbmTofCosmicClusterizer::BuildClusters: no "
5492 << Form(
" %3d %3d %3d %3d 0x%08x 0x%08x ",
5506 LOG(debug2) << Form(
" Node at (%6.1f,%6.1f,%6.1f) : %p",
5518 LOG(debug2) <<
" " << xDigiA->
ToString();
5519 LOG(debug2) <<
" " << xDigiB->
ToString();
5522 if (5 == iSmType && dTimeDif != 0.) {
5524 LOG(debug) <<
"CbmTofCosmicClusterizer::BuildClusters: "
5526 << iSm <<
" with inconsistent digits "
5528 <<
" -> " << dTimeDif;
5529 LOG(debug) <<
" " << xDigiA->
ToString();
5530 LOG(debug) <<
" " << xDigiB->
ToString();
5542 &&
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()
5545 <<
"Hit candidate outside correlation window, check for "
5546 "better possible digis, "
5548 <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
5552 Double_t dPosYN = 0.;
5553 Double_t dTimeDifN = 0;
5566 if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
5568 <<
"Replace digi on side " << xDigiC->
GetSide()
5569 <<
", yPosNext " << dPosYN <<
" old: " << dPosY;
5570 dTimeDif = dTimeDifN;
5596 <<
"Wrong combinations of digis "
5609 dPosX = ((Double_t)(-iNbCh / 2 + iCh) + 0.5)
5615 << Form(
" %3d %3d %3d %3d %3d 0x%p %1.0f Time %f PosX %f "
5633 if (0 < iNbChanInHit) {
5634 if (iLastChan == iCh - 1) {
5645 && iLastChan == iCh - 1
5648 dWeightedTime += dTime * dTotS;
5649 dWeightedPosX += dPosX * dTotS;
5650 dWeightedPosY += dPosY * dTotS;
5651 dWeightedPosZ += dPosZ * dTotS;
5652 dWeightsSum += dTotS;
5661 <<
" Add Digi and erase fStor entries(a): NbChanInHit "
5662 << iNbChanInHit <<
", " << iSmType <<
", SR "
5663 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5681 dWeightedTime /= dWeightsSum;
5682 dWeightedPosX /= dWeightsSum;
5683 dWeightedPosY /= dWeightsSum;
5684 dWeightedPosZ /= dWeightsSum;
5687 Double_t hitpos_local[3];
5688 hitpos_local[0] = dWeightedPosX;
5689 hitpos_local[1] = dWeightedPosY;
5690 hitpos_local[2] = dWeightedPosZ;
5693 TGeoNode* cNode = gGeoManager->GetCurrentNode();
5694 gGeoManager->GetCurrentMatrix();
5698 gGeoManager->LocalToMaster(hitpos_local, hitpos);
5700 << Form(
" LocalToMaster for node %p: "
5701 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
5710 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
5732 if (iChm < 0) iChm = 0;
5733 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
5735 iSm, iRpc, iChm, 0, iSmType);
5738 LOG(debug) <<
"Save Hit "
5739 << Form(
" %3d %3d 0x%08x %3d %3d %3d %f %f",
5760 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits
5761 <<
": vDigiIndRef.size()";
5767 && dWeightedTime == pHitL->
GetTime()) {
5768 LOG(debug) <<
"Store Hit twice? "
5769 <<
" fiNbHits " <<
fiNbHits <<
", "
5770 << Form(
"0x%08x", iDetId);
5776 LOG(debug) <<
" Digi " << pDigiC->
ToString();
5786 LOG(debug) <<
" DigiL " << pDigiC->
ToString();
5798 Int_t(dWeightsSum * 10.));
5804 LH_store(iSmType, iSm, iRpc, iChm, pHit);
5824 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
5825 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
5830 dWeightedTime = dTime * dTotS;
5831 dWeightedPosX = dPosX * dTotS;
5832 dWeightedPosY = dPosY * dTotS;
5833 dWeightedPosZ = dPosZ * dTotS;
5834 dWeightsSum = dTotS;
5839 <<
" Next fStor Digi " << iSmType <<
", SR "
5840 << iSm * iNbRpc + iRpc <<
", Ch" << iCh <<
", Dig0 "
5841 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0])
5843 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
5850 <<
" Erase fStor entries(b) " << iSmType <<
", SR "
5851 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5869 LOG(debug) << Form(
"1.Hit on channel %d, time: %f, PosY %f",
5875 dWeightedTime = dTime * dTotS;
5876 dWeightedPosX = dPosX * dTotS;
5877 dWeightedPosY = dPosY * dTotS;
5878 dWeightedPosZ = dPosZ * dTotS;
5879 dWeightsSum = dTotS;
5888 <<
" Erase fStor entries(c) " << iSmType <<
", SR "
5889 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
5891 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5893 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5895 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5897 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5915 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
5916 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
5918 LOG(debug2) <<
"finished V-RPC"
5919 << Form(
" %3d %3d %3d %d %f %fx",
5930 <<
"=> Cluster building "
5931 <<
"from digis to hits not implemented for pads, Sm type "
5932 << iSmType <<
" Rpc " << iRpc;
5938 if (0 < iNbChanInHit) {
5939 LOG(debug1) <<
"Process cluster " << iNbChanInHit;
5943 LOG(debug1) <<
"H-Hit ";
5946 LOG(debug2) <<
"V-Hit ";
5948 dWeightedTime /= dWeightsSum;
5949 dWeightedPosX /= dWeightsSum;
5950 dWeightedPosY /= dWeightsSum;
5951 dWeightedPosZ /= dWeightsSum;
5954 Double_t hitpos_local[3] = {3 * 0.};
5955 hitpos_local[0] = dWeightedPosX;
5956 hitpos_local[1] = dWeightedPosY;
5957 hitpos_local[2] = dWeightedPosZ;
5960 TGeoNode* cNode = gGeoManager->GetCurrentNode();
5961 gGeoManager->GetCurrentMatrix();
5965 gGeoManager->LocalToMaster(hitpos_local, hitpos);
5966 LOG(debug1) << Form(
" LocalToMaster for V-node %p: "
5967 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
5976 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
5994 if (iChm < 0) iChm = 0;
5995 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
5999 LOG(debug) <<
"Save V-Hit "
6000 << Form(
" %3d %3d 0x%08x %3d 0x%08x",
6008 LOG(debug) <<
", DigiInds: ";
6019 LOG(warning) <<
"Digi refs for Hit " <<
fiNbHits
6020 <<
": vDigiIndRef.size()";
6025 && dWeightedTime == pHitL->
GetTime())
6026 LOG(debug) <<
"Store Hit twice? "
6027 <<
" fiNbHits " <<
fiNbHits <<
", "
6028 << Form(
"0x%08x", iDetId);
6038 Int_t(dWeightsSum * 10.));
6045 LH_store(iSmType, iSm, iRpc, iChm, pHit);
6066 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
6067 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
6071 LOG(debug2) <<
" Fini-A "
6072 << Form(
" %3d %3d %3d M%3d",
6078 LOG(debug2) <<
" Fini-B " << Form(
" %3d ", iSmType);
6082 LOG(error) <<
" Compressed Digis not implemented ... ";
6090 LOG(info) <<
" No Hits defined ! Check! ";
6094 for (Int_t iHitInd = 0; iHitInd <
fTofHitsColl->GetEntries(); iHitInd++) {
6096 if (NULL == pHit)
continue;
6101 if (iSmType != 5 && iSmType != 8)
continue;
6102 LOG(debug) <<
"MergeClusters: in SmT " << iSmType <<
" for " << iNbRpc
6111 LOG(debug) <<
"MergeClusters: Check for mergers in "
6112 << Form(
" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d",
6118 for (Int_t iHitInd2 = iHitInd + 1; iHitInd2 <
fTofHitsColl->GetEntries();
6121 if (NULL == pHit2)
continue;
6124 if (iSmType2 == iSmType) {
6126 if (iSm2 == iSm || iSmType == 5) {
6128 if (TMath::Abs(iRpc - iRpc2) == 1
6133 Double_t xPos = pHit->
GetX();
6134 Double_t yPos = pHit->
GetY();
6135 Double_t tof = pHit->
GetTime();
6136 Double_t xPos2 = pHit2->
GetX();
6137 Double_t yPos2 = pHit2->
GetY();
6138 Double_t tof2 = pHit2->
GetTime();
6139 LOG(debug) <<
"MergeClusters: Found hit in neighbour "
6140 << Form(
" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d",
6146 << Form(
" DX %6.1f, DY %6.1f, DT %6.1f",
6159 for (Int_t iLink = 0; iLink < digiMatch->
GetNofLinks();
6163 Int_t iDigInd1 = (digiMatch->
GetLink(iLink + 1)).GetIndex();
6164 if (iDigInd0 < fTofCalDigisColl->GetEntries()
6178 for (Int_t iLink = 0; iLink < digiMatch2->
GetNofLinks();
6182 Int_t iDigInd1 = (digiMatch2->
GetLink(iLink + 1)).GetIndex();
6183 if (iDigInd0 < fTofCalDigisColl->GetEntries()
6189 dTot2 += pDig0->
GetTot();
6190 dTot2 += pDig1->
GetTot();
6195 LOG(debug) <<
"MergeClusters: Found merger in neighbour "
6196 << Form(
" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d(%d)",
6203 << Form(
" DX %6.1f, DY %6.1f, DT %6.1f",
6207 << Form(
" Tots %6.1f - %6.1f", dTot, dTot2);
6208 Double_t dTotSum = dTot + dTot2;
6209 Double_t dxPosM = (xPos * dTot + xPos2 * dTot2) / dTotSum;
6210 Double_t dyPosM = (yPos * dTot + yPos2 * dTot2) / dTotSum;
6211 Double_t dtofM = (tof * dTot + tof2 * dTot2) / dTotSum;
6222 LOG(debug) <<
"MergeClusters: Compress TClonesArrays to "
6245 double wx = 1. - par[4] * TMath::Power(xx + par[5], 2);
6246 double xboxe = par[0] * 0.25
6247 * (1. + TMath::Erf((xx + par[1] - par[3]) / par[2]))
6248 * (1. + TMath::Erf((-xx + par[1] + par[3]) / par[2]));
6254 h1 = (TH1*) gROOT->FindObjectAny(hname);
6255 if (NULL != h1) {
fit_ybox(h1, 0.); }
6259 Double_t* fpar = NULL;
6265 Double_t* fpar = NULL) {
6266 TAxis* xaxis = h1->GetXaxis();
6267 Double_t Ymin = xaxis->GetXmin();
6268 Double_t Ymax = xaxis->GetXmax();
6269 TF1* f1 =
new TF1(
"YBox",
f1_xboxe, Ymin, Ymax, 6);
6270 Double_t yini = (h1->GetMaximum() + h1->GetMinimum()) * 0.5;
6271 if (ysize == 0.) ysize = Ymax * 0.8;
6272 f1->SetParameters(yini, ysize * 0.5, 1., 0., 0., 0.);
6274 f1->SetParLimits(2, 0.2, 3.);
6275 f1->SetParLimits(3, -4., 4.);
6278 for (Int_t
i = 0;
i < 4;
i++)
6280 for (Int_t
i = 0;
i < 4;
i++)
6281 f1->SetParameter(2 +
i, fp[
i]);
6282 LOG(debug) <<
"Ini Fpar for " << h1->GetName() <<
" with "
6283 << Form(
" %6.3f %6.3f %6.3f %6.3f ", fp[0], fp[1], fp[2], fp[3]);
6286 h1->Fit(
"YBox",
"Q");
6290 res[9] = f1->GetChisquare();
6292 for (
int i = 0;
i < 6;
i++) {
6293 res[
i] = f1->GetParameter(
i);
6294 err[
i] = f1->GetParError(
i);
6297 LOG(debug) <<
"YBox Fit of " << h1->GetName()
6298 <<
" ended with chi2 = " << res[9]
6299 << Form(
", strip length %7.2f +/- %5.2f, position resolution "
6300 "%7.2f +/- %5.2f at y_cen = %7.2f +/- %5.2f",
6311 LOG(fatal) << Form(
"Inconsistent LH Smtype size %lu, %d ",
6318 LOG(fatal) << Form(
"Inconsistent LH Sm size %lu, %d T %d",
6325 LOG(fatal) << Form(
"Inconsistent LH Rpc size %lu, %d TS %d%d ",
6334 "Inconsistent LH RpcChannel size %lu, %d TSR %d%d%d ",
6341 if (
fvLastHits[iSmType][iSm][iRpc][iCh].size() > 0) {
6348 "Inconsistent address for Ev %8.0f in list of size %lu for "
6349 "TSRC %d%d%d%d: 0x%08x, time %f",
6357 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
6362 LOG(debug) << Form(
"LH check passed for event %8.0f",
fdEvent);
6367 LOG(fatal) << Form(
"Inconsistent LH Smtype size %lu, %d ",
6373 LOG(fatal) << Form(
"Inconsistent LH Sm size %lu, %d T %d",
6380 LOG(fatal) << Form(
"Inconsistent LH Rpc size %lu, %d TS %d%d ",
6389 "Inconsistent LH RpcChannel size %lu, %d TSR %d%d%d ",
6396 while (
fvLastHits[iSmType][iSm][iRpc][iCh].size() > 0) {
6403 "Inconsistent address for Ev %8.0f in list of size %lu for "
6404 "TSRC %d%d%d%d: 0x%08x, time %f",
6412 fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
6413 fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
6414 fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
6419 LOG(info) << Form(
"LH cleaning done after %8.0f events",
fdEvent);
6429 Double_t dLastTotS) {
6435 Int_t iCh = iLastChan + 1;
6436 LOG(debug) << Form(
"Inspect channel TSRC %d%d%d%d at time %f, pos %f, size ",
6443 <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
6444 if (iCh == iNbCh)
return kFALSE;
6445 if (0 ==
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
6447 if (0 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
6449 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
6450 if (1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
6451 Bool_t AddedHit = kFALSE;
6453 i1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size() - 1;
6455 if (AddedHit)
break;
6458 && i2 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
6459 LOG(debug) <<
"check digi pair " << i1 <<
"," << i2 <<
" with size "
6460 <<
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
6462 if ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i1])->GetSide()
6463 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i2])
6479 gGeoManager->FindNode(
6483 Double_t dPosY = 0.;
6490 if (TMath::Abs(dPosY - dLastPosY)
6493 Double_t dNClHits = (Double_t)(
vDigiIndRef.size() / 2);
6497 Double_t dNewTotS = (dLastTotS + dTotS);
6498 dLastPosX = (dLastPosX * dLastTotS + dPosX * dTotS) / dNewTotS;
6499 dLastPosY = (dLastPosY * dLastTotS + dPosY * dTotS) / dNewTotS;
6500 dLastTime = (dLastTime * dLastTotS + dTime * dTotS) / dNewTotS;
6501 dLastTotS = dNewTotS;
6503 Int_t Ind1 =
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i1];
6504 Int_t Ind2 =
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i2];
6509 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
6511 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
6513 std::vector<int>::iterator it;
6514 it = find(
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin(),
6517 if (it !=
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].end()) {
6519 it -
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin();
6520 LOG(debug) <<
"Found i2 " << i2 <<
" with Ind2 " << Ind2
6521 <<
" at position " << ipos;
6523 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
6525 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
6527 LOG(fatal) <<
" Did not find i2 " << i2 <<
" with Ind2 " << Ind2;
6531 if (iCh != (iNbCh - 1)
6540 LOG(debug) <<
"Added Strip " << iCh <<
" to cluster of size "
6551 Double_t hitpos_local[3] = {3 * 0.};
6552 hitpos_local[0] = dLastPosX;
6553 hitpos_local[1] = dLastPosY;
6554 hitpos_local[2] = 0.;
6556 gGeoManager->GetCurrentNode();
6557 gGeoManager->GetCurrentMatrix();
6558 gGeoManager->LocalToMaster(hitpos_local, hitpos);
6559 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
6560 TVector3 hitPosErr(0.5, 0.5, 0.5);
6562 if (iChm < 0) iChm = 0;
6563 if (iChm > iNbCh - 1) iChm = iNbCh - 1;
6569 LOG(debug) <<
"Save A-Hit "
6570 << Form(
"%2d %2d 0x%08x %3d t %f, y %f ",
6578 LOG(debug) <<
", DigiInds: ";
6592 Int_t(dLastTotS * 10.));
6596 LH_store(iSmType, iSm, iRpc, iChm, pHit);
6618 if (
fvLastHits[iSmType][iSm][iRpc][iChm].size() == 0)
6619 fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit);
6621 Double_t dLastTime = pHit->
GetTime();
6622 if (dLastTime >=
fvLastHits[iSmType][iSm][iRpc][iChm].back()->GetTime()) {
6623 fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit);
6625 " Store LH from Ev %8.0f for TSRC %d%d%d%d, size %lu, addr 0x%08x, "
6635 dLastTime -
fvLastHits[iSmType][iSm][iRpc][iChm].front()->GetTime());
6641 std::list<CbmTofHit*>::iterator it;
6642 for (it =
fvLastHits[iSmType][iSm][iRpc][iChm].begin();
6643 it !=
fvLastHits[iSmType][iSm][iRpc][iChm].end();
6645 if ((*it)->GetTime() > dLastTime)
break;
6646 fvLastHits[iSmType][iSm][iRpc][iChm].insert(--it, pHit);
6647 Double_t deltaTime = dLastTime - (*it)->GetTime();
6648 LOG(debug) << Form(
"Hit inserted into LH from Ev %8.0f for TSRC "
6649 "%d%d%d%d, size %lu, addr 0x%08x, delta time %f ",
6659 Double_t deltaTime =
6660 dLastTime -
fvLastHits[iSmType][iSm][iRpc][iChm].front()->GetTime();
6661 LOG(debug) << Form(
"first LH from Ev %8.0f for TSRC %d%d%d%d, size "
6662 "%lu, addr 0x%08x, delta time %f ",
6671 if (deltaTime == 0.) {
6675 fvLastHits[iSmType][iSm][iRpc][iChm].push_front(pHit);
6684 Long_t iP = TMath::Floor(dP);
6685 Double_t dPtime = dTime - (Double_t) iP *
fdTimePeriod;