CbmRoot
Loading...
Searching...
No Matches
CbmTaskTofClusterizerParWrite.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer], Pierre-Alain Loizeau, Norbert Herrmann */
4
6
7// TOF Classes and includes
8#include "CbmTofAddress.h" // in cbmdata/tof
9#include "CbmTofCell.h" // in tof/TofData
10#include "CbmTofCreateDigiPar.h" // in tof/TofTools
11#include "CbmTofDetectorId_v12b.h" // in cbmdata/tof
12#include "CbmTofDetectorId_v14a.h" // in cbmdata/tof
13#include "CbmTofDetectorId_v21a.h" // in cbmdata/tof
14#include "CbmTofDigiBdfPar.h" // in tof/TofParam
15#include "CbmTofDigiPar.h" // in tof/TofParam
16#include "CbmTofGeoHandler.h" // in tof/TofTools
17
18// FAIR classes and includes
19#include "FairRootFileSink.h"
20#include "FairRootManager.h"
21#include "FairRunAna.h"
22#include "FairRuntimeDb.h"
23#include "tof/CalibrateSetup.h"
24#include "tof/HitfindSetup.h"
25#include "yaml/Yaml.h"
26
27#include <Logger.h>
28
29// ROOT Classes and includes
30#include "TClonesArray.h"
31#include "TGeoManager.h"
32#include "TGeoPhysicalNode.h"
33#include "TH2.h"
34#include "TProfile.h"
35#include "TROOT.h"
36#include "TStopwatch.h"
37#include "TVector3.h"
38
39// C++ Classes and includes
40#include <iomanip>
41#include <vector>
42
43
44/************************************************************************************/
49
50CbmTaskTofClusterizerParWrite::CbmTaskTofClusterizerParWrite(const char* name, int32_t verbose, bool /*writeDataInOut*/)
51 : FairTask(TString(name), verbose)
52 , fTofId(NULL)
53 , fDigiPar(NULL)
54 , fDigiBdfPar(NULL)
55 , fvCPTOff()
56 , fvCPTotGain()
57 , fvCPTotOff()
58 , fvCPWalk()
59 , fvCPTOffY()
60 , fvCPTOffYBinWidth()
61 , fvCPTOffYRange()
62 , fvDeadStrips()
63 , fCalMode(0)
64 , fPosYMaxScal(1.)
65 , fTotMax(100.)
66 , fTotMin(0.)
67 , fTotOff(0.)
68 , fTotMean(0.)
69 , fMaxTimeDist(1.)
70 , fdChannelDeadtime(0.)
71 , fCalParFileName("")
72 , fdTOTMax(50.)
73 , fdTOTMin(0.)
74 , fdTTotMean(2.)
75 , fdMaxTimeDist(0.)
76 , fdMaxSpaceDist(0.)
77 , fdModifySigvel(1.0)
78 , fbSwapChannelSides(false)
79{
80}
81
83
84/************************************************************************************/
85// FairTasks inherited functions
87{
88 LOG(info) << "CbmTaskTofClusterizerParWrite initializing... expect Digis in ns units! ";
89 if (false == InitParameters()) return kFATAL;
90 if (false == InitCalibParameter()) return kFATAL;
91 if (false == InitAlgos()) return kFATAL;
92 return kSUCCESS;
93}
94
96{
97 LOG(info) << "=> Get the digi parameters for tof";
98 FairRunAna* ana = FairRunAna::Instance();
99 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
100
101 fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar"));
102
103 LOG(info) << "found " << fDigiPar->GetNrOfModules() << " cells ";
104 fDigiBdfPar = (CbmTofDigiBdfPar*) (rtdb->getContainer("CbmTofDigiBdfPar"));
105}
106
107
108/************************************************************************************/
110{
111
112 // Initialize the TOF GeoHandler
113 bool isSimulation = false;
114 LOG(info) << "CbmTaskTofClusterizerParWrite::InitParameters - Geometry, Mapping, ... ??";
115
116 // Get Base Container
117 FairRun* ana = FairRun::Instance();
118 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
119
120 CbmTofGeoHandler geoHandler;
121 int32_t iGeoVersion = geoHandler.Init(isSimulation);
122 if (k14a > iGeoVersion) {
123 LOG(error) << "CbmTaskTofClusterizerParWrite::InitParameters => Only compatible "
124 "with geometries after v14a !!!";
125 return false;
126 }
127 if (iGeoVersion == k14a)
129 else
131
132 // create digitization parameters from geometry file
133 CbmTofCreateDigiPar* tofDigiPar = new CbmTofCreateDigiPar("TOF Digi Producer", "TOF task");
134 LOG(info) << "Create DigiPar ";
135 tofDigiPar->Init();
136
137 fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar"));
138 if (0 == fDigiPar) {
139 LOG(error) << "CbmTaskTofClusterizerParWrite::InitParameters => Could not obtain "
140 "the CbmTofDigiPar ";
141 return false;
142 }
143
144 fDigiBdfPar = (CbmTofDigiBdfPar*) (rtdb->getContainer("CbmTofDigiBdfPar"));
145 if (0 == fDigiBdfPar) {
146 LOG(error) << "CbmTaskTofClusterizerParWrite::InitParameters => Could not obtain "
147 "the CbmTofDigiBdfPar ";
148 return false;
149 }
150
151 rtdb->initContainers(ana->GetRunId());
152
153 LOG(info) << "CbmTaskTofClusterizerParWrite::InitParameter: currently " << fDigiPar->GetNrOfModules()
154 << " digi cells ";
155
158
160 fdMaxTimeDist = fMaxTimeDist; // modify default
162 * 0.5; // cut consistently on positions (with default signal velocity)
163 }
164
165 LOG(info) << " BuildCluster with MaxTimeDist " << fdMaxTimeDist << ", MaxSpaceDist " << fdMaxSpaceDist;
166
168 return true;
169}
170/************************************************************************************/
172{
173 // dimension and initialize calib parameter
174 int32_t iNbSmTypes = fDigiBdfPar->GetNbSmTypes();
175
176 if (fTotMean != 0.) fdTTotMean = fTotMean; // adjust target mean for TOT
177
178 fvCPTOff.resize(iNbSmTypes);
179 fvCPTotGain.resize(iNbSmTypes);
180 fvCPTotOff.resize(iNbSmTypes);
181 fvCPWalk.resize(iNbSmTypes);
182 fvCPTOffY.resize(iNbSmTypes);
183 fvCPTOffYBinWidth.resize(iNbSmTypes);
184 fvCPTOffYRange.resize(iNbSmTypes);
185 for (int32_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
186 int32_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
187 int32_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
188 fvCPTOff[iSmType].resize(iNbSm * iNbRpc);
189 fvCPTotGain[iSmType].resize(iNbSm * iNbRpc);
190 fvCPTotOff[iSmType].resize(iNbSm * iNbRpc);
191 fvCPWalk[iSmType].resize(iNbSm * iNbRpc);
192 fvCPTOffY[iSmType].resize(iNbSm * iNbRpc);
193 fvCPTOffYBinWidth[iSmType].resize(iNbSm * iNbRpc);
194 fvCPTOffYRange[iSmType].resize(iNbSm * iNbRpc);
195 for (int32_t iSm = 0; iSm < iNbSm; iSm++) {
196 for (int32_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
197
198 fvCPTOffYBinWidth[iSmType][iSm * iNbRpc + iRpc] = 0.; // initialize
199 fvCPTOffYRange[iSmType][iSm * iNbRpc + iRpc] = 0.; // initialize
200
201 /* D.Smith 23.8.23: For testing hit time calibration. Please remove when done.
202 fvCPTOffYBinWidth[iSmType][iSm * iNbRpc + iRpc] = 1.; // initialize
203 fvCPTOffYRange[iSmType][iSm * iNbRpc + iRpc] = 200.; // initialize
204 fvCPTOffY[iSmType][iSm * iNbRpc + iRpc] = std::vector<double>(10000, 1000.);
205 for( size_t i = 0; i < fvCPTOffY[iSmType][iSm * iNbRpc + iRpc].size(); i++ )
206 {
207 fvCPTOffY[iSmType][iSm * iNbRpc + iRpc][i] = 1000.+500.*i;
208 }
209*/
210 int32_t iNbChan = fDigiBdfPar->GetNbChan(iSmType, iRpc);
211 fvCPTOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
212 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
213 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
214 fvCPWalk[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
215 int32_t nbSide = 2 - fDigiBdfPar->GetChanType(iSmType, iRpc);
216 for (int32_t iCh = 0; iCh < iNbChan; iCh++) {
217 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
218 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
219 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
220 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
221 for (int32_t iSide = 0; iSide < nbSide; iSide++) {
222 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = 0.; //initialize
223 fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = 1.; //initialize
224 fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = 0.; //initialize
225 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide].resize(nbClWalkBinX);
226 for (int32_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
227 fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide][iWx] = 0.;
228 }
229 }
230 }
231 }
232 }
233 }
234 LOG(info) << "CbmTaskTofClusterizerParWrite::InitCalibParameter: defaults set";
235
236 if (fCalMode <= 0) {
237 return true;
238 } // Skip calibration from histograms in mode zero
239
241 // <= To prevent histos from being sucked in by the param file of the TRootManager!
242 TFile* oldFile = gFile;
243 TDirectory* oldDir = gDirectory;
244
245 LOG(info) << "CbmTaskTofClusterizerParWrite::InitCalibParameter: read histos from "
246 << "file " << fCalParFileName;
247
248 // read parameter from histos
249 if (fCalParFileName.IsNull()) return true;
250
251 TFile* calParFile = new TFile(fCalParFileName, "READ");
252 if (NULL == calParFile) {
253 if (fCalMode % 10 == 9) { //modify reference file name
254 int iCalMode = fCalParFileName.Index("tofClust") - 3;
255 fCalParFileName(iCalMode) = '3';
256 LOG(info) << "Modified CalFileName = " << fCalParFileName;
257 calParFile = new TFile(fCalParFileName, "update");
258 if (NULL == calParFile)
259 LOG(fatal) << "CbmTaskTofClusterizerParWrite::InitCalibParameter: "
260 << "file " << fCalParFileName << " does not exist!";
261
262 return true;
263 }
264 LOG(fatal) << "Calibration parameter file not existing!";
265 }
266
267 for (int32_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
268 int32_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
269 int32_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
270 TProfile* hSvel = (TProfile*) gDirectory->FindObjectAny(Form("cl_SmT%01d_Svel", iSmType));
271 for (int32_t iSm = 0; iSm < iNbSm; iSm++)
272 for (int32_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
273
274 std::vector<std::vector<double>>& vCPTotGain = fvCPTotGain[iSmType][iSm * iNbRpc + iRpc];
275 std::vector<std::vector<double>>& vCPTOff = fvCPTOff[iSmType][iSm * iNbRpc + iRpc];
276 std::vector<std::vector<double>>& vCPTotOff = fvCPTotOff[iSmType][iSm * iNbRpc + iRpc];
277 std::vector<std::vector<std::vector<double>>>& vCPWalk = fvCPWalk[iSmType][iSm * iNbRpc + iRpc];
278
279 std::vector<double>& vCPTOffY = fvCPTOffY[iSmType][iSm * iNbRpc + iRpc];
280 double& vCPTOffYBinWidth = fvCPTOffYBinWidth[iSmType][iSm * iNbRpc + iRpc];
281 double& vCPTOffYRange = fvCPTOffYRange[iSmType][iSm * iNbRpc + iRpc];
282
283 // update default parameter
284 if (NULL != hSvel) {
285 double Vscal = hSvel->GetBinContent(iSm * iNbRpc + iRpc + 1);
286 if (Vscal == 0.) Vscal = 1.;
287 Vscal *= fdModifySigvel; //1.03; // testing the effect of wrong signal velocity, FIXME
288 fDigiBdfPar->SetSigVel(iSmType, iSm, iRpc, fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * Vscal);
289 LOG(info) << "Modify " << iSmType << iSm << iRpc << " Svel by " << Vscal << " to "
290 << fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
291 }
292 TH2D* htempPos_pfx =
293 (TH2D*) gDirectory->FindObjectAny(Form("cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
294 TH2D* htempTOff_pfx =
295 (TH2D*) gDirectory->FindObjectAny(Form("cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
296 TH1D* htempTot_Mean =
297 (TH1D*) gDirectory->FindObjectAny(Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
298 TH1D* htempTot_Off =
299 (TH1D*) gDirectory->FindObjectAny(Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
300 if (NULL != htempPos_pfx && NULL != htempTOff_pfx && NULL != htempTot_Mean && NULL != htempTot_Off) {
301 int32_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
302 //int32_t iNbinTot = htempTot_Mean->GetNbinsX();//not used any more
303 for (int32_t iCh = 0; iCh < iNbCh; iCh++) {
304 for (int32_t iSide = 0; iSide < 2; iSide++) {
305 double TotMean = htempTot_Mean->GetBinContent(iCh * 2 + 1 + iSide); //nh +1 empirical(?)
306 if (0.001 < TotMean) {
307 vCPTotGain[iCh][iSide] *= fdTTotMean / TotMean;
308 }
309 vCPTotOff[iCh][iSide] = htempTot_Off->GetBinContent(iCh * 2 + 1 + iSide);
310 }
311 double YMean = ((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1); //nh +1 empirical(?)
312 double TMean = ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
313 if (std::isnan(YMean) || std::isnan(TMean)) {
314 LOG(warn) << "Invalid calibration for TSRC " << iSmType << iSm << iRpc << iCh << ", use default!";
315 continue;
316 }
317 double dTYOff = YMean / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
318 if (5 == iSmType || 8 == iSmType) dTYOff = 0.; // no valid Y positon for pad counters
319 vCPTOff[iCh][0] += -dTYOff + TMean;
320 vCPTOff[iCh][1] += +dTYOff + TMean;
321
322 if (5 == iSmType || 8 == iSmType) { // for PAD counters
323 vCPTOff[iCh][1] = vCPTOff[iCh][0];
324 vCPTotGain[iCh][1] = vCPTotGain[iCh][0];
325 vCPTotOff[iCh][1] = vCPTotOff[iCh][0];
326 }
327 //if(iSmType==0 && iSm==4 && iRpc==2 && iCh==26)
328 if (iSmType == 0 && iSm == 2 && iRpc == 0)
329 //if (iSmType == 9 && iSm == 0 && iRpc == 0 && iCh == 10) // select specific channel
330 LOG(info) << "InitCalibParameter:"
331 << " TSRC " << iSmType << iSm << iRpc << iCh
332 << Form(": YMean %6.3f, TYOff %6.3f, TMean %6.3f", YMean, dTYOff, TMean) << " -> "
333 << Form(" TOff %f, %f, TotG %f, %f ", vCPTOff[iCh][0], vCPTOff[iCh][1], vCPTotGain[iCh][0],
334 vCPTotGain[iCh][1]);
335
336 TH1D* htempWalk0 = (TH1D*) gDirectory->FindObjectAny(
337 Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh));
338 TH1D* htempWalk1 = (TH1D*) gDirectory->FindObjectAny(
339 Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", iSmType, iSm, iRpc, iCh));
340 if (NULL == htempWalk0 && NULL == htempWalk1) { // regenerate Walk histos
341 int iSide = 0;
342 htempWalk0 = new TH1D(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh),
343 Form("Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk; Tot [a.u.]; #DeltaT [ns]",
344 iSmType, iSm, iRpc, iCh, iSide),
346 iSide = 1;
347 htempWalk1 = new TH1D(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", iSmType, iSm, iRpc, iCh),
348 Form("Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk; Tot [a.u.]; #DeltaT [ns]",
349 iSmType, iSm, iRpc, iCh, iSide),
351 }
352 if (NULL != htempWalk0 && NULL != htempWalk1) { // reinitialize Walk array
353 LOG(debug) << "Initialize Walk correction for "
354 << Form(" SmT%01d_sm%03d_rpc%03d_Ch%03d", iSmType, iSm, iRpc, iCh);
355 if (htempWalk0->GetNbinsX() != nbClWalkBinX)
356 LOG(error) << "CbmTaskTofClusterizerParWrite::InitCalibParameter: "
357 "Inconsistent Walk histograms";
358 for (int32_t iBin = 0; iBin < nbClWalkBinX; iBin++) {
359 vCPWalk[iCh][0][iBin] = htempWalk0->GetBinContent(iBin + 1);
360 vCPWalk[iCh][1][iBin] = htempWalk1->GetBinContent(iBin + 1);
361 if (iSmType == 0 && iSm == 0 && iRpc == 2 && iCh == 15) // debugging
362 LOG(info) << Form("Read new SmT%01d_sm%03d_rpc%03d_Ch%03d bin %d cen %f walk %f %f", iSmType, iSm,
363 iRpc, iCh, iBin, htempWalk0->GetBinCenter(iBin + 1), vCPWalk[iCh][0][iBin],
364 vCPWalk[iCh][1][iBin]);
365 if (5 == iSmType || 8 == iSmType) { // Pad structure, enforce consistency
366 if (vCPWalk[iCh][1][iBin] != vCPWalk[iCh][0][iBin]) {
367 LOG(fatal) << "Inconsisten walk values for TSRC " << iSmType << iSm << iRpc << iCh << ", Bin "
368 << iBin << ": " << vCPWalk[iCh][0][iBin] << ", " << vCPWalk[iCh][1][iBin];
369 }
370 vCPWalk[iCh][1][iBin] = vCPWalk[iCh][0][iBin];
371 htempWalk1->SetBinContent(iBin + 1, vCPWalk[iCh][1][iBin]);
372 }
373 }
374 }
375 else {
376 LOG(info) << "No Walk histograms for TSRC " << iSmType << iSm << iRpc << iCh;
377 }
378 }
379 // look for TcorY corrections
380 LOG(info) << "Check for TCorY in " << gDirectory->GetName();
381 TH1* hTCorY =
382 (TH1*) gDirectory->FindObjectAny(Form("calXY_SmT%d_sm%03d_rpc%03d_TOff_z_all_TcorY", iSmType, iSm, iRpc));
383 if (NULL != hTCorY) {
384 vCPTOffYBinWidth = hTCorY->GetBinWidth(0);
385 vCPTOffYRange = hTCorY->GetXaxis()->GetXmax();
386 LOG(info) << "Initialize TCorY: TSR " << iSmType << iSm << iRpc << ", Bwid " << vCPTOffYBinWidth
387 << ", Range " << vCPTOffYRange;
388 vCPTOffY.resize(hTCorY->GetNbinsX());
389 for (int iB = 0; iB < hTCorY->GetNbinsX(); iB++) {
390 vCPTOffY[iB] = hTCorY->GetBinContent(iB + 1);
391 }
392 }
393 }
394 else {
395 LOG(warning) << " Calibration histos " << Form("cl_SmT%01d_sm%03d_rpc%03d_XXX", iSmType, iSm, iRpc)
396 << " not found. ";
397 }
398 }
399 }
400
402 // <= To prevent histos from being sucked in by the param file of the TRootManager!
403 gFile = oldFile;
404 gDirectory = oldDir;
405 LOG(info) << "CbmTaskTofClusterizerParWrite::InitCalibParameter: initialization done";
406 return true;
407}
408
410{
411 // Needed as external TOT values might be different than ones used for input histo reading (TO DO: FIX)
412 if (fTotMax != 0.) fdTOTMax = fTotMax;
413 if (fTotMin != 0.) fdTOTMin = fTotMin;
414 LOG(info) << "ToT init to Min " << fdTOTMin << " Max " << fdTOTMax;
415
417 gGeoManager->CdTop();
418
419 int32_t iNbSmTypes = fDigiBdfPar->GetNbSmTypes();
420
421 // Create map with unique detector IDs and fill (needed only for dead strip array)
422 std::map<uint32_t, uint32_t> detIdIndexMap;
423 for (int32_t ind = 0; ind < fDigiBdfPar->GetNbDet(); ind++) {
424 int32_t iUniqueId = fDigiBdfPar->GetDetUId(ind);
425 detIdIndexMap[iUniqueId] = ind;
426 }
427
428 /* Hitfinding parameters */
429
431 setup.rpcs.resize(iNbSmTypes);
432
433 for (int32_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
434
435 int32_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
436 int32_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
437 setup.NbSm.push_back(iNbSm);
438 setup.NbRpc.push_back(iNbRpc);
439
440 setup.rpcs[iSmType].resize(iNbSm * iNbRpc);
441
442 for (int32_t iSm = 0; iSm < iNbSm; iSm++) {
443 for (int32_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
444
446
447 /* Cell geometry for hitfinding (can in principle be set channel-wise but is not needed for now) */
448
449 const int32_t rpcAddress = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType);
450 CbmTofCell* channelInfo = fDigiPar->GetCell(rpcAddress);
451 if (channelInfo == nullptr) {
452 continue;
453 }
454
455 // prepare local->global trafo
456 gGeoManager->FindNode(channelInfo->GetX(), channelInfo->GetY(), channelInfo->GetZ());
457 const double* tra_ptr = gGeoManager->MakePhysicalNode()->GetMatrix()->GetTranslation();
458 const double* rot_ptr = gGeoManager->GetCurrentMatrix()->GetRotationMatrix();
459 memcpy(par.cell.translation.data(), tra_ptr, 3 * sizeof(double));
460 memcpy(par.cell.rotation.data(), rot_ptr, 9 * sizeof(double));
461
462 par.cell.sizeX = channelInfo->GetSizex();
463 par.cell.sizeY = channelInfo->GetSizey();
464
465 /* Other hitfinding parameters */
466
467 const int32_t iDetId = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType);
468 const int32_t iDetIndx = detIdIndexMap[iDetId];
469 par.deadStrips = fvDeadStrips[iDetIndx];
473 par.sigVel = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
474 par.timeRes = 0.08;
475 par.trackingStationId = fDigiBdfPar->GetTrackingStation(iSmType, iSm, iRpc);
476 par.CPTOffYBinWidth = fvCPTOffYBinWidth[iSmType][iSm * iNbRpc + iRpc];
477 par.CPTOffY = fvCPTOffY[iSmType][iSm * iNbRpc + iRpc];
478 par.CPTOffYRange = fvCPTOffYRange[iSmType][iSm * iNbRpc + iRpc];
479
480 int32_t iNbChan = fDigiBdfPar->GetNbChan(iSmType, iRpc);
481 par.chanPar.resize(iNbChan);
482
483 for (int32_t iCh = 0; iCh < iNbChan; iCh++) {
485
486 const int32_t address = CbmTofAddress::GetUniqueAddress(iSm, iRpc, iCh, 0, iSmType);
487 chan.address = address;
488 }
489 setup.rpcs[iSmType][iSm * iNbRpc + iRpc] = par;
490 }
491 }
492 }
493
494 /* Calibration parameters */
495
497 calib.rpcs.resize(iNbSmTypes);
498
499 for (int32_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
500 int32_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
501 int32_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
502 calib.NbSm.push_back(iNbSm);
503 calib.NbRpc.push_back(iNbRpc);
504 calib.rpcs[iSmType].resize(iNbSm * iNbRpc);
505
506 for (int32_t iSm = 0; iSm < iNbSm; iSm++) {
507 for (int32_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
508
511 par.TOTMax = fdTOTMax;
512 par.TOTMin = fdTOTMin;
515
516 int32_t iNbChan = fDigiBdfPar->GetNbChan(iSmType, iRpc);
517 par.chanPar.resize(iNbChan);
518
519 for (int32_t iCh = 0; iCh < iNbChan; iCh++) {
521
522 chan.vCPTOff = fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh];
523 chan.vCPTotGain = fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh];
524 chan.vCPTotOff = fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh];
525 chan.vCPWalk = fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh];
526 }
527 calib.rpcs[iSmType][iSm * iNbRpc + iRpc] = par;
528 }
529 }
530 }
531
532 /* Write Yaml files */
533
535 std::ofstream fout("TofHitfinderPar.yaml");
536 fout << dump(setup);
537 fout.close();
538
539 std::ofstream fcalout("TofCalibratePar.yaml");
540 fcalout << dump(calib);
541 fcalout.close();
542
543 return true;
544}
std::vector< TH1 * > hSvel
@ k14a
std::vector< std::vector< std::vector< std::vector< double > > > > fvCPTOff
std::vector< std::vector< std::vector< std::vector< std::vector< double > > > > > fvCPWalk
virtual InitStatus Init()
Inherited from FairTask.
std::vector< std::vector< double > > fvCPTOffYRange
std::vector< std::vector< std::vector< double > > > fvCPTOffY
bool InitCalibParameter()
Initialize other parameters not included in parameter classes.
bool InitParameters()
Initialize other parameters not included in parameter classes.
bool InitAlgos()
Create one algo object for each RPC.
std::vector< std::vector< double > > fvCPTOffYBinWidth
std::vector< std::vector< std::vector< std::vector< double > > > > fvCPTotGain
std::vector< std::vector< std::vector< std::vector< double > > > > fvCPTotOff
virtual void SetParContainers()
Inherited from FairTask.
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)
Double_t GetSizey() const
Definition CbmTofCell.h:40
Double_t GetY() const
Definition CbmTofCell.h:36
Double_t GetSizex() const
Definition CbmTofCell.h:39
Double_t GetX() const
Definition CbmTofCell.h:35
Double_t GetZ() const
Definition CbmTofCell.h:37
virtual InitStatus Init()
Parameters class for the CBM ToF digitizer using beam data distributions.
Int_t GetNbSmTypes() const
void SetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc, Double_t dvel)
Int_t GetNbSm(Int_t iSmType) const
Double_t GetMaxDistAlongCh() const
Int_t GetNbChan(Int_t iSmType, Int_t iRpc) const
Int_t GetChanType(Int_t iSmType, Int_t iRpc) const
Int_t GetNbRpc(Int_t iSmType) const
Double_t GetMaxTimeDist() const
Int_t GetDetUId(Int_t iDet)
Double_t GetSignalSpeed() const
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
CbmTofCell * GetCell(Int_t i)
Int_t GetNrOfModules()
Int_t Init(Bool_t isSimulation=kFALSE)
std::vector< std::vector< double > > vCPWalk
TOF calibration setup.
std::vector< int32_t > NbSm
std::vector< int32_t > NbRpc
std::vector< std::vector< Rpc > > rpcs
std::array< double, 3 > translation
Hitfind setup / Hardware cabling for TOF Used to create the hardware mapping for the TOF hitfinder.
std::vector< std::vector< Rpc > > rpcs
std::vector< int32_t > NbSm
std::vector< int32_t > NbRpc