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
17
using namespace
std
;
18
19
//_____________________________________________________________________________
20
THaRunParameters::THaRunParameters
() :
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
26
fPrescale
.
Set
(
Decoder::CodaDecoder::MAX_PSFACT
);
27
for
(
int
i=0; i<
fPrescale
.
GetSize
(); i++)
28
fPrescale
[i] = -1;
29
}
30
31
//_____________________________________________________________________________
32
void
THaRunParameters::Clear
(
Option_t
* )
33
{
34
// Clear run parameters
35
fBeamName
=
fTgtName
=
fRunName
=
""
;
36
fBeamE
=
fBeamP
=
fBeamM
=
fBeamdE
=
fBeamPol
=
fTgtM
=
fTgtPol
= 0;
37
fBeamQ
= 0;
38
fIsPol
=
false
;
39
fPrescale
.
Reset
();
40
}
41
42
//_____________________________________________________________________________
43
void
THaRunParameters::Print
(
Option_t
* )
const
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"
;
61
Int_t
np
=
fPrescale
.
GetSize
();
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
//_____________________________________________________________________________
74
Int_t
THaRunParameters::ReadDatabase
(
const
TDatime
& date )
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
//_____________________________________________________________________________
108
void
THaRunParameters::SetBeam
(
Double_t
E,
Double_t
M,
Int_t
Q,
Double_t
dE )
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
//_____________________________________________________________________________
122
void
THaRunParameters::SetPolarizations
(
Double_t
pb,
Double_t
pt )
123
{
124
// Set beam and target polarization values (user-defined meaning)
125
126
fBeamPol
= pb;
127
fTgtPol
=
pt
;
128
fIsPol
= (
TMath::Abs
(pb*
pt
) > 1
e
-8);
129
130
}
131
132
//_____________________________________________________________________________
133
ClassImp
(
THaRunParameters
)
Int_t
int Int_t
CodaDecoder.h
kBig
const Data_t kBig
Definition
DataType.h:15
f
#define f(i)
e
#define e(i)
Double_t
double Double_t
Option_t
const char Option_t
TDatime.h
TError.h
np
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
THaAnalysisObject.h
LOAD
#define LOAD
OPEN
#define OPEN
THaRunParameters.h
TMath.h
Decoder::CodaDecoder::MAX_PSFACT
@ MAX_PSFACT
Definition
CodaDecoder.h:46
TArrayI::Set
void Set(Int_t n) override
TArrayI::Reset
void Reset()
TArray::GetSize
Int_t GetSize() const
TDatime
THaRunParameters
Definition
THaRunParameters.h:16
THaRunParameters::fBeamQ
Int_t fBeamQ
Definition
THaRunParameters.h:56
THaRunParameters::fBeamdE
Double_t fBeamdE
Definition
THaRunParameters.h:57
THaRunParameters::SetPolarizations
void SetPolarizations(Double_t pb, Double_t pt)
Definition
THaRunParameters.cxx:122
THaRunParameters::THaRunParameters
THaRunParameters()
Definition
THaRunParameters.cxx:20
THaRunParameters::SetBeam
void SetBeam(Double_t E, Double_t M, Int_t Q, Double_t dE=0.0)
Definition
THaRunParameters.cxx:108
THaRunParameters::fIsPol
Bool_t fIsPol
Definition
THaRunParameters.h:64
THaRunParameters::fBeamM
Double_t fBeamM
Definition
THaRunParameters.h:55
THaRunParameters::Clear
virtual void Clear(Option_t *opt="")
Definition
THaRunParameters.cxx:32
THaRunParameters::fRunName
TString fRunName
Definition
THaRunParameters.h:67
THaRunParameters::fBeamName
TString fBeamName
Definition
THaRunParameters.h:52
THaRunParameters::ReadDatabase
virtual Int_t ReadDatabase(const TDatime &date)
Definition
THaRunParameters.cxx:74
THaRunParameters::fPrescale
TArrayI fPrescale
Definition
THaRunParameters.h:68
THaRunParameters::fBeamE
Double_t fBeamE
Definition
THaRunParameters.h:53
THaRunParameters::fBeamP
Double_t fBeamP
Definition
THaRunParameters.h:54
THaRunParameters::fTgtM
Double_t fTgtM
Definition
THaRunParameters.h:62
THaRunParameters::fTgtPol
Double_t fTgtPol
Definition
THaRunParameters.h:63
THaRunParameters::fTgtName
TString fTgtName
Definition
THaRunParameters.h:61
THaRunParameters::Print
virtual void Print(Option_t *opt="") const
Definition
THaRunParameters.cxx:43
THaRunParameters::fBeamPol
Double_t fBeamPol
Definition
THaRunParameters.h:58
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
pt
TPaveText * pt
EComplexType::kDouble
@ kDouble
E
constexpr Double_t E()
TMath::Sqrt
Double_t Sqrt(Double_t x)
TMath::Abs
Double_t Abs(Double_t d)
std
STL namespace.
ClassImp
ClassImp(TPyArg)
Podd
THaRunParameters.cxx
Generated by
1.9.8