Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaRunParameters.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 04-Nov-2003
2
4//
5// THaRunParameters
6//
8
9#include "THaRunParameters.h"
10#include "THaAnalysisObject.h"
11#include "TDatime.h"
12#include "TError.h"
13#include "TMath.h"
14#include "CodaDecoder.h"
15#include <iostream>
16
17using namespace std;
18
19//_____________________________________________________________________________
21 fBeamE(0), fBeamP(0), fBeamM(0), fBeamQ(0), fBeamdE(0), fBeamPol(0),
22 fTgtM(0), fTgtPol(0), fIsPol(false)
23{
24 // Default constructor
25
27 for( int i=0; i<fPrescale.GetSize(); i++)
28 fPrescale[i] = -1;
29}
30
31//_____________________________________________________________________________
33{
34 // Clear run parameters
37 fBeamQ = 0;
38 fIsPol = false;
40}
41
42//_____________________________________________________________________________
44{
45 // Print run parameters
46
47 cout << "Run parameters: " << fRunName << endl;
48 cout << " Beam: " << fBeamName <<endl;
49 cout << " Energy = " << fBeamE << " +/- " << fBeamdE << " GeV\n";
50 cout << " Momentum = " << fBeamP << " GeV/c\n";
51 cout << " Mass/Charge = " << fBeamM << "/" << fBeamQ << " GeV/c^2\n";
52 if( fIsPol ) {
53 cout << " Polarization= " << 100.*fBeamPol << "%\n";
54 }
55 cout << " Target: " << fTgtName << endl;
56 cout << " Mass: = " << fTgtM << " GeV/c^2\n";
57 if( fIsPol ) {
58 cout << " Polarization= " << 100.*fTgtPol << "%\n";
59 }
60 cout << " DAQ:\n";
62 if( np > 0 ){
63 cout << " Prescale factors: (1-"<<np<<")\n ";
64 for( int i=0; i<np; i++ ) {
65 cout << fPrescale[i];
66 if( i != np-1 )
67 cout << "/";
68 }
69 cout << endl;
70 }
71}
72
73//_____________________________________________________________________________
75{
76 // Query the run database for the beam and target parameters at the
77 // specified date/time.
78 //
79 // Return 0 if success, <0 if file error, >0 if not all required data found.
80
81#define OPEN Podd::OpenDBFile
82#define LOAD THaAnalysisObject::LoadDB
83
84 FILE* f = OPEN("run", date, "THaRunParameters::ReadDatabase", "r", 1);
85 if( !f )
86 return -1;
87
88 Double_t E = kBig, M = 0.511e-3, Q = -1.0, dE = 0.0;
89
90 DBRequest request[] = {
91 { "ebeam", &E },
92 { "mbeam", &M, kDouble, 0, true },
93 { "qbeam", &Q, kDouble, 0, true },
94 { "dEbeam", &dE, kDouble, 0, true },
95 { nullptr }
96 };
97 Int_t err = LOAD( f, date, request, "" );
98 fclose(f);
99 if( err )
100 return err;
101
102 SetBeam( E, M, int(Q), dE );
103
104 return 0;
105}
106
107//_____________________________________________________________________________
109{
110 // Set beam parameters.
111
112 fBeamE = E;
113 fBeamM = M;
114 fBeamQ = Q;
115 fBeamP = (E>M) ? TMath::Sqrt(E*E-M*M) : 0.0;
116 if( fBeamP == 0.0 )
117 Warning( "SetBeam()", "Beam momentum = 0 ??");
118 fBeamdE = dE;
119}
120
121//_____________________________________________________________________________
123{
124 // Set beam and target polarization values (user-defined meaning)
125
126 fBeamPol = pb;
127 fTgtPol = pt;
128 fIsPol = (TMath::Abs(pb*pt) > 1e-8);
129
130}
131
132//_____________________________________________________________________________
int Int_t
const Data_t kBig
Definition DataType.h:15
#define f(i)
#define e(i)
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
#define LOAD
#define OPEN
void Set(Int_t n) override
void Reset()
Int_t GetSize() const
void SetPolarizations(Double_t pb, Double_t pt)
void SetBeam(Double_t E, Double_t M, Int_t Q, Double_t dE=0.0)
virtual void Clear(Option_t *opt="")
virtual Int_t ReadDatabase(const TDatime &date)
virtual void Print(Option_t *opt="") const
virtual void Warning(const char *method, const char *msgfmt,...) const
TPaveText * pt
constexpr Double_t E()
Double_t Sqrt(Double_t x)
Double_t Abs(Double_t d)
STL namespace.
ClassImp(TPyArg)