Skip to content

Commit 735d4fc

Browse files
authored
fix: exclude BMTBST, CENTRAL, and CVT from RG-L (#322)
1 parent 4d87b2a commit 735d4fc

1 file changed

Lines changed: 118 additions & 80 deletions

File tree

src/main/java/org/jlab/clas/timeline/run_analysis.groovy

Lines changed: 118 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ import org.jlab.clas.timeline.util.RunDependentCut
33

44
import org.jlab.groot.data.TDirectory
55

6+
// define timeline engines
67
def engines = [
7-
// out_ALERT: [new alert_atof_tdc(),
8+
// out_ALERT: [
9+
// new alert_atof_tdc(),
810
// ],
9-
out_BAND: [new band_adccor(),
11+
out_BAND: [
12+
new band_adccor(),
1013
new band_lasertime(),
1114
new band_meantimeadc(),
12-
new band_meantimetdc()],
13-
out_monitor: [new bmt_Occupancy(),
15+
new band_meantimetdc(),
16+
],
17+
out_monitor: [
18+
new bmt_Occupancy(),
1419
new bmt_OnTrkLayers(),
1520
new bst_Occupancy(),
1621
new bst_OnTrkLayers(),
@@ -69,29 +74,40 @@ def engines = [
6974
new rftime_prot_FD(),
7075
new rftime_prot_CD(),
7176
new epics_xy(),
72-
new epics_hall_weather()],
73-
out_CND: [new cnd_MIPS_dE_dz(),
77+
new epics_hall_weather(),
78+
],
79+
out_CND: [
80+
new cnd_MIPS_dE_dz(),
7481
new cnd_time_neg_vtP(),
75-
new cnd_zdiff()],
76-
out_CTOF: [new ctof_edep(),
82+
new cnd_zdiff(),
83+
],
84+
out_CTOF: [
85+
new ctof_edep(),
7786
new ctof_time(),
7887
new ctof_tdcadc(),
7988
],
80-
out_FT: [new ftc_pi0_mass(),
89+
out_FT: [
90+
new ftc_pi0_mass(),
8191
new ftc_time_charged(),
8292
new ftc_time_neutral(),
8393
new fth_MIPS_energy(),
8494
new fth_MIPS_time(),
8595
new fth_MIPS_energy_board(),
86-
new fth_MIPS_time_board()],
87-
out_HTCC: [new htcc_nphe_ring_sector(),
96+
new fth_MIPS_time_board()
97+
],
98+
out_HTCC: [
99+
new htcc_nphe_ring_sector(),
88100
new htcc_nphe_sector(),
89101
new htcc_vtimediff(),
90102
new htcc_vtimediff_sector(),
91103
new htcc_vtimediff_sector_ring(),
92-
new htcc_npheAll()],
93-
out_LTCC: [new ltcc_had_nphe_sector()],
94-
out_TOF: [new ftof_edep_p1a_smallangles(),
104+
new htcc_npheAll(),
105+
],
106+
out_LTCC: [
107+
new ltcc_had_nphe_sector(),
108+
],
109+
out_TOF: [
110+
new ftof_edep_p1a_smallangles(),
95111
new ftof_edep_p1a_midangles(),
96112
new ftof_edep_p1a_largeangles(),
97113
new ftof_edep_p1b_smallangles(),
@@ -112,90 +128,112 @@ def engines = [
112128
new dc_t0_sec_sl(),
113129
new dc_t0_even_sec_sl(),
114130
new dc_t0_odd_sec_sl(),
115-
new dc_tmax_sec_sl()],
116-
out_RICH: [new rich_dt_m(),
117-
new rich_trk_m(),
118-
new rich_etac_dir_m(),
119-
new rich_etac_plan_m(),
120-
new rich_etac_sphe_m(),
121-
new rich_npho_dir_m(),
122-
new rich_npho_plan_m(),
123-
new rich_npho_sphe_m(),
124-
new rich_npim_m(),
125-
new rich_npip_m(),
126-
new rich_nkm_m(),
127-
new rich_nkp_m(),
128-
new rich_npro_m(),
129-
new rich_npbar_m()],
130-
out_HELICITY: [new helicity()],
131-
out_TRIGGER: [new trigger()],
131+
new dc_tmax_sec_sl(),
132+
],
133+
out_RICH: [
134+
new rich_dt_m(),
135+
new rich_trk_m(),
136+
new rich_etac_dir_m(),
137+
new rich_etac_plan_m(),
138+
new rich_etac_sphe_m(),
139+
new rich_npho_dir_m(),
140+
new rich_npho_plan_m(),
141+
new rich_npho_sphe_m(),
142+
new rich_npim_m(),
143+
new rich_npip_m(),
144+
new rich_nkm_m(),
145+
new rich_nkp_m(),
146+
new rich_npro_m(),
147+
new rich_npbar_m(),
148+
],
149+
out_HELICITY: [
150+
new helicity(),
151+
],
152+
out_TRIGGER: [
153+
new trigger(),
154+
],
132155
]
133156

134157

158+
// parse arguments
135159
if(args.any{it=="--timelines"}) {
136160
engines.values().flatten().each{
137161
println(it.getClass().getSimpleName())
138162
}
139163
System.exit(0)
140164
}
165+
if(args.length != 2) {
166+
System.err.println "ARGUMENTS: [timeline] [input_dir]"
167+
System.err.println "use --timelines for a list of available timelines"
168+
System.exit(101)
169+
}
170+
def (timelineArg, inputDirArg) = args
141171

172+
// check the timeline argument
142173
def eng = engines.collectMany{key,engs->engs.collect{[key,it]}}
143-
.find{name,eng->eng.getClass().getSimpleName()==args[0]}
144-
145-
if(eng) {
146-
def (name,engine) = eng
147-
def input = new File(args[1])
148-
def allow_timeline = true
149-
println([name,args[0],engine.getClass().getSimpleName(),input])
150-
def fnames = []
151-
input.traverse {
152-
if(it.name.endsWith('.hipo') && it.name.contains(name))
153-
fnames.add(it.absolutePath)
154-
}
155-
156-
fnames.sort().each{arg->
157-
try{
158-
println("debug: "+engine.getClass().getSimpleName()+" started $arg")
174+
.find{name,eng->eng.getClass().getSimpleName()==timelineArg}
175+
if(eng == null) {
176+
System.err.println("error: timeline '$timelineArg' is not defined")
177+
System.exit(100)
178+
}
159179

160-
TDirectory dir = new TDirectory()
161-
dir.readFile(arg)
180+
// get list of input HIPO histogram files
181+
def (name,engine) = eng
182+
def inputDir = new File(inputDirArg)
183+
println([name,timelineArg,engine.getClass().getSimpleName(),inputDir])
184+
def fnames = []
185+
inputDir.traverse {
186+
if(it.name.endsWith('.hipo') && it.name.contains(name))
187+
fnames.add(it.absolutePath)
188+
}
162189

163-
// get run number from directory name
164-
def fname = arg.split('/')[-2]
165-
def m = fname =~ /\d+/
166-
def run = m[0].toInteger()
190+
// loop over input HIPO histogram files
191+
def allow_timeline = false
192+
fnames.sort().each{ fname ->
193+
try{
194+
println("debug: "+engine.getClass().getSimpleName()+" started $fname")
167195

168-
// allow / disallow certain timelines, based on run number
169-
if(RunDependentCut.runIsBefore(run, 21317, false)) { // before RG-L
170-
if(args[0] == "alert_atof_tdc") { allow_timeline = false }
171-
}
196+
// get run number from directory name
197+
def dname = fname.split('/')[-2]
198+
def m = dname =~ /\d+/
199+
def run = m[0].toInteger()
172200

173-
// run the analysis for this run
174-
if(allow_timeline) {
175-
engine.processRun(dir, run)
176-
println("debug: "+engine.getClass().getSimpleName()+" finished $arg")
177-
}
178-
else {
179-
println("debug: "+engine.getClass().getSimpleName()+" is not allowed for run $run")
180-
}
201+
// exclude certain run ranges from certain timelines
202+
def allow_run = true
203+
if(RunDependentCut.runIsBefore(run, 21317, false)) { // before RG-L
204+
if(timelineArg ==~ /^alert.*/) { allow_run = false }
205+
}
206+
if(RunDependentCut.runIsAfter(run, 21317, true)) { // RG-L FIXME: needs upper bound when RG-L completes
207+
if( timelineArg ==~ /^bmt.*/ ||
208+
timelineArg ==~ /^bst.*/ ||
209+
timelineArg ==~ /^cen.*/ ||
210+
timelineArg ==~ /^cvt.*/ ) { allow_run = false }
211+
}
181212

182-
} catch(Exception ex) {
183-
System.err.println("error: "+engine.getClass().getSimpleName()+" didn't process $arg, due to exception:")
184-
ex.printStackTrace()
185-
System.exit(100)
213+
// run the analysis for this run
214+
if(allow_run) {
215+
allow_timeline = true // allow the timeline if at least one run is allowed
216+
TDirectory dir = new TDirectory()
217+
dir.readFile(fname)
218+
engine.processRun(dir, run)
219+
println("debug: "+engine.getClass().getSimpleName()+" finished $fname")
220+
}
221+
else {
222+
println("debug: "+engine.getClass().getSimpleName()+" excludes run $run")
186223
}
187-
}
188224

189-
// write the timeline HIPO file
190-
if(allow_timeline) {
191-
engine.write()
192-
println("debug: "+engine.getClass().getSimpleName()+" ended")
193-
}
194-
else {
195-
println("debug: "+engine.getClass().getSimpleName()+" was not produced, since not allowed for these data")
225+
} catch(Exception ex) {
226+
System.err.println("error: "+engine.getClass().getSimpleName()+" didn't process $fname, due to exception:")
227+
ex.printStackTrace()
228+
System.exit(100)
196229
}
230+
}
197231

198-
} else {
199-
System.err.println("error: "+args[0]+" not found")
200-
System.exit(100)
232+
// write the timeline HIPO file
233+
if(allow_timeline) {
234+
engine.write()
235+
println("debug: "+engine.getClass().getSimpleName()+" ended")
236+
}
237+
else {
238+
println("debug: "+engine.getClass().getSimpleName()+" was not produced, since all runs were excluded")
201239
}

0 commit comments

Comments
 (0)