forked from JeffersonLab/SBS-offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SBSScalerHelicity.h
141 lines (111 loc) · 4.02 KB
/
SBSScalerHelicity.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef _SBSScalerHelicity_h_
#define _SBSScalerHelicity_h_
//////////////////////////////////////////////////////////////////////
//
// SBSScalerHelicity
//
// Based on the Podd class HallA/THaQWEAKHelicity
// Helicity of the beam - from QWEAK electronics in delayed mode
//
////////////////////////////////////////////////////////////////////////
#include <vector>
#include "THaHelicityDet.h"
#include "SBSScalerHelicityReader.h"
#include "TROOT.h"
#include "TTree.h"
#include "TString.h"
class TH1F;
class SBSScalerHelicity : public THaHelicityDet, public SBSScalerHelicityReader {
public:
SBSScalerHelicity( const char* name, const char* description,
THaApparatus* a = nullptr );
SBSScalerHelicity();
virtual ~SBSScalerHelicity();
virtual Int_t Begin( THaRunBase* r=nullptr );
virtual void Clear( Option_t* opt = "" );
virtual Int_t Decode( const THaEvData& evdata );
virtual Int_t End( THaRunBase* r=nullptr );
virtual void SetDebug( Int_t level );
virtual Bool_t HelicityValid() const { return fValidHel; }
void PrintEvent( UInt_t evtnum );
void SetVerbosity(int v) { fVerbosity = v; }
void SetHelicityDelay(Int_t delay){
if (delay<0) {
std::cerr << "**** Helicity Delay cannot be negative. Force to zero."
<< std::endl;
fHelicityDelay = 0;
}
else if (delay>64) {
std::cerr << "**** Helicity Delay cannot be greater than 64. Force to zero."
<< std::endl;
} else {
fHelicityDelay = delay;
}
}
protected:
virtual void FillHisto();
void CheckTIRvsRing( UInt_t eventnumber );
void LoadHelicity( UInt_t eventnumber );
UInt_t RanBit30( UInt_t& ranseed );
THaHelicityDet::EHelicity SetHelicity( UInt_t polarity, UInt_t phase);
// variables that need to be read from the database
UInt_t fOffsetTIRvsRing;
// Offset between the ring reported value and the TIR reported value
UInt_t fQWEAKDelay;
// delay of helicity (# windows)
UInt_t fMAXBIT;
//number of bit in the pseudo random helicity generator
std::vector<Int_t> fPatternSequence; // sequence of 0 and 1 in the pattern
UInt_t fQWEAKNPattern; // maximum of event in the pattern
Bool_t HWPIN;
Int_t fHelicityDelay;
Int_t fQrt;
Int_t fTSettle;
Bool_t fValidHel;
UInt_t fHelicityLastTIR;
UInt_t fPatternLastTIR;
void SetErrorCode(Int_t error);
Double_t fErrorCode;
// Ring related data
// UInt_t fScalerCumulative[32];
UInt_t fScalerCumulativePlus[32];
UInt_t fScalerCumulativeMinus[32];
// 64-bit signed integer versions
Long64_t fScalerCumulative[32]; // 64-bit signed integer
// Long64_t fScalerCumulativePlus[32];
// Long64_t fScalerCumulativeMinus[32];
UInt_t fRingFinalQrtHel;
UInt_t fRingFinalEvtNum;
UInt_t fRingFinalPatNum;
UInt_t fRingFinalSeed;
UInt_t fRingPattPhase;
UInt_t fRingHelicitySum;
Long_t fTimeStampYield;
Long_t fTimeStampDiff;
Long_t fScalerYield[32];
Long_t fScalerDiff[32];
UInt_t fRing_NSeed; //number of event collected for seed
UInt_t fRingU3plus, fRingU3minus;
UInt_t fRingT3plus, fRingT3minus;
UInt_t fRingT5plus, fRingT5minus;
UInt_t fRingT10plus, fRingT10minus;
UInt_t fRingTimeplus, fRingTimeminus;
UInt_t fRingSeed_reported;
UInt_t fRingSeed_actual;
UInt_t fRingPhase_reported;
UInt_t fRing_reported_polarity;
UInt_t fRing_actual_polarity;
UInt_t fEvtype; // Current CODA event type
Int_t fVerbosity;
// tree to write data to
TTree *fHelScalerTree;
// branch variables
UInt_t fBranch_seed;
Double_t fBranch_errCode;
static const Int_t NHIST = 2;
std::vector<TH1F*> fHisto;
virtual Int_t DefineVariables( EMode mode = kDefine );
virtual Int_t ReadDatabase( const TDatime& date );
ClassDef(SBSScalerHelicity,0) // Beam helicity from QWEAK electronics in delayed mode
};
#endif