Project

General

Profile

Output » History » Version 1

Ole Hansen, 03/30/2018 10:16 PM

1 1 Ole Hansen
h1. Configuring Analysis Output
2
3
Bob Michaels
4
5
e-mail:    rom@jlab.org
6
7
h2. FEATURES
8
9
Class THaOutput can be used to control the output of the new Root/C++ analyzer .   The output is defined by an output definition file, e.g. what is specified when you do 'analyzer->SetOdefFile("output.def");'   and has the following elements.   Note: To get vectorized formulas and histograms you must be using version 1.1 and higher of the analyzer. To get EPICS and Scaler data you need version 1.2.
10
11
* Global variables written to the tree. Can include arrays -- fixed or variable size. To see a list of variables, type 'gHaVars->Print()' at the analyzer prompt.
12
* Blocks of variables, e.g. L.* is everything in Left Spectrometer.
13
* Formulas involving variables. These can be vectors.
14
* Cuts. They appear in tree as 0 (false) or 1 (true). Also can be vectors.
15
* Histograms. These can involve variables and/or formul40.65a, as well as optional cuts. The histograms can be vectors depending on the rules for dimensionality.
16
* EPICS data (slow controls variables recorded in datastream.)
17
* Scalers (i.e. data from devices called scalers that count things).
18
19
h2. SYNTAX   of "output.def"   FILE
20
21
To add global variables, formulas, and histograms, the
22
syntax of each line of "output.def" is of the form
23
24
<pre>
25
keyword  rest-of-line
26
</pre> 
27
28
where the keywords are as follows :
29
(keywords are case-insensitive, the rest of the line is not)
30
31
   VARIABLE  -- indicates that a global variable is to
32
               be added to the tree.  The next string is
33
               the name of the variable.  You can see a list
34
               of variables by typing gHaVars->Print() at
35
               the analyzer's root shell prompt.
36
               A variable can also be an array, e.g. R.s1.lt  
37
               Then the values in the tree will be R.s1.lt[0], 
38
               R.s1.lt[1], etc, up to the array size which
39
               is Ndata.R.s1.lt
40
  
41
   BLOCK   --  An entire block of variables are written to the
42
               output.  E.g. "L.*" writes all Left HRS variables.
43
44
   FORMULA -- indicates a THaFormula to add to the output.
45
              The next word will be the "name" of the formula result 
46
              in the tree. The 3rd string is the formula to evaluate.  
47
              Note, it cannot have spaces in it.
48
              Formulas can be vectors if the arrays are fixed size.
49
50
   CUT --     Like a formula, but the data are 0 (false) or 1 (true)
51
52
   TH1F, TH2F, TH1D, TH2D  -- defines histograms (1D or 2D).
53
               The next word is the name of the object.
54
               The following string (must be in single quotes) is  40.65
55
               the title of the histogram.  Next, the variables
56
               or formulas names that are put into the histogram 
57
               are listed together with bin info: nbin, xlo, xhi and if 2D
58
               the same bin info for y.  Optional cuts can be specified 
59
               at the end of the line.  See examples below.  
60
61
One can add EPICS data or SCALER data to the output with a pair of
62
("begin", "end") statements in the output.def file.  This adds the data 
63
to both the main tree as well as to new trees.  The new trees are "E" 
64
for epics data, and "left" or "right" for the left and right HRS scalers.
65
66
     begin epics40.65
67
         #  put list of variables here
68
     end epics
69
70
And for the "left" spectrometer scalers (similarly for "right"):
71
72
     begin scalers left
73
         #  put list of variables here
74
     end scalers
