Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaIdealBeam.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 25-Mar-2003
2
4//
5// THaIdealBeam
6//
7// Apparatus describing an ideal beam - constant position and direction.
8//
10
11#include "THaIdealBeam.h"
12#include "TMath.h"
13#include "TDatime.h"
14#include "VarDef.h"
15
17
18//_____________________________________________________________________________
19THaIdealBeam::THaIdealBeam( const char* name, const char* description )
20 : THaBeam( name, description )
21{
22 // Constructor. Sets default beam position to (0,0,0) and direction to
23 // (0,0,1) (along z-axis)
24
25 fDirection.SetXYZ(0.0,0.0,1.0);
26}
27
28//_____________________________________________________________________________
30{
31 // Module initialization: get run parameters, then read databases. Calls
32 // our ReadRunDatabase below and sets our fixed position & direction.
33
34 if( THaBeam::Init(run_time) )
35 return fStatus;
36
37 // Copy our beam data to our beam info variables. This can be done here
38 // instead of in Reconstruct() because the info is constant.
39 Update();
40 return kOK;
41}
42
43//_____________________________________________________________________________
45{
46 // Query the run database for the position and direction information.
47 // Tags: <prefix>.x (m)
48 // <prefix>.y (m)
49 // <prefix>.theta (deg)
50 // <prefix>.phi (deg)
51 //
52 // If no tags exist, position and direction will be set to (0,0,0)
53 // and (0,0,1), respectively.
54
55 Int_t err = THaBeam::ReadRunDatabase( date );
56 if( err ) return err;
57
58 FILE* file = OpenRunDBFile( date );
59 if( !file ) return kFileError;
60
61 static const Double_t degrad = TMath::Pi()/180.0;
62
63 Double_t x = 0.0, y = 0.0, th = 0.0, ph = 0.0;
64
65 const DBRequest req[] = {
66 { "x", &x, kDouble, 0, true },
67 { "y", &y, kDouble, 0, true },
68 { "theta", &th, kDouble, 0, true },
69 { "phi", &ph, kDouble, 0, true },
70 { nullptr }
71 };
72 err = LoadDB( file, date, req );
73 if( err )
74 return kInitError;
75
76 fPosition.SetXYZ( x, y, 0.0 );
77
78 Double_t tt = TMath::Tan(degrad*th);
79 Double_t tp = TMath::Tan(degrad*ph);
80 fDirection.SetXYZ( tt, tp, 1.0 );
81 fDirection *= 1.0/TMath::Sqrt( 1.0+tt*tt+tp*tp );
82
83 fclose(file);
84 return kOK;
85}
int Int_t
double Double_t
char name[80]
virtual Int_t ReadRunDatabase(const TDatime &date)
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
virtual FILE * OpenRunDBFile(const TDatime &date)
TVector3 fPosition
Definition THaBeam.h:32
virtual void Update()
Definition THaBeam.cxx:85
TVector3 fDirection
Definition THaBeam.h:33
virtual Int_t ReadRunDatabase(const TDatime &date)
THaIdealBeam(const char *name, const char *description)
void SetXYZ(Double_t x, Double_t y, Double_t z)
Double_t y[n]
Double_t x[n]
Double_t Sqrt(Double_t x)
constexpr Double_t Pi()
Double_t Tan(Double_t)
auto * tt
ClassImp(TPyArg)