CbmRoot
CbmBeamProfile.cxx
Go to the documentation of this file.
1 
6 #include "CbmBeamProfile.h"
7 
8 #include "TRandom.h"
9 #include <sstream>
10 
11 
12 // ----- Default constructor --------------------------------------------
14  : fFocalZ(0.)
15  , fMeanPosX(0.)
16  , fMeanPosY(0.)
17  , fSigmaPosX(-1.)
18  , fSigmaPosY(-1.)
19  , fMeanThetaX(0.)
20  , fMeanThetaY(0.)
21  , fSigmaThetaX(-1.)
22  , fSigmaThetaY(-1.) {}
23 // --------------------------------------------------------------------------
24 
25 
26 // ----- Check whether average beam hits the target ---------------------
27 Bool_t CbmBeamProfile::CheckWithTarget(const CbmTarget& target) const {
28 
29  // --- Check upstream target surface
30  TVector3 surf1 = target.GetSurfaceCentreUp();
31  TVector3 sect1 = ExtrapolateToPlane(surf1, target.GetNormal());
32  Double_t dist1 = (sect1 - surf1).Mag();
33  if (dist1 > 0.5 * target.GetDiameter()) {
34  LOG(ERROR) << "EventGen: Average beam does not hit first target surface!";
35  LOG(ERROR) << " Surface centre is (" << surf1.X() << ", "
36  << surf1.Y() << ", " << surf1.Z() << ") cm";
37  LOG(ERROR) << " Intersection point is (" << sect1.X() << ", "
38  << sect1.Y() << ", " << sect1.Z() << ") cm";
39  LOG(ERROR) << " Distance to target surface centre is " << dist1
40  << " cm, target radius is " << 0.5 * target.GetDiameter()
41  << " cm";
42  return kFALSE;
43  }
44 
45  // --- Check downstream target surface
46  TVector3 surf2 = target.GetSurfaceCentreDown();
47  TVector3 sect2 = ExtrapolateToPlane(surf2, target.GetNormal());
48  Double_t dist2 = (sect2 - surf2).Mag();
49  if (dist2 > 0.5 * target.GetDiameter()) {
50  LOG(ERROR) << "EventGen: Average beam does not hit second target surface!";
51  LOG(ERROR) << " Surface centre is (" << surf2.X() << ", "
52  << surf2.Y() << ", " << surf2.Z() << ") cm";
53  LOG(ERROR) << " Intersection point is (" << sect2.X() << ", "
54  << sect2.Y() << ", " << sect2.Z() << ") cm";
55  LOG(ERROR) << " Distance to target surface centre is " << dist2
56  << " cm, target radius is " << 0.5 * target.GetDiameter()
57  << " cm";
58  return kFALSE;
59  }
60 
61  return kTRUE;
62 }
63 // --------------------------------------------------------------------------
64 
65 
66 // ----- Extrapolate the average beam to a plane ------------------------
67 TVector3 CbmBeamProfile::ExtrapolateToPlane(const TVector3& point,
68  const TVector3& norm) const {
69 
70  // Average beam trajectory
72 
73  // Intersection of average trajectory with plane
74  return beam.ExtrapolateToPlane(point, norm);
75 }
76 // --------------------------------------------------------------------------
77 
78 
79 // ----- Generate a beam trajectory -------------------------------------
80 std::unique_ptr<CbmBeam> CbmBeamProfile::GenerateBeam() {
81 
82  // Beam x position
83  Double_t x = fMeanPosX;
84  if (fSigmaPosX > 0.) x = gRandom->Gaus(fMeanPosX, fSigmaPosX);
85 
86  // Beam y position
87  Double_t y = fMeanPosY;
88  if (fSigmaPosY > 0.) y = gRandom->Gaus(fMeanPosY, fSigmaPosY);
89 
90  // Beam angle in x-z plane
91  Double_t tx = fMeanThetaX;
92  if (fSigmaThetaX > 0.) tx = gRandom->Gaus(fMeanThetaX, fSigmaThetaX);
93 
94  // Beam angle in y-z plane
95  Double_t ty = fMeanThetaY;
96  if (fSigmaThetaY > 0.) ty = gRandom->Gaus(fMeanThetaY, fSigmaThetaY);
97 
98  std::unique_ptr<CbmBeam> beam(new CbmBeam(x, y, fFocalZ, tx, ty));
99 
100  //return std::move(beam);
101  return beam;
102 }
103 // --------------------------------------------------------------------------
104 
105 
106 // ----- Set the parameters for the beam angle --------------------------
107 void CbmBeamProfile::SetAngle(Double_t x0,
108  Double_t y0,
109  Double_t sigmaX,
110  Double_t sigmaY) {
111  fMeanThetaX = x0;
112  fMeanThetaY = y0;
113  fSigmaThetaX = sigmaX;
114  fSigmaThetaY = sigmaY;
115 }
116 // --------------------------------------------------------------------------
117 
118 
119 // ----- Set the parameters for the beam position -----------------------
121  Double_t y0,
122  Double_t sigmaX,
123  Double_t sigmaY,
124  Double_t zF) {
125  fMeanPosX = x0;
126  fMeanPosY = y0;
127  fSigmaPosX = sigmaX;
128  fSigmaPosY = sigmaY;
129  fFocalZ = zF;
130 }
131 // --------------------------------------------------------------------------
132 
133 
134 // ----- Info to string -------------------------------------------------
135 std::string CbmBeamProfile::ToString() const {
136 
137  std::stringstream ss;
138  ss << "Beam profile:";
139  ss << "\n\t x position ";
140  if (fSigmaPosX > 0.)
141  ss << "mean " << fMeanPosX << " cm, sigma " << fSigmaPosX << " cm";
142  else
143  ss << fMeanPosX << " cm (fixed)";
144  ss << "\n\t y position ";
145  if (fSigmaPosY > 0.)
146  ss << "mean " << fMeanPosY << " cm, sigma " << fSigmaPosY << " cm";
147  else
148  ss << fMeanPosY << " cm (fixed)";
149  ss << "\n\t Focal plane: z = " << fFocalZ << " cm";
150  ss << "\n\t x-z angle ";
151  if (fSigmaThetaX > 0.)
152  ss << "mean " << fMeanThetaX << " rad, sigma " << fSigmaThetaX << " rad";
153  else
154  ss << fMeanThetaX << " rad (fixed)";
155  ss << "\n\t y-z angle ";
156  if (fSigmaThetaY > 0.)
157  ss << "mean " << fMeanThetaY << " rad, sigma " << fSigmaThetaY << " rad";
158  else
159  ss << fMeanThetaY << " rad (fixed)";
160 
161  return ss.str();
162 }
163 // --------------------------------------------------------------------------
CbmBeamProfile::fMeanPosX
Double_t fMeanPosX
Mean position in x [cm].
Definition: CbmBeamProfile.h:106
CbmBeam::ExtrapolateToPlane
TVector3 ExtrapolateToPlane(const TVector3 &point, const TVector3 &normal) const
Extrapolation of the beam to a plane.
Definition: CbmBeam.cxx:24
CbmBeamProfile::SetPosition
void SetPosition(Double_t x0, Double_t y0, Double_t sigmaX=-1., Double_t sigmaY=-1., Double_t zF=0.)
Set the parameters for the beam position distribution.
Definition: CbmBeamProfile.cxx:120
CbmBeamProfile::GenerateBeam
std::unique_ptr< CbmBeam > GenerateBeam()
Generate a beam trajectory.
Definition: CbmBeamProfile.cxx:80
CbmBeamProfile.h
CbmBeamProfile::fMeanThetaX
Double_t fMeanThetaX
Mean angle in x-z plane [rad].
Definition: CbmBeamProfile.h:110
CbmTarget::GetSurfaceCentreDown
TVector3 GetSurfaceCentreDown() const
Downstream surface centre.
Definition: CbmTarget.cxx:217
CbmBeamProfile::SetAngle
void SetAngle(Double_t x0, Double_t y0, Double_t sigmaX=-1., Double_t sigmaY=-1.)
Set the parameters for the beam angle distribution.
Definition: CbmBeamProfile.cxx:107
CbmTarget::GetDiameter
Double_t GetDiameter() const
Get target diameter.
Definition: CbmTarget.h:91
CbmBeamProfile::fSigmaThetaY
Double_t fSigmaThetaY
RMS of angle in y-z plane [rad].
Definition: CbmBeamProfile.h:113
CbmBeamProfile::ToString
std::string ToString() const
Info to string.
Definition: CbmBeamProfile.cxx:135
CbmBeamProfile::ExtrapolateToPlane
TVector3 ExtrapolateToPlane(const TVector3 &point, const TVector3 &norm) const
Extrapolate the average beam to a plane.
Definition: CbmBeamProfile.cxx:67
CbmBeamProfile::fSigmaThetaX
Double_t fSigmaThetaX
RMS of angle in x-z plane [rad].
Definition: CbmBeamProfile.h:112
CbmTarget
Class for constructing the geometry of the CBM target.
Definition: CbmTarget.h:31
CbmBeamProfile::fMeanThetaY
Double_t fMeanThetaY
Mean angle in y-z plane [rad].
Definition: CbmBeamProfile.h:111
CbmBeamProfile::fSigmaPosX
Double_t fSigmaPosX
RMS of position in x [cm].
Definition: CbmBeamProfile.h:108
CbmBeamProfile::fFocalZ
Double_t fFocalZ
z coordinate of focal plane [cm]
Definition: CbmBeamProfile.h:105
CbmBeamProfile::fMeanPosY
Double_t fMeanPosY
Mean position in y [cm].
Definition: CbmBeamProfile.h:107
CbmTarget::GetSurfaceCentreUp
TVector3 GetSurfaceCentreUp() const
Upstream surface centre.
Definition: CbmTarget.cxx:226
CbmBeam
Definition: CbmBeam.h:25
CbmTarget::GetNormal
TVector3 GetNormal() const
Normal vector.
Definition: CbmTarget.cxx:189
CbmBeamProfile::CheckWithTarget
Bool_t CheckWithTarget(const CbmTarget &target) const
Check consistency with a target.
Definition: CbmBeamProfile.cxx:27
CbmBeamProfile::CbmBeamProfile
CbmBeamProfile()
Default constructor
Definition: CbmBeamProfile.cxx:13
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmBeamProfile::fSigmaPosY
Double_t fSigmaPosY
RMS of position in y [cm].
Definition: CbmBeamProfile.h:109