BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnGeoNavigator.cxx
Go to the documentation of this file.
1
/** BmnTGeoNavigator.cxx
2
* \author Andrey Lebedev <andrey.lebedev@gsi.de> - Original author. First version of code for CBM experiment.
3
* \author Sergey Merts <Sergey.Merts@gmail.com> - Modification for BMN experiment.
4
* \date 2008-2014
5
**/
6
7
#include "
BmnGeoNavigator.h
"
8
9
#include "FairTrackParam.h"
10
#include "
TGeoManager.h
"
11
#include "
TGeoMaterial.h
"
12
#include "
TGeoNode.h
"
13
#include "
TGeoVolume.h
"
14
#include "
TMath.h
"
15
16
#include <cmath>
17
#include <iostream>
18
19
using namespace
TMath
;
20
21
BmnGeoNavigator::BmnGeoNavigator
() {}
22
23
BmnGeoNavigator::~BmnGeoNavigator
() {}
24
25
BmnStatus
BmnGeoNavigator::FindIntersections
(
const
FairTrackParam* par,
Float_t
zOut, vector<BmnMaterialInfo>& inter)
26
{
27
Bool_t
downstream = zOut <= par->GetZ();
28
// std::cout << "zOut=" << zOut << " Z=" << par->GetZ() << " downstream=" << downstream << std::endl;
29
30
InitTrack
(par, downstream);
31
if
(
gGeoManager
->IsOutside()) {
32
return
kBMNERROR
;
33
}
34
35
BmnMaterialInfo
stepInfo;
36
Bool_t
last =
kFALSE
;
37
38
cout.precision(7);
39
40
do
{
41
gGeoManager
->PushPoint();
42
stepInfo =
MakeStep
();
43
// std::cout << "stepInfo=" << stepInfo.ToString();
44
// Check if outside of the geometry
45
if
(
gGeoManager
->IsOutside()) {
46
// std::cout << "Error! BmnTGeoNavigator::FindIntersections: Outside geometry.\n";
47
gGeoManager
->PopDummy();
48
return
kBMNERROR
;
49
}
50
// Check for NaN values
51
if
(
IsNaN
(
gGeoManager
->GetCurrentPoint()[0]) ||
IsNaN
(
gGeoManager
->GetCurrentPoint()[1])
52
||
IsNaN
(
gGeoManager
->GetCurrentPoint()[2]))
53
{
54
// std::cout << "Error! BmnTGeoNavigator::FindIntersections: NaN values.\n";
55
gGeoManager
->PopDummy();
56
return
kBMNERROR
;
57
}
58
// Check if we currently at the output position
59
Bool_t
away = (!downstream) ? stepInfo.
GetZpos
() >= zOut : stepInfo.
GetZpos
() <= zOut;
60
if
(away) {
//|| gGeoManager->IsNullStep()){
61
gGeoManager
->PopPoint();
62
Float_t
l =
CalcLength
(zOut);
63
stepInfo.
SetLength
(l);
64
stepInfo.
SetZpos
(zOut);
65
last =
kTRUE
;
66
}
else
{
67
gGeoManager
->PopDummy();
68
}
69
inter.push_back(stepInfo);
70
}
while
(!last);
71
return
kBMNSUCCESS
;
72
}
73
74
void
BmnGeoNavigator::InitTrack
(
const
FairTrackParam* par,
Bool_t
downstream)
const
75
{
76
Double_t
nz = 1. /
TMath::Sqrt
(par->GetTx() * par->GetTx() + par->GetTy() * par->GetTy() + 1);
77
78
Double_t
nx = par->GetTx() * nz;
79
Double_t
ny = par->GetTy() * nz;
80
81
// Change track direction for upstream
82
if
(downstream) {
83
nx = -nx;
84
ny = -ny;
85
nz = -nz;
86
}
87
gGeoManager
->InitTrack(par->GetX(), par->GetY(), par->GetZ(), nx, ny, nz);
88
}
89
90
BmnMaterialInfo
BmnGeoNavigator::MakeStep
(
Float_t
step)
const
91
{
92
// fill current material information and then make a step
93
BmnMaterialInfo
matInfo;
94
TGeoMaterial
* mat =
gGeoManager
->GetCurrentNode()->GetMedium()->GetMaterial();
95
matInfo.
SetRL
(mat->
GetRadLen
());
96
matInfo.
SetRho
(mat->
GetDensity
());
97
matInfo.
SetZ
(mat->
GetZ
());
98
matInfo.
SetA
(mat->
GetA
());
99
matInfo.
SetName
(
gGeoManager
->GetCurrentNode()->GetName());
100
101
if
(step == 0.) {
102
gGeoManager
->FindNextBoundaryAndStep(25.);
103
}
else
{
104
gGeoManager
->SetStep(step);
105
gGeoManager
->Step(
kFALSE
);
106
}
107
108
matInfo.
SetLength
(
gGeoManager
->GetStep());
109
matInfo.
SetZpos
(
gGeoManager
->GetCurrentPoint()[2]);
110
111
return
matInfo;
112
}
113
114
Float_t
BmnGeoNavigator::CalcLength
(
Float_t
zOut)
const
115
{
116
// find intersection point of straight line with plane
117
Float_t
nx =
gGeoManager
->GetCurrentDirection()[0];
118
Float_t
ny =
gGeoManager
->GetCurrentDirection()[1];
119
Float_t
nz =
gGeoManager
->GetCurrentDirection()[2];
120
Float_t
z =
gGeoManager
->GetCurrentPoint()[2];
121
122
Float_t
t0 = (zOut - z) / nz;
123
124
Float_t
dx = nx * t0;
125
Float_t
dy = ny * t0;
126
Float_t
dz = (zOut - z);
// nz * t0;
127
128
// calculate distance between two points
129
return
std::sqrt(dx * dx + dy * dy + dz * dz);
130
}
Bool_t
bool Bool_t
Float_t
float Float_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
TGeoManager.h
gGeoManager
R__EXTERN TGeoManager * gGeoManager
TGeoMaterial.h
TGeoNode.h
TGeoVolume.h
TMath.h
BmnStatus
BmnStatus
Define status code.
Definition
BmnEnums.h:93
kBMNERROR
@ kBMNERROR
Error.
Definition
BmnEnums.h:95
kBMNSUCCESS
@ kBMNSUCCESS
Success.
Definition
BmnEnums.h:94
BmnGeoNavigator.h
BmnGeoNavigator::~BmnGeoNavigator
virtual ~BmnGeoNavigator()
Definition
BmnGeoNavigator.cxx:23
BmnGeoNavigator::FindIntersections
BmnStatus FindIntersections(const FairTrackParam *par, Float_t zOut, vector< BmnMaterialInfo > &inter)
Definition
BmnGeoNavigator.cxx:25
BmnGeoNavigator::InitTrack
void InitTrack(const FairTrackParam *par, Bool_t downstream) const
Definition
BmnGeoNavigator.cxx:74
BmnGeoNavigator::MakeStep
BmnMaterialInfo MakeStep(Float_t step=0.) const
Definition
BmnGeoNavigator.cxx:90
BmnGeoNavigator::BmnGeoNavigator
BmnGeoNavigator()
Definition
BmnGeoNavigator.cxx:21
BmnGeoNavigator::CalcLength
Float_t CalcLength(Float_t zOut) const
Definition
BmnGeoNavigator.cxx:114
BmnMaterialInfo
Definition
BmnMaterialInfo.h:21
BmnMaterialInfo::SetRho
void SetRho(Float_t rho)
Definition
BmnMaterialInfo.h:89
BmnMaterialInfo::SetLength
void SetLength(Float_t length)
Definition
BmnMaterialInfo.h:83
BmnMaterialInfo::SetName
void SetName(const string &name)
Definition
BmnMaterialInfo.h:100
BmnMaterialInfo::GetZpos
Float_t GetZpos() const
Definition
BmnMaterialInfo.h:78
BmnMaterialInfo::SetA
void SetA(Float_t A)
Definition
BmnMaterialInfo.h:95
BmnMaterialInfo::SetRL
void SetRL(Float_t rl)
Definition
BmnMaterialInfo.h:86
BmnMaterialInfo::SetZpos
void SetZpos(Float_t zpos)
Definition
BmnMaterialInfo.h:98
BmnMaterialInfo::SetZ
void SetZ(Float_t Z)
Definition
BmnMaterialInfo.h:92
TGeoMaterial
TGeoMaterial::GetRadLen
virtual Double_t GetRadLen() const
TGeoMaterial::GetA
virtual Double_t GetA() const
TGeoMaterial::GetDensity
virtual Double_t GetDensity() const
TGeoMaterial::GetZ
virtual Double_t GetZ() const
TMath
TMath::IsNaN
Bool_t IsNaN(Double_t x)
TMath::Sqrt
Double_t Sqrt(Double_t x)
base
math
BmnGeoNavigator.cxx
Generated on
for BmnRoot by
1.17.0