FairShip
Loading...
Searching...
No Matches
MuonPath Class Reference

#include <MuonPath.h>

Public Member Functions

 MuonPath ()
 ~MuonPath ()
void AddVolume (const std::string &aVol, const std::string &aMat, const double &aD)
double GetMomentum (const unsigned &idx) const
double Getpx (const unsigned &idx) const
double Getpy (const unsigned &idx) const
double Getpz (const unsigned &idx) const
std::string GetLabel () const
void SetLabel (const std::string &aLab)
double GetDensity () const
double GetWeightedDensity () const
double GetWeightedDensity (double minLength) const
void SetDensity (const double &aD)
double GetLength () const
double GetZLength () const
void SetLength (const double &aStep, const TVector3 &aStart, const double &aZ)
unsigned GetNSlices () const
double GetstartZ () const
double GetstartX (const unsigned &idx) const
double GetstartY (const unsigned &idx) const
double GetstartZ (const unsigned &idx) const
double GetEndZ (const unsigned &idx) const
double GetSliceLength (const unsigned &idx) const
void SetVertexInfo (const TVector3 &vecpos, const TVector3 &vecp, const double &time)
std::string GetLabel (const std::string &aVol, const std::string &aMat) const
void Print ()
double GetZ (const double &aZ, unsigned &idx) const
double GetZAtLength (double length, unsigned &idx) const
double GetLengthAtZ (const double &aZ) const
bool Add (const MuonPath &aEle)
double GetX (const double &aZ, const unsigned &idx) const
double GetY (const double &aZ, const unsigned &idx) const
double GetLength (const double &aZ, const unsigned &idx) const
double GetTimeNs (const double &aZ, const unsigned &idx) const

Private Attributes

std::string flabel
double fdensity
double fwdensity
double flength
double fzlength
std::vector< std::string > fvolName
std::vector< std::string > fmaterial
std::vector< TVector3 > fvtx
std::vector< double > fvtxT
std::vector< TVector3 > fstart
std::vector< double > fstartT
std::vector< double > fendZ
std::vector< double > fsliceDensity
std::vector< double > fendLength
std::vector< TVector3 > fpvec

Detailed Description

Definition at line 34 of file MuonPath.h.

Constructor & Destructor Documentation

◆ MuonPath()

MuonPath::MuonPath ( )

Definition at line 12 of file MuonPath.cxx.

12 {
13 flabel = "None";
14 fdensity = 0;
15 fwdensity = 0;
16 flength = 0;
17 fzlength = 0;
18}
double flength
Definition MuonPath.h:175
double fzlength
Definition MuonPath.h:176
double fdensity
Definition MuonPath.h:173
std::string flabel
Definition MuonPath.h:172
double fwdensity
Definition MuonPath.h:174

◆ ~MuonPath()

MuonPath::~MuonPath ( )
inline

Definition at line 37 of file MuonPath.h.

37{};

Member Function Documentation

◆ Add()

bool MuonPath::Add ( const MuonPath & aEle)

Definition at line 156 of file MuonPath.cxx.

156 {
157 // path added should always have only one element...
158 if (aEle.GetNSlices() != 1) {
159 LOG(error) << " -- incorrect number of elements in path: "
160 << aEle.GetNSlices();
161 return false;
162 }
163 fvolName.push_back(aEle.fvolName[0]);
164 fmaterial.push_back(aEle.fmaterial[0]);
165 fpvec.push_back(aEle.fpvec[0]);
166 fvtx.push_back(aEle.fvtx[0]);
167 fvtxT.push_back(aEle.fvtxT[0]);
168 fstart.push_back(aEle.fstart[0]);
169 fstartT.push_back(aEle.fstartT[0]);
170 fendZ.push_back(aEle.fendZ[0]);
171 flength += aEle.flength;
172 fendLength.push_back(flength);
173 fsliceDensity.push_back(aEle.fsliceDensity[0]);
174 fwdensity += aEle.fwdensity;
175 fzlength += aEle.fendZ[0] - aEle.fstart[0].Z();
176 return true;
177}
std::vector< TVector3 > fpvec
Definition MuonPath.h:188
std::vector< double > fsliceDensity
Definition MuonPath.h:185
std::vector< std::string > fvolName
Definition MuonPath.h:178
unsigned GetNSlices() const
Definition MuonPath.h:97
std::vector< std::string > fmaterial
Definition MuonPath.h:179
std::vector< TVector3 > fvtx
Definition MuonPath.h:180
std::vector< double > fvtxT
Definition MuonPath.h:181
std::vector< double > fendLength
Definition MuonPath.h:187
std::vector< TVector3 > fstart
Definition MuonPath.h:182
std::vector< double > fstartT
Definition MuonPath.h:183
std::vector< double > fendZ
Definition MuonPath.h:184

