CbmRoot
Loading...
Searching...
No Matches
CbmBeam.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 "CbmBeam.h"
11
12#include <cassert>
13#include <sstream>
14
15
16// ----- Default constructor --------------------------------------------
17CbmBeam::CbmBeam(Double_t x, Double_t y, Double_t z, Double_t thetaX, Double_t thetaY)
18 : fPosition(x, y, z)
19 , fDirection(TMath::Tan(thetaX), TMath::Tan(thetaY), 1.)
20{
21}
22// --------------------------------------------------------------------------
23
24
25// ----- Extrapolation to a plane ---------------------------------------
26TVector3 CbmBeam::ExtrapolateToPlane(const TVector3& point, const TVector3& norm) const
27{
28
29 // The beam should not be parallel to the plane
30 assert(norm * fDirection);
31
32 // Calculate intersection point. Just some analytic geometry.
33 Double_t numer = norm * (point - fPosition);
34 Double_t denom = norm * fDirection;
35 return fPosition + (numer / denom) * fDirection;
36}
37// --------------------------------------------------------------------------
38
39
40// ----- Info -----------------------------------------------------------
41std::string CbmBeam::ToString() const
42{
43
44 std::stringstream ss;
45 ss << "Current beam: position (" << fPosition.X() << ", " << fPosition.Y() << ", " << fPosition.Z() << ") cm, angle ("
46 << fDirection.X() << ", " << fDirection.Y() << ") rad";
47
48 return ss.str();
49}
50// --------------------------------------------------------------------------
TVector3 fPosition
Position vector.
Definition CbmBeam.h:88
CbmBeam(Double_t x=0., Double_t y=0., Double_t z=0., Double_t thetaX=0., Double_t thetaY=0.)
Default constructor.
Definition CbmBeam.cxx:17
TVector3 ExtrapolateToPlane(const TVector3 &point, const TVector3 &normal) const
Extrapolation of the beam to a plane.
Definition CbmBeam.cxx:26
TVector3 fDirection
Direction vector (dx/dz, dy/dz, 1.)
Definition CbmBeam.h:89
std::string ToString() const
Info on current beam trajectory.
Definition CbmBeam.cxx:41