Skip to content

Commit 9620312

Browse files
committed
fix: don't attempt to analyze empty ALERT timelines
- if before RG-L, don't even run the timeline engine - if during RG-L, run the engine, but if data are empty, don't attempt to produce the final timeline and instead complain to `stderr` so the chef sees the issue Fixes #307
1 parent b6e7be9 commit 9620312

2 files changed

Lines changed: 41 additions & 11 deletions

File tree

src/main/java/org/jlab/clas/timeline/analysis/alert/alert_atof_tdc.groovy

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.jlab.clas.timeline.analysis
22
import java.util.concurrent.ConcurrentHashMap
3+
import java.util.concurrent.atomic.AtomicBoolean
34
import org.jlab.groot.data.TDirectory
45
import org.jlab.groot.data.GraphErrors
56
import org.jlab.clas.timeline.fitter.ALERTFitter
67

78
class alert_atof_tdc {
89

910
def data = new ConcurrentHashMap()
11+
def has_data = new AtomicBoolean(false)
1012

1113
def processRun(dir, run) {
1214

@@ -22,19 +24,27 @@ def data = new ConcurrentHashMap()
2224
if (component <= 10) file_index = String.format('sector%d_layer%d_component%d_order0', sector, layer, component)
2325
else file_index = String.format('sector%d_layer%d_component%d_order1', sector, layer, component-1)
2426
def h1 = dir.getObject(String.format('/ALERT/TDC_%s', file_index))
25-
data[run].put(String.format('atof_tdc_%s', file_index), h1)
26-
def f1 = ALERTFitter.tdcfitter(h1)
27-
data[run].put(String.format('fit_atof_tdc_%s', file_index), f1)
28-
data[run].put(String.format('peak_location_atof_tdc_%s', file_index), f1.getParameter(1))
29-
data[run].put(String.format('sigma_atof_tdc_%s', file_index), f1.getParameter(2))
30-
data[run].put(String.format('integral_normalized_to_trigger_atof_tdc_%s', file_index), Math.sqrt(2*3.141597f) * f1.getParameter(0) * f1.getParameter(2)/trigger.getBinContent(reference_trigger_bit) )
27+
if(h1!=null && h1.getEntries()>10) {
28+
data[run].put(String.format('atof_tdc_%s', file_index), h1)
29+
def f1 = ALERTFitter.tdcfitter(h1)
30+
data[run].put(String.format('fit_atof_tdc_%s', file_index), f1)
31+
data[run].put(String.format('peak_location_atof_tdc_%s', file_index), f1.getParameter(1))
32+
data[run].put(String.format('sigma_atof_tdc_%s', file_index), f1.getParameter(2))
33+
data[run].put(String.format('integral_normalized_to_trigger_atof_tdc_%s', file_index), Math.sqrt(2*3.141597f) * f1.getParameter(0) * f1.getParameter(2)/trigger.getBinContent(reference_trigger_bit) )
34+
has_data.set(true)
35+
}
3136
}
3237
}
3338

3439

3540

3641
def write() {
3742

43+
if(!has_data.get()) {
44+
System.err.println "ERROR: no data for this ALERT timeline, not producing"
45+
return
46+
}
47+
3848
['peak_location', 'sigma', 'integral_normalized_to_trigger'].each{variable->
3949
(0..<15).collect{sector->
4050
(0..<4).collect{layer->
@@ -67,4 +77,4 @@ def data = new ConcurrentHashMap()
6777
}
6878
}
6979
}
70-
}
80+
}

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def eng = engines.collectMany{key,engs->engs.collect{[key,it]}}
144144
if(eng) {
145145
def (name,engine) = eng
146146
def input = new File(args[1])
147+
def allow_timeline = true
147148
println([name,args[0],engine.getClass().getSimpleName(),input])
148149
def fnames = []
149150
input.traverse {
@@ -163,17 +164,36 @@ if(eng) {
163164
def m = fname =~ /\d+/
164165
def run = m[0].toInteger()
165166

166-
engine.processRun(dir, run)
167+
// allow / disallow certain timelines, based on run number
168+
if(run < 21317) { // before RG-L
169+
if(args[0] == "alert_atof_tdc") { allow_timeline = false }
170+
}
171+
172+
// run the analysis for this run
173+
if(allow_timeline) {
174+
engine.processRun(dir, run)
175+
println("debug: "+engine.getClass().getSimpleName()+" finished $arg")
176+
}
177+
else {
178+
println("debug: "+engine.getClass().getSimpleName()+" is not allowed for run $run")
179+
}
167180

168-
println("debug: "+engine.getClass().getSimpleName()+" finished $arg")
169181
} catch(Exception ex) {
170182
System.err.println("error: "+engine.getClass().getSimpleName()+" didn't process $arg, due to exception:")
171183
ex.printStackTrace()
172184
System.exit(100)
173185
}
174186
}
175-
engine.write()
176-
println("debug: "+engine.getClass().getSimpleName()+" ended")
187+
188+
// write the timeline HIPO file
189+
if(allow_timeline) {
190+
engine.write()
191+
println("debug: "+engine.getClass().getSimpleName()+" ended")
192+
}
193+
else {
194+
println("debug: "+engine.getClass().getSimpleName()+" was not produced, since not allowed for these data")
195+
}
196+
177197
} else {
178198
System.err.println("error: "+args[0]+" not found")
179199
System.exit(100)

0 commit comments

Comments
 (0)