9 #include <FairLogger.h>
10 #include <FairParGenericSet.h>
11 #include <FairParamList.h>
15 #include <TDirectory.h>
17 #include <TFitResult.h>
18 #include <TFitResultPtr.h>
29 : FairParGenericSet(name, title, context)
31 , fbUseOnlyPrim(kFALSE)
32 , fbOneGapTrack(kTRUE)
39 , fdSignalPropSpeed(0.0)
53 , fiClusterRadiusModel(-1)
62 , fbMulUseTrackId(kTRUE)
63 , fdMaxTimeDistClust(0.5)
64 , fdMaxSpaceDistClust(2.5) {
69 LOG(DEBUG4) <<
"Enter CbmTofDigiBdfPar destructor";
71 LOG(DEBUG4) <<
"Leave CbmTofDigiBdfPar destructor";
80 for (UInt_t uSmType = 0; uSmType <
fh1ClusterSize.size(); uSmType++)
82 for (UInt_t uSmType = 0; uSmType <
fh1ClusterTot.size(); uSmType++)
106 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
107 l->add(Form(
"NbGaps%03d", iSmType),
fiNbGaps[iSmType]);
108 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
109 l->add(Form(
"GapSize%03d", iSmType),
fdGapSize[iSmType]);
110 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
111 l->add(Form(
"SigVel%03d", iSmType),
fdSigVel[iSmType]);
112 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
113 l->add(Form(
"NbCh%03d", iSmType),
fiNbCh[iSmType]);
114 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
115 l->add(Form(
"ChType%03d", iSmType),
fiChType[iSmType]);
116 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
132 if (!l) {
return kFALSE; }
134 LOG(debug2) <<
"Get the tof digitization parameters.";
137 if (!l->fill(
"UseExpDigi", &iTemp))
return kFALSE;
140 if (!l->fill(
"UseOnlyPrim", &iTemp))
return kFALSE;
143 if (!l->fill(
"UseOneGapPerTrk", &iTemp))
return kFALSE;
148 if (!l->fill(
"FeeTotThr", &
fdFeeTotThr))
return kFALSE;
152 LOG(debug) <<
"Use default FEE deadtime of " <<
fdDeadtime <<
" ns ";
154 if (!l->fill(
"NbSmTypes", &
fiNbSmTypes))
return kFALSE;
156 LOG(debug2) <<
"CbmTofDigiBdfPar => There are " <<
fiNbSmTypes
157 <<
" types of SM to be initialized.";
161 if (!l->fill(
"NbSm", &
fiNbSm))
return kFALSE;
164 if (!l->fill(
"NbRpc", &
fiNbRpc))
return kFALSE;
167 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
169 if (!l->fill(Form(
"NbGaps%03d", iSmType), &(
fiNbGaps[iSmType])))
174 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
176 if (!l->fill(Form(
"GapSize%03d", iSmType), &(
fdGapSize[iSmType])))
181 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
183 if (!l->fill(Form(
"SigVel%03d", iSmType), &(
fdSigVel[iSmType]))) {
185 <<
"CbmTofDigiBdfPar::getParams => parameter "
186 << Form(
"SigVel%03d", iSmType) <<
" not found in the text file. "
187 <<
"This is normal for geometries < 14a but may indicate file "
189 <<
" for newer geometries. Values are set to default 0.0 cm/ps.";
190 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++)
198 "SigVel%03d Array size: %d < request %d, copy values to all modules ",
200 (Int_t)(
fdSigVel[iSmType]).GetSize(),
203 TArrayD temp((
fdSigVel[iSmType]).GetSize());
204 for (Int_t
i = 0;
i < (
fdSigVel[iSmType]).GetSize();
i++)
208 for (Int_t iSm = 0; iSm <
fiNbSm[iSmType];
210 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++)
215 LOG(error) <<
"CbmTofDigiBdfPar::getParams => parameter "
216 << Form(
"SigVel%03d", iSmType)
217 <<
" has a not matching number of fields: "
218 << (
fdSigVel[iSmType]).GetSize() <<
" instead of "
228 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
230 if (!l->fill(Form(
"NbCh%03d", iSmType), &(
fiNbCh[iSmType])))
return kFALSE;
234 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
236 if (!l->fill(Form(
"ChType%03d", iSmType), &(
fiChType[iSmType])))
241 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
243 if (!l->fill(Form(
"ChOrientation%03d", iSmType),
250 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
258 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
259 for (Int_t iSm = 0; iSm <
GetNbSm(iSmType); iSm++) {
260 for (Int_t iRpc = 0; iRpc <
GetNbRpc(iSmType); iRpc++) {
277 Int_t iMaxSizeFilename = 500;
279 sTempText =
new Text_t[iMaxSizeFilename];
280 if (!l->fill(
"BeamInputFile", sTempText, iMaxSizeFilename))
return kFALSE;
282 if (l->fill(
"BeamCalibFile", sTempText, iMaxSizeFilename))
292 if (!l->fill(
"RadiusLandauMpv", &
fdLandauMpv))
return kFALSE;
294 if (!l->fill(
"RadLandauSigma", &
fdLandauSigma))
return kFALSE;
297 if (!l->fill(
"MulUseTrkId", &iTemp))
return kFALSE;
315 TDirectory* oldir = gDirectory;
318 if (kFALSE == fBeamtimeInput->IsOpen()) {
319 LOG(error) <<
"CbmTofDigiBdfPar => Could not open the beamtime data file.";
324 fBeamtimeInput->GetObject(
"Efficiency", pInputEff);
325 fBeamtimeInput->GetObject(
"TimeResol", pInputRes);
326 if (0 == pInputEff) {
327 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Efficiency array "
328 "from the beamtime data file.";
331 if (0 == pInputRes) {
332 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Time Resolution "
333 "array from the beamtime data file.";
334 gDirectory->cd(oldir->GetPath());
335 fBeamtimeInput->Close();
338 if (0 == pInputEff->GetSize() || 0 == pInputRes->GetSize()
339 || pInputEff->GetSize() != pInputRes->GetSize()) {
340 LOG(error) <<
"CbmTofDigiBdfPar => Efficiency or Time Resolution array "
341 "from the beamtime data file have wrong size.";
342 gDirectory->cd(oldir->GetPath());
343 fBeamtimeInput->Close();
350 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
365 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++) {
366 LOG(debug1) << iSmType <<
" Eff: " << iRpc <<
" "
368 <<
" " << (Double_t)
GetNbGaps(iSmType, iRpc) <<
" TRes "
373 1.0 / (Double_t)
GetNbGaps(iSmType, iRpc));
378 fBeamtimeInput->GetObject(
381 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Cluster Size "
382 "histogram for Sm Type "
383 << iSmType <<
", mapped to input type "
385 gDirectory->cd(oldir->GetPath());
386 fBeamtimeInput->Close();
390 (TH1*) (pH1Temp->Clone(Form(
"ClusterSizeType%03d", iSmType)));
393 fBeamtimeInput->GetObject(
396 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Cluster Size "
397 "histogram for Sm Type "
398 << iSmType <<
", mapped to input type "
400 gDirectory->cd(oldir->GetPath());
401 fBeamtimeInput->Close();
405 (TH1*) (pH1Temp->Clone(Form(
"ClusterTot%03d", iSmType)));
408 LOG(error) <<
"CbmTofDigiBdfPar => Wrong mapping index for Sm Type "
409 << iSmType <<
": Out of input boundaries";
410 gDirectory->cd(oldir->GetPath());
411 fBeamtimeInput->Close();
418 gDirectory->cd(oldir->GetPath());
419 fBeamtimeInput->Close();
425 TDirectory* oldir = gDirectory;
428 new TFile(
"RadToClustDist_0000_1000_0010_00025_05025_00025.root",
"READ");
429 if (kFALSE == fSimInput->IsOpen()) {
430 LOG(error) <<
"CbmTofDigiBdfPar => Could not open the Simulated Landau "
431 "distribution data file.";
439 fSimInput->GetObject(
"ClustSizeFitR0All", hFitR0All);
443 fSimInput->GetObject(
"ClustSizeFitSigInAll", hFitSigInAll);
449 fSimInput->GetObject(
"hClustSizeFitR0CntAll", hFitR0CntAll);
454 TH2D* hFitSigInCntAll;
455 fSimInput->GetObject(
"hClustSizeFitSigInCntAll", hFitSigInCntAll);
456 if (0 == hFitR0All || 0 == hFitSigInAll || 0 == hFitR0CntAll
457 || 0 == hFitSigInCntAll) {
458 LOG(error) <<
"CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Failed to "
459 "load Simulated Landau distribution values "
460 <<
" => Use default values from ASCII parameter file! Pointers: "
461 << hFitR0All <<
" " << hFitSigInAll <<
" " << hFitR0CntAll <<
" "
462 << hFitSigInCntAll <<
" ";
469 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
470 TFitResultPtr pResult =
fh1ClusterSize[iSmType]->Fit(
"landau",
"SN");
471 if (kTRUE == pResult->IsValid()) {
473 Double_t dMpv = pResult->Parameter(1);
474 Double_t dSigma = pResult->Parameter(2);
476 if (1 == hFitR0CntAll->GetBinContent(hFitR0CntAll->FindBin(dMpv, dSigma))
478 == hFitSigInCntAll->GetBinContent(
479 hFitSigInCntAll->FindBin(dMpv, dSigma))) {
482 hFitR0All->GetBinContent(hFitR0All->FindBin(dMpv, dSigma));
484 hFitSigInAll->GetBinContent(hFitSigInAll->FindBin(dMpv, dSigma));
489 LOG(WARNING) <<
"CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Fit "
490 "values matching a non-unique param pair for Sm Type "
492 << hFitR0CntAll->GetBinContent(
493 hFitR0CntAll->FindBin(dMpv, dSigma));
494 LOG(WARNING) <<
" => Use default values from ASCII parameter file";
500 LOG(WARNING) <<
"CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Fit "
501 "failed for Sm Type "
503 <<
" => Use default values from ASCII parameter file";
507 gDirectory->cd(oldir->GetPath());
564 LOG(error) <<
"Invalid iSm " << iSm <<
", iRpc " << iRpc;
567 LOG(error) <<
"Invalid SMType " << iSmType;
573 return fiNbCh[iSmType][iRpc];
671 LOG(info) <<
" _ _ _ _ _ _ _ _ _ _ ";
672 LOG(info) <<
" |_|+|_|+|_|+|_|+|_|+|_|+|_|+|_|+|_|+|_| ";
673 LOG(info) <<
"Parameter values in CbmTofDigiBdfPar: ";
674 LOG(info) <<
"=> MC data usage: ";
676 LOG(info) <<
" Tracks used: Only Primary!";
679 <<
" Tracks used: All (Primary + Secondary)";
681 LOG(info) <<
"=> FEE properties: ";
682 LOG(info) <<
" FEE gain standard deviation: "
684 LOG(info) <<
" FEE Threshold on ToT: " <<
fdFeeTotThr
686 LOG(info) <<
" FEE channel time resolution: " <<
fdTimeResElec
690 LOG(info) <<
" FEE deadtime: " <<
fdDeadtime <<
"[ns]";
693 LOG(info) <<
"=> Geometry variables: ";
696 LOG(info) <<
" Number of Super Modules (SM) Types: " <<
fiNbSmTypes;
698 TString sIndex =
" Sm Type |-- ";
699 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
700 sIndex += Form(
"%3d ", iSmType);
703 TString sSmNb =
" Nb SM for each SM type: |-> ";
704 TString sRpcNb =
" Nb Rpc for each SM type: |-> ";
705 sIndex =
" Rpc index |-- ";
715 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
716 sSmNb += Form(
"%3d ",
GetNbSm(iSmType));
717 sRpcNb += Form(
"%3d ",
GetNbRpc(iSmType));
718 sGapsNb[iSmType] = Form(
" Nb of Gaps in SM type %3d:|-> ", iSmType);
719 sGapsSz[iSmType] = Form(
" Gap Size(mm) in SM type %3d:|-> ", iSmType);
720 sSigVel[iSmType] = Form(
" SigVel(cm/ps) in SM type %3d:|-> ", iSmType);
721 sChNb[iSmType] = Form(
" Nb of Chan in SM type %3d:|-> ", iSmType);
722 sChType[iSmType] = Form(
" Chan Type in SM type %3d:|-> ", iSmType);
723 sChOrient[iSmType] = Form(
" Chan orient. in SM type %3d:|-> ", iSmType);
727 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++) {
728 sGapsNb[iSmType] += Form(
"%3d ",
GetNbGaps(iSmType, iRpc));
729 sGapsSz[iSmType] += Form(
"%3.2f ",
GetGapSize(iSmType, iRpc));
730 for (Int_t iSm = 0; iSm <
fiNbSm[iSmType]; iSm++)
731 sSigVel[iSmType] += Form(
"%4.3f ",
GetSigVel(iSmType, iSm, iRpc));
732 sChNb[iSmType] += Form(
"%3d ",
GetNbChan(iSmType, iRpc));
734 sChType[iSmType] +=
"pad ";
736 sChType[iSmType] +=
"str ";
738 sChOrient[iSmType] +=
"hor ";
740 sChOrient[iSmType] +=
"ver ";
743 for (Int_t iRpc = 0; iRpc < iMaxRpcNb; iRpc++)
744 sIndex += Form(
"%3d ", iRpc);
749 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
750 LOG(info) << sGapsNb[iSmType];
751 LOG(info) << sGapsSz[iSmType];
752 LOG(debug) << sSigVel[iSmType];
753 LOG(info) << sChNb[iSmType];
754 LOG(info) << sChType[iSmType];
755 LOG(info) << sChOrient[iSmType];
759 LOG(info) <<
"=> Beamtime variables: ";
765 <<
" Cluster radius model: Single value at 0.0002 cm";
768 LOG(info) <<
" Cluster radius model: Single value using "
769 "beamtime mean cluster size";
772 LOG(info) <<
" Cluster radius model: Landau Distrib. "
773 "using values from parameter file";
776 LOG(info) <<
" Cluster radius model: Landau Distrib. "
777 "using values from fit on beam data";
781 <<
" Cluster radius model: None, this should not be!!";
784 sIndex =
" Sm Type |-- ";
785 TString sTypeMap =
" SM type in file: |-> ";
786 TString sEffType =
" Efficiency: |-> ";
787 TString sResType =
" Resolution: |-> ";
788 TString sSysResTy =
" => Sys. Res.: |-> ";
789 TString sLandMpv =
" Landau MPV: |-> ";
790 TString sLandSig =
" Landau Sigma: |-> ";
791 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
792 sIndex += Form(
"%3d ", iSmType);
807 LOG(info) << sTypeMap;
808 LOG(info) << sEffType;
809 LOG(info) << sResType;
810 LOG(info) << sSysResTy;
814 LOG(info) << sLandMpv;
815 LOG(info) << sLandSig;
820 LOG(info) <<
"=> Digitization variables: ";
824 <<
" Output ToF digi type: Expanded (Double values)";
826 LOG(info) <<
" Output ToF digi type: Re-digitized (Encoding "
829 LOG(info) <<
" Avoid multi gaps digi for same trk: ON";
831 LOG(info) <<
" Avoid multi gaps digi for same trk: OFF";
836 LOG(info) <<
" Cluster model: Use directly cluster "
837 "size (no cluster radius)";
840 LOG(info) <<
" Cluster model: Flat disc as charge "
841 "distribution + geometrical overlap";
844 LOG(info) <<
" Cluster model: 2D gaussian as "
845 "charge distribution + integral";
849 <<
" Cluster model: None, this should not be!!";
852 LOG(info) <<
"=> Simple clusterizer parameters: ";
854 LOG(info) <<
" Variable used for multiplicity cnt: Track ID";
856 LOG(info) <<
" Variable used for multiplicity cnt: TofPoint ID";
858 LOG(info) <<
" Maximal time dist. to last chan.: " <<
GetMaxTimeDist()
861 LOG(info) <<
" Maximal time dist. to last chan.: Use 5*Nom. Syst. Res. "