Skip to content

Commit f1a56e1

Browse files
authored
feat: update include ATOF bar z (#460)
1 parent baff078 commit f1a56e1

9 files changed

Lines changed: 428 additions & 10 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ def has_data = new AtomicBoolean(false)
2020
(0..<11).collect{component->
2121
def h1 = dir.getObject(String.format('/ALERT/ATOF_Time_component%02d', component))
2222
if(h1!=null) {
23-
if (h1.getBinContent(h1.getMaximumBin()) > 30 && h1.getEntries()>300){
23+
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries()>10){
2424
data[run].put(String.format('atof_time_%02d', component), h1)
25-
def f1 = ALERTFitter.atof_time_fitter(h1,component)
25+
double fit_min = h1.getXaxis().getBinCenter(1)
26+
double fit_max = h1.getXaxis().getBinCenter(h1.getXaxis().getNBins())
27+
def f1 = ALERTFitter.atof_time_fitter(h1, component, fit_min, fit_max)
2628
data[run].put(String.format('fit_atof_time_%02d', component), f1)
2729
data[run].put(String.format('peak_location_atof_time_%02d', component), f1.getParameter(1))
2830
data[run].put(String.format('sigma_atof_time_%02d', component), f1.getParameter(2).abs())
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package org.jlab.clas.timeline.analysis
2+
import java.util.concurrent.ConcurrentHashMap
3+
import java.util.concurrent.atomic.AtomicBoolean
4+
import org.jlab.groot.data.TDirectory
5+
import org.jlab.groot.data.GraphErrors
6+
import org.jlab.clas.timeline.fitter.ALERTFitter
7+
8+
class alert_atof_time_sl {
9+
10+
def data = new ConcurrentHashMap()
11+
def has_data = new AtomicBoolean(false)
12+
int sector
13+
int layer
14+
15+
alert_atof_time_sl(int sector, int layer) {
16+
this.sector = sector
17+
this.layer = layer
18+
}
19+
20+
def getName() {
21+
return String.format("%s_sector%02d_layer%d", this.class.simpleName, sector, layer)
22+
}
23+
24+
def processRun(dir, run) {
25+
data[run] = [run:run]
26+
(0..<11).each { component ->
27+
def h1 = dir.getObject(String.format('/ALERT/ATOF_Time_sector%02d_layer%02d_component%02d', sector, layer, component))
28+
if (h1 != null) {
29+
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries() > 10) {
30+
def name = String.format('atof_time_sl_s%02d_l%d_c%02d', sector, layer, component)
31+
data[run].put(name, h1)
32+
double fit_min = h1.getXaxis().getBinCenter(1)
33+
double fit_max = h1.getXaxis().getBinCenter(h1.getXaxis().getNBins())
34+
def f1 = ALERTFitter.atof_time_fitter(h1, component, fit_min, fit_max)
35+
data[run].put('fit_' + name, f1)
36+
data[run].put('peak_location_' + name, f1.getParameter(1))
37+
data[run].put('sigma_' + name, f1.getParameter(2).abs())
38+
has_data.set(true)
39+
}
40+
}
41+
}
42+
}
43+
44+
def write() {
45+
if (!has_data.get()) {
46+
System.err.println "WARNING: no data for this timeline, not producing"
47+
return
48+
}
49+
['peak_location', 'sigma'].each { variable ->
50+
TDirectory out = new TDirectory()
51+
out.mkdir('/timelines')
52+
(0..<11).each { component ->
53+
def name = String.format('atof_time_sl_s%02d_l%d_c%02d', sector, layer, component)
54+
def gr = new GraphErrors(name)
55+
gr.setTitle(String.format("ATOF Time %s Sector %02d Layer %d", variable.replace('_', ' '), sector, layer))
56+
gr.setTitleY(String.format("ATOF Time %s (ns)", variable.replace('_', ' ')))
57+
gr.setTitleX("run number")
58+
data.sort { it.key }.each { run, it ->
59+
out.mkdir('/' + it.run)
60+
out.cd('/' + it.run)
61+
if (it.containsKey(name)) {
62+
out.addDataSet(it[name])
63+
out.addDataSet(it['fit_' + name])
64+
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
65+
} else if (variable == 'peak_location') {
66+
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
67+
}
68+
}
69+
out.cd('/timelines')
70+
out.addDataSet(gr)
71+
}
72+
out.writeFile(String.format('alert_atof_time_sl_%s_sector%02d_layer%d.hipo', variable, sector, layer))
73+
}
74+
}
75+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.jlab.clas.timeline.analysis
2+
import java.util.concurrent.ConcurrentHashMap
3+
import java.util.concurrent.atomic.AtomicBoolean
4+
import org.jlab.groot.data.TDirectory
5+
import org.jlab.groot.data.GraphErrors
6+
7+
class alert_atof_z {
8+
9+
def data = new ConcurrentHashMap()
10+
def has_data = new AtomicBoolean(false)
11+
12+
def processRun(dir, run) {
13+
data[run] = [run:run]
14+
def h1 = dir.getObject('/ALERT/ATOF_z_combined')
15+
if (h1 != null) {
16+
if (h1.getEntries() > 10) {
17+
data[run].put('atof_z_combined', h1)
18+
data[run].put('rms_atof_z_combined', h1.getRMS())
19+
has_data.set(true)
20+
}
21+
}
22+
}
23+
24+
def write() {
25+
if (!has_data.get()) {
26+
System.err.println "WARNING: no data for this timeline, not producing"
27+
return
28+
}
29+
TDirectory out = new TDirectory()
30+
out.mkdir('/timelines')
31+
def name = 'atof_z_combined'
32+
def gr = new GraphErrors(name)
33+
gr.setTitle("ATOF z RMS")
34+
gr.setTitleY("ATOF z RMS (cm)")
35+
gr.setTitleX("run number")
36+
data.sort { it.key }.each { run, it ->
37+
out.mkdir('/' + it.run)
38+
out.cd('/' + it.run)
39+
if (it.containsKey(name)) {
40+
out.addDataSet(it[name])
41+
gr.addPoint(it.run, it['rms_' + name], 0, 0)
42+
} else {
43+
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
44+
}
45+
}
46+
out.cd('/timelines')
47+
out.addDataSet(gr)
48+
out.writeFile('alert_atof_z_rms.hipo')
49+
}
50+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.jlab.clas.timeline.analysis
2+
import java.util.concurrent.ConcurrentHashMap
3+
import java.util.concurrent.atomic.AtomicBoolean
4+
import org.jlab.groot.data.TDirectory
5+
import org.jlab.groot.data.GraphErrors
6+
import org.jlab.clas.timeline.fitter.ALERTFitter
7+
8+
class alert_atof_z_c4 {
9+
10+
def data = new ConcurrentHashMap()
11+
def has_data = new AtomicBoolean(false)
12+
13+
def processRun(dir, run) {
14+
data[run] = [run:run]
15+
def h1 = dir.getObject('/ALERT/ATOF_z_combined_c4')
16+
if (h1 != null) {
17+
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries() > 10) {
18+
data[run].put('atof_z_c4_combined', h1)
19+
def f1 = ALERTFitter.atof_z_fitter(h1)
20+
data[run].put('fit_atof_z_c4_combined', f1)
21+
data[run].put('peak_location_atof_z_c4_combined', f1.getParameter(1))
22+
data[run].put('sigma_atof_z_c4_combined', f1.getParameter(2).abs())
23+
has_data.set(true)
24+
}
25+
}
26+
}
27+
28+
def write() {
29+
if (!has_data.get()) {
30+
System.err.println "WARNING: no data for this timeline, not producing"
31+
return
32+
}
33+
['peak_location', 'sigma'].each { variable ->
34+
TDirectory out = new TDirectory()
35+
out.mkdir('/timelines')
36+
def name = 'atof_z_c4_combined'
37+
def gr = new GraphErrors(name)
38+
gr.setTitle(String.format("ATOF z c4 %s", variable.replace('_', ' ')))
39+
gr.setTitleY(String.format("ATOF z c4 %s (cm)", variable.replace('_', ' ')))
40+
gr.setTitleX("run number")
41+
data.sort { it.key }.each { run, it ->
42+
out.mkdir('/' + it.run)
43+
out.cd('/' + it.run)
44+
if (it.containsKey(name)) {
45+
out.addDataSet(it[name])
46+
out.addDataSet(it['fit_' + name])
47+
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
48+
} else if (variable == 'peak_location') {
49+
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
50+
}
51+
}
52+
out.cd('/timelines')
53+
out.addDataSet(gr)
54+
out.writeFile(String.format('alert_atof_z_c4_%s.hipo', variable))
55+
}
56+
}
57+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.jlab.clas.timeline.analysis
2+
import java.util.concurrent.ConcurrentHashMap
3+
import java.util.concurrent.atomic.AtomicBoolean
4+
import org.jlab.groot.data.TDirectory
5+
import org.jlab.groot.data.GraphErrors
6+
import org.jlab.clas.timeline.fitter.ALERTFitter
7+
8+
class alert_atof_z_c4_sl {
9+
10+
def data = new ConcurrentHashMap()
11+
def has_data = new AtomicBoolean(false)
12+
int sector
13+
int layer
14+
15+
alert_atof_z_c4_sl(int sector, int layer) {
16+
this.sector = sector
17+
this.layer = layer
18+
}
19+
20+
def getName() {
21+
return String.format("%s_sector%02d_layer%d", this.class.simpleName, sector, layer)
22+
}
23+
24+
def processRun(dir, run) {
25+
data[run] = [run:run]
26+
def h1 = dir.getObject(String.format('/ALERT/ATOF_z_c4_sector%02d_layer%02d', sector, layer))
27+
if (h1 != null) {
28+
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries() > 10) {
29+
def name = String.format('atof_z_c4_sl_s%02d_l%d', sector, layer)
30+
data[run].put(name, h1)
31+
def f1 = ALERTFitter.atof_z_fitter(h1)
32+
data[run].put('fit_' + name, f1)
33+
data[run].put('peak_location_' + name, f1.getParameter(1))
34+
data[run].put('sigma_' + name, f1.getParameter(2).abs())
35+
has_data.set(true)
36+
}
37+
}
38+
}
39+
40+
def write() {
41+
if (!has_data.get()) {
42+
System.err.println "WARNING: no data for this timeline, not producing"
43+
return
44+
}
45+
['peak_location', 'sigma'].each { variable ->
46+
TDirectory out = new TDirectory()
47+
out.mkdir('/timelines')
48+
def name = String.format('atof_z_c4_sl_s%02d_l%d', sector, layer)
49+
def gr = new GraphErrors(name)
50+
gr.setTitle(String.format("ATOF z c4 %s Sector %02d Layer %d", variable.replace('_', ' '), sector, layer))
51+
gr.setTitleY(String.format("ATOF z c4 %s (cm)", variable.replace('_', ' ')))
52+
gr.setTitleX("run number")
53+
data.sort { it.key }.each { run, it ->
54+
out.mkdir('/' + it.run)
55+
out.cd('/' + it.run)
56+
if (it.containsKey(name)) {
57+
out.addDataSet(it[name])
58+
out.addDataSet(it['fit_' + name])
59+
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
60+
} else if (variable == 'peak_location') {
61+
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
62+
}
63+
}
64+
out.cd('/timelines')
65+
out.addDataSet(gr)
66+
out.writeFile(String.format('alert_atof_z_c4_sl_%s_sector%02d_layer%d.hipo', variable, sector, layer))
67+
}
68+
}
69+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package org.jlab.clas.timeline.analysis
2+
import java.util.concurrent.ConcurrentHashMap
3+
import java.util.concurrent.atomic.AtomicBoolean
4+
import org.jlab.groot.data.TDirectory
5+
import org.jlab.groot.data.GraphErrors
6+
7+
class alert_atof_z_sl {
8+
9+
def data = new ConcurrentHashMap()
10+
def has_data = new AtomicBoolean(false)
11+
int sector
12+
int layer
13+
14+
alert_atof_z_sl(int sector, int layer) {
15+
this.sector = sector
16+
this.layer = layer
17+
}
18+
19+
def getName() {
20+
return String.format("%s_sector%02d_layer%d", this.class.simpleName, sector, layer)
21+
}
22+
23+
def processRun(dir, run) {
24+
data[run] = [run:run]
25+
def h1 = dir.getObject(String.format('/ALERT/ATOF_z_sector%02d_layer%02d', sector, layer))
26+
if (h1 != null) {
27+
if (h1.getEntries() > 10) {
28+
def name = String.format('atof_z_sl_s%02d_l%d', sector, layer)
29+
data[run].put(name, h1)
30+
data[run].put('rms_' + name, h1.getRMS())
31+
has_data.set(true)
32+
}
33+
}
34+
}
35+
36+
def write() {
37+
if (!has_data.get()) {
38+
System.err.println "WARNING: no data for this timeline, not producing"
39+
return
40+
}
41+
TDirectory out = new TDirectory()
42+
out.mkdir('/timelines')
43+
def name = String.format('atof_z_sl_s%02d_l%d', sector, layer)
44+
def gr = new GraphErrors(name)
45+
gr.setTitle(String.format("ATOF z RMS Sector %02d Layer %d", sector, layer))
46+
gr.setTitleY("ATOF z RMS (cm)")
47+
gr.setTitleX("run number")
48+
data.sort { it.key }.each { run, it ->
49+
out.mkdir('/' + it.run)
50+
out.cd('/' + it.run)
51+
if (it.containsKey(name)) {
52+
out.addDataSet(it[name])
53+
gr.addPoint(it.run, it['rms_' + name], 0, 0)
54+
} else {
55+
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
56+
}
57+
}
58+
out.cd('/timelines')
59+
out.addDataSet(gr)
60+
out.writeFile(String.format('alert_atof_z_sl_rms_sector%02d_layer%d.hipo', sector, layer))
61+
}
62+
}

src/main/java/org/jlab/clas/timeline/fitter/ALERTFitter.groovy

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class ALERTFitter{
3434
}
3535

3636

37-
static F1D atof_time_fitter(H1F h1, int component){
37+
static F1D atof_time_fitter(H1F h1, int component, double fit_min, double fit_max){
3838
if(component>9){//bars
39-
def f1 =new F1D("fit:"+h1.getName(),"[amp]*gaus(x,[mean],[sigma])+[cst]", -5.0, 5.0);
39+
def f1 =new F1D("fit:"+h1.getName(),"[amp]*gaus(x,[mean],[sigma])+[cst]", fit_min, fit_max);
4040
f1.setLineColor(33);
4141
f1.setLineWidth(10);
4242
f1.setOptStat("1111");
@@ -182,6 +182,33 @@ class ALERTFitter{
182182
}
183183
}
184184

185+
static F1D atof_z_fitter(H1F h1){
186+
double maxz = h1.getBinContent(h1.getMaximumBin())
187+
double peak = h1.getAxis().getBinCenter(h1.getMaximumBin())
188+
int bin_low = h1.getAxis().getBin(peak - 10.0)
189+
int bin_high = h1.getAxis().getBin(peak + 10.0)
190+
double sigma = ALERTFitter.getRestrictedRMS(h1, bin_low, bin_high)
191+
if (sigma <= 0 || Double.isNaN(sigma)) sigma = 5.0
192+
193+
def f1 = new F1D("fit:" + h1.getName(), "[amp]*gaus(x,[mean],[sigma])", peak - 2*sigma, peak + 2*sigma)
194+
f1.setLineColor(33)
195+
f1.setLineWidth(10)
196+
f1.setOptStat("1111")
197+
f1.setParameter(0, maxz)
198+
f1.setParameter(1, peak)
199+
f1.setParameter(2, sigma)
200+
if (maxz > 0) f1.setParLimits(0, maxz * 0.5, maxz * 1.5)
201+
f1.setParLimits(1, peak - 5.0, peak + 5.0)
202+
f1.setParLimits(2, 0.01, 10.0)
203+
204+
PrintStream original = System.out
205+
System.setOut(new PrintStream(OutputStream.nullOutputStream()))
206+
DataFitter.fit(f1, h1, "RQ")
207+
System.setOut(original)
208+
209+
return f1
210+
}
211+
185212
static F1D residual_fitter(H1F h1){
186213
def f1 =new F1D("fit:"+h1.getName(),"[amp]*gaus(x,[mean],[sigma])+[cst]", -5.0, 5.0);
187214
f1.setLineColor(33);

0 commit comments

Comments
 (0)