◆ AddVolume()

void MuonPath::AddVolume ( const std::string & aVol,
const std::string & aMat,
const double & aD )
inline

Definition at line 39 of file MuonPath.h.

40 {
41 flabel = GetLabel(aVol, aMat);
42 fvolName.push_back(aVol);
43 fmaterial.push_back(aMat);
44 fdensity = aD;
45 };
std::string GetLabel() const
Definition MuonPath.h:67

◆ GetDensity()

double MuonPath::GetDensity ( ) const
inline

Definition at line 71 of file MuonPath.h.

71{ return fdensity; };

◆ GetEndZ()

double MuonPath::GetEndZ ( const unsigned & idx) const
inline

Definition at line 122 of file MuonPath.h.

122 {
123 if (idx >= GetNSlices()) return 0;
124 return fendZ[idx];
125 };

◆ GetLabel() [1/2]

std::string MuonPath::GetLabel ( ) const
inline

Definition at line 67 of file MuonPath.h.

67{ return flabel; };

◆ GetLabel() [2/2]

std::string MuonPath::GetLabel ( const std::string & aVol,
const std::string & aMat ) const

Definition at line 95 of file MuonPath.cxx.

96 {
97 //@FIXME AMM-avoid hardcoding, pass by config ?
98 std::string label = "REST";
99 if (aVol.find("Magn") != aVol.npos)
100 label = "MS";
101 else if (aVol.find("Upstream") != aVol.npos)
102 label = "UBT";
103 // The balloon skin includes the walls and both lids; decay_medium is HE.
104 else if (aVol.find("HeBalloon") != aVol.npos)
105 label = "HeBalloon";
106 else if (aMat.find("helium") != aMat.npos)
107 label = "HE";
108 else if (aMat.find("air") != aMat.npos)
109 label = "AIR";
110 else if (aVol.find("straw") != aVol.npos)
111 label = "SSTsens";
112 else if (aVol.find("gas") != aVol.npos && aMat.find("STT") != aMat.npos)
113 label = "SSTsens";
114 else if (aVol.find("wire") != aVol.npos && aMat.find("tungsten") != aMat.npos)
115 label = "SSTsens";
116 else if ((aVol.find("Tr1_frame") != aVol.npos ||
117 aVol.find("Tr2_frame") != aVol.npos ||
118 aVol.find("Tr3_frame") != aVol.npos ||
119 aVol.find("Tr4_frame") != aVol.npos))
120 label = "SSTfr";
121 else if ((aVol.find("Veto") != aVol.npos ||
122 aVol.find("vLongitRib") != aVol.npos))
123 label = "SBTfr";
124 else if (aVol.find("LiSc") != aVol.npos)
125 label = "SBTsens";
126 LOG(debug) << aVol << " " << aMat << " assigned to " << label << ".";
127 return label;
128}
const Int_t debug

◆ GetLength() [1/2]

double MuonPath::GetLength ( ) const
inline

Definition at line 79 of file MuonPath.h.

79{ return flength; };

◆ GetLength() [2/2]

double MuonPath::GetLength ( const double & aZ,
const unsigned & idx ) const
inline

Definition at line 153 of file MuonPath.h.

153 {
154 if (idx >= GetNSlices()) return 0;
155 return TMath::Sqrt(TMath::Power(GetX(aZ, idx) - fvtx[idx].X(), 2) +
156 TMath::Power(GetY(aZ, idx) - fvtx[idx].Y(), 2) +
157 TMath::Power(aZ - fvtx[idx].Z(), 2)); // in cm
158 };
double GetX(const double &aZ, const unsigned &idx) const
Definition MuonPath.h:141
double GetY(const double &aZ, const unsigned &idx) const
Definition MuonPath.h:147

