17 #include "CbmTofHit.h"
26 #include "FairEventHeader.h"
27 #include "FairLogger.h"
28 #include "FairMCEventHeader.h"
29 #include "FairRootManager.h"
30 #include "FairRunAna.h"
31 #include "FairRunSim.h"
32 #include "FairRuntimeDb.h"
35 #include "TClonesArray.h"
36 #include "TDirectory.h"
38 #include "TGeoManager.h"
74 : FairTask(
"CbmTofSimpClusterizer")
80 , fdParFeeTimeRes(0.0)
81 , fdParSystTimeRes(0.0)
82 , fTofPointsColl(NULL)
86 , fTofDigiMatchColl(NULL)
99 , fsHistoOutFilename(
"")
100 , fhClustBuildTime(NULL)
101 , fhHitsPerTracks(NULL)
103 , fhTimeResSingHits(NULL)
104 , fhTimeResSingHitsB(NULL)
105 , fhTimePtVsHits(NULL)
106 , fhClusterSize(NULL)
107 , fhClusterSizeType(NULL)
109 , fhClusterSizeMulti(NULL)
111 , fhHiTrkMulPos(NULL)
112 , fhAllTrkMulPos(NULL)
113 , fhMultiTrkProbPos(NULL)
114 , fhDigSpacDifClust(NULL)
115 , fhDigTimeDifClust(NULL)
116 , fhDigDistClust(NULL)
117 , fhClustSizeDifX(NULL)
118 , fhClustSizeDifY(NULL)
123 , fhRpcSigPropSpeed()
132 , fhTRpcCluPosition()
148 , fhNbDigiPerChan(NULL)
169 , fCalParFileName(
"")
171 , fbMcTrkMonitor(kFALSE) {}
174 : FairTask(TString(name), verbose)
180 , fdParFeeTimeRes(0.0)
181 , fdParSystTimeRes(0.0)
182 , fTofPointsColl(NULL)
183 , fMcTracksColl(NULL)
186 , fTofDigiMatchColl(NULL)
199 , fsHistoOutFilename(
"")
200 , fhClustBuildTime(NULL)
201 , fhHitsPerTracks(NULL)
203 , fhTimeResSingHits(NULL)
204 , fhTimeResSingHitsB(NULL)
205 , fhTimePtVsHits(NULL)
206 , fhClusterSize(NULL)
207 , fhClusterSizeType(NULL)
209 , fhClusterSizeMulti(NULL)
211 , fhHiTrkMulPos(NULL)
212 , fhAllTrkMulPos(NULL)
213 , fhMultiTrkProbPos(NULL)
214 , fhDigSpacDifClust(NULL)
215 , fhDigTimeDifClust(NULL)
216 , fhDigDistClust(NULL)
217 , fhClustSizeDifX(NULL)
218 , fhClustSizeDifY(NULL)
223 , fhRpcSigPropSpeed()
232 , fhTRpcCluPosition()
248 , fhNbDigiPerChan(NULL)
269 , fCalParFileName(
"")
271 , fbMcTrkMonitor(kFALSE)
302 LOG(info) <<
" CbmTofSimpClusterizer => Get the digi parameters for tof";
305 FairRunAna* ana = FairRunAna::Instance();
306 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
310 LOG(info) <<
" CbmTofSimpClusterizer::SetParContainers found "
327 LOG(debug) <<
" CbmTofSimpClusterizer => New event with " << iNbTofDigi
351 LOG(info) <<
"=====================================";
352 LOG(info) << GetName() <<
": Run summary (Time includes Hist filling)";
354 LOG(info) <<
"Digis / event : "
356 LOG(info) <<
"Hits / event : "
359 LOG(info) <<
"Time per event : "
361 LOG(info) <<
"=====================================";
367 FairRootManager* fManager = FairRootManager::Instance();
382 LOG(error) << GetName() <<
": No TofDigi input array present; "
383 <<
"task will be inactive.";
388 fMcTracksColl = (TClonesArray*) fManager->GetObject(
"MCTrack");
390 LOG(info) <<
"CbmTofSimpClusterizer: No MCTrack array.";
397 FairRootManager*
rootMgr = FairRootManager::Instance();
403 "TofHit",
"Tof",
fTofHitsColl, IsOutputBranchPersistent(
"TofHit"));
406 rootMgr->Register(
"TofHitDigiMatch",
409 IsOutputBranchPersistent(
"TofHitDigiMatch"));
416 Bool_t isSimulation = kFALSE;
418 LOG(info) <<
"CbmTofSimpClusterizer::InitParameters with GeoVersion "
421 if (
k12b > iGeoVersion) {
422 LOG(error) <<
"CbmTofSimpClusterizer::InitParameters => Only compatible "
423 "with geometries after v12b !!!";
428 LOG(info) <<
"CbmTofSimpClusterizer::InitParameters with GeoVersion "
431 switch (iGeoVersion) {
436 <<
"CbmTofSimpClusterizer::InitParameters => Invalid geometry!!!"
445 LOG(info) <<
" CbmTofSimpClusterizer::InitParameters found Tres FEE = "
447 LOG(info) <<
" CbmTofSimpClusterizer::InitParameters found Tres Syst = "
459 for (Int_t iT = 0; iT < iNbSmTypes; iT++) {
462 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++)
473 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
476 fvCPTOff[iSmType].resize(iNbSm * iNbRpc);
478 fvCPWalk[iSmType].resize(iNbSm * iNbRpc);
480 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
481 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
488 for (Int_t iTrg = 0; iTrg <
iNTrg; iTrg++)
489 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iTrg] =
494 fvCPTOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
495 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
496 fvCPWalk[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
498 for (Int_t iCh = 0; iCh < iNbChan; iCh++) {
499 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
500 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
501 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
502 for (Int_t iSide = 0; iSide < nbSide; iSide++) {
503 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
505 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
507 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide].resize(
510 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide][iWx] = 0.;
518 LOG(info) <<
"CbmTofSimpClusterizer::InitCalibParameter: defaults set";
527 LOG(info) <<
"CbmTofSimpClusterizer::InitCalibParameter: read histos from "
535 LOG(error) <<
"CbmTofSimpClusterizer::InitCalibParameter: "
545 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
548 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
549 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
550 TH2F* htempPos_pfx = (TH2F*) gDirectory->FindObjectAny(
551 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
552 TH2F* htempTOff_pfx = (TH2F*) gDirectory->FindObjectAny(
553 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
554 TH2F* htempTot_pfx = (TH2F*) gDirectory->FindObjectAny(
555 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
556 if (NULL != htempPos_pfx && NULL != htempTOff_pfx
557 && NULL != htempTot_pfx) {
559 Int_t iNbinTot = htempTot_pfx->GetNbinsX();
560 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
561 Double_t YMean = ((TProfile*) htempPos_pfx)
562 ->GetBinContent(iCh + 1);
564 ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
566 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
567 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
570 ((TProfile*) htempTot_pfx)
571 ->GetBinContent(iCh + 1);
573 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] *=
575 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] *=
578 LOG(debug1) <<
"CbmTofSimpClusterizer::InitCalibParameter:"
579 <<
" SmT " << iSmType <<
" Sm " << iSm <<
" Rpc "
580 << iRpc <<
" Ch " << iCh <<
": YMean " << YMean
581 <<
", TMean " << TMean <<
" -> "
582 <<
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
584 <<
fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
586 <<
fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
587 <<
", NbinTot " << iNbinTot;
589 TH1D* htempWalk0 = (TH1D*) gDirectory->FindObjectAny(
590 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
595 TH1D* htempWalk1 = (TH1D*) gDirectory->FindObjectAny(
596 Form(
"Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
601 if (NULL != htempWalk0
602 && NULL != htempWalk1) {
603 LOG(info) <<
"Initialize Walk correction for "
604 << Form(
" SmT%01d_sm%03d_rpc%03d_Ch%03d",
610 LOG(error) <<
"CbmTofSimpClusterizer::InitCalibParameter: "
611 "Inconsistent Walk histograms";
613 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin] =
614 htempWalk0->GetBinContent(iBin + 1);
615 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
616 htempWalk1->GetBinContent(iBin + 1);
618 " SmT%01d_sm%03d_rpc%03d_Ch%03d bin %d walk %f ",
624 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin]);
629 LOG(error) <<
" Histos "
631 "cl_SmT%01d_sm%03d_rpc%03d_XXX", iSmType, iSm, iRpc)
634 for (Int_t iTrg = 0; iTrg <
iNTrg; iTrg++) {
635 TH1D* htmpDelTof = (TH1D*) gDirectory->FindObjectAny(
636 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Trg%02d_DelTof",
641 if (NULL == htmpDelTof) {
642 LOG(info) <<
" Histos "
643 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Trg%02d_DelTof",
651 LOG(info) <<
" Load DelTof from histos "
652 << Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Trg%02d_DelTof",
659 fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iTrg] +=
660 htmpDelTof->GetBinContent(iBx + 1);
664 TDirectory* curdir = gDirectory;
665 gDirectory->cd(oldir->GetPath());
666 TH1D* h1DelTof = (TH1D*) htmpDelTof->Clone(
667 Form(
"cl_CorSmT%01d_sm%03d_rpc%03d_Trg%02d_DelTof",
673 LOG(info) <<
" copy histo " << h1DelTof->GetName()
674 <<
" to directory " << oldir->GetName();
676 gDirectory->cd(curdir->GetPath());
685 LOG(info) <<
"CbmTofSimpClusterizer::InitCalibParameter: initialization done";
690 LOG(debug) <<
"CbmTofSimpClusterizer::LoadGeometry starting for "
694 LOG(debug) <<
"Digi Parameter container contains " << iNrOfCells <<
" cells"
699 for (Int_t icell = 0; icell < iNrOfCells; ++icell) {
715 LOG(debug1) <<
"-I- InitPar " << icell <<
" Id: " << Form(
"0x%08x", cellId)
716 <<
" " << cell <<
" tmcs: " << smtype <<
" " << smodule <<
" "
717 << module <<
" " << cell <<
" x=" << Form(
"%6.2f",
x)
718 <<
" y=" << Form(
"%6.2f",
y) <<
" z=" << Form(
"%6.2f", z)
719 <<
" dx=" << dx <<
" dy=" << dy;
729 fvdX.resize(iNbSmTypes);
730 fvdY.resize(iNbSmTypes);
735 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
742 fvdX[iSmType].resize(iNbRpc);
743 fvdY[iSmType].resize(iNbRpc);
744 fvdDifX[iSmType].resize(iNbRpc);
745 fvdDifY[iSmType].resize(iNbRpc);
747 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
749 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
753 <<
"CbmTofSimpClusterizer::LoadGeometry: StoreDigi with "
755 " %3d %3d %3d %3d %5d ", iSmType, iSm, iNbRpc, iRpc, iNbChan);
756 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
757 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
762 LOG(debug) <<
"CbmTofSimpClusterizer::LoadGeometry: Done!";
768 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
771 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
772 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
793 new TH1I(
"TofSimpClus_ClustBuildTime",
794 "Time needed to build clusters in each event; Time [s]",
799 new TH1I(
"TofSimpClus_TofHitPerTrk",
800 "Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []",
806 "Distribution of the Number of MCPoints associated "
807 "to each TofHit; Nb MCPoint []",
813 new TH1I(
"TofSimpClus_TofTimeResClust",
814 "Time resolution for TofHits containing Digis from a single MC "
815 "Track; t(1st Mc Point) -tTofHit [ns]",
820 new TH2I(
"TofSimpClus_TofTimeResClustB",
821 "Time resolution for TofHits containing Digis from a single MC "
822 "Track; (1st Mc Point) -tTofHit [ns]",
830 new TH2I(
"TofSimpClus_TofTimePtVsHit",
831 "Time resolution for TofHits containing Digis from a single MC "
832 "Track; t(1st Mc Point) -tTofHit [ps]",
841 new TH1I(
"TofSimpClus_TofTimeResClust",
842 "Time resolution for TofHits containing Digis from a single "
843 "TofPoint; tMcPoint -tTofHit [ns]",
848 new TH2I(
"TofSimpClus_TofTimeResClustB",
849 "Time resolution for TofHits containing Digis from a single "
850 "TofPoint; tMcPoint -tTofHit [ns]",
858 "Time resolution for TofHits containing Digis "
859 "from a single TofPoint; tMcPoint -tTofHit [ps]",
868 "Cluster Size distribution; Cluster Size [Strips]",
873 new TH2I(
"TofSimpClus_ClusterSizeType",
874 "Cluster Size distribution in each (SM type, Rpc) pair; Cluster "
875 "Size [Strips]; 10*SM Type + Rpc Index []",
884 "TofSimpClus_TrackMul",
885 "Number of MC tracks generating the cluster; MC Tracks multiplicity []",
890 "TofSimpClus_ClusterSizeMulti",
891 "Cluster Size distribution as function of Number of MC tracks generating "
892 "the cluster; Cluster Size [Strips]; MC tracks mul. []",
900 "Position of Clusters with only 1 MC tracks "
901 "generating the cluster; X [cm]; Y [cm]",
909 "Position of Clusters with >1 MC tracks "
910 "generating the cluster; X [cm]; Y [cm]",
918 "TofSimpClus_AllTrkMulPos",
919 "Position of all clusters generating the cluster; X [cm]; Y [cm]",
927 new TH2D(
"TofSimpClus_MultiTrkProbPos",
928 "Probability of having a cluster with multiple tracks as "
929 "function of position; X [cm]; Y [cm]; Prob. [%]",
939 new TH1I(
"TofSimpClus_DigSpacDifClust",
940 "Space difference along channel direction between Digi pairs on "
941 "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
946 new TH1I(
"TofSimpClus_DigTimeDifClust",
947 "Time difference between Digi pairs on adjacent channels; "
948 "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
953 "TofSimpClus_DigDistClust",
954 "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
955 "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
964 new TH2I(
"TofSimpClus_ClustSizeDifX",
965 "Position difference between Point and Hit as function of Cluster "
966 "Size; Cluster Size [Strips]; dX [cm]",
974 new TH2I(
"TofSimpClus_ClustSizeDifY",
975 "Position difference between Point and Hit as function of Cluster "
976 "Size; Cluster Size [Strips]; dY [cm]",
984 "Position difference between Point and Hit as "
985 "function of Channel dif; Ch Dif [Strips]; dX [cm]",
993 "Position difference between Point and Hit as "
994 "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1003 "How many time per event the 2 digis on a channel "
1004 "were of the same side ; Counts/Event []",
1009 "Nb of Digis per channel; Nb Digis []",
1022 + (
fStop.GetNanoSec() -
fStart.GetNanoSec()) / 1e9);
1029 Int_t iNbTofTracks = 0;
1030 Int_t iNbTofTracksPrim = 0;
1032 for (Int_t iTrkInd = 0; iTrkInd < iNbTracks; iTrkInd++) {
1042 if (0 < iNbTofTracks)
1043 fhHitsPerTracks->Fill((Double_t) iNbTofHits / (Double_t) iNbTofTracks);
1047 for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
1071 for (UInt_t uCluster = 0; uCluster <
fviClusterSize[iSmType][iRpc].size();
1075 40 * iSmType + iRpc);
1080 if (1 ==
fviTrkMul[iSmType][iRpc][uCluster])
1082 fvdY[iSmType][iRpc][uCluster]);
1083 if (1 <
fviTrkMul[iSmType][iRpc][uCluster])
1085 fvdY[iSmType][iRpc][uCluster]);
1087 fvdY[iSmType][iRpc][uCluster]);
1089 if (1 ==
fviTrkMul[iSmType][iRpc][uCluster]) {
1091 fvdDifX[iSmType][iRpc][uCluster]);
1093 fvdDifY[iSmType][iRpc][uCluster]);
1096 fvdDifX[iSmType][iRpc][uCluster]);
1098 fvdDifY[iSmType][iRpc][uCluster]);
1104 fvdX[iSmType][iRpc].clear();
1105 fvdY[iSmType][iRpc].clear();
1106 fvdDifX[iSmType][iRpc].clear();
1107 fvdDifY[iSmType][iRpc].clear();
1117 LOG(info) <<
"CbmTofSimpClusterizer::WriteHistos => Control histograms "
1118 "will not be written to disk!";
1119 LOG(info) <<
"CbmTofSimpClusterizer::WriteHistos => To change this "
1120 "behavior please provide a full path "
1121 <<
"with the SetHistoFileName method";
1125 TDirectory* oldir = gDirectory;
1160 gDirectory->cd(oldir->GetPath());
1208 Double_t dEventTime = 0.;
1218 LOG(debug) <<
" BuildCluster with MaxTimeDist " << dMaxTimeDist
1219 <<
", MaxSpaceDist " << dMaxSpaceDist;
1227 LOG(info) <<
"Number of TOF digis: " << iNbTofDigi;
1230 for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
1233 LOG(debug1) <<
"CbmTofSimpClusterizer::BuildClusters: " << iDigInd <<
" "
1234 << pDigi <<
" " << pDigi->
GetType() <<
" " << pDigi->
GetSm()
1236 << Form(
"T %6.2f, Tot %6.1f ",
1253 .push_back(iDigInd);
1271 Int_t iWx = (Int_t)((pDigi->
GetTot() -
TOTMin / 2.) / dTotBinSize);
1272 if (0 > iWx) iWx = 0;
1275 (pDigi->
GetTot() -
TOTMin / 2.) / dTotBinSize - (Double_t) iWx - 0.5;
1316 <<
"CbmTofSimpClusterizer::BuildClusters: CalDigi " << iDigInd
1317 <<
", T " << pDigi->
GetType() <<
", Sm " << pDigi->
GetSm()
1320 <<
", Tot " << pDigi->
GetTot() <<
", TotGain "
1326 <<
", Walk " << iWx <<
": "
1333 <<
" dDTot " << dDTot <<
" BinSize: " << dTotBinSize <<
", CPWalk "
1348 <<
" -> dWT = " << dWT;
1351 LOG(debug) <<
"CbmTofSimpBeamClusterizer::BuildClusters: Skip Digi "
1352 <<
" Type " << pDigi->
GetType() <<
" "
1355 << pDigi->
GetRpc() <<
" "
1381 Double_t dWeightedTime = 0.0;
1382 Double_t dWeightedPosX = 0.0;
1383 Double_t dWeightedPosY = 0.0;
1384 Double_t dWeightedPosZ = 0.0;
1385 Double_t dWeightedTimeErr = 0.0;
1386 Double_t dWeightsSum = 0.0;
1387 std::vector<CbmTofPoint*>
vPtsRef;
1390 Int_t iTrafoCell = -1;
1391 Int_t iNbChanInHit = 0;
1393 Int_t iLastChan = -1;
1395 Double_t dLastPosY = 0.0;
1396 Double_t dLastTime = 0.0;
1398 Double_t dPosX = 0.0;
1399 Double_t dPosY = 0.0;
1400 Double_t dPosZ = 0.0;
1401 Double_t dTime = 0.0;
1402 Double_t dTotS = 0.0;
1406 gGeoManager->CdTop();
1408 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
1411 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
1412 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
1415 LOG(debug2) <<
"CbmTofSimpClusterizer::BuildClusters: RPC - Loop "
1416 << Form(
" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
1421 dWeightedTime = 0.0;
1422 dWeightedPosX = 0.0;
1423 dWeightedPosY = 0.0;
1424 dWeightedPosZ = 0.0;
1425 dWeightedTimeErr = 0.0;
1436 LOG(debug2) <<
"CbmTofSimpClusterizer::BuildClusters: ChanOrient "
1437 << Form(
" %3d %3d %3d %3d %3d ",
1449 for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
1451 <<
"CbmTofSimpClusterizer::BuildClusters: VDigisize"
1453 " T %3d Sm %3d R %3d Ch %3d Size %3zu ",
1458 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
1460 if (0 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
1462 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
1464 1 <
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
1466 <<
"CbmTofSimpClusterizer::BuildClusters: digis processing "
1468 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3zu ",
1482 while ((
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])
1484 == (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
1489 <<
"CbmTofSimpClusterizer::BuildClusters: SameSide Hits! "
1491 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])
1494 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
1497 << (
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
1503 <<
" SameSide Erase fStor entries(d) " << iSmType
1504 <<
", SR " << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
1506 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1508 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1509 if (2 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
1516 <<
"CbmTofSimpClusterizer::BuildClusters: digis processing "
1518 << Form(
" SmT %3d Sm %3d Rpc %3d Ch %3d # %3zu ",
1526 >
fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
1543 LOG(error) <<
"CbmTofSimpClusterizer::BuildClusters: no "
1545 << Form(
" %3d %3d %3d %3d 0x%08x 0x%08x ",
1555 <<
"CbmTofSimpClusterizer::BuildClusters:"
1557 " T %3d Sm %3d R %3d Ch %3d size %3zu ",
1562 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
1563 << Form(
" ChId: 0x%08x 0x%08x %p",
1593 if (NULL == fTrafoCell) {
1600 << Form(
" Node at (%6.1f,%6.1f,%6.1f) : %p, info %p, %p",
1634 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1636 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1641 <<
"CbmTofSimpClusterizer::BuildClusters: NbChanInHit"
1642 << Form(
" %3d %3d %3d %p %2.0f Time %6.1f PosY %5.1f Svel "
1652 << Form(
", Offs %5.1f, %5.1f",
1653 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
1654 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
1657 if (0 < iNbChanInHit) {
1660 if (iLastChan == iCh - 1) {
1669 if (TMath::Abs(dTime - dLastTime) < dMaxTimeDist
1670 && iLastChan == iCh - 1
1671 && TMath::Abs(dPosY - dLastPosY) < dMaxSpaceDist) {
1673 dWeightedTime += dTime * dTotS;
1674 dWeightedPosX += dPosX * dTotS;
1675 dWeightedPosY += dPosY * dTotS;
1676 dWeightedPosZ += dPosZ * dTotS;
1677 dWeightedTimeErr += dTotS * dTotS;
1678 dWeightsSum += dTotS;
1718 <<
" Add Digi and erase fStor entries(a): NbChanInHit "
1719 << iNbChanInHit <<
", " << iSmType <<
", SR "
1720 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
1738 dWeightedTime /= dWeightsSum;
1739 dWeightedPosX /= dWeightsSum;
1740 dWeightedPosY /= dWeightsSum;
1741 dWeightedPosZ /= dWeightsSum;
1747 Double_t hitpos_local[3];
1751 gGeoManager->FindNode(fTrafoCell->
GetX(),
1753 fTrafoCell->
GetZ());
1754 TGeoNode* cNode = gGeoManager->GetCurrentNode();
1756 TGeoRotation rotMatrix(*gGeoManager->GetCurrentMatrix());
1758 hitpos[0] = fTrafoCell->
GetX();
1759 hitpos[1] = fTrafoCell->
GetY();
1760 hitpos[2] = fTrafoCell->
GetZ();
1761 gGeoManager->MasterToLocal(hitpos, hitpos_local);
1762 LOG(debug1) << Form(
" Node0 at (%6.1f,%6.1f,%6.1f) : "
1763 "(%6.1f,%6.1f,%6.1f) pointer %p",
1772 hitpos_local[0] += dWeightedPosX;
1773 hitpos_local[1] += dWeightedPosY;
1774 hitpos_local[2] += dWeightedPosZ;
1776 gGeoManager->LocalToMaster(hitpos_local, hitpos);
1778 << Form(
" LTM for node %p, info %p: "
1779 "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
1789 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
1794 Double_t hiterr_local[3];
1799 / TMath::Sqrt(12.0);
1811 rotMatrix.LocalToMaster(hiterr_local, hiterr);
1813 TVector3 hitPosErr(hiterr[0], hiterr[1], hiterr[2]);
1821 if (iChm < 0 || iChm > iNbCh) {
1822 LOG(debug) <<
"CbmTofSimpClusterizer::BuildClusters: "
1823 "Invalid mean channel";
1826 iSm, iRpc, iChm, 0, iSmType);
1830 <<
"CbmTofSimpClusterizer::BuildClusters: Save Hit "
1831 << Form(
" %3d %3d 0x%08x %3d %3d %3d %f %f",
1875 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
1876 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
1886 dWeightedTime = dTime * dTotS;
1887 dWeightedPosX = dPosX * dTotS;
1888 dWeightedPosY = dPosY * dTotS;
1889 dWeightedPosZ = dPosZ * dTotS;
1890 dWeightedTimeErr = dTotS * dTotS;
1891 dWeightsSum = dTotS;
1897 <<
" Next fStor Digi " << iSmType <<
", SR "
1898 << iSm * iNbRpc + iRpc <<
", Ch" << iCh <<
", Dig0 "
1899 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0])
1901 << (
fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
1908 <<
" Erase fStor entries(b) " << iSmType <<
", SR "
1909 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
1938 <<
"CbmTofSimpClusterizer::BuildClusters: 1.Hit on "
1940 << iCh <<
", time: " << dTime <<
", x: " << dPosX
1941 <<
", y: " << dPosY <<
", Tot: " << dTotS;
1944 dWeightedTime = dTime * dTotS;
1945 dWeightedPosX = dPosX * dTotS;
1946 dWeightedPosY = dPosY * dTotS;
1947 dWeightedPosZ = dPosZ * dTotS;
1948 dWeightedTimeErr = dTotS * dTotS;
1949 dWeightsSum = dTotS;
1960 <<
" Erase fStor entries(c) " << iSmType <<
", SR "
1961 << iSm * iNbRpc + iRpc <<
", Ch" << iCh;
1963 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1965 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1967 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1969 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
1988 fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
1989 fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
1992 <<
"CbmTofSimpClusterizer::BuildClusters: finished V-RPC"
1993 << Form(
" %3d %3d %3d %d",
2002 <<
"CbmTofSimpClusterizer::BuildClusters => Cluster building "
2003 <<
"from digis to hits not implemented for pads, Sm type "
2004 << iSmType <<
" Rpc " << iRpc;
2010 if (0 < iNbChanInHit) {
2012 <<
"CbmTofSimpClusterizer::BuildClusters: Process cluster "
2017 LOG(debug1) <<
"CbmTofSimpClusterizer::BuildClusters: H-Hit ";
2020 LOG(debug2) <<
"CbmTofSimpClusterizer::BuildClusters: V-Hit ";
2022 dWeightedTime /= dWeightsSum;
2023 dWeightedPosX /= dWeightsSum;
2024 dWeightedPosY /= dWeightsSum;
2025 dWeightedPosZ /= dWeightsSum;
2031 Double_t hitpos_local[3];
2035 gGeoManager->FindNode(
2036 fTrafoCell->
GetX(), fTrafoCell->
GetY(), fTrafoCell->
GetZ());
2038 gGeoManager->GetCurrentNode();
2040 TGeoRotation rotMatrix(*gGeoManager->GetCurrentMatrix());
2042 hitpos[0] = fTrafoCell->
GetX();
2043 hitpos[1] = fTrafoCell->
GetY();
2044 hitpos[2] = fTrafoCell->
GetZ();
2045 gGeoManager->MasterToLocal(hitpos, hitpos_local);
2046 LOG(debug1) << Form(
2047 " Node0 at (%6.1f,%6.1f,%6.1f) : (%6.1f,%6.1f,%6.1f)",
2055 hitpos_local[0] += dWeightedPosX;
2056 hitpos_local[1] += dWeightedPosY;
2057 hitpos_local[2] += dWeightedPosZ;
2059 gGeoManager->LocalToMaster(hitpos_local, hitpos);
2060 LOG(debug1) << Form(
2061 " LTM for V-node %p, info %p, tra %p: (%6.1f,%6.1f,%6.1f) "
2062 "->(%6.1f,%6.1f,%6.1f) [(%6.1f,%6.1f,%6.1f)]",
2074 fTrafoCell->
GetZ());
2076 TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
2080 Double_t hiterr_local[3];
2085 / TMath::Sqrt(12.0);
2097 rotMatrix.LocalToMaster(hiterr_local, hiterr);
2099 TVector3 hitPosErr(hiterr[0], hiterr[1], hiterr[2]);
2121 if (iChm < 0 || iChm > iNbCh) {
2122 LOG(debug) <<
"CbmTofSimpClusterizer::BuildClusters: Invalid "
2124 << iChm <<
"(" << iNbCh <<
")";
2131 <<
"CbmTofSimpClusterizer::BuildClusters: Save V-Hit "
2133 << Form(
" %3d %3d %3d %3d %3d ",
2141 LOG(debug) <<
", DigiInds: ";
2174 fvdX[iSmType][iRpc].push_back(dWeightedPosX);
2175 fvdY[iSmType][iRpc].push_back(dWeightedPosY);
2185 LOG(DEBUG4) <<
" Fini-A "
2186 << Form(
" %3d %3d %3d ", iSmType, iSm, iRpc);
2188 LOG(debug3) <<
" Fini-B " << Form(
" %3d ", iSmType);
2192 LOG(error) <<
" Compressed Digis not implemented ... ";
2199 Double_t& eventTime) {
2202 if (FairRunAna::Instance()) {
2203 FairEventHeader*
event = FairRunAna::Instance()->GetEventHeader();
2204 inputNr =
event->GetInputFileId();
2205 eventNr =
event->GetMCEntryNumber();
2206 eventTime =
event->GetEventTime();
2212 if (!FairRunSim::Instance())
2213 LOG(fatal) << GetName() <<
": neither SIM nor ANA run.";
2214 FairMCEventHeader*
event = FairRunSim::Instance()->GetMCEventHeader();
2216 eventNr =
event->GetEventID();