CbmRoot
Loading...
Searching...
No Matches
CbmTofDigiBdfPar.cxx
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Florian Uhlig [committer] */
4
9#include "CbmTofDigiBdfPar.h"
10
11#include "CbmTofAddress.h" // for CbmTofAddress
12
13#include <FairParGenericSet.h> // for FairParGenericSet
14#include <FairParamList.h> // for FairParamList
15#include <Logger.h> // for LOG, Logger
16
17#include <TArrayD.h> // for TArrayD
18#include <TArrayI.h> // for TArrayI
19#include <TDirectory.h> // for TDirectory, gDirectory
20#include <TFile.h> // for TFile
21#include <TFitResult.h> // for TFitResult
22#include <TFitResultPtr.h> // for TFitResultPtr
23#include <TH1.h> // for TH1
24#include <TH2.h> // for TH2D
25#include <TMath.h> // for Power, Sqrt
26#include <TROOT.h> // for TROOT, gROOT
27
29
30 CbmTofDigiBdfPar::CbmTofDigiBdfPar(const char* name, const char* title, const char* context)
31 : FairParGenericSet(name, title, context)
32 , fbUseExpDigi(kTRUE)
33 , fbUseOnlyPrim(kFALSE)
34 , fbOneGapTrack(kTRUE)
35 , fiClusterModel(0)
36 , fdFeeGainSigma(0.0)
37 , fdFeeTotThr(0.0)
38 , fdTimeResElec(0.0)
39 , fdTimeResStart(0.0)
40 , fdDeadtime(5.0)
41 , fdSignalPropSpeed(0.0)
42 , fiNbSmTypes(0)
43 , fiNbTrackingStations(0)
44 , fiNbSm()
45 , fiNbRpc()
46 , fiNbGaps()
47 , fdGapSize()
48 , fdSigVel()
49 , fiTrkStation()
50 , fiNbCh()
51 , fiChType()
52 , fiChOrientation()
53 , fiDetUId()
54 , fMapDetInd()
55 , fsBeamInputFile("")
56 , fsBeamCalibFile("")
57 , fiClusterRadiusModel(-1)
58 , fiSmTypeInpMapp()
59 , fdEfficiency()
60 , fdGapsEfficiency()
61 , fdTimeResolution()
62 , fh1ClusterSize()
63 , fh1ClusterTot()
64 , fdLandauMpv()
65 , fdLandauSigma()
66 , fbMulUseTrackId(kTRUE)
67 , fdMaxTimeDistClust(0.5)
68 , fdMaxSpaceDistClust(2.5)
69{
70 detName = "Tof";
71}
72
74{
75 LOG(debug4) << "Enter CbmTofDigiBdfPar destructor";
76 clear();
77 LOG(debug4) << "Leave CbmTofDigiBdfPar destructor";
78}
79
81{
82 status = kFALSE;
83 resetInputVersions();
85}
87{
88 for (UInt_t uSmType = 0; uSmType < fh1ClusterSize.size(); uSmType++)
89 delete fh1ClusterSize[uSmType];
90 for (UInt_t uSmType = 0; uSmType < fh1ClusterTot.size(); uSmType++)
91 delete fh1ClusterTot[uSmType];
92 fh1ClusterSize.clear();
93 fh1ClusterTot.clear();
94}
95
96void CbmTofDigiBdfPar::putParams(FairParamList* l)
97{
98 if (!l) {
99 return;
100 }
101
102 l->add("UseExpDigi", (Int_t) fbUseExpDigi);
103 l->add("UseOnlyPrim", (Int_t) fbUseOnlyPrim);
104 l->add("ClusterModel", fiClusterModel);
105 l->add("FeeGainSigma", fdFeeGainSigma);
106 l->add("FeeTotThr", fdFeeTotThr);
107 l->add("TimeResElec", fdTimeResElec);
108 l->add("TimeResStart", fdTimeResStart);
109 l->add("Deadtime", fdDeadtime);
110 l->add("SignalPropSpeed", fdSignalPropSpeed);
111 l->add("NbSmTypes", fiNbSmTypes);
112 l->add("NbSm", fiNbSm);
113 l->add("NbRpc", fiNbRpc);
114 // l->add("NbCh", fiNbCh);
115 // l->add("ChType", fiChType);
116 // l->add("ChOrientation", fiChOrientation);
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++)
130 l->add(Form("ChOrientation%03d", iSmType), fiChOrientation[iSmType]);
131 l->add("BeamInputFile", fsBeamInputFile);
132 l->add("BeamCalibFile", fsBeamCalibFile);
133 l->add("ClusterRadiusModel", fiClusterRadiusModel);
134 l->add("SmTypeInpMapp", fiSmTypeInpMapp);
135 if (1 == fiClusterRadiusModel) {
136 l->add("RadiusLandauMpv", fdLandauMpv);
137 l->add("RadLandauSigma", fdLandauSigma);
138 } // if( 1 == fiClusterRadiusModel )
139 l->add("MulUseTrkId", (Int_t) fbUseOnlyPrim);
140 l->add("MaxTimeDistClust", fdMaxTimeDistClust);
141 l->add("MaxSpaceDistClust", fdMaxSpaceDistClust);
142}
143
144Bool_t CbmTofDigiBdfPar::getParams(FairParamList* l)
145{
146 if (!l) {
147 return kFALSE;
148 }
149
150 LOG(debug2) << "Get the tof digitization parameters.";
151
152 Int_t iTemp;
153 if (!l->fill("UseExpDigi", &iTemp)) return kFALSE;
154 fbUseExpDigi = (1 == iTemp ? kTRUE : kFALSE);
155
156 if (!l->fill("UseOnlyPrim", &iTemp)) return kFALSE;
157 fbUseOnlyPrim = (1 == iTemp ? kTRUE : kFALSE);
158
159 if (!l->fill("UseOneGapPerTrk", &iTemp)) return kFALSE;
160 fbOneGapTrack = (1 == iTemp ? kTRUE : kFALSE);
161
162 if (!l->fill("ClusterModel", &fiClusterModel)) return kFALSE;
163 if (!l->fill("FeeGainSigma", &fdFeeGainSigma)) return kFALSE;
164 if (!l->fill("FeeTotThr", &fdFeeTotThr)) return kFALSE;
165 if (!l->fill("TimeResElec", &fdTimeResElec)) return kFALSE;
166 if (!l->fill("TimeResStart", &fdTimeResStart)) return kFALSE;
167 if (!l->fill("Deadtime", &fdDeadtime)) LOG(debug) << "Use default FEE deadtime of " << fdDeadtime << " ns ";
168 if (!l->fill("SignalPropSpeed", &fdSignalPropSpeed)) return kFALSE;
169 if (!l->fill("NbSmTypes", &fiNbSmTypes)) return kFALSE;
170
171 LOG(debug2) << "CbmTofDigiBdfPar => There are " << fiNbSmTypes << " types of SM to be initialized.";
172
173
174 fiNbSm.Set(fiNbSmTypes);
175 if (!l->fill("NbSm", &fiNbSm)) return kFALSE;
176
177 fiNbRpc.Set(fiNbSmTypes);
178 if (!l->fill("NbRpc", &fiNbRpc)) return kFALSE;
179
180 fiNbGaps.resize(fiNbSmTypes);
181 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
182 fiNbGaps[iSmType].Set(fiNbRpc[iSmType]);
183 if (!l->fill(Form("NbGaps%03d", iSmType), &(fiNbGaps[iSmType]))) return kFALSE;
184 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
185
186 fdGapSize.resize(fiNbSmTypes);
187 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
188 fdGapSize[iSmType].Set(fiNbRpc[iSmType]);
189 if (!l->fill(Form("GapSize%03d", iSmType), &(fdGapSize[iSmType]))) return kFALSE;
190 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
191
192 fdSigVel.resize(fiNbSmTypes);
193 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
194 fdSigVel[iSmType].Set(fiNbSm[iSmType] * fiNbRpc[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 "
199 "corruption "
200 << " for newer geometries. Values are set to default 0.0 cm/ns.";
201 for (Int_t iRpc = 0; iRpc < fiNbRpc[iSmType]; iRpc++)
202 fdSigVel[iSmType].SetAt(0.0, iRpc);
203 //return kFALSE;
204 } // if ( ! l->fill( Form("SigVel%03d", iSmType), &(fdSigVel[iSmType]) ) )
205
206 if ((fdSigVel[iSmType]).GetSize() < fiNbSm[iSmType] * fiNbRpc[iSmType]) {
207 if ((fdSigVel[iSmType]).GetSize() == fiNbRpc[iSmType]) {
208 LOG(info) << Form("SigVel%03d Array size: %d < request %d, copy values to all modules ", iSmType,
209 (Int_t)(fdSigVel[iSmType]).GetSize(), fiNbSm[iSmType] * fiNbRpc[iSmType]);
210
211 TArrayD temp((fdSigVel[iSmType]).GetSize()); // temporary copy of data
212 for (Int_t i = 0; i < (fdSigVel[iSmType]).GetSize(); i++)
213 temp[i] = fdSigVel[iSmType][i];
214
215 fdSigVel[iSmType].Set(fiNbSm[iSmType] * fiNbRpc[iSmType]);
216 for (Int_t iSm = 0; iSm < fiNbSm[iSmType]; iSm++) { // fill elements for all SMs
217 for (Int_t iRpc = 0; iRpc < fiNbRpc[iSmType]; iRpc++)
218 fdSigVel[iSmType][iSm * fiNbRpc[iSmType] + iRpc] = temp[iRpc];
219 }
220 } // if( (fdSigVel[iSmType]).GetSize() == fiNbRpc[iSmType] )
221 else {
222 LOG(error) << "CbmTofDigiBdfPar::getParams => parameter " << Form("SigVel%03d", iSmType)
223 << " has a not matching number of fields: " << (fdSigVel[iSmType]).GetSize() << " instead of "
224 << fiNbRpc[iSmType] << " or " << fiNbSm[iSmType] * fiNbRpc[iSmType];
225 return kFALSE;
226 } // else of if( (fdSigVel[iSmType]).GetSize() == fiNbRpc[iSmType] )
227 }
228
229 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
230
232 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
233 fiTrkStation[iSmType].Set(fiNbSm[iSmType] * fiNbRpc[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++)
239 fiTrkStation[iSmType].SetAt(0, iRpc);
240 //return kFALSE;
241 } // if ( ! l->fill( Form("SigVel%03d", iSmType), &(fdSigVel[iSmType]) ) )
242 for (Int_t iRpc = 0; iRpc < fiNbSm[iSmType] * fiNbRpc[iSmType]; iRpc++)
243 fiNbTrackingStations = TMath::Max(fiNbTrackingStations, fiTrkStation[iSmType][iRpc] + 1);
244 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
245
246 fiNbCh.resize(fiNbSmTypes);
247 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
248 fiNbCh[iSmType].Set(fiNbRpc[iSmType]);
249 if (!l->fill(Form("NbCh%03d", iSmType), &(fiNbCh[iSmType]))) return kFALSE;
250 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
251
252 fiChType.resize(fiNbSmTypes);
253 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
254 fiChType[iSmType].Set(fiNbRpc[iSmType]);
255 if (!l->fill(Form("ChType%03d", iSmType), &(fiChType[iSmType]))) return kFALSE;
256 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
257
259 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
260 fiChOrientation[iSmType].Set(fiNbRpc[iSmType]);
261 if (!l->fill(Form("ChOrientation%03d", iSmType), &(fiChOrientation[iSmType]))) return kFALSE;
262 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
263
264
265 Int_t nDet = 0;
266 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
267 nDet += GetNbSm(iSmType) * GetNbRpc(iSmType);
268 }
269
270 fiDetUId.Set(nDet); // dimension unique identifier array
271 fMapDetInd.clear(); // reset
272
273 Int_t iDet = 0;
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++) {
277 Int_t iAddr = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType);
278 fMapDetInd[iAddr] = iDet;
279 fiDetUId[iDet++] = iAddr;
280 }
281 }
282 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
283 /*
284 fiChType.Set(fiNbSmTypes);
285 if ( ! l->fill("", &) ) return kFALSE;
286
287 .Set(fiNbSmTypes);
288 if ( ! l->fill("", &) ) return kFALSE;
289*/
290 // Use Text_t as FairParamList does not seem to support TStrings yet
291
292
293 Int_t iMaxSizeFilename = 500;
294 Text_t* sTempText;
295 sTempText = new Text_t[iMaxSizeFilename];
296 if (!l->fill("BeamInputFile", sTempText, iMaxSizeFilename)) return kFALSE;
297 fsBeamInputFile = sTempText;
298 if (l->fill("BeamCalibFile", sTempText, iMaxSizeFilename)) fsBeamCalibFile = sTempText;
299
300 if (!l->fill("ClusterRadiusModel", &fiClusterRadiusModel)) return kFALSE;
301
303 if (!l->fill("SmTypeInpMapp", &fiSmTypeInpMapp)) return kFALSE;
304
305 if (1 <= fiClusterRadiusModel) {
307 if (!l->fill("RadiusLandauMpv", &fdLandauMpv)) return kFALSE;
309 if (!l->fill("RadLandauSigma", &fdLandauSigma)) return kFALSE;
310 } // if( 1 <= fiClusterRadiusModel )
311
312 if (!l->fill("MulUseTrkId", &iTemp)) return kFALSE;
313 fbMulUseTrackId = (1 == iTemp ? kTRUE : kFALSE);
314
315 if (!l->fill("MaxTimeDistClust", &fdMaxTimeDistClust)) return kFALSE;
316 if (!l->fill("MaxSpaceDistClust", &fdMaxSpaceDistClust)) return kFALSE;
317
318 // Extract beamtime parameters from file
321 // So that the histos are not created in more than 1 exemplar in case of a double call to this method
322 ClearHistos();
325
326 return kTRUE;
327}
328
330{
332 TFile* oldFile = gFile;
333 TDirectory* oldDir = gDirectory;
334
335 TFile* fBeamtimeInput = new TFile(fsBeamInputFile, "READ");
336 if (kFALSE == fBeamtimeInput->IsOpen()) {
337 LOG(error) << "CbmTofDigiBdfPar => Could not open the beamtime data file.";
338 return kFALSE;
339 } // if( kFALSE == fBeamtimeInput->IsOpen() )
340 TArrayD* pInputEff;
341 TArrayD* pInputRes;
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.";
347 return kFALSE;
348 } // if( 0 == pInputEff)
349 if (0 == pInputRes) {
350 LOG(error) << "CbmTofDigiBdfPar => Could not recover the Time Resolution "
351 "array from the beamtime data file.";
352 fBeamtimeInput->Close();
353 gFile = oldFile;
354 gDirectory = oldDir;
355 return kFALSE;
356 } // if( 0 == pInputEff)
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();
362 gFile = oldFile;
363 gDirectory = oldDir;
364 return kFALSE;
365 } // if wrong array size
366
367 TH1* pH1Temp;
368 gROOT->cd();
370 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++)
371 if (fiSmTypeInpMapp[iSmType] < pInputEff->GetSize()) {
372 fdEfficiency[iSmType] = pInputEff->GetAt(fiSmTypeInpMapp[iSmType]);
373
374 // For now use a simple gap treatment:
375 // - a single fired gap fires the channel
376 // - all gaps have exactly equivalent efficiency/firing probability
377 // - independent gap firing (no charge accumulation or such)
378 // The probability for a hit not to fire at all is then
379 // (1-p)^NGaps with p = gap efficiency and Ngaps the number of gaps in this RPC
380 // This results in the relation: p = 1 - (1 - P)^(1/Ngaps)
381 // with P = RPC efficiency from beamtime
382 fdGapsEfficiency[iSmType].Set(fiNbRpc[iSmType]);
383 fdTimeResolution[iSmType] = pInputRes->GetAt(fiSmTypeInpMapp[iSmType]);
384
385 for (Int_t iRpc = 0; iRpc < fiNbRpc[iSmType]; iRpc++) {
386 LOG(debug1) << iSmType << " Eff: " << iRpc << " " << fdEfficiency[iSmType] << " " << GetNbGaps(iSmType, iRpc)
387 << " " << (Double_t) GetNbGaps(iSmType, iRpc) << " TRes " << fdTimeResolution[iSmType];
388 fdGapsEfficiency[iSmType][iRpc] =
389 1 - TMath::Power(1.0 - fdEfficiency[iSmType], 1.0 / (Double_t) GetNbGaps(iSmType, iRpc));
390 }
391
392
393 // Cluster Size histograms
394 fBeamtimeInput->GetObject(Form("h1ClusterSizeType%03d", fiSmTypeInpMapp[iSmType]), pH1Temp);
395 if (0 == pH1Temp) {
396 LOG(error) << "CbmTofDigiBdfPar => Could not recover the Cluster Size "
397 "histogram for Sm Type "
398 << iSmType << ", mapped to input type " << fiSmTypeInpMapp[iSmType];
399 fBeamtimeInput->Close();
401 gFile = oldFile;
402 gDirectory = oldDir;
403 return kFALSE;
404 } // if( 0 == pH1Temp )
405 fh1ClusterSize[iSmType] = (TH1*) (pH1Temp->Clone(Form("ClusterSizeType%03d", iSmType)));
406
407 // Cluster Total ToT histograms
408 fBeamtimeInput->GetObject(Form("h1ClusterTot%03d", fiSmTypeInpMapp[iSmType]), pH1Temp);
409 if (0 == pH1Temp) {
410 LOG(error) << "CbmTofDigiBdfPar => Could not recover the Cluster Size "
411 "histogram for Sm Type "
412 << iSmType << ", mapped to input type " << fiSmTypeInpMapp[iSmType];
413 fBeamtimeInput->Close();
415 gFile = oldFile;
416 gDirectory = oldDir;
417 return kFALSE;
418 } // if( 0 == pH1Temp )
419 fh1ClusterTot[iSmType] = (TH1*) (pH1Temp->Clone(Form("ClusterTot%03d", iSmType)));
420 } // if( fiSmTypeInpMapp[iSmType] < pInputEff->GetSize() )
421 else {
422 LOG(error) << "CbmTofDigiBdfPar => Wrong mapping index for Sm Type " << iSmType << ": Out of input boundaries";
423 fBeamtimeInput->Close();
425 gFile = oldFile;
426 gDirectory = oldDir;
427 return kFALSE;
428 }
429
430 if (2 == fiClusterRadiusModel) {
432 } // if( 2 == fiClusterRadiusModel )
433 fBeamtimeInput->Close();
435 gFile = oldFile;
436 gDirectory = oldDir;
437
438 return kTRUE;
439}
440/************************************************************************************/
442{
444 TFile* oldFile = gFile;
445 TDirectory* oldDir = gDirectory;
446
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.";
451 return kFALSE;
452 } // if( kFALSE == fSimInput->IsOpen() )
453
454 // Get the input histograms from the Simulated Landau distributions file
455 // R0 value of the Landau distribution used to generate a simple cluster size distribution as function of
456 // the MPV and sigma values of a Landau fit on said Cluster size distribution
457 TH2D* hFitR0All;
458 fSimInput->GetObject("ClustSizeFitR0All", hFitR0All);
459 // Input Sigma value of the Landau distribution used to generate a simple cluster size distribution as function of
460 // the MPV and sigma values of a Landau fit on said Cluster size distribution
461 TH2D* hFitSigInAll;
462 fSimInput->GetObject("ClustSizeFitSigInAll", hFitSigInAll);
463 // Number of entries for each bin of the R0 of a Landau Input distribution as function of
464 // the MPV and sigma values of a Landau fit on the corresponding Cluster size distribution
465 // The (R0, Input Sigma) pair can be used only if it is one, otherwise it means that more than 1 Cluster Size
466 // distribution gave these values after being fitted with a Landau
467 TH2D* hFitR0CntAll;
468 fSimInput->GetObject("hClustSizeFitR0CntAll", hFitR0CntAll);
469 // Number of entries for each bin of the Sigma of a Landau Input distribution as function of
470 // the MPV and sigma values of a Landau fit on the corresponding Cluster size distribution
471 // The (R0, Input Sigma) pair can be used only if it is one, otherwise it means that more than 1 Cluster Size
472 // distribution gave these values after being fitted with a Landau
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 << " ";
481 gFile = oldFile;
482 gDirectory = oldDir;
483 return kFALSE;
484 } // if( 0 == hFitR0All || 0 == hFitSigInAll || 0 == hFitR0CntAll || 0 == hFitSigInCntAll )
485
486 // Prepare the TArrayD
489 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++) {
490 TFitResultPtr pResult = fh1ClusterSize[iSmType]->Fit("landau", "SN");
491 if (kTRUE == pResult->IsValid()) {
492 // Fit succedeed
493 Double_t dMpv = pResult->Parameter(1);
494 Double_t dSigma = pResult->Parameter(2);
495
496 if (1 == hFitR0CntAll->GetBinContent(hFitR0CntAll->FindBin(dMpv, dSigma))
497 && 1 == hFitSigInCntAll->GetBinContent(hFitSigInCntAll->FindBin(dMpv, dSigma))) {
498 // Unique Cluster size distribution giving these values
499 fdLandauMpv[iSmType] = hFitR0All->GetBinContent(hFitR0All->FindBin(dMpv, dSigma));
500 fdLandauSigma[iSmType] = hFitSigInAll->GetBinContent(hFitSigInAll->FindBin(dMpv, dSigma));
501 } // if unique pair
502 else {
503 // Pair is not unique
504 // => Do nothing, as default parameters should have been previously loaded
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";
509 } // Nor unique pair
510 } // if( kTRUE == pResult->IsValid() )
511 else {
512 // Fit failed
513 // => Do nothing, as default parameters should have been previously loaded
514 LOG(warning) << "CbmTofDigiBdfPar::GetLandauParFromBeamDataFit => Fit "
515 "failed for Sm Type "
516 << iSmType << " => Use default values from ASCII parameter file";
517 } // else of if( kTRUE == pResult->IsValid() )
518 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
519
521 gFile = oldFile;
522 gDirectory = oldDir;
523
524 return kTRUE;
525}
526/************************************************************************************/
527// Geometry variables
528Int_t CbmTofDigiBdfPar::GetNbSm(Int_t iSmType) const
529{
530 if (iSmType < fiNbSmTypes)
531 return fiNbSm[iSmType];
532 else
533 return 0;
534}
535Int_t CbmTofDigiBdfPar::GetNbRpc(Int_t iSmType) const
536{
537 if (iSmType < fiNbSmTypes)
538 return fiNbRpc[iSmType];
539 else
540 return 0;
541}
542Int_t CbmTofDigiBdfPar::GetNbGaps(Int_t iSmType, Int_t iRpc) const
543{
544 if (iSmType < fiNbSmTypes) {
545 if (iRpc < fiNbRpc[iSmType])
546 return fiNbGaps[iSmType][iRpc];
547 else
548 return 0;
549 } // if( iSmType < fiNbSmTypes )
550 else
551 return 0;
552}
553Double_t CbmTofDigiBdfPar::GetGapSize(Int_t iSmType, Int_t iRpc) const
554{
555 if (iSmType < fiNbSmTypes) {
556 if (iRpc < fiNbRpc[iSmType])
557 return fdGapSize[iSmType][iRpc];
558 else
559 return 0.0;
560 } // if( iSmType < fiNbSmTypes )
561 else
562 return 0.0;
563}
564Double_t CbmTofDigiBdfPar::GetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc) const
565{
566 if (iSmType < fiNbSmTypes) {
567 if (iSm < fiNbSm[iSmType] && iRpc < fiNbRpc[iSmType])
568 return fdSigVel[iSmType][iSm * fiNbRpc[iSmType] + iRpc];
569 else
570 return 0.0;
571 } // if( iSmType < fiNbSmTypes )
572 else
573 return 0.0;
574}
575void CbmTofDigiBdfPar::SetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc, Double_t vel)
576{
577 if (iSmType > -1 && iSmType < fiNbSmTypes) {
578 if (iSm < fiNbSm[iSmType] && iRpc < fiNbRpc[iSmType])
579 fdSigVel[iSmType][iSm * fiNbRpc[iSmType] + iRpc] = vel;
580 else {
581 LOG(error) << "Invalid iSm " << iSm << ", iRpc " << iRpc;
582 }
583 }
584 else {
585 LOG(error) << "Invalid SMType " << iSmType;
586 }
587}
588Int_t CbmTofDigiBdfPar::GetTrackingStation(Int_t iSmType, Int_t iSm, Int_t iRpc) const
589{
590 if (iSmType < fiNbSmTypes) {
591 if (iSm < fiNbSm[iSmType] && iRpc < fiNbRpc[iSmType])
592 return fiTrkStation[iSmType][iSm * fiNbRpc[iSmType] + iRpc];
593 else
594 return 0;
595 } // if( iSmType < fiNbSmTypes )
596 else
597 return 0;
598}
599Int_t CbmTofDigiBdfPar::GetNbChan(Int_t iSmType, Int_t iRpc) const
600{
601 if (iSmType < fiNbSmTypes) {
602 if (iRpc < fiNbRpc[iSmType])
603 return fiNbCh[iSmType][iRpc];
604 else
605 return 0;
606 } // if( iSmType < fiNbSmTypes )
607 else
608 return 0;
609}
610Int_t CbmTofDigiBdfPar::GetChanType(Int_t iSmType, Int_t iRpc) const
611{
612 if (iSmType < fiNbSmTypes) {
613 if (iRpc < fiNbRpc[iSmType])
614 return fiChType[iSmType][iRpc];
615 else
616 return 0;
617 } // if( iSmType < fiNbSmTypes )
618 else
619 return 0;
620}
621Int_t CbmTofDigiBdfPar::GetChanOrient(Int_t iSmType, Int_t iRpc) const
622{
623 if (iSmType < fiNbSmTypes) {
624 if (iRpc < fiNbRpc[iSmType])
625 return fiChOrientation[iSmType][iRpc];
626 else
627 return 0;
628 } // if( iSmType < fiNbSmTypes )
629 else
630 return 0;
631}
632// Beamtime variables
633Int_t CbmTofDigiBdfPar::GetTypeInputMap(Int_t iSmType) const
634{
635 if (iSmType < fiNbSmTypes)
636 return fiSmTypeInpMapp[iSmType];
637 else
638 return 0;
639}
640Double_t CbmTofDigiBdfPar::GetEfficiency(Int_t iSmType) const
641{
642 if (iSmType < fiNbSmTypes)
643 return fdEfficiency[iSmType];
644 else
645 return 0;
646}
647Double_t CbmTofDigiBdfPar::GetGapEfficiency(Int_t iSmType, Int_t iRpc) const
648{
649 if (iSmType < fiNbSmTypes) {
650 if (iRpc < fiNbRpc[iSmType])
651 return fdGapsEfficiency[iSmType][iRpc];
652 else
653 return 0;
654 } // if( iSmType < fiNbSmTypes )
655 else
656 return 0;
657}
658Double_t CbmTofDigiBdfPar::GetResolution(Int_t iSmType) const
659{
660 if (iSmType < fiNbSmTypes)
661 return fdTimeResolution[iSmType];
662 else
663 return 0;
664}
665Double_t CbmTofDigiBdfPar::GetSystemResolution(Int_t iSmType) const
666{
667 if (iSmType < fiNbSmTypes)
669 + fdTimeResolution[iSmType] * fdTimeResolution[iSmType]);
670 else
671 return 0;
672}
673TH1* CbmTofDigiBdfPar::GetClustSizeHist(Int_t iSmType) const
674{
675 if (iSmType < fiNbSmTypes)
676 return fh1ClusterSize[iSmType];
677 else
678 return 0;
679}
680TH1* CbmTofDigiBdfPar::GetClustTotHist(Int_t iSmType) const
681{
682 if (iSmType < fiNbSmTypes)
683 return fh1ClusterTot[iSmType];
684 else
685 return 0;
686}
687Double_t CbmTofDigiBdfPar::GetLandauMpv(Int_t iSmType) const
688{
689 if (iSmType < fiNbSmTypes)
690 return fdLandauMpv[iSmType];
691 else
692 return 0;
693}
694Double_t CbmTofDigiBdfPar::GetLandauSigma(Int_t iSmType) const
695{
696 if (iSmType < fiNbSmTypes)
697 return fdLandauSigma[iSmType];
698 else
699 return 0;
700}
702{
703 if (-1 < fdMaxTimeDistClust)
704 return fdMaxTimeDistClust;
705 else
706 return 5 * 0.08;
707}
709{
710 // LOG(info)<<" _ _ _ _ _ _ _ _ _ _ ";
711 // LOG(info)<<" / \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \ ";
712 // LOG(info)<<" \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ ";
713 LOG(info) << " _ _ _ _ _ _ _ _ _ _ ";
714 LOG(info) << " |_|+|_|+|_|+|_|+|_|+|_|+|_|+|_|+|_|+|_| ";
715 LOG(info) << "Parameter values in CbmTofDigiBdfPar: ";
716 LOG(info) << "=> MC data usage: ";
717 if (kTRUE == fbUseOnlyPrim)
718 LOG(info) << " Tracks used: Only Primary!";
719 else
720 LOG(info) << " Tracks used: All (Primary + Secondary)";
721 // Fee properties
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]";
728
729 // Geometry variables
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;
733
734 TString sIndex = " Sm Type |-- ";
735 for (Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType++)
736 sIndex += Form("%3d ", iSmType);
737 LOG(info) << sIndex;
738
739 TString sSmNb = " Nb SM for each SM type: |-> ";
740 TString sRpcNb = " Nb Rpc for each SM type: |-> ";
741 sIndex = " Rpc index |-- ";
742 Int_t iMaxRpcNb = 0;
743
744 TString* sGapsNb = new TString[fiNbSmTypes];
745 TString* sGapsSz = new TString[fiNbSmTypes];
746 TString* sSigVel = new TString[fiNbSmTypes];
747 TString* sChNb = new TString[fiNbSmTypes];
748 TString* sChType = new TString[fiNbSmTypes];
749 TString* sChOrient = new TString[fiNbSmTypes];
750 TString* sTrkStation = new TString[fiNbSmTypes];
751
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);
762 if (iMaxRpcNb < fiNbRpc[iSmType]) iMaxRpcNb = fiNbRpc[iSmType];
763
764
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));
771 if (1 == GetChanType(iSmType, iRpc))
772 sChType[iSmType] += "pad ";
773 else
774 sChType[iSmType] += "str ";
775
776 sChOrient[iSmType] += Form(" %d ", GetChanOrient(iSmType, iRpc));
777 for (Int_t iSm = 0; iSm < fiNbSm[iSmType]; iSm++)
778 sTrkStation[iSmType] += Form(" %d ", GetTrackingStation(iSmType, iSm, iRpc));
779 }
780 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
781 for (Int_t iRpc = 0; iRpc < iMaxRpcNb; iRpc++)
782 sIndex += Form("%3d ", iRpc);
783
784 LOG(info) << sSmNb;
785 LOG(info) << sRpcNb;
786 LOG(info) << sIndex;
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];
795 } // for( Int_t iSmType = 0; iSmType < fiNbSmTypes; iSmType ++)
796
797 // Beamtime variables
798 LOG(info) << "=> Beamtime variables: ";
799 LOG(info) << " Beamtime data input file name: " << fsBeamInputFile;
800 LOG(info) << " Beamtime data calib file name: " << fsBeamCalibFile;
801 switch (fiClusterRadiusModel) {
802 case -1: LOG(info) << " Cluster radius model: Single value at 0.0002 cm"; break;
803 case 0:
804 LOG(info) << " Cluster radius model: Single value using "
805 "beamtime mean cluster size";
806 break;
807 case 1:
808 LOG(info) << " Cluster radius model: Landau Distrib. "
809 "using values from parameter file";
810 break;
811 case 2:
812 LOG(info) << " Cluster radius model: Landau Distrib. "
813 "using values from fit on beam data";
814 break;
815 default: LOG(info) << " Cluster radius model: None, this should not be!!"; break;
816 } // switch( fiClusterRadiusModel )
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);
826 sTypeMap += Form("%3d ", GetTypeInputMap(iSmType));
827 sEffType += Form("%1.2f ", fdEfficiency[iSmType]);
828 sResType += Form("%2.3f ", fdTimeResolution[iSmType]);
829 sSysResTy += Form("%2.3f ", GetSystemResolution(iSmType));
830 switch (fiClusterRadiusModel) {
831 case 1:
832 case 2:
833 sLandMpv += Form("%2.3f ", fdLandauMpv[iSmType]);
834 sLandSig += Form("%2.3f ", fdLandauSigma[iSmType]);
835 break;
836 default: break;
837 } // switch( fiClusterRadiusModel )
838 }
839 LOG(info) << sIndex;
840 LOG(info) << sTypeMap;
841 LOG(info) << sEffType;
842 LOG(info) << sResType;
843 LOG(info) << sSysResTy;
844 switch (fiClusterRadiusModel) {
845 case 1:
846 case 2:
847 LOG(info) << sLandMpv;
848 LOG(info) << sLandSig;
849 break;
850 default: break;
851 } // switch( fiClusterRadiusModel )
852
853 LOG(info) << "=> Digitization variables: ";
854 // Digi type to use
855 if (kTRUE == fbUseExpDigi)
856 LOG(info) << " Output ToF digi type: Expanded (Double values)";
857 else
858 LOG(info) << " Output ToF digi type: Re-digitized (Encoding "
859 "in 64 bits)";
860 if (kTRUE == fbOneGapTrack)
861 LOG(info) << " Avoid multi gaps digi for same trk: ON";
862 else
863 LOG(info) << " Avoid multi gaps digi for same trk: OFF";
864
865 // Cluster Model to use
866 switch (fiClusterModel) {
867 case 0:
868 LOG(info) << " Cluster model: Use directly cluster "
869 "size (no cluster radius)";
870 break;
871 case 1:
872 LOG(info) << " Cluster model: Flat disc as charge "
873 "distribution + geometrical overlap";
874 break;
875 case 2:
876 LOG(info) << " Cluster model: 2D gaussian as "
877 "charge distribution + integral";
878 break;
879 default: LOG(info) << " Cluster model: None, this should not be!!"; break;
880 } // switch( fiClusterModel )
881 LOG(info) << "=> Simple clusterizer parameters: ";
882 if (kTRUE == fbMulUseTrackId)
883 LOG(info) << " Variable used for multiplicity cnt: Track ID";
884 else
885 LOG(info) << " Variable used for multiplicity cnt: TofPoint ID";
886 if (-1 < fdMaxTimeDistClust)
887 LOG(info) << " Maximal time dist. to last chan.: " << GetMaxTimeDist() << " [ns]";
888 else
889 LOG(info) << " Maximal time dist. to last chan.: Use 5*Nom. Syst. Res. "
890 "(80 ps) = "
891 << GetMaxTimeDist() << " [ns]";
892
893 LOG(info) << " Maximal dist. along ch to last one: " << fdMaxSpaceDistClust << " [cm]";
894
895
896 delete[] sGapsNb;
897 delete[] sGapsSz;
898 delete[] sChNb;
899 delete[] sChType;
900 delete[] sChOrient;
901}
902
903Int_t CbmTofDigiBdfPar::GetNbDet() const { return fiDetUId.GetSize(); }
904
906{
907
908 //const Int_t DetMask = 0x3fffff; // v14a
909 const Int_t DetMask = 0x1fffff; // v21a
910 return fMapDetInd[(iAddr & DetMask)];
911}
912
913Int_t CbmTofDigiBdfPar::GetDetUId(Int_t iInd) { return fiDetUId[iInd]; }
const Int_t DetMask
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
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
std::vector< TArrayI > fiTrkStation
Int_t GetNbSm(Int_t iSmType) const
Int_t GetNbChan(Int_t iSmType, Int_t iRpc) const
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
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
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
TH1 * GetClustTotHist(Int_t iSmType) const
std::map< Int_t, Int_t > fMapDetInd