25 character*1024 in_file
27 character*1024 config_file
28 character*16 num_events_arg
29 logical config_file_set
30 character(kind=c_char, len=1024)
31 & in_file_cstr, config_file_cstr, etc_dir
35 integer(c_int) reader_status
36 integer(c_int) nrows, nrows_c
42 integer(c_int) pid(n_max)
43 real(c_float) px(n_max), py(n_max), pz(n_max)
44 real(c_float) vz(n_max)
45 integer(c_int) stat(n_max)
46 integer(c_int) sector(n_max)
47 real(c_float) torus(n_max)
48 integer(c_int) runnum(n_max)
51 logical(c_bool) accept(n_max)
52 real(c_double) qx, qy, qz, qe
53 real(c_double) q2, x, y, w, nu
54 real(c_double) beampz, targetm
55 integer(c_int) key_vz_filter
56 integer(c_int) key_inc_kin
59 integer(c_int) algo_eb_filter, algo_vz_filter,
60 & algo_inc_kin, algo_mom_cor
74 config_file_set = .false.
78 call iguana_getconfiginstallationprefix(etc_dir)
79 print *,
'ERROR: please at least specify a HIPO_FILE'
81 print *,
'ARGS: ',
'HIPO_FILE',
' ',
'NUM_EVENTS'
83 print *,
' HIPO_FILE: ',
'the input HIPO file'
85 print *,
' NUM_EVENTS (optional): ',
86 &
'the number of events (0 for all)'
87 print *,
' default: ', num_events
89 print *,
' CONFIG_FILE (optional): ',
90 &
'algorithm configuration file'
91 print *,
' default: ',
'use the internal defaults'
92 print *,
' example config file: ',
93 & trim(etc_dir)//
'/examples/my_z_vertex_cuts.yaml'
96 call getarg(1, in_file)
97 in_file_cstr = trim(in_file)//c_null_char
100 call getarg(2, num_events_arg)
101 read(num_events_arg,*) num_events
104 call getarg(3, config_file)
105 config_file_cstr = trim(config_file)//c_null_char
106 config_file_set = .true.
110 call hipo_file_open(in_file_cstr)
131 call iguana_algo_create(
133 &
'clas12::EventBuilderFilter'//c_null_char)
134 call iguana_algo_create(
136 &
'clas12::ZVertexFilter'//c_null_char)
137 call iguana_algo_create(
139 &
'physics::InclusiveKinematics'//c_null_char)
140 call iguana_algo_create(
142 &
'clas12::MomentumCorrection'//c_null_char)
149 call iguana_algo_set_log_level(
150 & algo_eb_filter,
'debug'//c_null_char)
151 call iguana_algo_set_log_level(
152 & algo_vz_filter,
'debug'//c_null_char)
153 call iguana_algo_set_log_level(
154 & algo_inc_kin,
'debug'//c_null_char)
155 call iguana_algo_set_log_level(
156 & algo_mom_cor,
'debug'//c_null_char)
159 if(config_file_set)
then
160 call iguana_set_config_file(config_file_cstr)
170 10
if(reader_status.eq.0 .and.
171 & (num_events.eq.0 .or. counter.lt.num_events))
then
174 print *,
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> event ', counter
177 call hipo_file_next(reader_status)
178 call hipo_read_bank(
'REC::Particle', nrows)
179 call hipo_read_bank(
'RUN::config', nrows_c)
180 call hipo_read_int(
'REC::Particle',
'pid', nr, pid, n_max)
181 call hipo_read_float(
'REC::Particle',
'px', nr, px, n_max)
182 call hipo_read_float(
'REC::Particle',
'py', nr, py, n_max)
183 call hipo_read_float(
'REC::Particle',
'pz', nr, pz, n_max)
184 call hipo_read_float(
'REC::Particle',
'vz', nr, vz, n_max)
185 call hipo_read_int(
'REC::Particle',
'status', nr, stat, n_max)
186 call hipo_read_float(
'RUN::config',
'torus', nr, torus, n_max)
187 call hipo_read_int(
'RUN::config',
'run', nr, runnum, n_max)
192 call iguana_clas12_zvertexfilter_prepareevent(
193 & algo_vz_filter, runnum(1), key_vz_filter)
196 call iguana_physics_inclusivekinematics_prepareevent(
197 & algo_inc_kin, runnum(1), -1, key_inc_kin)
205 print *,
'===> filter particles with iguana:'
208 call iguana_clas12_eventbuilderfilter_filter(
209 & algo_eb_filter, pid(i), accept(i))
210 call iguana_clas12_zvertexfilter_filter(
211 & algo_vz_filter, vz(i), pid(i), stat(i),
212 & key_vz_filter, accept(i))
213 print *,
' i = ', i,
' pid = ', pid(i),
' vz = ', vz(i),
214 &
' status = ', stat(i),
' => accept = ', accept(i)
226 if(nrows_c.lt.1)
then
227 print *,
'===> no RUN::config bank; cannot ',
228 &
'apply momentum corrections'
230 print *,
'===> momentum corrections:'
234 print *,
' before: p = (', px(i), py(i), pz(i),
')'
235 call iguana_clas12_momentumcorrection_transform(
237 & px(i), py(i), pz(i),
238 & sector(i), pid(i), torus(1),
239 & px(i), py(i), pz(i))
240 print *,
' after: p = (', px(i), py(i), pz(i),
')'
248 print *,
'===> finding electron...'
251 print *,
' i = ', i,
' status = ', stat(i)
252 if(pid(i).eq.11 .and. stat(i).lt.0)
then
253 p = sqrt(px(i)**2 + py(i)**2 + pz(i)**2)
263 print *,
'===> found DIS electron:'
264 print *,
' i = ', i_ele
265 print *,
' p = ', p_ele
267 print *,
'===> no DIS electron'
272 call iguana_physics_inclusivekinematics_computefromlepton(
274 & px(i_ele), py(i_ele), pz(i_ele),
279 print *,
'===> inclusive kinematics:'
280 print *,
' q = (', qx, qy, qz, qe,
')'
281 print *,
' Q2 = ', q2
285 print *,
' nu = ', nu
288 counter = counter + 1
program iguana_ex_fortran_01_action_functions
Fortran example program.