CbmRoot
Loading...
Searching...
No Matches
CbmLitTGeoTrackPropagator.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2017 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12
19#include "utils/CbmLitMath.h"
21
22#include <cmath>
23#include <iostream>
24#include <vector>
25
26using std::cout;
27using std::endl;
28
29
31
37
39
41 int pdg, std::vector<litfloat>* F, litfloat* length)
42{
43 *parOut = *parIn;
44 return Propagate(parOut, zOut, pdg, F, length);
45}
46
47LitStatus CbmLitTGeoTrackPropagator::Propagate(CbmLitTrackParam* par, litfloat zOut, int pdg, std::vector<litfloat>* F,
48 litfloat* length)
49
50{
51 if (!IsParCorrect(par)) {
52 return kLITERROR;
53 }
54
55 litfloat zIn = par->GetZ();
56 litfloat dz = zOut - zIn;
57
59 return kLITSUCCESS;
60 }
61
62 // Check whether upstream or downstream
63 // TODO check upstream/downstream
64 bool downstream = dz > 0;
65
66 if (F != NULL) {
67 F->assign(36, 0.);
68 (*F)[0] = 1.;
69 (*F)[7] = 1.;
70 (*F)[14] = 1.;
71 (*F)[21] = 1.;
72 (*F)[28] = 1.;
73 (*F)[35] = 1.;
74 }
75
76 int nofSteps = int(std::abs(dz) / CbmLitTGeoTrackPropagator::MAXIMUM_PROPAGATION_STEP_SIZE);
77 litfloat stepSize;
78 if (nofSteps == 0) {
79 stepSize = std::abs(dz);
80 }
81 else {
83 }
84 litfloat z = zIn;
85
86 if (length) *length = 0;
87
88 // Loop over steps + additional step to propagate to virtual plane at zOut
89 for (int iStep = 0; iStep < nofSteps + 1; iStep++) {
90 if (!IsParCorrect(par)) {
91 return kLITERROR;
92 }
93 // Check if already at exit position
94 if (z == zOut) break;
95
96 // Update current z position
97 if (iStep != nofSteps) {
98 z = (downstream) ? z + stepSize : z - stepSize;
99 }
100 else {
101 z = zOut;
102 }
103
104 // Get intersections with materials for this step
105 std::vector<CbmLitMaterialInfo> inter;
106 if (fNavigator->FindIntersections(par, z, inter) == kLITERROR) {
107 return kLITERROR;
108 }
109
110 // Loop over material layers
111 for (unsigned int iMat = 0; iMat < inter.size(); iMat++) {
112 CbmLitMaterialInfo mat = inter[iMat];
113
114 // Check if track parameters are correct
115 if (!IsParCorrect(par)) {
116 return kLITERROR;
117 }
118
119 std::vector<litfloat>* Fnew = NULL;
120 if (F != NULL) {
121 Fnew = new std::vector<litfloat>(36, 0.);
122 }
123 // Extrapolate to the next boundary
124 if (fExtrapolator->Extrapolate(par, mat.GetZpos(), Fnew) == kLITERROR) {
125 return kLITERROR;
126 }
127
128 // Update transport matrix
129 if (F != NULL) {
130 UpdateF(*F, *Fnew);
131 }
132 if (Fnew != NULL) delete Fnew;
133
134 // Add material effects
135 fMaterial->Update(par, &mat, pdg, downstream);
136
137 if (length) *length += mat.GetLength();
138 }
139 }
140
141 if (!IsParCorrect(par)) {
142 return kLITERROR;
143 }
144 else {
145 return kLITSUCCESS;
146 }
147}
148
149void CbmLitTGeoTrackPropagator::UpdateF(std::vector<litfloat>& F, const std::vector<litfloat>& newF)
150{
151 std::vector<litfloat> A(36);
152 Mult36(newF, F, A);
153 F.assign(A.begin(), A.end());
154}
155
157{
158 litfloat maxSlope = 5.;
159 litfloat minSlope = 1e-6;
160 litfloat maxQp = 1000.; // p = 10 MeV
161
162 if (std::abs(par->GetTx()) > maxSlope || std::abs(par->GetTy()) > maxSlope || std::abs(par->GetTx()) < minSlope
163 || std::abs(par->GetTy()) < minSlope || std::abs(par->GetQp()) > maxQp) {
164 return false;
165 }
166
167 if (std::isnan(par->GetX()) || std::isnan(par->GetY()) || std::isnan(par->GetTx()) || std::isnan(par->GetTy())
168 || std::isnan(par->GetQp())) {
169 return false;
170 }
171
172 return true;
173}
LitStatus
Definition CbmLitEnums.h:29
@ kLITERROR
Definition CbmLitEnums.h:31
@ kLITSUCCESS
Definition CbmLitEnums.h:30
double litfloat
Definition CbmLitFloat.h:19
Calculation of multiple scattering and energy loss.
bool Mult36(const std::vector< litfloat > &a, const std::vector< litfloat > &b, std::vector< litfloat > &c)
Interface for track extrapolation algorithm.
Data class for track parameters.
boost::shared_ptr< CbmLitMaterialEffects > MaterialEffectsPtr
boost::shared_ptr< CbmLitGeoNavigator > GeoNavigatorPtr
boost::shared_ptr< CbmLitTrackExtrapolator > TrackExtrapolatorPtr
Calculation of multiple scattering and energy loss.
litfloat GetLength() const
litfloat GetZpos() const
virtual LitStatus Propagate(const CbmLitTrackParam *parIn, CbmLitTrackParam *parOut, litfloat zOut, int pdg, std::vector< litfloat > *F, litfloat *length)
Track parameter propagation.
void UpdateF(std::vector< litfloat > &F, const std::vector< litfloat > &newF)
CbmLitTGeoTrackPropagator(TrackExtrapolatorPtr extrapolator)
bool IsParCorrect(const CbmLitTrackParam *par)
Data class for track parameters.
litfloat GetZ() const
litfloat GetTx() const
litfloat GetX() const
litfloat GetY() const
litfloat GetTy() const
litfloat GetQp() const
static const litfloat MINIMUM_PROPAGATION_DISTANCE