CbmRoot
Loading...
Searching...
No Matches
CbmFsdMC.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 Physikalisches Institut Eberhard Karls Universitaet Tuebingen, Tuebingen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Alla Maevskaya, Florian Uhlig, Lukas Chlad [committer] */
4
12#include "CbmFsdMC.h"
13
14#include "CbmFsdGeoHandler.h"
15#include "CbmFsdPoint.h"
16#include "CbmGeometryUtils.h"
17#include "CbmModuleList.h"
18#include "CbmStack.h"
19
20#include <FairVolume.h>
21
22#include <TGeoNode.h>
23#include <TGeoVolume.h>
24#include <TVirtualMC.h>
25
26#include <cassert>
27#include <string>
28
29// ----- Destructor ----------------------------------------------------
31{
32 if (fFsdPoints) {
33 fFsdPoints->Delete();
34 delete fFsdPoints;
35 }
36}
37// -------------------------------------------------------------------------
38
39
40// ----- Construct the geometry from file ------------------------------
42{
43 LOG(info) << "Importing FSD geometry from ROOT file " << fgeoName.Data();
45}
46// -------------------------------------------------------------------------
47
48
49// ----- End of event action -------------------------------------------
51{
52 Print(); // Status output
53 fFsdPoints->Delete();
54}
55// -------------------------------------------------------------------------
56
57
58// ----- Print ---------------------------------------------------------
59void CbmFsdMC::Print(Option_t*) const
60{
61 LOG(info) << fName << ": " << fFsdPoints->GetEntriesFast() << " points registered in this event.";
62}
63// -------------------------------------------------------------------------
64
65// ----- Initialise ----------------------------------------------------
67{
68 // --- Instantiate the output array
69 fFsdPoints = new TClonesArray("CbmFsdPoint");
70
71 // --- Call the Initialise method of the mother class
72 FairDetector::Initialize();
73}
74// -------------------------------------------------------------------------
75
76
77// ----- Public method ProcessHits --------------------------------------
78Bool_t CbmFsdMC::ProcessHits(FairVolume*)
79{
80
81 // No action for neutral particles
82 if (TMath::Abs(gMC->TrackCharge()) <= 0) return kFALSE;
83
84 // --- If this is the first step for the track in the volume:
85 // Reset energy loss and store track parameters
86 if (gMC->IsTrackEntering()) {
87 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
88
90 gMC->TrackPosition(fPos);
91 gMC->TrackMomentum(fMom);
92 fTime = gMC->TrackTime() * 1.0e09;
93 fLength = gMC->TrackLength();
94 fEloss = 0.;
95 } //? track entering
96
97 // --- For all steps within active volume: sum up differential energy loss
98 fEloss += gMC->Edep();
99
100 // --- If track is leaving: get track parameters and create CbmstsPoint
101 if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
102
103 // Create CbmFsdPoint
104 Int_t size = fFsdPoints->GetEntriesFast();
105 new ((*fFsdPoints)[size]) CbmFsdPoint(fTrackID, fAddress, fPos.Vect(), fMom.Vect(), fTime, fLength, fEloss);
106
107 // --- Increment number of FsdPoints for this track in the stack
108 CbmStack* stack = dynamic_cast<CbmStack*>(gMC->GetStack());
109 assert(stack);
111
112 } //? track is exiting or stopped
113
114 return kTRUE;
115}
116// -------------------------------------------------------------------------
117
118
119// ----- Register the sensitive volumes --------------------------------
121{
122
123 TObjArray* daughters = node->GetVolume()->GetNodes();
124 for (Int_t iDaughter = 0; iDaughter < daughters->GetEntriesFast(); iDaughter++) {
125 TGeoNode* daughter = dynamic_cast<TGeoNode*>(daughters->At(iDaughter));
126 assert(daughter);
127 if (daughter->GetNdaughters() > 0) RegisterSensitiveVolumes(daughter);
128 TGeoVolume* daughterVolume = daughter->GetVolume();
129 if (CheckIfSensitive(daughterVolume->GetName())) { AddSensitiveVolume(daughterVolume); } //? Sensitive volume
130 } //# Daughter nodes
131}
132// -------------------------------------------------------------------------
133
134
ClassImp(CbmConverterManager)
@ kFsd
Forward spectator detector.
static constexpr size_t size()
Definition KfSimdPseudo.h:2
static CbmFsdGeoHandler & GetInstance()
int32_t GetCurrentAddress(TVirtualMC *vmc) const
Get the unique address from TVirtualMC.
Class for the MC transport of the CBM-FSD.
Definition CbmFsdMC.h:32
virtual Bool_t CheckIfSensitive(std::string name)
Check whether a volume is sensitive.
Definition CbmFsdMC.h:70
virtual Bool_t ProcessHits(FairVolume *volume=0)
Stepping action.
Definition CbmFsdMC.cxx:78
Int_t fTrackID
Output array.
Definition CbmFsdMC.h:144
TLorentzVector fMom
position
Definition CbmFsdMC.h:147
Double_t fTime
momentum
Definition CbmFsdMC.h:148
virtual void Print(Option_t *opt="") const
Screen log Prints current number of StsPoints in array. Virtual from TObject.
Definition CbmFsdMC.cxx:59
TClonesArray * fFsdPoints
Definition CbmFsdMC.h:141
virtual ~CbmFsdMC()
Definition CbmFsdMC.cxx:30
TLorentzVector fPos
address (module and layer)
Definition CbmFsdMC.h:146
Int_t fAddress
track index
Definition CbmFsdMC.h:145
virtual void EndOfEvent()
Action at end of event.
Definition CbmFsdMC.cxx:50
Double_t fEloss
length
Definition CbmFsdMC.h:150
virtual void ConstructGeometry()
Construct the FSD geometry in the TGeoManager.
Definition CbmFsdMC.cxx:41
void RegisterSensitiveVolumes(TGeoNode *node)
energy loss
Definition CbmFsdMC.cxx:120
virtual void Initialize()
Initialisation.
Definition CbmFsdMC.cxx:66
Double_t fLength
time
Definition CbmFsdMC.h:149
Interception of MC track with the plane representing the FSD.
Definition CbmFsdPoint.h:23
void AddPoint(ECbmModuleId iDet)
Definition CbmStack.cxx:331
void ImportRootGeometry(TString &filename, FairModule *mod, TGeoMatrix *mat)