◆ GetLengthAtZ()

double MuonPath::GetLengthAtZ ( const double & aZ) const

Definition at line 57 of file MuonPath.cxx.

57 {
58 if (fendLength.empty()) return 0.;
59 unsigned idx = 0;
60 const double z = GetZ(aZ, idx);
61 const double previous = idx == 0 ? 0. : fendLength[idx - 1];
62 const double dz = fendZ[idx] - fstart[idx].Z();
63 return previous + (dz > 0. ? std::clamp((z - fstart[idx].Z()) / dz, 0., 1.) *
64 (fendLength[idx] - previous)
65 : 0.);
66}
double GetZ(const double &aZ, unsigned &idx) const
Definition MuonPath.cxx:68

◆ GetMomentum()

double MuonPath::GetMomentum ( const unsigned & idx) const
inline

Definition at line 47 of file MuonPath.h.

47 {
48 if (idx >= GetNSlices()) return 0;
49 return fpvec[idx].Mag();
50 };

◆ GetNSlices()

unsigned MuonPath::GetNSlices ( ) const
inline

Definition at line 97 of file MuonPath.h.

97 {
98 return static_cast<unsigned>(
99 std::min({fvolName.size(), fmaterial.size(), fpvec.size(), fvtx.size(),
100 fvtxT.size(), fstart.size(), fstartT.size(), fendZ.size()}));
101 };

◆ Getpx()

double MuonPath::Getpx ( const unsigned & idx) const
inline

Definition at line 52 of file MuonPath.h.

52 {
53 if (idx >= GetNSlices()) return 0;
54 return fpvec[idx].X();
55 };

◆ Getpy()

double MuonPath::Getpy ( const unsigned & idx) const
inline

Definition at line 57 of file MuonPath.h.

57 {
58 if (idx >= GetNSlices()) return 0;
59 return fpvec[idx].Y();
60 };

◆ Getpz()

double MuonPath::Getpz ( const unsigned & idx) const
inline

Definition at line 62 of file MuonPath.h.

62 {
63 if (idx >= GetNSlices()) return 0;
64 return fpvec[idx].Z();
65 };

◆ GetSliceLength()

double MuonPath::GetSliceLength ( const unsigned & idx) const
inline

Definition at line 127 of file MuonPath.h.

127 {
128 if (idx >= GetNSlices()) return 0;
129 return fendLength[idx] - (idx == 0 ? 0. : fendLength[idx - 1]);
130 };

◆ GetstartX()

double MuonPath::GetstartX ( const unsigned & idx) const
inline

Definition at line 107 of file MuonPath.h.

107 {
108 if (idx >= GetNSlices()) return 0;
109 return fstart[idx].X();
110 };

◆ GetstartY()

double MuonPath::GetstartY ( const unsigned & idx) const
inline

Definition at line 112 of file MuonPath.h.

112 {
113 if (idx >= GetNSlices()) return 0;
114 return fstart[idx].Y();
115 };

◆ GetstartZ() [1/2]

double MuonPath::GetstartZ ( ) const
inline

Definition at line 103 of file MuonPath.h.

103 {
104 return fstart.empty() ? 0. : fstart.front().Z();
105 };

◆ GetstartZ() [2/2]

double MuonPath::GetstartZ ( const unsigned & idx) const
inline

Definition at line 117 of file MuonPath.h.

117 {
118 if (idx >= GetNSlices()) return 0;
119 return fstart[idx].Z();
120 };

◆ GetTimeNs()

double MuonPath::GetTimeNs ( const double & aZ,
const unsigned & idx ) const
inline

Definition at line 160 of file MuonPath.h.

160 {
161 if (idx >= GetNSlices() || fpvec[idx].Z() == 0.) return 0;
162 double P = fpvec[idx].Mag();
163 if (P == 0.) return 0;
164 double v = ShipUnit::c_light * P /
165 TMath::Sqrt(TMath::Power(P, 2) + TMath::Power(MuonMass(), 2));
166 if (v == 0.) return 0;
167 // A slice may precede its reference measurement in z.
168 return fvtxT[idx] + (aZ - fvtx[idx].Z()) * P / fpvec[idx].Z() / v;
169 };
double MuonMass()
Definition MuonPath.h:29
constexpr double c_light
Definition ShipUnit.h:44

