CbmRoot
CbmTof.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmTof source file -----
3 // ----- Created 28/07/04 by V. Friese -----
4 // -------------------------------------------------------------------------
5 
6 #include "CbmTof.h"
7 
8 #include "CbmGeometryUtils.h"
9 #include "CbmStack.h"
10 #include "CbmTofGeoHandler.h"
11 #include "CbmTofPoint.h"
12 
13 #include <FairMCEventHeader.h>
14 #include <FairRunSim.h>
15 
16 #include <FairGeoBuilder.h>
17 #include <FairGeoMedia.h>
18 
19 #include "TClonesArray.h"
20 #include "TGeoManager.h"
21 #include "TGeoNode.h"
22 #include "TGeoPhysicalNode.h"
23 #include "TGeoVolume.h"
24 #include "TKey.h"
25 #include "TObjArray.h"
26 #include "TParticle.h"
27 #include "TVirtualMC.h"
28 #include <TFile.h>
29 
30 #include <boost/lexical_cast.hpp>
31 #include <boost/regex.hpp>
32 #include <iostream>
33 
34 using std::cout;
35 using std::endl;
36 
37 // ----- Default constructor -------------------------------------------
39  : FairDetector("TOF", kTRUE, ToIntegralType(ECbmModuleId::kTof))
40  , fTrackID(-1)
41  , fVolumeID(-1)
42  , fPos()
43  , fMom()
44  , fTime(-1.)
45  , fLength(-1.)
46  , fELoss(-1.)
47  , fPosIndex(0)
48  , fTofCollection(new TClonesArray("CbmTofPoint"))
49  , fGeoHandler(new CbmTofGeoHandler())
50  , fCombiTrans()
51  , fVolumeName("")
52  , fbOnePointPerTrack(kFALSE)
53  , fbIsNewTrack(kFALSE)
54  , fTofNodePath("")
55  , fCurrentNodePath("")
56  , fCurrentModuleType(0)
57  , fCurrentModuleIndex(0)
58  , fCurrentCounterIndex(0)
59  , fActiveCounters()
60  , fInactiveCounters()
61  , fInactiveCounterIDs()
62  , fCountersInBeam()
63  , fOutputTreeEntry(0)
64  , fbProcessAnyTrack(kFALSE)
65  , fbAllCountersInactive(kFALSE) {
66  fVerboseLevel = 1;
67 }
68 // -------------------------------------------------------------------------
69 
70 
71 // ----- Standard constructor ------------------------------------------
72 CbmTof::CbmTof(const char* name, Bool_t active)
73  : FairDetector(name, active, ToIntegralType(ECbmModuleId::kTof))
74  , fTrackID(-1)
75  , fVolumeID(-1)
76  , fPos()
77  , fMom()
78  , fTime(-1.)
79  , fLength(-1.)
80  , fELoss(-1.)
81  , fPosIndex(0)
82  , fTofCollection(new TClonesArray("CbmTofPoint"))
83  , fGeoHandler(new CbmTofGeoHandler())
84  , fCombiTrans()
85  , fVolumeName("")
86  , fbOnePointPerTrack(kFALSE)
87  , fbIsNewTrack(kFALSE)
88  , fTofNodePath("")
89  , fCurrentNodePath("")
90  , fCurrentModuleType(0)
91  , fCurrentModuleIndex(0)
92  , fCurrentCounterIndex(0)
93  , fActiveCounters()
94  , fInactiveCounters()
95  , fInactiveCounterIDs()
96  , fCountersInBeam()
97  , fOutputTreeEntry(0)
98  , fbProcessAnyTrack(kFALSE)
99  , fbAllCountersInactive(kFALSE) {
100  fVerboseLevel = 1;
101 }
102 // -------------------------------------------------------------------------
103 
104 
105 // ----- Destructor ----------------------------------------------------
107  if (fTofCollection) {
108  fTofCollection->Delete();
109  delete fTofCollection;
110  }
111  if (fGeoHandler) { delete fGeoHandler; }
112 
113  for (auto& CounterInBeam : fCountersInBeam) {
114  if ((CounterInBeam.second).second) { delete (CounterInBeam.second).second; }
115  }
116 }
117 // -------------------------------------------------------------------------
118 
120  FairDetector::Initialize();
121 
122  // Initialize the CbmTofGeoHandler helper class from the
123  // TVirtualMC interface
124  Bool_t isSimulation = kTRUE;
125  /*Int_t bla =*/fGeoHandler->Init(isSimulation);
126 
127  if (fbOnePointPerTrack) {
128  for (auto itInactiveCounter = fInactiveCounters.cbegin();
129  itInactiveCounter != fInactiveCounters.cend();) {
130  if (fActiveCounters.find(*itInactiveCounter) != fActiveCounters.end()) {
131  itInactiveCounter = fInactiveCounters.erase(itInactiveCounter);
132  } else {
133  // FIXME: Actually, a volume marked insensitive by 'FairModule::CheckifSensitive'
134  // should not be called 'FairDetector::ProcessHits' for. But the method
135  // 'FairMCApplication::Stepping' calls the latter for all volumes that share
136  // the same 'TGeoVolume::fNumber' with any volume marked sensitive. As all
137  // "Cell" volumes in the ToF geometry share the same volume number, namely "4",
138  // a single cell marked sensitive by 'CheckIfSensitive' results in all ToF
139  // cells being marked sensitive in 'FairMCApplication::Stepping'. For this reason,
140  // for each call of 'ProcessHits' the counter address needs to be checked against
141  // sensitivity.
143  std::get<0>(*itInactiveCounter),
144  std::get<1>(*itInactiveCounter),
145  std::get<2>(*itInactiveCounter),
146  0,
147  0);
148  fInactiveCounterIDs.emplace(
149  fGeoHandler->GetDetIdPointer()->SetDetectorInfo(tCounterInfo));
150 
151  ++itInactiveCounter;
152  }
153  }
154  }
155 }
156 
158  if (fbOnePointPerTrack) { fbIsNewTrack = kTRUE; }
159 }
160 
162  // method is called right before FairRootManager::Fill, once per FairDetector per event
163 
164  if (fbOnePointPerTrack) {
165  // loop over all MC points (1 point per counter) created by all tracks in the event
166  for (Int_t iPoint = 0; iPoint < fTofCollection->GetEntriesFast();
167  iPoint++) {
168  CbmTofPoint* tCurrentPoint =
169  dynamic_cast<CbmTofPoint*>(fTofCollection->At(iPoint));
170 
171  // average all point properties except for the energy loss in the gaps
172  Int_t iNCells = tCurrentPoint->GetNCells();
173  tCurrentPoint->SetTime(tCurrentPoint->GetTime() / iNCells);
174  tCurrentPoint->SetLength(tCurrentPoint->GetLength() / iNCells);
175  tCurrentPoint->SetX(tCurrentPoint->GetX() / iNCells);
176  tCurrentPoint->SetY(tCurrentPoint->GetY() / iNCells);
177  tCurrentPoint->SetZ(tCurrentPoint->GetZ() / iNCells);
178  tCurrentPoint->SetPx(tCurrentPoint->GetPx() / iNCells);
179  tCurrentPoint->SetPy(tCurrentPoint->GetPy() / iNCells);
180  tCurrentPoint->SetPz(tCurrentPoint->GetPz() / iNCells);
181 
182  if (1 == tCurrentPoint->GetNLinks()) {
183  // NOTE: 'FairMultiLinkedData_Interface::GetLink' returns a copy of the 'FairLink' object!
184  FairLink tLinkToTrack = tCurrentPoint->GetLink(0);
185  tLinkToTrack.SetLink(
186  0, fOutputTreeEntry, tLinkToTrack.GetType(), tLinkToTrack.GetIndex());
187  tCurrentPoint->SetLink(tLinkToTrack);
188  }
189 
190  // LOG(info)<<Form("ToF point in detector 0x%.8x at time %f ns", tCurrentPoint->GetDetectorID(), tCurrentPoint->GetTime());
191  }
192  }
193 
194  // Extract collision vertex information from the MC event header
195  FairMCEventHeader* tEventHeader = FairRunSim::Instance()->GetMCEventHeader();
196 
197  Double_t dTargetVertexT = tEventHeader->GetT(); // [s]
198  // Define a beam line parallel to Z through the collision vertex and another point shifted along Z
199  Double_t dGlobalTargetCoordinates[3] = {
200  tEventHeader->GetX(), tEventHeader->GetY(), tEventHeader->GetZ()};
201  Double_t dGlobalTargetCoordinates1[3] = {
202  tEventHeader->GetX(), tEventHeader->GetY(), tEventHeader->GetZ() + 1.};
203  Double_t dGlobalCounterCoordinates[3] = {0., 0., 0.};
204  Double_t dLocalTargetCoordinates[3] = {0., 0., 0.};
205  Double_t dLocalTargetCoordinates1[3] = {0., 0., 0.};
206  Double_t dLocalCounterCoordinates[3] = {0., 0., 0.};
207 
208  TGeoPhysicalNode* tCurrentNode(NULL);
209  Int_t iModuleType(0);
210  Int_t iModuleIndex(0);
211  Int_t iCounterIndex(0);
212  Int_t iUniqueCounterId(0);
213  CbmTofPoint* tBeamPoint(NULL);
214 
215  // Loop over all counters that are eligible for beam points
216  for (auto const& CounterInBeam : fCountersInBeam) {
217  iModuleType = std::get<0>(CounterInBeam.first);
218  iModuleIndex = std::get<1>(CounterInBeam.first);
219  iCounterIndex = std::get<2>(CounterInBeam.first);
220 
221  // Create the unique counter ID
222  CbmTofDetectorInfo tCounterInfo(
223  ECbmModuleId::kTof, iModuleType, iModuleIndex, iCounterIndex, 0, 0);
224  iUniqueCounterId =
225  fGeoHandler->GetDetIdPointer()->SetDetectorInfo(tCounterInfo);
226 
227  tCurrentNode = (CounterInBeam.second).second;
228 
229  // Transform the two points defining the beam line into the local coordinate system of the counter
230  tCurrentNode->GetMatrix()->MasterToLocal(dGlobalTargetCoordinates,
231  dLocalTargetCoordinates);
232  tCurrentNode->GetMatrix()->MasterToLocal(dGlobalTargetCoordinates1,
233  dLocalTargetCoordinates1);
234 
235  // Calculate the intersection point between the beam line and the counter plane in the local c.s.
236  dLocalCounterCoordinates[0] =
237  dLocalTargetCoordinates[0]
238  - dLocalTargetCoordinates[2]
239  * (dLocalTargetCoordinates1[0] - dLocalTargetCoordinates[0])
240  / (dLocalTargetCoordinates1[2] - dLocalTargetCoordinates[2]);
241  dLocalCounterCoordinates[1] =
242  dLocalTargetCoordinates[1]
243  - dLocalTargetCoordinates[2]
244  * (dLocalTargetCoordinates1[1] - dLocalTargetCoordinates[1])
245  / (dLocalTargetCoordinates1[2] - dLocalTargetCoordinates[2]);
246 
247  // Check if the intersection point is contained in the actual counter volume (i.e. glass plate/gap)
248  // If yes, create a CbmTofPoint for the beam traversing the counter
249  if (tCurrentNode->GetShape()->Contains(dLocalCounterCoordinates)) {
250  // Transform the local beam point into the global coordinate system
251  tCurrentNode->GetMatrix()->LocalToMaster(dLocalCounterCoordinates,
252  dGlobalCounterCoordinates);
253 
254  // Retrieve the beam momentum in laboratory to calculate the time of flight between the
255  // collision vertex in the target and the (global) beam point in the counter
256  Double_t dBeamMomentumLab = FairRunSim::Instance()->GetBeamMom();
257  Double_t dCounterBeamTime = dTargetVertexT;
258  // Distance between the collision vertex point and the beam point in the counter
259  // N.B.: The beam line is assumed to be parallel to Z
260  Double_t dCounterTargetDistance =
261  dGlobalCounterCoordinates[2] - dGlobalTargetCoordinates[2];
262 
263  if (0. < dBeamMomentumLab) {
264  Double_t dBeamVelocityLab =
265  dBeamMomentumLab
266  / TMath::Sqrt(TMath::Power(dBeamMomentumLab, 2.)
267  + TMath::Power(0.938271998, 2.))
268  * TMath::Ccgs(); // [cm/s]
269  dCounterBeamTime += dCounterTargetDistance / dBeamVelocityLab;
270  }
271 
272  // Create the beam point in the CbmTofPoint collection
273  tBeamPoint =
274  new ((*fTofCollection)[fTofCollection->GetEntriesFast()]) CbmTofPoint();
275  tBeamPoint->SetDetectorID(iUniqueCounterId);
276  tBeamPoint->SetEventID(
277  fOutputTreeEntry); // set to the exact same value in 'CbmMCPointBuffer::Fill'
278  tBeamPoint->SetTime(dCounterBeamTime * 1.0e09); // [ns]
279  tBeamPoint->SetLength(dCounterTargetDistance);
280  tBeamPoint->SetX(dGlobalCounterCoordinates[0]);
281  tBeamPoint->SetY(dGlobalCounterCoordinates[1]);
282  tBeamPoint->SetZ(dGlobalCounterCoordinates[2]);
283  tBeamPoint->SetPz(dBeamMomentumLab);
284  tBeamPoint->SetNCells(1);
285  }
286  }
287 
289 }
290 
291 // ----- Public method ProcessHits --------------------------------------
292 Bool_t CbmTof::ProcessHits(FairVolume* /*vol*/) {
293  if (fbOnePointPerTrack) {
294  // create/update CbmTofPoint objects for any charged particle or geantinos/rootinos
295  if (fbProcessAnyTrack || 0 != gMC->TrackCharge() || 0 == gMC->TrackPid()) {
296  Int_t iCounterID = fGeoHandler->GetUniqueCounterId();
297 
298  // If the current volume is marked insensitive, do not process the MC hit.
299  if (fInactiveCounterIDs.find(iCounterID) != fInactiveCounterIDs.end()) {
300  return kTRUE;
301  }
302 
303  Int_t iTrackID = gMC->GetStack()->GetCurrentTrackNumber();
304 
305  Double_t dTrackEnergyDeposit = gMC->Edep();
306 
307  CbmTofPoint* tCounterPoint(0);
308  Bool_t bCounterPointExists = kFALSE;
309 
310  // scan the MC point array only if an existing point may be found
311  if (!fbIsNewTrack) {
312  // loop over all MC points (1 point per counter) created by all tracks in the event so far
313  // in reverse order to find the proper MC point immediately
314  for (Int_t iPoint = fTofCollection->GetEntriesFast() - 1; iPoint >= 0;
315  iPoint--) {
316  tCounterPoint =
317  dynamic_cast<CbmTofPoint*>(fTofCollection->At(iPoint));
318 
319  if (tCounterPoint->GetDetectorID() == iCounterID
320  && tCounterPoint->GetTrackID() == iTrackID) {
321  bCounterPointExists = kTRUE;
322  break;
323  }
324  }
325  } else {
326  fbIsNewTrack = kFALSE;
327  }
328 
329  // first step of the track in the current gas gap (cell)
330  if (gMC->IsTrackEntering()) {
331  Double_t dTrackTime = gMC->TrackTime() * 1.0e09;
332  Double_t dTrackLength = gMC->TrackLength();
333  Double_t dTrackPositionX(0.);
334  Double_t dTrackPositionY(0.);
335  Double_t dTrackPositionZ(0.);
336  gMC->TrackPosition(dTrackPositionX, dTrackPositionY, dTrackPositionZ);
337  Double_t dTrackMomentumX(0.);
338  Double_t dTrackMomentumY(0.);
339  Double_t dTrackMomentumZ(0.);
340  Double_t dTrackEnergy(0.);
341  gMC->TrackMomentum(
342  dTrackMomentumX, dTrackMomentumY, dTrackMomentumZ, dTrackEnergy);
343 
344  if (bCounterPointExists) {
345  tCounterPoint->SetTime(tCounterPoint->GetTime() + dTrackTime);
346  tCounterPoint->SetLength(tCounterPoint->GetLength() + dTrackLength);
347  tCounterPoint->SetEnergyLoss(tCounterPoint->GetEnergyLoss()
348  + dTrackEnergyDeposit);
349  tCounterPoint->SetX(tCounterPoint->GetX() + dTrackPositionX);
350  tCounterPoint->SetY(tCounterPoint->GetY() + dTrackPositionY);
351  tCounterPoint->SetZ(tCounterPoint->GetZ() + dTrackPositionZ);
352  tCounterPoint->SetPx(tCounterPoint->GetPx() + dTrackMomentumX);
353  tCounterPoint->SetPy(tCounterPoint->GetPy() + dTrackMomentumY);
354  tCounterPoint->SetPz(tCounterPoint->GetPz() + dTrackMomentumZ);
355  tCounterPoint->SetNCells(tCounterPoint->GetNCells() + 1);
356  } else {
357  tCounterPoint =
358  new ((*fTofCollection)[fTofCollection->GetEntriesFast()])
359  CbmTofPoint();
360  tCounterPoint->SetTrackID(iTrackID);
361  tCounterPoint->SetDetectorID(iCounterID);
362  tCounterPoint->SetEventID(
363  fOutputTreeEntry); // set to the exact same value in 'CbmMCPointBuffer::Fill'
364 
365  tCounterPoint->SetTime(dTrackTime);
366  tCounterPoint->SetLength(dTrackLength);
367  tCounterPoint->SetEnergyLoss(dTrackEnergyDeposit);
368  tCounterPoint->SetX(dTrackPositionX);
369  tCounterPoint->SetY(dTrackPositionY);
370  tCounterPoint->SetZ(dTrackPositionZ);
371  tCounterPoint->SetPx(dTrackMomentumX);
372  tCounterPoint->SetPy(dTrackMomentumY);
373  tCounterPoint->SetPz(dTrackMomentumZ);
374  tCounterPoint->SetNCells(1);
375 
376  // Increment number of tof points for TParticle
377  CbmStack* stack = dynamic_cast<CbmStack*>(gMC->GetStack());
379  }
380 
381  tCounterPoint->SetGap(fGeoHandler->GetGap(iCounterID));
382  } else {
383  tCounterPoint->SetEnergyLoss(tCounterPoint->GetEnergyLoss()
384  + dTrackEnergyDeposit);
385  }
386  }
387  } else {
388  // Set parameters at entrance of volume. Reset ELoss.
389  if (gMC->IsTrackEntering()) {
390  fELoss = 0.;
391  fTime = gMC->TrackTime() * 1.0e09;
392  fLength = gMC->TrackLength();
393  gMC->TrackPosition(fPos);
394  gMC->TrackMomentum(fMom);
395  }
396 
397  // Sum energy loss for all steps in the active volume
398  fELoss += gMC->Edep();
399 
400  // Create CbmTofPoint at exit of active volume
401  if (((0 == gMC->GetStack()->GetCurrentTrack()->GetPdgCode())
402  || // Add geantinos/rootinos
403  (gMC->TrackCharge() != 0))
404  && (gMC->IsTrackExiting() || gMC->IsTrackStop()
405  || gMC->IsTrackDisappeared())) {
406 
407  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
408 
410 
411  LOG(debug2) << "CbmTof::TID: " << fTrackID;
412  LOG(debug2) << " TofVol: " << fVolumeID;
413  LOG(debug2) << " DetSys: " << fGeoHandler->GetDetSystemId(fVolumeID);
414  LOG(debug2) << " SMtype: " << fGeoHandler->GetSMType(fVolumeID);
415  LOG(debug2) << " SModule: " << fGeoHandler->GetSModule(fVolumeID);
416  LOG(debug2) << " Counter: " << fGeoHandler->GetCounter(fVolumeID);
417  LOG(debug2) << " Gap: " << fGeoHandler->GetGap(fVolumeID);
418  LOG(debug2) << " Cell: " << fGeoHandler->GetCell(fVolumeID);
419  LOG(debug2) << Form(" x: %6.2f", fPos.X());
420  LOG(debug2) << Form(" y: %6.2f", fPos.Y());
421  LOG(debug2) << Form(" z: %6.2f", fPos.Z());
422  // LOG(debug2)<<"Region: "<<fGeoHandler->GetRegion(fVolumeID);
423  // LOG(debug2)<<"*************";
424 
425  //fVolumeID = ((region-1)<<24) + ((module-1)<<14) + ((cell-1)<<4) + (gap-1);
426 
428  fVolumeID,
429  TVector3(fPos.X(), fPos.Y(), fPos.Z()),
430  TVector3(fMom.Px(), fMom.Py(), fMom.Pz()),
431  fTime,
432  fLength,
433  fELoss);
434 
435  // Increment number of tof points for TParticle
436  CbmStack* stack = (CbmStack*) gMC->GetStack();
438 
439  ResetParameters();
440  }
441  }
442 
443  return kTRUE;
444 }
445 // -------------------------------------------------------------------------
446 
447 
448 // ----- Public method EndOfEvent --------------------------------------
450  if (fVerboseLevel) Print();
451  fTofCollection->Delete();
452  fPosIndex = 0;
453 }
454 // -------------------------------------------------------------------------
455 
456 
457 // ----- Public method Register ----------------------------------------
459  FairRootManager::Instance()->Register(
460  "TofPoint", "Tof", fTofCollection, kTRUE);
461 }
462 // -------------------------------------------------------------------------
463 
464 
465 // ----- Public method GetCollection -----------------------------------
466 TClonesArray* CbmTof::GetCollection(Int_t iColl) const {
467  if (iColl == 0)
468  return fTofCollection;
469  else
470  return NULL;
471 }
472 // -------------------------------------------------------------------------
473 
474 
475 // ----- Public method Print -------------------------------------------
476 void CbmTof::Print(Option_t*) const {
477  Int_t nHits = fTofCollection->GetEntriesFast();
478  LOG(info) << fName << ": " << nHits << " points registered in this event.";
479 
480  if (fVerboseLevel > 1)
481  for (Int_t i = 0; i < nHits; i++)
482  (*fTofCollection)[i]->Print();
483 }
484 // -------------------------------------------------------------------------
485 
486 
487 // ----- Public method Reset -------------------------------------------
489  fTofCollection->Delete();
490  ResetParameters();
491 }
492 // -------------------------------------------------------------------------
493 
494 
495 // ----- Public method CopyClones --------------------------------------
496 void CbmTof::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) {
497  Int_t nEntries = cl1->GetEntriesFast();
498  LOG(info) << "CbmTof: " << nEntries << " entries to add.";
499  TClonesArray& clref = *cl2;
500  CbmTofPoint* oldpoint = NULL;
501  for (Int_t i = 0; i < nEntries; i++) {
502  oldpoint = (CbmTofPoint*) cl1->At(i);
503  Int_t index = oldpoint->GetTrackID() + offset;
504  oldpoint->SetTrackID(index);
505  new (clref[fPosIndex]) CbmTofPoint(*oldpoint);
506  fPosIndex++;
507  }
508  LOG(info) << "CbmTof: " << cl2->GetEntriesFast() << " merged entries.";
509 }
510 // -------------------------------------------------------------------------
512  TString fileName = GetGeometryFileName();
513  if (fileName.EndsWith(".root")) {
515  // Create TGeoPhysicalNode objects for those counters eligible for beam points
517  } else {
518  LOG(fatal) << "Geometry format " << fileName << " not supported.";
519  }
520 }
521 
522 void CbmTof::ConstructRootGeometry(TGeoMatrix*) {
524  LOG(info) << "Importing TOF geometry from ROOT file " << fgeoName.Data();
526  } else {
527  LOG(info) << "Constructing TOF geometry from ROOT file " << fgeoName.Data();
528  FairModule::ConstructRootGeometry();
529  }
530 }
531 
532 // ----- Public method SetCounterActive --------------------------------
533 void CbmTof::SetCounterActive(Int_t iModuleType,
534  Int_t iModuleIndex,
535  Int_t iCounterIndex) {
536  fActiveCounters.emplace(
537  std::make_tuple(iModuleType, iModuleIndex, iCounterIndex));
538 }
539 // -------------------------------------------------------------------------
540 
541 
542 // ----- Public method SetCounterInactive ------------------------------
543 void CbmTof::SetCounterInactive(Int_t iModuleType,
544  Int_t iModuleIndex,
545  Int_t iCounterIndex) {
546  fInactiveCounters.emplace(
547  std::make_tuple(iModuleType, iModuleIndex, iCounterIndex));
548 }
549 // -------------------------------------------------------------------------
550 
551 
552 // ----- Public method SetCounterInBeam --------------------------------
553 void CbmTof::SetCounterInBeam(Int_t iModuleType,
554  Int_t iModuleIndex,
555  Int_t iCounterIndex) {
556  fCountersInBeam[std::make_tuple(iModuleType, iModuleIndex, iCounterIndex)];
557 }
558 // -------------------------------------------------------------------------
559 
560 
561 // ----- Private method CreateInBeamNodes ------------------------------
563  for (auto& CounterInBeam : fCountersInBeam) {
564  (CounterInBeam.second).second =
565  new TGeoPhysicalNode(((CounterInBeam.second).first).Data());
566  }
567 }
568 // -------------------------------------------------------------------------
569 
570 // ----- Private method CheckIfSensitive -------------------------------
571 Bool_t CbmTof::CheckIfSensitive(std::string name) {
572  // If the current Cell volume belongs to a counter declared inactive w.r.t.
573  // Monte Carlo point creation, it is not declared sensitive
574  TString tsname = name;
575  if (tsname.Contains("Cell")) {
576  // FIXME: This does not work at the moment (see comment in the 'Initialize' method).
577  for (auto const& InactiveCounter : fInactiveCounters) {
578  if (std::get<0>(InactiveCounter) == fCurrentModuleType
579  && std::get<1>(InactiveCounter) == fCurrentModuleIndex
580  && std::get<2>(InactiveCounter) == fCurrentCounterIndex) {
581  return kFALSE;
582  }
583  }
584 
585  return kTRUE;
586  }
587  return kFALSE;
588 }
589 // -------------------------------------------------------------------------
590 
591 
592 // ----- Private method AddHit -----------------------------------------
594  Int_t detID,
595  TVector3 pos,
596  TVector3 mom,
597  Double_t time,
598  Double_t length,
599  Double_t eLoss) {
600  TClonesArray& clref = *fTofCollection;
601  Int_t size = clref.GetEntriesFast();
602  return new (clref[size])
603  CbmTofPoint(trackID, detID, pos, mom, time, length, eLoss);
604 }
605 // -------------------------------------------------------------------------
606 
CbmTofPoint::GetNCells
Int_t GetNCells() const
Number of traversed cells @value Number of traversed cells.
Definition: CbmTofPoint.h:72
CbmTof::fLength
Double32_t fLength
time
Definition: CbmTof.h:162
CbmTofGeoHandler::GetDetSystemId
Int_t GetDetSystemId(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:454
CbmTof::GetCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
Definition: CbmTof.cxx:466
CbmTofGeoHandler::GetCounter
Int_t GetCounter(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:469
CbmTof::fInactiveCounterIDs
std::set< Int_t > fInactiveCounterIDs
Set of inactive counters.
Definition: CbmTof.h:187
CbmTof::fTrackID
Int_t fTrackID
Definition: CbmTof.h:157
CbmTof
Definition: CbmTof.h:35
CbmTof::AddHit
CbmTofPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss)
Definition: CbmTof.cxx:593
CbmTof::fOutputTreeEntry
Int_t fOutputTreeEntry
Map of counters in beam.
Definition: CbmTof.h:193
CbmTof::CreateInBeamNodes
void CreateInBeamNodes()
Definition: CbmTof.cxx:562
CbmTof.h
CbmTof::fTofCollection
TClonesArray * fTofCollection
Definition: CbmTof.h:166
CbmTof::fCurrentModuleType
Int_t fCurrentModuleType
Path to current physical node.
Definition: CbmTof.h:179
CbmTof::fELoss
Double32_t fELoss
length
Definition: CbmTof.h:163
CbmTof::ProcessHits
virtual Bool_t ProcessHits(FairVolume *vol=0)
Definition: CbmTof.cxx:292
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmTof::SetCounterActive
void SetCounterActive(Int_t iModuleType, Int_t iModuleIndex, Int_t iCounterIndex)
Definition: CbmTof.cxx:533
CbmTofGeoHandler::GetGap
Int_t GetGap(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:474
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmTof::fbProcessAnyTrack
Bool_t fbProcessAnyTrack
Definition: CbmTof.h:195
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmTofPoint::SetPz
void SetPz(Double_t pZ)
Set z component of momentum.
Definition: CbmTofPoint.h:108
CbmTof::CbmTof
CbmTof()
Definition: CbmTof.cxx:38
CbmTofGeoHandler::GetSModule
Int_t GetSModule(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:464
CbmTof::fVolumeID
Int_t fVolumeID
track index
Definition: CbmTof.h:158
CbmTof::fPos
TLorentzVector fPos
volume id
Definition: CbmTof.h:159
CbmStack.h
CbmTofGeoHandler.h
CbmTof::Initialize
virtual void Initialize()
Definition: CbmTof.cxx:119
CbmTofGeoHandler::GetUniqueCounterId
Int_t GetUniqueCounterId()
Definition: CbmTofGeoHandler.cxx:209
CbmTofGeoHandler::GetDetIdPointer
CbmTofDetectorId * GetDetIdPointer()
Definition: CbmTofGeoHandler.h:80
CbmStack::AddPoint
void AddPoint(ECbmModuleId iDet)
Definition: CbmStack.cxx:383
CbmTof::fCombiTrans
TGeoCombiTrans * fCombiTrans
Interface to gMC and gGeoManager.
Definition: CbmTof.h:170
CbmTofGeoHandler
Definition: CbmTofGeoHandler.h:30
Cbm::GeometryUtils::IsNewGeometryFile
Bool_t IsNewGeometryFile(TString &filename)
Definition: CbmGeometryUtils.cxx:133
CbmTof::ResetParameters
void ResetParameters()
Definition: CbmTof.h:231
CbmTof::fActiveCounters
std::set< std::tuple< Int_t, Int_t, Int_t > > fActiveCounters
Current counter index.
Definition: CbmTof.h:184
CbmTof::fCountersInBeam
std::map< std::tuple< Int_t, Int_t, Int_t >, std::pair< TString, TGeoPhysicalNode * > > fCountersInBeam
Set of inactive counter IDs.
Definition: CbmTof.h:191
CbmTofGeoHandler::Init
Int_t Init(Bool_t isSimulation=kFALSE)
Definition: CbmTofGeoHandler.cxx:39
CbmTof::fbOnePointPerTrack
Bool_t fbOnePointPerTrack
Name of Volume to be imported.
Definition: CbmTof.h:174
CbmTofGeoHandler::GetUniqueDetectorId
Int_t GetUniqueDetectorId()
Definition: CbmTofGeoHandler.cxx:149
CbmTof::fPosIndex
Int_t fPosIndex
energy loss
Definition: CbmTof.h:165
CbmTof::CopyClones
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Definition: CbmTof.cxx:496
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTof::ConstructGeometry
virtual void ConstructGeometry()
Definition: CbmTof.cxx:511
CbmTofDetectorId::SetDetectorInfo
virtual Int_t SetDetectorInfo(const CbmTofDetectorInfo detectorInfo)=0
CbmTofDetectorInfo
Definition: CbmTofDetectorId.h:20
CbmTof::fTime
Double32_t fTime
momentum
Definition: CbmTof.h:161
CbmTofPoint::SetPy
void SetPy(Double_t pY)
Set y component of momentum.
Definition: CbmTofPoint.h:102
CbmTof::fCurrentModuleIndex
Int_t fCurrentModuleIndex
Current module type.
Definition: CbmTof.h:180
CbmTofGeoHandler::GetCell
Int_t GetCell(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:479
CbmTof::fMom
TLorentzVector fMom
position
Definition: CbmTof.h:160
CbmTof::SetCounterInactive
void SetCounterInactive(Int_t iModuleType, Int_t iModuleIndex, Int_t iCounterIndex)
Definition: CbmTof.cxx:543
CbmTof::fGeoHandler
CbmTofGeoHandler * fGeoHandler
Hit collection.
Definition: CbmTof.h:167
CbmTof::CheckIfSensitive
Bool_t CheckIfSensitive(std::string name)
Definition: CbmTof.cxx:571
CbmTofPoint::SetGap
void SetGap(Int_t iGap)
Set a gap in the gap mask.
Definition: CbmTofPoint.cxx:90
CbmTof::ConstructRootGeometry
virtual void ConstructRootGeometry(TGeoMatrix *shift=NULL)
Definition: CbmTof.cxx:522
ToIntegralType
constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition: CbmDefs.h:24
CbmTofPoint.h
CbmTof::Print
virtual void Print(Option_t *="") const
Definition: CbmTof.cxx:476
CbmTof::Register
virtual void Register()
Definition: CbmTof.cxx:458
CbmTofGeoHandler::GetSMType
Int_t GetSMType(Int_t uniqueId)
Definition: CbmTofGeoHandler.cxx:459
CbmTof::FinishEvent
virtual void FinishEvent()
Definition: CbmTof.cxx:161
CbmTofPoint::SetPx
void SetPx(Double_t pX)
Set x component of momentum.
Definition: CbmTofPoint.h:96
CbmTofPoint::SetNCells
void SetNCells(Int_t nCells)
Set the number of traversed cells.
Definition: CbmTofPoint.h:114
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
Cbm::GeometryUtils::ImportRootGeometry
void ImportRootGeometry(TString &filename, FairModule *mod, TGeoMatrix *mat)
Definition: CbmGeometryUtils.cxx:140
CbmTofPoint
Geometric intersection of a MC track with a TOFb detector.
Definition: CbmTofPoint.h:40
CbmTof::fInactiveCounters
std::set< std::tuple< Int_t, Int_t, Int_t > > fInactiveCounters
Set of active counters.
Definition: CbmTof.h:186
CbmStack
Definition: CbmStack.h:45
CbmTof::fbIsNewTrack
Bool_t fbIsNewTrack
Definition: CbmTof.h:175
CbmTof::Reset
virtual void Reset()
Definition: CbmTof.cxx:488
CbmTof::EndOfEvent
virtual void EndOfEvent()
Definition: CbmTof.cxx:449
CbmTof::SetCounterInBeam
void SetCounterInBeam(Int_t iModuleType, Int_t iModuleIndex, Int_t iCounterIndex)
Definition: CbmTof.cxx:553
CbmTof::~CbmTof
virtual ~CbmTof()
Definition: CbmTof.cxx:106
CbmGeometryUtils.h
CbmTof::PreTrack
virtual void PreTrack()
Definition: CbmTof.cxx:157
CbmTof::fCurrentCounterIndex
Int_t fCurrentCounterIndex
Current module index.
Definition: CbmTof.h:181