75
76
77
h2. LEARN   BY   EXAMPLE
78
79
<pre>
80
# --------  Example output.def  --------------------------
81
82
# Variables appear in the tree.
83
84
variable L.s1.lt[4]
85
variable L.s1.rt40.65
86
87
# The 'block' variables:  All data in Right HRS go to tree.
88
block R.*
89
90
# Formulas can be scalers or vectors.  
91
# Lt4a is a scaler.
92
formula Lt4a 5.*L.s1.lt[4]
93
# Lt4b is a vector.  Access by Lt4b[0], Lt4b[1],... 
94
formula Lt4b 5.*L.s1.lt
95
# Tsm is a vector
96
formula Tsm 4*L.s1.lt+2*L.s1.rt+3*L.s1.lt[4]
97
#   Tsm[0] = 4*L.s1.lt[0]+2*L.s1.rt[0]+3*L.s1.lt[4]
98
#   Tsm[1] = 4*L.s1.lt[1]+2*L.s1.rt[1]+3*L.s1.lt[4]
99
#   etc...
100
101
# Cuts can be defined globally and used in histograms.
102
# Cut C1 is a scaler.  Data is 0 or 1.
103
cut C1 L.s1.lt[4]>1350
104
# Cut C2 is a vector.  Access as C2[0], C2[1],...
105
cut C2 L.s1.lt>1160
106
107
# Histograms can involve formulas, variables, and cuts.
108
# th1f, th1d, th2f, th2d supported.
109
# Formulas and cuts may be global, or defined in the line.
110
# Histograms are vector or scalers whose dimensionality is 
111
# determined by the dimensionality of its components.
112
# 1. dim(X)>=0 && dim(Y)==0 && dim(Cut)==0  --> Data in 1 histo,
113
#             and if dim(X)>1 all components go into 1 histo.
114
# 2. dim(X)>1 && (dim(Y)>1 || dim(Cut)>1) --> vector of histos
115
#     appear in output, the dim's must match and the indices track.
116
# The "eye" variable [I] becomes an index that tracks the
117
# index of the accompanying variable.  L.s1.lt[I] is synonymous
118
# with L.s1.lt.
119
# Prefixes SUM:, OR:, and AND: supported.
120
# SUM:  the sum of variables or sum of a vector formula.
121
# AND:, OR:  logical "and","or" of cut conditions.
122
123
TH1F  rv1n  'L-arm vdc hits on V1'  L.vdc.v1.nhit  10 0 10
124
th1f  rv1w  'L-arm vdc wiremap on V1'  L.vdc.v1.wire  200 0 400
125
TH1F  rv1z  'L-arm vdc TDC on V1'  L.vdc.v1.rawtime  200 0 2500
126
TH1d  hLt4  'Lt4a formula' Lt4a 100 0 9000
127
th1d  hLta  'Lt4b formula' Lt4b 100 0 9000
128
TH1F  Lt4c0 'Lt4 from var, no cut' L.s1.lt[4] 100 -1 2000
129
TH1F  Lt4c1 'Lt4 from var, cut' L.s1.lt[4] 100 -1 2000 L.s1.lt[4]>1300.
130
TH1F  Lt4c2 'Lt4 from var, cut C1' L.s1.lt[4] 100 -1 2000 C1
131
TH1F  Lt4c3 'Lt4 from formula, cut C1' Lt4a 100 -1 9000 C1
132
TH1F  Lts1 'L.s1.rt (all elements)' L.s1.rt 100 -1 2000
133
# Since Lt4b and C2 are vectors, get histograms Ltv0, Ltv1, ... Ltv5
134
TH1F  Ltv  'Vector formula, cut C2' Lt4b 100 -1 20000 C2
135
# The "eye" variable as R. Feuerbach requested
136
TH2F  a1eye 'Eye test 1' [I] L.s1.lt 14 0 7 100 0 2000
137
TH2F  a2eye 'Eye test 2' [i] L.s1.lt[I] 14 0 7 100 0 2000  # same as above
138
TH2F  a3eye 'Eye test 3' [I] Lt4b 14 0 7 100 0 9000
139
TH2F  a4eye 'Eye test 4' [I] Lt4b 14 0 7 100 0 9000 L.s1.lt>1300
140
TH2F  a5eye 'Eye test 5' [I] Lt4b 14 0 7 100 0 9000 C2
141
# Prefixes (SUM:  OR:  AND:)
142
TH1F  Lsum1 'Test of sum 1' SUM:L.s1.lt 100 0 15000 
143
TH2f  Lsum2 'Test of sum 2' SUM:L.s1.rt SUM:L.s1.rt 100 0 15000 100 0 2000
144
TH1F  Lor1  'Test of or 1' L.s1.lt[4] 100 0 2000 OR:L.s1.lt>1000
145
TH1F  Lor2  'Test of or 2' L.s1.lt 100 0 2000 OR:L.s1.lt>1000
146
TH1F  Land1 'Test of and 1' L.s1.lt 100 0 2000 AND:L.s1.lt<1200
147
148
149
# --------------------------------------------------
150
# For reference, here is a collection of things that do NOT work.
151
# Cannot define formula in terms of variable sized arrays.
152
# Exception: 'formula Lv1w L.vdc.v1.wire' results in Lv1w[0], Lv1w[1]...
153
# formula Lw2 L.vdc.v1.wire[2]     # error
154
# formula Lw3 3*L.vdc.v1.wire      # error
155
# A cut defined by a formula does NOT work. Perhaps in future.
156
# cut C4 Lta>1160
157
# Cannot use prefix like SUM: inside a formula.
158
# TH1F Lnot 'Invalid test1' 3*SUM:L.s1.lt 100 0 20000
159
# If Lta is a formula, then cut = Lta>1160 is illegal.
160
# Must instead write the formula explicitly.
161
# TH1F  Lte  'Lta vector formula, cut 3' Lta 100 -1 2000 Lta>1160
162
163
164
# --------------------------------------------------
165
# EPICS data to appear in regular event tree ("T") and
166
# a new EPICS tree ("E").  The E tree is only filled
167
# on EPICS events.  The E tree also has a timestamp.
168
# Access via T->Draw("hac_bcm_average")
169
# and E->Draw("hac_bcm_average")
170
# and E->Draw("hac_bcm_average:timestamp")
171
# Notice that slia:DataValid appears in the
172
# tree as slia_DataValid (i.e. ":" is replaced
173
# by "_").  This replacement makes TTree::Draw
174
# work properly. Note also, the value of 
175
# slia_DataValid is 71 if slia:DataValid
176
# was "Yes" (case senstive!), 422 if "No" and 
177
# 0 otherwise.  
178
179
begin epics
180
   hac_bcm_average
