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