Hall C ROOT/C++ Analyzer (hcana)
Loading...
Searching...
No Matches
THcBCMCurrent.cxx
Go to the documentation of this file.
1
18#include "THcParmList.h"
19#include "THcGlobals.h"
20#include "THcHitList.h"
21
22#include "THcBCMCurrent.h"
23
24using namespace std;
25
27 const char* description) :
28 THaPhysicsModule(name, description)
29{
30
31 fBCMflag = 0;
32
33 fBCM1avg = 0;
34 fBCM2avg = 0;
35 fBCM4aavg = 0;
36 fBCM4bavg = 0;
37 fBCM4cavg = 0;
38}
39
40//__________________________________________________
41
43{
44
46
47 delete [] fiBCM1; fiBCM1 = NULL;
48 delete [] fiBCM2; fiBCM2 = NULL;
49 delete [] fiBCM4a; fiBCM4a = NULL;
50 delete [] fiBCM4b; fiBCM4b = NULL;
51 delete [] fiBCM4c; fiBCM4c = NULL;
52 delete [] fEvtNum; fEvtNum = NULL;
53
54}
55
56//__________________________________________________
57
59{
60
61
62 if( THaPhysicsModule::Init( date ) != kOK )
63 return fStatus;
64
65 return fStatus = kOK;
66}
67
68//__________________________________________________
69
71{
72
73 DBRequest list1[] = {
74 {"num_scal_reads", &fNscaler, kInt},
75 {"gBCM_Current_threshold", &fThreshold, kDouble},
76 {"gBCM_Current_threshold_index", &fBCMIndex, kInt},
77 {0}
78 };
79
80 gHcParms->LoadParmValues((DBRequest*)&list1);
81
87
88 fEvtNum = new Int_t[fNscaler];
89
90 DBRequest list2[] = {
91 {"scal_read_bcm1_current", fiBCM1, kDouble, (UInt_t) fNscaler},
92 {"scal_read_bcm2_current", fiBCM2, kDouble, (UInt_t) fNscaler},
93 {"scal_read_bcm4a_current", fiBCM4a, kDouble, (UInt_t) fNscaler},
94 {"scal_read_bcm4b_current", fiBCM4b, kDouble, (UInt_t) fNscaler},
95 {"scal_read_bcm4c_current", fiBCM4c, kDouble, (UInt_t) fNscaler},
96 {"scal_read_event", fEvtNum, kInt, (UInt_t) fNscaler},
97 {0}
98 };
99
100 gHcParms->LoadParmValues((DBRequest*)&list2);
101
102 BCMInfo binfo;
103 for(int i=0; i<fNscaler; i++)
104 {
105 binfo.bcm1_current = fiBCM1[i];
106 binfo.bcm2_current = fiBCM2[i];
107 binfo.bcm4a_current = fiBCM4a[i];
108 binfo.bcm4b_current = fiBCM4b[i];
109 binfo.bcm4c_current = fiBCM4c[i];
110
111 BCMInfoMap.insert( std::make_pair(fEvtNum[i], binfo) );
112 }
113
114 return kOK;
115
116}
117
118//__________________________________________________
119
121{
122
123 if( mode == kDefine && fIsSetup ) return kOK;
124 fIsSetup = ( mode == kDefine );
125
126 RVarDef vars[] = {
127 {"CurrentFlag", "BCM current flag for good event", "fBCMflag"},
128 {"bcm1.AvgCurrent", "BCM1 average beam current", "fBCM1avg"},
129 {"bcm2.AvgCurrent", "BCM2 average beam current", "fBCM2avg"},
130 {"bcm4a.AvgCurrent", "BCM4a average beam current", "fBCM4aavg"},
131 {"bcm4b.AvgCurrent", "BCM4b average beam current", "fBCM4bavg"},
132 {"bcm4c.AvgCurrent", "BCM4c average beam current", "fBCM4cavg"},
133 { 0 }
134 };
135
136 return DefineVarsFromList(vars, mode);
137
138}
139
140//__________________________________________________
141
143{
144
145 if( !IsOK() ) return -1;
146
147 int fEventNum = evdata.GetEvNum();
148
149 BCMInfo binfo;
150 Int_t fGetScaler = GetAvgCurrent( fEventNum, binfo );
151
152 if(fGetScaler != kOK)
153 {
154 fBCM1avg = 0;
155 fBCM2avg = 0;
156 fBCM4aavg = 0;
157 fBCM4bavg = 0;
158 fBCM4cavg = 0;
159 }
160 else
161 {
162 fBCM1avg = binfo.bcm1_current;
163 fBCM2avg = binfo.bcm2_current;
164 fBCM4aavg = binfo.bcm4a_current;
165 fBCM4bavg = binfo.bcm4b_current;
166 fBCM4cavg = binfo.bcm4c_current;
167 }
168
169 switch (fBCMIndex)
170 {
171 case BCM1 :
172 fBCMflag = ( fBCM1avg < fThreshold )?0:1;
173 break;
174 case BCM2:
175 fBCMflag = ( fBCM2avg < fThreshold )?0:1;
176 break;
177 case BCM4A:
178 fBCMflag = ( fBCM4aavg < fThreshold )?0:1;
179 break;
180 case BCM4B:
181 fBCMflag = ( fBCM4bavg < fThreshold )?0:1;
182 break;
183 case BCM4C:
184 fBCMflag = ( fBCM4cavg < fThreshold )?0:1;
185 break;
186 default:
187 fBCMflag = 0;
188 break;
189 }
190
191 return kOK;
192
193}
194
195//__________________________________________________
196
198{
199
200 map<int, BCMInfo>::iterator it, next;
201 it = BCMInfoMap.find(fevn);
202 if( it != BCMInfoMap.end() )
203 {
204 bcminfo.bcm1_current = it->second.bcm1_current;
205 bcminfo.bcm2_current = it->second.bcm2_current;
206 bcminfo.bcm4a_current = it->second.bcm4a_current;
207 bcminfo.bcm4b_current = it->second.bcm4b_current;
208 bcminfo.bcm4c_current = it->second.bcm4c_current;
209
210 return kOK;
211 }
212 else
213 {
214 next = BCMInfoMap.upper_bound(fevn);
215 if( next != BCMInfoMap.end() )
216 {
217 bcminfo.bcm1_current = next->second.bcm1_current;
218 bcminfo.bcm2_current = next->second.bcm2_current;
219 bcminfo.bcm4a_current = next->second.bcm4a_current;
220 bcminfo.bcm4b_current = next->second.bcm4b_current;
221 bcminfo.bcm4c_current = next->second.bcm4c_current;
222 return kOK;
223 }
224 return kOK+1;
225 }
226
227 return kOK+1;
228
229}
230
231//__________________________________________________
232
int Int_t
unsigned int UInt_t
double Double_t
Option_t Option_t TPoint TPoint const char mode
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
Definition THcGlobals.h:11
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="")
Bool_t IsOK() const
UInt_t GetEvNum() const
Read BCM current from scalers and compare to thresholds.
Double_t fBCM4cavg
Double_t * fiBCM4b
Double_t fThreshold
Int_t GetAvgCurrent(Int_t fevn, BCMInfo &bcminfo)
Double_t fBCM1avg
virtual Int_t ReadDatabase(const TDatime &date)
Double_t * fiBCM4a
Double_t * fiBCM2
Double_t fBCM2avg
THcBCMCurrent(const char *name, const char *description)
Double_t fBCM4bavg
Double_t fBCM4aavg
std::map< Int_t, BCMInfo > BCMInfoMap
virtual Int_t Process(const THaEvData &)
Double_t * fiBCM1
virtual Int_t DefineVariables(EMode mode=kDefine)
Double_t * fiBCM4c
virtual ~THcBCMCurrent()
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
STL namespace.