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