KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVRangeTableGeoNavigator.cpp
Go to the documentation of this file.
2 #include <TGeoMaterial.h>
3 #include <TGeoManager.h>
4 #include <TGeoVolume.h>
5 #include <TGeoNode.h>
6 #include "KVNucleus.h"
8 
10 
11 // BEGIN_HTML <!--
13 /* -->
14 <h2>KVRangeTableGeoNavigator</h2>
15 <h4>Propagate particles through a geometry and calculate their energy losses</h4>
16 <!-- */
17 // --> END_HTML
18 
19 
21 
22 
34 void KVRangeTableGeoNavigator::ParticleEntersNewVolume(KVNucleus* part)
35 {
36  // Overrides method in KVGeoNavigator base class.
37  // Every time a particle enters a new volume, we check the material to see
38  // if it is known (i.e. contained in the range table fRangeTable).
39  // If so, then we calculate the energy loss of the particle in this volume,
40  // reduce the particle's energy accordingly, and, if the energy falls below
41  // a certain cut-off (default 1.e-3 MeV; can be modified with
42  // SetCutOffKEForPropagation(Double_t) ), we stop the propagation.
43  //
44  // The (cumulated) energy losses in the active layers of all hit detectors
45  // are updated with the energy lost by this particle
46 
47  Double_t de = 0;
48  Double_t e = part->GetEnergy();
49  if (e <= fCutOffEnergy) {
50  e = 0.;
51  SetStopPropagation();//propagation will stop after this step
52  if (IsTracking()) {
53  AddPointToCurrentTrack(GetEntryPoint().X(), GetEntryPoint().Y(), GetEntryPoint().Z());
54  AddPointToCurrentTrack(GetExitPoint().X(), GetExitPoint().Y(), GetExitPoint().Z());
55  }
56  return;
57  }
58 
59  // calculate energy losses in known materials for charged particles
60  TGeoMaterial* material = GetCurrentVolume()->GetMaterial();
61  KVIonRangeTableMaterial* irmat = 0;
62  if ((irmat = fRangeTable->GetMaterial(material))) {
63  de = irmat->GetLinearDeltaEOfIon(
64  part->GetZ(), part->GetA(), e, GetStepSize(), 0.,
65  material->GetTemperature(),
66  material->GetPressure());
67  e -= de;
68  if (e <= fCutOffEnergy) {
69  e = 0.;
70  SetStopPropagation();//propagation will stop after this step
71  }
72  //set flag to say that particle has been slowed down
73  part->SetIsDetected();
74  //If this is the first absorber that the particle crosses, we set a "reminder" of its
75  //initial energy
76  if (!part->GetPInitial()) part->SetE0();
77 
78  TString absorber_name;
79  KVDetector* theDet = GetDetectorFromPath(GetCurrentPath());
80  Bool_t active_layer = kFALSE;
81  if (theDet) {
82  if (!theDet->IsSingleLayer()) {
83  absorber_name.Form("%s/%s", theDet->GetName(), GetCurrentNode()->GetName());
84  if (strncmp(GetCurrentNode()->GetName(), "ACTIVE", 6) == 0) active_layer = kTRUE;
85  }
86  else {
87  absorber_name = theDet->GetName();
88  active_layer = kTRUE;
89  }
90  }
91  else
92  absorber_name = irmat->GetName();
93 
94  if (part->GetZ()) {
95  part->GetParameters()->SetValue(Form("DE:%s", absorber_name.Data()), de);
96  if (active_layer) {
97  // update energy loss in active layer of detector
98  Double_t E = theDet->GetEnergyLoss() + de;
99  theDet->SetEnergyLoss(E);
100  //theDet->AddHit(part);//don't put a reference to simulated particle in detector
101  }
102  }
103  //part->GetParameters()->SetValue(Form("Xin:%s", absorber_name.Data()), GetEntryPoint().X());
104  //part->GetParameters()->SetValue(Form("Yin:%s", absorber_name.Data()), GetEntryPoint().Y());
105  //part->GetParameters()->SetValue(Form("Zin:%s", absorber_name.Data()), GetEntryPoint().Z());
106  if (StopPropagation()) {
107  // If particle stops in this volume, we use as 'exit point' the point corresponding to
108  // the calculated range of the particle
109  Double_t r = irmat->GetRangeOfLastDE() / irmat->GetDensity();
110  TVector3 path = GetExitPoint() - GetEntryPoint();
111  TVector3 midVol = GetEntryPoint() + (r / path.Mag()) * path;
112  //part->GetParameters()->SetValue(Form("Xout:%s", absorber_name.Data()), midVol.X());
113  //part->GetParameters()->SetValue(Form("Yout:%s", absorber_name.Data()), midVol.Y());
114  //part->GetParameters()->SetValue(Form("Zout:%s", absorber_name.Data()), midVol.Z());
115  if (IsTracking()) {
116  AddPointToCurrentTrack(GetEntryPoint().X(), GetEntryPoint().Y(), GetEntryPoint().Z());
117  AddPointToCurrentTrack(midVol.X(), midVol.Y(), midVol.Z());
118  }
119  }
120  else {
121  //part->GetParameters()->SetValue(Form("Xout:%s", absorber_name.Data()), GetExitPoint().X());
122  //part->GetParameters()->SetValue(Form("Yout:%s", absorber_name.Data()), GetExitPoint().Y());
123  //part->GetParameters()->SetValue(Form("Zout:%s", absorber_name.Data()), GetExitPoint().Z());
124  if (IsTracking()) {
125  AddPointToCurrentTrack(GetEntryPoint().X(), GetEntryPoint().Y(), GetEntryPoint().Z());
126  AddPointToCurrentTrack(GetExitPoint().X(), GetExitPoint().Y(), GetExitPoint().Z());
127  }
128  }
129  part->SetEnergy(e);
130  }
131 }
132 
133 
134 
137 
139 {
140  // Start a new track to visualise trajectory of nucleus through the array
141 
142  fTrackTime = 0.;
143  Int_t pdg = part->GetN() * 100 + part->GetZ();
144  gGeoManager->SetPdgName(pdg, part->GetSymbol());
145  Int_t itrack = gGeoManager->AddTrack(GetTrackID(), pdg, part);
148  if (TheOrigin) AddPointToCurrentTrack(TheOrigin->x(), TheOrigin->y(), TheOrigin->z());
149  else AddPointToCurrentTrack(0, 0, 0);
150 }
151 
152 
153 
156 
158 {
159  // We start a new track to represent the particle's trajectory through the array.
160 
161  if (IsTracking()) InitialiseTrack(part, TheOrigin);
162 
163  KVGeoNavigator::PropagateParticle(part, TheOrigin);
164 
165  if (part->GetParameters()->HasParameter("DEADZONE")) {
166  if (IsTracking()) {
168  }
169  }
170 }
171 
172 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
ROOT::R::TRInterface & r
#define e(i)
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
Base class for detector geometry description.
Definition: KVDetector.h:159
virtual void SetEnergyLoss(Double_t e) const
Definition: KVDetector.h:372
virtual Double_t GetEnergyLoss() const
Definition: KVDetector.h:368
Bool_t IsSingleLayer() const
Definition: KVDetector.h:769
Bool_t IsTracking() const
Int_t GetTrackID() const
void IncrementTrackID()
virtual void PropagateParticle(KVNucleus *, TVector3 *TheOrigin=0)
const TVector3 & GetEntryPoint() const
Material for use in energy loss & range calculations.
virtual Double_t GetLinearDeltaEOfIon(Int_t Z, Int_t A, Double_t E, Double_t e, Double_t isoAmat=0., Double_t T=-1., Double_t P=-1.)
Bool_t HasParameter(const Char_t *name) const
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:125
const Char_t * GetSymbol(Option_t *opt="") const
Definition: KVNucleus.cpp:81
Int_t GetN() const
Return the number of neutron.
Definition: KVNucleus.cpp:781
Int_t GetZ() const
Return the number of proton / atomic number.
Definition: KVNucleus.cpp:770
KVNameValueList * GetParameters() const
Definition: KVParticle.h:816
Propagate particles through array geometry calculating energy losses.
void InitialiseTrack(KVNucleus *part, TVector3 *TheOrigin)
Start a new track to visualise trajectory of nucleus through the array.
TVirtualGeoTrack * fCurrentTrack
current track of nucleus being propagated
void AddPointToCurrentTrack(Double_t x, Double_t y, Double_t z)
virtual void PropagateParticle(KVNucleus *, TVector3 *TheOrigin=0)
We start a new track to represent the particle's trajectory through the array.
Double_t fTrackTime
track "clock"
Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle=0)
void SetPdgName(Int_t pdg, const char *name)
TVirtualGeoTrack * GetTrack(Int_t index)
Double_t GetTemperature() const
Double_t GetPressure() const
virtual const char * GetName() const
const char * Data() const
void Form(const char *fmt,...)
Double_t Z() const
Double_t Y() const
Double_t X() const
Double_t z() const
Double_t x() const
Double_t Mag() const
Double_t y() const
constexpr Double_t E()