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