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