◆ GetWeightedDensity() [1/2]

double MuonPath::GetWeightedDensity ( ) const
inline

Definition at line 73 of file MuonPath.h.

73{ return fwdensity; };

◆ GetWeightedDensity() [2/2]

double MuonPath::GetWeightedDensity ( double minLength) const

Definition at line 28 of file MuonPath.cxx.

28 {
29 minLength = std::clamp(minLength, 0., flength);
30 double weightedDensity = 0.;
31 double previous = 0.;
32 for (unsigned i = 0; i < fendLength.size(); ++i) {
33 const double length =
34 std::max(0., fendLength[i] - std::max(previous, minLength));
35 weightedDensity += length * fsliceDensity[i];
36 previous = fendLength[i];
37 }
38 return weightedDensity;
39}
int i
Definition ShipAna.py:108

◆ GetX()

double MuonPath::GetX ( const double & aZ,
const unsigned & idx ) const
inline

Definition at line 141 of file MuonPath.h.

141 {
142 if (idx >= GetNSlices() || fpvec[idx].Z() == 0) return 0;
143 return fvtx[idx].X() +
144 (aZ - fvtx[idx].Z()) * fpvec[idx].X() / fpvec[idx].Z();
145 };

◆ GetY()

double MuonPath::GetY ( const double & aZ,
const unsigned & idx ) const
inline

Definition at line 147 of file MuonPath.h.

147 {
148 if (idx >= GetNSlices() || fpvec[idx].Z() == 0) return 0;
149 return fvtx[idx].Y() +
150 (aZ - fvtx[idx].Z()) * fpvec[idx].Y() / fpvec[idx].Z();
151 };

◆ GetZ()

double MuonPath::GetZ ( const double & aZ,
unsigned & idx ) const

Definition at line 68 of file MuonPath.cxx.

68 {
69 //@FIXME AMM- is this efficient enough??
70 const unsigned nSlices = GetNSlices();
71 if (nSlices == 0) {
72 idx = 0;
73 return aZ;
74 }
75
76 if (aZ < fendZ[0]) {
77 idx = 0;
78 return aZ;
79 }
80 double prevz = fendZ[0];
81 for (unsigned iz(1); iz < nSlices; ++iz) {
82 double extraz = aZ - prevz;
83 double stepz = fendZ[iz] - fstart[iz].Z();
84 if (extraz < stepz) {
85 idx = iz;
86 return fstart[iz].Z() + extraz;
87 }
88 prevz += stepz;
89 }
90 // set a default to the last value
91 idx = nSlices - 1;
92 return fendZ[idx];
93}

◆ GetZAtLength()

double MuonPath::GetZAtLength ( double length,
unsigned & idx ) const

Definition at line 41 of file MuonPath.cxx.

41 {
42 idx = 0;
43 if (fendLength.empty()) return 0.;
44 length = std::clamp(length, 0., flength);
45 const auto end =
46 std::upper_bound(fendLength.begin(), fendLength.end(), length);
47 idx = end == fendLength.end() ? fendLength.size() - 1
48 : end - fendLength.begin();
49 const double previous = idx == 0 ? 0. : fendLength[idx - 1];
50 const double step = fendLength[idx] - previous;
51 return step > 0. ? fstart[idx].Z() + (length - previous) / step *
52 (fendZ[idx] - fstart[idx].Z())
53 : fstart[idx].Z();
54}

◆ GetZLength()

double MuonPath::GetZLength ( ) const
inline

Definition at line 81 of file MuonPath.h.

81{ return fzlength; };

◆ Print()

void MuonPath::Print ( )

Definition at line 130 of file MuonPath.cxx.

