CbmRoot
CbmTofCalibrator.cxx
Go to the documentation of this file.
1 
7 // CBMroot classes and includes
8 #include "CbmTofCalibrator.h"
9 #include "CbmMatch.h"
10 #include "CbmTofAddress.h" // in cbmdata/tof
11 #include "CbmTofCell.h" // in tof/TofData
12 #include "CbmTofClusterizersDef.h"
13 #include "CbmTofDetectorId_v12b.h" // in cbmdata/tof
14 #include "CbmTofDetectorId_v14a.h" // in cbmdata/tof
15 #include "CbmTofDigiBdfPar.h" // in tof/TofParam
16 #include "CbmTofDigiPar.h" // in tof/TofParam
17 #include "CbmTofGeoHandler.h" // in tof/TofTools
18 #include "CbmTofHit.h"
19 #include "CbmTofTracklet.h"
20 
21 // FAIR classes and includes
22 #include "FairLogger.h"
23 #include "FairRunAna.h"
24 #include "FairRuntimeDb.h"
25 
26 // ROOT Classes and includes
27 #include <TClonesArray.h>
28 #include <TDirectory.h>
29 #include <TFile.h>
30 #include <TGeoManager.h>
31 #include <TH1.h>
32 #include <TH2.h>
33 #include <TProfile.h>
34 #include <TROOT.h>
35 
37  : fDigiMan(NULL)
38  , fTofClusterizer(NULL)
39  , fTofFindTracks(NULL)
40  , fTrackletTools(NULL)
41  , fDigiPar(NULL)
42  , fDigiBdfPar(NULL)
43  , fTofDigiMatchColl(NULL)
44  , fhCalPos()
45  , fhCalTOff()
46  , fhCalTot()
47  , fhCalWalk()
48  , fhCorPos()
49  , fhCorTOff()
50  , fhCorTot()
51  , fhCorTotOff()
52  , fhCorSvel()
53  , fhCorWalk()
54  , fDetIdIndexMap() {}
55 
57 
58 InitStatus CbmTofCalibrator::Init() {
59 
60  FairRootManager* fManager = FairRootManager::Instance();
61  // check for availability of digis
63  if (NULL == fDigiMan) {
64  LOG(warning) << "No CbmDigiManager";
65  return kFATAL;
66  }
67  fDigiMan->Init();
68 
70  LOG(warn) << "CbmTofCalibrator: No digi input!";
71  }
72 
73  // check for access to current calibration file
75  if (NULL == fTofClusterizer) {
76  LOG(warn) << "CbmTofCalibrator: no access to active calibration";
77  } else {
78  TString CalParFileName = fTofClusterizer->GetCalParFileName();
79  LOG(info) << "Current calibration file: " << CalParFileName;
80  }
82  if (NULL == fTofFindTracks) {
83  LOG(warn) << "CbmTofCalibrator: no access to tof tracker ";
84  }
85 
86  // Get Access to MatchCollection
87  fTofDigiMatchColl = (TClonesArray*) fManager->GetObject("TofDigiMatch");
88  if (NULL == fTofDigiMatchColl)
89  fTofDigiMatchColl = (TClonesArray*) fManager->GetObject("TofCalDigiMatch");
90 
91  if (NULL == fTofDigiMatchColl) {
92  LOG(error) << "CbmTofCalibrator: no access to DigiMatch ";
93  return kFATAL;
94  }
95 
96  // Get Parameters
97  if (!InitParameters()) { LOG(error) << "CbmTofCalibrator: No parameters!"; }
98  // generate deviation histograms
99  if (!CreateCalHist()) {
100  LOG(error) << "CbmTofCalibrator: No histograms!";
101  return kFATAL;
102  }
103 
104  fTrackletTools = new CbmTofTrackletTools(); // initialize tools
105 
106  LOG(info) << "TofCalibrator initialized successfully";
107  return kSUCCESS;
108 }
109 
111  LOG(info) << "InitParameters: get par pointers from RTDB";
112  // Get Base Container
113  FairRun* ana = FairRun::Instance();
114  FairRuntimeDb* rtdb = ana->GetRuntimeDb();
115 
116  fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar"));
117  if (NULL == fDigiPar) return kFALSE;
118 
119  fDigiBdfPar = (CbmTofDigiBdfPar*) (rtdb->getContainer("CbmTofDigiBdfPar"));
120  if (NULL == fDigiBdfPar) return kFALSE;
121 
122  return kTRUE;
123 }
124 
126  // detector related distributions
127  Int_t iNbDet = fDigiBdfPar->GetNbDet();
128  LOG(info) << "Define Calibrator histos for " << iNbDet << " detectors ";
129  fhCalPos.resize(iNbDet);
130  fhCalTOff.resize(iNbDet);
131  fhCalTot.resize(iNbDet);
132  fhCalWalk.resize(iNbDet);
133 
134  fDetIdIndexMap.clear();
135 
136  for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
137  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
138  fDetIdIndexMap[iUniqueId] = iDetIndx;
139 
140  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
141  Int_t iSmId = CbmTofAddress::GetSmId(iUniqueId);
142  Int_t iRpcId = CbmTofAddress::GetRpcId(iUniqueId);
143  Int_t iUCellId =
144  CbmTofAddress::GetUniqueAddress(iSmId, iRpcId, 0, 0, iSmType);
145  CbmTofCell* fChannelInfo = fDigiPar->GetCell(iUCellId);
146  if (NULL == fChannelInfo) {
147  LOG(warning) << "No DigiPar for Det " << Form("0x%08x", iUCellId);
148  continue;
149  }
150  Double_t YDMAX = 5;
151  fhCalPos[iDetIndx] = new TH2F(
152  Form("cal_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
153  Form(
154  "Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]",
155  iRpcId,
156  iSmId,
157  iSmType),
158  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
159  0,
160  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
161  99,
162  -YDMAX,
163  YDMAX);
164 
165  Double_t TSumMax = 2.;
166  //if(iSmType == 5) TSumMax *= 2.; // enlarge for diamond / beamcounter
167  fhCalTOff[iDetIndx] = new TH2F(
168  Form("cal_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
169  Form(
170  "Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]",
171  iRpcId,
172  iSmId,
173  iSmType),
174  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
175  0,
176  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
177  99,
178  -TSumMax,
179  TSumMax);
180 
181  Double_t TotMax = 25.;
182  fhCalTot[iDetIndx] = new TH2F(
183  Form("cal_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
184  Form(
185  "Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [a.u.]",
186  iRpcId,
187  iSmId,
188  iSmType),
189  2 * fDigiBdfPar->GetNbChan(iSmType, iRpcId),
190  0,
191  2 * fDigiBdfPar->GetNbChan(iSmType, iRpcId),
192  100,
193  0.,
194  TotMax);
195 
196  TSumMax = 1.;
197  fhCalWalk[iDetIndx].resize(fDigiBdfPar->GetNbChan(iSmType, iRpcId));
198  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpcId); iCh++) {
199  fhCalWalk[iDetIndx][iCh].resize(2);
200  for (Int_t iSide = 0; iSide < 2; iSide++) {
201  fhCalWalk[iDetIndx][iCh][iSide] =
202  new TH2D(Form("cal_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
203  iSmType,
204  iSmId,
205  iRpcId,
206  iCh,
207  iSide),
208  Form("Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk; Tot "
209  "[a.u.]; #DeltaT [ns]",
210  iSmType,
211  iSmId,
212  iRpcId,
213  iCh,
214  iSide),
215  nbClWalkBinX,
216  0.,
217  TotMax,
218  nbClWalkBinY,
219  -TSumMax,
220  TSumMax);
221  }
222  }
223  }
224 
225  return kTRUE;
226 }
227 
229  // fill deviation histograms on walk level
230  if (pTrk->GetTt() < 0) return; // take tracks with positive velocity only
231  if (!pTrk->ContainsAddr(0x00005006))
232  return; // request beam counter hit for calibration
233  if (fdR0Lim
234  > 0.) // consider only tracks originating from nominal interaction point
235  if (pTrk->GetR0() > fdR0Lim) return;
236 
237  for (Int_t iHit = 0; iHit < pTrk->GetNofHits(); iHit++) {
238  CbmTofHit* pHit = pTrk->GetTofHitPointer(iHit);
239  Int_t iDetId = (pHit->GetAddress() & DetMask);
240  Int_t iSmType = CbmTofAddress::GetSmType(iDetId);
241  Int_t iSm = CbmTofAddress::GetSmId(iDetId);
242  Int_t iRpc = CbmTofAddress::GetRpcId(iDetId);
243 
244  std::map<UInt_t, UInt_t>::iterator it = fDetIdIndexMap.find(iDetId);
245  if (it == fDetIdIndexMap.end())
246  continue; // continue for invalid detector index
247  Int_t iDetIndx = it->second; //fDetIdIndexMap[iDetId];
248 
249  Int_t iChId = pHit->GetAddress();
250  Int_t iCh = CbmTofAddress::GetChannelId(iChId);
251  CbmTofCell* fChannelInfo = fDigiPar->GetCell(iChId);
252  if (NULL == fChannelInfo) {
253  LOG(error) << "Invalid Channel Pointer for ChId "
254  << Form(" 0x%08x ", iChId) << ", Ch " << iCh;
255  continue;
256  }
257  gGeoManager->FindNode(
258  fChannelInfo->GetX(), fChannelInfo->GetY(), fChannelInfo->GetZ());
259  Double_t hitpos[3];
260  hitpos[0] = pHit->GetX();
261  hitpos[1] = pHit->GetY();
262  hitpos[2] = pHit->GetZ();
263  Double_t hlocal_p[3];
264  //TGeoNode* cNode=
265  gGeoManager->GetCurrentNode();
266  gGeoManager->MasterToLocal(hitpos, hlocal_p);
267  hitpos[0] = pTrk->GetFitX(pHit->GetZ());
268  hitpos[1] = pTrk->GetFitY(pHit->GetZ());
269  Double_t hlocal_f[3];
270  gGeoManager->MasterToLocal(hitpos, hlocal_f);
271 
272  fhCalPos[iDetIndx]->Fill(
273  (Double_t) iCh, hlocal_p[1] - hlocal_f[1]); // transformed into LRF
274  fhCalTOff[iDetIndx]->Fill(
275  (Double_t) iCh,
276  pHit->GetTime()
277  - pTrk->GetFitT(pHit->GetZ())); // residuals transformed into LRF
278  //fhCalTOff[iDetIndx]->Fill((Double_t)iCh,fTrackletTools->GetTdif(pTrk, iDetId, pHit)); // prediction by other hits
279 
280  Int_t iMA = pTrk->GetTofHitIndex(iHit);
281  if (iMA > fTofDigiMatchColl->GetEntries()) {
282  LOG(error) << " Inconsistent DigiMatches for Hitind " << iMA
283  << ", TClonesArraySize: " << fTofDigiMatchColl->GetEntries();
284  }
285  CbmMatch* digiMatch = (CbmMatch*) fTofDigiMatchColl->At(iMA);
286 
287  for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks();
288  iLink += 2) { // loop over digis
289  CbmLink L0 = digiMatch->GetLink(iLink);
290  Int_t iDigInd0 = L0.GetIndex();
291  Int_t iDigInd1 = (digiMatch->GetLink(iLink + 1)).GetIndex();
292 
293  const CbmTofDigi* tDigi0 = fDigiMan->Get<CbmTofDigi>(iDigInd0);
294  Int_t iCh0 = tDigi0->GetChannel();
295  Int_t iSide0 = tDigi0->GetSide();
296  LOG(debug) << "Fill Walk for " << iDetIndx << ", TSRCS " << iSmType << iSm
297  << iRpc << iCh0 << iSide0 << ", " << tDigi0 << ", " << pTrk;
298  if (iDetIndx > (Int_t) fhCalWalk.size()) {
299  LOG(error) << "Invalid DetIndx " << iDetIndx;
300  continue;
301  }
302  if (iCh0 > (Int_t) fhCalWalk[iDetIndx].size()) {
303  LOG(error) << "Invalid Ch0 " << iCh0;
304  continue;
305  }
306  if (iSide0 > (Int_t) fhCalWalk[iDetIndx][iCh0].size()) {
307  LOG(error) << "Invalid Side0 " << iSide0;
308  continue;
309  }
310 
311  fhCalWalk[iDetIndx][iCh0][iSide0]->Fill(
312  tDigi0->GetTot(),
313  tDigi0->GetTime()
314  + (1. - 2. * tDigi0->GetSide()) * hlocal_p[1]
315  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
316  - pTrk->GetFitT(
317  pHit->GetZ()) //-fTrackletTools->GetTexpected(pTrk, iDetId, pHit)
318  + fTofFindTracks->GetTOff(iDetId)
319  + 2. * (1. - 2. * tDigi0->GetSide()) * (hlocal_p[1] - hlocal_f[1])
320  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc));
321  /*
322  LOG(info)<<"TSRCS "<<iSmType<<iSm<<iRpc<<iCh<<iSide0<<Form(": digi0 %f, ex %f, prop %f, Off %f, res %f",
323  tDigi0->GetTime(),
324  fTrackletTools->GetTexpected(pTrk, iDetId, pHit) ,
325  fTofFindTracks->GetTOff(iDetId),
326  (1.-2.*tDigi0->GetSide())*hlocal_f[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc),
327  tDigi0->GetTime()-fTrackletTools->GetTexpected(pTrk, iDetId, pHit)
328  -(1.-2.*tDigi0->GetSide())*hlocal_f[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc));
329  */
330 
331  const CbmTofDigi* tDigi1 = fDigiMan->Get<CbmTofDigi>(iDigInd1);
332  Int_t iCh1 = tDigi1->GetChannel();
333  Int_t iSide1 = tDigi1->GetSide();
334  LOG(debug) << "Fill Walk for " << iDetIndx << ", TSRCS " << iSmType << iSm
335  << iRpc << iCh1 << iSide1 << ", " << tDigi1 << ", " << pTrk;
336  if (iCh1 > (Int_t) fhCalWalk[iDetIndx].size()) {
337  LOG(error) << "Invalid Ch1 " << iCh1;
338  continue;
339  }
340  if (iSide1 > (Int_t) fhCalWalk[iDetIndx][iCh1].size()) {
341  LOG(error) << "Invalid Side1 " << iSide1;
342  continue;
343  }
344  fhCalWalk[iDetIndx][iCh1][iSide1]->Fill(
345  tDigi1->GetTot(),
346  tDigi1->GetTime()
347  + (1. - 2. * tDigi1->GetSide()) * hlocal_p[1]
348  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
349  - pTrk->GetFitT(
350  pHit->GetZ()) //-fTrackletTools->GetTexpected(pTrk, iDetId, pHit)
351  + fTofFindTracks->GetTOff(iDetId)
352  + 2. * (1. - 2. * tDigi1->GetSide()) * (hlocal_p[1] - hlocal_f[1])
353  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc));
354  }
355  }
356 }
357 
359  // get current calibration histos
360  LOG(info) << "CbmTofCalibrator:: update histos from "
361  << "file "
363  << " with option " << iOpt;
364  TFile* fCalParFile =
365  new TFile(CbmTofEventClusterizer::Instance()->GetCalParFileName(), "");
366  if (NULL == fCalParFile) {
367  LOG(warn)
368  << "Could not open TofClusterizer calibration file, abort Update ";
369  return kFALSE;
370  }
371  assert(fCalParFile);
372  ReadHist(fCalParFile);
373 
374  const Double_t MINCTS = 100.; //FIXME, numerical constant in code
375  // modify calibration histograms
376  for (Int_t iDetIndx = 0; iDetIndx < fDigiBdfPar->GetNbDet(); iDetIndx++) {
377  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
378  // Int_t iSmAddr = iUniqueId & DetMask;
379  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
380  // Int_t iSm = CbmTofAddress::GetSmId( iUniqueId );
381  Int_t iRpc = CbmTofAddress::GetRpcId(iUniqueId);
382  switch (iOpt) {
383  case 0: // none
384  break;
385  case 1: // update channel mean
386  {
387  //LOG(info) << "Update Offsets for TSR "<<iSmType<<iSm<<iRpc;
388  TProfile* hpP = fhCalPos[iDetIndx]->ProfileX();
389  TProfile* hpT = fhCalTOff[iDetIndx]->ProfileX();
390  TH1* hCalT = fhCalTOff[iDetIndx]->ProjectionX();
391  //fhCorPos[iDetIndx]->Add((TH1 *)hpP,-1.);
392  //fhCorTOff[iDetIndx]->Add((TH1*)hpT,-1.);
393  Double_t dAvOff = 0.; //hpT->GetMean(2);
394  for (Int_t iBin = 0; iBin < fhCorTOff[iDetIndx]->GetNbinsX(); iBin++) {
395  Double_t dDt = hpT->GetBinContent(iBin + 1);
396  Double_t dCorT = fhCorTOff[iDetIndx]->GetBinContent(iBin + 1);
397  Double_t dCts = hCalT->GetBinContent(iBin + 1);
398  if (iDetIndx == -1) {
399  LOG(info) << Form(
400  "Update %s: bin %02d, Cts: %d, Old %f, dev %f, av %f, new %f",
401  fhCorTOff[iDetIndx]->GetName(),
402  iBin,
403  (Int_t) dCts,
404  dCorT,
405  dDt,
406  dAvOff,
407  dCorT - dDt + dAvOff);
408  }
409  Double_t dDp = hpP->GetBinContent(iBin + 1);
410  Double_t dCorP = fhCorPos[iDetIndx]->GetBinContent(iBin + 1);
411  if (dCts > MINCTS) {
412  fhCorTOff[iDetIndx]->SetBinContent(iBin + 1, dCorT + dDt + dAvOff);
413  fhCorPos[iDetIndx]->SetBinContent(iBin + 1, dCorP + dDp);
414  }
415  }
416  } break;
417  case 2: // update individual channel walks
418  const Double_t MinCounts = 10.;
419  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
420  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
421  for (Int_t iSide = 0; iSide < 2; iSide++) {
422  //LOG(info) << "Get walk histo pointer for TSRCS " << iSmType<<iSm<<iRpc<<iCh<<iSide;
423  TProfile* hpW =
424  fhCalWalk[iDetIndx][iCh][iSide]->ProfileX(); // mean deviation
425  TH1* hCW = fhCalWalk[iDetIndx][iCh][iSide]
426  ->ProjectionX(); // contributing counts
427 
428  Double_t dCorT = 0;
429  for (Int_t iBin = 0; iBin < fhCorTOff[iDetIndx]->GetNbinsX();
430  iBin++) {
431  Double_t dCts = hCW->GetBinContent(iBin + 1);
432  Double_t dWOff = fhCorWalk[iDetIndx][iCh][iSide]->GetBinContent(
433  iBin + 1); // current value
434  if (dCts > MinCounts) { dCorT = hpW->GetBinContent(iBin + 1); }
435  fhCorWalk[iDetIndx][iCh][iSide]->SetBinContent(
436  iBin + 1, dWOff + dCorT); //set new value
437  }
438  // determine effective/count rate weighted mean
439  Double_t dMean = 0;
440  Double_t dCtsAll = 0.;
441  for (Int_t iBin = 0; iBin < fhCorTOff[iDetIndx]->GetNbinsX();
442  iBin++) {
443  Double_t dCts = hCW->GetBinContent(iBin + 1);
444  Double_t dWOff = fhCorWalk[iDetIndx][iCh][iSide]->GetBinContent(
445  iBin + 1); // current value
446  if (dCts > MinCounts) {
447  dCtsAll += dCts;
448  dMean += dCts * dWOff;
449  }
450  }
451  if (dCtsAll > 0.) dMean /= dCtsAll;
452  // keep mean value at 0
453  for (Int_t iBin = 0; iBin < fhCorTOff[iDetIndx]->GetNbinsX();
454  iBin++) {
455  Double_t dWOff = fhCorWalk[iDetIndx][iCh][iSide]->GetBinContent(
456  iBin + 1); // current value
457  fhCorWalk[iDetIndx][iCh][iSide]->SetBinContent(
458  iBin + 1, dWOff - dMean); //set new value
459  }
460  }
461  }
462  break;
463  } //switch( iOpt) end
464  }
465 
466  TFile* fCalParFileNew =
467  new TFile(Form("New_%s", fCalParFile->GetName()), "RECREATE");
468  WriteHist(fCalParFileNew);
469  fCalParFileNew->Close();
470 
471  return kTRUE;
472 }
473 
474 void CbmTofCalibrator::ReadHist(TFile* fHist) {
475  LOG(info) << "Read Cor histos from file " << fHist->GetName();
476  if (0 == fhCorPos.size()) {
477  Int_t iNbDet = fDigiBdfPar->GetNbDet();
478  //LOG(info) << "resize histo vector for " << iNbDet << " detectors ";
479  fhCorPos.resize(iNbDet);
480  fhCorTOff.resize(iNbDet);
481  fhCorTot.resize(iNbDet);
482  fhCorTotOff.resize(iNbDet);
483  fhCorSvel.resize(iNbDet);
484  fhCorWalk.resize(iNbDet);
485  }
486 
487  for (Int_t iDetIndx = 0; iDetIndx < fDigiBdfPar->GetNbDet(); iDetIndx++) {
488  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
489  //Int_t iSmAddr = iUniqueId & DetMask;
490  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
491  Int_t iSm = CbmTofAddress::GetSmId(iUniqueId);
492  Int_t iRpc = CbmTofAddress::GetRpcId(iUniqueId);
493  //LOG(info) << "Get histo pointer for TSR " << iSmType<<iSm<<iRpc;
494 
495  fhCorPos[iDetIndx] = (TH1*) gDirectory->FindObjectAny(
496  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
497  if (NULL == fhCorPos[iDetIndx]) {
498  LOG(error) << "hCorPos not found";
499  return;
500  }
501  fhCorTOff[iDetIndx] = (TH1*) gDirectory->FindObjectAny(
502  Form("cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
503  fhCorTot[iDetIndx] = (TH1*) gDirectory->FindObjectAny(
504  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
505  fhCorTotOff[iDetIndx] = (TH1*) gDirectory->FindObjectAny(
506  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
507 
508  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
509  fhCorWalk[iDetIndx].resize(iNbCh);
510  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
511  fhCorWalk[iDetIndx][iCh].resize(2);
512  for (Int_t iSide = 0; iSide < 2; iSide++) {
513  //LOG(info) << "Get walk histo pointer for TSRCS " << iSmType<<iSm<<iRpc<<iCh<<iSide;
514  fhCorWalk[iDetIndx][iCh][iSide] = (TH1*) gDirectory->FindObjectAny(
515  Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%d_Walk_px",
516  iSmType,
517  iSm,
518  iRpc,
519  iCh,
520  iSide));
521  }
522  }
523  }
524 }
525 
526 void CbmTofCalibrator::WriteHist(TFile* fHist) {
527  LOG(info) << "Write Cor histos to file " << fHist->GetName();
528  TDirectory* oldir = gDirectory;
529  fHist->cd();
530  for (Int_t iDetIndx = 0; iDetIndx < fDigiBdfPar->GetNbDet(); iDetIndx++) {
531  fhCorPos[iDetIndx]->Write();
532  fhCorTOff[iDetIndx]->Write();
533  fhCorTot[iDetIndx]->Write();
534  fhCorTotOff[iDetIndx]->Write();
535 
536  Int_t iNbCh = (Int_t) fhCorWalk[iDetIndx].size();
537  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
538  for (Int_t iSide = 0; iSide < 2; iSide++) {
539  fhCorWalk[iDetIndx][iCh][iSide]->Write();
540  }
541  }
542  }
543  oldir->cd();
544 }
545 
CbmTofDigiBdfPar.h
CbmTofCell::GetZ
Double_t GetZ() const
Definition: CbmTofCell.h:38
CbmHit::GetZ
Double_t GetZ() const
Definition: CbmHit.h:70
CbmTofTrackletTools
contains fits and resolution functions
Definition: CbmTofTrackletTools.h:21
CbmMatch
Definition: CbmMatch.h:22
CbmTofCalibrator
contains filling and updating of calibration histos
Definition: CbmTofCalibrator.h:44
CbmTofCalibrator::InitParameters
Bool_t InitParameters()
Definition: CbmTofCalibrator.cxx:110
CbmTofCalibrator::fhCorTOff
std::vector< TH1 * > fhCorTOff
Definition: CbmTofCalibrator.h:80
CbmTofAddress::GetSmType
static Int_t GetSmType(UInt_t address)
Definition: CbmTofAddress.h:82
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmMatch::GetLink
const CbmLink & GetLink(Int_t i) const
Definition: CbmMatch.h:35
CbmMatch::GetNofLinks
Int_t GetNofLinks() const
Definition: CbmMatch.h:38
CbmTofCalibrator::~CbmTofCalibrator
virtual ~CbmTofCalibrator()
Definition: CbmTofCalibrator.cxx:56
CbmTofTracklet::GetNofHits
Int_t GetNofHits() const
Definition: CbmTofTracklet.h:48
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmTofCalibrator::ReadHist
void ReadHist(TFile *fhFile)
Definition: CbmTofCalibrator.cxx:474
CbmTofCalibrator::fhCalWalk
std::vector< std::vector< std::vector< TH2 * > > > fhCalWalk
Definition: CbmTofCalibrator.h:77
CbmTofCalibrator::Init
InitStatus Init()
Definition: CbmTofCalibrator.cxx:58
CbmTofDigiBdfPar::GetNbChan
Int_t GetNbChan(Int_t iSmType, Int_t iRpc) const
Definition: CbmTofDigiBdfPar.cxx:570
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmTofTracklet::GetTofHitIndex
Int_t GetTofHitIndex(Int_t ind) const
Definition: CbmTofTracklet.h:71
CbmTofTracklet
Provides information on attaching a TofHit to a TofTrack.
Definition: CbmTofTracklet.h:25
CbmTofEventClusterizer::GetCalParFileName
TString GetCalParFileName()
Definition: CbmTofEventClusterizer.h:160
CbmTofAddress::GetRpcId
static Int_t GetRpcId(UInt_t address)
Definition: CbmTofAddress.h:89
CbmTofDigiBdfPar::GetSigVel
Double_t GetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc) const
Definition: CbmTofDigiBdfPar.cxx:546
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmTofCalibrator::fTofDigiMatchColl
TClonesArray * fTofDigiMatchColl
Definition: CbmTofCalibrator.h:71
CbmTofDigiPar.h
CbmMatch.h
CbmTofAddress::GetSmId
static Int_t GetSmId(UInt_t address)
Definition: CbmTofAddress.h:75
CbmTofDigiPar::GetCell
CbmTofCell * GetCell(Int_t i)
Definition: CbmTofDigiPar.h:48
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmTofTracklet.h
CbmTofCalibrator::CbmTofCalibrator
CbmTofCalibrator()
Definition: CbmTofCalibrator.cxx:36
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmTofCalibrator::fTrackletTools
CbmTofTrackletTools * fTrackletTools
Definition: CbmTofCalibrator.h:67
CbmTofGeoHandler.h
CbmTofCalibrator.h
CbmTofFindTracks::Instance
static CbmTofFindTracks * Instance()
Definition: CbmTofFindTracks.h:65
CbmTofDetectorId_v14a.h
CbmTofDigi::GetSide
Double_t GetSide() const
Channel Side.
Definition: CbmTofDigi.h:142
CbmTofTracklet::GetR0
Double_t GetR0()
Definition: CbmTofTracklet.cxx:149
CbmTofCalibrator::fTofFindTracks
CbmTofFindTracks * fTofFindTracks
Definition: CbmTofCalibrator.h:66
CbmTofCalibrator::fhCalPos
std::vector< TH2 * > fhCalPos
Definition: CbmTofCalibrator.h:73
CbmTofCalibrator::fDetIdIndexMap
std::map< UInt_t, UInt_t > fDetIdIndexMap
Definition: CbmTofCalibrator.h:87
CbmTofCalibrator::fhCorTotOff
std::vector< TH1 * > fhCorTotOff
Definition: CbmTofCalibrator.h:82
CbmTofCalibrator::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmTofCalibrator.h:64
CbmTofTracklet::ContainsAddr
virtual Bool_t ContainsAddr(Int_t iAddr)
Definition: CbmTofTracklet.cxx:466
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmTofCell::GetX
Double_t GetX() const
Definition: CbmTofCell.h:36
CbmTofCalibrator::fhCorSvel
std::vector< TH1 * > fhCorSvel
Definition: CbmTofCalibrator.h:83
CbmTofDetectorId_v12b.h
CbmTofDigi::GetChannel
Double_t GetChannel() const
Channel .
Definition: CbmTofDigi.h:136
CbmHit::GetTime
Double_t GetTime() const
Definition: CbmHit.h:75
CbmTofCell
Definition: CbmTofCell.h:8
CbmTofCalibrator::fhCalTOff
std::vector< TH2 * > fhCalTOff
Definition: CbmTofCalibrator.h:74
CbmTofCalibrator::CreateCalHist
Bool_t CreateCalHist()
Definition: CbmTofCalibrator.cxx:125
CbmTofAddress::GetChannelId
static Int_t GetChannelId(UInt_t address)
Definition: CbmTofAddress.h:96
CbmTofFindTracks::GetTOff
Double_t GetTOff(Int_t iAddr)
Definition: CbmTofFindTracks.cxx:2383
CbmHit::GetAddress
Int_t GetAddress() const
Definition: CbmHit.h:73
CbmTofTracklet::GetTt
Double_t GetTt() const
Definition: CbmTofTracklet.h:54
CbmTofCalibrator::fDigiBdfPar
CbmTofDigiBdfPar * fDigiBdfPar
Definition: CbmTofCalibrator.h:70
CbmTofDigi::GetTime
Double_t GetTime() const
Inherited from CbmDigi.
Definition: CbmTofDigi.h:111
CbmTofAddress.h
CbmTofEventClusterizer::Instance
static CbmTofEventClusterizer * Instance()
Definition: CbmTofEventClusterizer.h:58
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTofDigiBdfPar
Parameters class for the CBM ToF digitizer using beam data distributions.
Definition: CbmTofDigiBdfPar.h:30
CbmTofCell.h
CbmTofCalibrator::fTofClusterizer
CbmTofEventClusterizer * fTofClusterizer
Definition: CbmTofCalibrator.h:65
CbmTofCalibrator::fdR0Lim
Double_t fdR0Lim
Definition: CbmTofCalibrator.h:89
nbClWalkBinY
const Int_t nbClWalkBinY
Definition: CbmTofClusterizersDef.h:45
fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmTofAnaTestbeam.cxx:88
CbmTofDigi
Data class for expanded digital TOF information.
Definition: CbmTofDigi.h:38
CbmTofCalibrator::fhCalTot
std::vector< TH2 * > fhCalTot
Definition: CbmTofCalibrator.h:75
CbmTofCalibrator::UpdateCalHist
Bool_t UpdateCalHist(Int_t iOpt)
Definition: CbmTofCalibrator.cxx:358
CbmTofTracklet::GetFitX
Double_t GetFitX(Double_t Z)
Definition: CbmTofTracklet.cxx:516
nbClWalkBinX
const Int_t nbClWalkBinX
Definition: CbmTofClusterizersDef.h:44
CbmTofDigiBdfPar::GetNbDet
Int_t GetNbDet() const
Definition: CbmTofDigiBdfPar.cxx:876
CbmTofClusterizersDef.h
CbmTofDigiPar
Definition: CbmTofDigiPar.h:18
CbmTofTracklet::GetFitY
Double_t GetFitY(Double_t Z)
Definition: CbmTofTracklet.cxx:520
CbmTofCalibrator::fhCorWalk
std::vector< std::vector< std::vector< TH1 * > > > fhCorWalk
Definition: CbmTofCalibrator.h:85
CbmTofHit
Definition: core/data/tof/CbmTofHit.h:26
CbmTofCell::GetY
Double_t GetY() const
Definition: CbmTofCell.h:37
CbmTofCalibrator::fDigiPar
CbmTofDigiPar * fDigiPar
Definition: CbmTofCalibrator.h:69
CbmTofDigi::GetTot
Double_t GetTot() const
Alias for GetCharge.
Definition: CbmTofDigi.h:120
CbmTofAddress::GetUniqueAddress
static UInt_t GetUniqueAddress(UInt_t Sm, UInt_t Rpc, UInt_t Channel, UInt_t Side=0, UInt_t SmType=0)
Definition: CbmTofAddress.h:124
CbmTofCalibrator::FillCalHist
void FillCalHist(CbmTofTracklet *pTrk)
Definition: CbmTofCalibrator.cxx:228
CbmTofDigiBdfPar::GetDetUId
Int_t GetDetUId(Int_t iDet)
Definition: CbmTofDigiBdfPar.cxx:893
CbmTofCalibrator::fhCorPos
std::vector< TH1 * > fhCorPos
Definition: CbmTofCalibrator.h:79
CbmTofTracklet::GetFitT
Double_t GetFitT(Double_t R)
Definition: CbmTofTracklet.cxx:524
CbmTofTracklet::GetTofHitPointer
CbmTofHit * GetTofHitPointer(Int_t ind)
Definition: CbmTofTracklet.h:72
CbmTofCalibrator::fhCorTot
std::vector< TH1 * > fhCorTot
Definition: CbmTofCalibrator.h:81
CbmTofCalibrator::WriteHist
void WriteHist(TFile *fhFile)
Definition: CbmTofCalibrator.cxx:526
DetMask
const Int_t DetMask
Definition: CbmTofAnaTestbeam.cxx:75