Skip to content

Commit 78c9f2a

Browse files
Sangbaekc-dilks
andauthored
feat: integrate sectors and layers for the ATOF Time (#442)
Co-authored-by: Christopher Dilks <c-dilks@users.noreply.github.com>
1 parent c2c6975 commit 78c9f2a

3 files changed

Lines changed: 39 additions & 71 deletions

File tree

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

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,23 @@ class alert_atof_time {
99

1010
def data = new ConcurrentHashMap()
1111
def has_data = new AtomicBoolean(false)
12-
int sector;
13-
int min_index;
14-
int max_index;
15-
16-
alert_atof_time(int atof_sector){ // atof_sector runs from 0 to 14.
17-
this.sector = atof_sector;
18-
this.min_index = 44*(atof_sector);
19-
this.max_index = 44*(atof_sector+1);
20-
}
2112

22-
def getName() {
23-
return "${this.class.simpleName}_${String.format('%02d', sector)}"
24-
}
2513

2614
def processRun(dir, run) {
2715

2816
data[run] = [run:run]
2917
def trigger = dir.getObject('/TRIGGER/bits')
3018
def reference_trigger_bit = 0
3119
// data[run].put('bits', trigger)
32-
(min_index..<max_index).collect{index->
33-
int atof_sector = index / (11 * 4);
34-
assert sector == atof_sector // sanity-check. this should be the same.
35-
int layer = (index % (11 * 4)) / 11;
36-
int component = index % 11;
37-
def file_index = String.format('sector%02d_layer%d_component%02d', sector, layer, component)
38-
def h1 = dir.getObject(String.format('/ALERT/ATOF_Time_%s', file_index))
20+
(0..<11).collect{component->
21+
def h1 = dir.getObject(String.format('/ALERT/ATOF_Time_component%02d', component))
3922
if(h1!=null) {
4023
if (h1.getBinContent(h1.getMaximumBin()) > 30 && h1.getEntries()>300){
41-
data[run].put(String.format('atof_time_%s', file_index), h1)
24+
data[run].put(String.format('atof_time_%02d', component), h1)
4225
def f1 = ALERTFitter.atof_time_fitter(h1,component)
43-
data[run].put(String.format('fit_atof_time_%s', file_index), f1)
44-
data[run].put(String.format('peak_location_atof_time_%s', file_index), f1.getParameter(1).abs())
45-
data[run].put(String.format('sigma_atof_time_%s', file_index), f1.getParameter(2).abs())
46-
data[run].put(String.format('integral_normalized_to_trigger_atof_time_%s', file_index), Math.sqrt(2*3.141597f) * f1.getParameter(0).abs() * f1.getParameter(2).abs()/trigger.getBinContent(reference_trigger_bit) )
26+
data[run].put(String.format('fit_atof_time_%02d', component), f1)
27+
data[run].put(String.format('peak_location_atof_time_%02d', component), f1.getParameter(1).abs())
28+
data[run].put(String.format('sigma_atof_time_%02d', component), f1.getParameter(2).abs())
4729
has_data.set(true)
4830
}
4931
}
@@ -59,36 +41,31 @@ int max_index;
5941
return
6042
}
6143

62-
['peak_location', 'sigma', 'integral_normalized_to_trigger'].each{variable->
63-
(0..<4).collect{layer->
64-
def names = []
65-
TDirectory out = new TDirectory()
66-
out.mkdir('/timelines')
67-
(0..<11).collect{component->
68-
def file_index = ''
69-
file_index = String.format('sector%02d_layer%d_component%02d', sector, layer, component)
70-
names << String.format('atof_time_%s', file_index)
71-
}
72-
names.each{ name ->
73-
def gr = new GraphErrors(name)
74-
gr.setTitle( String.format("ATOF Time %s sector %02d layer %d", variable.replace('_', ' '), sector, layer))
75-
gr.setTitleY( String.format("ATOF Time %s sector %02d layer %d (ns)", variable.replace('_', ' '), sector, layer))
76-
gr.setTitleX("run number")
77-
data.sort{it.key}.each{run,it->
78-
out.mkdir('/'+it.run)
79-
out.cd('/'+it.run)
80-
if (it.containsKey(name)){
81-
out.addDataSet(it[name])
82-
out.addDataSet(it['fit_'+name])
83-
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
84-
}
85-
else if (variable=="peak_location") println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
44+
['peak_location', 'sigma'].each{variable->
45+
TDirectory out = new TDirectory()
46+
out.mkdir('/timelines')
47+
(0..<11).collect{component->
48+
def name = String.format('atof_time_%02d', component)
49+
50+
def gr = new GraphErrors(name)
51+
52+
gr.setTitle( String.format("ATOF Time %s ", variable.replace('_', ' ')))
53+
gr.setTitleY( String.format("ATOF Time %s (ns)", variable.replace('_', ' ')))
54+
gr.setTitleX("run number")
55+
data.sort{it.key}.each{run,it->
56+
out.mkdir('/'+it.run)
57+
out.cd('/'+it.run)
58+
if (it.containsKey(name)){
59+
out.addDataSet(it[name])
60+
out.addDataSet(it['fit_'+name])
61+
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
8662
}
87-
out.cd('/timelines')
88-
out.addDataSet(gr)
63+
else if (variable=="peak_location") println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
8964
}
90-
out.writeFile(String.format('alert_atof_time_%s_sector%02d_layer%d.hipo', variable, sector, layer))
65+
out.cd('/timelines')
66+
out.addDataSet(gr)
9167
}
68+
out.writeFile(String.format('alert_atof_time_%s.hipo', variable))
9269
}
9370
}
9471
}

src/main/java/org/jlab/clas/timeline/histograms/ALERT.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,14 @@ public ALERT(int reqrunNum, String reqOutputDir, float reqEb, boolean reqTimeBas
5757
}
5858
rf_large_integer = 1000;
5959

60-
ATOF_Time = new H1F[660];// ATOF Time Histograms
60+
ATOF_Time = new H1F[11];// ATOF Time Histograms
6161

62-
for (int index = 0; index < 660; index++) {
63-
int sector = 0;
64-
int layer = 0;
65-
int component = 0;
62+
for (int component = 0; component < 11; component++) {
6663

67-
sector = index / (11 * 4);
68-
layer = (index % (11 * 4)) / 11;
69-
component = index % 11;
70-
71-
ATOF_Time[index] = new H1F(String.format("ATOF_Time_sector%02d_layer%d_component%02d", sector, layer, component), String.format("ATOF Time sector%02d layer%d component%02d", sector, layer, component), 300, 85, 100);
72-
ATOF_Time[index].setTitleX("ATOF Time (ns)");
73-
ATOF_Time[index].setTitleY("Counts");
74-
ATOF_Time[index].setFillColor(4);
64+
ATOF_Time[component] = new H1F(String.format("ATOF_Time_component%02d", component), String.format("ATOF Time component%02d", component), 240, 83, 95);
65+
ATOF_Time[component].setTitleX("ATOF Time (ns)");
66+
ATOF_Time[component].setTitleY("Counts");
67+
ATOF_Time[component].setFillColor(4);
7568
}
7669

7770
//AHDC ADC Histograms
@@ -154,13 +147,11 @@ public void fillAHDC_hits(DataBank ahdc_hits) {
154147
public void fillATOF_hits(DataBank atof_hits) {
155148
int rows = atof_hits.rows();
156149
for (int loop = 0; loop < rows; loop++) {
157-
int sector = atof_hits.getInt("sector", loop);
158-
int layer = atof_hits.getInt("layer", loop);
150+
159151
int component = atof_hits.getInt("component", loop);
160152
float time = atof_hits.getFloat("time", loop);
161-
int index = sector * 44 + layer * 11 + component;
162153

163-
ATOF_Time[index].fill(time);
154+
ATOF_Time[component].fill(time);
164155

165156
}
166157
}
@@ -231,8 +222,8 @@ public void write() {
231222
TDirectory dirout = new TDirectory();
232223
dirout.mkdir("/ALERT/");
233224
dirout.cd("/ALERT/");
234-
for (int index = 0; index < 660; index++) {
235-
dirout.addDataSet(ATOF_Time[index]);
225+
for (int component = 0; component < 11; component++) {
226+
dirout.addDataSet(ATOF_Time[component]);
236227
}
237228
for (int index = 0; index < 576; index++) {
238229
dirout.addDataSet(ADC[index], AHDC_TIME[index]);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def engines = [
99
*(1..8).collect {ahdc_layer_number -> new alert_ahdc_adc (ahdc_layer_number) },
1010
new alert_ahdc_residual(),
1111
*(1..8).collect {ahdc_layer_number -> new alert_ahdc_time (ahdc_layer_number) },
12-
*(0..14).collect {atof_sector -> new alert_atof_time(atof_sector)},
12+
new alert_atof_time(),
1313
],
1414
out_BAND: [
1515
new band_adccor(),

0 commit comments

Comments
 (0)