Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaHelicity.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 03-April-2008
3//
4// THaHelicity
5//
7
8#include "THaHelicity.h"
9#include "THaEvData.h"
10#include "VarDef.h"
11#include <iostream>
12
13using namespace std;
14
15//____________________________________________________________________
16THaHelicity::THaHelicity( const char* name, const char* description,
17 THaApparatus* app ) :
18 THaADCHelicity(name, description, app), fG0_Hel(kUnknown),
19 fGoodHel(false), fGoodHel2(false)
20{
21
22}
23
24//____________________________________________________________________
26 : THaADCHelicity(), fG0_Hel(kUnknown),
27 fGoodHel(false), fGoodHel2(false)
28{
29 // Default constructor - for ROOT I/O only
30}
31
32//____________________________________________________________________
34{
35 // Destructor
36
38}
39
40//____________________________________________________________________
42{
43 // Initialize global variables
44
45 // Define standard variables from base class
47 if( ret )
48 return ret;
49
50 // Define variables for the G0 in-time mode
51 const RVarDef var[] = {
52 { "qrt", "QRT from ROC", "fQrt" },
53 { "gate", "Helicity Gate from ROC", "fGate" },
54 { "pread", "Present G0 reading", "fPresentReading" },
55 { "timestamp", "Timestamp from ROC", "fTimestamp" },
56 { "validtime", "Timestamp is valid", "fValidTime" },
57 { "g0_hel", "G0 helicity reading", "fG0_Hel" },
58 { "goodhel", "ADC and G0 helicities agree", "fGoodHel" },
59 { "goodhel2", "ADC and G0 helicities agree unless one unknown",
60 "fGoodHel2" },
61 { nullptr }
62 };
63 return DefineVarsFromList( var, mode );
64}
65
66//____________________________________________________________________
68{
69 // Read database
70
71 // Read ADCHelicity parameters
73 if( st != kOK )
74 return st;
75
76 // Read G0 readout parameters (ROC addresses etc.)
78 date, fG0Debug );
79 if( st != kOK )
80 return st;
81
82 // Read parameters for this class
83 FILE* file = OpenFile( date );
84 if( !file ) return kFileError;
85
86 DBRequest req[] = {
87 { "verbose", &fDebug, kInt, 0, true, -2 },
88 { nullptr }
89 };
90 st = LoadDB( file, date, req );
91 fclose(file);
92 if( st )
93 return kInitError;
94
95 return kOK;
96}
97
98//____________________________________________________________________
100{
101 // Clear the event data
102
106 fGoodHel2 = fGoodHel = false;
107}
108
109//____________________________________________________________________
111{
112 // Decode ADC and G0 helicity data. Check for agreement.
113 // If disagreement, print error if requested.
114
115 Int_t st = THaADCHelicity::Decode( evdata );
116 if( st < 0 )
117 return st;
118
119 // Read G0 data
120 st = ReadData( evdata );
121 if( st < 0 )
122 return st;
123 if( fGate )
125
126 // Test helicities for agreement
128 fGoodHel2 = (fGoodHel ||
129 (fADC_Hel == kUnknown && fG0_Hel != kUnknown) ||
130 (fG0_Hel == kUnknown && fADC_Hel != kUnknown) );
131
132 if( (!fGoodHel && fDebug >= 2) || (!fGoodHel2 && fDebug >= 1) ) {
133 Warning( Here("Decode"), "ADC and G0 helicities disagree: %d %d at "
134 "evno = %d", fADC_Hel, fG0_Hel, evdata.GetEvNum() );
135 }
136
137 return kOK;
138}
139
140
142
#define kOK
Definition BdataLoc.cxx:40
#define kInitError
Definition BdataLoc.cxx:41
int Int_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
char name[80]
kUnknown
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual Int_t ReadDatabase(const TDatime &date)
virtual Int_t Decode(const THaEvData &evdata)
virtual void Clear(Option_t *opt="")
EHelicity fADC_Hel
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual const char * Here(const char *) const
const char * GetPrefix() const
virtual FILE * OpenFile(const TDatime &date)
UInt_t GetEvNum() const
Definition THaEvData.h:56
virtual Int_t ReadData(const THaEvData &evdata)
Int_t ReadDatabase(const char *dbfilename, const char *prefix, const TDatime &date, int debug_flag=0)
virtual void Clear(Option_t *opt="")
virtual const char * GetDBFileName() const
virtual Int_t ReadDatabase(const TDatime &date)
Bool_t fGoodHel2
Definition THaHelicity.h:35
Bool_t fGoodHel
Definition THaHelicity.h:34
virtual Int_t DefineVariables(EMode mode=kDefine)
Int_t fG0_Hel
Definition THaHelicity.h:33
virtual void Clear(Option_t *opt="")
virtual ~THaHelicity()
virtual Int_t Decode(const THaEvData &evdata)
virtual void Warning(const char *method, const char *msgfmt,...) const
STL namespace.
ClassImp(TPyArg)