13#include <FairParGenericSet.h>
14#include <FairParamList.h>
19#include <TDirectory.h>
21#include <TFitResult.h>
22#include <TFitResultPtr.h>
31 : FairParGenericSet(name, title, context)
33 , fbUseOnlyPrim(kFALSE)
34 , fbOneGapTrack(kTRUE)
41 , fdSignalPropSpeed(0.0)
43 , fiNbTrackingStations(0)
57 , fiClusterRadiusModel(-1)
66 , fbMulUseTrackId(kTRUE)
67 , fdMaxTimeDistClust(0.5)
68 , fdMaxSpaceDistClust(2.5)
75 LOG(debug4) <<
"Enter CbmTofDigiBdfPar destructor";
77 LOG(debug4) <<
"Leave CbmTofDigiBdfPar destructor";
88 for (UInt_t uSmType = 0; uSmType <
fh1ClusterSize.size(); uSmType++)
90 for (UInt_t uSmType = 0; uSmType <
fh1ClusterTot.size(); uSmType++)
117 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
118 l->add(Form(
"NbGaps%03d", iSmType),
fiNbGaps[iSmType]);
119 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
120 l->add(Form(
"GapSize%03d", iSmType),
fdGapSize[iSmType]);
121 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
122 l->add(Form(
"SigVel%03d", iSmType),
fdSigVel[iSmType]);
123 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
124 l->add(Form(
"TrkStation%03d", iSmType),
fiTrkStation[iSmType]);
125 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
126 l->add(Form(
"NbCh%03d", iSmType),
fiNbCh[iSmType]);
127 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
128 l->add(Form(
"ChType%03d", iSmType),
fiChType[iSmType]);
129 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
150 LOG(debug2) <<
"Get the tof digitization parameters.";
153 if (!l->fill(
"UseExpDigi", &iTemp))
return kFALSE;
156 if (!l->fill(
"UseOnlyPrim", &iTemp))
return kFALSE;
159 if (!l->fill(
"UseOneGapPerTrk", &iTemp))
return kFALSE;
164 if (!l->fill(
"FeeTotThr", &
fdFeeTotThr))
return kFALSE;
167 if (!l->fill(
"Deadtime", &
fdDeadtime)) LOG(debug) <<
"Use default FEE deadtime of " <<
fdDeadtime <<
" ns ";
169 if (!l->fill(
"NbSmTypes", &
fiNbSmTypes))
return kFALSE;
171 LOG(debug2) <<
"CbmTofDigiBdfPar => There are " <<
fiNbSmTypes <<
" types of SM to be initialized.";
175 if (!l->fill(
"NbSm", &
fiNbSm))
return kFALSE;
178 if (!l->fill(
"NbRpc", &
fiNbRpc))
return kFALSE;
181 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
183 if (!l->fill(Form(
"NbGaps%03d", iSmType), &(
fiNbGaps[iSmType])))
return kFALSE;
187 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
189 if (!l->fill(Form(
"GapSize%03d", iSmType), &(
fdGapSize[iSmType])))
return kFALSE;
193 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
195 if (!l->fill(Form(
"SigVel%03d", iSmType), &(
fdSigVel[iSmType]))) {
196 LOG(warning) <<
"CbmTofDigiBdfPar::getParams => parameter " << Form(
"SigVel%03d", iSmType)
197 <<
" not found in the text file. "
198 <<
"This is normal for geometries < 14a but may indicate file "
200 <<
" for newer geometries. Values are set to default 0.0 cm/ns.";
201 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++)
208 LOG(info) << Form(
"SigVel%03d Array size: %d < request %d, copy values to all modules ", iSmType,
211 TArrayD temp((
fdSigVel[iSmType]).GetSize());
212 for (Int_t i = 0; i < (
fdSigVel[iSmType]).GetSize(); i++)
216 for (Int_t iSm = 0; iSm <
fiNbSm[iSmType]; iSm++) {
217 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++)
222 LOG(error) <<
"CbmTofDigiBdfPar::getParams => parameter " << Form(
"SigVel%03d", iSmType)
223 <<
" has a not matching number of fields: " << (
fdSigVel[iSmType]).GetSize() <<
" instead of "
232 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
234 if (!l->fill(Form(
"TrkStation%03d", iSmType), &(
fiTrkStation[iSmType]))) {
235 LOG(error) <<
"CbmTofDigiBdfPar::getParams => parameter " << Form(
"TrkStation%03d", iSmType)
236 <<
" not found in the text file. "
237 <<
"Initialized to 0 ";
238 for (Int_t iRpc = 0; iRpc <
fiNbSm[iSmType] *
fiNbRpc[iSmType]; iRpc++)
242 for (Int_t iRpc = 0; iRpc <
fiNbSm[iSmType] *
fiNbRpc[iSmType]; iRpc++)
247 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
249 if (!l->fill(Form(
"NbCh%03d", iSmType), &(
fiNbCh[iSmType])))
return kFALSE;
253 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
255 if (!l->fill(Form(
"ChType%03d", iSmType), &(
fiChType[iSmType])))
return kFALSE;
259 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
261 if (!l->fill(Form(
"ChOrientation%03d", iSmType), &(
fiChOrientation[iSmType])))
return kFALSE;
266 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
274 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
275 for (Int_t iSm = 0; iSm <
GetNbSm(iSmType); iSm++) {
276 for (Int_t iRpc = 0; iRpc <
GetNbRpc(iSmType); iRpc++) {
293 Int_t iMaxSizeFilename = 500;
295 sTempText =
new Text_t[iMaxSizeFilename];
296 if (!l->fill(
"BeamInputFile", sTempText, iMaxSizeFilename))
return kFALSE;
298 if (l->fill(
"BeamCalibFile", sTempText, iMaxSizeFilename))
fsBeamCalibFile = sTempText;
307 if (!l->fill(
"RadiusLandauMpv", &
fdLandauMpv))
return kFALSE;
309 if (!l->fill(
"RadLandauSigma", &
fdLandauSigma))
return kFALSE;
312 if (!l->fill(
"MulUseTrkId", &iTemp))
return kFALSE;
332 TFile* oldFile = gFile;
333 TDirectory* oldDir = gDirectory;
336 if (kFALSE == fBeamtimeInput->IsOpen()) {
337 LOG(error) <<
"CbmTofDigiBdfPar => Could not open the beamtime data file.";
342 fBeamtimeInput->GetObject(
"Efficiency", pInputEff);
343 fBeamtimeInput->GetObject(
"TimeResol", pInputRes);
344 if (0 == pInputEff) {
345 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Efficiency array "
346 "from the beamtime data file.";
349 if (0 == pInputRes) {
350 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Time Resolution "
351 "array from the beamtime data file.";
352 fBeamtimeInput->Close();
357 if (0 == pInputEff->GetSize() || 0 == pInputRes->GetSize() || pInputEff->GetSize() != pInputRes->GetSize()) {
358 LOG(error) <<
"CbmTofDigiBdfPar => Efficiency or Time Resolution array "
359 "from the beamtime data file have wrong size.";
360 fBeamtimeInput->Close();
370 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
385 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++) {
386 LOG(debug1) << iSmType <<
" Eff: " << iRpc <<
" " <<
fdEfficiency[iSmType] <<
" " <<
GetNbGaps(iSmType, iRpc)
394 fBeamtimeInput->GetObject(Form(
"h1ClusterSizeType%03d",
fiSmTypeInpMapp[iSmType]), pH1Temp);
396 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Cluster Size "
397 "histogram for Sm Type "
399 fBeamtimeInput->Close();
405 fh1ClusterSize[iSmType] = (TH1*) (pH1Temp->Clone(Form(
"ClusterSizeType%03d", iSmType)));
408 fBeamtimeInput->GetObject(Form(
"h1ClusterTot%03d",
fiSmTypeInpMapp[iSmType]), pH1Temp);
410 LOG(error) <<
"CbmTofDigiBdfPar => Could not recover the Cluster Size "
411 "histogram for Sm Type "
413 fBeamtimeInput->Close();
419 fh1ClusterTot[iSmType] = (TH1*) (pH1Temp->Clone(Form(
"ClusterTot%03d", iSmType)));
422 LOG(error) <<
"CbmTofDigiBdfPar => Wrong mapping index for Sm Type " << iSmType <<
": Out of input boundaries";
423 fBeamtimeInput->Close();
433 fBeamtimeInput->Close();
444 TFile* oldFile = gFile;
445 TDirectory* oldDir = gDirectory;
447 TFile* fSimInput =
new TFile(
"RadToClustDist_0000_1000_0010_00025_05025_00025.root",
"READ");
448 if (kFALSE == fSimInput->IsOpen()) {
449 LOG(error) <<
"CbmTofDigiBdfPar => Could not open the Simulated Landau "
450 "distribution data file.";
458 fSimInput->GetObject(
"ClustSizeFitR0All", hFitR0All);
462 fSimInput->GetObject(
"ClustSizeFitSigInAll", hFitSigInAll);
468 fSimInput->GetObject(
"hClustSizeFitR0CntAll", hFitR0CntAll);
473 TH2D* hFitSigInCntAll;
474 fSimInput->GetObject(
"hClustSizeFitSigInCntAll", hFitSigInCntAll);
475 if (0 == hFitR0All || 0 == hFitSigInAll || 0 == hFitR0CntAll || 0 == hFitSigInCntAll) {
476 LOG(error) <<
"CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Failed to "
477 "load Simulated Landau distribution values "
478 <<
" => Use default values from ASCII parameter file! Pointers: " << hFitR0All <<
" " << hFitSigInAll
479 <<
" " << hFitR0CntAll <<
" " << hFitSigInCntAll <<
" ";
489 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
490 TFitResultPtr pResult =
fh1ClusterSize[iSmType]->Fit(
"landau",
"SN");
491 if (kTRUE == pResult->IsValid()) {
493 Double_t dMpv = pResult->Parameter(1);
494 Double_t dSigma = pResult->Parameter(2);
496 if (1 == hFitR0CntAll->GetBinContent(hFitR0CntAll->FindBin(dMpv, dSigma))
497 && 1 == hFitSigInCntAll->GetBinContent(hFitSigInCntAll->FindBin(dMpv, dSigma))) {
499 fdLandauMpv[iSmType] = hFitR0All->GetBinContent(hFitR0All->FindBin(dMpv, dSigma));
500 fdLandauSigma[iSmType] = hFitSigInAll->GetBinContent(hFitSigInAll->FindBin(dMpv, dSigma));
505 LOG(warning) <<
"CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Fit "
506 "values matching a non-unique param pair for Sm Type "
507 << iSmType <<
": " << hFitR0CntAll->GetBinContent(hFitR0CntAll->FindBin(dMpv, dSigma));
508 LOG(warning) <<
" => Use default values from ASCII parameter file";
514 LOG(warning) <<
"CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Fit "
515 "failed for Sm Type "
516 << iSmType <<
" => Use default values from ASCII parameter file";
581 LOG(error) <<
"Invalid iSm " << iSm <<
", iRpc " << iRpc;
585 LOG(error) <<
"Invalid SMType " << iSmType;
603 return fiNbCh[iSmType][iRpc];
713 LOG(info) <<
" _ _ _ _ _ _ _ _ _ _ ";
714 LOG(info) <<
" |_|+|_|+|_|+|_|+|_|+|_|+|_|+|_|+|_|+|_| ";
715 LOG(info) <<
"Parameter values in CbmTofDigiBdfPar: ";
716 LOG(info) <<
"=> MC data usage: ";
718 LOG(info) <<
" Tracks used: Only Primary!";
720 LOG(info) <<
" Tracks used: All (Primary + Secondary)";
722 LOG(info) <<
"=> FEE properties: ";
723 LOG(info) <<
" FEE gain standard deviation: " << 100.0 *
fdFeeGainSigma <<
" [%]";
724 LOG(info) <<
" FEE Threshold on ToT: " <<
fdFeeTotThr <<
"[ns]";
725 LOG(info) <<
" FEE channel time resolution: " <<
fdTimeResElec <<
"[ns]";
726 LOG(info) <<
" Start channel time resolution: " <<
fdTimeResStart <<
"[ns]";
727 LOG(info) <<
" FEE deadtime: " <<
fdDeadtime <<
"[ns]";
730 LOG(info) <<
"=> Geometry variables: ";
731 LOG(info) <<
" Signal propa. speed on readout el.: " <<
fdSignalPropSpeed <<
" [cm/ns]";
732 LOG(info) <<
" Number of Super Modules (SM) Types: " <<
fiNbSmTypes;
734 TString sIndex =
" Sm Type |-- ";
735 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++)
736 sIndex += Form(
"%3d ", iSmType);
739 TString sSmNb =
" Nb SM for each SM type: |-> ";
740 TString sRpcNb =
" Nb Rpc for each SM type: |-> ";
741 sIndex =
" Rpc index |-- ";
752 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
753 sSmNb += Form(
"%3d ",
GetNbSm(iSmType));
754 sRpcNb += Form(
"%3d ",
GetNbRpc(iSmType));
755 sGapsNb[iSmType] = Form(
" Nb of Gaps in SM type %3d:|-> ", iSmType);
756 sGapsSz[iSmType] = Form(
" Gap Size(mm) in SM type %3d:|-> ", iSmType);
757 sSigVel[iSmType] = Form(
" SigVel(cm/ns) in SM type %3d:|-> ", iSmType);
758 sChNb[iSmType] = Form(
" Nb of Chan in SM type %3d:|-> ", iSmType);
759 sChType[iSmType] = Form(
" Chan Type in SM type %3d:|-> ", iSmType);
760 sChOrient[iSmType] = Form(
" Chan Orientation in SM type %3d:|-> ", iSmType);
761 sTrkStation[iSmType] = Form(
" TrackStations in SM type %3d:|-> ", iSmType);
765 for (Int_t iRpc = 0; iRpc <
fiNbRpc[iSmType]; iRpc++) {
766 sGapsNb[iSmType] += Form(
"%3d ",
GetNbGaps(iSmType, iRpc));
767 sGapsSz[iSmType] += Form(
"%3.2f ",
GetGapSize(iSmType, iRpc));
768 for (Int_t iSm = 0; iSm <
fiNbSm[iSmType]; iSm++)
769 sSigVel[iSmType] += Form(
"%4.3f ",
GetSigVel(iSmType, iSm, iRpc));
770 sChNb[iSmType] += Form(
"%3d ",
GetNbChan(iSmType, iRpc));
772 sChType[iSmType] +=
"pad ";
774 sChType[iSmType] +=
"str ";
776 sChOrient[iSmType] += Form(
" %d ",
GetChanOrient(iSmType, iRpc));
777 for (Int_t iSm = 0; iSm <
fiNbSm[iSmType]; iSm++)
781 for (Int_t iRpc = 0; iRpc < iMaxRpcNb; iRpc++)
782 sIndex += Form(
"%3d ", iRpc);
787 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
788 LOG(info) << sGapsNb[iSmType];
789 LOG(info) << sGapsSz[iSmType];
790 LOG(debug) << sSigVel[iSmType];
791 LOG(info) << sChNb[iSmType];
792 LOG(info) << sChType[iSmType];
793 LOG(info) << sChOrient[iSmType];
794 LOG(info) << sTrkStation[iSmType];
798 LOG(info) <<
"=> Beamtime variables: ";
802 case -1: LOG(info) <<
" Cluster radius model: Single value at 0.0002 cm";
break;
804 LOG(info) <<
" Cluster radius model: Single value using "
805 "beamtime mean cluster size";
808 LOG(info) <<
" Cluster radius model: Landau Distrib. "
809 "using values from parameter file";
812 LOG(info) <<
" Cluster radius model: Landau Distrib. "
813 "using values from fit on beam data";
815 default: LOG(info) <<
" Cluster radius model: None, this should not be!!";
break;
817 sIndex =
" Sm Type |-- ";
818 TString sTypeMap =
" SM type in file: |-> ";
819 TString sEffType =
" Efficiency: |-> ";
820 TString sResType =
" Resolution: |-> ";
821 TString sSysResTy =
" => Sys. Res.: |-> ";
822 TString sLandMpv =
" Landau MPV: |-> ";
823 TString sLandSig =
" Landau Sigma: |-> ";
824 for (Int_t iSmType = 0; iSmType <
fiNbSmTypes; iSmType++) {
825 sIndex += Form(
"%3d ", iSmType);
840 LOG(info) << sTypeMap;
841 LOG(info) << sEffType;
842 LOG(info) << sResType;
843 LOG(info) << sSysResTy;
847 LOG(info) << sLandMpv;
848 LOG(info) << sLandSig;
853 LOG(info) <<
"=> Digitization variables: ";
856 LOG(info) <<
" Output ToF digi type: Expanded (Double values)";
858 LOG(info) <<
" Output ToF digi type: Re-digitized (Encoding "
861 LOG(info) <<
" Avoid multi gaps digi for same trk: ON";
863 LOG(info) <<
" Avoid multi gaps digi for same trk: OFF";
868 LOG(info) <<
" Cluster model: Use directly cluster "
869 "size (no cluster radius)";
872 LOG(info) <<
" Cluster model: Flat disc as charge "
873 "distribution + geometrical overlap";
876 LOG(info) <<
" Cluster model: 2D gaussian as "
877 "charge distribution + integral";
879 default: LOG(info) <<
" Cluster model: None, this should not be!!";
break;
881 LOG(info) <<
"=> Simple clusterizer parameters: ";
883 LOG(info) <<
" Variable used for multiplicity cnt: Track ID";
885 LOG(info) <<
" Variable used for multiplicity cnt: TofPoint ID";
887 LOG(info) <<
" Maximal time dist. to last chan.: " <<
GetMaxTimeDist() <<
" [ns]";
889 LOG(info) <<
" Maximal time dist. to last chan.: Use 5*Nom. Syst. Res. "
909 const Int_t
DetMask = 0x1fffff;
ClassImp(CbmTofDigiBdfPar) CbmTofDigiBdfPar
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
Parameters class for the CBM ToF digitizer using beam data distributions.
std::vector< TArrayD > fdGapSize
Bool_t LoadBeamtimeHistos()
CbmTofDigiBdfPar(const char *name="CbmTofDigiBdfPar", const char *title="BDF Digitization parameters for the TOF detector", const char *context="TestDefaultContext")
Double_t GetResolution(Int_t iSmType) const
void SetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc, Double_t dvel)
Double_t GetGapSize(Int_t iSmType, Int_t iRpc) const
Int_t GetTypeInputMap(Int_t iSmType) const
Double_t fdMaxSpaceDistClust
std::vector< TArrayI > fiTrkStation
Int_t GetNbSm(Int_t iSmType) const
Int_t GetNbChan(Int_t iSmType, Int_t iRpc) const
Double_t fdSignalPropSpeed
Int_t GetDetInd(Int_t iAddr)
Double_t GetEfficiency(Int_t iSmType) const
std::vector< TH1 * > fh1ClusterTot
Bool_t getParams(FairParamList *)
std::vector< TArrayD > fdSigVel
std::vector< TArrayI > fiNbGaps
Double_t GetGapEfficiency(Int_t iSmType, Int_t iRpc) const
TH1 * GetClustSizeHist(Int_t iSmType) const
std::vector< TArrayI > fiNbCh
Int_t fiClusterRadiusModel
Bool_t GetLandauParFromBeamDataFit()
Int_t GetNbGaps(Int_t iSmType, Int_t iRpc) const
void putParams(FairParamList *)
Int_t GetChanType(Int_t iSmType, Int_t iRpc) const
Int_t GetNbRpc(Int_t iSmType) const
Double_t GetLandauMpv(Int_t iSmType) const
Int_t fiNbTrackingStations
Double_t GetMaxTimeDist() const
std::vector< TArrayI > fiChOrientation
std::vector< TArrayD > fdGapsEfficiency
Double_t GetSystemResolution(Int_t iSmType) const
Int_t GetChanOrient(Int_t iSmType, Int_t iRpc) const
std::vector< TH1 * > fh1ClusterSize
Double_t GetLandauSigma(Int_t iSmType) const
Int_t GetDetUId(Int_t iDet)
std::vector< TArrayI > fiChType
Int_t GetTrackingStation(Int_t iSmType, Int_t iSm, Int_t iRpc) const
Double_t GetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc) const
Double_t fdMaxTimeDistClust
TH1 * GetClustTotHist(Int_t iSmType) const
std::map< Int_t, Int_t > fMapDetInd