CbmRoot
CbmTofCosmicClusterizer.cxx
Go to the documentation of this file.
1 
10 
11 // TOF Classes and includes
12 #include "CbmMatch.h"
13 #include "CbmTofAddress.h" // in cbmdata/tof
14 #include "CbmTofCell.h" // in tof/TofData
15 #include "CbmTofDetectorId_v12b.h" // in cbmdata/tof
16 #include "CbmTofDetectorId_v14a.h" // in cbmdata/tof
17 #include "CbmTofDigi.h" // in cbmdata/tof
18 #include "CbmTofDigiBdfPar.h" // in tof/TofParam
19 #include "CbmTofDigiPar.h" // in tof/TofParam
20 #include "CbmTofGeoHandler.h" // in tof/TofTools
21 #include "CbmTofHit.h" // in cbmdata/tof
22 #include "CbmTofPoint.h" // in cbmdata/tof
23 
24 #include "TTrbHeader.h"
25 
26 // CBMroot classes and includes
27 #include "CbmMCTrack.h"
28 
29 // FAIR classes and includes
30 #include "FairLogger.h"
31 #include "FairRootManager.h"
32 #include "FairRunAna.h"
33 #include "FairRuntimeDb.h"
34 
35 // ROOT Classes and includes
36 #include "TClonesArray.h"
37 #include "TDirectory.h"
38 #include "TF1.h"
39 #include "TF2.h"
40 #include "TGeoManager.h"
41 #include "TH1.h"
42 #include "TH2.h"
43 #include "TH3.h"
44 #include "TLine.h"
45 #include "TMath.h"
46 #include "TMinuit.h"
47 #include "TProfile.h"
48 #include "TROOT.h"
49 #include "TRandom3.h"
50 #include "TVector3.h"
51 #include <TFile.h>
52 
53 // Constants definitions
54 #include "CbmTofClusterizersDef.h"
55 
56 // C++ Classes and includes
57 // Globals
58 #include <vector>
59 
60 static Int_t iIndexDut = 0;
61 static Double_t StartAnalysisTime = 0.;
62 const Double_t cLight = 29.9792; // in cm/ns
63 
64 
66 
67 /************************************************************************************/
69  : CbmTofCosmicClusterizer("CosmicClusterizer", 0, 0) {
70  if (!fInstance) fInstance = this;
71 }
72 
74  Int_t verbose,
75  Bool_t writeDataInOut)
76  : FairTask(TString(name), verbose)
77  , fGeoHandler(new CbmTofGeoHandler())
78  , fTofId(NULL)
79  , fDigiPar(NULL)
80  , fChannelInfo(NULL)
81  , fDigiBdfPar(NULL)
82  , fTrbHeader(NULL)
83  , fTofPointsColl(NULL)
84  , fMcTracksColl(NULL)
85  , fTofDigisColl(NULL)
86  , fbWriteHitsInOut(writeDataInOut)
87  , fbWriteDigisInOut(writeDataInOut)
88  , fTofCalDigisColl(NULL)
89  , fTofHitsColl(NULL)
90  , fTofDigiMatchColl(NULL)
91  , fiNbHits(0)
92  , fVerbose(verbose)
93  , fStorDigiExp()
94  , fStorDigiInd()
95  , fviClusterMul()
96  , fviClusterSize()
97  , fviTrkMul()
98  , fvdX()
99  , fvdY()
100  , fvdDifX()
101  , fvdDifY()
102  , fvdDifCh()
103  , fhClustBuildTime(NULL)
104  , fhHitsPerTracks(NULL)
105  , fhPtsPerHit(NULL)
106  , fhTimeResSingHits(NULL)
107  , fhTimeResSingHitsB(NULL)
108  , fhTimePtVsHits(NULL)
109  , fhClusterSize(NULL)
110  , fhClusterSizeType(NULL)
111  , fhTrackMul(NULL)
112  , fhClusterSizeMulti(NULL)
113  , fhTrk1MulPos(NULL)
114  , fhHiTrkMulPos(NULL)
115  , fhAllTrkMulPos(NULL)
116  , fhMultiTrkProbPos(NULL)
117  , fhDigSpacDifClust(NULL)
118  , fhDigTimeDifClust(NULL)
119  , fhDigDistClust(NULL)
120  , fhClustSizeDifX(NULL)
121  , fhClustSizeDifY(NULL)
122  , fhChDifDifX(NULL)
123  , fhChDifDifY(NULL)
124  , fhCluMulCorDutSel(NULL)
125  , fhRpcDigiCor()
126  , fhRpcCluMul()
127  , fhRpcCluRate()
128  , fhRpcCluPosition()
129  , fhRpcCluPositionEvol()
130  , fhRpcCluTimeEvol()
131  , fhRpcCluDelPos()
132  , fhRpcCluDelMatPos()
133  , fhRpcCluTOff()
134  , fhRpcCluDelTOff()
135  , fhRpcCluDelMatTOff()
136  , fhRpcCluTrms()
137  , fhRpcCluTot()
138  , fhRpcCluSize()
139  , fhRpcCluAvWalk()
140  , fhRpcCluAvLnWalk()
141  , fhRpcCluWalk()
142  , fhSmCluPosition()
143  , fhSmCluTOff()
144  , fhSmCluSvel()
145  , fhSmCluFpar()
146  , fhRpcDTLastHits()
147  , fhRpcDTLastHits_Tot()
148  , fhRpcDTLastHits_CluSize()
149  , fhTRpcCluMul()
150  , fhTRpcCluPosition()
151  , fhTRpcCluTOff()
152  , fhTRpcCluTot()
153  , fhTRpcCluSize()
154  , fhTRpcCluAvWalk()
155  , fhTRpcCluDelTof()
156  , fhTRpcCludXdY()
157  , fhTRpcCluWalk()
158  , fhTRpcCluWalk2()
159  , fhTSmCluPosition()
160  , fhTSmCluTOff()
161  , fhTSmCluTRun()
162  , fhTRpcCluTOffDTLastHits()
163  , fhTRpcCluTotDTLastHits()
164  , fhTRpcCluSizeDTLastHits()
165  , fhTRpcCluMemMulDTLastHits()
166  , fhSeldT()
167  , fvCPDelTof()
168  , fvCPTOff()
169  , fvCPTotGain()
170  , fvCPTotOff()
171  , fvCPWalk()
172  , fvLastHits()
173  , fiNbSameSide(0)
174  , fhNbSameSide(NULL)
175  , fhNbDigiPerChan(NULL)
176  , fStart()
177  , fStop()
178  , dTRef(0.)
179  , fdTRefMax(0.)
180  , fCalMode(0)
181  , fCalSel(0)
182  , fCalSmAddr(0)
183  , fdCaldXdYMax(0.)
184  , fiCluMulMax(0)
185  , fTRefMode(0)
186  , fTRefHits(0)
187  , fDutId(0)
188  , fDutSm(0)
189  , fDutRpc(0)
190  , fDutAddr(0)
191  , fSelId(0)
192  , fSelSm(0)
193  , fSelRpc(0)
194  , fSelAddr(0)
195  , fSel2Id(0)
196  , fSel2Sm(0)
197  , fSel2Rpc(0)
198  , fSel2Addr(0)
199  , fSel2MulMax(1)
200  , fDetIdIndexMap()
201  , fviDetId()
202  , vDigiIndRef()
203  , fPosYMaxScal(0.)
204  , fTRefDifMax(0.)
205  , fTotMax(0.)
206  , fTotMin(0.)
207  , fTotOff(0.)
208  , fTotMean(0.)
209  , fdDelTofMax(60.)
210  , fTotPreRange(0.)
211  , fMaxTimeDist(0.)
212  , fdChannelDeadtime(0.)
213  , fdMemoryTime(0.)
214  , fdYFitMin(1.E6)
215  , fdTimePeriod(0.)
216  , fiCorMode(0)
217  , fEnableMatchPosScaling(kTRUE)
218  , fEnableAvWalk(kFALSE)
219  , fbPs2Ns(kFALSE)
220  , fCalParFileName("")
221  , fOutHstFileName("")
222  , fCalParFile(NULL)
223  , fiNevtBuild(0)
224  , fiMsgCnt(100)
225  , fdTOTMax(50.)
226  , fdTOTMin(0.)
227  , fdTTotMean(2.)
228  , fdMaxTimeDist(0.)
229  , fdMaxSpaceDist(0.)
230  , fdEvent(0) {
231  if (!fInstance) fInstance = this;
232 }
233 
235  if (fGeoHandler) delete fGeoHandler;
236  if (fInstance == this) fInstance = 0;
237  // DeleteHistos(); // <-- if needed ?
238 }
239 
240 /************************************************************************************/
241 // FairTasks inherited functions
243  LOG(info)
244  << "CbmTofCosmicClusterizer initializing... expect Digis in ns units! ";
245 
246  if (kFALSE == RegisterInputs()) return kFATAL;
247 
248  if (kFALSE == RegisterOutputs()) return kFATAL;
249 
250  if (kFALSE == InitParameters()) return kFATAL;
251 
252  if (kFALSE == LoadGeometry()) return kFATAL;
253 
254  if (kFALSE == InitCalibParameter()) return kFATAL;
255 
256  if (kFALSE == CreateHistos()) return kFATAL;
257 
262 
263  LOG(info) << "Init() completed for " << iNSel << " triggers"
264  << ", Dut " << fDutId << ", " << fDutSm << ", " << fDutRpc
265  << Form(", 0x%08x", fDutAddr) << ", Sel " << fSelId << ", "
266  << fSelSm << ", " << fSelRpc << Form(", 0x%08x", fSelAddr)
267  << ", Sel2 " << fSel2Id << ", " << fSel2Sm << ", " << fSel2Rpc
268  << Form(", 0x%08x", fSel2Addr);
269 
270  return kSUCCESS;
271 }
272 
273 
275  LOG(info) << "=> Get the digi parameters for tof";
276  LOG(warning) << "Return without action";
277  return;
278  // Get Base Container
279  FairRunAna* ana = FairRunAna::Instance();
280  FairRuntimeDb* rtdb = ana->GetRuntimeDb();
281 
282  fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar"));
283 
284  LOG(info) << "found " << fDigiPar->GetNrOfModules() << " cells ";
285  fDigiBdfPar = (CbmTofDigiBdfPar*) (rtdb->getContainer("CbmTofDigiBdfPar"));
286 }
287 
288 
289 void CbmTofCosmicClusterizer::Exec(Option_t* /*option*/) {
290  // Clear output arrays
291  fTofCalDigisColl->Clear("C");
292  fTofHitsColl->Clear("C");
293  //fTofHitsColl->Delete(); // Computationally costly!, but hopefully safe
294  //for (Int_t i=0; i<fTofDigiMatchColl->GetEntries(); i++) ((CbmMatch *)(fTofDigiMatchColl->At(i)))->ClearLinks(); // FIXME, try to tamper memory leak (did not help)
295  //fTofDigiMatchColl->Clear("C+L"); // leads to memory leak
296  fTofDigiMatchColl->Delete();
297 
298  fiNbHits = 0;
299 
300  LOG(debug) << "CbmTofCosmicClusterizer::Exec => New event";
301  fStart.Set();
302 
303  BuildClusters();
304 
305  MergeClusters();
306 
307  fStop.Set();
308 
309  fdEvent++;
310  FillHistos();
311 
312  // fTofDigisColl->RemoveAll();
313 }
314 
315 /************************************************************************************/
317  WriteHistos();
318  // Prevent them from being sucked in by the CbmHadronAnalysis WriteHistograms method
319  // DeleteHistos();
320  if (fdMemoryTime > 0.) CleanLHMemory();
321 }
322 
323 void CbmTofCosmicClusterizer::Finish(Double_t calMode) {
324  SetCalMode(calMode);
325  WriteHistos();
326 }
327 
328 /************************************************************************************/
329 // Functions common for all clusters approximations
331  FairRootManager* fManager = FairRootManager::Instance();
332 
333  if (NULL == fManager) {
334  LOG(error) << "CbmTofCosmicClusterizer::RegisterInputs => Could not find "
335  "FairRootManager!!!";
336  return kFALSE;
337  } // if( NULL == fTofDigisColl)
338 
339  /*
340  fTofPointsColl = (TClonesArray *) fManager->GetObject("TofPoint");
341  if( NULL == fTofPointsColl)
342  {
343  LOG(error)<<"CbmTofCosmicClusterizer::RegisterInputs => Could not get the TofPoint TClonesArray!!!";
344  return kFALSE;
345  } // if( NULL == fTofPointsColl)
346 
347  fMcTracksColl = (TClonesArray *) fManager->GetObject("MCTrack");
348  if( NULL == fMcTracksColl)
349  {
350  LOG(error)<<"CbmTofCosmicClusterizer::RegisterInputs => Could not get the MCTrack TClonesArray!!!";
351  return kFALSE;
352  } // if( NULL == fMcTracksColl)
353  */
354 
355  fTofDigisColl = (TClonesArray*) fManager->GetObject("CbmTofDigi");
356 
357  if (NULL == fTofDigisColl)
358  fTofDigisColl = (TClonesArray*) fManager->GetObject("CbmTofDigi");
359 
360  if (NULL == fTofDigisColl)
361  fTofDigisColl = (TClonesArray*) fManager->GetObject("TofDigiExp");
362 
363  if (NULL == fTofDigisColl)
364  fTofDigisColl = (TClonesArray*) fManager->GetObject("TofDigi");
365 
366  if (NULL == fTofDigisColl) {
367  LOG(error) << "CbmTofCosmicClusterizer::RegisterInputs => Could not get "
368  "the CbmTofDigi TClonesArray!!!";
369  return kFALSE;
370  } // if( NULL == fTofDigisColl)
371 
372 
373  fTrbHeader = (TTrbHeader*) fManager->GetObject("TofTrbHeader.");
374  if (NULL == fTrbHeader) {
375  LOG(info) << "CbmTofCosmicClusterizer::RegisterInputs => Could not get the "
376  "TofTrbHeader Object";
377  }
378 
379  return kTRUE;
380 }
382  FairRootManager* rootMgr = FairRootManager::Instance();
383 
384  fTofCalDigisColl = new TClonesArray("CbmTofDigi");
385 
386  // Flag check to control whether digis are written in output root file
387  rootMgr->Register("TofCalDigi", "Tof", fTofCalDigisColl, fbWriteDigisInOut);
388 
389 
390  fTofHitsColl = new TClonesArray("CbmTofHit");
391 
392  // Flag check to control whether digis are written in output root file
393  rootMgr->Register("TofHit", "Tof", fTofHitsColl, fbWriteHitsInOut);
394 
395  fTofDigiMatchColl = new TClonesArray("CbmMatch", 100);
396  rootMgr->Register("TofDigiMatch", "Tof", fTofDigiMatchColl, fbWriteHitsInOut);
397 
398  return kTRUE;
399 }
401 
402  // Initialize the TOF GeoHandler
403  Bool_t isSimulation = kFALSE;
404  LOG(info)
405  << "CbmTofCosmicClusterizer::InitParameters - Geometry, Mapping, ... ??";
406 
407  // Get Base Container
408  FairRun* ana = FairRun::Instance();
409  FairRuntimeDb* rtdb = ana->GetRuntimeDb();
410 
411  Int_t iGeoVersion = fGeoHandler->Init(isSimulation);
412  if (k14a > iGeoVersion) {
413  LOG(error) << "CbmTofCosmicClusterizer::InitParameters => Only compatible "
414  "with geometries after v14a !!!";
415  return kFALSE;
416  }
418 
419  fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar"));
420  if (0 == fDigiPar) {
421  LOG(error) << "CbmTofCosmicClusterizer::InitParameters => Could not obtain "
422  "the CbmTofDigiPar ";
423  return kFALSE;
424  }
425 
426  fDigiBdfPar = (CbmTofDigiBdfPar*) (rtdb->getContainer("CbmTofDigiBdfPar"));
427  if (0 == fDigiBdfPar) {
428  LOG(error) << "CbmTofCosmicClusterizer::InitParameters => Could not obtain "
429  "the CbmTofDigiBdfPar ";
430  return kFALSE;
431  }
432 
433  rtdb->initContainers(ana->GetRunId());
434 
435  LOG(info) << "CbmTofCosmicClusterizer::InitParameter: currently "
436  << fDigiPar->GetNrOfModules() << " digi cells ";
437 
438 
441 
442  if (fMaxTimeDist != fdMaxTimeDist) {
443  fdMaxTimeDist = fMaxTimeDist; // modify default
446  * 0.5; // cut consistently on positions (with default signal velocity)
447  }
448 
449  LOG(info) << " BuildCluster with MaxTimeDist " << fdMaxTimeDist
450  << ", MaxSpaceDist " << fdMaxSpaceDist;
451 
452  if (fiCluMulMax == 0) fiCluMulMax = 100;
453  if (fOutHstFileName == "") { fOutHstFileName = "./tofCosmicClust.hst.root"; }
454 
455  LOG(info) << " Hst Output filename = " << fOutHstFileName;
456 
457  LOG(info) << "<I> Sel2Type = " << fSel2Id << ", Sm " << fSel2Sm << ", Det "
458  << fSel2Rpc << ", MulMax " << fSel2MulMax;
459 
460  return kTRUE;
461 }
462 /************************************************************************************/
464  // dimension and initialize calib parameter
465  // Int_t iNbDet = fDigiBdfPar->GetNbDet(); (VF) not used
466  Int_t iNbSmTypes = fDigiBdfPar->GetNbSmTypes();
467 
468  if (fTotMean != 0.) fdTTotMean = fTotMean; // adjust target mean for TTT
469 
470  fvCPTOff.resize(iNbSmTypes);
471  fvCPTotGain.resize(iNbSmTypes);
472  fvCPTotOff.resize(iNbSmTypes);
473  fvCPWalk.resize(iNbSmTypes);
474  fvCPDelTof.resize(iNbSmTypes);
475  for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
476  Int_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
477  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
478  fvCPTOff[iSmType].resize(iNbSm * iNbRpc);
479  fvCPTotGain[iSmType].resize(iNbSm * iNbRpc);
480  fvCPTotOff[iSmType].resize(iNbSm * iNbRpc);
481  fvCPWalk[iSmType].resize(iNbSm * iNbRpc);
482  fvCPDelTof[iSmType].resize(iNbSm * iNbRpc);
483  for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
484  for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
485  // LOG(info)<<Form(" fvCPDelTof resize for SmT %d, R %d, B %d ",iSmType,iNbSm*iNbRpc,nbClDelTofBinX)
486  // ;
487  fvCPDelTof[iSmType][iSm * iNbRpc + iRpc].resize(nbClDelTofBinX);
488  for (Int_t iBx = 0; iBx < nbClDelTofBinX; iBx++) {
489  // LOG(info)<<Form(" fvCPDelTof for SmT %d, R %d, B %d",iSmType,iSm*iNbRpc+iRpc,iBx);
490  fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx].resize(iNSel);
491  for (Int_t iSel = 0; iSel < iNSel; iSel++)
492  fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] =
493  0.; // initialize
494  }
495 
496  Int_t iNbChan = fDigiBdfPar->GetNbChan(iSmType, iRpc);
497  fvCPTOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
498  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
499  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
500  fvCPWalk[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
501  Int_t nbSide = 2 - fDigiBdfPar->GetChanType(iSmType, iRpc);
502  for (Int_t iCh = 0; iCh < iNbChan; iCh++) {
503  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
504  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
505  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
506  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh].resize(nbSide);
507  for (Int_t iSide = 0; iSide < nbSide; iSide++) {
508  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
509  0.; //initialize
510  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
511  1.; //initialize
512  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
513  0.; //initialize
514  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide].resize(
515  nbClWalkBinX);
516  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
517  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][iSide][iWx] = 0.;
518  }
519  }
520  }
521  }
522  }
523  }
524 
525  LOG(info) << "CbmTofCosmicClusterizer::InitCalibParameter: defaults set";
526 
527  TDirectory* oldir =
528  gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager!
529  /*
530  gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager !
531  */
532 
533  if (0 < fCalMode) {
534  LOG(info)
535  << "CbmTofCosmicClusterizer::InitCalibParameter: read histos from "
536  << "file " << fCalParFileName;
537 
538  // read parameter from histos
539  if (fCalParFileName.IsNull()) return kTRUE;
540 
541  fCalParFile = new TFile(fCalParFileName, "");
542  if (NULL == fCalParFile) {
543  LOG(fatal) << "CbmTofCosmicClusterizer::InitCalibParameter: "
544  << "file " << fCalParFileName << " does not exist!";
545  return kTRUE;
546  }
547  /*
548  gDirectory->Print();
549  fCalParFile->cd();
550  fCalParFile->ls();
551  */
552  for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
553  Int_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
554  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
555  TProfile* hSvel =
556  (TProfile*) gDirectory->FindObjectAny(Form("cl_SmT%01d_Svel", iSmType));
557 
558  // copy Histo to memory
559  TDirectory* curdir = gDirectory;
560  if (NULL != hSvel) {
561  gDirectory->cd(oldir->GetPath());
562  // TProfile *hSvelmem = (TProfile *)hSvel->Clone(); (VF) not used
563  gDirectory->cd(curdir->GetPath());
564  } else {
565  LOG(info) << "Svel histogram not found for module type " << iSmType;
566  }
567 
568  for (Int_t iPar = 0; iPar < 4; iPar++) {
569  TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(
570  Form("cl_SmT%01d_Fpar%1d", iSmType, iPar));
571  if (NULL != hFparcur) {
572  gDirectory->cd(oldir->GetPath());
573  // TProfile *hFparmem = (TProfile *)hFparcur->Clone(); (VF) not used
574  gDirectory->cd(curdir->GetPath());
575  }
576  }
577 
578  for (Int_t iSm = 0; iSm < iNbSm; iSm++)
579  for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
580  // update default parameter
581  if (NULL != hSvel) {
582  Double_t Vscal = 1.; //hSvel->GetBinContent(iSm*iNbRpc+iRpc+1);
583  if (Vscal == 0.) Vscal = 1.;
584  fDigiBdfPar->SetSigVel(iSmType,
585  iSm,
586  iRpc,
587  fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
588  * Vscal);
589  LOG(info) << "Modify " << iSmType << iSm << iRpc << " Svel by "
590  << Vscal << " to "
591  << fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
592  }
593  TH2F* htempPos_pfx = (TH2F*) gDirectory->FindObjectAny(
594  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
595  TH2F* htempTOff_pfx = (TH2F*) gDirectory->FindObjectAny(
596  Form("cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
597  TH1D* htempTot_Mean = (TH1D*) gDirectory->FindObjectAny(
598  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
599  TH1D* htempTot_Off = (TH1D*) gDirectory->FindObjectAny(
600  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
601  if (NULL != htempPos_pfx && NULL != htempTOff_pfx
602  && NULL != htempTot_Mean && NULL != htempTot_Off) {
603  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
604  Int_t iNbinTot = htempTot_Mean->GetNbinsX();
605  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
606  Double_t YMean = ((TProfile*) htempPos_pfx)
607  ->GetBinContent(iCh + 1); //nh +1 empirical(?)
608  Double_t TMean =
609  ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
610  //Double_t dTYOff=YMean/fDigiBdfPar->GetSignalSpeed() ;
611  Double_t dTYOff =
612  YMean / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
613  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
614  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
615 
616  for (Int_t iSide = 0; iSide < 2; iSide++) {
617  Double_t TotMean = htempTot_Mean->GetBinContent(
618  iCh * 2 + 1 + iSide); //nh +1 empirical(?)
619  if (0.001 < TotMean) {
620  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
621  fdTTotMean / TotMean;
622  }
623  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] =
624  htempTot_Off->GetBinContent(iCh * 2 + 1 + iSide);
625  }
626 
627  if (5 == iSmType || 8 == iSmType) {
628  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
629  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
630  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
631  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0];
632  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] =
633  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
634  }
635 
636  LOG(debug) << "CbmTofCosmicClusterizer::InitCalibParameter:"
637  << " SmT " << iSmType << " Sm " << iSm << " Rpc "
638  << iRpc << " Ch " << iCh
639  << Form(": YMean %f, TMean %f", YMean, TMean) << " -> "
640  << Form(
641  " %f, %f, %f, %f ",
642  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
643  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
644  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
645  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1])
646  << ", NbinTot " << iNbinTot;
647 
648  TH1D* htempWalk0 = (TH1D*) gDirectory->FindObjectAny(
649  Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
650  iSmType,
651  iSm,
652  iRpc,
653  iCh));
654  TH1D* htempWalk1 = (TH1D*) gDirectory->FindObjectAny(
655  Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
656  iSmType,
657  iSm,
658  iRpc,
659  iCh));
660  if (NULL != htempWalk0
661  && NULL != htempWalk1) { // reinitialize Walk array
662  LOG(debug) << "Initialize Walk correction for "
663  << Form(" SmT%01d_sm%03d_rpc%03d_Ch%03d",
664  iSmType,
665  iSm,
666  iRpc,
667  iCh);
668  if (htempWalk0->GetNbinsX() != nbClWalkBinX)
669  LOG(error) << "CbmTofCosmicClusterizer::InitCalibParameter: "
670  "Inconsistent Walk histograms";
671  for (Int_t iBin = 0; iBin < nbClWalkBinX; iBin++) {
672  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin] =
673  htempWalk0->GetBinContent(iBin + 1);
674  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
675  htempWalk1->GetBinContent(iBin + 1);
676  LOG(debug1) << Form(
677  " SmT%01d_sm%03d_rpc%03d_Ch%03d bin %d walk %f ",
678  iSmType,
679  iSm,
680  iRpc,
681  iCh,
682  iBin,
683  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin]);
684  if (5 == iSmType || 8 == iSmType) { // Pad structure
685  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iBin] =
686  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iBin];
687  }
688  }
689  }
690  }
691  } else {
692  LOG(warning) << " Calibration histos "
693  << Form("cl_SmT%01d_sm%03d_rpc%03d_XXX",
694  iSmType,
695  iSm,
696  iRpc)
697  << " not found. ";
698  }
699  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
700  TH1D* htmpDelTof = (TH1D*) gDirectory->FindObjectAny(
701  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
702  iSmType,
703  iSm,
704  iRpc,
705  iSel));
706  if (NULL == htmpDelTof) {
707  LOG(debug) << " Histos "
708  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
709  iSmType,
710  iSm,
711  iRpc,
712  iSel)
713  << " not found. ";
714  continue;
715  }
716  LOG(debug) << " Load DelTof from histos "
717  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
718  iSmType,
719  iSm,
720  iRpc,
721  iSel)
722  << ".";
723  for (Int_t iBx = 0; iBx < nbClDelTofBinX; iBx++) {
724  fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] +=
725  htmpDelTof->GetBinContent(iBx + 1);
726  }
727 
728  // copy Histo to memory
729  // TDirectory * curdir = gDirectory;
730  gDirectory->cd(oldir->GetPath());
731  TH1D* h1DelTof = (TH1D*) htmpDelTof->Clone(
732  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
733  iSmType,
734  iSm,
735  iRpc,
736  iSel));
737 
738  LOG(debug) << " copy histo " << h1DelTof->GetName()
739  << " to directory " << oldir->GetName();
740 
741  gDirectory->cd(curdir->GetPath());
742  }
743  }
744  }
745  }
746  // fCalParFile->Delete();
747  gDirectory->cd(
748  oldir
749  ->GetPath()); // <= To prevent histos from being sucked in by the param file of the TRootManager!
750  LOG(info)
751  << "CbmTofCosmicClusterizer::InitCalibParameter: initialization done";
752  return kTRUE;
753 }
754 /************************************************************************************/
756  LOG(info) << "CbmTofCosmicClusterizer::LoadGeometry starting for "
757  << fDigiBdfPar->GetNbDet() << " described detectors, "
758  << fDigiPar->GetNrOfModules() << " geometrically known modules ";
759 
760  //fTRefMode=0x00002016; // use plastic 1 as time reference
761 
762  Int_t iNrOfCells = fDigiPar->GetNrOfModules();
763  LOG(info) << "Digi Parameter container contains " << iNrOfCells << " cells.";
764  for (Int_t icell = 0; icell < iNrOfCells; ++icell) {
765 
766  Int_t cellId =
767  fDigiPar->GetCellId(icell); // cellId is assigned in CbmTofCreateDigiPar
768  fChannelInfo = fDigiPar->GetCell(cellId);
769 
770  Int_t smtype = fGeoHandler->GetSMType(cellId);
771  Int_t smodule = fGeoHandler->GetSModule(cellId);
772  Int_t module = fGeoHandler->GetCounter(cellId);
773  Int_t cell = fGeoHandler->GetCell(cellId);
774 
775  Double_t x = fChannelInfo->GetX();
776  Double_t y = fChannelInfo->GetY();
777  Double_t z = fChannelInfo->GetZ();
778  Double_t dx = fChannelInfo->GetSizex();
779  Double_t dy = fChannelInfo->GetSizey();
780  LOG(debug) << "-I- InitPar " << icell << " Id: " << Form("0x%08x", cellId)
781  << " " << cell << " tmcs: " << smtype << " " << smodule << " "
782  << module << " " << cell << " x=" << Form("%6.2f", x)
783  << " y=" << Form("%6.2f", y) << " z=" << Form("%6.2f", z)
784  << " dx=" << dx << " dy=" << dy;
785 
786  TGeoNode* fNode = // prepare local->global trafo
787  gGeoManager->FindNode(
789  LOG(debug2) << Form(" Node at (%6.1f,%6.1f,%6.1f) : 0x%p",
790  fChannelInfo->GetX(),
791  fChannelInfo->GetY(),
792  fChannelInfo->GetZ(),
793  fNode);
794  // fNode->Print();
795  }
796 
797  Int_t iNbDet = fDigiBdfPar->GetNbDet();
798  for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
799  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
800  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
801  Int_t iSmId = CbmTofAddress::GetSmId(iUniqueId);
802  Int_t iRpcId = CbmTofAddress::GetRpcId(iUniqueId);
803  LOG(info) << " DetIndx " << iDetIndx << "(" << iNbDet << "), SmType "
804  << iSmType << ", SmId " << iSmId << ", RpcId " << iRpcId
805  << " => UniqueId " << Form("0x%08x ", iUniqueId)
806  << Form(" Svel %6.6f ",
807  fDigiBdfPar->GetSigVel(iSmType, iSmId, iRpcId));
808  Int_t iCell = -1;
809  while (kTRUE) {
810  Int_t iUCellId =
811  CbmTofAddress::GetUniqueAddress(iSmId, iRpcId, ++iCell, 0, iSmType);
812  fChannelInfo = fDigiPar->GetCell(iUCellId);
813  if (NULL == fChannelInfo) break;
814  LOG(debug3) << " Cell " << iCell << Form(" 0x%08x ", iUCellId)
815  << Form(", fCh 0x%p ", fChannelInfo)
816  << ", x: " << fChannelInfo->GetX()
817  << ", y: " << fChannelInfo->GetY()
818  << ", z: " << fChannelInfo->GetZ();
819  }
820  }
821 
822  // return kTRUE;
823 
824  Int_t iNbSmTypes = fDigiBdfPar->GetNbSmTypes();
825 
826  if (kTRUE == fDigiBdfPar->UseExpandedDigi()) {
827  fStorDigiExp.resize(iNbSmTypes);
828  fStorDigiInd.resize(iNbSmTypes);
829  fviClusterSize.resize(iNbSmTypes);
830  fviTrkMul.resize(iNbSmTypes);
831  fvdX.resize(iNbSmTypes);
832  fvdY.resize(iNbSmTypes);
833  fvdDifX.resize(iNbSmTypes);
834  fvdDifY.resize(iNbSmTypes);
835  fvdDifCh.resize(iNbSmTypes);
836  fviClusterMul.resize(iNbSmTypes);
837  fvLastHits.resize(iNbSmTypes);
838 
839  for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
840  Int_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
841  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
842  fStorDigiExp[iSmType].resize(iNbSm * iNbRpc);
843  fStorDigiInd[iSmType].resize(iNbSm * iNbRpc);
844  fviClusterSize[iSmType].resize(iNbRpc);
845  fviTrkMul[iSmType].resize(iNbRpc);
846  fvdX[iSmType].resize(iNbRpc);
847  fvdY[iSmType].resize(iNbRpc);
848  fvdDifX[iSmType].resize(iNbRpc);
849  fvdDifY[iSmType].resize(iNbRpc);
850  fvdDifCh[iSmType].resize(iNbRpc);
851  for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
852  fviClusterMul[iSmType].resize(iNbSm);
853  fvLastHits[iSmType].resize(iNbSm);
854  for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
855  fviClusterMul[iSmType][iSm].resize(iNbRpc);
856  fvLastHits[iSmType][iSm].resize(iNbRpc);
857  Int_t iNbChan = fDigiBdfPar->GetNbChan(iSmType, iRpc);
858  if (iNbChan == 0) {
859  LOG(warning) << "CbmTofCosmicClusterizer::LoadGeometry: StoreDigi "
860  "without channels "
861  << Form("SmTy %3d, Sm %3d, NbRpc %3d, Rpc, %3d ",
862  iSmType,
863  iSm,
864  iNbRpc,
865  iRpc);
866  }
867  LOG(debug1)
868  << "CbmTofCosmicClusterizer::LoadGeometry: StoreDigi with "
869  << Form(
870  " %3d %3d %3d %3d %5d ", iSmType, iSm, iNbRpc, iRpc, iNbChan);
871  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
872  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc].resize(iNbChan);
873  fvLastHits[iSmType][iSm][iRpc].resize(iNbChan);
874  } // for( Int_t iRpc = 0; iRpc < iNbRpc; iRpc++ )
875  } // for( Int_t iSm = 0; iSm < iNbSm; iSm++ )
876  } // for( Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++ )
877  } // if( kTRUE == fDigiBdfPar->UseExpandedDigi() )
878 
879  return kTRUE;
880 }
882  LOG(info) << "CbmTofCosmicClusterizer::DeleteGeometry starting";
883  return kTRUE;
884  Int_t iNbSmTypes = fDigiBdfPar->GetNbSmTypes();
885  if (kTRUE == fDigiBdfPar->UseExpandedDigi()) {
886  for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
887  Int_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
888  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
889  for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
890  for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
891  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].clear();
892  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc].clear();
893  }
894  } // for( Int_t iSm = 0; iSm < iNbSm; iSm++ )
895  fStorDigiExp[iSmType].clear();
896  fStorDigiInd[iSmType].clear();
897  } // for( Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++ )
898  fStorDigiExp.clear();
899  fStorDigiInd.clear();
900  } // if( kTRUE == fDigiBdfPar->UseExpandedDigi() )
901 
902  return kTRUE;
903 }
904 /************************************************************************************/
905 // Histogramming functions
907  TDirectory* oldir =
908  gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager!
909  gROOT
910  ->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager !
912  new TH1I("TofCosmicClus_ClustBuildTime",
913  "Time needed to build clusters in each event; Time [s]",
914  4000,
915  0.0,
916  4.0);
917 
918  /* TH2* hTemp = 0;*/
919 
920  // Sm related distributions
928 
929  for (Int_t iS = 0; iS < fDigiBdfPar->GetNbSmTypes(); iS++) {
930  Double_t YSCAL = 50.;
931  if (fPosYMaxScal != 0.) YSCAL = fPosYMaxScal;
932  Int_t iUCellId = CbmTofAddress::GetUniqueAddress(0, 0, 0, 0, iS);
933  fChannelInfo = fDigiPar->GetCell(iUCellId);
934  if (NULL == fChannelInfo) {
935  LOG(warning) << "No DigiPar for SmType "
936  << Form("%d, 0x%08x", iS, iUCellId);
937  continue;
938  }
939  Double_t YDMAX = TMath::Max(2., fChannelInfo->GetSizey()) * YSCAL;
940 
941  fhSmCluPosition[iS] =
942  new TH2F(Form("cl_SmT%01d_Pos", iS),
943  Form("Clu position of SmType %d; Sm+Rpc# []; ypos [cm]", iS),
945  0,
947  99,
948  -YDMAX,
949  YDMAX);
950 
951  Double_t TSumMax = 1.E3;
952  if (fTRefDifMax != 0.) TSumMax = fTRefDifMax;
953  fhSmCluTOff[iS] =
954  new TH2F(Form("cl_SmT%01d_TOff", iS),
955  Form("Clu TimeZero in SmType %d; Sm+Rpc# []; TOff [ns]", iS),
957  0,
958  fDigiBdfPar->GetNbSm(iS), //*fDigiBdfPar->GetNbRpc(iS),
959  99,
960  -TSumMax,
961  TSumMax);
962 
963  TProfile* hSvelcur =
964  (TProfile*) gDirectory->FindObjectAny(Form("cl_SmT%01d_Svel", iS));
965  if (NULL == hSvelcur) {
966  fhSmCluSvel[iS] = new TProfile(
967  Form("cl_SmT%01d_Svel", iS),
968  Form("Clu Svel in SmType %d; Sm+Rpc# []; v/v_{nominal} ", iS),
970  0,
972  0.8,
973  1.2);
974  fhSmCluSvel[iS]->Sumw2();
975  } else
976  fhSmCluSvel[iS] = (TProfile*) hSvelcur->Clone();
977 
978  fhSmCluFpar[iS].resize(4);
979  for (Int_t iPar = 0; iPar < 4; iPar++) {
980  TProfile* hFparcur = (TProfile*) gDirectory->FindObjectAny(
981  Form("cl_SmT%01d_Fpar%1d", iS, iPar));
982  if (NULL == hFparcur) {
983  LOG(info) << "Histo " << Form("cl_SmT%01d_Fpar%1d", iS, iPar)
984  << " not found, recreate ...";
985  fhSmCluFpar[iS][iPar] = new TProfile(
986  Form("cl_SmT%01d_Fpar%1d", iS, iPar),
987  Form("Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS),
989  0,
991  -100.,
992  100.);
993  } else
994  fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone();
995  }
996 
997  fhTSmCluPosition[iS].resize(iNSel);
998  fhTSmCluTOff[iS].resize(iNSel);
999  fhTSmCluTRun[iS].resize(iNSel);
1000  for (Int_t iSel = 0; iSel < iNSel; iSel++) { // Loop over selectors
1001  fhTSmCluPosition[iS][iSel] =
1002  new TH2F(Form("cl_TSmT%01d_Sel%02d_Pos", iS, iSel),
1003  Form("Clu position of SmType %d under Selector %02d; Sm+Rpc# "
1004  "[]; ypos [cm]",
1005  iS,
1006  iSel),
1008  0,
1010  99,
1011  -YDMAX,
1012  YDMAX);
1013  fhTSmCluTOff[iS][iSel] =
1014  new TH2F(Form("cl_TSmT%01d_Sel%02d_TOff", iS, iSel),
1015  Form("Clu TimeZero in SmType %d under Selector %02d; Sm+Rpc# "
1016  "[]; TOff [ns]",
1017  iS,
1018  iSel),
1020  0,
1022  99,
1023  -TSumMax,
1024  TSumMax);
1025  fhTSmCluTRun[iS][iSel] =
1026  new TH2F(Form("cl_TSmT%01d_Sel%02d_TRun", iS, iSel),
1027  Form("Clu TimeZero in SmType %d under Selector %02d; Event# "
1028  "[]; TMean [ns]",
1029  iS,
1030  iSel),
1031  100,
1032  0,
1033  MaxNbEvent,
1034  99,
1035  -TSumMax,
1036  TSumMax);
1037  }
1038  }
1039 
1040  // RPC related distributions
1041  Int_t iNbDet = fDigiBdfPar->GetNbDet();
1042  LOG(info) << " Define Clusterizer histos for " << iNbDet << " detectors ";
1043 
1044  fhRpcDigiCor.resize(iNbDet);
1045  fhRpcCluMul.resize(iNbDet);
1046  fhRpcCluRate.resize(iNbDet);
1047  fhRpcCluPosition.resize(iNbDet);
1048  fhRpcCluPositionEvol.resize(iNbDet);
1049  fhRpcCluTimeEvol.resize(iNbDet);
1050  fhRpcCluDelPos.resize(iNbDet);
1051  fhRpcCluDelMatPos.resize(iNbDet);
1052  fhRpcCluTOff.resize(iNbDet);
1053  fhRpcCluDelTOff.resize(iNbDet);
1054  fhRpcCluDelMatTOff.resize(iNbDet);
1055  fhRpcCluTrms.resize(iNbDet);
1056  fhRpcCluTot.resize(iNbDet);
1057  fhRpcCluSize.resize(iNbDet);
1058  fhRpcCluAvWalk.resize(iNbDet);
1059  fhRpcCluAvLnWalk.resize(iNbDet);
1060  fhRpcCluWalk.resize(iNbDet);
1061  fhRpcDTLastHits.resize(iNbDet);
1062  fhRpcDTLastHits_Tot.resize(iNbDet);
1063  fhRpcDTLastHits_CluSize.resize(iNbDet);
1064  fviDetId.resize(iNbDet);
1065 
1066  fDetIdIndexMap.clear();
1067 
1068  if (fTotMax != 0.) fdTOTMax = fTotMax;
1069  if (fTotMin != 0.) fdTOTMin = fTotMin;
1070 
1071  for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1072  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
1073  fDetIdIndexMap[iUniqueId] = iDetIndx;
1074  fviDetId[iDetIndx] = iUniqueId;
1075 
1076  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
1077  Int_t iSmId = CbmTofAddress::GetSmId(iUniqueId);
1078  Int_t iRpcId = CbmTofAddress::GetRpcId(iUniqueId);
1079  Int_t iUCellId =
1080  CbmTofAddress::GetUniqueAddress(iSmId, iRpcId, 0, 0, iSmType);
1081  fChannelInfo = fDigiPar->GetCell(iUCellId);
1082  if (NULL == fChannelInfo) {
1083  LOG(warning) << "No DigiPar for Det " << Form("0x%08x", iUCellId);
1084  continue;
1085  }
1086  LOG(info) << "DetIndx " << iDetIndx << ", SmType " << iSmType << ", SmId "
1087  << iSmId << ", RpcId " << iRpcId << " => UniqueId "
1088  << Form("(0x%08x, 0x%08x)", iUniqueId, iUCellId) << ", dx "
1089  << fChannelInfo->GetSizex() << ", dy " << fChannelInfo->GetSizey()
1090  << Form(" ChPoi: %p ", fChannelInfo) << ", nbCh "
1091  << fDigiBdfPar->GetNbChan(iSmType, 0);
1092 
1093  // check access to all channel infos
1094  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpcId); iCh++) {
1095  Int_t iCCellId =
1096  CbmTofAddress::GetUniqueAddress(iSmId, iRpcId, iCh, 0, iSmType);
1097  fChannelInfo = fDigiPar->GetCell(iCCellId);
1098  if (NULL == fChannelInfo)
1099  LOG(warning) << Form(
1100  "missing ChannelInfo for ch %d addr 0x%08x", iCh, iCCellId);
1101  }
1102 
1103  fChannelInfo = fDigiPar->GetCell(iUCellId);
1104  fhRpcDigiCor[iDetIndx] = new TH2F(
1105  Form("cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iSmType, iSmId, iRpcId),
1106  Form(
1107  "Digi Correlation of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1",
1108  iRpcId,
1109  iSmId,
1110  iSmType),
1111  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1112  0,
1113  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1114  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1115  0,
1116  fDigiBdfPar->GetNbChan(iSmType, iRpcId));
1117 
1118  fhRpcCluMul[iDetIndx] = new TH1F(
1119  Form("cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
1120  Form("Clu multiplicity of Rpc #%03d in Sm %03d of type %d; M []; Cnts",
1121  iRpcId,
1122  iSmId,
1123  iSmType),
1124  2. + 2. * fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1125  0,
1126  2. + 2. * fDigiBdfPar->GetNbChan(iSmType, iRpcId));
1127 
1128  fhRpcCluRate[iDetIndx] = new TH1F(
1129  Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSmId, iRpcId),
1130  Form("Clu rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)",
1131  iRpcId,
1132  iSmId,
1133  iSmType),
1134  3600.,
1135  0.,
1136  3600.);
1137 
1138  fhRpcDTLastHits[iDetIndx] = new TH1F(
1139  Form("cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iSmType, iSmId, iRpcId),
1140  Form("Clu #DeltaT to last hits of Rpc #%03d in Sm %03d of type %d; log( "
1141  "#DeltaT (ns)); counts",
1142  iRpcId,
1143  iSmId,
1144  iSmType),
1145  100.,
1146  0.,
1147  10.);
1148 
1149  fhRpcDTLastHits_Tot[iDetIndx] = new TH2F(
1150  Form("cl_SmT%01d_sm%03d_rpc%03d_Tot_DTLH", iSmType, iSmId, iRpcId),
1151  Form("Clu Tot of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); TOT "
1152  "[a.u.]",
1153  iRpcId,
1154  iSmId,
1155  iSmType),
1156  100,
1157  0.,
1158  10.,
1159  100,
1160  fdTOTMin,
1161  4. * fdTOTMax);
1162 
1163  fhRpcDTLastHits_CluSize[iDetIndx] = new TH2F(
1164  Form("cl_SmT%01d_sm%03d_rpc%03d_CluSize_DTLH", iSmType, iSmId, iRpcId),
1165  Form("Clu Size of Rpc #%03d in Sm %03d of type %d; log(#DeltaT (ns)); "
1166  "CluSize []",
1167  iRpcId,
1168  iSmId,
1169  iSmType),
1170  100,
1171  0.,
1172  10.,
1173  16,
1174  0.5,
1175  16.5);
1176 
1177  Double_t YSCAL = 50.;
1178  if (fPosYMaxScal != 0.) YSCAL = fPosYMaxScal;
1179  Double_t YDMAX = TMath::Max(2., fChannelInfo->GetSizey()) * YSCAL;
1180  fhRpcCluPosition[iDetIndx] = new TH2F(
1181  Form("cl_SmT%01d_sm%03d_rpc%03d_Pos", iSmType, iSmId, iRpcId),
1182  Form(
1183  "Clu position of Rpc #%03d in Sm %03d of type %d; Strip []; ypos [cm]",
1184  iRpcId,
1185  iSmId,
1186  iSmType),
1187  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1188  0,
1189  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1190  99,
1191  -YDMAX,
1192  YDMAX);
1193 
1194  fhRpcCluPositionEvol[iDetIndx] = new TProfile(
1195  Form("cl_SmT%01d_sm%03d_rpc%03d_PosEvol", iSmType, iSmId, iRpcId),
1196  Form("Clu position of Rpc #%03d in Sm %03d of type %d; Analysis Time "
1197  "[s]; ypos [cm]",
1198  iRpcId,
1199  iSmId,
1200  iSmType),
1201  1000,
1202  0.,
1203  1.E5,
1204  -100.,
1205  100.);
1206 
1207  fhRpcCluTimeEvol[iDetIndx] = new TProfile(
1208  Form("cl_SmT%01d_sm%03d_rpc%03d_TimeEvol", iSmType, iSmId, iRpcId),
1209  Form("Clu time of Rpc #%03d in Sm %03d of type %d; Analysis Time [s]; dT "
1210  "[ns]",
1211  iRpcId,
1212  iSmId,
1213  iSmType),
1214  1000,
1215  0.,
1216  1.E5,
1217  -10.,
1218  10.);
1219 
1220  fhRpcCluDelPos[iDetIndx] =
1221  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_DelPos", iSmType, iSmId, iRpcId),
1222  Form("Clu position difference of Rpc #%03d in Sm %03d of type "
1223  "%d; Strip []; #Deltaypos(clu) [cm]",
1224  iRpcId,
1225  iSmId,
1226  iSmType),
1227  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1228  0,
1229  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1230  99,
1231  -10.,
1232  10.);
1233 
1234  fhRpcCluDelMatPos[iDetIndx] = new TH2F(
1235  Form("cl_SmT%01d_sm%03d_rpc%03d_DelMatPos", iSmType, iSmId, iRpcId),
1236  Form("Matched Clu position difference of Rpc #%03d in Sm %03d of type "
1237  "%d; Strip []; #Deltaypos(mat) [cm]",
1238  iRpcId,
1239  iSmId,
1240  iSmType),
1241  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1242  0,
1243  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1244  99,
1245  -5.,
1246  5.);
1247 
1248  Double_t TSumMax = 1.E3;
1249  if (fTRefDifMax != 0.) TSumMax = fTRefDifMax;
1250  fhRpcCluTOff[iDetIndx] = new TH2F(
1251  Form("cl_SmT%01d_sm%03d_rpc%03d_TOff", iSmType, iSmId, iRpcId),
1252  Form(
1253  "Clu TimeZero of Rpc #%03d in Sm %03d of type %d; Strip []; TOff [ns]",
1254  iRpcId,
1255  iSmId,
1256  iSmType),
1257  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1258  0,
1259  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1260  99,
1261  -TSumMax,
1262  TSumMax);
1263 
1264  fhRpcCluDelTOff[iDetIndx] = new TH2F(
1265  Form("cl_SmT%01d_sm%03d_rpc%03d_DelTOff", iSmType, iSmId, iRpcId),
1266  Form("Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1267  "[]; #DeltaTOff(clu) [ns]",
1268  iRpcId,
1269  iSmId,
1270  iSmType),
1271  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1272  0,
1273  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1274  99,
1275  -0.6,
1276  0.6);
1277 
1278  fhRpcCluDelMatTOff[iDetIndx] = new TH2F(
1279  Form("cl_SmT%01d_sm%03d_rpc%03d_DelMatTOff", iSmType, iSmId, iRpcId),
1280  Form("Clu TimeZero Difference of Rpc #%03d in Sm %03d of type %d; Strip "
1281  "[]; #DeltaTOff(mat) [ns]",
1282  iRpcId,
1283  iSmId,
1284  iSmType),
1285  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1286  0,
1287  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1288  99,
1289  -0.6,
1290  0.6);
1291 
1292  fhRpcCluTrms[iDetIndx] = new TH2F(
1293  Form("cl_SmT%01d_sm%03d_rpc%03d_Trms", iSmType, iSmId, iRpcId),
1294  Form(
1295  "Clu Time RMS of Rpc #%03d in Sm %03d of type %d; Strip []; Trms [ns]",
1296  iRpcId,
1297  iSmId,
1298  iSmType),
1299  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1300  0,
1301  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1302  99,
1303  0.,
1304  0.5);
1305 
1306  fhRpcCluTot[iDetIndx] = new TH2F(
1307  Form("cl_SmT%01d_sm%03d_rpc%03d_Tot", iSmType, iSmId, iRpcId),
1308  Form(
1309  "Clu Tot of Rpc #%03d in Sm %03d of type %d; StripSide []; TOT [a.u.]",
1310  iRpcId,
1311  iSmId,
1312  iSmType),
1313  2 * fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1314  0,
1315  2 * fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1316  100,
1317  fdTOTMin,
1318  fdTOTMax);
1319 
1320  fhRpcCluSize[iDetIndx] = new TH2F(
1321  Form("cl_SmT%01d_sm%03d_rpc%03d_Size", iSmType, iSmId, iRpcId),
1322  Form(
1323  "Clu size of Rpc #%03d in Sm %03d of type %d; Strip []; size [strips]",
1324  iRpcId,
1325  iSmId,
1326  iSmType),
1327  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1328  0,
1329  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1330  16,
1331  0.5,
1332  16.5);
1333 
1334  // Walk histos
1335  fhRpcCluAvWalk[iDetIndx] = new TH2D(
1336  Form("cl_SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1337  Form("Walk in SmT%01d_sm%03d_rpc%03d_AvWalk", iSmType, iSmId, iRpcId),
1338  nbClWalkBinX,
1339  fdTOTMin,
1340  fdTOTMax,
1341  nbClWalkBinY,
1342  -TSumMax,
1343  TSumMax);
1344 
1345  fhRpcCluAvLnWalk[iDetIndx] = new TH2D(
1346  Form("cl_SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1347  Form("Walk in SmT%01d_sm%03d_rpc%03d_AvLnWalk", iSmType, iSmId, iRpcId),
1348  nbClWalkBinX,
1349  TMath::Log10(fdTOTMax / 50.),
1350  TMath::Log10(fdTOTMax),
1351  nbClWalkBinY,
1352  -TSumMax,
1353  TSumMax);
1354 
1355  fhRpcCluWalk[iDetIndx].resize(fDigiBdfPar->GetNbChan(iSmType, iRpcId));
1356  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpcId); iCh++) {
1357  fhRpcCluWalk[iDetIndx][iCh].resize(2);
1358  for (Int_t iSide = 0; iSide < 2; iSide++) {
1359  fhRpcCluWalk[iDetIndx][iCh][iSide] =
1360  new TH2D(Form("cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
1361  iSmType,
1362  iSmId,
1363  iRpcId,
1364  iCh,
1365  iSide),
1366  Form("Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Walk",
1367  iSmType,
1368  iSmId,
1369  iRpcId,
1370  iCh,
1371  iSide),
1372  nbClWalkBinX,
1373  fdTOTMin,
1374  fdTOTMax,
1375  nbClWalkBinY,
1376  -TSumMax,
1377  TSumMax);
1378  }
1379  /*
1380  (fhRpcCluWalk[iDetIndx]).push_back( hTemp );
1381  */
1382  }
1383  }
1384 
1385  // Clusterizing monitoring
1386 
1387  LOG(info) << " Define Clusterizer monitoring histos ";
1388 
1390  new TH2F(Form("hCluMulCorDutSel"),
1391  Form("Cluster Multiplicity Correlation of Dut %d%d%d with Sel "
1392  "%d%d%d; Mul(Sel); Mul(Dut)",
1393  fDutId,
1394  fDutSm,
1395  fDutRpc,
1396  fSelId,
1397  fSelSm,
1398  fSelRpc),
1399  32,
1400  0,
1401  32,
1402  32,
1403  0,
1404  32);
1405 
1407  new TH1I("Clus_DigSpacDifClust",
1408  "Space difference along channel direction between Digi pairs on "
1409  "adjacent channels; PosCh i - Pos Ch i+1 [cm]",
1410  5000,
1411  -10.0,
1412  10.0);
1414  new TH1I("Clus_DigTimeDifClust",
1415  "Time difference between Digi pairs on adjacent channels; "
1416  "0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1417  5000,
1418  -5.0,
1419  5.0);
1420  fhDigDistClust = new TH2I(
1421  "Clus_DigDistClust",
1422  "Distance between Digi pairs on adjacent channels; PosCh i - Pos Ch i+1 "
1423  "[cm along ch]; 0.5*(tDigiA + tDigiA)chi - 0.5*(tDigiA + tDigiA)chi+1 [ns]",
1424  5000,
1425  -10.0,
1426  10.0,
1427  2000,
1428  -5.0,
1429  5.0);
1430  fhClustSizeDifX =
1431  new TH2I("Clus_ClustSizeDifX",
1432  "Position difference between Point and Hit as function of Cluster "
1433  "Size; Cluster Size [Strips]; dX [cm]",
1434  100,
1435  0.5,
1436  100.5,
1437  500,
1438  -50,
1439  50);
1440  fhClustSizeDifY =
1441  new TH2I("Clus_ClustSizeDifY",
1442  "Position difference between Point and Hit as function of Cluster "
1443  "Size; Cluster Size [Strips]; dY [cm]",
1444  100,
1445  0.5,
1446  100.5,
1447  500,
1448  -50,
1449  50);
1450  fhChDifDifX = new TH2I("Clus_ChDifDifX",
1451  "Position difference between Point and Hit as "
1452  "function of Channel dif; Ch Dif [Strips]; dX [cm]",
1453  101,
1454  -50.5,
1455  50.5,
1456  500,
1457  -50,
1458  50);
1459  fhChDifDifY = new TH2I("Clus_ChDifDifY",
1460  "Position difference between Point and Hit as "
1461  "function of Channel Dif; Ch Dif [Strips]; dY [cm]",
1462  101,
1463  -50.5,
1464  50.5,
1465  500,
1466  -50,
1467  50);
1468  fhNbSameSide = new TH1I("Clus_NbSameSide",
1469  "How many time per event the 2 digis on a channel "
1470  "were of the same side ; Counts/Event []",
1471  500,
1472  0.0,
1473  500.0);
1474  fhNbDigiPerChan = new TH1I("Clus_NbDigiPerChan",
1475  "Nb of Digis per channel; Nb Digis []",
1476  100,
1477  0.0,
1478  100.0);
1479 
1480  // Trigger selected histograms
1481  if (0 < iNSel) {
1482 
1483  fhSeldT.resize(iNSel);
1484  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
1485  fhSeldT[iSel] = new TH2F(Form("cl_dt_Sel%02d", iSel),
1486  Form("Selector time %02d; dT [ns]", iSel),
1487  99,
1488  -50.,
1489  50.,
1490  16,
1491  -0.5,
1492  15.5);
1493  }
1494 
1495  fhTRpcCluMul.resize(iNbDet);
1496  fhTRpcCluPosition.resize(iNbDet);
1497  fhTRpcCluTOff.resize(iNbDet);
1498  fhTRpcCluTot.resize(iNbDet);
1499  fhTRpcCluSize.resize(iNbDet);
1500  fhTRpcCluAvWalk.resize(iNbDet);
1501  fhTRpcCluDelTof.resize(iNbDet);
1502  fhTRpcCludXdY.resize(iNbDet);
1503  fhTRpcCluWalk.resize(iNbDet);
1504  fhTRpcCluWalk2.resize(iNbDet);
1505  fhTRpcCluTOffDTLastHits.resize(iNbDet);
1506  fhTRpcCluTotDTLastHits.resize(iNbDet);
1507  fhTRpcCluSizeDTLastHits.resize(iNbDet);
1508  fhTRpcCluMemMulDTLastHits.resize(iNbDet);
1509 
1510  for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
1511  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
1512  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
1513  Int_t iSmId = CbmTofAddress::GetSmId(iUniqueId);
1514  Int_t iRpcId = CbmTofAddress::GetRpcId(iUniqueId);
1515  Int_t iUCellId =
1516  CbmTofAddress::GetUniqueAddress(iSmId, iRpcId, 0, 0, iSmType);
1517  fChannelInfo = fDigiPar->GetCell(iUCellId);
1518  if (NULL == fChannelInfo) {
1519  LOG(warning) << "No DigiPar for Det " << Form("0x%08x", iUCellId);
1520  continue;
1521  }
1522  LOG(debug1) << "DetIndx " << iDetIndx << ", SmType " << iSmType
1523  << ", SmId " << iSmId << ", RpcId " << iRpcId
1524  << " => UniqueId "
1525  << Form("(0x%08x, 0x%08x)", iUniqueId, iUCellId) << ", dx "
1526  << fChannelInfo->GetSizex() << ", dy "
1527  << fChannelInfo->GetSizey()
1528  << Form(" poi: 0x%p ", fChannelInfo) << ", nbCh "
1529  << fDigiBdfPar->GetNbChan(iSmType, iRpcId);
1530 
1531  fhTRpcCluMul[iDetIndx].resize(iNSel);
1532  fhTRpcCluPosition[iDetIndx].resize(iNSel);
1533  fhTRpcCluTOff[iDetIndx].resize(iNSel);
1534  fhTRpcCluTot[iDetIndx].resize(iNSel);
1535  fhTRpcCluSize[iDetIndx].resize(iNSel);
1536  fhTRpcCluAvWalk[iDetIndx].resize(iNSel);
1537  fhTRpcCluDelTof[iDetIndx].resize(iNSel);
1538  fhTRpcCludXdY[iDetIndx].resize(iNSel);
1539  fhTRpcCluWalk[iDetIndx].resize(iNSel);
1540  fhTRpcCluWalk2[iDetIndx].resize(iNSel);
1541  fhTRpcCluTOffDTLastHits[iDetIndx].resize(iNSel);
1542  fhTRpcCluTotDTLastHits[iDetIndx].resize(iNSel);
1543  fhTRpcCluSizeDTLastHits[iDetIndx].resize(iNSel);
1544  fhTRpcCluMemMulDTLastHits[iDetIndx].resize(iNSel);
1545 
1546  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
1547  fhTRpcCluMul[iDetIndx][iSel] =
1548  new TH1F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Mul",
1549  iSmType,
1550  iSmId,
1551  iRpcId,
1552  iSel),
1553  Form("Clu multiplicity of Rpc #%03d in Sm %03d of type %d "
1554  "under Selector %02d; M []; cnts",
1555  iRpcId,
1556  iSmId,
1557  iSmType,
1558  iSel),
1559  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1560  0.,
1561  fDigiBdfPar->GetNbChan(iSmType, iRpcId));
1562 
1563  if (NULL == fhTRpcCluMul[iDetIndx][iSel])
1564  LOG(fatal) << " Histo not generated !";
1565 
1566  Double_t YSCAL = 50.;
1567  if (fPosYMaxScal != 0.) YSCAL = fPosYMaxScal;
1568  Double_t YDMAX = TMath::Max(2., fChannelInfo->GetSizey()) * YSCAL;
1569  fhTRpcCluPosition[iDetIndx][iSel] =
1570  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Pos",
1571  iSmType,
1572  iSmId,
1573  iRpcId,
1574  iSel),
1575  Form("Clu position of Rpc #%03d in Sm %03d of type %d under "
1576  "Selector %02d; Strip []; ypos [cm]",
1577  iRpcId,
1578  iSmId,
1579  iSmType,
1580  iSel),
1581  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1582  0,
1583  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1584  100,
1585  -YDMAX,
1586  YDMAX);
1587 
1588  Double_t TSumMax = 1.E4;
1589  if (fTRefDifMax != 0.) TSumMax = fTRefDifMax;
1590  fhTRpcCluTOff[iDetIndx][iSel] =
1591  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff",
1592  iSmType,
1593  iSmId,
1594  iRpcId,
1595  iSel),
1596  Form("Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1597  "Selector %02d; Strip []; TOff [ns]",
1598  iRpcId,
1599  iSmId,
1600  iSmType,
1601  iSel),
1602  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1603  0,
1604  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1605  999,
1606  -TSumMax,
1607  TSumMax);
1608 
1609  if (fTotMax != 0.) fdTOTMax = fTotMax;
1610  fhTRpcCluTot[iDetIndx][iSel] =
1611  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot",
1612  iSmType,
1613  iSmId,
1614  iRpcId,
1615  iSel),
1616  Form("Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1617  "Selector %02d; StripSide []; TOT [a.u.]",
1618  iRpcId,
1619  iSmId,
1620  iSmType,
1621  iSel),
1622  fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2,
1623  0,
1624  fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2,
1625  100,
1626  fdTOTMin,
1627  fdTOTMax);
1628 
1629  fhTRpcCluSize[iDetIndx][iSel] =
1630  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size",
1631  iSmType,
1632  iSmId,
1633  iRpcId,
1634  iSel),
1635  Form("Clu size of Rpc #%03d in Sm %03d of type %d under "
1636  "Selector %02d; Strip []; size [strips]",
1637  iRpcId,
1638  iSmId,
1639  iSmType,
1640  iSel),
1641  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1642  0,
1643  fDigiBdfPar->GetNbChan(iSmType, iRpcId),
1644  16,
1645  0.5,
1646  16.5);
1647 
1648  // Walk histos
1649  fhTRpcCluAvWalk[iDetIndx][iSel] = new TH2D(
1650  Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk",
1651  iSmType,
1652  iSmId,
1653  iRpcId,
1654  iSel),
1655  Form("Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_AvWalk; TOT; T-TSel",
1656  iSmType,
1657  iSmId,
1658  iRpcId,
1659  iSel),
1660  nbClWalkBinX,
1661  fdTOTMin,
1662  fdTOTMax,
1663  nbClWalkBinY,
1664  -TSumMax,
1665  TSumMax);
1666 
1667  // Tof Histos
1668  fhTRpcCluDelTof[iDetIndx][iSel] = new TH2F(
1669  Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
1670  iSmType,
1671  iSmId,
1672  iRpcId,
1673  iSel),
1674  Form("SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; DistSel; T-TSel",
1675  iSmType,
1676  iSmId,
1677  iRpcId,
1678  iSel),
1679  //Form("SmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof; TRef-TSel; T-TSel", iSmType, iSmId, iRpcId, iSel),
1680  //nbClDelTofBinX,-fdDelTofMax,fdDelTofMax,nbClDelTofBinY,-TSumMax,TSumMax);
1682  0.,
1683  fdDelTofMax,
1685  -TSumMax,
1686  TSumMax); // x-axis is distance of hits
1687 
1688  // Position deviation histos
1689  fhTRpcCludXdY[iDetIndx][iSel] =
1690  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY",
1691  iSmType,
1692  iSmId,
1693  iRpcId,
1694  iSel),
1695  Form("SmT%01d_sm%03d_rpc%03d_Sel%02d_dXdY; #Delta x [cm]; "
1696  "#Delta y [cm];",
1697  iSmType,
1698  iSmId,
1699  iRpcId,
1700  iSel),
1701  nbCldXdYBinX,
1702  -dXdYMax,
1703  dXdYMax,
1704  nbCldXdYBinY,
1705  -dXdYMax,
1706  dXdYMax);
1707 
1708  fhTRpcCluWalk2[iDetIndx][iSel] =
1709  new TH3F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2",
1710  iSmType,
1711  iSmId,
1712  iRpcId,
1713  iSel),
1714  Form("Walk in SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2",
1715  iSmType,
1716  iSmId,
1717  iRpcId,
1718  iSel),
1719  nbClWalkBinX,
1720  fdTOTMin,
1721  fdTOTMax,
1722  nbClWalkBinX,
1723  fdTOTMin,
1724  fdTOTMax,
1725  nbClWalkBinY,
1726  -TSumMax,
1727  TSumMax);
1728 
1729  fhTRpcCluWalk[iDetIndx][iSel].resize(
1730  fDigiBdfPar->GetNbChan(iSmType, iRpcId));
1731 
1732  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpcId);
1733  iCh++) {
1734 
1735  fhTRpcCluWalk[iDetIndx][iSel][iCh].resize(2);
1736  for (Int_t iSide = 0; iSide < 2; iSide++) {
1737  fhTRpcCluWalk[iDetIndx][iSel][iCh][iSide] = new TH2D(
1738  Form("cl_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk",
1739  iSmType,
1740  iSmId,
1741  iRpcId,
1742  iCh,
1743  iSide,
1744  iSel),
1745  Form("Walk in SmT%01d_sm%03d_rpc%03d_Ch%03d_S%01d_Sel%02d_Walk",
1746  iSmType,
1747  iSmId,
1748  iRpcId,
1749  iCh,
1750  iSide,
1751  iSel),
1752  nbClWalkBinX,
1753  fdTOTMin,
1754  fdTOTMax,
1755  nbClWalkBinY,
1756  -TSumMax,
1757  TSumMax);
1758  }
1759  }
1760 
1761  fhTRpcCluTOffDTLastHits[iDetIndx][iSel] =
1762  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_TOff_DTLH",
1763  iSmType,
1764  iSmId,
1765  iRpcId,
1766  iSel),
1767  Form("Clu TimeZero of Rpc #%03d in Sm %03d of type %d under "
1768  "Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1769  iRpcId,
1770  iSmId,
1771  iSmType,
1772  iSel),
1773  100,
1774  0.,
1775  10.,
1776  99,
1777  -TSumMax,
1778  TSumMax);
1779 
1780  fhTRpcCluTotDTLastHits[iDetIndx][iSel] =
1781  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Tot_DTLH",
1782  iSmType,
1783  iSmId,
1784  iRpcId,
1785  iSel),
1786  Form("Clu Tot of Rpc #%03d in Sm %03d of type %d under "
1787  "Selector %02d; log(#DeltaT (ns)); TOT [a.u.]",
1788  iRpcId,
1789  iSmId,
1790  iSmType,
1791  iSel),
1792  100,
1793  0.,
1794  10.,
1795  100,
1796  fdTOTMin,
1797  fdTOTMax);
1798 
1799  fhTRpcCluSizeDTLastHits[iDetIndx][iSel] =
1800  new TH2F(Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Size_DTLH",
1801  iSmType,
1802  iSmId,
1803  iRpcId,
1804  iSel),
1805  Form("Clu size of Rpc #%03d in Sm %03d of type %d under "
1806  "Selector %02d; log(#DeltaT (ns)); size [strips]",
1807  iRpcId,
1808  iSmId,
1809  iSmType,
1810  iSel),
1811  100,
1812  0.,
1813  10.,
1814  10,
1815  0.5,
1816  10.5);
1817 
1818  fhTRpcCluMemMulDTLastHits[iDetIndx][iSel] = new TH2F(
1819  Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_MemMul_DTLH",
1820  iSmType,
1821  iSmId,
1822  iRpcId,
1823  iSel),
1824  Form("Clu Memorized Multiplicity of Rpc #%03d in Sm %03d of type %d "
1825  "under Selector %02d; log(#DeltaT (ns)); TOff [ns]",
1826  iRpcId,
1827  iSmId,
1828  iSmType,
1829  iSel),
1830  100,
1831  0.,
1832  10.,
1833  10,
1834  0,
1835  10);
1836  }
1837  }
1838  }
1839  // MC reference
1840  fhHitsPerTracks =
1841  new TH1I("Clus_TofHitPerTrk",
1842  "Mean Number of TofHit per Mc Track; Nb TofHits/Nb MC Tracks []",
1843  2000,
1844  0.0,
1845  20.0);
1846  if (kFALSE == fDigiBdfPar->ClustUseTrackId())
1847  fhPtsPerHit = new TH1I("Clus_TofPtsPerHit",
1848  "Distribution of the Number of MCPoints associated "
1849  "to each TofHit; Nb MCPoint []",
1850  20,
1851  0.0,
1852  20.0);
1853  if (kTRUE == fDigiBdfPar->ClustUseTrackId()) {
1855  new TH1I("Clus_TofTimeResClust",
1856  "Time resolution for TofHits containing Digis from a single MC "
1857  "Track; t(1st Mc Point) -tTofHit [ns]",
1858  10000,
1859  -25.0,
1860  25.0);
1862  new TH2I("Clus_TofTimeResClustB",
1863  "Time resolution for TofHits containing Digis from a single MC "
1864  "Track; (1st Mc Point) -tTofHit [ns]",
1865  5000,
1866  -25.0,
1867  25.0,
1868  6,
1869  0,
1870  6);
1871  fhTimePtVsHits =
1872  new TH2I("Clus_TofTimePtVsHit",
1873  "Time resolution for TofHits containing Digis from a single MC "
1874  "Track; t(1st Mc Point) -tTofHit [ns]",
1875  2000,
1876  0.0,
1877  50.0,
1878  2000,
1879  0.0,
1880  50.0);
1881  } else {
1883  new TH1I("Clus_TofTimeResClust",
1884  "Time resolution for TofHits containing Digis from a single "
1885  "TofPoint; tMcPoint -tTofHit [ns]",
1886  10000,
1887  -25.0,
1888  25.0);
1890  new TH2I("Clus_TofTimeResClustB",
1891  "Time resolution for TofHits containing Digis from a single "
1892  "TofPoint; tMcPoint -tTofHit [ns]",
1893  5000,
1894  -25.0,
1895  25.0,
1896  6,
1897  0,
1898  6);
1899  fhTimePtVsHits = new TH2I("Clus_TofTimePtVsHit",
1900  "Time resolution for TofHits containing Digis "
1901  "from a single TofPoint; tMcPoint -tTofHit [ps]",
1902  2000,
1903  0.0,
1904  50.0,
1905  2000,
1906  0.0,
1907  50.0);
1908  } // else of if( kTRUE == fDigiBdfPar->ClustUseTrackId() )
1909  fhClusterSize = new TH1I("Clus_ClusterSize",
1910  "Cluster Size distribution; Cluster Size [Strips]",
1911  100,
1912  0.5,
1913  100.5);
1915  new TH2I("Clus_ClusterSizeType",
1916  "Cluster Size distribution in each (SM type, Rpc) pair; Cluster "
1917  "Size [Strips]; 10*SM Type + Rpc Index []",
1918  100,
1919  0.5,
1920  100.5,
1921  40 * fDigiBdfPar->GetNbSmTypes(),
1922  0.0,
1923  40 * fDigiBdfPar->GetNbSmTypes());
1924  if (kTRUE == fDigiBdfPar->ClustUseTrackId()) {
1925  fhTrackMul = new TH1I(
1926  "Clus_TrackMul",
1927  "Number of MC tracks generating the cluster; MC Tracks multiplicity []",
1928  100,
1929  0.5,
1930  100.5);
1931  fhClusterSizeMulti = new TH2I(
1932  "Clus_ClusterSizeMulti",
1933  "Cluster Size distribution as function of Number of MC tracks generating "
1934  "the cluster; Cluster Size [Strips]; MC tracks mul. []",
1935  100,
1936  0.5,
1937  100.5,
1938  100,
1939  0.5,
1940  100.5);
1941  fhTrk1MulPos = new TH2D("Clus_Trk1MulPos",
1942  "Position of Clusters with only 1 MC tracks "
1943  "generating the cluster; X [cm]; Y [cm]",
1944  1500,
1945  -750,
1946  750,
1947  1000,
1948  -500,
1949  500);
1950  fhHiTrkMulPos = new TH2D("Clus_HiTrkMulPos",
1951  "Position of Clusters with >1 MC tracks "
1952  "generating the cluster; X [cm]; Y [cm]",
1953  1500,
1954  -750,
1955  750,
1956  1000,
1957  -500,
1958  500);
1959  fhAllTrkMulPos = new TH2D(
1960  "Clus_AllTrkMulPos",
1961  "Position of all clusters generating the cluster; X [cm]; Y [cm]",
1962  1500,
1963  -750,
1964  750,
1965  1000,
1966  -500,
1967  500);
1969  new TH2D("Clus_MultiTrkProbPos",
1970  "Probability of having a cluster with multiple tracks as "
1971  "function of position; X [cm]; Y [cm]; Prob. [%]",
1972  1500,
1973  -750,
1974  750,
1975  1000,
1976  -500,
1977  500);
1978  } // if( kTRUE == fDigiBdfPar->ClustUseTrackId() )
1979 
1980  gDirectory->cd(
1981  oldir
1982  ->GetPath()); // <= To prevent histos from being sucked in by the param file of the TRootManager!
1983 
1984  return kTRUE;
1985 }
1986 
1988  fhClustBuildTime->Fill(fStop.GetSec() - fStart.GetSec()
1989  + (fStop.GetNanoSec() - fStart.GetNanoSec()) / 1e9);
1990  Int_t iNbTofHits = fTofHitsColl->GetEntries();
1991  CbmTofHit* pHit;
1992  //gGeoManager->SetTopVolume( gGeoManager->FindVolumeFast("tof_v14a") );
1993  gGeoManager->CdTop();
1994 
1995  if (0 < iNbTofHits) {
1996  /* Double_t dCluMul=0.;*/
1997  Bool_t BSel[iNSel];
1998  Double_t dTTrig[iNSel];
1999  CbmTofHit* pTrig[iNSel];
2000  CbmTofHit* pRef;
2001  Double_t ddXdZ[iNSel];
2002  Double_t ddYdZ[iNSel];
2003  Double_t dSel2dXdYMin[iNSel];
2004 
2005  Int_t iSel2Mul = 0;
2006 
2007  if (0 < iNSel) { // check software triggers
2008 
2009  LOG(debug) << "CbmTofCosmicClusterizer::FillHistos: Muls: "
2010  << fviClusterMul[fDutId][fDutSm][fDutRpc] << ", "
2012  // monitor multiplicities
2013  Int_t iNbDet = fDigiBdfPar->GetNbDet();
2014  for (Int_t iDetIndx = 0; iDetIndx < iNbDet; iDetIndx++) {
2015  Int_t iDetId = fviDetId[iDetIndx];
2016  Int_t iSmType = CbmTofAddress::GetSmType(iDetId);
2017  Int_t iSm = CbmTofAddress::GetSmId(iDetId);
2018  Int_t iRpc = CbmTofAddress::GetRpcId(iDetId);
2019  //LOG(info) << Form(" indx %d, Id 0x%08x, TSR %d %d %d", iDetIndx, iDetId, iSmType, iSm, iRpc)
2020  // ;
2021  if (NULL != fhRpcCluMul[iDetIndx])
2022  fhRpcCluMul[iDetIndx]->Fill(fviClusterMul[iSmType][iSm][iRpc]); //
2023  }
2024 
2027 
2028  // do input distributions first
2029  for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2030  pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
2031  if (NULL == pHit) continue;
2032  if (StartAnalysisTime == 0.) {
2033  StartAnalysisTime = pHit->GetTime();
2034  LOG(info) << "StartAnalysisTime set to " << StartAnalysisTime
2035  << " ns. ";
2036  }
2037  Int_t iDetId = (pHit->GetAddress() & DetMask);
2038 
2039  std::map<UInt_t, UInt_t>::iterator it = fDetIdIndexMap.find(iDetId);
2040  if (it == fDetIdIndexMap.end())
2041  continue; // continue for invalid detector index
2042  Int_t iDetIndx = it->second; //fDetIdIndexMap[iDetId];
2043 
2044  Int_t iSmType = CbmTofAddress::GetSmType(iDetId);
2045  Int_t iSm = CbmTofAddress::GetSmId(iDetId);
2046  Int_t iRpc = CbmTofAddress::GetRpcId(iDetId);
2047  Int_t iCh = CbmTofAddress::GetChannelId(pHit->GetAddress());
2048 
2049  Double_t dTimeAna = (pHit->GetTime() - StartAnalysisTime) / 1.E9;
2050  LOG(debug) << "TimeAna " << StartAnalysisTime << ", "
2051  << Form(" Addr 0x%08x, t %f, tspill %f ",
2052  pHit->GetAddress(),
2053  pHit->GetTime(),
2054  dTimeAna);
2055  fhRpcCluRate[iDetIndx]->Fill(dTimeAna);
2056 
2057  if (fdMemoryTime > 0.
2058  && fvLastHits[iSmType][iSm][iRpc][iCh].size() == 0)
2059  LOG(fatal) << Form(" <E> hit not stored in memory for TSRC %d%d%d%d",
2060  iSmType,
2061  iSm,
2062  iRpc,
2063  iCh);
2064 
2065  //CheckLHMemory();
2066 
2067  if (fvLastHits[iSmType][iSm][iRpc][iCh].size()
2068  > 1) { // check for outdated hits
2069  //std::list<CbmTofHit *>::iterator it0=fvLastHits[iSmType][iSm][iRpc][iCh].begin();
2070  //std::list<CbmTofHit *>::iterator itL=fvLastHits[iSmType][iSm][iRpc][iCh].end();
2071  //CbmTofHit* pH0 = *it0;
2072  //CbmTofHit* pHL = *(--itL);
2073  CbmTofHit* pH0 = fvLastHits[iSmType][iSm][iRpc][iCh].front();
2074  CbmTofHit* pHL = fvLastHits[iSmType][iSm][iRpc][iCh].back();
2075  if (pH0->GetTime() > pHL->GetTime())
2076  LOG(warning) << Form("Invalid time ordering in ev %8.0f in list of "
2077  "size %lu for TSRC %d%d%d%d: Delta t %f ",
2078  fdEvent,
2079  fvLastHits[iSmType][iSm][iRpc][iCh].size(),
2080  iSmType,
2081  iSm,
2082  iRpc,
2083  iCh,
2084  pHL->GetTime() - pH0->GetTime());
2085 
2086  // while( (*((std::list<CbmTofHit *>::iterator) fvLastHits[iSmType][iSm][iRpc][iCh].begin()))->GetTime()+fdMemoryTime < pHit->GetTime()
2087  while (fvLastHits[iSmType][iSm][iRpc][iCh].size() > 2.
2088  || fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime()
2089  + fdMemoryTime
2090  < pHit->GetTime())
2091 
2092  {
2093  LOG(debug)
2094  << " pop from list size "
2095  << fvLastHits[iSmType][iSm][iRpc][iCh].size()
2096  << Form(" outdated hits for ev %8.0f in TSRC %d%d%d%d",
2097  fdEvent,
2098  iSmType,
2099  iSm,
2100  iRpc,
2101  iCh)
2102  << Form(
2103  " with tHit - tLast %f ",
2104  pHit->GetTime()
2105  - fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime())
2106  //(*((std::list<CbmTofHit *>::iterator) fvLastHits[iSmType][iSm][iRpc][iCh].begin()))->GetTime())
2107  ;
2108  if (fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress()
2109  != pHit->GetAddress())
2110  LOG(fatal) << Form(
2111  "Inconsistent address in list of size %lu for TSRC %d%d%d%d: "
2112  "0x%08x, time %f",
2113  fvLastHits[iSmType][iSm][iRpc][iCh].size(),
2114  iSmType,
2115  iSm,
2116  iRpc,
2117  iCh,
2118  fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
2119  fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
2120  fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
2121  fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
2122  }
2123  } //fvLastHits[iSmType][iSm][iRpc][iCh].size()>1)
2124 
2125  // plot remaining time difference to previous hits
2126  if (fvLastHits[iSmType][iSm][iRpc][iCh].size()
2127  > 1) { // check for previous hits in memory time interval
2128  CbmMatch* digiMatch = (CbmMatch*) fTofDigiMatchColl->At(iHitInd);
2129  Double_t dTotSum = 0.;
2130  for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks();
2131  iLink += 2) { // loop over digis
2132  CbmLink L0 = digiMatch->GetLink(iLink);
2133  Int_t iDigInd0 = L0.GetIndex();
2134  Int_t iDigInd1 = (digiMatch->GetLink(iLink + 1)).GetIndex();
2135  CbmTofDigi* pDig0 = (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd0));
2136  CbmTofDigi* pDig1 = (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd1));
2137  dTotSum += pDig0->GetTot() + pDig1->GetTot();
2138  }
2139 
2140  std::list<CbmTofHit*>::iterator itL =
2141  fvLastHits[iSmType][iSm][iRpc][iCh].end();
2142  itL--;
2143  for (size_t iH = 0;
2144  iH < fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2145  iH++) {
2146  itL--;
2147  fhRpcDTLastHits[iDetIndx]->Fill(
2148  TMath::Log10(pHit->GetTime() - (*itL)->GetTime()));
2149  fhRpcDTLastHits_CluSize[iDetIndx]->Fill(
2150  TMath::Log10(pHit->GetTime() - (*itL)->GetTime()),
2151  digiMatch->GetNofLinks() / 2.);
2152  fhRpcDTLastHits_Tot[iDetIndx]->Fill(
2153  TMath::Log10(pHit->GetTime() - (*itL)->GetTime()), dTotSum);
2154  }
2155  }
2156  } // iHitInd loop end
2157 
2158  // do reference first
2159  dTRef = dDoubleMax;
2160  fTRefHits = 0;
2161  pRef = NULL;
2162 
2163  Double_t dMatXYScal =
2164  fhRpcCluPosition[iIndexDut]->GetYaxis()->GetXmax() / 30.;
2165 
2166  for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2167  pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
2168  if (NULL == pHit) continue;
2169  Int_t iModId =
2170  (pHit->GetAddress() & ModMask); // select Sel2 module hits
2171 
2172  if (fSel2Addr == iModId) {
2173  // Check Tot
2174  CbmMatch* digiMatch = (CbmMatch*) fTofDigiMatchColl->At(iHitInd);
2175  Double_t TotSum = 0.;
2176  for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks();
2177  iLink += 2) { // loop over digis
2178  CbmLink L0 = digiMatch->GetLink(iLink); //vDigish.at(ivDigInd);
2179  Int_t iDigInd0 = L0.GetIndex();
2180  if (iDigInd0 < fTofCalDigisColl->GetEntries()) {
2181  CbmTofDigi* pDig0 =
2182  (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd0));
2183  TotSum += pDig0->GetTot();
2184  }
2185  }
2186  TotSum /= (0.5 * digiMatch->GetNofLinks());
2187  if (TotSum > fhRpcCluTot[iIndexDut]->GetYaxis()->GetXmax())
2188  continue; // ignore too large clusters
2189 
2190  fTRefHits = 1;
2191  if (pHit->GetTime() < dTRef) {
2192  dTRef = pHit->GetTime();
2193  pRef = pHit;
2194  }
2195  iSel2Mul++;
2196  }
2197  }
2198  LOG(debug) << "CbmTofCosmicClusterizer::FillHistos: Sel2Mul: "
2199  << iSel2Mul;
2200 
2201  if (iSel2Mul > fSel2MulMax)
2202  return kFALSE; // don't fill histos with ambigious reference
2203  if (iSel2Mul == 0)
2204  return kFALSE; // don't fill histos without reference time
2205 
2206  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
2207  BSel[iSel] = kFALSE;
2208  pTrig[iSel] = NULL;
2209  Int_t iDutMul = 0;
2210  Int_t iRefMul = 0;
2211  Int_t iR0 = 0;
2212  Int_t iRl = 0;
2213  ddXdZ[iSel] = 0.;
2214  ddYdZ[iSel] = 0.;
2215  dSel2dXdYMin[iSel] = 1.E300;
2216 
2217  switch (iSel) {
2218  case 0: // Detector under Test (Dut) && Sel2
2219  iRl = fviClusterMul[fDutId][fDutSm].size();
2220  if (fDutRpc > -1) { iR0 = fDutRpc; }
2221  for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2222  iDutMul += fviClusterMul[fDutId][fDutSm][iRpc];
2223  LOG(debug) << "selector 0: DutMul "
2224  << fviClusterMul[fDutId][fDutSm][fDutRpc] << ", "
2225  << iDutMul << ", Sel2Mul " << iSel2Mul
2226  << " TRef: " << dTRef;
2227  if (iDutMul > 0 && iDutMul < fiCluMulMax) {
2228  dTTrig[iSel] = dDoubleMax;
2229  for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2230  pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
2231  if (NULL == pHit) continue;
2232  Int_t iModId = (pHit->GetAddress() & ModMask);
2233  if (fDutAddr == iModId) {
2234  if (pHit->GetTime() < dTTrig[iSel]) {
2235  dTTrig[iSel] = pHit->GetTime();
2236  pTrig[iSel] = pHit;
2237  BSel[iSel] = kTRUE;
2238  }
2239  }
2240  }
2241  LOG(debug) << Form(
2242  "Found selector 0 with mul %d from 0x%08x at %f ",
2243  iDutMul,
2244  pTrig[iSel]->GetAddress(),
2245  dTTrig[iSel]);
2246  }
2247  break;
2248 
2249  case 1: // MRef & Sel2
2250  iRl = fviClusterMul[fSelId][fSelSm].size();
2251  if (fSelRpc > -1) { iR0 = fSelRpc; }
2252  for (Int_t iRpc = iR0; iRpc < iRl; iRpc++)
2253  iRefMul += fviClusterMul[fSelId][fSelSm][iRpc];
2254  LOG(debug) << "selector 1: RefMul "
2255  << fviClusterMul[fSelId][fSelSm][fSelRpc] << ", "
2256  << iRefMul << ", Sel2Mul " << iSel2Mul;
2257  if (iRefMul > 0 && iRefMul < fiCluMulMax) {
2258  LOG(debug1) << "Found selector 1";
2259  dTTrig[iSel] = dDoubleMax;
2260  for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2261  pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
2262  if (NULL == pHit) continue;
2263  Int_t iModId = (pHit->GetAddress() & ModMask);
2264  if (fSelAddr == iModId) {
2265  if (pHit->GetTime() < dTTrig[iSel]) {
2266  dTTrig[iSel] = pHit->GetTime();
2267  pTrig[iSel] = pHit;
2268  BSel[iSel] = kTRUE;
2269  }
2270  }
2271  }
2272  LOG(debug) << Form(
2273  "Found selector 1 with mul %d from 0x%08x at %f ",
2274  iRefMul,
2275  pTrig[iSel]->GetAddress(),
2276  dTTrig[iSel]);
2277  }
2278  break;
2279 
2280  default:
2281  LOG(info) << "CbmTofCosmicClusterizer::FillHistos: selection not "
2282  "implemented "
2283  << iSel;
2284  ;
2285  } // switch end
2286  if (fTRefMode > 10) {
2287  if (pRef == NULL) return kFALSE;
2288  dTTrig[iSel] = dTRef;
2289  pTrig[iSel] = pRef;
2290  }
2291  } // iSel - loop end
2292 
2293  if (fSel2Id > 0) { // confirm selector by independent match
2294  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
2295  if (BSel[iSel]) {
2296  BSel[iSel] = kFALSE;
2297  //if(fviClusterMul[fSel2Id][fSel2Sm][fSel2Rpc] > 0 && fviClusterMul[fSel2Id][fSel2Sm][fSel2Rpc] < fiCluMulMax)
2298  for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2299  pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
2300  if (NULL == pHit) continue;
2301  Int_t iModId = (pHit->GetAddress() & ModMask);
2302  if (fSel2Addr == iModId) {
2303  Double_t dzscal = 1.;
2305  dzscal = pHit->GetZ() / pTrig[iSel]->GetZ();
2306  Double_t dSEl2dXdz = (pHit->GetX() - pTrig[iSel]->GetX())
2307  / (pHit->GetZ() - pTrig[iSel]->GetZ());
2308  Double_t dSEl2dYdz = (pHit->GetY() - pTrig[iSel]->GetY())
2309  / (pHit->GetZ() - pTrig[iSel]->GetZ());
2310 
2311  if (TMath::Sqrt(
2312  TMath::Power(pHit->GetX() - dzscal * pTrig[iSel]->GetX(),
2313  2.)
2314  + TMath::Power(
2315  pHit->GetY() - dzscal * pTrig[iSel]->GetY(), 2.))
2316  < fdCaldXdYMax * dMatXYScal) {
2317  BSel[iSel] = kTRUE;
2318  Double_t dX2Y2 =
2319  TMath::Sqrt(dSEl2dXdz * dSEl2dXdz + dSEl2dYdz * dSEl2dYdz);
2320  if (dX2Y2 < dSel2dXdYMin[iSel]) {
2321  ddXdZ[iSel] = dSEl2dXdz;
2322  ddYdZ[iSel] = dSEl2dYdz;
2323  dSel2dXdYMin[iSel] = dX2Y2;
2324  }
2325  break;
2326  }
2327  }
2328  }
2329  } // BSel condition end
2330  } // iSel lopp end
2331  } // Sel2Id condition end
2332 
2333  UInt_t uTriggerPattern = 0;
2334  if (NULL != fTrbHeader)
2335  uTriggerPattern = fTrbHeader->GetTriggerPattern();
2336  else {
2337  for (Int_t iSel = 0; iSel < iNSel; iSel++)
2338  if (BSel[iSel]) {
2339  uTriggerPattern |=
2340  (0x1 << (iSel * 3
2341  + CbmTofAddress::GetRpcId(pTrig[iSel]->GetAddress()
2342  & DetMask)));
2343  }
2344  }
2345  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
2346  if (BSel[iSel]) {
2347  if (dTRef != 0. && fTRefHits > 0) {
2348  for (UInt_t uChannel = 0; uChannel < 16; uChannel++) {
2349  if (uTriggerPattern & (0x1 << uChannel)) {
2350  fhSeldT[iSel]->Fill(dTTrig[iSel] - dTRef, uChannel);
2351  }
2352  }
2353  }
2354  }
2355  }
2356  } // 0<iNSel software trigger check end
2357 
2358  for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
2359  pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
2360  if (NULL == pHit) continue;
2361 
2362  Int_t iDetId = (pHit->GetAddress() & DetMask);
2363  std::map<UInt_t, UInt_t>::iterator it = fDetIdIndexMap.find(iDetId);
2364  if (it == fDetIdIndexMap.end())
2365  continue; // continue for invalid detector index
2366  Int_t iDetIndx = it->second; //fDetIdIndexMap[iDetId];
2367 
2368  Int_t iSmType = CbmTofAddress::GetSmType(iDetId);
2369  Int_t iSm = CbmTofAddress::GetSmId(iDetId);
2370  Int_t iRpc = CbmTofAddress::GetRpcId(iDetId);
2371  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
2372 
2373  if (fviClusterMul[iSmType][iSm][iRpc] > fiCluMulMax)
2374  continue; // skip this rpc
2375 
2376  if (-1 < fviClusterMul[iSmType][iSm][iRpc]) {
2377  for (Int_t iSel = 0; iSel < iNSel; iSel++)
2378  if (BSel[iSel]) {
2379  Double_t w = fviClusterMul[iSmType][iSm][iRpc];
2380  if (w == 0.)
2381  w = 1.;
2382  else
2383  w = 1. / w;
2384  fhTRpcCluMul[iDetIndx][iSel]->Fill(
2385  fviClusterMul[iSmType][iSm][iRpc], w);
2386  }
2387  }
2388 
2389  Int_t iChId = pHit->GetAddress();
2390  fChannelInfo = fDigiPar->GetCell(iChId);
2391  Int_t iCh = CbmTofAddress::GetChannelId(iChId);
2392  if (NULL == fChannelInfo) {
2393  LOG(error) << "Invalid Channel Pointer for ChId "
2394  << Form(" 0x%08x ", iChId) << ", Ch " << iCh;
2395  continue;
2396  }
2397  /*TGeoNode *fNode=*/ // prepare global->local trafo
2398  gGeoManager->FindNode(
2400 
2401  LOG(debug1) << "Hit info: "
2402  << Form(" 0x%08x %d %f %f %f %f %f %d",
2403  iChId,
2404  iCh,
2405  pHit->GetX(),
2406  pHit->GetY(),
2407  pHit->GetTime(),
2408  fChannelInfo->GetX(),
2409  fChannelInfo->GetY(),
2410  iHitInd);
2411 
2412  Double_t hitpos[3];
2413  hitpos[0] = pHit->GetX();
2414  hitpos[1] = pHit->GetY();
2415  hitpos[2] = pHit->GetZ();
2416  Double_t hitpos_local[3];
2417  TGeoNode* cNode = gGeoManager->GetCurrentNode();
2418  gGeoManager->MasterToLocal(hitpos, hitpos_local);
2419  LOG(debug1) << Form(
2420  " MasterToLocal for node %p: (%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
2421  cNode,
2422  hitpos[0],
2423  hitpos[1],
2424  hitpos[2],
2425  hitpos_local[0],
2426  hitpos_local[1],
2427  hitpos_local[2]);
2428 
2429  fhRpcCluPosition[iDetIndx]->Fill(
2430  (Double_t) iCh, hitpos_local[1]); //pHit->GetY()-fChannelInfo->GetY());
2431  fhSmCluPosition[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc),
2432  hitpos_local[1]);
2433 
2434  Double_t dTimeAna = (pHit->GetTime() - StartAnalysisTime) / 1.E9;
2435  if (pHit != pRef)
2436  fhRpcCluTimeEvol[iDetIndx]->Fill(dTimeAna, pHit->GetTime() - dTRef);
2437  fhRpcCluPositionEvol[iDetIndx]->Fill(dTimeAna, hitpos_local[1]);
2438 
2439  for (Int_t iSel = 0; iSel < iNSel; iSel++)
2440  if (BSel[iSel]) {
2441  fhTRpcCluPosition[iDetIndx][iSel]->Fill(
2442  (Double_t) iCh,
2443  hitpos_local[1]); //pHit->GetY()-fChannelInfo->GetY());
2444  fhTSmCluPosition[iSmType][iSel]->Fill((Double_t)(iSm * iNbRpc + iRpc),
2445  hitpos_local[1]);
2446  }
2447 
2448  if (TMath::Abs(hitpos_local[1]) > fChannelInfo->GetSizey() * fPosYMaxScal)
2449  continue;
2450  LOG(debug1) << " TofDigiMatchColl entries:"
2451  << fTofDigiMatchColl->GetEntries();
2452 
2453  if (iHitInd > fTofDigiMatchColl->GetEntries()) {
2454  LOG(error) << " Inconsistent DigiMatches for Hitind " << iHitInd
2455  << ", TClonesArraySize: " << fTofDigiMatchColl->GetEntries();
2456  }
2457 
2458  CbmMatch* digiMatch = (CbmMatch*) fTofDigiMatchColl->At(iHitInd);
2459  LOG(debug1) << " got " << digiMatch->GetNofLinks() << " matches for iCh "
2460  << iCh << " at iHitInd " << iHitInd;
2461 
2462  fhRpcCluSize[iDetIndx]->Fill((Double_t) iCh,
2463  digiMatch->GetNofLinks() / 2.);
2464 
2465  for (Int_t iSel = 0; iSel < iNSel; iSel++)
2466  if (BSel[iSel]) {
2467  fhTRpcCluSize[iDetIndx][iSel]->Fill((Double_t) iCh,
2468  digiMatch->GetNofLinks() / 2.);
2469  if (fvLastHits[iSmType][iSm][iRpc][iCh].size()
2470  > 1) { // check for previous hits in memory time interval
2471  std::list<CbmTofHit*>::iterator itL =
2472  fvLastHits[iSmType][iSm][iRpc][iCh].end();
2473  itL--;
2474  for (size_t iH = 0;
2475  iH < fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2476  iH++) {
2477  itL--;
2478  fhTRpcCluSizeDTLastHits[iDetIndx][iSel]->Fill(
2479  TMath::Log10(pHit->GetTime() - (*itL)->GetTime()),
2480  digiMatch->GetNofLinks() / 2.);
2481  }
2482  }
2483  }
2484 
2485  Double_t TotSum = 0.;
2486  for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks();
2487  iLink++) { // loop over digis
2488  CbmLink L0 = digiMatch->GetLink(iLink); //vDigish.at(ivDigInd);
2489  Int_t iDigInd0 = L0.GetIndex();
2490  if (iDigInd0 < fTofCalDigisColl->GetEntries()) {
2491  CbmTofDigi* pDig0 = (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd0));
2492  TotSum += pDig0->GetTot();
2493  }
2494  }
2495  Double_t dMeanTimeSquared = 0.;
2496  Double_t dNstrips = 0.;
2497 
2498  Double_t dDelTof = 0.;
2499  Double_t dTcor[iNSel];
2500  Double_t dTTcor[iNSel];
2501  Double_t dZsign[iNSel];
2502  Double_t dzscal = 1.;
2503  Double_t dDist = 0.;
2504 
2505  for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks();
2506  iLink += 2) { // loop over digis
2507  CbmLink L0 = digiMatch->GetLink(iLink); //vDigish.at(ivDigInd);
2508  Int_t iDigInd0 = L0.GetIndex();
2509  Int_t iDigInd1 =
2510  (digiMatch->GetLink(iLink + 1)).GetIndex(); //vDigish.at(ivDigInd+1);
2511  //LOG(debug1)<<" " << iDigInd0<<", "<<iDigInd1;
2512 
2513  if (iDigInd0 < fTofCalDigisColl->GetEntries()
2514  && iDigInd1 < fTofCalDigisColl->GetEntries()) {
2515  CbmTofDigi* pDig0 = (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd0));
2516  CbmTofDigi* pDig1 = (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd1));
2517  if ((Int_t) pDig0->GetType() != iSmType) {
2518  LOG(error) << Form(" Wrong Digi SmType for Tofhit %d in iDetIndx "
2519  "%d, Ch %d with %3.0f strips at Indx %d, %d",
2520  iHitInd,
2521  iDetIndx,
2522  iCh,
2523  dNstrips,
2524  iDigInd0,
2525  iDigInd1);
2526  }
2527  LOG(debug1) << " fhRpcCluTot: Digi 0 " << iDigInd0 << ": Ch "
2528  << pDig0->GetChannel() << ", Side " << pDig0->GetSide()
2529  << ", StripSide "
2530  << (Double_t) iCh * 2. + pDig0->GetSide() << " Digi 1 "
2531  << iDigInd1 << ": Ch " << pDig1->GetChannel() << ", Side "
2532  << pDig1->GetSide() << ", StripSide "
2533  << (Double_t) iCh * 2. + pDig1->GetSide() << ", Tot0 "
2534  << pDig0->GetTot() << ", Tot1 " << pDig1->GetTot();
2535 
2536  fhRpcCluTot[iDetIndx]->Fill(
2537  pDig0->GetChannel() * 2. + pDig0->GetSide(), pDig0->GetTot());
2538  fhRpcCluTot[iDetIndx]->Fill(
2539  pDig1->GetChannel() * 2. + pDig1->GetSide(), pDig1->GetTot());
2540 
2541  Int_t iCh0 = pDig0->GetChannel();
2542  Int_t iCh1 = pDig1->GetChannel();
2543  Int_t iS0 = pDig0->GetSide();
2544  Int_t iS1 = pDig1->GetSide();
2545  if (iCh0 != iCh1 || iS0 == iS1) {
2546  LOG(fatal) << Form(
2547  " MT2 for Tofhit %d in iDetIndx %d, Ch %d from %3.0f strips: ",
2548  iHitInd,
2549  iDetIndx,
2550  iCh,
2551  dNstrips)
2552  << Form(" Dig0: Ind %d, Ch %d, Side %d, T: %6.1f ",
2553  iDigInd0,
2554  iCh0,
2555  iS0,
2556  pDig0->GetTime())
2557  << Form(" Dig1: Ind %d, Ch %d, Side %d, T: %6.1f ",
2558  iDigInd1,
2559  iCh1,
2560  iS1,
2561  pDig1->GetTime());
2562  continue;
2563  }
2564 
2565  if (0 > iCh0 || fDigiBdfPar->GetNbChan(iSmType, iRpc) <= iCh0) {
2566  LOG(error) << Form(
2567  " Wrong Digi for Tofhit %d in iDetIndx %d, Ch %d at Indx %d, %d "
2568  "from %3.0f strips: %d, %d, %d, %d",
2569  iHitInd,
2570  iDetIndx,
2571  iCh,
2572  iDigInd0,
2573  iDigInd1,
2574  dNstrips,
2575  iCh0,
2576  iCh1,
2577  iS0,
2578  iS1);
2579  continue;
2580  }
2581 
2582  if (
2583  digiMatch->GetNofLinks()
2584  > 2) //&& digiMatch->GetNofLinks()<8 ) // FIXME: hardcoded limits on CluSize
2585  {
2586  dNstrips += 1.;
2587  dMeanTimeSquared += TMath::Power(
2588  0.5 * (pDig0->GetTime() + pDig1->GetTime()) - pHit->GetTime(), 2);
2589  // fhRpcCluAvWalk[iDetIndx]->Fill(0.5*(pDig0->GetTot()+pDig1->GetTot()),
2590  // 0.5*(pDig0->GetTime()+pDig1->GetTime())-pHit->GetTime());
2591 
2592 
2593  //Double_t dTotWeigth=(pDig0->GetTot()+pDig1->GetTot())/TotSum; (VF) not used
2594  //Double_t dCorWeigth=1.-dTotWeigth;
2595  Double_t dCorWeigth = 1.;
2596  Double_t dTDigi =
2597  0.5 * (pDig0->GetTime() + pDig1->GetTime()) - pHit->GetTime();
2598 
2599  fhRpcCluAvLnWalk[iDetIndx]->Fill(
2600  TMath::Log10(0.5 * (pDig0->GetTot() + pDig1->GetTot())), dTDigi);
2601 
2602  fhRpcCluDelTOff[iDetIndx]->Fill(pDig0->GetChannel(),
2603  dCorWeigth * dTDigi);
2604 
2605  Double_t dDelPos = 0.5 * (pDig0->GetTime() - pDig1->GetTime())
2606  * fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
2607  if (0 == pDig0->GetSide()) dDelPos *= -1.;
2608  fhRpcCluDelPos[iDetIndx]->Fill(
2609  pDig0->GetChannel(), dCorWeigth * (dDelPos - hitpos_local[1]));
2610 
2611  fhRpcCluWalk[iDetIndx][iCh0][iS0]->Fill(pDig0->GetTot(), dTDigi);
2612  //pDig0->GetTime()-(pHit->GetTime() -(1.-2.*pDig0->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc)));
2613 
2614  fhRpcCluWalk[iDetIndx][iCh1][iS1]->Fill(pDig1->GetTot(), dTDigi);
2615  //pDig1->GetTime()-(pHit->GetTime()-(1.-2.*pDig1->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc)));
2616 
2617  fhRpcCluAvWalk[iDetIndx]->Fill(pDig0->GetTot(), dTDigi);
2618  fhRpcCluAvWalk[iDetIndx]->Fill(pDig1->GetTot(), dTDigi);
2619 
2620  } // end of Clustersize > 1 condition
2621 
2622  LOG(debug1) << " fhRpcCluTot: Digi 0 " << iDigInd0 << ": Ch "
2623  << pDig0->GetChannel() << ", Side " << pDig0->GetSide()
2624  << ", StripSide "
2625  << (Double_t) iCh * 2. + pDig0->GetSide() << " Digi 1 "
2626  << iDigInd1 << ": Ch " << pDig1->GetChannel() << ", Side "
2627  << pDig1->GetSide() << ", StripSide "
2628  << (Double_t) iCh * 2. + pDig1->GetSide();
2629 
2630  // Fill event selected (triggered) histograms
2631 
2632  for (Int_t iSel = 0; iSel < iNSel; iSel++)
2633  if (BSel[iSel]) {
2634  if (NULL == pHit || NULL == pTrig[iSel]) {
2635  LOG(info) << " invalid pHit, iSel " << iSel << ", iDetIndx "
2636  << iDetIndx;
2637  break;
2638  }
2639  if (pHit->GetAddress() == pTrig[iSel]->GetAddress()) continue;
2640 
2641  fhTRpcCluTot[iDetIndx][iSel]->Fill(
2642  pDig0->GetChannel() * 2. + pDig0->GetSide(), pDig0->GetTot());
2643  fhTRpcCluTot[iDetIndx][iSel]->Fill(
2644  pDig1->GetChannel() * 2. + pDig1->GetSide(), pDig1->GetTot());
2645  if (fvLastHits[iSmType][iSm][iRpc][iCh].size()
2646  > 1) { // check for previous hits in memory time interval
2647  std::list<CbmTofHit*>::iterator itL =
2648  fvLastHits[iSmType][iSm][iRpc][iCh].end();
2649  itL--;
2650  for (size_t iH = 0;
2651  iH < fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2652  iH++) {
2653  itL--;
2654  fhTRpcCluTotDTLastHits[iDetIndx][iSel]->Fill(
2655  TMath::Log10(pHit->GetTime() - (*itL)->GetTime()),
2656  pDig0->GetTot());
2657  fhTRpcCluTotDTLastHits[iDetIndx][iSel]->Fill(
2658  TMath::Log10(pHit->GetTime() - (*itL)->GetTime()),
2659  pDig1->GetTot());
2660  }
2661  }
2662  if (iLink == 0) { // Fill histo only once (for 1. digi entry)
2664  dzscal = pHit->GetZ() / pTrig[iSel]->GetZ();
2665  fhTRpcCludXdY[iDetIndx][iSel]->Fill(
2666  pHit->GetX() - dzscal * pTrig[iSel]->GetX(),
2667  pHit->GetY() - dzscal * pTrig[iSel]->GetY());
2668  // calculate spatial distance to trigger hit
2669  dDist = TMath::Sqrt(
2670  TMath::Power(pHit->GetX() - pTrig[iSel]->GetX(), 2.)
2671  + TMath::Power(pHit->GetY() - pTrig[iSel]->GetY(), 2.)
2672  + TMath::Power(pHit->GetZ() - pTrig[iSel]->GetZ(), 2.));
2673  dDelTof =
2674  dDist / cLight; // correct to first order for speed of light
2675  pHit->GetZ() < pTrig[iSel]->GetZ() ? dZsign[iSel] = -1.
2676  : dZsign[iSel] = 1.;
2677  if ((pHit->GetAddress() & DetMask)
2678  == (pTrig[iSel]->GetAddress() & DetMask))
2679  dZsign[iSel] = 0.;
2680  dTTcor[iSel] =
2681  dDelTof * dZsign[iSel]; // store timing correction
2682  }
2684  //if( iSmType==fSel2Id // to get entries in diamond/Sel2 histos
2685  if (iSmType == 5 // FIXME, to get entries in diamond histos
2686  || TMath::Sqrt(
2687  TMath::Power(pHit->GetX() - dzscal * pTrig[iSel]->GetX(),
2688  2.)
2689  + TMath::Power(
2690  pHit->GetY() - dzscal * pTrig[iSel]->GetY(), 2.))
2691  < fdCaldXdYMax) {
2692  if (!fEnableMatchPosScaling && dSel2dXdYMin[iSel] < 1.E300)
2693  if (TMath::Sqrt(
2694  TMath::Power(
2695  pHit->GetX()
2696  - (pTrig[iSel]->GetX()
2697  + ddXdZ[iSel]
2698  * (pHit->GetZ() - (pTrig[iSel]->GetZ()))),
2699  2.)
2700  + TMath::Power(
2701  pHit->GetY()
2702  - (pTrig[iSel]->GetY()
2703  + ddYdZ[iSel]
2704  * (pHit->GetZ() - (pTrig[iSel]->GetZ()))),
2705  2.))
2706  > 0.5 * fdCaldXdYMax)
2707  continue; // FIXME: refine position selection cut in cosmic measurement
2708  if (
2709  dTRef
2710  != 0.) { //&& TMath::Abs(dTRef-dTTrig[iSel])<fdDelTofMax) { // correct times for DelTof - velocity spread
2711  if (
2712  iLink
2713  == 0) { // do calculations only once (at 1. digi entry) // interpolate!
2714  // determine correction value
2715  //if(fSel2Addr != iDetId) // do not do this for reference counter itself
2716  dTcor[iSel] = 0.; // precaution
2717  dDelTof = 0.; //re
2718  if (
2719  fTRefMode
2720  < 11) // ??, old comment: do not do this for trigger counter itself
2721  {
2722  //Double_t dTentry=dTRef-dTTrig[iSel]+fdDelTofMax;
2723  //Int_t iBx = dTentry/2./fdDelTofMax*nbClDelTofBinX;
2724  //if(iBx<0) iBx=0;
2725  //if(iBx>nbClDelTofBinX-1) iBx=nbClDelTofBinX-1;
2726  //Double_t dBinWidth=2.*fdDelTofMax/nbClDelTofBinX;
2727 
2728  Double_t dTentry = dDist;
2729  Int_t iBx = dTentry / fdDelTofMax * nbClDelTofBinX;
2730  if (iBx < 0) iBx = 0;
2731  if (iBx > nbClDelTofBinX - 1) iBx = nbClDelTofBinX - 1;
2732  Double_t dBinWidth = fdDelTofMax / nbClDelTofBinX;
2733 
2734  Double_t dDTentry =
2735  dTentry - ((Double_t) iBx) * dBinWidth;
2736  Int_t iBx1 = 0;
2737  dDTentry < 0 ? iBx1 = iBx - 1 : iBx1 = iBx + 1;
2738  Double_t w0 = 1. - TMath::Abs(dDTentry) / dBinWidth;
2739  Double_t w1 = 1. - w0;
2740  if (iBx1 < 0) iBx1 = 0;
2741  if (iBx1 > nbClDelTofBinX - 1) iBx1 = nbClDelTofBinX - 1;
2742  dDelTof =
2743  fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] * w0
2744  + fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx1][iSel]
2745  * w1;
2746  //dDelTof *= dDist; // has to be consistent with fhTRpcCluDelTof filling
2747  LOG(debug1)
2748  << Form(" DelTof for SmT %d, Sm %d, R %d, T %d, dTRef "
2749  "%6.1f, Bx %d, Bx1 %d, DTe %6.1f -> DelT %6.1f",
2750  iSmType,
2751  iSm,
2752  iRpc,
2753  iSel,
2754  dTRef - dTTrig[iSel],
2755  iBx,
2756  iBx1,
2757  dDTentry,
2758  dDelTof);
2759  }
2760 
2761  dTTcor[iSel] +=
2762  dDelTof * dZsign[iSel]; // store timing correction
2763  dTcor[iSel] =
2764  (pHit->GetTime() - dTTrig[iSel]) - dTTcor[iSel];
2765  // Double_t dAvTot=0.5*(pDig0->GetTot()+pDig1->GetTot()); (VF) not used
2766  } // if(iLink==0)
2767 
2768  LOG(debug) << Form(
2769  "TRpcCluWalk for Ev %d, Link %d(%d), Sel %d, TSR %d%d%d, "
2770  "Ch %d,%d, S %d,%d Tcor %8.3f, LocT %6.1f, W-ent: "
2771  "%6.0f,%6.0f",
2772  fiNevtBuild,
2773  iLink,
2774  (Int_t) digiMatch->GetNofLinks(),
2775  iSel,
2776  iSmType,
2777  iSm,
2778  iRpc,
2779  iCh0,
2780  iCh1,
2781  iS0,
2782  iS1,
2783  dTcor[iSel],
2784  hitpos_local[1]
2785  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc),
2786  fhTRpcCluWalk[iDetIndx][iSel][iCh0][iS0]->GetEntries(),
2787  fhTRpcCluWalk[iDetIndx][iSel][iCh1][iS1]->GetEntries());
2788 
2789  if (fhTRpcCluWalk[iDetIndx][iSel][iCh0][iS0]->GetEntries()
2790  != fhTRpcCluWalk[iDetIndx][iSel][iCh1][iS1]->GetEntries())
2791  LOG(error)
2792  << Form(" Inconsistent walk histograms -> debugging "
2793  "necessary ... for %d, %d, %d, %d, %d, %d, %d ",
2794  fiNevtBuild,
2795  iDetIndx,
2796  iSel,
2797  iCh0,
2798  iCh1,
2799  iS0,
2800  iS1);
2801 
2802  LOG(debug)
2803  << Form("TRpcCluWalk values side %d: %5.2f, %7.3f, %6.3f, "
2804  " side %d: %5.2f, %7.3f, %6.3f",
2805  iS0,
2806  pDig0->GetTot(),
2807  pDig0->GetTime()
2808  - TMath::Floor(pDig0->GetTime() / 1000.) * 1000.,
2809  dTcor[iSel]
2810  + (1. - 2. * pDig0->GetSide()) * hitpos_local[1]
2811  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc),
2812  iS1,
2813  pDig1->GetTot(),
2814  pDig1->GetTime()
2815  - TMath::Floor(pDig1->GetTime() / 1000.) * 1000.,
2816  dTcor[iSel]
2817  + (1. - 2. * pDig1->GetSide()) * hitpos_local[1]
2818  / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc));
2819 
2820  fhTRpcCluWalk[iDetIndx][iSel][iCh0][iS0]->Fill(
2821  pDig0->GetTot(),
2822  //(pDig0->GetTime()+((1.-2.*pDig0->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc))-dTTrig[iSel])-dTTcor[iSel]);
2823  // dTcor[iSel]+(1.-2.*pDig0->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc));
2824  dTcor[iSel]);
2825  fhTRpcCluWalk[iDetIndx][iSel][iCh1][iS1]->Fill(
2826  pDig1->GetTot(),
2827  //(pDig1->GetTime()+((1.-2.*pDig1->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc))-dTTrig[iSel])-dTTcor[iSel]);
2828  //dTcor[iSel]+(1.-2.*pDig1->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc));
2829  dTcor[iSel]);
2830 
2831  fhTRpcCluWalk2[iDetIndx][iSel]->Fill(
2832  pDig0->GetTot(), pDig1->GetTot(), dTcor[iSel]);
2833 
2834  fhTRpcCluAvWalk[iDetIndx][iSel]->Fill(
2835  pDig0->GetTot(),
2836  //(pDig0->GetTime()+((1.-2.*pDig0->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc))-dTTrig[iSel])-dTTcor[iSel]);
2837  //dTcor[iSel]+(1.-2.*pDig0->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc));
2838  dTcor[iSel]);
2839  fhTRpcCluAvWalk[iDetIndx][iSel]->Fill(
2840  pDig1->GetTot(),
2841  //(pDig1->GetTime()+((1.-2.*pDig1->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc))-dTTrig[iSel])-dTTcor[iSel]);
2842  //dTcor[iSel]+(1.-2.*pDig1->GetSide())*hitpos_local[1]/fDigiBdfPar->GetSigVel(iSmType,iSm,iRpc));
2843  dTcor[iSel]);
2844 
2845  if (iLink == 0) { // Fill histo only once (for 1. digi entry)
2846  fhTRpcCluDelTof[iDetIndx][iSel]->Fill(dDist, dTcor[iSel]);
2847  //fhTRpcCluDelTof[iDetIndx][iSel]->Fill(dTRef-dTTrig[iSel],dTcor[iSel]/dDist);
2848  //fhTRpcCluDelTof[iDetIndx][iSel]->Fill(dTRef-dTTrig[iSel],dTcor[iSel]);
2849  //fhTSmCluTOff[iSmType][iSel]->Fill((Double_t)(iSm*iNbRpc+iRpc),dTcor[iSel]);
2850  fhTSmCluTOff[iSmType][iSel]->Fill((Double_t)(iSm),
2851  dTcor[iSel]);
2852  fhTSmCluTRun[iSmType][iSel]->Fill(fdEvent, dTcor[iSel]);
2853  if (
2854  iDetId
2855  != (pTrig[iSel]->GetAddress()
2856  & DetMask)) { // transform matched hit-pair back into detector frame
2857  hitpos[0] = pHit->GetX() - dzscal * pTrig[iSel]->GetX()
2858  + fChannelInfo->GetX();
2859  hitpos[1] = pHit->GetY() - dzscal * pTrig[iSel]->GetY()
2860  + fChannelInfo->GetY();
2861  hitpos[2] = pHit->GetZ();
2862  gGeoManager->MasterToLocal(
2863  hitpos, hitpos_local); // transform into local frame
2864  fhRpcCluDelMatPos[iDetIndx]->Fill((Double_t) iCh,
2865  hitpos_local[1]);
2866  fhRpcCluDelMatTOff[iDetIndx]->Fill(
2867  (Double_t) iCh,
2868  (pHit->GetTime() - dTTrig[iSel]) - dTTcor[iSel]);
2869  }
2870  } // iLink==0 condition end
2871  } // position condition end
2872  } // Match condition end
2873  } // closing of selector loop
2874  } else {
2875  LOG(error)
2876  << "CbmTofCosmicClusterizer::FillHistos: invalid digi index "
2877  << iDetIndx << " digi0,1" << iDigInd0 << ", " << iDigInd1
2878  << " - max:" << fTofCalDigisColl->GetEntries()
2879  // << " in event " << XXX
2880  ;
2881  }
2882  } // iLink digi loop end;
2883 
2884  if (1 < dNstrips) {
2885  // Double_t dVar=dMeanTimeSquared/dNstrips - TMath::Power(pHit->GetTime(),2);
2886  Double_t dVar = dMeanTimeSquared / (dNstrips - 1);
2887  //if(dVar<0.) dVar=0.;
2888  Double_t dTrms = TMath::Sqrt(dVar);
2889  LOG(debug) << Form(" Trms for Tofhit %d in iDetIndx %d, Ch %d from "
2890  "%3.0f strips: %6.3f ns",
2891  iHitInd,
2892  iDetIndx,
2893  iCh,
2894  dNstrips,
2895  dTrms);
2896  fhRpcCluTrms[iDetIndx]->Fill((Double_t) iCh, dTrms);
2897  pHit->SetTimeError(dTrms);
2898  }
2899 
2900  LOG(debug1) << " Fill Time of iDetIndx " << iDetIndx << ", hitAddr "
2901  << Form(
2902  " %08x, y = %5.2f", pHit->GetAddress(), hitpos_local[1])
2903  << " for |y| <"
2904  << fhRpcCluPosition[iDetIndx]->GetYaxis()->GetXmax();
2905  if (TMath::Abs(hitpos_local[1])
2906  < (fhRpcCluPosition[iDetIndx]->GetYaxis()->GetXmax())) {
2907  if (dTRef != 0. && fTRefHits == 1) {
2908  // correct for distance
2909  dDist = TMath::Sqrt(TMath::Power(pHit->GetX() - pRef->GetX(), 2.)
2910  + TMath::Power(pHit->GetY() - pRef->GetY(), 2.)
2911  + TMath::Power(pHit->GetZ() - pRef->GetZ(), 2.));
2912  dDelTof =
2913  dDist / cLight; // correct to first order for speed of light
2914  Double_t dZsgn = 1.;
2915  if (pHit->GetZ() < pRef->GetZ()) dZsgn = -1.;
2916  dDelTof *= dZsgn; // store timing correction
2917 
2918  fhRpcCluTOff[iDetIndx]->Fill((Double_t) iCh,
2919  (pHit->GetTime() - dTRef) - dDelTof);
2920  //fhSmCluTOff[iSmType]->Fill((Double_t)(iSm*iNbRpc+iRpc),pHit->GetTime()-dTRef-dDelTof);
2921  fhSmCluTOff[iSmType]->Fill((Double_t)(iSm),
2922  (pHit->GetTime() - dTRef) - dDelTof);
2923 
2924  for (Int_t iSel = 0; iSel < iNSel; iSel++)
2925  if (BSel[iSel]) {
2926  LOG(debug1) << " TRpcCluTOff " << iDetIndx << ", Sel " << iSel
2927  << Form(", Dt %7.3f, LHsize %lu ",
2928  (pHit->GetTime() - dTTrig[iSel]),
2929  fvLastHits[iSmType][iSm][iRpc][iCh].size());
2930  if (pHit->GetAddress() == pTrig[iSel]->GetAddress()) continue;
2931 
2932  if (fvLastHits[iSmType][iSm][iRpc][iCh].size()
2933  > 1) { // check for previous hits in memory time interval
2934  std::list<CbmTofHit*>::iterator itL =
2935  fvLastHits[iSmType][iSm][iRpc][iCh].end();
2936  itL--;
2937  for (size_t iH = 0;
2938  iH < fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1;
2939  iH++) {
2940  itL--;
2941  LOG(debug1)
2942  << Form(" %f,", pHit->GetTime() - (*itL)->GetTime());
2943  }
2944  }
2945  LOG(debug1);
2946  // fill Time Offset histograms with DelTof correction
2947  fhTRpcCluTOff[iDetIndx][iSel]->Fill(
2948  (Double_t) iCh,
2949  (pHit->GetTime() - dTTrig[iSel])
2950  - dTTcor[iSel]); // DEC2017 modified !
2951  if (fvLastHits[iSmType][iSm][iRpc][iCh].size()
2952  > 1) { // check for previous hits in memory time interval
2953  std::list<CbmTofHit*>::iterator itL =
2954  fvLastHits[iSmType][iSm][iRpc][iCh].end();
2955  itL--;
2956  for (Int_t iH = 0; iH < 1; iH++) { // use only last hit
2957  // for(Int_t iH=0; iH<fvLastHits[iSmType][iSm][iRpc][iCh].size()-1; iH++){//fill for all memorized hits
2958  itL--;
2959  Double_t dTsinceLast = pHit->GetTime() - (*itL)->GetTime();
2960  if (dTsinceLast > fdMemoryTime)
2961  LOG(fatal) << Form("Invalid Time since last hit on channel "
2962  "TSRC %d%d%d%d: %f > %f",
2963  iSmType,
2964  iSm,
2965  iRpc,
2966  iCh,
2967  dTsinceLast,
2968  fdMemoryTime);
2969 
2970  fhTRpcCluTOffDTLastHits[iDetIndx][iSel]->Fill(
2971  TMath::Log10(dTsinceLast),
2972  (pHit->GetTime() - dTTrig[iSel]));
2973  fhTRpcCluMemMulDTLastHits[iDetIndx][iSel]->Fill(
2974  TMath::Log10(dTsinceLast),
2975  fvLastHits[iSmType][iSm][iRpc][iCh].size() - 1);
2976  }
2977  }
2978  }
2979  }
2980  }
2981  }
2982 
2983  for (Int_t iSmType = 0; iSmType < fDigiBdfPar->GetNbSmTypes(); iSmType++) {
2984  for (Int_t iRpc = 0; iRpc < fDigiBdfPar->GetNbRpc(iSmType); iRpc++) {
2985  LOG(debug1) << "CbmTofCosmicClusterizer::FillHistos: "
2986  << Form(" %3d %3d %3lu ",
2987  iSmType,
2988  iRpc,
2989  fviClusterSize[iSmType][iRpc].size());
2990 
2991  for (UInt_t uCluster = 0;
2992  uCluster < fviClusterSize[iSmType][iRpc].size();
2993  uCluster++) {
2994  LOG(debug2) << "CbmTofCosmicClusterizer::FillHistos: "
2995  << Form(" %3d %3d %3d ", iSmType, iRpc, uCluster);
2996 
2997  fhClusterSize->Fill(fviClusterSize[iSmType][iRpc][uCluster]);
2998  fhClusterSizeType->Fill(fviClusterSize[iSmType][iRpc][uCluster],
2999  40 * iSmType
3000  + iRpc); //FIXME - hardwired constant
3001 
3002  if (kFALSE) // 1 == fviTrkMul[iSmType][iRpc][uCluster] )
3003  {
3004  fhClustSizeDifX->Fill(fviClusterSize[iSmType][iRpc][uCluster],
3005  fvdDifX[iSmType][iRpc][uCluster]);
3006  fhClustSizeDifY->Fill(fviClusterSize[iSmType][iRpc][uCluster],
3007  fvdDifY[iSmType][iRpc][uCluster]);
3008 
3009  if (1 == fviClusterSize[iSmType][iRpc][uCluster]) {
3010  fhChDifDifX->Fill(fvdDifCh[iSmType][iRpc][uCluster],
3011  fvdDifX[iSmType][iRpc][uCluster]);
3012  fhChDifDifY->Fill(fvdDifCh[iSmType][iRpc][uCluster],
3013  fvdDifY[iSmType][iRpc][uCluster]);
3014  }
3015  }
3016  } // for( UInt_t uCluster = 0; uCluster < fviClusterSize[iSmType][iRpc].size(); uCluster++ )
3017  fviClusterSize[iSmType][iRpc].clear();
3018  fviTrkMul[iSmType][iRpc].clear();
3019  fvdX[iSmType][iRpc].clear();
3020  fvdY[iSmType][iRpc].clear();
3021  fvdDifX[iSmType][iRpc].clear();
3022  fvdDifY[iSmType][iRpc].clear();
3023  fvdDifCh[iSmType][iRpc].clear();
3024  } // for( Int_t iRpc = 0; iRpc < fDigiBdfPar->GetNbRpc( iSmType); iRpc++ )
3025  }
3026  fhNbSameSide->Fill(fiNbSameSide);
3027  }
3028 
3029  return kTRUE;
3030 }
3031 
3033  TDirectory* oldir = gDirectory;
3034  TFile* fHist;
3035  fHist = new TFile(fOutHstFileName, "RECREATE");
3036  fHist->cd();
3037  // fhClustBuildTime->Write();
3038 
3039  for (Int_t iDetIndx = 0; iDetIndx < fDigiBdfPar->GetNbDet(); iDetIndx++) {
3040  if (NULL == fhRpcCluMul[iDetIndx]) continue;
3041  // fhRpcCluMul[iDetIndx]->Write();
3042  // fhRpcCluRate[iDetIndx]->Write();
3043  // fhRpcCluPosition[iDetIndx]->Write();
3044  // fhRpcCluDelPos[iDetIndx]->Write();
3045  // fhRpcCluTOff[iDetIndx]->Write();
3046  // fhRpcCluDelTOff[iDetIndx]->Write();
3047  // fhRpcCluTrms[iDetIndx]->Write();
3048  // fhRpcCluTot[iDetIndx]->Write();
3049  // fhRpcCluAvWalk[iDetIndx]->Write();
3050  // fhRpcCluAvLnWalk[iDetIndx]->Write();
3051  // fhRpcDTLastHits[iDetIndx]->Write();
3052  // fhRpcDTLastHits_Tot[iDetIndx]->Write();
3053  // fhRpcDTLastHits_CluSize[iDetIndx]->Write();
3054 
3055  LOG(debug) << "Write triggered Histos for Det Ind " << iDetIndx
3056  << Form(", UID 0x%08x", fDigiBdfPar->GetDetUId(iDetIndx));
3057  for (Int_t iSel = 0; iSel < iNSel;
3058  iSel++) { // Save trigger selected histos
3059  if (NULL == fhTRpcCluMul[iDetIndx][iSel]) continue;
3060  // fhTRpcCluMul[iDetIndx][iSel]->Write();
3061  // fhTRpcCluPosition[iDetIndx][iSel]->Write();
3062  // fhTRpcCluTOff[iDetIndx][iSel]->Write();
3063  // fhTRpcCluTot[iDetIndx][iSel]->Write();
3064  // fhTRpcCluAvWalk[iDetIndx][iSel]->Write();
3065  }
3066 
3067  Int_t iUniqueId = fDigiBdfPar->GetDetUId(iDetIndx);
3068  Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
3069  Int_t iSm = CbmTofAddress::GetSmId(iUniqueId);
3070  Int_t iRpc = CbmTofAddress::GetRpcId(iUniqueId);
3071  Int_t iSmAddr = iUniqueId & ModMask;
3072 
3073  Int_t iNent = 0;
3074  if (fCalSel > -1) {
3075  if (NULL == fhTRpcCluAvWalk[iDetIndx][fCalSel]) continue;
3076  iNent = (Int_t) fhTRpcCluAvWalk[iDetIndx][fCalSel]->GetEntries();
3077  } else {
3078  if (NULL == fhRpcCluAvWalk[iDetIndx]) continue;
3079  iNent = (Int_t) fhRpcCluAvWalk[iDetIndx]->GetEntries();
3080  }
3081  if (0 == iNent) {
3082  LOG(info) << "WriteHistos: No entries in Walk histos for "
3083  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc " << iRpc;
3084  // continue;
3085  }
3086 
3087  TH2* htempPos = NULL;
3088  TProfile* htempPos_pfx = NULL;
3089  TH1* htempPos_py = NULL;
3090  TProfile* htempTOff_pfx = NULL;
3091  TH1* htempTOff_px = NULL;
3092  TProfile* hAvPos_pfx = NULL;
3093  TProfile* hAvTOff_pfx = NULL;
3094  TH2* htempTOff =
3095  NULL; // -> Comment to remove warning because set but never used
3096  TH2* htempTot = NULL;
3097  TProfile* htempTot_pfx = NULL;
3098  TH1* htempTot_Mean = NULL;
3099  TH1* htempTot_Off = NULL;
3100 
3101  if (-1 < fCalSel) {
3102  htempPos = fhRpcCluPosition
3103  [iDetIndx]; // use untriggered distributions for position
3104  htempPos_pfx = fhRpcCluPosition[iDetIndx]->ProfileX(
3105  "_pfx", 1, fhRpcCluPosition[iDetIndx]->GetNbinsY());
3106  //htempPos = fhTRpcCluPosition[iDetIndx][fCalSel];
3107  //htempPos_pfx = fhTRpcCluPosition[iDetIndx][fCalSel]->ProfileX("_pfx",1,fhTRpcCluPosition[iDetIndx][fCalSel]->GetNbinsY());
3108  htempTOff = fhTRpcCluTOff
3109  [iDetIndx]
3110  [fCalSel]; // -> Comment to remove warning because set but never used
3111  htempTOff_pfx = htempTOff->ProfileX(
3112  "_pfx", 1, fhTRpcCluTOff[iDetIndx][fCalSel]->GetNbinsY());
3113  htempTOff_px = htempTOff->ProjectionX(
3114  "_px", 1, fhTRpcCluTOff[iDetIndx][fCalSel]->GetNbinsY());
3115  htempTot = fhTRpcCluTot[iDetIndx][fCalSel];
3116  htempTot_pfx = fhTRpcCluTot[iDetIndx][fCalSel]->ProfileX(
3117  "_pfx", 1, fhTRpcCluTot[iDetIndx][fCalSel]->GetNbinsY());
3118  hAvPos_pfx = fhTSmCluPosition[iSmType][fCalSel]->ProfileX(
3119  "_pfx", 1, fhTSmCluPosition[iSmType][fCalSel]->GetNbinsY());
3120  hAvTOff_pfx = fhTSmCluTOff[iSmType][fCalSel]->ProfileX(
3121  "_pfx", 1, fhTSmCluTOff[iSmType][fCalSel]->GetNbinsY(), "s");
3122  } else // all triggers
3123  {
3124  htempPos = fhRpcCluPosition[iDetIndx];
3125  htempTot = fhRpcCluTot[iDetIndx];
3126  htempTot_pfx = fhRpcCluTot[iDetIndx]->ProfileX(
3127  "_pfx", 1, fhRpcCluTot[iDetIndx]->GetNbinsY());
3128  hAvPos_pfx = fhSmCluPosition[iSmType]->ProfileX(
3129  "_pfx", 1, fhSmCluPosition[iSmType]->GetNbinsY());
3130  hAvTOff_pfx = fhSmCluTOff[iSmType]->ProfileX(
3131  "_pfx", 1, fhSmCluTOff[iSmType]->GetNbinsY());
3132  if (-1 == fCalSel) { // take corrections from untriggered distributions
3133  htempPos_pfx = fhRpcCluPosition[iDetIndx]->ProfileX(
3134  "_pfx", 1, fhRpcCluPosition[iDetIndx]->GetNbinsY());
3135  // htempTOff = fhRpcCluTOff[iDetIndx]; // -> Comment to remove warning because set but never used
3136  htempTOff_pfx = fhRpcCluTOff[iDetIndx]->ProfileX(
3137  "_pfx", 1, fhRpcCluTOff[iDetIndx]->GetNbinsY(), "s");
3138  htempTOff_px = fhRpcCluTOff[iDetIndx]->ProjectionX(
3139  "_px", 1, fhRpcCluTOff[iDetIndx]->GetNbinsY());
3140  } else {
3141  if (-2 == fCalSel) { //take corrections from Cluster deviations
3142  htempPos_pfx = fhRpcCluDelPos[iDetIndx]->ProfileX(
3143  "_pfx", 1, fhRpcCluDelPos[iDetIndx]->GetNbinsY());
3144  // htempTOff = fhRpcCluDelTOff[iDetIndx]; // -> Comment to remove warning because set but never used
3145  htempTOff_pfx = fhRpcCluDelTOff[iDetIndx]->ProfileX(
3146  "_pfx", 1, fhRpcCluDelTOff[iDetIndx]->GetNbinsY());
3147  htempTOff_px = fhRpcCluDelTOff[iDetIndx]->ProjectionX(
3148  "_px", 1, fhRpcCluDelTOff[iDetIndx]->GetNbinsY());
3149  } else {
3150  if (
3151  -3
3152  == fCalSel) { // take corrections from deviations to matched trigger hit
3153  htempPos_pfx = fhRpcCluDelMatPos[iDetIndx]->ProfileX(
3154  "_pfx", 1, fhRpcCluDelMatPos[iDetIndx]->GetNbinsY());
3155  // htempTOff = fhRpcCluDelMatTOff[iDetIndx]; // -> Comment to remove warning because set but never used
3156  htempTOff_pfx = fhRpcCluDelMatTOff[iDetIndx]->ProfileX(
3157  "_pfx", 1, fhRpcCluDelMatTOff[iDetIndx]->GetNbinsY());
3158  htempTOff_px = fhRpcCluDelMatTOff[iDetIndx]->ProjectionX(
3159  "_px", 1, fhRpcCluDelMatTOff[iDetIndx]->GetNbinsY());
3160  }
3161  }
3162  }
3163  }
3164 
3165  if (NULL == htempPos_pfx) {
3166  LOG(info) << "WriteHistos: Projections not available, continue ";
3167  continue;
3168  }
3169 
3170  htempTot_Mean = htempTot_pfx->ProjectionX("_Mean");
3171  htempTot_Off = htempTot_pfx->ProjectionX("_Off");
3172 
3173  htempPos_pfx->SetName(
3174  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Pos_pfx", iSmType, iSm, iRpc));
3175  htempTOff_pfx->SetName(
3176  Form("cl_CorSmT%01d_sm%03d_rpc%03d_TOff_pfx", iSmType, iSm, iRpc));
3177  htempTot_pfx->SetName(
3178  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_pfx", iSmType, iSm, iRpc));
3179  htempTot_Mean->SetName(
3180  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Mean", iSmType, iSm, iRpc));
3181  htempTot_Off->SetName(
3182  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Tot_Off", iSmType, iSm, iRpc));
3183  hAvPos_pfx->SetName(Form("cl_CorSmT%01d_Pos_pfx", iSmType));
3184  hAvTOff_pfx->SetName(Form("cl_CorSmT%01d_TOff_pfx", iSmType));
3185 
3186  switch (fCalMode % 10) {
3187  case 0: { // Initialize
3188  htempTot_Off->Reset(); // prepare TotOffset histo
3189  TH1* hbins[200];
3190  Int_t nbins = htempTot->GetNbinsX();
3191  for (int i = 0; i < nbins; i++) {
3192  hbins[i] = htempTot->ProjectionY(Form("bin%d", i + 1), i + 1, i + 1);
3193  /* Double_t Ymax=hbins[i]->GetMaximum();*/
3194  Int_t iBmax = hbins[i]->GetMaximumBin();
3195  TAxis* xaxis = hbins[i]->GetXaxis();
3196  Double_t Xmax = xaxis->GetBinCenter(iBmax);
3197  Double_t XOff = Xmax - fTotPreRange;
3198  XOff = (Double_t)(Int_t) XOff;
3199  if (XOff < 0) XOff = 0;
3200  htempTot_Off->SetBinContent(i + 1, XOff);
3201  Double_t Xmean = htempTot_Mean->GetBinContent(i + 1);
3202  if (Xmean < XOff) {
3203  LOG(warning) << "Inconsistent Tot numbers for "
3204  << Form(
3205  "SmT%01d_sm%03d_rpc%03d bin%d: mean %f, Off %f",
3206  iSmType,
3207  iSm,
3208  iRpc,
3209  i,
3210  Xmean,
3211  XOff);
3212  }
3213  htempTot_Mean->SetBinContent(i + 1, (Xmean - XOff));
3214  if (htempTot_Mean->GetBinContent(i + 1) != (Xmean - XOff))
3215  LOG(warning)
3216  << "Tot numbers not stored properly for "
3217  << Form("SmT%01d_sm%03d_rpc%03d bin%d: mean %f, target %f",
3218  iSmType,
3219  iSm,
3220  iRpc,
3221  i,
3222  htempTot_Mean->GetBinContent(i + 1),
3223  Xmean - XOff);
3224  }
3225  htempPos_pfx->Write();
3226  htempTOff_pfx->Write();
3227  // htempTot_pfx->Write();
3228  htempTot_Mean->Write();
3229  htempTot_Off->Write();
3230  } break;
3231  case 1: //save offsets, update walks
3232  {
3233  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
3234  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
3235  LOG(info) << "WriteHistos: restore Offsets and Gains and save Walk for "
3236  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc " << iRpc
3237  << " and calSmAddr = "
3238  << Form(" 0x%08x ", TMath::Abs(fCalSmAddr));
3239  htempPos_pfx->Reset(); //reset to restore means of original histos
3240  htempTOff_pfx->Reset();
3241  htempTot_Mean->Reset();
3242  htempTot_Off->Reset();
3243  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
3244  Double_t YMean = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * 0.5
3245  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3246  - fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3247  Double_t TMean = 0.5
3248  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3249  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3250  htempPos_pfx->Fill(iCh, YMean);
3251  if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3252  LOG(error) << "WriteHistos: restore unsuccessful! ch " << iCh
3253  << " got " << htempPos_pfx->GetBinContent(iCh) << ","
3254  << htempPos_pfx->GetBinContent(iCh + 1) << ","
3255  << htempPos_pfx->GetBinContent(iCh + 2) << ", expected "
3256  << YMean;
3257  }
3258  htempTOff_pfx->Fill(iCh, TMean);
3259 
3260  for (Int_t iSide = 0; iSide < 2; iSide++) {
3261  htempTot_Mean->SetBinContent(
3262  iCh * 2 + 1 + iSide,
3263  fdTTotMean
3264  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh]
3265  [iSide]); //nh +1 empirical(?)
3266  htempTot_Off->SetBinContent(
3267  iCh * 2 + 1 + iSide,
3268  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3269  }
3270  }
3271 
3272  LOG(debug1) << " Offset, gain restoring done ... ";
3273  htempPos_pfx->Write();
3274  htempTOff_pfx->Write();
3275  // htempTot_pfx->Write();
3276  htempTot_Mean->Write();
3277  htempTot_Off->Write();
3278 
3279  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
3280  // Store DelTof corrections
3281  TDirectory* curdir = gDirectory;
3282  gROOT->cd(); //
3283  TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3284  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3285  iSmType,
3286  iSm,
3287  iRpc,
3288  iSel));
3289  gDirectory->cd(curdir->GetPath());
3290  if (NULL != hCorDelTof) {
3291  TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3292  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3293  iSmType,
3294  iSm,
3295  iRpc,
3296  iSel));
3297  hCorDelTofout->Write();
3298  } else {
3299  LOG(debug) << " No CorDelTof histo "
3300  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3301  iSmType,
3302  iSm,
3303  iRpc,
3304  iSel);
3305  }
3306  }
3307 
3308  if (
3309  (fCalSmAddr < 0 && TMath::Abs(fCalSmAddr) != iSmAddr)
3310  || fCalSmAddr
3311  == iSmAddr) // select detectors for determination of walk correction
3312  {
3313 
3314  LOG(info) << "restore Offsets and Gains and update Walk for "
3315  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc " << iRpc
3316  << " with " << fDigiBdfPar->GetNbChan(iSmType, iRpc)
3317  << " channels";
3318  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpc);
3319  iCh++) {
3320  TH2* h2tmp0;
3321  TH2* h2tmp1;
3322  if (!fEnableAvWalk) {
3323  if (-1 < fCalSel) {
3324  h2tmp0 = fhTRpcCluWalk[iDetIndx][fCalSel][iCh][0];
3325  h2tmp1 = fhTRpcCluWalk[iDetIndx][fCalSel][iCh][1];
3326  } else { // take correction from deviation within clusters
3327  h2tmp0 = fhRpcCluWalk[iDetIndx][iCh][0];
3328  h2tmp1 = fhRpcCluWalk[iDetIndx][iCh][1];
3329  }
3330  } else { // go for averages (low statistics)
3331  if (-1 < fCalSel) {
3332  h2tmp0 = fhTRpcCluAvWalk[iDetIndx][fCalSel];
3333  h2tmp1 = fhTRpcCluAvWalk[iDetIndx][fCalSel];
3334  } else { // take correction from deviation within clusters
3335  h2tmp0 = fhRpcCluAvWalk[iDetIndx];
3336  h2tmp1 = fhRpcCluAvWalk[iDetIndx];
3337  }
3338  }
3339  if (NULL == h2tmp0) {
3340  LOG(info) << Form("WriteHistos: Walk histo not available for SmT "
3341  "%d, Sm %d, Rpc %d, Ch %d",
3342  iSmType,
3343  iSm,
3344  iRpc,
3345  iCh);
3346  continue;
3347  }
3348  Int_t iNEntries = h2tmp0->GetEntries();
3349  //if(iCh==0) // condition to print message only once
3350  LOG(info) << Form(" Update Walk correction for SmT %d, Sm %d, Rpc "
3351  "%d, Ch %d, Sel%d: Entries %d",
3352  iSmType,
3353  iSm,
3354  iRpc,
3355  iCh,
3356  fCalSel,
3357  iNEntries);
3358 
3359  // h2tmp0->Write();
3360  // h2tmp1->Write();
3361  if (-1 < iNEntries) { // always done
3362  TProfile* htmp0 =
3363  h2tmp0->ProfileX("_pfx", 1, h2tmp0->GetNbinsY());
3364  TProfile* htmp1 =
3365  h2tmp1->ProfileX("_pfx", 1, h2tmp1->GetNbinsY());
3366  TH1D* h1tmp0 = h2tmp0->ProjectionX("_px", 1, h2tmp0->GetNbinsY());
3367  TH1D* h1tmp1 = h2tmp1->ProjectionX("_px", 1, h2tmp1->GetNbinsY());
3368  TH1D* h1ytmp0 =
3369  h2tmp0->ProjectionY("_py", 1, nbClWalkBinX); // preserve means
3370  TH1D* h1ytmp1 = h2tmp1->ProjectionY("_py", 1, nbClWalkBinX);
3371  Double_t dWMean0 = h1ytmp0->GetMean();
3372  Double_t dWMean1 = h1ytmp1->GetMean();
3373  Double_t dWMean = 0.5 * (dWMean0 + dWMean1);
3374  Int_t iWalkUpd = 2; // Walk update mode flag
3375  //if(5==iSmType || 8==iSmType || 2==iSmType) iWalkUpd=0; // keep both sides consistent for diamonds and pads
3376  if (5 == iSmType || 8 == iSmType)
3377  iWalkUpd =
3378  0; // keep both sides consistent for diamonds and pads (Cern2016)
3379  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
3380  switch (iWalkUpd) {
3381  case 0:
3382  if (h1tmp0->GetBinContent(iWx + 1) > WalkNHmin
3383  && h1tmp1->GetBinContent(iWx + 1) > WalkNHmin) {
3384  // preserve y - position (difference) on average
3385  Double_t dWcor =
3386  (((TProfile*) htmp0)->GetBinContent(iWx + 1)
3387  + ((TProfile*) htmp1)->GetBinContent(iWx + 1))
3388  * 0.5;
3389  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3390  dWcor - dWMean;
3391  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3392  dWcor - dWMean;
3393  }
3394  break;
3395  case 1:
3396  if (h1tmp0->GetBinContent(iWx + 1) > WalkNHmin
3397  && h1tmp1->GetBinContent(iWx + 1) > WalkNHmin) {
3398  Double_t dWcor0 =
3399  ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3400  Double_t dWcor1 =
3401  ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3402  Double_t dWcor = 0.5 * (dWcor0 + dWcor1);
3403  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3404  dWcor; //-dWMean0;
3405  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3406  dWcor; //-dWMean1;
3407 
3408  if (iCh == 10 && iSmType == 0 && iSm == 1
3409  && h1tmp0->GetBinContent(iWx + 1) > WalkNHmin)
3410  LOG(debug)
3411  << "Update Walk Sm = " << iSm << "(" << iNbRpc
3412  << "), Rpc " << iRpc << ", Bin " << iWx << ", "
3413  << h1tmp0->GetBinContent(iWx + 1) << " cts: "
3414  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]
3415  << " + "
3416  << ((TProfile*) htmp0)->GetBinContent(iWx + 1)
3417  << " - " << dWMean0 << " -> " << dWcor - dWMean0
3418  << ", S1: "
3419  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
3420  << " + "
3421  << ((TProfile*) htmp1)->GetBinContent(iWx + 1)
3422  << " - " << dWMean1 << " -> " << dWcor - dWMean1;
3423  }
3424  break;
3425  case 2:
3426  if (h1tmp0->GetBinContent(iWx + 1) > WalkNHmin
3427  && h1tmp1->GetBinContent(iWx + 1) > WalkNHmin) {
3428  Double_t dWcor0 =
3429  ((TProfile*) htmp0)->GetBinContent(iWx + 1) - dWMean0;
3430  Double_t dWcor1 =
3431  ((TProfile*) htmp1)->GetBinContent(iWx + 1) - dWMean1;
3432  //Double_t dWcor = 0.5*(dWcor0 + dWcor1);
3433  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx] +=
3434  dWcor0;
3435  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx] +=
3436  dWcor1;
3437 
3438  if (iCh == 10 && iSmType == 0
3439  && h1tmp0->GetBinContent(iWx + 1) > WalkNHmin)
3440  LOG(info)
3441  << "Update Walk Sm = " << iSm << "(" << iNbRpc
3442  << "), Rpc " << iRpc << ", Bin " << iWx << ", "
3443  << h1tmp0->GetBinContent(iWx + 1) << " cts: "
3444  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]
3445  << " + "
3446  << ((TProfile*) htmp0)->GetBinContent(iWx + 1)
3447  << " - " << dWMean0 << " -> " << dWcor0 - dWMean0
3448  << ", S1: "
3449  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]
3450  << " + "
3451  << ((TProfile*) htmp1)->GetBinContent(iWx + 1)
3452  << " - " << dWMean1 << " -> " << dWcor1 - dWMean1;
3453  }
3454  break;
3455 
3456  default:;
3457  }
3458  }
3459  h1tmp0->Reset();
3460  h1tmp1->Reset();
3461  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
3462  h1tmp0->SetBinContent(
3463  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3464  h1tmp1->SetBinContent(
3465  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3466  Int_t iTry = 3;
3467  while (
3468  iTry-- > 0
3469  && h1tmp0->GetBinContent(iWx + 1)
3470  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3471  h1tmp0->SetBinContent(
3472  iWx + 1,
3473  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3474  }
3475  if (iTry == 0)
3476  LOG(error)
3477  << "writing not successful for " << h1tmp0->GetName()
3478  << ", attempts left: " << iTry << ", iWx " << iWx
3479  << ", got " << h1tmp0->GetBinContent(iWx + 1)
3480  << ", expected "
3481  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3482  iTry = 3;
3483  while (
3484  iTry-- > 0
3485  && h1tmp1->GetBinContent(iWx + 1)
3486  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]) {
3487  h1tmp1->SetBinContent(
3488  iWx + 1,
3489  fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3490  }
3491  if (iTry == 0)
3492  LOG(error)
3493  << "writing not successful for " << h1tmp1->GetName()
3494  << ", attempts left: " << iTry << ", iWx " << iWx
3495  << ", got " << h1tmp1->GetBinContent(iWx + 1)
3496  << ", expected "
3497  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx];
3498  }
3499 
3500  h1tmp0->SetName(
3501  Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3502  iSmType,
3503  iSm,
3504  iRpc,
3505  iCh));
3506  h1tmp0->Smooth(iNWalkSmooth);
3507  h1tmp0->Write();
3508  h1tmp1->SetName(
3509  Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3510  iSmType,
3511  iSm,
3512  iRpc,
3513  iCh));
3514  h1tmp1->Smooth(iNWalkSmooth);
3515  h1tmp1->Write();
3516  }
3517  }
3518  } else { // preserve whatever is there for fCalSmAddr !
3519  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpc);
3520  iCh++) // restore old values
3521  {
3522  // TProfile *htmp0 = fhRpcCluWalk[iDetIndx][iCh][0]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
3523  // TProfile *htmp1 = fhRpcCluWalk[iDetIndx][iCh][1]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
3524  TH1D* h1tmp0 = fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX(
3525  "_px", 1, nbClWalkBinY);
3526  TH1D* h1tmp1 = fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX(
3527  "_px", 1, nbClWalkBinY);
3528  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
3529  h1tmp0->SetBinContent(
3530  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3531  h1tmp1->SetBinContent(
3532  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3533  if (h1tmp0->GetBinContent(iWx + 1)
3534  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3535  LOG(error)
3536  << "WriteHistos: restore unsuccessful! iWx " << iWx << " got "
3537  << h1tmp0->GetBinContent(iWx + 1) << ", expected "
3538  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3539  }
3540  }
3541  h1tmp0->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3542  iSmType,
3543  iSm,
3544  iRpc,
3545  iCh));
3546  // htmp0->Write();
3547  h1tmp0->Write();
3548  h1tmp1->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3549  iSmType,
3550  iSm,
3551  iRpc,
3552  iCh));
3553  // htmp1->Write();
3554  h1tmp1->Write();
3555  }
3556  }
3557  } break;
3558 
3559  case 2: //update time offsets from positions and times with Sm averages, save walks and DELTOF
3560  {
3561  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
3562  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
3563 
3564  if ((fCalSmAddr < 0)
3565  || (fCalSmAddr
3566  != iSmAddr)) { // select detectors for updating offsets
3567  LOG(debug) << "WriteHistos: (case 2) update Offsets and keep Gains, "
3568  "Walk and DELTOF for "
3569  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc "
3570  << iRpc;
3571  Int_t iB = iSm * iNbRpc + iRpc;
3572  Double_t dVscal = 1.;
3573  if (NULL != fhSmCluSvel[iSmType])
3574  dVscal =
3575  fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3576  if (dVscal == 0.) dVscal = 1.;
3577 
3578  Double_t YMean = ((TProfile*) hAvPos_pfx)
3579  ->GetBinContent(iB + 1); //nh +1 empirical(?)
3580  htempPos_py =
3581  htempPos->ProjectionY(Form("%s_py", htempPos->GetName()), 1, iNbCh);
3582  if (htempPos_py->GetEntries() > fdYFitMin && fPosYMaxScal < 1.1) {
3583  LOG(debug1) << Form("Determine YMean in %s by fit to %d entries",
3584  htempPos->GetName(),
3585  (Int_t) htempPos_py->GetEntries());
3586  CbmTofDetectorInfo xDetInfo(
3587  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, 0);
3588  Int_t iChId = fTofId->SetDetectorInfo(xDetInfo);
3589  fChannelInfo = fDigiPar->GetCell(iChId);
3590  if (NULL == fChannelInfo) {
3591  LOG(warning) << Form("invalid ChannelInfo for 0x%08x", iChId);
3592  continue;
3593  }
3594  fit_ybox(htempPos_py, 0.5 * fChannelInfo->GetSizey());
3595  TF1* ff = htempPos_py->GetFunction("YBox");
3596  if (NULL != ff) {
3597  LOG(info) << "FRes YBox " << htempPos_py->GetEntries()
3598  << " entries in TSR " << iSmType << iSm << iRpc
3599  << ", chi2 " << ff->GetChisquare() / ff->GetNDF()
3600  << Form(
3601  ", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3602  "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3604  dVscal,
3605  2. * ff->GetParameter(1),
3606  2. * ff->GetParError(1),
3607  ff->GetParameter(2),
3608  ff->GetParError(2),
3609  ff->GetParameter(3),
3610  ff->GetParError(3));
3611 
3612  if (TMath::Abs(fChannelInfo->GetSizey()
3613  - 2. * ff->GetParameter(1))
3614  / fChannelInfo->GetSizey()
3615  < 0.2
3616  && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1)) < 0.2)
3617  // && ff->GetChisquare() < 500.) //FIXME - constants!
3618  {
3619  if (TMath::Abs(ff->GetParameter(3) - YMean)
3620  < 0.5 * fChannelInfo->GetSizey()) {
3621  YMean = ff->GetParameter(3);
3622  Double_t dV = dVscal * fChannelInfo->GetSizey()
3623  / (2. * ff->GetParameter(1));
3624  fhSmCluSvel[iSmType]->Fill((Double_t)(iSm * iNbRpc + iRpc),
3625  dV);
3626  }
3627  }
3628  }
3629  }
3630 
3631 
3632  Double_t TMean = ((TProfile*) hAvTOff_pfx)->GetBinContent(iSm + 1);
3633  Double_t TWidth = ((TProfile*) hAvTOff_pfx)->GetBinError(iSm + 1);
3634  Double_t dTYOff = YMean / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
3635 
3636 
3637  //if (fSel2Addr == iSmAddr) TMean=0.; // don't shift reference counter
3638  //if (fSel2Id == iSmType && fSel2Sm == iSm && fSel2Rpc == iRpc) TMean=0.; // don't shift reference counter
3639 
3640  LOG(debug) << Form("<ICor> Correct %d %d %d by TMean=%8.2f, "
3641  "TYOff=%8.2f, TWidth=%8.2f, ",
3642  iSmType,
3643  iSm,
3644  iRpc,
3645  TMean,
3646  dTYOff,
3647  TWidth);
3648 
3649 
3650  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // update Offset and Gain
3651  {
3652  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
3653  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
3654 
3655  LOG(debug) << "FillCalHist:"
3656  << " SmT " << iSmType << " Sm " << iSm << " Rpc " << iRpc
3657  << " Ch " << iCh << ": YMean " << YMean << ", TMean "
3658  << TMean << " -> "
3659  << Form(
3660  " %f, %f, %f, %f ",
3661  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3662  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
3663  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
3664  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
3665  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
3666  }
3667  htempPos_pfx->Reset(); //reset to store new values
3668  htempTOff_pfx->Reset();
3669  htempTot_Mean->Reset();
3670  htempTot_Off->Reset();
3671  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // store new values
3672  {
3673  Double_t YMean = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * 0.5
3674  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3675  - fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3676  Double_t TMean = 0.5
3677  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
3678  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
3679  htempPos_pfx->Fill(iCh, YMean);
3680  if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
3681  LOG(error) << "WriteHistos: restore unsuccessful! ch " << iCh
3682  << " got " << htempPos_pfx->GetBinContent(iCh) << ","
3683  << htempPos_pfx->GetBinContent(iCh + 1) << ","
3684  << htempPos_pfx->GetBinContent(iCh + 2) << ", expected "
3685  << YMean;
3686  }
3687  htempTOff_pfx->Fill(iCh, TMean);
3688 
3689  for (Int_t iSide = 0; iSide < 2; iSide++) {
3690  htempTot_Mean->SetBinContent(
3691  iCh * 2 + 1 + iSide,
3692  fdTTotMean
3693  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh]
3694  [iSide]); //nh +1 empirical(?)
3695  htempTot_Off->SetBinContent(
3696  iCh * 2 + 1 + iSide,
3697  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
3698  }
3699  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
3700 
3701  LOG(debug1) << " Updating done ... write to file ";
3702  htempPos_pfx->Write();
3703  htempTOff_pfx->Write();
3704  // htempTot_pfx->Write();
3705  htempTot_Mean->Write();
3706  htempTot_Off->Write();
3707 
3708  // store old DELTOF histos
3709  LOG(debug) << " Copy old DelTof histos from " << gDirectory->GetName()
3710  << " to file ";
3711 
3712  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
3713  // Store DelTof corrections
3714  TDirectory* curdir = gDirectory;
3715  gROOT->cd(); //
3716  TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
3717  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3718  iSmType,
3719  iSm,
3720  iRpc,
3721  iSel));
3722  gDirectory->cd(curdir->GetPath());
3723  if (NULL != hCorDelTof) {
3724  TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
3725  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3726  iSmType,
3727  iSm,
3728  iRpc,
3729  iSel));
3730  hCorDelTofout->Write();
3731  } else {
3732  LOG(debug) << " No CorDelTof histo "
3733  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
3734  iSmType,
3735  iSm,
3736  iRpc,
3737  iSel);
3738  }
3739  }
3740 
3741  // store walk histos
3742  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // store new values
3743  {
3744  // TProfile *htmp0 = fhRpcCluWalk[iDetIndx][iCh][0]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
3745  // TProfile *htmp1 = fhRpcCluWalk[iDetIndx][iCh][1]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
3746  TH1D* h1tmp0 =
3747  fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX("_px", 1, nbClWalkBinY);
3748  TH1D* h1tmp1 =
3749  fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX("_px", 1, nbClWalkBinY);
3750  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
3751  h1tmp0->SetBinContent(
3752  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
3753  h1tmp1->SetBinContent(
3754  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
3755  if (h1tmp0->GetBinContent(iWx + 1)
3756  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
3757  LOG(error) << "WriteHistos: restore unsuccessful! iWx " << iWx
3758  << " got " << h1tmp0->GetBinContent(iWx + 1)
3759  << ", expected "
3760  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
3761  }
3762  }
3763  h1tmp0->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
3764  iSmType,
3765  iSm,
3766  iRpc,
3767  iCh));
3768  // htmp0->Write();
3769  h1tmp0->Write();
3770  h1tmp1->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
3771  iSmType,
3772  iSm,
3773  iRpc,
3774  iCh));
3775  // htmp1->Write();
3776  h1tmp1->Write();
3777  }
3778  } break;
3779 
3780  case 3: //update offsets, gains, save walks and DELTOF
3781  {
3782  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
3783  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
3784  if ((fCalSmAddr < 0)
3785  || (fCalSmAddr
3786  != iSmAddr)) { // select detectors for updating offsets
3787  LOG(info) << Form("calMode==3: update Offsets and Gains, keep Walk "
3788  "and DelTof for 0x%08x, ",
3789  iSmAddr)
3790  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc " << iRpc
3791  << " with " << iNbCh << " channels "
3792  << " using selector " << fCalSel;
3793  /*
3794  Double_t dTRefMean=0.;
3795  if (5 == iSmType && fTRefMode%10 == iSm){ // reference counter
3796  dTRefMean=htempTOff->GetMean(2);
3797  }
3798  */
3799  Double_t dVscal = 1.;
3800  Double_t dVW = 1.;
3801  if (0) // NULL != fhSmCluSvel[iSmType])
3802  {
3803  dVscal =
3804  fhSmCluSvel[iSmType]->GetBinContent(iSm * iNbRpc + iRpc + 1);
3805  if (dVscal == 0.) dVscal = 1.;
3806  dVW = fhSmCluSvel[iSmType]->GetBinEffectiveEntries(iSm * iNbRpc
3807  + iRpc + 1);
3808  dVW *= 50.; //(Double_t)iNbCh;
3809  if (dVW < 0.1) dVW = 0.1;
3810  }
3811 
3812  // determine average values
3813  htempPos_py =
3814  htempPos->ProjectionY(Form("%s_py", htempPos->GetName()), 1, iNbCh);
3815  LOG(info) << Form("Inspect histo %s with %d entries",
3816  htempPos->GetName(),
3817  (Int_t) htempPos_py->GetEntries());
3818  Double_t dYMeanAv = 0.;
3819  Double_t dYMeanFit = 0.;
3820  if (htempPos_py->GetEntries() > fdYFitMin && fPosYMaxScal < 1.1) {
3821  dYMeanAv = htempPos_py->GetMean();
3822  LOG(debug1) << Form("Determine YMeanAv in %s by fit to %d entries",
3823  htempPos->GetName(),
3824  (Int_t) htempPos_py->GetEntries());
3825  CbmTofDetectorInfo xDetInfo(
3826  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, 0);
3827  Int_t iChId = fTofId->SetDetectorInfo(xDetInfo);
3828  fChannelInfo = fDigiPar->GetCell(iChId);
3829  if (NULL == fChannelInfo) {
3830  LOG(warning) << Form("invalid ChannelInfo for 0x%08x", iChId);
3831  continue;
3832  }
3833  fit_ybox(htempPos_py, 0.5 * fChannelInfo->GetSizey());
3834  TF1* ff = htempPos_py->GetFunction("YBox");
3835  if (NULL != ff) {
3836  if (TMath::Abs(fChannelInfo->GetSizey()
3837  - 2. * ff->GetParameter(1))
3838  / fChannelInfo->GetSizey()
3839  < 0.2
3840  && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1))
3841  < 0.2) {
3842  Double_t dV = dVscal * fChannelInfo->GetSizey()
3843  / (2. * ff->GetParameter(1));
3844  LOG(info) << "FAvRes YBox " << htempPos_py->GetEntries()
3845  << " entries in TSR " << iSmType << iSm << iRpc
3846  << ", stat: " << gMinuit->fCstatu << ", chi2 "
3847  << ff->GetChisquare() / ff->GetNDF()
3848  << Form(", striplen (%5.2f): %7.2f+/-%5.2f, pos res "
3849  "%5.2f+/-%5.2f at y_cen = %5.2f+/-%5.2f",
3851  2. * ff->GetParameter(1),
3852  2. * ff->GetParError(1),
3853  ff->GetParameter(2),
3854  ff->GetParError(2),
3855  ff->GetParameter(3),
3856  ff->GetParError(3));
3857  if (TMath::Abs(ff->GetParameter(3) - dYMeanAv)
3858  < 0.5 * fChannelInfo->GetSizey()) {
3859  dYMeanFit = ff->GetParameter(3);
3860  fhSmCluSvel[iSmType]->Fill(
3861  (Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3862  for (Int_t iPar = 0; iPar < 4; iPar++)
3863  fhSmCluFpar[iSmType][iPar]->Fill(
3864  (Double_t)(iSm * iNbRpc + iRpc),
3865  ff->GetParameter(2 + iPar));
3866  }
3867  } else {
3868  LOG(info)
3869  << "FAvBad YBox " << htempPos_py->GetEntries()
3870  << " entries in TSR " << iSmType << iSm << iRpc << ", chi2 "
3871  << ff->GetChisquare()
3872 
3873  << Form(", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos res "
3874  "%5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3876  dVscal,
3877  2. * ff->GetParameter(1),
3878  2. * ff->GetParError(1),
3879  ff->GetParameter(2),
3880  ff->GetParError(2),
3881  ff->GetParameter(3),
3882  ff->GetParError(3));
3883  }
3884  } else {
3885  LOG(info) << "FAvFailed for TSR " << iSmType << iSm << iRpc;
3886  }
3887  }
3888  Double_t dYShift = dYMeanFit - dYMeanAv;
3889 
3890  if (!(fSel2Addr == iSmAddr
3891  && fTRefMode > 10)) // condition parameter update
3892  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // update Offset and Gain
3893  {
3894  Double_t YMean = ((TProfile*) htempPos_pfx)
3895  ->GetBinContent(iCh + 1); //set default
3896  YMean += dYShift;
3897 
3898  htempPos_py = htempPos->ProjectionY(
3899  Form("%s_py%02d", htempPos->GetName(), iCh), iCh + 1, iCh + 1);
3900  if (htempPos_py->GetEntries() > fdYFitMin
3901  && fPosYMaxScal < -1.1) { //disabled
3902  LOG(debug1) << Form(
3903  "Determine YMean in %s of channel %d by fit to %d entries",
3904  htempPos->GetName(),
3905  iCh,
3906  (Int_t) htempPos_py->GetEntries());
3907  CbmTofDetectorInfo xDetInfo(
3908  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, iCh);
3909  Int_t iChId = fTofId->SetDetectorInfo(xDetInfo);
3910  fChannelInfo = fDigiPar->GetCell(iChId);
3911  if (NULL == fChannelInfo) {
3912  LOG(warning) << Form("invalid ChannelInfo for 0x%08x", iChId);
3913  continue;
3914  }
3915  Double_t fp[4] = {1., 3 * 0.}; // initialize fit parameter
3916  for (Int_t iPar = 2; iPar < 4; iPar++)
3917  if (NULL != fhSmCluFpar[iSmType][iPar])
3918  fp[iPar] = fhSmCluFpar[iSmType][iPar]->GetBinContent(
3919  iSm * iNbRpc + iRpc + 1);
3920  //LOG(info) << Form("Call yFit with %6.3f, %6.3f, %6.3f, %6.3f",fp[0],fp[1],fp[2],fp[3])
3921  // ;
3922  Double_t* fpp = &fp[0];
3923  fit_ybox(htempPos_py, 0.5 * fChannelInfo->GetSizey(), fpp);
3924  TF1* ff = htempPos_py->GetFunction("YBox");
3925  if (NULL != ff) {
3926  if (TMath::Abs(fChannelInfo->GetSizey()
3927  - 2. * ff->GetParameter(1))
3928  / fChannelInfo->GetSizey()
3929  < 0.1
3930  && TMath::Abs(ff->GetParError(1) / ff->GetParameter(1))
3931  < 0.05)
3932  //&& ff->GetChisquare() < 200.) //FIXME - constants!
3933  {
3934  if (TMath::Abs(ff->GetParameter(3) - YMean)
3935  < 0.5 * fChannelInfo->GetSizey()) {
3936  YMean = ff->GetParameter(3);
3937  Double_t dV = dVscal * fChannelInfo->GetSizey()
3938  / (2. * ff->GetParameter(1));
3939  fhSmCluSvel[iSmType]->Fill(
3940  (Double_t)(iSm * iNbRpc + iRpc), dV, dVW);
3941  LOG(info)
3942  << "FRes YBox " << htempPos_py->GetEntries()
3943  << " entries in " << iSmType << iSm << iRpc << iCh
3944  << ", chi2 " << ff->GetChisquare()
3945  << Form(", striplen (%5.2f), %4.2f -> %4.2f, %4.1f: "
3946  "%7.2f+/-%5.2f, pos res %5.2f+/-%5.2f at y_cen "
3947  "= %5.2f+/-%5.2f",
3949  dVscal,
3950  dV,
3951  dVW,
3952  2. * ff->GetParameter(1),
3953  2. * ff->GetParError(1),
3954  ff->GetParameter(2),
3955  ff->GetParError(2),
3956  ff->GetParameter(3),
3957  ff->GetParError(3));
3958  for (Int_t iPar = 0; iPar < 4; iPar++)
3959  fhSmCluFpar[iSmType][iPar]->Fill(
3960  (Double_t)(iSm * iNbRpc + iRpc),
3961  ff->GetParameter(2 + iPar));
3962  }
3963  } else {
3964  //YMean=0.; // no new info available - did not help!
3965  LOG(info)
3966  << "FBad YBox " << htempPos_py->GetEntries()
3967  << " entries in " << iSmType << iSm << iRpc << iCh
3968  << ", chi2 " << ff->GetChisquare()
3969  << Form(", striplen (%5.2f), %4.2f: %7.2f +/- %5.2f, pos "
3970  "res %5.2f +/- %5.2f at y_cen = %5.2f +/- %5.2f",
3972  dVscal,
3973  2. * ff->GetParameter(1),
3974  2. * ff->GetParError(1),
3975  ff->GetParameter(2),
3976  ff->GetParError(2),
3977  ff->GetParameter(3),
3978  ff->GetParError(3));
3979  }
3980  }
3981  }
3982 
3983  Double_t TMean =
3984  ((TProfile*) htempTOff_pfx)->GetBinContent(iCh + 1);
3985  Double_t dTYOff =
3986  YMean / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
3987 
3988  /*
3989  if (fSel2Addr == iSmAddr) {
3990  //if (fSel2Id == iSmType && fSel2Sm == iSm && fSel2Rpc == iRpc) {
3991  // don't shift reference counter on average
3992  //TMean-=((TProfile *)hAvTOff_pfx)->GetBinContent(iSm+1);
3993  }
3994  */
3995 
3996  if (htempTOff_px->GetBinContent(iCh + 1) > WalkNHmin) {
3997  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] +=
3998  -dTYOff + TMean;
3999  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] +=
4000  +dTYOff + TMean;
4001  if (iCh == 10)
4002  LOG(info)
4003  << Form("Calib: TSRC %d%d%d%d, hits %6.0f, dTY %8.3f, TM "
4004  "%8.3f -> new Off %8.3f,%8.3f ",
4005  iSmType,
4006  iSm,
4007  iRpc,
4008  iCh,
4009  htempTOff_px->GetBinContent(iCh + 1),
4010  dTYOff,
4011  TMean,
4012  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4013  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4014  }
4015  /*
4016  Double_t TotMean=((TProfile *)htempTot_pfx)->GetBinContent(iCh+1); //nh +1 empirical(!)
4017  if(0.001 < TotMean){
4018  fvCPTotGain[iSmType][iSm*iNbRpc+iRpc][iCh][0] *= fdTTotMean / TotMean;
4019  fvCPTotGain[iSmType][iSm*iNbRpc+iRpc][iCh][1] *= fdTTotMean / TotMean;
4020  }
4021  */
4022  for (Int_t iSide = 0; iSide < 2; iSide++) {
4023  Int_t ib = iCh * 2 + 1 + iSide;
4024  TH1* hbin = htempTot->ProjectionY(Form("bin%d", ib), ib, ib);
4025  if (100 > hbin->GetEntries())
4026  continue; //request min number of entries
4027  /* Double_t Ymax=hbin->GetMaximum();*/
4028  Int_t iBmax = hbin->GetMaximumBin();
4029  TAxis* xaxis = hbin->GetXaxis();
4030  Double_t Xmax =
4031  xaxis->GetBinCenter(iBmax)
4032  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4033  Double_t XOff = Xmax - fTotPreRange;
4034  if (
4035  0) { //TMath::Abs(XOff - fvCPTotOff[iSmType][iSm*iNbRpc+iRpc][iCh][iSide])>100){
4036  LOG(warning)
4037  << "XOff changed for "
4038  << Form(
4039  "SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f",
4040  iSmType,
4041  iSm,
4042  iRpc,
4043  iSide,
4044  XOff,
4045  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4046  }
4047  // Double_t TotMean=htempTot_Mean->GetBinContent(ib);
4048  Double_t TotMean = hbin->GetMean();
4049  if (15 == iSmType) {
4050  LOG(warning)
4051  << "Gain for "
4052  << Form(
4053  "SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4054  "gain %f, modg %f ",
4055  iSmType,
4056  iSm,
4057  iRpc,
4058  iSide,
4059  TotMean,
4060  htempTot_Mean->GetBinContent(ib),
4061  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide],
4062  fdTTotMean / TotMean);
4063  }
4064  if (0.001 < TotMean) {
4065  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
4066  fdTTotMean / TotMean;
4067  }
4068  }
4069  if (5 == iSmType
4070  && fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4071  != fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh]
4072  [1]) { // diamond
4073  LOG(warning)
4074  << "CbmTofCosmicClusterizer::FillCalHist:"
4075  << " SmT " << iSmType << " Sm " << iSm << " Rpc " << iRpc
4076  << " Ch " << iCh << ": YMean " << YMean << ", TMean " << TMean
4077  << " -> "
4078  << Form(" %f %f %f %f ",
4079  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4080  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4081  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4082  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4083  Double_t dTOff =
4084  0.5
4085  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4086  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4087  Double_t dGain =
4088  0.5
4089  * (fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4090  + fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4091  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4092  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4093  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4094  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4095  } // diamond warning end
4096  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
4097  } // iSmType selection condition
4098 
4099  htempPos_pfx->Reset(); //reset to store new values
4100  htempTOff_pfx->Reset();
4101  htempTot_Mean->Reset();
4102  htempTot_Off->Reset();
4103  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // store new values
4104  {
4105  Double_t YMean = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * 0.5
4106  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4107  - fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4108  Double_t TMean = 0.5
4109  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4110  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4111  htempPos_pfx->Fill(iCh, YMean);
4112  if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4113  LOG(error) << "WriteHistos: restore unsuccessful! ch " << iCh
4114  << " got " << htempPos_pfx->GetBinContent(iCh) << ","
4115  << htempPos_pfx->GetBinContent(iCh + 1) << ","
4116  << htempPos_pfx->GetBinContent(iCh + 2) << ", expected "
4117  << YMean;
4118  }
4119  htempTOff_pfx->Fill(iCh, TMean);
4120 
4121  for (Int_t iSide = 0; iSide < 2; iSide++) {
4122  htempTot_Mean->SetBinContent(
4123  iCh * 2 + 1 + iSide,
4124  fdTTotMean
4125  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4126  htempTot_Off->SetBinContent(
4127  iCh * 2 + 1 + iSide,
4128  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4129  }
4130  // htempTot_pfx->Fill(iCh,fdTTotMean/fvCPTotGain[iSmType][iSm*iNbRpc+iRpc][iCh][1]);
4131  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
4132 
4133 
4134  LOG(debug1) << " Updating done ... write to file ";
4135  htempPos_pfx->Write();
4136  htempTOff_pfx->Write();
4137  // htempTot_pfx->Write();
4138  htempTot_Mean->Write();
4139  htempTot_Off->Write();
4140 
4141  // store old DELTOF histos
4142  LOG(debug) << " Copy old DelTof histos from " << gDirectory->GetName()
4143  << " to file ";
4144 
4145  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
4146  // Store DelTof corrections
4147  TDirectory* curdir = gDirectory;
4148  gROOT->cd(); //
4149  TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4150  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4151  iSmType,
4152  iSm,
4153  iRpc,
4154  iSel));
4155  gDirectory->cd(curdir->GetPath());
4156  if (NULL != hCorDelTof) {
4157  TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4158  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4159  iSmType,
4160  iSm,
4161  iRpc,
4162  iSel));
4163  hCorDelTofout->Write();
4164  } else {
4165  LOG(debug) << " No CorDelTof histo "
4166  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4167  iSmType,
4168  iSm,
4169  iRpc,
4170  iSel);
4171  }
4172  }
4173 
4174  LOG(debug) << " Store old walk histos to file ";
4175  // store walk histos
4176  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // restore old values
4177  {
4178  if (NULL == fhRpcCluWalk[iDetIndx][iCh][0]) break;
4179  // TProfile *htmp0 = fhRpcCluWalk[iDetIndx][iCh][0]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
4180  // TProfile *htmp1 = fhRpcCluWalk[iDetIndx][iCh][1]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
4181  TH1D* h1tmp0 =
4182  fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX("_px", 1, nbClWalkBinY);
4183  TH1D* h1tmp1 =
4184  fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX("_px", 1, nbClWalkBinY);
4185  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
4186  h1tmp0->SetBinContent(
4187  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4188  h1tmp1->SetBinContent(
4189  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4190  if (h1tmp0->GetBinContent(iWx + 1)
4191  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4192  LOG(error) << "WriteHistos: restore unsuccessful! iWx " << iWx
4193  << " got " << h1tmp0->GetBinContent(iWx + 1)
4194  << ", expected "
4195  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4196  }
4197  }
4198  h1tmp0->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4199  iSmType,
4200  iSm,
4201  iRpc,
4202  iCh));
4203  // htmp0->Write();
4204  h1tmp0->Write();
4205  h1tmp1->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4206  iSmType,
4207  iSm,
4208  iRpc,
4209  iCh));
4210  // htmp1->Write();
4211  h1tmp1->Write();
4212  }
4213  } break;
4214 
4215  case 4: //update DelTof, save offsets, gains and walks
4216  {
4217  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
4218  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
4219  LOG(debug)
4220  << "WriteHistos: restore Offsets, Gains and Walk, save DelTof for "
4221  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc " << iRpc;
4222  htempPos_pfx->Reset(); //reset to restore mean of original histos
4223  htempTOff_pfx->Reset();
4224  htempTot_Mean->Reset();
4225  htempTot_Off->Reset();
4226  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
4227  Double_t YMean = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * 0.5
4228  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4229  - fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4230  Double_t TMean = 0.5
4231  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4232  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4233  htempPos_pfx->Fill(iCh, YMean);
4234  if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4235  LOG(error) << "WriteHistos: restore unsuccessful! ch " << iCh
4236  << " got " << htempPos_pfx->GetBinContent(iCh) << ","
4237  << htempPos_pfx->GetBinContent(iCh + 1) << ","
4238  << htempPos_pfx->GetBinContent(iCh + 2) << ", expected "
4239  << YMean;
4240  }
4241  htempTOff_pfx->Fill(iCh, TMean);
4242 
4243  for (Int_t iSide = 0; iSide < 2; iSide++) {
4244  htempTot_Mean->SetBinContent(
4245  iCh * 2 + 1 + iSide,
4246  fdTTotMean
4247  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh]
4248  [iSide]); //nh +1 empirical(?)
4249  htempTot_Off->SetBinContent(
4250  iCh * 2 + 1 + iSide,
4251  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4252  }
4253  }
4254 
4255  LOG(debug1) << " Restoring of Offsets and Gains done ... ";
4256  htempPos_pfx->Write();
4257  htempTOff_pfx->Write();
4258  // htempTot_pfx->Write();
4259  htempTot_Mean->Write();
4260  htempTot_Off->Write();
4261 
4262  // restore walk histos
4263  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // restore old values
4264  {
4265  if (NULL == fhRpcCluWalk[iDetIndx][iCh][0]) break;
4266  // TProfile *htmp0 = fhRpcCluWalk[iDetIndx][iCh][0]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
4267  // TProfile *htmp1 = fhRpcCluWalk[iDetIndx][iCh][1]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
4268  TH1D* h1tmp0 =
4269  fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX("_px", 1, nbClWalkBinY);
4270  TH1D* h1tmp1 =
4271  fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX("_px", 1, nbClWalkBinY);
4272  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
4273  h1tmp0->SetBinContent(
4274  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4275  h1tmp1->SetBinContent(
4276  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4277  if (h1tmp0->GetBinContent(iWx + 1)
4278  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4279  LOG(error) << "WriteHistos: restore unsuccessful! iWx " << iWx
4280  << " got " << h1tmp0->GetBinContent(iWx + 1)
4281  << ", expected "
4282  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4283  }
4284  }
4285  h1tmp0->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4286  iSmType,
4287  iSm,
4288  iRpc,
4289  iCh));
4290  // htmp0->Write();
4291  h1tmp0->Write();
4292  h1tmp1->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4293  iSmType,
4294  iSm,
4295  iRpc,
4296  iCh));
4297  // htmp1->Write();
4298  h1tmp1->Write();
4299  }
4300 
4301  // generate/update DelTof corrections
4302  if (
4303  (fCalSmAddr < 0 && -fCalSmAddr != iSmAddr)
4304  || (fCalSmAddr
4305  == iSmAddr)) // select detectors for determination of DelTof correction
4306  {
4307  // if( fSel2Id == iSmType ) continue; // no DelTof correction for Diamonds
4308 
4309  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
4310  TH2* h2tmp = fhTRpcCluDelTof[iDetIndx][iSel];
4311  if (NULL == h2tmp) {
4312  LOG(debug) << Form(
4313  "WriteHistos: histo not available for SmT %d, Sm %d, Rpc %d",
4314  iSmType,
4315  iSm,
4316  iRpc);
4317  break;
4318  }
4319  Int_t iNEntries = h2tmp->GetEntries();
4320 
4321  // h2tmp->Write();
4322  TProfile* htmp = h2tmp->ProfileX("_pfx", 1, h2tmp->GetNbinsY());
4323  TH1D* h1tmp = h2tmp->ProjectionX("_px", 1, h2tmp->GetNbinsY());
4324  /* TH1D *h1ytmp = h2tmp->ProjectionY("_py",1,h2tmp->GetNbinsX());*/
4325  Double_t dDelMean =
4326  0.; //h1ytmp->GetMean();// inspect normalization, interferes with mode 3 for diamonds, nh, 10.01.2015 (?)
4327  for (Int_t iBx = 0; iBx < nbClDelTofBinX; iBx++) {
4328  Double_t dNEntries = h1tmp->GetBinContent(iBx + 1);
4329  if (dNEntries
4330  > WalkNHmin) // modify, request sufficient # of entries
4331  fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel] +=
4332  ((TProfile*) htmp)->GetBinContent(iBx + 1);
4333  dDelMean += fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel];
4334  }
4335  dDelMean /= (Double_t) nbClDelTofBinX;
4336 
4337  LOG(debug) << Form(" Update DelTof correction for SmT %d, Sm %d, "
4338  "Rpc %d, Sel%d: Entries %d, Mean shift %6.1f",
4339  iSmType,
4340  iSm,
4341  iRpc,
4342  iSel,
4343  iNEntries,
4344  dDelMean);
4345 
4346  for (Int_t iBx = 0; iBx < nbClDelTofBinX; iBx++) {
4347  //h1tmp->SetBinContent(iBx+1,fvCPDelTof[iSmType][iSm*iNbRpc+iRpc][iBx][iSel]-dDelMean);
4348  h1tmp->SetBinContent(
4349  iBx + 1, fvCPDelTof[iSmType][iSm * iNbRpc + iRpc][iBx][iSel]);
4350  }
4351  h1tmp->SetName(Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4352  iSmType,
4353  iSm,
4354  iRpc,
4355  iSel));
4356  h1tmp->Write();
4357  }
4358  } else { // copy existing histograms
4359  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
4360  // Store DelTof corrections
4361  TDirectory* curdir = gDirectory;
4362  gROOT->cd(); //
4363  TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4364  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4365  iSmType,
4366  iSm,
4367  iRpc,
4368  iSel));
4369  gDirectory->cd(curdir->GetPath());
4370  if (NULL != hCorDelTof) {
4371  TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4372  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4373  iSmType,
4374  iSm,
4375  iRpc,
4376  iSel));
4377  LOG(debug) << " Save existing CorDelTof histo "
4378  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4379  iSmType,
4380  iSm,
4381  iRpc,
4382  iSel);
4383  hCorDelTofout->Write();
4384  } else {
4385  LOG(debug) << " No CorDelTof histo "
4386  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4387  iSmType,
4388  iSm,
4389  iRpc,
4390  iSel);
4391  }
4392  }
4393  }
4394  } break;
4395  case 5: //update offsets (from positions only), gains, save walks and DELTOF
4396  {
4397  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
4398  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
4399  if ((fCalSmAddr < 0)
4400  || (fCalSmAddr
4401  != iSmAddr)) { // select detectors for updating offsets
4402  LOG(info) << "WriteHistos (calMode==3): update Offsets and Gains, "
4403  "keep Walk and DelTof for "
4404  << "Smtype" << iSmType << ", Sm " << iSm << ", Rpc " << iRpc
4405  << " with " << iNbCh << " channels "
4406  << " using selector " << fCalSel;
4407 
4408  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // update Offset and Gain
4409  {
4410  Double_t YMean = ((TProfile*) htempPos_pfx)
4411  ->GetBinContent(iCh + 1); //nh +1 empirical(?)
4412  Double_t TMean = 0.;
4413  Double_t dTYOff =
4414  YMean / fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc);
4415 
4416 
4417  if (htempTOff_px->GetBinContent(iCh + 1) > WalkNHmin) {
4418  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
4419  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
4420  }
4421  LOG(debug3) << Form(
4422  "Calib: TSRC %d%d%d%d, hits %6.0f, new Off %8.0f,%8.0f ",
4423  iSmType,
4424  iSm,
4425  iRpc,
4426  iCh,
4427  htempTOff_px->GetBinContent(iCh + 1),
4428  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4429  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4430 
4431  /*
4432  Double_t TotMean=((TProfile *)htempTot_pfx)->GetBinContent(iCh+1); //nh +1 empirical(!)
4433  if(0.001 < TotMean){
4434  fvCPTotGain[iSmType][iSm*iNbRpc+iRpc][iCh][0] *= fdTTotMean / TotMean;
4435  fvCPTotGain[iSmType][iSm*iNbRpc+iRpc][iCh][1] *= fdTTotMean / TotMean;
4436  }
4437  */
4438  for (Int_t iSide = 0; iSide < 2; iSide++) {
4439  Int_t ib = iCh * 2 + 1 + iSide;
4440  TH1* hbin = htempTot->ProjectionY(Form("bin%d", ib), ib, ib);
4441  if (100 > hbin->GetEntries())
4442  continue; //request min number of entries
4443  /* Double_t Ymax=hbin->GetMaximum();*/
4444  Int_t iBmax = hbin->GetMaximumBin();
4445  TAxis* xaxis = hbin->GetXaxis();
4446  Double_t Xmax =
4447  xaxis->GetBinCenter(iBmax)
4448  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide];
4449  Double_t XOff = Xmax - fTotPreRange;
4450  if (
4451  0) { //TMath::Abs(XOff - fvCPTotOff[iSmType][iSm*iNbRpc+iRpc][iCh][iSide])>100){
4452  LOG(warning)
4453  << "XOff changed for "
4454  << Form("SmT%01d_sm%03d_rpc%03d_Side%d: XOff %f, old %f",
4455  iSmType,
4456  iSm,
4457  iRpc,
4458  iSide,
4459  XOff,
4460  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4461  }
4462  // Double_t TotMean=htempTot_Mean->GetBinContent(ib);
4463  Double_t TotMean = hbin->GetMean();
4464  if (15 == iSmType) {
4465  LOG(warning)
4466  << "Gain for "
4467  << Form("SmT%01d_sm%03d_rpc%03d_Side%d: TotMean %f, prof %f, "
4468  "gain %f, modg %f ",
4469  iSmType,
4470  iSm,
4471  iRpc,
4472  iSide,
4473  TotMean,
4474  htempTot_Mean->GetBinContent(ib),
4475  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide],
4476  fdTTotMean / TotMean);
4477  }
4478  if (0.001 < TotMean) {
4479  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *=
4480  fdTTotMean / TotMean;
4481  }
4482  }
4483  if (5 == iSmType
4484  && fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4485  != fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh]
4486  [1]) { // diamond
4487  LOG(warning)
4488  << "CbmTofCosmicClusterizer::FillCalHist:"
4489  << " SmT " << iSmType << " Sm " << iSm << " Rpc " << iRpc
4490  << " Ch " << iCh << ": YMean " << YMean << ", TMean " << TMean
4491  << " -> "
4492  << Form(" %f %f %f %f ",
4493  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4494  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1],
4495  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0],
4496  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4497  Double_t dTOff =
4498  0.5
4499  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4500  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4501  Double_t dGain =
4502  0.5
4503  * (fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0]
4504  + fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
4505  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dTOff;
4506  fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dTOff;
4507  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][0] = dGain;
4508  fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][1] = dGain;
4509  } // diamond warning end
4510  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
4511  } // iSmType selection condition
4512 
4513  htempPos_pfx->Reset(); //reset to store new values
4514  htempTOff_pfx->Reset();
4515  htempTot_Mean->Reset();
4516  htempTot_Off->Reset();
4517  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // store new values
4518  {
4519  Double_t YMean = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * 0.5
4520  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4521  - fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4522  Double_t TMean = 0.5
4523  * (fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]
4524  + fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0]);
4525  htempPos_pfx->Fill(iCh, YMean);
4526  if (((TProfile*) htempPos_pfx)->GetBinContent(iCh + 1) != YMean) {
4527  LOG(error) << "WriteHistos: restore unsuccessful! ch " << iCh
4528  << " got " << htempPos_pfx->GetBinContent(iCh) << ","
4529  << htempPos_pfx->GetBinContent(iCh + 1) << ","
4530  << htempPos_pfx->GetBinContent(iCh + 2) << ", expected "
4531  << YMean;
4532  }
4533  htempTOff_pfx->Fill(iCh, TMean);
4534 
4535  for (Int_t iSide = 0; iSide < 2; iSide++) {
4536  htempTot_Mean->SetBinContent(
4537  iCh * 2 + 1 + iSide,
4538  fdTTotMean
4539  / fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4540  htempTot_Off->SetBinContent(
4541  iCh * 2 + 1 + iSide,
4542  fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide]);
4543  }
4544  // htempTot_pfx->Fill(iCh,fdTTotMean/fvCPTotGain[iSmType][iSm*iNbRpc+iRpc][iCh][1]);
4545  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
4546 
4547 
4548  LOG(debug1) << " Updating done ... write to file ";
4549  htempPos_pfx->Write();
4550  htempTOff_pfx->Write();
4551  // htempTot_pfx->Write();
4552  htempTot_Mean->Write();
4553  htempTot_Off->Write();
4554 
4555  // store old DELTOF histos
4556  LOG(debug) << " Copy old DelTof histos from " << gDirectory->GetName()
4557  << " to file ";
4558 
4559  for (Int_t iSel = 0; iSel < iNSel; iSel++) {
4560  // Store DelTof corrections
4561  TDirectory* curdir = gDirectory;
4562  gROOT->cd(); //
4563  TH1D* hCorDelTof = (TH1D*) gDirectory->FindObjectAny(
4564  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4565  iSmType,
4566  iSm,
4567  iRpc,
4568  iSel));
4569  gDirectory->cd(curdir->GetPath());
4570  if (NULL != hCorDelTof) {
4571  TH1D* hCorDelTofout = (TH1D*) hCorDelTof->Clone(
4572  Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4573  iSmType,
4574  iSm,
4575  iRpc,
4576  iSel));
4577  hCorDelTofout->Write();
4578  } else {
4579  LOG(debug) << " No CorDelTof histo "
4580  << Form("cl_CorSmT%01d_sm%03d_rpc%03d_Sel%02d_DelTof",
4581  iSmType,
4582  iSm,
4583  iRpc,
4584  iSel);
4585  }
4586  }
4587 
4588  LOG(debug) << " Store old walk histos to file ";
4589  // store walk histos
4590  for (Int_t iCh = 0; iCh < iNbCh; iCh++) // restore old values
4591  {
4592  if (NULL == fhRpcCluWalk[iDetIndx][iCh][0]) break;
4593  // TProfile *htmp0 = fhRpcCluWalk[iDetIndx][iCh][0]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
4594  // TProfile *htmp1 = fhRpcCluWalk[iDetIndx][iCh][1]->ProfileX("_pfx",1,nbClWalkBinY); (VF) not used
4595  TH1D* h1tmp0 =
4596  fhRpcCluWalk[iDetIndx][iCh][0]->ProjectionX("_px", 1, nbClWalkBinY);
4597  TH1D* h1tmp1 =
4598  fhRpcCluWalk[iDetIndx][iCh][1]->ProjectionX("_px", 1, nbClWalkBinY);
4599  for (Int_t iWx = 0; iWx < nbClWalkBinX; iWx++) {
4600  h1tmp0->SetBinContent(
4601  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]);
4602  h1tmp1->SetBinContent(
4603  iWx + 1, fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][1][iWx]);
4604  if (h1tmp0->GetBinContent(iWx + 1)
4605  != fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx]) {
4606  LOG(error) << "WriteHistos: restore unsuccessful! iWx " << iWx
4607  << " got " << h1tmp0->GetBinContent(iWx + 1)
4608  << ", expected "
4609  << fvCPWalk[iSmType][iSm * iNbRpc + iRpc][iCh][0][iWx];
4610  }
4611  }
4612  h1tmp0->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px",
4613  iSmType,
4614  iSm,
4615  iRpc,
4616  iCh));
4617  // htmp0->Write();
4618  h1tmp0->Write();
4619  h1tmp1->SetName(Form("Cor_SmT%01d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",
4620  iSmType,
4621  iSm,
4622  iRpc,
4623  iCh));
4624  // htmp1->Write();
4625  h1tmp1->Write();
4626  }
4627  } break;
4628 
4629 
4630  default:
4631  LOG(debug) << "WriteHistos: update mode " << fCalMode
4632  << " not yet implemented";
4633  }
4634  }
4635 
4636  // fhCluMulCorDutSel->Write();
4637 
4638  // fhDigSpacDifClust->Write();
4639  // fhDigTimeDifClust->Write();
4640  // fhDigDistClust->Write();
4641 
4642  // fhClustSizeDifX->Write();
4643  // fhClustSizeDifY->Write();
4644 
4645  // fhChDifDifX->Write();
4646  // fhChDifDifY->Write();
4647 
4648  // fhNbSameSide->Write();
4649  // fhNbDigiPerChan->Write();
4650 
4651 
4652  // fhHitsPerTracks->Write();
4653  if (kFALSE == fDigiBdfPar->ClustUseTrackId())
4654  // fhPtsPerHit->Write();
4655  // fhTimeResSingHits->Write();
4656  // fhTimeResSingHitsB->Write();
4657  // fhTimePtVsHits->Write();
4658  // fhClusterSize->Write();
4659  // fhClusterSizeType->Write();
4660  if (kTRUE == fDigiBdfPar->ClustUseTrackId()) {
4661  // fhTrackMul->Write();
4662  // fhClusterSizeMulti->Write();
4663  // fhTrk1MulPos->Write();
4664  // fhHiTrkMulPos->Write();
4665  // fhAllTrkMulPos->Write();
4666  // fhMultiTrkProbPos->Divide( fhHiTrkMulPos, fhAllTrkMulPos);
4667  // fhMultiTrkProbPos->Scale( 100.0 );
4668  // fhMultiTrkProbPos->Write();
4669  } // if( kTRUE == fDigiBdfPar->ClustUseTrackId() )
4670 
4671  for (Int_t iS = 0; iS < fDigiBdfPar->GetNbSmTypes(); iS++) {
4672  if (NULL == fhSmCluPosition[iS]) continue;
4673  // fhSmCluPosition[iS]->Write();
4674  // fhSmCluTOff[iS]->Write();
4675  fhSmCluSvel[iS]->Write();
4676  for (Int_t iPar = 0; iPar < 4; iPar++)
4677  fhSmCluFpar[iS][iPar]->Write();
4678 
4679  for (Int_t iSel = 0; iSel < iNSel; iSel++) { // Loop over selectors
4680  // fhTSmCluPosition[iS][iSel]->Write();
4681  // fhTSmCluTOff[iS][iSel]->Write();
4682  // fhTSmCluTRun[iS][iSel]->Write();
4683  }
4684  }
4685 
4686 
4687  gDirectory->cd(oldir->GetPath());
4688 
4689  fHist->Close();
4690 
4691  return kTRUE;
4692 }
4694  delete fhClustBuildTime;
4695  delete fhHitsPerTracks;
4696  delete fhPtsPerHit;
4697  delete fhTimeResSingHits;
4698  delete fhTimeResSingHitsB;
4699  delete fhTimePtVsHits;
4700  delete fhClusterSize;
4701  delete fhClusterSizeType;
4702 
4703  if (kTRUE == fDigiBdfPar->ClustUseTrackId()) {
4704  delete fhTrackMul;
4705  delete fhClusterSizeMulti;
4706  delete fhTrk1MulPos;
4707  delete fhHiTrkMulPos;
4708  delete fhAllTrkMulPos;
4709  delete fhMultiTrkProbPos;
4710  }
4711  delete fhDigSpacDifClust;
4712  delete fhDigTimeDifClust;
4713  delete fhDigDistClust;
4714 
4715  delete fhClustSizeDifX;
4716  delete fhClustSizeDifY;
4717 
4718  delete fhChDifDifX;
4719  delete fhChDifDifY;
4720 
4721  delete fhNbSameSide;
4722  delete fhNbDigiPerChan;
4723 
4724  return kTRUE;
4725 }
4726 /************************************************************************************/
4728  /*
4729  * FIXME: maybe use the 2D distance (X/Y) as criteria instead of the distance long channel
4730  * direction
4731  */
4732  Int_t iMess = 0;
4733  //gGeoManager->SetTopVolume( gGeoManager->FindVolumeFast("tof_v14a") );
4734  gGeoManager->CdTop();
4735 
4736  if (NULL == fTofDigisColl) {
4737  LOG(info) << " No CalDigis defined ! Check! ";
4738  return kFALSE;
4739  }
4740  fiNevtBuild++;
4741  LOG(debug) << "CbmTofCosmicClusterizer::BuildClusters from "
4742  << fTofDigisColl->GetEntries() << " digis in event "
4743  << fiNevtBuild;
4744 
4745  fTRefHits = 0.;
4746 
4747  Int_t iNbTofDigi = fTofDigisColl->GetEntries();
4748  if (kTRUE) {
4749  for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
4750  CbmTofDigi* pDigi = (CbmTofDigi*) fTofDigisColl->At(iDigInd);
4751  LOG(debug) << "#"
4752  << iDigInd
4753  // <<Form(" Address : 0x%08x ",pDigi->GetAddress())
4754  << " TSR " << pDigi->GetType() << pDigi->GetSm()
4755  << pDigi->GetRpc() << " Ch " << pDigi->GetChannel() << " S "
4756  << pDigi->GetSide() << " : " << pDigi->ToString()
4757  // <<" Time "<<pDigi->GetTime()
4758  // <<" Tot " <<pDigi->GetTot()
4759  ;
4760 
4761  Int_t iDetIndx = fDigiBdfPar->GetDetInd(pDigi->GetAddress());
4762 
4763  if (fDigiBdfPar->GetNbDet() - 1 < iDetIndx || iDetIndx < 0) {
4764  LOG(debug) << Form(
4765  " Wrong DetIndx %d >< %d,0 ", iDetIndx, fDigiBdfPar->GetNbDet());
4766  break;
4767  }
4768 
4769  if (NULL == fhRpcDigiCor[iDetIndx]) {
4770  if (100 < iMess++)
4771  LOG(warning) << Form(
4772  " DigiCor Histo for DetIndx %d derived from 0x%08x not found",
4773  iDetIndx,
4774  pDigi->GetAddress());
4775  continue;
4776  }
4777 
4778  Double_t dTDifMin = dDoubleMax;
4779  CbmTofDigi* pDigi2Min = NULL;
4780  // for (Int_t iDigI2 =iDigInd+1; iDigI2<iNbTofDigi;iDigI2++){
4781  for (Int_t iDigI2 = 0; iDigI2 < iNbTofDigi; iDigI2++) {
4782  CbmTofDigi* pDigi2 = (CbmTofDigi*) fTofDigisColl->At(iDigI2);
4783  if (iDetIndx == fDigiBdfPar->GetDetInd(pDigi2->GetAddress())) {
4784  if (0. == pDigi->GetSide() && 1. == pDigi2->GetSide()) {
4785  fhRpcDigiCor[iDetIndx]->Fill(pDigi->GetChannel(),
4786  pDigi2->GetChannel());
4787  } else {
4788  if (1. == pDigi->GetSide() && 0. == pDigi2->GetSide()) {
4789  fhRpcDigiCor[iDetIndx]->Fill(pDigi2->GetChannel(),
4790  pDigi->GetChannel());
4791  }
4792  }
4793  if (pDigi->GetSide() != pDigi2->GetSide()) {
4794  if (pDigi->GetChannel() == pDigi2->GetChannel()) {
4795  Double_t dTDif = TMath::Abs(pDigi->GetTime() - pDigi2->GetTime());
4796  if (dTDif < dTDifMin) {
4797  dTDifMin = dTDif;
4798  pDigi2Min = pDigi2;
4799  }
4800  } else if (
4801  TMath::Abs(pDigi->GetChannel() - pDigi2->GetChannel())
4802  == 1) { // opposite side missing, neighbouring channel has hit on opposite side // FIXME
4803  // check that same side digi of neighbouring channel is absent
4804  LOG(debug) << Form("Missing digi cor %d for TSRC %d%d%d%d ?",
4805  fiCorMode,
4806  (Int_t) pDigi->GetType(),
4807  (Int_t) pDigi->GetSm(),
4808  (Int_t) pDigi->GetRpc(),
4809  (Int_t) pDigi->GetChannel());
4810  Int_t iDigI3 = 0;
4811  for (; iDigI3 < iNbTofDigi; iDigI3++) {
4812  CbmTofDigi* pDigi3 = (CbmTofDigi*) fTofDigisColl->At(iDigI3);
4813  if (iDetIndx == fDigiBdfPar->GetDetInd(pDigi3->GetAddress()))
4814  if (pDigi3->GetSide() == pDigi->GetSide()
4815  && pDigi2->GetChannel() == pDigi3->GetChannel())
4816  break;
4817  }
4818  if (iDigI3 == iNbTofDigi) // same side neighbour did not fire
4819  {
4820  //Int_t fiCorMode=2; // Missing hit correction mode
4821  switch (fiCorMode) {
4822  case 0: // no action
4823  break;
4824  case 1: // shift found hit
4825  LOG(debug2) << Form("shift channel %d%d%d%d%d and ",
4826  (Int_t) pDigi->GetType(),
4827  (Int_t) pDigi->GetSm(),
4828  (Int_t) pDigi->GetRpc(),
4829  (Int_t) pDigi->GetChannel(),
4830  (Int_t) pDigi->GetSide())
4831  << Form(" %d%d%d%d%d ",
4832  (Int_t) pDigi2->GetType(),
4833  (Int_t) pDigi2->GetSm(),
4834  (Int_t) pDigi2->GetRpc(),
4835  (Int_t) pDigi2->GetChannel(),
4836  (Int_t) pDigi2->GetSide());
4837  //if(pDigi->GetTime() < pDigi2->GetTime())
4838  if (pDigi->GetSide() == 0)
4839  pDigi2->SetAddress(pDigi->GetSm(),
4840  pDigi->GetRpc(),
4841  pDigi->GetChannel(),
4842  1 - pDigi->GetSide(),
4843  pDigi->GetType());
4844  else
4845  pDigi->SetAddress(pDigi2->GetSm(),
4846  pDigi2->GetRpc(),
4847  pDigi2->GetChannel(),
4848  1 - pDigi2->GetSide(),
4849  pDigi2->GetType());
4850 
4851  LOG(debug2) << Form("resultchannel %d%d%d%d%d and ",
4852  (Int_t) pDigi->GetType(),
4853  (Int_t) pDigi->GetSm(),
4854  (Int_t) pDigi->GetRpc(),
4855  (Int_t) pDigi->GetChannel(),
4856  (Int_t) pDigi->GetSide())
4857  << Form(" %d%d%d%d%d ",
4858  (Int_t) pDigi2->GetType(),
4859  (Int_t) pDigi2->GetSm(),
4860  (Int_t) pDigi2->GetRpc(),
4861  (Int_t) pDigi2->GetChannel(),
4862  (Int_t) pDigi2->GetSide());
4863  break;
4864  case 2: // insert missing hits
4865 
4866  CbmTofDigi* pDigiN =
4867  new ((*fTofDigisColl)[iNbTofDigi++]) CbmTofDigi(*pDigi);
4868  pDigiN->SetAddress(pDigi->GetSm(),
4869  pDigi->GetRpc(),
4870  pDigi2->GetChannel(),
4871  pDigi->GetSide(),
4872  pDigi->GetType());
4873  pDigiN->SetTot(pDigi2->GetTot());
4874  LOG(debug) << Form("InsertDigi TSRCS %d%d%d%d%d and ",
4875  (Int_t) pDigiN->GetType(),
4876  (Int_t) pDigiN->GetSm(),
4877  (Int_t) pDigiN->GetRpc(),
4878  (Int_t) pDigiN->GetChannel(),
4879  (Int_t) pDigiN->GetSide());
4880 
4881  CbmTofDigi* pDigiN2 =
4882  new ((*fTofDigisColl)[iNbTofDigi++]) CbmTofDigi(*pDigi2);
4883  pDigiN2->SetAddress(pDigi2->GetSm(),
4884  pDigi2->GetRpc(),
4885  pDigi->GetChannel(),
4886  pDigi2->GetSide(),
4887  pDigi2->GetType());
4888  pDigiN2->SetTot(pDigi->GetTot());
4889  LOG(debug) << Form("InsertDigi2 TSRCS %d%d%d%d%d and ",
4890  (Int_t) pDigiN2->GetType(),
4891  (Int_t) pDigiN2->GetSm(),
4892  (Int_t) pDigiN2->GetRpc(),
4893  (Int_t) pDigiN2->GetChannel(),
4894  (Int_t) pDigiN2->GetSide());
4895  break;
4896  }
4897  }
4898  }
4899  }
4900  }
4901  }
4902 
4903  if (pDigi2Min != NULL) {
4905  pDigi->GetType(),
4906  pDigi->GetSm(),
4907  pDigi->GetRpc(),
4908  0,
4909  pDigi->GetChannel());
4910  Int_t iChId = fTofId->SetDetectorInfo(xDetInfo);
4911  fChannelInfo = fDigiPar->GetCell(iChId);
4912  if (NULL == fChannelInfo) {
4913  LOG(warning) << Form("BuildClusters: invalid ChannelInfo for 0x%08x",
4914  iChId);
4915  continue;
4916  }
4917  if (fDigiBdfPar->GetSigVel(
4918  pDigi->GetType(), pDigi->GetSm(), pDigi->GetRpc())
4919  * dTDifMin * 0.5
4921  //check consistency
4922  if (8 == pDigi->GetType() || 5 == pDigi->GetType()) {
4923  if (pDigi->GetTime() != pDigi2Min->GetTime()) {
4924  if (fiMsgCnt-- > 0) {
4925  LOG(warning)
4926  << " BuildClusters: Inconsistent duplicated digis in event "
4927  << fiNevtBuild << ", Ind: " << iDigInd;
4928  LOG(warning) << " " << pDigi->ToString();
4929  LOG(warning) << " " << pDigi2Min->ToString();
4930  }
4931  pDigi2Min->SetTot(pDigi->GetTot());
4932  pDigi2Min->SetTime(pDigi->GetTime());
4933  }
4934  }
4935 
4936  // average ToTs! temporary fix, FIXME
4937  /*
4938  Double_t dAvTot=0.5*(pDigi->GetTot()+pDigi2Min->GetTot());
4939  pDigi->SetTot(dAvTot);
4940  pDigi2Min->SetTot(dAvTot);
4941  LOG(debug)<<" BuildClusters: TDif "<<dTDifMin<<", Average Tot "<<dAvTot;
4942  LOG(debug)<<" "<<pDigi->ToString();
4943  LOG(debug)<<" "<<pDigi2Min->ToString();
4944  */
4945  }
4946  }
4947  }
4948  }
4949 
4950  // First Time order the Digis array
4951  // fTofDigisColl->Sort();
4952 
4953  // Then loop over the digis array and store the Digis in separate vectors for
4954  // each RPC modules
4955 
4956  // Calibrate RawDigis
4957  if (kTRUE == fDigiBdfPar->UseExpandedDigi()) {
4958  CbmTofDigi* pDigi;
4959  CbmTofDigi* pCalDigi = NULL;
4960  Int_t iDigIndCal = -1;
4961  // channel deadtime map
4962  std::map<Int_t, Double_t> mChannelDeadTime;
4963 
4964  for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
4965  pDigi = (CbmTofDigi*) fTofDigisColl->At(iDigInd);
4966  Int_t iAddr = pDigi->GetAddress();
4967 
4968  LOG(debug1) << "BC " // Before Calibration
4969  << Form("0x%08x", pDigi->GetAddress()) << " TSRC "
4970  << pDigi->GetType() << pDigi->GetSm() << pDigi->GetRpc()
4971  << Form("%2d", (Int_t) pDigi->GetChannel()) << " "
4972  << pDigi->GetSide() << " " << Form("%f", pDigi->GetTime())
4973  << " " << pDigi->GetTot();
4974 
4975  if (pDigi->GetType() == 5
4976  || pDigi->GetType()
4977  == 8) // for Pad counters generate fake digi to mockup a strip
4978  if (pDigi->GetSide() == 1)
4979  continue; // skip one side to avoid double entries
4980 
4981  Bool_t bValid = kTRUE;
4982  std::map<Int_t, Double_t>::iterator it;
4983  it = mChannelDeadTime.find(iAddr);
4984  if (it != mChannelDeadTime.end()) {
4985  LOG(debug1) << "CCT found valid ChannelDeadtime entry "
4986  << mChannelDeadTime[iAddr] << ", DeltaT "
4987  << pDigi->GetTime() - mChannelDeadTime[iAddr];
4988  if ((bValid = (pDigi->GetTime()
4989  > mChannelDeadTime[iAddr] + fdChannelDeadtime)))
4990  pCalDigi = new ((*fTofCalDigisColl)[++iDigIndCal]) CbmTofDigi(*pDigi);
4991  } else {
4992  pCalDigi = new ((*fTofCalDigisColl)[++iDigIndCal]) CbmTofDigi(*pDigi);
4993  }
4994  mChannelDeadTime[iAddr] = pDigi->GetTime();
4995  if (!bValid) continue;
4996 
4997 
4998  if (fbPs2Ns) {
4999  pCalDigi->SetTime(pCalDigi->GetTime()
5000  / 1000.); // for backward compatibility
5001  pCalDigi->SetTot(pCalDigi->GetTot()
5002  / 1000.); // for backward compatibility
5003  }
5004 
5005  if (fdTimePeriod > 0.) {
5006  pCalDigi->SetTime(TimeInPeriod(pCalDigi->GetTime())); // for debugging
5007  }
5008 
5009  LOG(debug1) << "DC " // After deadtime check. before Calibration
5010  << Form("0x%08x", pDigi->GetAddress()) << " TSRC "
5011  << pDigi->GetType() << pDigi->GetSm() << pDigi->GetRpc()
5012  << Form("%2d", (Int_t) pDigi->GetChannel()) << " "
5013  << pDigi->GetSide() << " " << Form("%f", pDigi->GetTime())
5014  << " " << pDigi->GetTot();
5015 
5016  if (fDigiBdfPar->GetNbSmTypes()
5017  > pDigi->GetType() // prevent crash due to misconfiguration
5018  && fDigiBdfPar->GetNbSm(pDigi->GetType()) > pDigi->GetSm()
5019  && fDigiBdfPar->GetNbRpc(pDigi->GetType()) > pDigi->GetRpc()
5020  && fDigiBdfPar->GetNbChan(pDigi->GetType(), pDigi->GetRpc())
5021  > pDigi->GetChannel()) {
5022 
5023  LOG(debug2) << " CluCal-Init: " << pDigi->ToString();
5024  // apply calibration vectors
5025  pCalDigi->SetTime(
5026  pCalDigi->GetTime() - // calibrate Digi Time
5027  fvCPTOff[pDigi->GetType()]
5028  [pDigi->GetSm() * fDigiBdfPar->GetNbRpc(pDigi->GetType())
5029  + pDigi->GetRpc()][pDigi->GetChannel()][pDigi->GetSide()]);
5030  LOG(debug2) << " CluCal-TOff: " << pCalDigi->ToString();
5031 
5032  Double_t dTot =
5033  pCalDigi->GetTot() - // subtract Offset
5034  fvCPTotOff[pDigi->GetType()]
5035  [pDigi->GetSm() * fDigiBdfPar->GetNbRpc(pDigi->GetType())
5036  + pDigi->GetRpc()][pDigi->GetChannel()][pDigi->GetSide()];
5037  if (dTot < 0.001) dTot = 0.001;
5038  pCalDigi->SetTot(
5039  dTot * // calibrate Digi ToT
5040  fvCPTotGain[pDigi->GetType()]
5041  [pDigi->GetSm() * fDigiBdfPar->GetNbRpc(pDigi->GetType())
5042  + pDigi->GetRpc()][pDigi->GetChannel()]
5043  [pDigi->GetSide()]);
5044 
5045  // walk correction
5046  Double_t dTotBinSize = (fdTOTMax - fdTOTMin) / nbClWalkBinX;
5047  Int_t iWx = (Int_t)((pCalDigi->GetTot() - fdTOTMin) / dTotBinSize);
5048  if (0 > iWx) iWx = 0;
5049  if (iWx >= nbClWalkBinX) iWx = nbClWalkBinX - 1;
5050  Double_t dDTot =
5051  (pCalDigi->GetTot() - fdTOTMin) / dTotBinSize - (Double_t) iWx - 0.5;
5052  Double_t dWT = fvCPWalk[pCalDigi->GetType()]
5053  [pCalDigi->GetSm()
5054  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5055  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5056  [pCalDigi->GetSide()][iWx];
5057  if (dDTot > 0) { // linear interpolation to next bin
5058  if (iWx < nbClWalkBinX - 1) { // linear interpolation to next bin
5059 
5060  dWT += dDTot
5061  * (fvCPWalk[pCalDigi->GetType()]
5062  [pCalDigi->GetSm()
5063  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5064  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5065  [pCalDigi->GetSide()][iWx + 1]
5066  - fvCPWalk[pCalDigi->GetType()]
5067  [pCalDigi->GetSm()
5068  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5069  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5070  [pCalDigi->GetSide()][iWx]); //memory leak???
5071  }
5072  } else // dDTot < 0, linear interpolation to next bin
5073  {
5074  if (0 < iWx) { // linear interpolation to next bin
5075  dWT -= dDTot
5076  * (fvCPWalk[pCalDigi->GetType()]
5077  [pCalDigi->GetSm()
5078  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5079  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5080  [pCalDigi->GetSide()][iWx - 1]
5081  - fvCPWalk[pCalDigi->GetType()]
5082  [pCalDigi->GetSm()
5083  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5084  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5085  [pCalDigi->GetSide()][iWx]); //memory leak???
5086  }
5087  }
5088 
5089  pCalDigi->SetTime(pCalDigi->GetTime() - dWT); // calibrate Digi Time
5090  LOG(debug2) << " CluCal-Walk: " << pCalDigi->ToString();
5091 
5092  if (0) { //pDigi->GetType()==7 && pDigi->GetSm()==0){
5093  LOG(info)
5094  << "CbmTofCosmicClusterizer::BuildClusters: CalDigi " << iDigIndCal
5095  << ", T " << pCalDigi->GetType() << ", Sm " << pCalDigi->GetSm()
5096  << ", R " << pCalDigi->GetRpc() << ", Ch " << pCalDigi->GetChannel()
5097  << ", S " << pCalDigi->GetSide() << ", T " << pCalDigi->GetTime()
5098  << ", Tot " << pCalDigi->GetTot() << ", TotGain "
5099  << fvCPTotGain[pCalDigi->GetType()]
5100  [pCalDigi->GetSm()
5101  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5102  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5103  [pCalDigi->GetSide()]
5104  << ", TotOff "
5105  << fvCPTotOff[pCalDigi->GetType()]
5106  [pCalDigi->GetSm()
5107  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5108  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5109  [pCalDigi->GetSide()]
5110  << ", Walk " << iWx << ": "
5111  << fvCPWalk[pCalDigi->GetType()]
5112  [pCalDigi->GetSm()
5113  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5114  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5115  [pCalDigi->GetSide()][iWx];
5116 
5117  LOG(info) << " dDTot " << dDTot << " BinSize: " << dTotBinSize
5118  << ", CPWalk "
5119  << fvCPWalk[pCalDigi->GetType()]
5120  [pCalDigi->GetSm()
5121  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5122  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5123  [pCalDigi->GetSide()][iWx - 1]
5124  << ", "
5125  << fvCPWalk[pCalDigi->GetType()]
5126  [pCalDigi->GetSm()
5127  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5128  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5129  [pCalDigi->GetSide()][iWx]
5130  << ", "
5131  << fvCPWalk[pCalDigi->GetType()]
5132  [pCalDigi->GetSm()
5133  * fDigiBdfPar->GetNbRpc(pCalDigi->GetType())
5134  + pCalDigi->GetRpc()][pCalDigi->GetChannel()]
5135  [pCalDigi->GetSide()][iWx + 1]
5136  << " -> dWT = " << dWT;
5137  }
5138  } else {
5139  LOG(info) << "Skip1 Digi "
5140  << " Type " << pDigi->GetType() << " "
5141  << fDigiBdfPar->GetNbSmTypes() << " Sm " << pDigi->GetSm()
5142  << " " << fDigiBdfPar->GetNbSm(pDigi->GetType()) << " Rpc "
5143  << pDigi->GetRpc() << " "
5144  << fDigiBdfPar->GetNbRpc(pDigi->GetType()) << " Ch "
5145  << pDigi->GetChannel() << " "
5146  << fDigiBdfPar->GetNbChan(pDigi->GetType(), 0);
5147  }
5148  if (pCalDigi->GetType() == 5
5149  || pCalDigi->GetType()
5150  == 8) { // for Pad counters generate fake digi to mockup a strip
5151  CbmTofDigi* pCalDigi2 =
5152  new ((*fTofCalDigisColl)[++iDigIndCal]) CbmTofDigi(*pCalDigi);
5153  if (pCalDigi->GetSide() == 0)
5154  pCalDigi2->SetAddress(pCalDigi->GetSm(),
5155  pCalDigi->GetRpc(),
5156  pCalDigi->GetChannel(),
5157  1,
5158  pCalDigi->GetType());
5159  else
5160  pCalDigi2->SetAddress(pCalDigi->GetSm(),
5161  pCalDigi->GetRpc(),
5162  pCalDigi->GetChannel(),
5163  0,
5164  pCalDigi->GetType());
5165  ;
5166  }
5167  } // for( Int_t iDigInd = 0; iDigInd < nTofDigi; iDigInd++ )
5168 
5169  iNbTofDigi = fTofCalDigisColl
5170  ->GetEntries(); // update because of added duplicted digis
5171  if (fTofCalDigisColl->IsSortable())
5172  LOG(debug) << "CbmTofCosmicClusterizer::BuildClusters: Sort "
5173  << fTofCalDigisColl->GetEntries() << " calibrated digis ";
5174  if (iNbTofDigi > 1) {
5175  fTofCalDigisColl->Sort(
5176  iNbTofDigi); // Time order again, in case modified by the calibration
5177  if (!fTofCalDigisColl->IsSorted()) {
5178  LOG(warning)
5179  << "CbmTofCosmicClusterizer::BuildClusters: Sorting not successful ";
5180  }
5181  }
5182 
5183  // Store CalDigis in vectors
5184  for (Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++) {
5185  pDigi = (CbmTofDigi*) fTofCalDigisColl->At(iDigInd);
5186  LOG(debug1) << "AC " // After Calibration
5187  << Form("0x%08x", pDigi->GetAddress()) << " TSRC "
5188  << pDigi->GetType() << pDigi->GetSm() << pDigi->GetRpc()
5189  << Form("%2d", (Int_t) pDigi->GetChannel()) << " "
5190  << pDigi->GetSide() << " " << Form("%f", pDigi->GetTime())
5191  << " " << pDigi->GetTot();
5192 
5193  if (fDigiBdfPar->GetNbSmTypes()
5194  > pDigi->GetType() // prevent crash due to misconfiguration
5195  && fDigiBdfPar->GetNbSm(pDigi->GetType()) > pDigi->GetSm()
5196  && fDigiBdfPar->GetNbRpc(pDigi->GetType()) > pDigi->GetRpc()
5197  && fDigiBdfPar->GetNbChan(pDigi->GetType(), pDigi->GetRpc())
5198  > pDigi->GetChannel()) {
5199  fStorDigiExp[pDigi->GetType()]
5200  [pDigi->GetSm() * fDigiBdfPar->GetNbRpc(pDigi->GetType())
5201  + pDigi->GetRpc()][pDigi->GetChannel()]
5202  .push_back(pDigi);
5203  fStorDigiInd[pDigi->GetType()]
5204  [pDigi->GetSm() * fDigiBdfPar->GetNbRpc(pDigi->GetType())
5205  + pDigi->GetRpc()][pDigi->GetChannel()]
5206  .push_back(iDigInd);
5207  } else {
5208  LOG(info) << "Skip2 Digi "
5209  << " Type " << pDigi->GetType() << " "
5210  << fDigiBdfPar->GetNbSmTypes() << " Sm " << pDigi->GetSm()
5211  << " " << fDigiBdfPar->GetNbSm(pDigi->GetType()) << " Rpc "
5212  << pDigi->GetRpc() << " "
5213  << fDigiBdfPar->GetNbRpc(pDigi->GetType()) << " Ch "
5214  << pDigi->GetChannel() << " "
5215  << fDigiBdfPar->GetNbChan(pDigi->GetType(), 0);
5216  }
5217  } // for( Int_t iDigInd = 0; iDigInd < nTofDigi; iDigInd++ )
5218 
5219  } // if( kTRUE == fDigiBdfPar->UseExpandedDigi() )
5220  else {
5221  return kFALSE; // not implemented properly yet
5222  /*
5223  CbmTofDigi *pDigi;
5224  for( Int_t iDigInd = 0; iDigInd < iNbTofDigi; iDigInd++ )
5225  {
5226  pDigi = (CbmTofDigi*) fTofDigisColl->At( iDigInd );
5227  fStorDigi[pDigi->GetType()]
5228  [pDigi->GetSm()*fDigiBdfPar->GetNbRpc( pDigi->GetType()) + pDigi->GetRpc()]
5229  [pDigi->GetChannel()].push_back(pDigi);
5230  fStorDigiInd[pDigi->GetType()]
5231  [pDigi->GetSm()*fDigiBdfPar->GetNbRpc( pDigi->GetType()) + pDigi->GetRpc()]
5232  [pDigi->GetChannel()].push_back(iDigInd);
5233  } // for( Int_t iDigInd = 0; iDigInd < nTofDigi; iDigInd++ )
5234  */
5235  } // else of if( kTRUE == fDigiBdfPar->UseExpandedDigi() )
5236 
5237 
5238  // Then build clusters inside each RPC module
5239  // Assume only 0 or 1 Digi per channel/side in each event
5240  // Use simplest method possible, scan direction independent:
5241  // a) Loop over channels in the RPC starting from 0
5242  // * If strips
5243  // i) Loop over Digis to check if both ends of the channel have a Digi
5244  // ii) Reconstruct a mean channel time and a mean position
5245  // + If a Hit is currently filled & the mean position (space, time) is less than XXX from last channel position
5246  // iii) Add the mean channel time and the mean position to the ones of the hit
5247  // + else
5248  // iii) Use nb of strips in cluster to cal. the hit mean time and pos (charge/tot weighting)
5249  // iv) Save the hit
5250  // v) Start a new hit with current channel
5251  // * else (pads)
5252  // i) Loop over Digis to find if this channel fired
5253  // ii) FIXME: either scan all other channels to check for matching Digis or have more than 1 hit open
5254  Int_t iNbSmTypes = fDigiBdfPar->GetNbSmTypes();
5255  // Hit variables
5256  Double_t dWeightedTime = 0.0;
5257  Double_t dWeightedPosX = 0.0;
5258  Double_t dWeightedPosY = 0.0;
5259  Double_t dWeightedPosZ = 0.0;
5260  Double_t dWeightsSum = 0.0;
5261  vDigiIndRef.clear();
5262  // CbmTofCell *fTrafoCell=NULL; (VF) not used
5263  // Int_t iTrafoCell=-1; (VF) not used
5264  Int_t iNbChanInHit = 0;
5265  // Last Channel Temp variables
5266  Int_t iLastChan = -1;
5267  Double_t dLastPosX =
5268  0.0; // -> Comment to remove warning because set but never used
5269  Double_t dLastPosY = 0.0;
5270  Double_t dLastTime = 0.0;
5271  // Channel Temp variables
5272  Double_t dPosX = 0.0;
5273  Double_t dPosY = 0.0;
5274  Double_t dPosZ = 0.0;
5275  Double_t dTime = 0.0;
5276  Double_t dTimeDif = 0.0;
5277  Double_t dTotS = 0.0;
5278  fiNbSameSide = 0;
5279  if (kTRUE == fDigiBdfPar->UseExpandedDigi()) {
5280  for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
5281  Int_t iNbSm = fDigiBdfPar->GetNbSm(iSmType);
5282  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
5283  for (Int_t iSm = 0; iSm < iNbSm; iSm++)
5284  for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
5285  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
5286  Int_t iChType = fDigiBdfPar->GetChanType(iSmType, iRpc);
5287  LOG(debug2) << "RPC - Loop "
5288  << Form(" %3d %3d %3d %3d ", iSmType, iSm, iRpc, iChType);
5289  fviClusterMul[iSmType][iSm][iRpc] = 0;
5290  Int_t iChId = 0;
5291  if (0 == iChType) {
5292  // Don't spread clusters over RPCs!!!
5293  dWeightedTime = 0.0;
5294  dWeightedPosX = 0.0;
5295  dWeightedPosY = 0.0;
5296  dWeightedPosZ = 0.0;
5297  dWeightsSum = 0.0;
5298  iNbChanInHit = 0;
5299  // For safety reinitialize everything
5300  iLastChan = -1;
5301  // dLastPosX = 0.0; // -> Comment to remove warning because set but never used
5302  dLastPosY = 0.0;
5303  dLastTime = 0.0;
5304  LOG(debug2) << "ChanOrient "
5305  << Form(" %3d %3d %3d %3d %3d ",
5306  iSmType,
5307  iSm,
5308  iRpc,
5309  fDigiBdfPar->GetChanOrient(iSmType, iRpc),
5310  iNbCh);
5311 
5312  if (1 == fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
5313  // Horizontal strips => X comes from left right time difference
5314  } // if( 1 == fDigiBdfPar->GetChanOrient( iSmType, iRpc ) )
5315  else {
5316  // Vertical strips => Y comes from bottom top time difference
5317  for (Int_t iCh = 0; iCh < iNbCh; iCh++) {
5318  LOG(debug3)
5319  << "VDigisize "
5320  << Form(
5321  " T %3d Sm %3d R %3d Ch %3d Size %3lu ",
5322  iSmType,
5323  iSm,
5324  iRpc,
5325  iCh,
5326  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5327  if (0 == fStorDigiExp[iSmType][iSm * iNbRpc + iRpc].size())
5328  continue;
5329  if (0 < fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
5330  fhNbDigiPerChan->Fill(
5331  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5332 
5333  while (
5334  1 < fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
5335 
5336  while ((fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0])
5337  ->GetSide()
5338  == (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
5339  ->GetSide()) {
5340  // Not one Digi of each end!
5341  fiNbSameSide++;
5342  if (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()
5343  > 2) {
5344  LOG(debug)
5345  << "SameSide Digis! on TSRC " << iSmType << iSm << iRpc
5346  << iCh << ", Times: "
5347  << Form("%f",
5348  (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5349  [0])
5350  ->GetTime())
5351  << ", "
5352  << Form("%f",
5353  (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5354  [1])
5355  ->GetTime())
5356  << ", DeltaT "
5357  << (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1])
5358  ->GetTime()
5359  - (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5360  [0])
5361  ->GetTime()
5362  << ", array size: "
5363  << fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5364  .size();
5365  if (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]
5366  ->GetSide()
5367  == fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]
5368  ->GetSide()) {
5369  LOG(debug)
5370  << "3 consecutive SameSide Digis! on TSRC " << iSmType
5371  << iSm << iRpc << iCh << ", Times: "
5372  << (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5373  [0])
5374  ->GetTime()
5375  << ", "
5376  << (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5377  [1])
5378  ->GetTime()
5379  << ", DeltaT "
5380  << (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5381  [1])
5382  ->GetTime()
5383  - (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc]
5384  [iCh][0])
5385  ->GetTime()
5386  << ", array size: "
5387  << fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5388  .size();
5389  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5390  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5391  .begin());
5392  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5393  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5394  .begin());
5395  } else {
5396  if (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]
5397  ->GetTime()
5398  - fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5399  [0]
5400  ->GetTime()
5401  > fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2]
5402  ->GetTime()
5403  - fStorDigiExp[iSmType][iSm * iNbRpc + iRpc]
5404  [iCh][1]
5405  ->GetTime()) {
5406  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5407  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5408  .begin());
5409  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5410  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5411  .begin());
5412  } else {
5413  LOG(debug) << Form(
5414  "Ev %8.0f, digis not properly time ordered, TSRCS "
5415  "%d%d%d%d%d ",
5416  fdEvent,
5417  iSmType,
5418  iSm,
5419  iRpc,
5420  iCh,
5421  (Int_t)
5422  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0]
5423  ->GetSide());
5424  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5425  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5426  .begin()
5427  + 1);
5428  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5429  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5430  .begin()
5431  + 1);
5432  }
5433  }
5434  } else {
5435  LOG(debug2)
5436  << "SameSide Erase fStor entries(d) " << iSmType
5437  << ", SR " << iSm * iNbRpc + iRpc << ", Ch" << iCh;
5438  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5439  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5440  .begin());
5441  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5442  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5443  .begin());
5444  }
5445  if (2 > fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5446  .size())
5447  break;
5448  continue;
5449  } // same condition side end
5450 
5451  LOG(debug2)
5452  << "digis processing for "
5453  << Form(" SmT %3d Sm %3d Rpc %3d Ch %3d # %3lu ",
5454  iSmType,
5455  iSm,
5456  iRpc,
5457  iCh,
5458  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5459  .size());
5460  if (2 > fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5461  .size()) {
5462  LOG(debug) << Form(
5463  "Leaving digi processing for TSRC %d%d%d%d, size %3lu",
5464  iSmType,
5465  iSm,
5466  iRpc,
5467  iCh,
5468  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
5469  break;
5470  }
5471  /* Int_t iLastChId = iChId; // Save Last hit channel*/
5472 
5473  // 2 Digis = both sides present
5474  CbmTofDetectorInfo xDetInfo(
5475  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, iCh);
5476  iChId = fTofId->SetDetectorInfo(xDetInfo);
5477  Int_t iUCellId =
5478  CbmTofAddress::GetUniqueAddress(iSm, iRpc, iCh, 0, iSmType);
5479  LOG(debug1) << Form(
5480  " TSRC %d%d%d%d size %3lu ",
5481  iSmType,
5482  iSm,
5483  iRpc,
5484  iCh,
5485  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
5486  << Form(" ChId: 0x%08x 0x%08x ", iChId, iUCellId);
5487  fChannelInfo = fDigiPar->GetCell(iChId);
5488 
5489  if (NULL == fChannelInfo) {
5490  LOG(error) << "CbmTofCosmicClusterizer::BuildClusters: no "
5491  "geometry info! "
5492  << Form(" %3d %3d %3d %3d 0x%08x 0x%08x ",
5493  iSmType,
5494  iSm,
5495  iRpc,
5496  iCh,
5497  iChId,
5498  iUCellId);
5499  break;
5500  }
5501 
5502  TGeoNode* fNode = // prepare local->global trafo
5503  gGeoManager->FindNode(fChannelInfo->GetX(),
5504  fChannelInfo->GetY(),
5505  fChannelInfo->GetZ());
5506  LOG(debug2) << Form(" Node at (%6.1f,%6.1f,%6.1f) : %p",
5507  fChannelInfo->GetX(),
5508  fChannelInfo->GetY(),
5509  fChannelInfo->GetZ(),
5510  fNode);
5511  // fNode->Print();
5512 
5513  CbmTofDigi* xDigiA =
5514  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][0];
5515  CbmTofDigi* xDigiB =
5516  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][1];
5517 
5518  LOG(debug2) << " " << xDigiA->ToString();
5519  LOG(debug2) << " " << xDigiB->ToString();
5520 
5521  dTimeDif = (xDigiA->GetTime() - xDigiB->GetTime());
5522  if (5 == iSmType && dTimeDif != 0.) {
5523  // FIXME -> Overflow treatment in calib/tdc/TMbsCalibTdcTof.cxx
5524  LOG(debug) << "CbmTofCosmicClusterizer::BuildClusters: "
5525  "Diamond hit in "
5526  << iSm << " with inconsistent digits "
5527  << xDigiA->GetTime() << ", " << xDigiB->GetTime()
5528  << " -> " << dTimeDif;
5529  LOG(debug) << " " << xDigiA->ToString();
5530  LOG(debug) << " " << xDigiB->ToString();
5531  }
5532  if (1 == xDigiA->GetSide())
5533  // 0 is the top side, 1 is the bottom side
5534  dPosY = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
5535  * dTimeDif * 0.5;
5536  else
5537  // 0 is the bottom side, 1 is the top side
5538  dPosY = -fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
5539  * dTimeDif * 0.5;
5540 
5541  if (TMath::Abs(dPosY) > fChannelInfo->GetSizey()
5542  && fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()
5543  > 2) {
5544  LOG(debug)
5545  << "Hit candidate outside correlation window, check for "
5546  "better possible digis, "
5547  << " mul "
5548  << fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
5549 
5550  CbmTofDigi* xDigiC =
5551  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][2];
5552  Double_t dPosYN = 0.;
5553  Double_t dTimeDifN = 0;
5554  if (xDigiC->GetSide() == xDigiA->GetSide())
5555  dTimeDifN = xDigiC->GetTime() - xDigiB->GetTime();
5556  else
5557  dTimeDifN = xDigiA->GetTime() - xDigiC->GetTime();
5558 
5559  if (1 == xDigiA->GetSide())
5560  dPosYN = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
5561  * dTimeDifN * 0.5;
5562  else
5563  dPosYN = -fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc)
5564  * dTimeDifN * 0.5;
5565 
5566  if (TMath::Abs(dPosYN) < TMath::Abs(dPosY)) {
5567  LOG(debug)
5568  << "Replace digi on side " << xDigiC->GetSide()
5569  << ", yPosNext " << dPosYN << " old: " << dPosY;
5570  dTimeDif = dTimeDifN;
5571  dPosY = dPosYN;
5572  if (xDigiC->GetSide() == xDigiA->GetSide()) {
5573  xDigiA = xDigiC;
5574  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5575  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5576  .begin());
5577  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5578  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5579  .begin());
5580  } else {
5581  xDigiB = xDigiC;
5582  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5583  ++(fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5584  .begin()
5585  + 1));
5586  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5587  ++(fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5588  .begin()
5589  + 1));
5590  }
5591  }
5592  }
5593 
5594  if (xDigiA->GetSide() == xDigiB->GetSide()) {
5595  LOG(fatal)
5596  << "Wrong combinations of digis "
5597  << fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]
5598  << ","
5599  << fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1];
5600  }
5601  // The "Strip" time is the mean time between each end
5602  dTime = 0.5 * (xDigiA->GetTime() + xDigiB->GetTime());
5603 
5604  // Weight is the total charge => sum of both ends ToT
5605  dTotS = xDigiA->GetTot() + xDigiB->GetTot();
5606 
5607 
5608  // use local coordinates, (0,0,0) is in the center of counter ?
5609  dPosX = ((Double_t)(-iNbCh / 2 + iCh) + 0.5)
5610  * fChannelInfo->GetSizex();
5611  dPosZ = 0.;
5612 
5613  LOG(debug1)
5614  << "NbChanInHit "
5615  << Form(" %3d %3d %3d %3d %3d 0x%p %1.0f Time %f PosX %f "
5616  "PosY %f Svel %f ",
5617  iNbChanInHit,
5618  iSmType,
5619  iRpc,
5620  iCh,
5621  iLastChan,
5622  xDigiA,
5623  xDigiA->GetSide(),
5624  dTime,
5625  dPosX,
5626  dPosY,
5627  fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc))
5628  // << Form( ", Offs %f, %f ",fvCPTOff[iSmType][iSm*iNbRpc+iRpc][iCh][0],
5629  // fvCPTOff[iSmType][iSm*iNbRpc+iRpc][iCh][1])
5630  ;
5631 
5632  // Now check if a hit/cluster is already started
5633  if (0 < iNbChanInHit) {
5634  if (iLastChan == iCh - 1) {
5635  fhDigTimeDifClust->Fill(dTime - dLastTime);
5636  fhDigSpacDifClust->Fill(dPosY - dLastPosY);
5637  fhDigDistClust->Fill(dPosY - dLastPosY,
5638  dTime - dLastTime);
5639  }
5640  // if( iLastChan == iCh - 1 )
5641  // a cluster is already started => check distance in space/time
5642  // For simplicity, just check along strip direction for now
5643  // and break cluster when a not fired strip is found
5644  if (TMath::Abs(dTime - dLastTime) < fdMaxTimeDist
5645  && iLastChan == iCh - 1
5646  && TMath::Abs(dPosY - dLastPosY) < fdMaxSpaceDist) {
5647  // Add to cluster/hit
5648  dWeightedTime += dTime * dTotS;
5649  dWeightedPosX += dPosX * dTotS;
5650  dWeightedPosY += dPosY * dTotS;
5651  dWeightedPosZ += dPosZ * dTotS;
5652  dWeightsSum += dTotS;
5653  iNbChanInHit += 1;
5654 
5655  vDigiIndRef.push_back((Int_t)(
5656  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]));
5657  vDigiIndRef.push_back((Int_t)(
5658  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]));
5659 
5660  LOG(debug1)
5661  << " Add Digi and erase fStor entries(a): NbChanInHit "
5662  << iNbChanInHit << ", " << iSmType << ", SR "
5663  << iSm * iNbRpc + iRpc << ", Ch" << iCh;
5664 
5665  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5666  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5667  .begin());
5668  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5669  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5670  .begin());
5671  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5672  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5673  .begin());
5674  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5675  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5676  .begin());
5677 
5678  } // if current Digis compatible with last fired chan
5679  else {
5680  // Save Hit
5681  dWeightedTime /= dWeightsSum;
5682  dWeightedPosX /= dWeightsSum;
5683  dWeightedPosY /= dWeightsSum;
5684  dWeightedPosZ /= dWeightsSum;
5685  // TVector3 hitPosLocal(dWeightedPosX, dWeightedPosY, dWeightedPosZ);
5686  //TVector3 hitPos;
5687  Double_t hitpos_local[3];
5688  hitpos_local[0] = dWeightedPosX;
5689  hitpos_local[1] = dWeightedPosY;
5690  hitpos_local[2] = dWeightedPosZ;
5691 
5692  Double_t hitpos[3];
5693  TGeoNode* cNode = gGeoManager->GetCurrentNode();
5694  /*TGeoHMatrix* cMatrix =*/gGeoManager->GetCurrentMatrix();
5695  //cNode->Print();
5696  //cMatrix->Print();
5697 
5698  gGeoManager->LocalToMaster(hitpos_local, hitpos);
5699  LOG(debug1)
5700  << Form(" LocalToMaster for node %p: "
5701  "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
5702  cNode,
5703  hitpos_local[0],
5704  hitpos_local[1],
5705  hitpos_local[2],
5706  hitpos[0],
5707  hitpos[1],
5708  hitpos[2]);
5709 
5710  TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
5711 
5712  // Simple errors, not properly done at all for now
5713  // Right way of doing it should take into account the weight distribution
5714  // and real system time resolution
5715  TVector3 hitPosErr(
5716  0.5, 0.5, 0.5); // including positioning uncertainty
5717  /*
5718  TVector3 hitPosErr( fChannelInfo->GetSizex()/TMath::Sqrt(12.0), // Single strips approximation
5719  0.5, // Use generic value
5720  1.);
5721 
5722  */ // fDigiBdfPar->GetFeeTimeRes() * fDigiBdfPar->GetSigVel(iSmType,iRpc), // Use the electronics resolution
5723  //fDigiBdfPar->GetNbGaps( iSmType, iRpc)*
5724  //fDigiBdfPar->GetGapSize( iSmType, iRpc)/ //10.0 / // Change gap size in cm
5725  //TMath::Sqrt(12.0) ); // Use full RPC thickness as "Channel" Z size
5726 
5727  // calc mean ch from dPosX=((Double_t)(-iNbCh/2 + iCh)+0.5)*fChannelInfo->GetSizex();
5728 
5729  Int_t iChm =
5730  floor(dWeightedPosX / fChannelInfo->GetSizex())
5731  + iNbCh / 2;
5732  if (iChm < 0) iChm = 0;
5733  if (iChm > iNbCh - 1) iChm = iNbCh - 1;
5734  Int_t iDetId = CbmTofAddress::GetUniqueAddress(
5735  iSm, iRpc, iChm, 0, iSmType);
5736  Int_t iRefId = 0; // Index of the correspondng TofPoint
5737 
5738  LOG(debug) << "Save Hit "
5739  << Form(" %3d %3d 0x%08x %3d %3d %3d %f %f",
5740  fiNbHits,
5741  iNbChanInHit,
5742  iDetId,
5743  iChm,
5744  iLastChan,
5745  iRefId,
5746  dWeightedTime,
5747  dWeightedPosY)
5748  << ", DigiSize: " << vDigiIndRef.size()
5749  << ", DigiInds: ";
5750 
5751  fviClusterMul[iSmType][iSm][iRpc]++;
5752 
5753  for (UInt_t i = 0; i < vDigiIndRef.size(); i++) {
5754  LOG(debug) << " " << vDigiIndRef.at(i) << "(M"
5755  << fviClusterMul[iSmType][iSm][iRpc] << ")";
5756  }
5757  LOG(debug);
5758 
5759  if (vDigiIndRef.size() < 2) {
5760  LOG(warning) << "Digi refs for Hit " << fiNbHits
5761  << ": vDigiIndRef.size()";
5762  }
5763  if (fiNbHits > 0) {
5764  CbmTofHit* pHitL =
5765  (CbmTofHit*) fTofHitsColl->At(fiNbHits - 1);
5766  if (iDetId == pHitL->GetAddress()
5767  && dWeightedTime == pHitL->GetTime()) {
5768  LOG(debug) << "Store Hit twice? "
5769  << " fiNbHits " << fiNbHits << ", "
5770  << Form("0x%08x", iDetId);
5771 
5772  for (UInt_t i = 0; i < vDigiIndRef.size(); i++) {
5773  CbmTofDigi* pDigiC =
5775  vDigiIndRef.at(i));
5776  LOG(debug) << " Digi " << pDigiC->ToString();
5777  }
5778  CbmMatch* digiMatchL =
5779  (CbmMatch*) fTofDigiMatchColl->At(fiNbHits - 1);
5780  for (Int_t i = 0; i < digiMatchL->GetNofLinks();
5781  i++) {
5782  CbmLink L0 = digiMatchL->GetLink(i);
5783  Int_t iDigIndL = L0.GetIndex();
5784  CbmTofDigi* pDigiC =
5785  (CbmTofDigi*) fTofCalDigisColl->At(iDigIndL);
5786  LOG(debug) << " DigiL " << pDigiC->ToString();
5787  }
5788  }
5789  }
5790  CbmTofHit* pHit = new CbmTofHit(
5791  iDetId,
5792  hitPos,
5793  hitPosErr, //local detector coordinates
5794  fiNbHits, // this number is used as reference!!
5795  dWeightedTime,
5796  vDigiIndRef
5797  .size(), // number of linked digis = 2*CluSize
5798  Int_t(dWeightsSum * 10.)); //channel -> Tot
5799  //0) ; //channel
5800  // output hit
5801  new ((*fTofHitsColl)[fiNbHits]) CbmTofHit(*pHit);
5802  // memorize hit
5803  if (fdMemoryTime > 0.) {
5804  LH_store(iSmType, iSm, iRpc, iChm, pHit);
5805  } else {
5806  pHit->Delete();
5807  }
5808  /*
5809  new((*fTofDigiMatchColl)[fiNbHits]) CbmMatch();
5810  CbmMatch* digiMatch = (CbmMatch *)fTofDigiMatchColl->At(fiNbHits);
5811  */
5812  CbmMatch* digiMatch =
5813  new ((*fTofDigiMatchColl)[fiNbHits]) CbmMatch();
5814  for (size_t i = 0; i < vDigiIndRef.size(); i++) {
5815  Double_t dTot = ((CbmTofDigi*) (fTofCalDigisColl->At(
5816  vDigiIndRef.at(i))))
5817  ->GetTot();
5818  digiMatch->AddLink(CbmLink(dTot, vDigiIndRef.at(i)));
5819  }
5820 
5821  fiNbHits++;
5822  // For Histogramming
5823  fviClusterSize[iSmType][iRpc].push_back(iNbChanInHit);
5824  fvdX[iSmType][iRpc].push_back(dWeightedPosX);
5825  fvdY[iSmType][iRpc].push_back(dWeightedPosY);
5826 
5827  vDigiIndRef.clear();
5828 
5829  // Start a new hit
5830  dWeightedTime = dTime * dTotS;
5831  dWeightedPosX = dPosX * dTotS;
5832  dWeightedPosY = dPosY * dTotS;
5833  dWeightedPosZ = dPosZ * dTotS;
5834  dWeightsSum = dTotS;
5835  iNbChanInHit = 1;
5836  // Save pointer on CbmTofPoint
5837  // Save next digi address
5838  LOG(debug2)
5839  << " Next fStor Digi " << iSmType << ", SR "
5840  << iSm * iNbRpc + iRpc << ", Ch" << iCh << ", Dig0 "
5841  << (fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0])
5842  << ", Dig1 "
5843  << (fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
5844 
5845  vDigiIndRef.push_back((Int_t)(
5846  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]));
5847  vDigiIndRef.push_back((Int_t)(
5848  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]));
5849  LOG(debug2)
5850  << " Erase fStor entries(b) " << iSmType << ", SR "
5851  << iSm * iNbRpc + iRpc << ", Ch" << iCh;
5852  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5853  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5854  .begin());
5855  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5856  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh]
5857  .begin());
5858  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5859  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5860  .begin());
5861  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5862  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh]
5863  .begin());
5864 
5865 
5866  } // else of if current Digis compatible with last fired chan
5867  } // if( 0 < iNbChanInHit)
5868  else {
5869  LOG(debug) << Form("1.Hit on channel %d, time: %f, PosY %f",
5870  iCh,
5871  dTime,
5872  dPosY);
5873 
5874  // first fired strip in this RPC
5875  dWeightedTime = dTime * dTotS;
5876  dWeightedPosX = dPosX * dTotS;
5877  dWeightedPosY = dPosY * dTotS;
5878  dWeightedPosZ = dPosZ * dTotS;
5879  dWeightsSum = dTotS;
5880  iNbChanInHit = 1;
5881 
5882  vDigiIndRef.push_back((Int_t)(
5883  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][0]));
5884  vDigiIndRef.push_back((Int_t)(
5885  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][1]));
5886 
5887  LOG(debug2)
5888  << " Erase fStor entries(c) " << iSmType << ", SR "
5889  << iSm * iNbRpc + iRpc << ", Ch" << iCh;
5890  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5891  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5892  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5893  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5894  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5895  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5896  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
5897  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin());
5898 
5899  } // else of if( 0 < iNbChanInHit)
5900  iLastChan = iCh;
5901  dLastPosX = dPosX;
5902  dLastPosY = dPosY;
5903  dLastTime = dTime;
5904  if (AddNextChan(iSmType,
5905  iSm,
5906  iRpc,
5907  iLastChan,
5908  dLastPosX,
5909  dLastPosY,
5910  dLastTime,
5911  dWeightsSum)) {
5912  iNbChanInHit = 0; // cluster already stored
5913  }
5914  } // while( 1 < fStorDigiExp[iSmType][iSm*iNbRpc+iRpc][iCh].size() )
5915  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
5916  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].clear();
5917  } // for( Int_t iCh = 0; iCh < iNbCh; iCh++ )
5918  LOG(debug2) << "finished V-RPC"
5919  << Form(" %3d %3d %3d %d %f %fx",
5920  iSmType,
5921  iSm,
5922  iRpc,
5923  fTofHitsColl->GetEntries(),
5924  dLastPosX,
5925  dLastPosY);
5926  } // else of if( 1 == fDigiBdfPar->GetChanOrient( iSmType, iRpc ) )
5927  } // if( 0 == iChType)
5928  else {
5929  LOG(error)
5930  << "=> Cluster building "
5931  << "from digis to hits not implemented for pads, Sm type "
5932  << iSmType << " Rpc " << iRpc;
5933  return kFALSE;
5934  } // else of if( 0 == iChType)
5935 
5936  // Now check if another hit/cluster is started
5937  // and save it if it's the case
5938  if (0 < iNbChanInHit) {
5939  LOG(debug1) << "Process cluster " << iNbChanInHit;
5940 
5941  // Check orientation to properly assign errors
5942  if (1 == fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
5943  LOG(debug1) << "H-Hit ";
5944  } // if( 1 == fDigiBdfPar->GetChanOrient( iSmType, iRpc ) )
5945  else {
5946  LOG(debug2) << "V-Hit ";
5947  // Save Hit
5948  dWeightedTime /= dWeightsSum;
5949  dWeightedPosX /= dWeightsSum;
5950  dWeightedPosY /= dWeightsSum;
5951  dWeightedPosZ /= dWeightsSum;
5952  //TVector3 hitPos(dWeightedPosX, dWeightedPosY, dWeightedPosZ);
5953 
5954  Double_t hitpos_local[3] = {3 * 0.};
5955  hitpos_local[0] = dWeightedPosX;
5956  hitpos_local[1] = dWeightedPosY;
5957  hitpos_local[2] = dWeightedPosZ;
5958 
5959  Double_t hitpos[3];
5960  TGeoNode* cNode = gGeoManager->GetCurrentNode();
5961  /*TGeoHMatrix* cMatrix =*/gGeoManager->GetCurrentMatrix();
5962  //cNode->Print();
5963  //cMatrix->Print();
5964 
5965  gGeoManager->LocalToMaster(hitpos_local, hitpos);
5966  LOG(debug1) << Form(" LocalToMaster for V-node %p: "
5967  "(%6.1f,%6.1f,%6.1f) ->(%6.1f,%6.1f,%6.1f)",
5968  cNode,
5969  hitpos_local[0],
5970  hitpos_local[1],
5971  hitpos_local[2],
5972  hitpos[0],
5973  hitpos[1],
5974  hitpos[2]);
5975 
5976  TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
5977  // Cosmic errors, not properly done at all for now
5978  // Right way of doing it should take into account the weight distribution
5979  // and real system time resolution
5980  TVector3 hitPosErr(
5981  0.5, 0.5, 0.5); // including positioning uncertainty
5982  /*
5983  TVector3 hitPosErr( fChannelInfo->GetSizex()/TMath::Sqrt(12.0), // Single strips approximation
5984  0.5, // Use generic value
5985  1.);
5986  */
5987  // fDigiBdfPar->GetFeeTimeRes() * fDigiBdfPar->GetSigVel(iSmType,iRpc), // Use the electronics resolution
5988  // fDigiBdfPar->GetNbGaps( iSmType, iRpc)*
5989  // fDigiBdfPar->GetGapSize( iSmType, iRpc)/10.0 / // Change gap size in cm
5990  // TMath::Sqrt(12.0) ); // Use full RPC thickness as "Channel" Z size
5991 
5992  Int_t iChm =
5993  floor(dWeightedPosX / fChannelInfo->GetSizex()) + iNbCh / 2;
5994  if (iChm < 0) iChm = 0;
5995  if (iChm > iNbCh - 1) iChm = iNbCh - 1;
5996  Int_t iDetId =
5997  CbmTofAddress::GetUniqueAddress(iSm, iRpc, iChm, 0, iSmType);
5998  Int_t iRefId = 0; // Index of the correspondng TofPoint
5999  LOG(debug) << "Save V-Hit "
6000  << Form(" %3d %3d 0x%08x %3d 0x%08x", // %3d %3d
6001  fiNbHits,
6002  iNbChanInHit,
6003  iDetId,
6004  iLastChan,
6005  iRefId)
6006  // dWeightedTime,dWeightedPosY)
6007  << ", DigiSize: " << vDigiIndRef.size();
6008  LOG(debug) << ", DigiInds: ";
6009 
6010  fviClusterMul[iSmType][iSm][iRpc]++;
6011 
6012  for (UInt_t i = 0; i < vDigiIndRef.size(); i++) {
6013  LOG(debug) << " " << vDigiIndRef.at(i) << "(M"
6014  << fviClusterMul[iSmType][iSm][iRpc] << ")";
6015  }
6016  LOG(debug);
6017 
6018  if (vDigiIndRef.size() < 2) {
6019  LOG(warning) << "Digi refs for Hit " << fiNbHits
6020  << ": vDigiIndRef.size()";
6021  }
6022  if (fiNbHits > 0) {
6023  CbmTofHit* pHitL = (CbmTofHit*) fTofHitsColl->At(fiNbHits - 1);
6024  if (iDetId == pHitL->GetAddress()
6025  && dWeightedTime == pHitL->GetTime())
6026  LOG(debug) << "Store Hit twice? "
6027  << " fiNbHits " << fiNbHits << ", "
6028  << Form("0x%08x", iDetId);
6029  }
6030 
6031  CbmTofHit* pHit = new CbmTofHit(
6032  iDetId,
6033  hitPos,
6034  hitPosErr, //local detector coordinates
6035  fiNbHits, // this number is used as reference!!
6036  dWeightedTime,
6037  vDigiIndRef.size(), // number of linked digis = 2*CluSize
6038  Int_t(dWeightsSum * 10.)); //channel -> Tot
6039  // 0) ; //channel
6040  // vDigiIndRef);
6041  // output hit
6042  new ((*fTofHitsColl)[fiNbHits]) CbmTofHit(*pHit);
6043  // memorize hit
6044  if (fdMemoryTime > 0.) {
6045  LH_store(iSmType, iSm, iRpc, iChm, pHit);
6046  } else {
6047  pHit->Delete();
6048  }
6049  /*
6050  new((*fTofDigiMatchColl)[fiNbHits]) CbmMatch();
6051  CbmMatch* digiMatch = (CbmMatch *)fTofDigiMatchColl->At(fiNbHits);
6052  */
6053  CbmMatch* digiMatch =
6054  new ((*fTofDigiMatchColl)[fiNbHits]) CbmMatch();
6055 
6056  for (size_t i = 0; i < vDigiIndRef.size(); i++) {
6057  Double_t dTot =
6058  ((CbmTofDigi*) (fTofCalDigisColl->At(vDigiIndRef.at(i))))
6059  ->GetTot();
6060  digiMatch->AddLink(CbmLink(dTot, vDigiIndRef.at(i)));
6061  }
6062 
6063  fiNbHits++;
6064  // For Histogramming
6065  fviClusterSize[iSmType][iRpc].push_back(iNbChanInHit);
6066  fvdX[iSmType][iRpc].push_back(dWeightedPosX);
6067  fvdY[iSmType][iRpc].push_back(dWeightedPosY);
6068  vDigiIndRef.clear();
6069  } // else of if( 1 == fDigiBdfPar->GetChanOrient( iSmType, iRpc ) )
6070  } // if( 0 < iNbChanInHit)
6071  LOG(debug2) << " Fini-A "
6072  << Form(" %3d %3d %3d M%3d",
6073  iSmType,
6074  iSm,
6075  iRpc,
6076  fviClusterMul[iSmType][iSm][iRpc]);
6077  } // for each sm/rpc pair
6078  LOG(debug2) << " Fini-B " << Form(" %3d ", iSmType);
6079  } // for( Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++ )
6080  } // if( kTRUE == fDigiBdfPar->UseExpandedDigi() )
6081  else {
6082  LOG(error) << " Compressed Digis not implemented ... ";
6083  }
6084  return kTRUE;
6085 }
6086 
6088  // Merge clusters from neigbouring Rpc within a (Super)Module
6089  if (NULL == fTofHitsColl) {
6090  LOG(info) << " No Hits defined ! Check! ";
6091  return kFALSE;
6092  }
6093  // inspect hits
6094  for (Int_t iHitInd = 0; iHitInd < fTofHitsColl->GetEntries(); iHitInd++) {
6095  CbmTofHit* pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
6096  if (NULL == pHit) continue;
6097 
6098  Int_t iDetId = (pHit->GetAddress() & DetMask);
6099  Int_t iSmType = CbmTofAddress::GetSmType(iDetId);
6100  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
6101  if (iSmType != 5 && iSmType != 8) continue; // only merge diamonds and Pad
6102  LOG(debug) << "MergeClusters: in SmT " << iSmType << " for " << iNbRpc
6103  << " Rpcs";
6104 
6105  if (iNbRpc > 1) { // check for possible mergers
6106  Int_t iSm = CbmTofAddress::GetSmId(iDetId);
6107  Int_t iRpc = CbmTofAddress::GetRpcId(iDetId);
6108  Int_t iChId = pHit->GetAddress();
6109  fChannelInfo = fDigiPar->GetCell(iChId);
6110  Int_t iCh = CbmTofAddress::GetChannelId(iChId);
6111  LOG(debug) << "MergeClusters: Check for mergers in "
6112  << Form(" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d",
6113  iSmType,
6114  iSm,
6115  iRpc,
6116  iCh,
6117  iHitInd);
6118  for (Int_t iHitInd2 = iHitInd + 1; iHitInd2 < fTofHitsColl->GetEntries();
6119  iHitInd2++) {
6120  CbmTofHit* pHit2 = (CbmTofHit*) fTofHitsColl->At(iHitInd2);
6121  if (NULL == pHit2) continue;
6122  Int_t iDetId2 = (pHit2->GetAddress() & DetMask);
6123  Int_t iSmType2 = CbmTofAddress::GetSmType(iDetId2);
6124  if (iSmType2 == iSmType) {
6125  Int_t iSm2 = CbmTofAddress::GetSmId(iDetId2);
6126  if (iSm2 == iSm || iSmType == 5) {
6127  Int_t iRpc2 = CbmTofAddress::GetRpcId(iDetId2);
6128  if (TMath::Abs(iRpc - iRpc2) == 1
6129  || iSm2 != iSm) { // Found neighbour
6130  Int_t iChId2 = pHit2->GetAddress();
6131  // CbmTofCell *fChannelInfo2 = fDigiPar->GetCell( iChId2 ); (VF) not used
6132  Int_t iCh2 = CbmTofAddress::GetChannelId(iChId2);
6133  Double_t xPos = pHit->GetX();
6134  Double_t yPos = pHit->GetY();
6135  Double_t tof = pHit->GetTime();
6136  Double_t xPos2 = pHit2->GetX();
6137  Double_t yPos2 = pHit2->GetY();
6138  Double_t tof2 = pHit2->GetTime();
6139  LOG(debug) << "MergeClusters: Found hit in neighbour "
6140  << Form(" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d",
6141  iSmType2,
6142  iSm2,
6143  iRpc2,
6144  iCh2,
6145  iHitInd2)
6146  << Form(" DX %6.1f, DY %6.1f, DT %6.1f",
6147  xPos - xPos2,
6148  yPos - yPos2,
6149  tof - tof2);
6150 
6151 
6152  if (TMath::Abs(xPos - xPos2) < fdCaldXdYMax * 2.
6153  && TMath::Abs(yPos - yPos2) < fdCaldXdYMax * 2.
6154  && TMath::Abs(tof - tof2) < fMaxTimeDist) {
6155 
6156  CbmMatch* digiMatch =
6157  (CbmMatch*) fTofDigiMatchColl->At(iHitInd);
6158  Double_t dTot = 0;
6159  for (Int_t iLink = 0; iLink < digiMatch->GetNofLinks();
6160  iLink += 2) { // loop over digis
6161  CbmLink L0 = digiMatch->GetLink(iLink);
6162  Int_t iDigInd0 = L0.GetIndex();
6163  Int_t iDigInd1 = (digiMatch->GetLink(iLink + 1)).GetIndex();
6164  if (iDigInd0 < fTofCalDigisColl->GetEntries()
6165  && iDigInd1 < fTofCalDigisColl->GetEntries()) {
6166  CbmTofDigi* pDig0 =
6167  (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd0));
6168  CbmTofDigi* pDig1 =
6169  (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd1));
6170  dTot += pDig0->GetTot();
6171  dTot += pDig1->GetTot();
6172  }
6173  }
6174 
6175  CbmMatch* digiMatch2 =
6176  (CbmMatch*) fTofDigiMatchColl->At(iHitInd2);
6177  Double_t dTot2 = 0;
6178  for (Int_t iLink = 0; iLink < digiMatch2->GetNofLinks();
6179  iLink += 2) { // loop over digis
6180  CbmLink L0 = digiMatch2->GetLink(iLink);
6181  Int_t iDigInd0 = L0.GetIndex();
6182  Int_t iDigInd1 = (digiMatch2->GetLink(iLink + 1)).GetIndex();
6183  if (iDigInd0 < fTofCalDigisColl->GetEntries()
6184  && iDigInd1 < fTofCalDigisColl->GetEntries()) {
6185  CbmTofDigi* pDig0 =
6186  (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd0));
6187  CbmTofDigi* pDig1 =
6188  (CbmTofDigi*) (fTofCalDigisColl->At(iDigInd1));
6189  dTot2 += pDig0->GetTot();
6190  dTot2 += pDig1->GetTot();
6191  digiMatch->AddLink(CbmLink(pDig0->GetTot(), iDigInd0));
6192  digiMatch->AddLink(CbmLink(pDig1->GetTot(), iDigInd1));
6193  }
6194  }
6195  LOG(debug) << "MergeClusters: Found merger in neighbour "
6196  << Form(" SmT %d, Sm %d, Rpc %d, Ch %d - hit %d(%d)",
6197  iSmType2,
6198  iSm2,
6199  iRpc2,
6200  iCh2,
6201  iHitInd2,
6202  fTofHitsColl->GetEntries())
6203  << Form(" DX %6.1f, DY %6.1f, DT %6.1f",
6204  xPos - xPos2,
6205  yPos - yPos2,
6206  tof - tof2)
6207  << Form(" Tots %6.1f - %6.1f", dTot, dTot2);
6208  Double_t dTotSum = dTot + dTot2;
6209  Double_t dxPosM = (xPos * dTot + xPos2 * dTot2) / dTotSum;
6210  Double_t dyPosM = (yPos * dTot + yPos2 * dTot2) / dTotSum;
6211  Double_t dtofM = (tof * dTot + tof2 * dTot2) / dTotSum;
6212  pHit->SetX(dxPosM);
6213  pHit->SetY(dyPosM);
6214  pHit->SetTime(dtofM);
6215 
6216  // remove merged hit at iHitInd2 and update digiMatch
6217 
6218  fTofHitsColl->RemoveAt(iHitInd2);
6219  fTofDigiMatchColl->RemoveAt(iHitInd2);
6220  fTofDigiMatchColl->Compress();
6221  fTofHitsColl->Compress();
6222  LOG(debug) << "MergeClusters: Compress TClonesArrays to "
6223  << fTofHitsColl->GetEntries() << ", "
6224  << fTofDigiMatchColl->GetEntries();
6225  /*
6226  for(Int_t i=iHitInd2; i<fTofHitsColl->GetEntries(); i++){ // update RefLinks
6227  CbmTofHit *pHiti = (CbmTofHit*) fTofHitsColl->At( i );
6228  pHiti->SetRefId(i);
6229  }
6230  */
6231  //check merged hit (cluster)
6232  //pHit->Print();
6233  }
6234  }
6235  }
6236  }
6237  }
6238  }
6239  }
6240  return kTRUE;
6241 }
6242 
6243 static Double_t f1_xboxe(double* x, double* par) {
6244  double xx = x[0];
6245  double wx = 1. - par[4] * TMath::Power(xx + par[5], 2);
6246  double xboxe = par[0] * 0.25
6247  * (1. + TMath::Erf((xx + par[1] - par[3]) / par[2]))
6248  * (1. + TMath::Erf((-xx + par[1] + par[3]) / par[2]));
6249  return xboxe * wx;
6250 }
6251 
6252 void CbmTofCosmicClusterizer::fit_ybox(const char* hname) {
6253  TH1* h1;
6254  h1 = (TH1*) gROOT->FindObjectAny(hname);
6255  if (NULL != h1) { fit_ybox(h1, 0.); }
6256 }
6257 
6258 void CbmTofCosmicClusterizer::fit_ybox(TH1* h1, Double_t ysize) {
6259  Double_t* fpar = NULL;
6260  fit_ybox(h1, ysize, fpar);
6261 }
6262 
6264  Double_t ysize,
6265  Double_t* fpar = NULL) {
6266  TAxis* xaxis = h1->GetXaxis();
6267  Double_t Ymin = xaxis->GetXmin();
6268  Double_t Ymax = xaxis->GetXmax();
6269  TF1* f1 = new TF1("YBox", f1_xboxe, Ymin, Ymax, 6);
6270  Double_t yini = (h1->GetMaximum() + h1->GetMinimum()) * 0.5;
6271  if (ysize == 0.) ysize = Ymax * 0.8;
6272  f1->SetParameters(yini, ysize * 0.5, 1., 0., 0., 0.);
6273  // f1->SetParLimits(1,ysize*0.8,ysize*1.2);
6274  f1->SetParLimits(2, 0.2, 3.);
6275  f1->SetParLimits(3, -4., 4.);
6276  if (fpar != NULL) {
6277  Double_t fp[4];
6278  for (Int_t i = 0; i < 4; i++)
6279  fp[i] = *fpar++;
6280  for (Int_t i = 0; i < 4; i++)
6281  f1->SetParameter(2 + i, fp[i]);
6282  LOG(debug) << "Ini Fpar for " << h1->GetName() << " with "
6283  << Form(" %6.3f %6.3f %6.3f %6.3f ", fp[0], fp[1], fp[2], fp[3]);
6284  }
6285 
6286  h1->Fit("YBox", "Q");
6287 
6288  double res[10];
6289  double err[10];
6290  res[9] = f1->GetChisquare();
6291 
6292  for (int i = 0; i < 6; i++) {
6293  res[i] = f1->GetParameter(i);
6294  err[i] = f1->GetParError(i);
6295  //cout << " FPar "<< i << ": " << res[i] << ", " << err[i] << endl;
6296  }
6297  LOG(debug) << "YBox Fit of " << h1->GetName()
6298  << " ended with chi2 = " << res[9]
6299  << Form(", strip length %7.2f +/- %5.2f, position resolution "
6300  "%7.2f +/- %5.2f at y_cen = %7.2f +/- %5.2f",
6301  2. * res[1],
6302  2. * err[1],
6303  res[2],
6304  err[2],
6305  res[3],
6306  err[3]);
6307 }
6308 
6310  if (fvLastHits.size() != static_cast<size_t>(fDigiBdfPar->GetNbSmTypes()))
6311  LOG(fatal) << Form("Inconsistent LH Smtype size %lu, %d ",
6312  fvLastHits.size(),
6314 
6315  for (Int_t iSmType = 0; iSmType < fDigiBdfPar->GetNbSmTypes(); iSmType++) {
6316  if (fvLastHits[iSmType].size()
6317  != static_cast<size_t>(fDigiBdfPar->GetNbSm(iSmType)))
6318  LOG(fatal) << Form("Inconsistent LH Sm size %lu, %d T %d",
6319  fvLastHits[iSmType].size(),
6320  fDigiBdfPar->GetNbSm(iSmType),
6321  iSmType);
6322  for (Int_t iSm = 0; iSm < fDigiBdfPar->GetNbSm(iSmType); iSm++) {
6323  if (fvLastHits[iSmType][iSm].size()
6324  != static_cast<size_t>(fDigiBdfPar->GetNbRpc(iSmType)))
6325  LOG(fatal) << Form("Inconsistent LH Rpc size %lu, %d TS %d%d ",
6326  fvLastHits[iSmType][iSm].size(),
6327  fDigiBdfPar->GetNbRpc(iSmType),
6328  iSmType,
6329  iSm);
6330  for (Int_t iRpc = 0; iRpc < fDigiBdfPar->GetNbRpc(iSmType); iRpc++) {
6331  if (fvLastHits[iSmType][iSm][iRpc].size()
6332  != static_cast<size_t>(fDigiBdfPar->GetNbChan(iSmType, iRpc)))
6333  LOG(fatal) << Form(
6334  "Inconsistent LH RpcChannel size %lu, %d TSR %d%d%d ",
6335  fvLastHits[iSmType][iSm][iRpc].size(),
6336  fDigiBdfPar->GetNbChan(iSmType, iRpc),
6337  iSmType,
6338  iSm,
6339  iRpc);
6340  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpc); iCh++)
6341  if (fvLastHits[iSmType][iSm][iRpc][iCh].size() > 0) {
6342  CbmTofDetectorInfo xDetInfo(
6343  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, iCh);
6344  Int_t iAddr = fTofId->SetDetectorInfo(xDetInfo);
6345  if (fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress()
6346  != iAddr)
6347  LOG(fatal) << Form(
6348  "Inconsistent address for Ev %8.0f in list of size %lu for "
6349  "TSRC %d%d%d%d: 0x%08x, time %f",
6350  fdEvent,
6351  fvLastHits[iSmType][iSm][iRpc][iCh].size(),
6352  iSmType,
6353  iSm,
6354  iRpc,
6355  iCh,
6356  fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
6357  fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
6358  }
6359  }
6360  }
6361  }
6362  LOG(debug) << Form("LH check passed for event %8.0f", fdEvent);
6363 }
6364 
6366  if (fvLastHits.size() != static_cast<size_t>(fDigiBdfPar->GetNbSmTypes()))
6367  LOG(fatal) << Form("Inconsistent LH Smtype size %lu, %d ",
6368  fvLastHits.size(),
6370  for (Int_t iSmType = 0; iSmType < fDigiBdfPar->GetNbSmTypes(); iSmType++) {
6371  if (fvLastHits[iSmType].size()
6372  != static_cast<size_t>(fDigiBdfPar->GetNbSm(iSmType)))
6373  LOG(fatal) << Form("Inconsistent LH Sm size %lu, %d T %d",
6374  fvLastHits[iSmType].size(),
6375  fDigiBdfPar->GetNbSm(iSmType),
6376  iSmType);
6377  for (Int_t iSm = 0; iSm < fDigiBdfPar->GetNbSm(iSmType); iSm++) {
6378  if (fvLastHits[iSmType][iSm].size()
6379  != static_cast<size_t>(fDigiBdfPar->GetNbRpc(iSmType)))
6380  LOG(fatal) << Form("Inconsistent LH Rpc size %lu, %d TS %d%d ",
6381  fvLastHits[iSmType][iSm].size(),
6382  fDigiBdfPar->GetNbRpc(iSmType),
6383  iSmType,
6384  iSm);
6385  for (Int_t iRpc = 0; iRpc < fDigiBdfPar->GetNbRpc(iSmType); iRpc++) {
6386  if (fvLastHits[iSmType][iSm][iRpc].size()
6387  != static_cast<size_t>(fDigiBdfPar->GetNbChan(iSmType, iRpc)))
6388  LOG(fatal) << Form(
6389  "Inconsistent LH RpcChannel size %lu, %d TSR %d%d%d ",
6390  fvLastHits[iSmType][iSm][iRpc].size(),
6391  fDigiBdfPar->GetNbChan(iSmType, iRpc),
6392  iSmType,
6393  iSm,
6394  iRpc);
6395  for (Int_t iCh = 0; iCh < fDigiBdfPar->GetNbChan(iSmType, iRpc); iCh++)
6396  while (fvLastHits[iSmType][iSm][iRpc][iCh].size() > 0) {
6397  CbmTofDetectorInfo xDetInfo(
6398  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, iCh);
6399  Int_t iAddr = fTofId->SetDetectorInfo(xDetInfo);
6400  if (fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress()
6401  != iAddr)
6402  LOG(fatal) << Form(
6403  "Inconsistent address for Ev %8.0f in list of size %lu for "
6404  "TSRC %d%d%d%d: 0x%08x, time %f",
6405  fdEvent,
6406  fvLastHits[iSmType][iSm][iRpc][iCh].size(),
6407  iSmType,
6408  iSm,
6409  iRpc,
6410  iCh,
6411  fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetAddress(),
6412  fvLastHits[iSmType][iSm][iRpc][iCh].front()->GetTime());
6413  fvLastHits[iSmType][iSm][iRpc][iCh].front()->Delete();
6414  fvLastHits[iSmType][iSm][iRpc][iCh].pop_front();
6415  }
6416  }
6417  }
6418  }
6419  LOG(info) << Form("LH cleaning done after %8.0f events", fdEvent);
6420 }
6421 
6423  Int_t iSm,
6424  Int_t iRpc,
6425  Int_t iLastChan,
6426  Double_t dLastPosX,
6427  Double_t dLastPosY,
6428  Double_t dLastTime,
6429  Double_t dLastTotS) {
6430  // Int_t iNbSm = fDigiBdfPar->GetNbSm( iSmType); (VF) not used
6431  Int_t iNbRpc = fDigiBdfPar->GetNbRpc(iSmType);
6432  Int_t iNbCh = fDigiBdfPar->GetNbChan(iSmType, iRpc);
6433  // Int_t iChType = fDigiBdfPar->GetChanType( iSmType, iRpc ); (VF) not used
6434 
6435  Int_t iCh = iLastChan + 1;
6436  LOG(debug) << Form("Inspect channel TSRC %d%d%d%d at time %f, pos %f, size ",
6437  iSmType,
6438  iSm,
6439  iRpc,
6440  iCh,
6441  dLastTime,
6442  dLastPosY)
6443  << fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
6444  if (iCh == iNbCh) return kFALSE;
6445  if (0 == fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
6446  return kFALSE;
6447  if (0 < fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size())
6448  fhNbDigiPerChan->Fill(
6449  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size());
6450  if (1 < fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
6451  Bool_t AddedHit = kFALSE;
6452  for (size_t i1 = 0;
6453  i1 < fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size() - 1;
6454  i1++) {
6455  if (AddedHit) break;
6456  size_t i2 = i1 + 1;
6457  while (!AddedHit
6458  && i2 < fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size()) {
6459  LOG(debug) << "check digi pair " << i1 << "," << i2 << " with size "
6460  << fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].size();
6461 
6462  if ((fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i1])->GetSide()
6463  == (fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i2])
6464  ->GetSide()) {
6465  i2++;
6466  continue;
6467  } // endif same side
6468  // 2 Digis, both sides present
6469  CbmTofDigi* xDigiA =
6470  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i1];
6471  CbmTofDigi* xDigiB =
6472  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh][i2];
6473  Double_t dTime = 0.5 * (xDigiA->GetTime() + xDigiB->GetTime());
6474  if (TMath::Abs(dTime - dLastTime) < fdMaxTimeDist) {
6475  CbmTofDetectorInfo xDetInfo(
6476  ECbmModuleId::kTof, iSmType, iSm, iRpc, 0, iCh);
6477  Int_t iChId = fTofId->SetDetectorInfo(xDetInfo);
6478  fChannelInfo = fDigiPar->GetCell(iChId);
6479  gGeoManager->FindNode(
6481 
6482  Double_t dTimeDif = xDigiA->GetTime() - xDigiB->GetTime();
6483  Double_t dPosY = 0.;
6484  if (1 == xDigiA->GetSide())
6485  dPosY = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDif * 0.5;
6486  else
6487  dPosY =
6488  -fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDif * 0.5;
6489 
6490  if (TMath::Abs(dPosY - dLastPosY)
6491  < fdMaxSpaceDist) { // append digi pair to current cluster
6492 
6493  Double_t dNClHits = (Double_t)(vDigiIndRef.size() / 2);
6494  Double_t dPosX =
6495  ((Double_t)(-iNbCh / 2 + iCh) + 0.5) * fChannelInfo->GetSizex();
6496  Double_t dTotS = xDigiA->GetTot() + xDigiB->GetTot();
6497  Double_t dNewTotS = (dLastTotS + dTotS);
6498  dLastPosX = (dLastPosX * dLastTotS + dPosX * dTotS) / dNewTotS;
6499  dLastPosY = (dLastPosY * dLastTotS + dPosY * dTotS) / dNewTotS;
6500  dLastTime = (dLastTime * dLastTotS + dTime * dTotS) / dNewTotS;
6501  dLastTotS = dNewTotS;
6502  // attach selected digis from pool
6503  Int_t Ind1 = fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i1];
6504  Int_t Ind2 = fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh][i2];
6505  vDigiIndRef.push_back(Ind1);
6506  vDigiIndRef.push_back(Ind2);
6507  // remove selected digis from pool
6508  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6509  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
6510  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6511  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + i1);
6512 
6513  std::vector<int>::iterator it;
6514  it = find(fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin(),
6515  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].end(),
6516  Ind2);
6517  if (it != fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].end()) {
6518  auto ipos =
6519  it - fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin();
6520  LOG(debug) << "Found i2 " << i2 << " with Ind2 " << Ind2
6521  << " at position " << ipos;
6522  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6523  fStorDigiExp[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
6524  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].erase(
6525  fStorDigiInd[iSmType][iSm * iNbRpc + iRpc][iCh].begin() + ipos);
6526  } else {
6527  LOG(fatal) << " Did not find i2 " << i2 << " with Ind2 " << Ind2;
6528  }
6529 
6530  //if(iCh == iNbCh-1) break; //Last strip reached
6531  if (iCh != (iNbCh - 1)
6532  && AddNextChan(iSmType,
6533  iSm,
6534  iRpc,
6535  iCh,
6536  dLastPosX,
6537  dLastPosY,
6538  dLastTime,
6539  dLastTotS)) {
6540  LOG(debug) << "Added Strip " << iCh << " to cluster of size "
6541  << dNClHits;
6542  return kTRUE; // signal hit was already added
6543  }
6544  AddedHit = kTRUE;
6545  } //TMath::Abs(dPosY - dLastPosY) < fdMaxSpaceDist
6546  } //TMath::Abs(dTime-dLastTime)<fdMaxTimeDist)
6547  i2++;
6548  } // while(i2 < fStorDigiExp[iSmType][iSm*iNbRpc+iRpc][iCh].size()-1 )
6549  } // end for i1
6550  } // end if size
6551  Double_t hitpos_local[3] = {3 * 0.};
6552  hitpos_local[0] = dLastPosX;
6553  hitpos_local[1] = dLastPosY;
6554  hitpos_local[2] = 0.;
6555  Double_t hitpos[3];
6556  /*TGeoNode* cNode = */ gGeoManager->GetCurrentNode();
6557  /*TGeoHMatrix* cMatrix = */ gGeoManager->GetCurrentMatrix();
6558  gGeoManager->LocalToMaster(hitpos_local, hitpos);
6559  TVector3 hitPos(hitpos[0], hitpos[1], hitpos[2]);
6560  TVector3 hitPosErr(0.5, 0.5, 0.5); // FIXME including positioning uncertainty
6561  Int_t iChm = floor(dLastPosX / fChannelInfo->GetSizex()) + iNbCh / 2;
6562  if (iChm < 0) iChm = 0;
6563  if (iChm > iNbCh - 1) iChm = iNbCh - 1;
6564  Int_t iDetId = CbmTofAddress::GetUniqueAddress(iSm, iRpc, iChm, 0, iSmType);
6565 
6566  Int_t iNbChanInHit = vDigiIndRef.size() / 2;
6567  fviClusterMul[iSmType][iSm][iRpc]++;
6568 
6569  LOG(debug) << "Save A-Hit "
6570  << Form("%2d %2d 0x%08x %3d t %f, y %f ",
6571  fiNbHits,
6572  iNbChanInHit,
6573  iDetId,
6574  iLastChan,
6575  dLastTime,
6576  dLastPosY)
6577  << ", DigiSize: " << vDigiIndRef.size();
6578  LOG(debug) << ", DigiInds: ";
6579  for (UInt_t i = 0; i < vDigiIndRef.size(); i++) {
6580  LOG(debug) << " " << vDigiIndRef.at(i) << "(M"
6581  << fviClusterMul[iSmType][iSm][iRpc] << ")";
6582  }
6583  LOG(debug);
6584 
6585  CbmTofHit* pHit =
6586  new CbmTofHit(iDetId,
6587  hitPos,
6588  hitPosErr, //local detector coordinates
6589  fiNbHits, // this number is used as reference!!
6590  dLastTime,
6591  vDigiIndRef.size(), // number of linked digis = 2*CluSize
6592  Int_t(dLastTotS * 10.)); //channel -> Tot
6593  // output hit
6594  new ((*fTofHitsColl)[fiNbHits]) CbmTofHit(*pHit);
6595  if (fdMemoryTime > 0.) { // memorize hit
6596  LH_store(iSmType, iSm, iRpc, iChm, pHit);
6597  } else {
6598  pHit->Delete();
6599  }
6600  CbmMatch* digiMatch = new ((*fTofDigiMatchColl)[fiNbHits]) CbmMatch();
6601  for (size_t i = 0; i < vDigiIndRef.size(); i++) {
6602  Double_t dTot =
6603  ((CbmTofDigi*) (fTofCalDigisColl->At(vDigiIndRef.at(i))))->GetTot();
6604  digiMatch->AddLink(CbmLink(dTot, vDigiIndRef.at(i)));
6605  }
6606  fiNbHits++;
6607  vDigiIndRef.clear();
6608 
6609  return kTRUE;
6610 }
6611 
6613  Int_t iSm,
6614  Int_t iRpc,
6615  Int_t iChm,
6616  CbmTofHit* pHit) {
6617 
6618  if (fvLastHits[iSmType][iSm][iRpc][iChm].size() == 0)
6619  fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit);
6620  else {
6621  Double_t dLastTime = pHit->GetTime();
6622  if (dLastTime >= fvLastHits[iSmType][iSm][iRpc][iChm].back()->GetTime()) {
6623  fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit);
6624  LOG(debug) << Form(
6625  " Store LH from Ev %8.0f for TSRC %d%d%d%d, size %lu, addr 0x%08x, "
6626  "time %f, dt %f",
6627  fdEvent,
6628  iSmType,
6629  iSm,
6630  iRpc,
6631  iChm,
6632  fvLastHits[iSmType][iSm][iRpc][iChm].size(),
6633  pHit->GetAddress(),
6634  dLastTime,
6635  dLastTime - fvLastHits[iSmType][iSm][iRpc][iChm].front()->GetTime());
6636  } else {
6637  if (dLastTime
6638  >= fvLastHits[iSmType][iSm][iRpc][iChm]
6639  .front()
6640  ->GetTime()) { // hit has to be inserted in the proper place
6641  std::list<CbmTofHit*>::iterator it;
6642  for (it = fvLastHits[iSmType][iSm][iRpc][iChm].begin();
6643  it != fvLastHits[iSmType][iSm][iRpc][iChm].end();
6644  ++it)
6645  if ((*it)->GetTime() > dLastTime) break;
6646  fvLastHits[iSmType][iSm][iRpc][iChm].insert(--it, pHit);
6647  Double_t deltaTime = dLastTime - (*it)->GetTime();
6648  LOG(debug) << Form("Hit inserted into LH from Ev %8.0f for TSRC "
6649  "%d%d%d%d, size %lu, addr 0x%08x, delta time %f ",
6650  fdEvent,
6651  iSmType,
6652  iSm,
6653  iRpc,
6654  iChm,
6655  fvLastHits[iSmType][iSm][iRpc][iChm].size(),
6656  pHit->GetAddress(),
6657  deltaTime);
6658  } else { // this hit is first
6659  Double_t deltaTime =
6660  dLastTime - fvLastHits[iSmType][iSm][iRpc][iChm].front()->GetTime();
6661  LOG(debug) << Form("first LH from Ev %8.0f for TSRC %d%d%d%d, size "
6662  "%lu, addr 0x%08x, delta time %f ",
6663  fdEvent,
6664  iSmType,
6665  iSm,
6666  iRpc,
6667  iChm,
6668  fvLastHits[iSmType][iSm][iRpc][iChm].size(),
6669  pHit->GetAddress(),
6670  deltaTime);
6671  if (deltaTime == 0.) {
6672  // remove hit, otherwise double entry?
6673  pHit->Delete();
6674  } else {
6675  fvLastHits[iSmType][iSm][iRpc][iChm].push_front(pHit);
6676  }
6677  }
6678  }
6679  }
6680 }
6681 
6682 Double_t CbmTofCosmicClusterizer::TimeInPeriod(Double_t dTime) {
6683  Double_t dP = dTime / fdTimePeriod;
6684  Long_t iP = TMath::Floor(dP);
6685  Double_t dPtime = dTime - (Double_t) iP * fdTimePeriod;
6686  // LOG(debug1)<<Form(" %f, %d -> %f ",dTime,iP,dPtime);
6687  return dPtime;
6688 }
CbmTofDigiBdfPar.h
CbmTofCosmicClusterizer::fhNbDigiPerChan
TH1 * fhNbDigiPerChan
Definition: CbmTofCosmicClusterizer.h:368
CbmTofCell::GetZ
Double_t GetZ() const
Definition: CbmTofCell.h:38
CbmTofCosmicClusterizer::fMaxTimeDist
Double_t fMaxTimeDist
Definition: CbmTofCosmicClusterizer.h:410
CbmTofCosmicClusterizer::fCalParFileName
TString fCalParFileName
Definition: CbmTofCosmicClusterizer.h:421
CbmTofCosmicClusterizer::fhRpcCluTot
std::vector< TH2 * > fhRpcCluTot
Definition: CbmTofCosmicClusterizer.h:315
CbmTofCosmicClusterizer::fDetIdIndexMap
std::map< UInt_t, UInt_t > fDetIdIndexMap
Definition: CbmTofCosmicClusterizer.h:398
iNWalkSmooth
const Int_t iNWalkSmooth
Definition: CbmTofClusterizersDef.h:49
CbmHit::GetZ
Double_t GetZ() const
Definition: CbmHit.h:70
CbmTofCosmicClusterizer
Definition: CbmTofCosmicClusterizer.h:50
CbmTofCosmicClusterizer::RegisterOutputs
Bool_t RegisterOutputs()
Create and register output TClonesArray of Tof Hits.
Definition: CbmTofCosmicClusterizer.cxx:381
CbmTofCosmicClusterizer::fdTOTMin
Double_t fdTOTMin
Definition: CbmTofCosmicClusterizer.h:431
CbmTofCosmicClusterizer::fit_ybox
virtual void fit_ybox(const char *hname)
Definition: CbmTofCosmicClusterizer.cxx:6252
CbmMatch
Definition: CbmMatch.h:22
CbmPixelHit::SetY
void SetY(Double_t y)
Definition: CbmPixelHit.h:103
CbmTofDigi::ToString
std::string ToString() const
Definition: CbmTofDigi.cxx:47
CbmTofCell::GetSizex
Double_t GetSizex() const
Definition: CbmTofCell.h:40
CbmTofCosmicClusterizer::fhTSmCluTRun
std::vector< std::vector< TH2 * > > fhTSmCluTRun
Definition: CbmTofCosmicClusterizer.h:343
CbmTofCosmicClusterizer::fhRpcDTLastHits
std::vector< TH1 * > fhRpcDTLastHits
Definition: CbmTofCosmicClusterizer.h:325
CbmTofCosmicClusterizer::fbPs2Ns
Bool_t fbPs2Ns
Definition: CbmTofCosmicClusterizer.h:419
CbmTofCosmicClusterizer::fhTRpcCluTOffDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluTOffDTLastHits
Definition: CbmTofCosmicClusterizer.h:344
CbmTofCosmicClusterizer::fvdDifX
std::vector< std::vector< std::vector< Double_t > > > fvdDifX
Definition: CbmTofCosmicClusterizer.h:273
CbmTofGeoHandler::GetCounter
Int_t GetCounter(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:469
CbmTofAddress::GetSmType
static Int_t GetSmType(UInt_t address)
Definition: CbmTofAddress.h:82
CbmTofCosmicClusterizer::fTotMean
Double_t fTotMean
Definition: CbmTofCosmicClusterizer.h:407
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmTofCosmicClusterizer::fiNevtBuild
Int_t fiNevtBuild
Definition: CbmTofCosmicClusterizer.h:427
CbmMatch::GetLink
const CbmLink & GetLink(Int_t i) const
Definition: CbmMatch.h:35
CbmTofCosmicClusterizer::fhSmCluPosition
std::vector< TH2 * > fhSmCluPosition
Definition: CbmTofCosmicClusterizer.h:321
CbmMatch::GetNofLinks
Int_t GetNofLinks() const
Definition: CbmMatch.h:38
CbmTofCosmicClusterizer::fTofDigiMatchColl
TClonesArray * fTofDigiMatchColl
Definition: CbmTofCosmicClusterizer.h:245
CbmTofCosmicClusterizer::fhRpcCluTimeEvol
std::vector< TProfile * > fhRpcCluTimeEvol
Definition: CbmTofCosmicClusterizer.h:308
nbClDelTofBinY
const Int_t nbClDelTofBinY
Definition: CbmTofClusterizersDef.h:60
CbmTofCosmicClusterizer::vDigiIndRef
std::vector< Int_t > vDigiIndRef
Definition: CbmTofCosmicClusterizer.h:400
CbmStsAddress::GetAddress
Int_t GetAddress(UInt_t unit=0, UInt_t ladder=0, UInt_t halfladder=0, UInt_t module=0, UInt_t sensor=0, UInt_t side=0, UInt_t version=kCurrentVersion)
Construct address.
Definition: CbmStsAddress.cxx:90
CbmTofDigi::SetTime
void SetTime(Double_t time)
Definition: CbmTofDigi.h:153
CbmTofCosmicClusterizer::fhClustBuildTime
TH1 * fhClustBuildTime
Definition: CbmTofCosmicClusterizer.h:280
CbmTofCosmicClusterizer::fTrbHeader
TTrbHeader * fTrbHeader
Definition: CbmTofCosmicClusterizer.h:233
CbmTofCosmicClusterizer::fdTTotMean
Double_t fdTTotMean
Definition: CbmTofCosmicClusterizer.h:432
CbmTofCosmicClusterizer::fhRpcCluDelPos
std::vector< TH2 * > fhRpcCluDelPos
Definition: CbmTofCosmicClusterizer.h:309
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmTofCosmicClusterizer::SetCalMode
void SetCalMode(Int_t iMode)
Definition: CbmTofCosmicClusterizer.h:94
CbmTofCosmicClusterizer::fhTimePtVsHits
TH2 * fhTimePtVsHits
Definition: CbmTofCosmicClusterizer.h:285
CbmTofCosmicClusterizer::fviClusterMul
std::vector< std::vector< std::vector< Int_t > > > fviClusterMul
Definition: CbmTofCosmicClusterizer.h:263
CbmTofCosmicClusterizer::fhRpcCluDelTOff
std::vector< TH2 * > fhRpcCluDelTOff
Definition: CbmTofCosmicClusterizer.h:312
CbmTofCosmicClusterizer::fvdDifCh
std::vector< std::vector< std::vector< Double_t > > > fvdDifCh
Definition: CbmTofCosmicClusterizer.h:277
CbmTofCosmicClusterizer::fhCluMulCorDutSel
TH2 * fhCluMulCorDutSel
Definition: CbmTofCosmicClusterizer.h:301
CbmTofCosmicClusterizer::fhRpcCluAvWalk
std::vector< TH2 * > fhRpcCluAvWalk
Definition: CbmTofCosmicClusterizer.h:317
CbmTofCosmicClusterizer::TimeInPeriod
virtual Double_t TimeInPeriod(Double_t dTime)
Definition: CbmTofCosmicClusterizer.cxx:6682
CbmTofDigiBdfPar::GetNbChan
Int_t GetNbChan(Int_t iSmType, Int_t iRpc) const
Definition: CbmTofDigiBdfPar.cxx:570
CbmTofCosmicClusterizer::fhRpcCluRate
std::vector< TH1 * > fhRpcCluRate
Definition: CbmTofCosmicClusterizer.h:305
CbmTofDigiPar::GetNrOfModules
Int_t GetNrOfModules()
Definition: CbmTofDigiPar.h:44
CbmTofCosmicClusterizer::fvCPTOff
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTOff
Definition: CbmTofCosmicClusterizer.h:354
CbmTofCosmicClusterizer::fhTRpcCluWalk
std::vector< std::vector< std::vector< std::vector< TH2 * > > > > fhTRpcCluWalk
Definition: CbmTofCosmicClusterizer.h:338
CbmTofCosmicClusterizer::fhRpcCluDelMatPos
std::vector< TH2 * > fhRpcCluDelMatPos
Definition: CbmTofCosmicClusterizer.h:310
CbmTofCosmicClusterizer::fPosYMaxScal
Double_t fPosYMaxScal
Definition: CbmTofCosmicClusterizer.h:402
CbmTofCosmicClusterizer::fhClustSizeDifY
TH2 * fhClustSizeDifY
Definition: CbmTofCosmicClusterizer.h:298
CbmTofCosmicClusterizer::fhRpcCluWalk
std::vector< std::vector< std::vector< TH2 * > > > fhRpcCluWalk
Definition: CbmTofCosmicClusterizer.h:320
rootMgr
static FairRootManager * rootMgr
Definition: CbmDeviceHitBuilderTof.cxx:72
CbmTofCosmicClusterizer::fDutId
Int_t fDutId
Definition: CbmTofCosmicClusterizer.h:384
CbmTofCosmicClusterizer::fiMsgCnt
Int_t fiMsgCnt
Definition: CbmTofCosmicClusterizer.h:428
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmTofCosmicClusterizer::fbWriteDigisInOut
Bool_t fbWriteDigisInOut
Definition: CbmTofCosmicClusterizer.h:242
CbmTofCosmicClusterizer::fhTRpcCluTotDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluTotDTLastHits
Definition: CbmTofCosmicClusterizer.h:345
CbmTofCosmicClusterizer::AddNextChan
virtual Bool_t AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iLastChan, Double_t dLastPosX, Double_t dLastPosY, Double_t dLastTime, Double_t dLastTot)
Definition: CbmTofCosmicClusterizer.cxx:6422
dDoubleMax
const Double_t dDoubleMax
Definition: CbmTofClusterizersDef.h:36
CbmTofDigiBdfPar::GetNbRpc
Int_t GetNbRpc(Int_t iSmType) const
Definition: CbmTofDigiBdfPar.cxx:519
CbmTofCosmicClusterizer::dTRef
Double_t dTRef
Definition: CbmTofCosmicClusterizer.h:375
CbmTofCosmicClusterizer::fChannelInfo
CbmTofCell * fChannelInfo
Definition: CbmTofCosmicClusterizer.h:230
StartAnalysisTime
static Double_t StartAnalysisTime
Definition: CbmTofCosmicClusterizer.cxx:61
CbmTofCosmicClusterizer::fhSmCluSvel
std::vector< TProfile * > fhSmCluSvel
Definition: CbmTofCosmicClusterizer.h:323
CbmTofCosmicClusterizer::fdMaxTimeDist
Double_t fdMaxTimeDist
Definition: CbmTofCosmicClusterizer.h:435
CbmTofCosmicClusterizer::fhDigSpacDifClust
TH1 * fhDigSpacDifClust
Definition: CbmTofCosmicClusterizer.h:294
CbmTofCosmicClusterizer::fhHiTrkMulPos
TH2 * fhHiTrkMulPos
Definition: CbmTofCosmicClusterizer.h:291
CbmTofAddress::GetRpcId
static Int_t GetRpcId(UInt_t address)
Definition: CbmTofAddress.h:89
nbCldXdYBinX
const Int_t nbCldXdYBinX
Definition: CbmTofClusterizersDef.h:63
CbmTofCosmicClusterizer::fGeoHandler
CbmTofGeoHandler * fGeoHandler
Definition: CbmTofCosmicClusterizer.h:227
CbmTofDigi::SetTot
void SetTot(Double_t tot)
Definition: CbmTofDigi.h:154
CbmTofCosmicClusterizer::fTotMin
Double_t fTotMin
Definition: CbmTofCosmicClusterizer.h:405
CbmTofDigiBdfPar::GetChanOrient
Int_t GetChanOrient(Int_t iSmType, Int_t iRpc) const
Definition: CbmTofDigiBdfPar.cxx:590
CbmTofCosmicClusterizer::fEnableAvWalk
Bool_t fEnableAvWalk
Definition: CbmTofCosmicClusterizer.h:418
CbmTofCosmicClusterizer::fdTimePeriod
Double_t fdTimePeriod
Definition: CbmTofCosmicClusterizer.h:414
iMess
static Int_t iMess
Definition: CbmDeviceHitBuilderTof.cxx:68
CbmTofCosmicClusterizer::fStorDigiInd
std::vector< std::vector< std::vector< std::vector< Int_t > > > > fStorDigiInd
Definition: CbmTofCosmicClusterizer.h:255
CbmTofCosmicClusterizer::fiNbHits
Int_t fiNbHits
Definition: CbmTofCosmicClusterizer.h:246
CbmTofDigiBdfPar::GetSigVel
Double_t GetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc) const
Definition: CbmTofDigiBdfPar.cxx:546
CbmTofDigiBdfPar::GetNbSmTypes
Int_t GetNbSmTypes() const
Definition: CbmTofDigiBdfPar.h:56
CbmTofCosmicClusterizer::fdMaxSpaceDist
Double_t fdMaxSpaceDist
Definition: CbmTofCosmicClusterizer.h:437
CbmTofDigiBdfPar::GetDetInd
Int_t GetDetInd(Int_t iAddr)
Definition: CbmTofDigiBdfPar.cxx:878
CbmTofCosmicClusterizer::fhRpcCluPositionEvol
std::vector< TProfile * > fhRpcCluPositionEvol
Definition: CbmTofCosmicClusterizer.h:307
CbmTofDigi.h
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmTofDigiPar.h
CbmMatch.h
CbmTofCosmicClusterizer::fhRpcCluPosition
std::vector< TH2 * > fhRpcCluPosition
Definition: CbmTofCosmicClusterizer.h:306
CbmTofDigi::GetSm
Double_t GetSm() const
Sm.
Definition: CbmTofDigi.h:124
CbmTofCosmicClusterizer::fTofCalDigisColl
TClonesArray * fTofCalDigisColl
Definition: CbmTofCosmicClusterizer.h:243
CbmTofCosmicClusterizer::fDigiBdfPar
CbmTofDigiBdfPar * fDigiBdfPar
Definition: CbmTofCosmicClusterizer.h:231
CbmTofCosmicClusterizer::fSelRpc
Int_t fSelRpc
Definition: CbmTofCosmicClusterizer.h:390
CbmTofCosmicClusterizer::fCalSmAddr
Int_t fCalSmAddr
Definition: CbmTofCosmicClusterizer.h:379
CbmTofAddress::GetSmId
static Int_t GetSmId(UInt_t address)
Definition: CbmTofAddress.h:75
CbmTofDigiPar::GetCell
CbmTofCell * GetCell(Int_t i)
Definition: CbmTofDigiPar.h:48
CbmTofCosmicClusterizer::fhRpcCluTrms
std::vector< TH2 * > fhRpcCluTrms
Definition: CbmTofCosmicClusterizer.h:314
CbmTofCosmicClusterizer::fdTOTMax
Double_t fdTOTMax
Definition: CbmTofCosmicClusterizer.h:430
CbmTofGeoHandler::GetSModule
Int_t GetSModule(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:464
CbmTofCosmicClusterizer::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmTofCosmicClusterizer.cxx:316
CbmTofCosmicClusterizer::fSelId
Int_t fSelId
Definition: CbmTofCosmicClusterizer.h:388
CbmTofCosmicClusterizer::LoadGeometry
Bool_t LoadGeometry()
Load the geometry: for now just resizing the Digis temporary vectors.
Definition: CbmTofCosmicClusterizer.cxx:755
CbmTofCosmicClusterizer::fhTRpcCluMul
std::vector< std::vector< TH1 * > > fhTRpcCluMul
Definition: CbmTofCosmicClusterizer.h:329
cLight
const Double_t cLight
Definition: CbmTofCosmicClusterizer.cxx:62
CbmTofCosmicClusterizer::fTotPreRange
Double_t fTotPreRange
Definition: CbmTofCosmicClusterizer.h:409
CbmTofCosmicClusterizer::fhTrk1MulPos
TH2 * fhTrk1MulPos
Definition: CbmTofCosmicClusterizer.h:290
CbmTofCosmicClusterizer::InitParameters
Bool_t InitParameters()
Initialize other parameters not included in parameter classes.
Definition: CbmTofCosmicClusterizer.cxx:400
CbmTofGeoHandler.h
CbmTofCosmicClusterizer::fvdDifY
std::vector< std::vector< std::vector< Double_t > > > fvdDifY
Definition: CbmTofCosmicClusterizer.h:275
CbmTofCosmicClusterizer::fTotMax
Double_t fTotMax
Definition: CbmTofCosmicClusterizer.h:404
CbmTofDetectorId_v14a.h
CbmTofCosmicClusterizer::fTRefMode
Int_t fTRefMode
Definition: CbmTofCosmicClusterizer.h:382
CbmTofDigi::GetSide
Double_t GetSide() const
Channel Side.
Definition: CbmTofDigi.h:142
CbmTofCosmicClusterizer::fhAllTrkMulPos
TH2 * fhAllTrkMulPos
Definition: CbmTofCosmicClusterizer.h:292
CbmTofCosmicClusterizer::CleanLHMemory
virtual void CleanLHMemory()
Definition: CbmTofCosmicClusterizer.cxx:6365
CbmTofCosmicClusterizer::fhSmCluTOff
std::vector< TH2 * > fhSmCluTOff
Definition: CbmTofCosmicClusterizer.h:322
CbmTofCosmicClusterizer::fviDetId
std::vector< Int_t > fviDetId
Definition: CbmTofCosmicClusterizer.h:399
CbmTofCosmicClusterizer::fDutSm
Int_t fDutSm
Definition: CbmTofCosmicClusterizer.h:385
nbClDelTofBinX
const Int_t nbClDelTofBinX
Definition: CbmTofClusterizersDef.h:59
CbmTofDigi::GetType
Double_t GetType() const
Sm Type .
Definition: CbmTofDigi.h:128
CbmTofCosmicClusterizer::fhRpcCluDelMatTOff
std::vector< TH2 * > fhRpcCluDelMatTOff
Definition: CbmTofCosmicClusterizer.h:313
iNSel
const Int_t iNSel
Definition: CbmTofClusterizersDef.h:67
CbmTofCosmicClusterizer::fTofHitsColl
TClonesArray * fTofHitsColl
Definition: CbmTofCosmicClusterizer.h:244
TTrbHeader::GetTriggerPattern
UInt_t GetTriggerPattern() const
Definition: TTrbHeader.h:30
CbmTofCosmicClusterizer::fhClusterSizeType
TH2 * fhClusterSizeType
Definition: CbmTofCosmicClusterizer.h:287
CbmTofCosmicClusterizer::fSelAddr
Int_t fSelAddr
Definition: CbmTofCosmicClusterizer.h:391
CbmTofCosmicClusterizer::fhRpcCluSize
std::vector< TH2 * > fhRpcCluSize
Definition: CbmTofCosmicClusterizer.h:316
CbmTofCosmicClusterizer::InitCalibParameter
Bool_t InitCalibParameter()
Initialize other parameters not included in parameter classes.
Definition: CbmTofCosmicClusterizer.cxx:463
CbmTofCosmicClusterizer::DeleteHistos
Bool_t DeleteHistos()
Definition: CbmTofCosmicClusterizer.cxx:4693
CbmTofGeoHandler
Definition: CbmTofGeoHandler.h:30
CbmTofCosmicClusterizer::fSel2Id
Int_t fSel2Id
Definition: CbmTofCosmicClusterizer.h:392
CbmTofCosmicClusterizer::fSel2Addr
Int_t fSel2Addr
Definition: CbmTofCosmicClusterizer.h:395
CbmTofCosmicClusterizer::fvCPTotGain
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotGain
Definition: CbmTofCosmicClusterizer.h:356
CbmTofCosmicClusterizer::fdMemoryTime
Double_t fdMemoryTime
Definition: CbmTofCosmicClusterizer.h:412
CbmTofCosmicClusterizer::fviClusterSize
std::vector< std::vector< std::vector< Int_t > > > fviClusterSize
Definition: CbmTofCosmicClusterizer.h:265
CbmTofCosmicClusterizer::CbmTofCosmicClusterizer
CbmTofCosmicClusterizer()
Constructor.
Definition: CbmTofCosmicClusterizer.cxx:68
CbmTofCell::GetX
Double_t GetX() const
Definition: CbmTofCell.h:36
CbmTofDetectorId_v12b.h
CbmTofDigi::GetChannel
Double_t GetChannel() const
Channel .
Definition: CbmTofDigi.h:136
CbmHit::GetTime
Double_t GetTime() const
Definition: CbmHit.h:75
CbmTofCosmicClusterizer::fDutAddr
Int_t fDutAddr
Definition: CbmTofCosmicClusterizer.h:387
CbmTofAddress::GetChannelId
static Int_t GetChannelId(UInt_t address)
Definition: CbmTofAddress.h:96
iIndexDut
static Int_t iIndexDut
Definition: CbmTofCosmicClusterizer.cxx:60
CbmTofCosmicClusterizer::fhTRpcCluSizeDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluSizeDTLastHits
Definition: CbmTofCosmicClusterizer.h:346
CbmHit::GetAddress
Int_t GetAddress() const
Definition: CbmHit.h:73
k14a
@ k14a
Definition: CbmTofGeoHandler.h:17
vDigiIndRef
std::vector< Int_t > vDigiIndRef
Definition: CbmTofTestBeamClusterizer.cxx:64
CbmMatch::AddLink
void AddLink(const CbmLink &newLink)
Definition: CbmMatch.cxx:42
CbmTofCosmicClusterizer::fhTRpcCludXdY
std::vector< std::vector< TH2 * > > fhTRpcCludXdY
Definition: CbmTofCosmicClusterizer.h:336
CbmTofCosmicClusterizer::fhTSmCluTOff
std::vector< std::vector< TH2 * > > fhTSmCluTOff
Definition: CbmTofCosmicClusterizer.h:342
CbmTofDigi::GetTime
Double_t GetTime() const
Inherited from CbmDigi.
Definition: CbmTofDigi.h:111
CbmTofAddress.h
CbmTofCosmicClusterizer::fhRpcCluAvLnWalk
std::vector< TH2 * > fhRpcCluAvLnWalk
Definition: CbmTofCosmicClusterizer.h:318
CbmTofCosmicClusterizer::fdDelTofMax
Double_t fdDelTofMax
Definition: CbmTofCosmicClusterizer.h:408
CbmTofCosmicClusterizer::fhTrackMul
TH1 * fhTrackMul
Definition: CbmTofCosmicClusterizer.h:288
CbmTofDetectorId_v14a
Definition: CbmTofDetectorId_v14a.h:36
CbmTofCosmicClusterizer::Exec
virtual void Exec(Option_t *option)
Inherited from FairTask.
Definition: CbmTofCosmicClusterizer.cxx:289
CbmTofGeoHandler::Init
Int_t Init(Bool_t isSimulation=kFALSE)
Definition: CbmTofGeoHandler.cxx:39
CbmTofCosmicClusterizer::MergeClusters
Bool_t MergeClusters()
Definition: CbmTofCosmicClusterizer.cxx:6087
CbmTofDigiBdfPar::GetChanType
Int_t GetChanType(Int_t iSmType, Int_t iRpc) const
Definition: CbmTofDigiBdfPar.cxx:580
CbmTofCosmicClusterizer::fhTimeResSingHits
TH1 * fhTimeResSingHits
Definition: CbmTofCosmicClusterizer.h:283
CbmTofCosmicClusterizer::fhClusterSize
TH1 * fhClusterSize
Definition: CbmTofCosmicClusterizer.h:286
CbmTofCosmicClusterizer::fvLastHits
std::vector< std::vector< std::vector< std::vector< std::list< CbmTofHit * > > > > > fvLastHits
Definition: CbmTofCosmicClusterizer.h:363
CbmTofDigiBdfPar
Parameters class for the CBM ToF digitizer using beam data distributions.
Definition: CbmTofDigiBdfPar.h:30
CbmTofCosmicClusterizer::fhChDifDifY
TH2 * fhChDifDifY
Definition: CbmTofCosmicClusterizer.h:300
CbmTofCosmicClusterizer::CheckLHMemory
virtual void CheckLHMemory()
Definition: CbmTofCosmicClusterizer.cxx:6309
CbmTofCosmicClusterizer::fhRpcDTLastHits_Tot
std::vector< TH1 * > fhRpcDTLastHits_Tot
Definition: CbmTofCosmicClusterizer.h:326
CbmTofDetectorId::SetDetectorInfo
virtual Int_t SetDetectorInfo(const CbmTofDetectorInfo detectorInfo)=0
CbmTofCell.h
CbmTofCosmicClusterizer::fvCPWalk
std::vector< std::vector< std::vector< std::vector< std::vector< Double_t > > > > > fvCPWalk
Definition: CbmTofCosmicClusterizer.h:360
CbmTofCosmicClusterizer::fhClusterSizeMulti
TH2 * fhClusterSizeMulti
Definition: CbmTofCosmicClusterizer.h:289
CbmTofCosmicClusterizer::fhTRpcCluMemMulDTLastHits
std::vector< std::vector< TH2 * > > fhTRpcCluMemMulDTLastHits
Definition: CbmTofCosmicClusterizer.h:347
CbmTofCosmicClusterizer::fvdY
std::vector< std::vector< std::vector< Double_t > > > fvdY
Definition: CbmTofCosmicClusterizer.h:271
CbmTofCosmicClusterizer::fhSeldT
std::vector< TH1 * > fhSeldT
Definition: CbmTofCosmicClusterizer.h:349
CbmPixelHit::SetX
void SetX(Double_t x)
Definition: CbmPixelHit.h:102
CbmTofDetectorInfo
Definition: CbmTofDetectorId.h:20
nbClWalkBinY
const Int_t nbClWalkBinY
Definition: CbmTofClusterizersDef.h:45
fTofHitsColl
TClonesArray * fTofHitsColl
Definition: CbmHadronAnalysis.cxx:52
CbmTofDigi
Data class for expanded digital TOF information.
Definition: CbmTofDigi.h:38
CbmTofCosmicClusterizer::fhTimeResSingHitsB
TH2 * fhTimeResSingHitsB
Definition: CbmTofCosmicClusterizer.h:284
CbmTofCosmicClusterizer::fhPtsPerHit
TH1 * fhPtsPerHit
Definition: CbmTofCosmicClusterizer.h:282
CbmTofCell::GetSizey
Double_t GetSizey() const
Definition: CbmTofCell.h:41
CbmTofCosmicClusterizer::RegisterInputs
Bool_t RegisterInputs()
Recover pointer on input TClonesArray: TofPoints, TofDigis...
Definition: CbmTofCosmicClusterizer.cxx:330
CbmTofCosmicClusterizer::fStorDigiExp
std::vector< std::vector< std::vector< std::vector< CbmTofDigi * > > > > fStorDigiExp
Definition: CbmTofCosmicClusterizer.h:253
CbmTofCosmicClusterizer::fhRpcCluTOff
std::vector< TH2 * > fhRpcCluTOff
Definition: CbmTofCosmicClusterizer.h:311
CbmHit::SetTimeError
void SetTimeError(Double_t error)
Definition: CbmHit.h:89
CbmTofCosmicClusterizer::fhDigTimeDifClust
TH1 * fhDigTimeDifClust
Definition: CbmTofCosmicClusterizer.h:295
CbmTofCosmicClusterizer::fvCPTotOff
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPTotOff
Definition: CbmTofCosmicClusterizer.h:358
CbmHit::SetTime
void SetTime(Double_t time)
Definition: CbmHit.h:84
CbmTofGeoHandler::GetCell
Int_t GetCell(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:479
CbmTofDigiBdfPar::UseExpandedDigi
Bool_t UseExpandedDigi() const
Definition: CbmTofDigiBdfPar.h:85
CbmTofDigi::GetRpc
Double_t GetRpc() const
Detector aka Module aka RPC .
Definition: CbmTofDigi.h:132
CbmTofCosmicClusterizer::fhRpcDigiCor
std::vector< TH2 * > fhRpcDigiCor
Definition: CbmTofCosmicClusterizer.h:303
CbmTofCosmicClusterizer::fDutRpc
Int_t fDutRpc
Definition: CbmTofCosmicClusterizer.h:386
fdMemoryTime
static Double_t fdMemoryTime
Definition: CbmTofAnaTestbeam.cxx:86
CbmTofCosmicClusterizer::fInstance
static CbmTofCosmicClusterizer * fInstance
Definition: CbmTofCosmicClusterizer.h:178
CbmMCTrack.h
nbClWalkBinX
const Int_t nbClWalkBinX
Definition: CbmTofClusterizersDef.h:44
TTrbHeader.h
CbmTofCosmicClusterizer::FillHistos
Bool_t FillHistos()
Definition: CbmTofCosmicClusterizer.cxx:1987
CbmTofCosmicClusterizer::fTRefDifMax
Double_t fTRefDifMax
Definition: CbmTofCosmicClusterizer.h:403
CbmTofCosmicClusterizer::fiNbSameSide
Int_t fiNbSameSide
Definition: CbmTofCosmicClusterizer.h:366
CbmTofCosmicClusterizer::fhSmCluFpar
std::vector< std::vector< TProfile * > > fhSmCluFpar
Definition: CbmTofCosmicClusterizer.h:324
CbmTofCosmicClusterizer::fTofId
CbmTofDetectorId * fTofId
Definition: CbmTofCosmicClusterizer.h:228
dXdYMax
const Double_t dXdYMax
Definition: CbmTofClusterizersDef.h:65
CbmTofDigiBdfPar::GetNbDet
Int_t GetNbDet() const
Definition: CbmTofDigiBdfPar.cxx:876
CbmTofCosmicClusterizer::fhTRpcCluAvWalk
std::vector< std::vector< TH2 * > > fhTRpcCluAvWalk
Definition: CbmTofCosmicClusterizer.h:334
CbmTofCosmicClusterizer::fhTRpcCluPosition
std::vector< std::vector< TH2 * > > fhTRpcCluPosition
Definition: CbmTofCosmicClusterizer.h:330
CbmTofCosmicClusterizer::fhTRpcCluTot
std::vector< std::vector< TH2 * > > fhTRpcCluTot
Definition: CbmTofCosmicClusterizer.h:332
CbmTofCosmicClusterizer::fiCorMode
Int_t fiCorMode
Definition: CbmTofCosmicClusterizer.h:415
CbmTofCosmicClusterizer::fSel2Rpc
Int_t fSel2Rpc
Definition: CbmTofCosmicClusterizer.h:394
CbmTofCosmicClusterizer::fStop
TTimeStamp fStop
Definition: CbmTofCosmicClusterizer.h:372
CbmTofClusterizersDef.h
CbmTofCosmicClusterizer::fdCaldXdYMax
Double_t fdCaldXdYMax
Definition: CbmTofCosmicClusterizer.h:380
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTofCosmicClusterizer.h
CbmTofCosmicClusterizer::fCalParFile
TFile * fCalParFile
Definition: CbmTofCosmicClusterizer.h:424
CbmTofCosmicClusterizer::DeleteGeometry
Bool_t DeleteGeometry()
Delete the geometry related arrays: for now just clearing the Digis temporary vectors.
Definition: CbmTofCosmicClusterizer.cxx:881
CbmTofDigiPar
Definition: CbmTofDigiPar.h:18
CbmTofPoint.h
CbmTofCosmicClusterizer::fhHitsPerTracks
TH1 * fhHitsPerTracks
Definition: CbmTofCosmicClusterizer.h:281
CbmTofCosmicClusterizer::fhRpcDTLastHits_CluSize
std::vector< TH1 * > fhRpcDTLastHits_CluSize
Definition: CbmTofCosmicClusterizer.h:327
CbmTofCosmicClusterizer::fOutHstFileName
TString fOutHstFileName
Definition: CbmTofCosmicClusterizer.h:423
CbmTofCosmicClusterizer::fSelSm
Int_t fSelSm
Definition: CbmTofCosmicClusterizer.h:389
CbmTofCosmicClusterizer::fhDigDistClust
TH2 * fhDigDistClust
Definition: CbmTofCosmicClusterizer.h:296
CbmTofCosmicClusterizer::fvCPDelTof
std::vector< std::vector< std::vector< std::vector< Double_t > > > > fvCPDelTof
Definition: CbmTofCosmicClusterizer.h:352
CbmTofGeoHandler::GetSMType
Int_t GetSMType(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:459
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTofDigiPar::GetCellId
Int_t GetCellId(Int_t i)
Definition: CbmTofDigiPar.h:45
MaxNbEvent
const Double_t MaxNbEvent
Definition: CbmTofClusterizersDef.h:71
pRef
CbmTofDigiExp * pRef
Definition: CbmDeviceHitBuilderTof.cxx:75
nbCldXdYBinY
const Int_t nbCldXdYBinY
Definition: CbmTofClusterizersDef.h:64
CbmTofCosmicClusterizer::fSel2Sm
Int_t fSel2Sm
Definition: CbmTofCosmicClusterizer.h:393
CbmTofCosmicClusterizer::fvdX
std::vector< std::vector< std::vector< Double_t > > > fvdX
Definition: CbmTofCosmicClusterizer.h:269
ModMask
const Int_t ModMask
Definition: CbmTofClusterizersDef.h:38
CbmTofCosmicClusterizer::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmTofCosmicClusterizer.cxx:242
CbmTofCosmicClusterizer::fdChannelDeadtime
Double_t fdChannelDeadtime
Definition: CbmTofCosmicClusterizer.h:411
CbmTofCosmicClusterizer::fTRefHits
Int_t fTRefHits
Definition: CbmTofCosmicClusterizer.h:383
CbmTofCosmicClusterizer::fhTRpcCluTOff
std::vector< std::vector< TH2 * > > fhTRpcCluTOff
Definition: CbmTofCosmicClusterizer.h:331
CbmTofCosmicClusterizer::fStart
TTimeStamp fStart
Definition: CbmTofCosmicClusterizer.h:371
CbmTofCosmicClusterizer::fviTrkMul
std::vector< std::vector< std::vector< Int_t > > > fviTrkMul
Definition: CbmTofCosmicClusterizer.h:267
CbmTofHit
Definition: core/data/tof/CbmTofHit.h:26
CbmTofDigi::SetAddress
void SetAddress(Int_t address)
Definition: CbmTofDigi.h:147
CbmTofCosmicClusterizer::fDigiPar
CbmTofDigiPar * fDigiPar
Definition: CbmTofCosmicClusterizer.h:229
CbmTofDigiBdfPar::GetSignalSpeed
Double_t GetSignalSpeed() const
Definition: CbmTofDigiBdfPar.h:55
CbmTofCosmicClusterizer::fdYFitMin
Double_t fdYFitMin
Definition: CbmTofCosmicClusterizer.h:413
CbmTofDigiBdfPar::SetSigVel
void SetSigVel(Int_t iSmType, Int_t iSm, Int_t iRpc, Double_t dvel)
Definition: CbmTofDigiBdfPar.cxx:556
CbmTofCell::GetY
Double_t GetY() const
Definition: CbmTofCell.h:37
CbmTofCosmicClusterizer::fCalSel
Int_t fCalSel
Definition: CbmTofCosmicClusterizer.h:378
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
f1_xboxe
static Double_t f1_xboxe(double *x, double *par)
Definition: CbmTofCosmicClusterizer.cxx:6243
CbmTofCosmicClusterizer::fbWriteHitsInOut
Bool_t fbWriteHitsInOut
Definition: CbmTofCosmicClusterizer.h:241
CbmTofDigiBdfPar::GetMaxDistAlongCh
Double_t GetMaxDistAlongCh() const
Definition: CbmTofDigiBdfPar.h:97
CbmTofDigiBdfPar::GetDetUId
Int_t GetDetUId(Int_t iDet)
Definition: CbmTofDigiBdfPar.cxx:893
CbmTofDigi::GetAddress
Int_t GetAddress() const
Inherited from CbmDigi.
Definition: CbmTofDigi.h:98
CbmTofCosmicClusterizer::fhTRpcCluWalk2
std::vector< std::vector< TH3 * > > fhTRpcCluWalk2
Definition: CbmTofCosmicClusterizer.h:339
CbmTofCosmicClusterizer::fSel2MulMax
Int_t fSel2MulMax
Definition: CbmTofCosmicClusterizer.h:396
CbmTofCosmicClusterizer::~CbmTofCosmicClusterizer
virtual ~CbmTofCosmicClusterizer()
Destructor.
Definition: CbmTofCosmicClusterizer.cxx:234
TTrbHeader
Definition: TTrbHeader.h:10
CbmTofCosmicClusterizer::fhMultiTrkProbPos
TH2 * fhMultiTrkProbPos
Definition: CbmTofCosmicClusterizer.h:293
CbmTofCosmicClusterizer::fEnableMatchPosScaling
Bool_t fEnableMatchPosScaling
Definition: CbmTofCosmicClusterizer.h:417
CbmTofDigiBdfPar::ClustUseTrackId
Bool_t ClustUseTrackId() const
Definition: CbmTofDigiBdfPar.h:95
CbmTofCosmicClusterizer::fTofDigisColl
TClonesArray * fTofDigisColl
Definition: CbmTofCosmicClusterizer.h:238
CbmTofCosmicClusterizer::fCalMode
Int_t fCalMode
Definition: CbmTofCosmicClusterizer.h:377
CbmTofCosmicClusterizer::fhRpcCluMul
std::vector< TH1 * > fhRpcCluMul
Definition: CbmTofCosmicClusterizer.h:304
CbmTofCosmicClusterizer::LH_store
virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit *pHit)
Definition: CbmTofCosmicClusterizer.cxx:6612
PairAnalysisStyler::Fill
static Int_t Fill[]
Definition: PairAnalysisStyleDefs.h:82
CbmTofCosmicClusterizer::fhTRpcCluDelTof
std::vector< std::vector< TH2 * > > fhTRpcCluDelTof
Definition: CbmTofCosmicClusterizer.h:335
CbmTofDigiBdfPar::GetMaxTimeDist
Double_t GetMaxTimeDist() const
Definition: CbmTofDigiBdfPar.cxx:661
WalkNHmin
const Double_t WalkNHmin
Definition: CbmTofClusterizersDef.h:47
CbmTofCosmicClusterizer::CreateHistos
Bool_t CreateHistos()
Definition: CbmTofCosmicClusterizer.cxx:906
CbmTofCosmicClusterizer::fdEvent
Double_t fdEvent
Definition: CbmTofCosmicClusterizer.h:439
CbmTofCosmicClusterizer::fhClustSizeDifX
TH2 * fhClustSizeDifX
Definition: CbmTofCosmicClusterizer.h:297
CbmTofCosmicClusterizer::fhTRpcCluSize
std::vector< std::vector< TH2 * > > fhTRpcCluSize
Definition: CbmTofCosmicClusterizer.h:333
CbmTofCosmicClusterizer::BuildClusters
Bool_t BuildClusters()
Build clusters out of ToF Digis and store the resulting info in a TofHit.
Definition: CbmTofCosmicClusterizer.cxx:4727
CbmTofCosmicClusterizer::fhChDifDifX
TH2 * fhChDifDifX
Definition: CbmTofCosmicClusterizer.h:299
CbmTofCosmicClusterizer::fhTSmCluPosition
std::vector< std::vector< TH2 * > > fhTSmCluPosition
Definition: CbmTofCosmicClusterizer.h:341
CbmTofCosmicClusterizer::fhNbSameSide
TH1 * fhNbSameSide
Definition: CbmTofCosmicClusterizer.h:367
CbmTofCosmicClusterizer::fiCluMulMax
Int_t fiCluMulMax
Definition: CbmTofCosmicClusterizer.h:381
DetMask
const Int_t DetMask
Definition: CbmTofAnaTestbeam.cxx:75
CbmTofCosmicClusterizer::WriteHistos
Bool_t WriteHistos()
Definition: CbmTofCosmicClusterizer.cxx:3032
CbmTofCosmicClusterizer::SetParContainers
virtual void SetParContainers()
Inherited from FairTask.
Definition: CbmTofCosmicClusterizer.cxx:274
CbmTofDigiBdfPar::GetNbSm
Int_t GetNbSm(Int_t iSmType) const
Definition: CbmTofDigiBdfPar.cxx:513