181
   IPM1H04A.XPOS
182
   IPM1H04A.YPOS
183
   IPM1H04B.XPOS
184
   IPM1H04B.YPOS
185
   slia:DataValid  Yes=71 No=422
186
end epics
187
188
# Rules about EPICS variable assignment:
189
# You can now do things like this in
190
# the output definition file
191
192
begin epics
193
   FB_A:use_RF 'RF On'=14 'RF Off'=52
194
   slia:DataValid  Yes=1 No=0  
195
end epics
196
197
# The rule is that everything between single
198
# quotes is EPICS data (string type) which, 
199
# if found in the datastream, gets assigned 
200
# the numerical value after the equal sign.  
201
# So, if the string "RF On" is found, you get
202
# 14 in the tree.  The strings with white space
203
# must contain single quotes.  The other strings
204
# could contain single quotes, but it is not
205
# necessary (e.g. slia:DataValid 'Yes'=1).
206
207
# Examples of *GOOD* syntax:
208
209
begin epics
210
   hac_bcm_average
211
   IPM1H04A.XPOS
212
   FB_A:use_RF 'RF On'=14 'RF Off'=52
213
   slia:DataValid  Yes=1 No=0 
214
   hla:DataValid   Fred=2 'No'=22 Yes==452
215
end epics 
216
217
# Examples of *BAD* syntax:
218
219
begin epics
220
   Joe Momma    # erroneous space
221
   FB_A:use_RF 'RF On=14  # missing a quote
222
   slia:DataValid  Yes = 1 # erroneous space 
223
   hla:DataValid   Fred= 2 # erroneous space 
224
end epics 
225
226
227
228
229
# --------------------------------------------------
230
# Scalers to appear in the regular event tree ("T") and
231
# new scaler trees, one for each bank.
232
# Banks are "right", "left" (and perhaps 3rd arm).
233
# Access to data:
234
# T->Draw("right_bcm_u1"), right->Draw("bcm_u1")  for R-arm
235
# T->Draw("left_bcm_u1"), left->Draw("bcm_u1")  for L-arm
236
# "default" and "default_helicity" cause a list
237
# of normalization scalers to appear.  Examples:
238
# T->Draw("right_trigger_1")  from default list
239
# T->Draw("right_P_trigger_1") helicity plus ("P")
240
# T->Draw("right_M_trigger_1") helicity minus ("M")
241
# also right->Draw("trigger_1"), etc. appear.
242
# Implictly the values are RATES (Hz) unless one
243
# specifies the "counts" flag.
244
# "myclk 8 7"  is a rate from slot 8 chan 7 and
245
# appears as T->Draw("myclk").
246
# "myclkc 8 7 counts" are raw counts, slot 8, chan 7.
247
248
begin scalers right
249
   default      # this expands to "trigger_1", "bcm_u1", etc...
250
   default_helicity   # expands to "P_trigger_1", "M_trigger_1" ...
251
   mypulser 7 3
252
   myclk 8 7    
253
   myclkc 8 7 counts
254
end scalers
255
256
begin scalers left
257
   default
258
   default_helicity
259
   mypulser 4 3
260
   myclk 4 7
261
   myclkc 4 7 counts
262
end scalers
263
</pre>
264
265
266
h2. EXPECTED   RESULTS
267
268
Below is a table showing examples of lines in the output definition file (output.def) and the corresponding expected output.
269
270
|\3=.Behavior of Output |
271
|_.output.def   line   |_.Example How to Access |_.Comments   |
272
| @VARIABLE  L.s1.lt[4]@ |  @T->Draw("L.s1.lt[4]")@ | |
273
| @VARIABLE  L.s1.rt@ 	 |  Tree has @L.s1.lt[i], i = 0,1,...Ndata.L.s1.lt@ | Array |
274
| @BLOCK   R.*@          |  @T->Draw("R.s1.lt[0]")@, etc. |  All variables in Right (R) HRS |
275
| @FORMULA Lt4a 5*L.s1.lt[4]@ | @T->Draw("Lt4a")@ | Scaler Formula |
276
| @FORMULA   Lt4b   5*L.s1.lt@ | Tree has @Lt4b[i], i = 0,1,...Ndata.Lt4b@ | Vector Formula |
277
| @CUT   C1   L.s1.lt[4]>1350@ | @T->Draw("C1")@  | Scaler Cut |
278
| @CUT   C2   L.s1.lt>1350@    | Tree has @C2[i], i = 0,1,...Ndata.C2@ |  Vector Cut |
279
| @TH1F   rs   'Scint' R.s1.lt 100 0 2000@ | @rs->Draw()@ |  Histogram (all elements of @R.s1.lt[]@ in 1 histo) |
280
| @TH1F   rs4   'Scint' R.s1.lt[4] 100 0 2000 R.s1.lt[4]>500@ | @rs4->Draw()@ |	  Cut @R.s1.lt[4]>500@ is optional |
281
| @TH1F   rv   'Scint' R.s1.lt 200 0 2000 R.s1.lt>500@ | @rv0->Draw(), rv1->Draw, ... rv5->Draw()@ | Vector Histogram (size 6) |