130 {
131 const unsigned nSlices = GetNSlices();
132
133 std::ostringstream ldebug;
134 ldebug << flabel << " "
135 << " d=" << fdensity << " l=" << flength << " l_in_z=" << fzlength;
136 if (flength > 0) ldebug << " <d>=" << fwdensity / flength << std::endl;
137
138 if (nSlices == 0) {
139 ldebug << "z-slices n=0" << std::endl;
140 LOG(debug) << ldebug.str();
141 return;
142 }
143
144 ldebug << " zIn=" << fstart[0].Z() << " zOut=" << fendZ[nSlices - 1]
145 << std::endl;
146 ldebug << "z-slices n=" << nSlices << ": " << std::endl;
147 for (unsigned iz(0); iz < nSlices; ++iz) {
148 ldebug << fvolName[iz] << " " << fmaterial[iz] << " vtxz=" << fvtx[iz].Z()
149 << " slice [" << fstart[iz].Z() << "-" << fendZ[iz] << "] "
150 << std::endl;
151 }
152 ldebug << std::endl;
153 LOG(debug) << ldebug.str();
154}

◆ SetDensity()

void MuonPath::SetDensity ( const double & aD)
inline

Definition at line 77 of file MuonPath.h.

77{ fdensity = aD; };

◆ SetLabel()

void MuonPath::SetLabel ( const std::string & aLab)
inline

Definition at line 69 of file MuonPath.h.

69{ flabel = aLab; };

◆ SetLength()

void MuonPath::SetLength ( const double & aStep,
const TVector3 & aStart,
const double & aZ )
inline

Definition at line 83 of file MuonPath.h.

84 {
85 flength += aStep;
86 fendLength.push_back(flength);
87 fzlength += aZ;
88 fstart.push_back(aStart);
89 fendZ.push_back(aStart.Z() + aZ);
90 fwdensity += aStep * fdensity;
91 fsliceDensity.push_back(fdensity);
92 const unsigned idx = static_cast<unsigned>(fstart.size() - 1);
93 fstartT.push_back(0.);
94 fstartT.back() = GetTimeNs(aStart.Z(), idx);
95 };
double GetTimeNs(const double &aZ, const unsigned &idx) const
Definition MuonPath.h:160

◆ SetVertexInfo()

void MuonPath::SetVertexInfo ( const TVector3 & vecpos,
const TVector3 & vecp,
const double & time )

Definition at line 20 of file MuonPath.cxx.

21 {
22 fvtx.push_back(vecpos);
23 fvtxT.push_back(time);
24 fpvec.push_back(vecp);
25}

Member Data Documentation

◆ fdensity

double MuonPath::fdensity
private

Definition at line 173 of file MuonPath.h.

◆ fendLength

std::vector<double> MuonPath::fendLength
private

Definition at line 187 of file MuonPath.h.

◆ fendZ

std::vector<double> MuonPath::fendZ
private

Definition at line 184 of file MuonPath.h.

◆ flabel

std::string MuonPath::flabel
private

Definition at line 172 of file MuonPath.h.

◆ flength

double MuonPath::flength
private

Definition at line 175 of file MuonPath.h.

◆ fmaterial

std::vector<std::string> MuonPath::fmaterial
private

Definition at line 179 of file MuonPath.h.

◆ fpvec

std::vector<TVector3> MuonPath::fpvec
private

Definition at line 188 of file MuonPath.h.

◆ fsliceDensity

std::vector<double> MuonPath::fsliceDensity
private

Definition at line 185 of file MuonPath.h.

◆ fstart

std::vector<TVector3> MuonPath::fstart
private

Definition at line 182 of file MuonPath.h.

◆ fstartT

std::vector<double> MuonPath::fstartT
private

Definition at line 183 of file MuonPath.h.

◆ fvolName

std::vector<std::string> MuonPath::fvolName
private

Definition at line 178 of file MuonPath.h.

◆ fvtx

std::vector<TVector3> MuonPath::fvtx
private

Definition at line 180 of file MuonPath.h.

◆ fvtxT

std::vector<double> MuonPath::fvtxT
private

Definition at line 181 of file MuonPath.h.

◆ fwdensity

double MuonPath::fwdensity
private

Definition at line 174 of file MuonPath.h.

◆ fzlength

double MuonPath::fzlength
private

Definition at line 176 of file MuonPath.h.


The documentation for this class was generated from the following files: