CbmRoot
Loading...
Searching...
No Matches
CbmStsPoint.cxx
Go to the documentation of this file.
1/* Copyright (C) 2004-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese, Florian Uhlig, Denis Bertini [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmStsPoint source file -----
7// ----- Created 26/07/04 by V. Friese -----
8// -------------------------------------------------------------------------
9
10#include "CbmStsPoint.h"
11
12#include "CbmDefs.h" // for kMCTrack
13
14#include <FairLink.h> // for FairLink
15#include <FairMCPoint.h> // for FairMCPoint
16
17#include <sstream> // for operator<<, basic_ostream, endl, stri...
18#include <string> // for char_traits
19
20#include <cmath>
21
22using std::endl;
23using std::string;
24using std::stringstream;
25
26// ----- Default constructor -------------------------------------------
28 : FairMCPoint()
29 , fX_out(0.)
30 , fY_out(0.)
31 , fZ_out(0.)
32 , fPx_out(0.)
33 , fPy_out(0.)
34 , fPz_out(0.)
35 , fPid(0)
36 , fIndex(0)
37 , fFlag(0)
38{
39}
40// -------------------------------------------------------------------------
41
42
43// ----- Standard constructor ------------------------------------------
44CbmStsPoint::CbmStsPoint(int32_t trackID, int32_t detID, TVector3 posIn, TVector3 posOut, TVector3 momIn,
45 TVector3 momOut, double tof, double length, double eLoss, int32_t pid, int32_t eventId,
46 int32_t index, int16_t flag)
47 : FairMCPoint(trackID, detID, posIn, momIn, tof, length, eLoss, eventId)
48 , fX_out(posOut.X())
49 , fY_out(posOut.Y())
50 , fZ_out(posOut.Z())
51 , fPx_out(momOut.Px())
52 , fPy_out(momOut.Py())
53 , fPz_out(momOut.Pz())
54 , fPid(pid)
55 , fIndex(index)
56 , fFlag(flag)
57{
58 SetLink(FairLink(ToIntegralType(ECbmDataType::kMCTrack), trackID));
59}
60// -------------------------------------------------------------------------
61
62
63// ----- Destructor ----------------------------------------------------
65// -------------------------------------------------------------------------
66
67
68// ----- Copy constructor with event and epoch time --------------------
69CbmStsPoint::CbmStsPoint(const CbmStsPoint& point, int32_t eventId, double eventTime, double epochTime)
70 : FairMCPoint(point)
71 , fX_out(point.fX_out)
72 , fY_out(point.fY_out)
73 , fZ_out(point.fZ_out)
74 , fPx_out(point.fPx_out)
75 , fPy_out(point.fPy_out)
76 , fPz_out(point.fPz_out)
77 , fPid(point.fPid)
78 , fIndex(point.fIndex)
79 , fFlag(point.fFlag)
80
81{
82 // *this = point;
83 if (eventId > 0) fEventId = eventId;
84 fTime = point.GetTime() + eventTime - epochTime;
85}
86// -------------------------------------------------------------------------
87
88
89// ----- Point x coordinate from linear extrapolation ------------------
90double CbmStsPoint::GetX(double z) const
91{
92 // LOG(info) << fZ << " " << z << " " << fZ_out;
93 double dz = fZ_out - fZ;
94 if (fabs(dz) < 1.e-4) return 0.5 * (fX_out + fX);
95 return (fX + (z - fZ) / dz * (fX_out - fX));
96}
97// -------------------------------------------------------------------------
98
99
100// ----- Point y coordinate from linear extrapolation ------------------
101double CbmStsPoint::GetY(double z) const
102{
103 double dz = fZ_out - fZ;
104 if (fabs(dz) < 1.e-4) return 0.5 * (fY_out + fY);
105 return (fY + (z - fZ) / dz * (fY_out - fY));
106}
107// -------------------------------------------------------------------------
108
109
110// ----- Public method IsUsable ----------------------------------------
112{
113 double dz = fZ_out - fZ;
114 if (abs(dz) < 1.e-4) return false;
115 return true;
116}
117// -------------------------------------------------------------------------
118
119
120// ----- String output -------------------------------------------------
122{
123 stringstream ss;
124 ss << "StsPoint: track ID " << fTrackID << ", detector ID " << fDetectorID << endl;
125 ss << " IN Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl;
126 ss << " OUT Position (" << fX_out << ", " << fY_out << ", " << fZ_out << ") cm" << endl;
127 ss << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl;
128 ss << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" << endl;
129 return ss.str();
130}
131// -------------------------------------------------------------------------
132
133
ClassImp(CbmConverterManager)
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition CbmDefs.h:29
bool IsUsable() const
double GetX(double z) const
virtual ~CbmStsPoint()
Double32_t fX_out
double GetY(double z) const
std::string ToString() const
Double32_t fZ_out
Double32_t fY_out