CbmRoot
CbmLitTGeoTrackPropagator.cxx
Go to the documentation of this file.
1 
8 
10 #include "data/CbmLitTrackParam.h"
15 #include "utils/CbmLitMath.h"
16 #include "utils/CbmLitMatrixMath.h"
17 
18 #include <cmath>
19 #include <iostream>
20 #include <vector>
21 
22 using std::cout;
23 using std::endl;
24 
25 
27 
29  TrackExtrapolatorPtr extrapolator)
30  : fExtrapolator(extrapolator) {
33 }
34 
36 
38  CbmLitTrackParam* parOut,
39  litfloat zOut,
40  int pdg,
41  std::vector<litfloat>* F,
42  litfloat* length) {
43  *parOut = *parIn;
44  return Propagate(parOut, zOut, pdg, F, length);
45 }
46 
48  litfloat zOut,
49  int pdg,
50  std::vector<litfloat>* F,
51  litfloat* length)
52 
53 {
54  if (!IsParCorrect(par)) { return kLITERROR; }
55 
56  litfloat zIn = par->GetZ();
57  litfloat dz = zOut - zIn;
58 
59  if (std::fabs(dz)
61  return kLITSUCCESS;
62  }
63 
64  // Check whether upstream or downstream
65  // TODO check upstream/downstream
66  bool downstream = dz > 0;
67 
68  if (F != NULL) {
69  F->assign(36, 0.);
70  (*F)[0] = 1.;
71  (*F)[7] = 1.;
72  (*F)[14] = 1.;
73  (*F)[21] = 1.;
74  (*F)[28] = 1.;
75  (*F)[35] = 1.;
76  }
77 
78  int nofSteps = int(
80  litfloat stepSize;
81  if (nofSteps == 0) {
82  stepSize = std::abs(dz);
83  } else {
85  }
86  litfloat z = zIn;
87 
88  if (length) *length = 0;
89 
90  // Loop over steps + additional step to propagate to virtual plane at zOut
91  for (int iStep = 0; iStep < nofSteps + 1; iStep++) {
92  if (!IsParCorrect(par)) { return kLITERROR; }
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  } else {
100  z = zOut;
101  }
102 
103  // Get intersections with materials for this step
104  std::vector<CbmLitMaterialInfo> inter;
105  if (fNavigator->FindIntersections(par, z, inter) == kLITERROR) {
106  return kLITERROR;
107  }
108 
109  // Loop over material layers
110  for (unsigned int iMat = 0; iMat < inter.size(); iMat++) {
111  CbmLitMaterialInfo mat = inter[iMat];
112 
113  // Check if track parameters are correct
114  if (!IsParCorrect(par)) { return kLITERROR; }
115 
116  std::vector<litfloat>* Fnew = NULL;
117  if (F != NULL) { Fnew = new std::vector<litfloat>(36, 0.); }
118  // Extrapolate to the next boundary
119  if (fExtrapolator->Extrapolate(par, mat.GetZpos(), Fnew) == kLITERROR) {
120  return kLITERROR;
121  }
122 
123  // Update transport matrix
124  if (F != NULL) { UpdateF(*F, *Fnew); }
125  if (Fnew != NULL) delete Fnew;
126 
127  // Add material effects
128  fMaterial->Update(par, &mat, pdg, downstream);
129 
130  if (length) *length += mat.GetLength();
131  }
132  }
133 
134  if (!IsParCorrect(par)) {
135  return kLITERROR;
136  } else {
137  return kLITSUCCESS;
138  }
139 }
140 
141 void CbmLitTGeoTrackPropagator::UpdateF(std::vector<litfloat>& F,
142  const std::vector<litfloat>& newF) {
143  std::vector<litfloat> A(36);
144  Mult36(newF, F, A);
145  F.assign(A.begin(), A.end());
146 }
147 
149  litfloat maxSlope = 5.;
150  litfloat minSlope = 1e-6;
151  litfloat maxQp = 1000.; // p = 10 MeV
152 
153  if (std::abs(par->GetTx()) > maxSlope || std::abs(par->GetTy()) > maxSlope
154  || std::abs(par->GetTx()) < minSlope || std::abs(par->GetTy()) < minSlope
155  || std::abs(par->GetQp()) > maxQp) {
156  return false;
157  }
158 
159  if (std::isnan(par->GetX()) || std::isnan(par->GetY())
160  || std::isnan(par->GetTx()) || std::isnan(par->GetTy())
161  || std::isnan(par->GetQp())) {
162  return false;
163  }
164 
165  return true;
166 }
CbmLitTrackParam.h
Data class for track parameters.
litfloat
double litfloat
Definition: CbmLitFloat.h:15
lit::CbmLitDefaultSettings::MINIMUM_PROPAGATION_DISTANCE
static const litfloat MINIMUM_PROPAGATION_DISTANCE
Definition: CbmLitDefaultSettings.h:22
CbmLitTrackParam::GetX
litfloat GetX() const
Definition: CbmLitTrackParam.h:53
CbmLitTGeoTrackPropagator::IsParCorrect
bool IsParCorrect(const CbmLitTrackParam *par)
Definition: CbmLitTGeoTrackPropagator.cxx:148
CbmLitTGeoNavigator
Definition: CbmLitTGeoNavigator.h:19
CbmLitTrackParam
Data class for track parameters.
Definition: CbmLitTrackParam.h:29
CbmLitTrackParam::GetY
litfloat GetY() const
Definition: CbmLitTrackParam.h:54
CbmLitDefaultSettings.h
CbmLitTrackParam::GetQp
litfloat GetQp() const
Definition: CbmLitTrackParam.h:58
CbmLitTGeoTrackPropagator::fMaterial
MaterialEffectsPtr fMaterial
Definition: CbmLitTGeoTrackPropagator.h:61
CbmLitTGeoTrackPropagator::CbmLitTGeoTrackPropagator
CbmLitTGeoTrackPropagator(TrackExtrapolatorPtr extrapolator)
Definition: CbmLitTGeoTrackPropagator.cxx:28
kLITSUCCESS
@ kLITSUCCESS
Definition: CbmLitEnums.h:24
CbmLitMaterialInfo
Definition: CbmLitMaterialInfo.h:19
CbmLitTrackExtrapolator.h
Interface for track extrapolation algorithm.
CbmLitTGeoTrackPropagator::MAXIMUM_PROPAGATION_STEP_SIZE
static litfloat MAXIMUM_PROPAGATION_STEP_SIZE
Definition: CbmLitTGeoTrackPropagator.h:44
CbmLitTGeoTrackPropagator::UpdateF
void UpdateF(std::vector< litfloat > &F, const std::vector< litfloat > &newF)
Definition: CbmLitTGeoTrackPropagator.cxx:141
GeoNavigatorPtr
boost::shared_ptr< CbmLitGeoNavigator > GeoNavigatorPtr
Definition: CbmTofPtrTypes.h:27
CbmLitMaterialInfo::GetZpos
litfloat GetZpos() const
Definition: CbmLitMaterialInfo.h:69
CbmLitMaterialEffectsImp
Calculation of multiple scattering and energy loss.
Definition: CbmLitMaterialEffectsImp.h:23
CbmLitTrackParam::GetZ
litfloat GetZ() const
Definition: CbmLitTrackParam.h:55
CbmLitTGeoTrackPropagator::fExtrapolator
TrackExtrapolatorPtr fExtrapolator
Definition: CbmLitTGeoTrackPropagator.h:59
CbmLitMath.h
kLITERROR
@ kLITERROR
Definition: CbmLitEnums.h:25
TrackExtrapolatorPtr
boost::shared_ptr< CbmLitTrackExtrapolator > TrackExtrapolatorPtr
Definition: CbmTofPtrTypes.h:22
CbmLitTGeoTrackPropagator.h
CbmLitMaterialInfo::GetLength
litfloat GetLength() const
Definition: CbmLitMaterialInfo.h:54
CbmLitTGeoTrackPropagator::Propagate
virtual LitStatus Propagate(const CbmLitTrackParam *parIn, CbmLitTrackParam *parOut, litfloat zOut, int pdg, std::vector< litfloat > *F, litfloat *length)
Track parameter propagation.
Definition: CbmLitTGeoTrackPropagator.cxx:37
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
MaterialEffectsPtr
boost::shared_ptr< CbmLitMaterialEffects > MaterialEffectsPtr
Definition: CbmTofPtrTypes.h:28
CbmLitMatrixMath.h
CbmLitTGeoTrackPropagator::~CbmLitTGeoTrackPropagator
virtual ~CbmLitTGeoTrackPropagator()
Definition: CbmLitTGeoTrackPropagator.cxx:35
CbmLitTrackParam::GetTy
litfloat GetTy() const
Definition: CbmLitTrackParam.h:57
CbmLitTGeoTrackPropagator::fNavigator
GeoNavigatorPtr fNavigator
Definition: CbmLitTGeoTrackPropagator.h:60
CbmLitTGeoNavigator.h
Mult36
bool Mult36(const std::vector< litfloat > &a, const std::vector< litfloat > &b, std::vector< litfloat > &c)
Definition: CbmLitMatrixMath.cxx:278
CbmLitMaterialInfo.h
LitStatus
LitStatus
Definition: CbmLitEnums.h:23
CbmLitTrackParam::GetTx
litfloat GetTx() const
Definition: CbmLitTrackParam.h:56
CbmLitMaterialEffectsImp.h
Calculation of multiple scattering and energy loss.