Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ def has_data = new AtomicBoolean(false)
(0..<11).collect{component->
def h1 = dir.getObject(String.format('/ALERT/ATOF_Time_component%02d', component))
if(h1!=null) {
if (h1.getBinContent(h1.getMaximumBin()) > 30 && h1.getEntries()>300){
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries()>10){
data[run].put(String.format('atof_time_%02d', component), h1)
def f1 = ALERTFitter.atof_time_fitter(h1,component)
double fit_min = h1.getXaxis().getBinCenter(1)
double fit_max = h1.getXaxis().getBinCenter(h1.getXaxis().getNBins())
def f1 = ALERTFitter.atof_time_fitter(h1, component, fit_min, fit_max)
data[run].put(String.format('fit_atof_time_%02d', component), f1)
data[run].put(String.format('peak_location_atof_time_%02d', component), f1.getParameter(1))
data[run].put(String.format('sigma_atof_time_%02d', component), f1.getParameter(2).abs())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.jlab.clas.timeline.analysis
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
import org.jlab.groot.data.TDirectory
import org.jlab.groot.data.GraphErrors
import org.jlab.clas.timeline.fitter.ALERTFitter

class alert_atof_time_sl {

def data = new ConcurrentHashMap()
def has_data = new AtomicBoolean(false)
int sector
int layer

alert_atof_time_sl(int sector, int layer) {
this.sector = sector
this.layer = layer
}

def getName() {
return String.format("%s_sector%02d_layer%d", this.class.simpleName, sector, layer)
}

def processRun(dir, run) {
data[run] = [run:run]
(0..<11).each { component ->
def h1 = dir.getObject(String.format('/ALERT/ATOF_Time_sector%02d_layer%02d_component%02d', sector, layer, component))
if (h1 != null) {
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries() > 10) {
def name = String.format('atof_time_sl_s%02d_l%d_c%02d', sector, layer, component)
data[run].put(name, h1)
double fit_min = h1.getXaxis().getBinCenter(1)
double fit_max = h1.getXaxis().getBinCenter(h1.getXaxis().getNBins())
def f1 = ALERTFitter.atof_time_fitter(h1, component, fit_min, fit_max)
data[run].put('fit_' + name, f1)
data[run].put('peak_location_' + name, f1.getParameter(1))
data[run].put('sigma_' + name, f1.getParameter(2).abs())
has_data.set(true)
}
}
}
}

def write() {
if (!has_data.get()) {
System.err.println "WARNING: no data for this timeline, not producing"
return
}
['peak_location', 'sigma'].each { variable ->
TDirectory out = new TDirectory()
out.mkdir('/timelines')
(0..<11).each { component ->
def name = String.format('atof_time_sl_s%02d_l%d_c%02d', sector, layer, component)
def gr = new GraphErrors(name)
gr.setTitle(String.format("ATOF Time %s Sector %02d Layer %d", variable.replace('_', ' '), sector, layer))
gr.setTitleY(String.format("ATOF Time %s (ns)", variable.replace('_', ' ')))
gr.setTitleX("run number")
data.sort { it.key }.each { run, it ->
out.mkdir('/' + it.run)
out.cd('/' + it.run)
if (it.containsKey(name)) {
out.addDataSet(it[name])
out.addDataSet(it['fit_' + name])
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
} else if (variable == 'peak_location') {
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
}
}
out.cd('/timelines')
out.addDataSet(gr)
}
out.writeFile(String.format('alert_atof_time_sl_%s_sector%02d_layer%d.hipo', variable, sector, layer))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.jlab.clas.timeline.analysis
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
import org.jlab.groot.data.TDirectory
import org.jlab.groot.data.GraphErrors

class alert_atof_z {

def data = new ConcurrentHashMap()
def has_data = new AtomicBoolean(false)

def processRun(dir, run) {
data[run] = [run:run]
def h1 = dir.getObject('/ALERT/ATOF_z_combined')
if (h1 != null) {
if (h1.getEntries() > 10) {
data[run].put('atof_z_combined', h1)
data[run].put('rms_atof_z_combined', h1.getRMS())
has_data.set(true)
}
}
}

def write() {
if (!has_data.get()) {
System.err.println "WARNING: no data for this timeline, not producing"
return
}
TDirectory out = new TDirectory()
out.mkdir('/timelines')
def name = 'atof_z_combined'
def gr = new GraphErrors(name)
gr.setTitle("ATOF z RMS")
gr.setTitleY("ATOF z RMS (cm)")
gr.setTitleX("run number")
data.sort { it.key }.each { run, it ->
out.mkdir('/' + it.run)
out.cd('/' + it.run)
if (it.containsKey(name)) {
out.addDataSet(it[name])
gr.addPoint(it.run, it['rms_' + name], 0, 0)
} else {
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
}
}
out.cd('/timelines')
out.addDataSet(gr)
out.writeFile('alert_atof_z_rms.hipo')
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.jlab.clas.timeline.analysis
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
import org.jlab.groot.data.TDirectory
import org.jlab.groot.data.GraphErrors
import org.jlab.clas.timeline.fitter.ALERTFitter

class alert_atof_z_c4 {

def data = new ConcurrentHashMap()
def has_data = new AtomicBoolean(false)

def processRun(dir, run) {
data[run] = [run:run]
def h1 = dir.getObject('/ALERT/ATOF_z_combined_c4')
if (h1 != null) {
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries() > 10) {
data[run].put('atof_z_c4_combined', h1)
def f1 = ALERTFitter.atof_z_fitter(h1)
data[run].put('fit_atof_z_c4_combined', f1)
data[run].put('peak_location_atof_z_c4_combined', f1.getParameter(1))
data[run].put('sigma_atof_z_c4_combined', f1.getParameter(2).abs())
has_data.set(true)
}
}
}

def write() {
if (!has_data.get()) {
System.err.println "WARNING: no data for this timeline, not producing"
return
}
['peak_location', 'sigma'].each { variable ->
TDirectory out = new TDirectory()
out.mkdir('/timelines')
def name = 'atof_z_c4_combined'
def gr = new GraphErrors(name)
gr.setTitle(String.format("ATOF z c4 %s", variable.replace('_', ' ')))
gr.setTitleY(String.format("ATOF z c4 %s (cm)", variable.replace('_', ' ')))
gr.setTitleX("run number")
data.sort { it.key }.each { run, it ->
out.mkdir('/' + it.run)
out.cd('/' + it.run)
if (it.containsKey(name)) {
out.addDataSet(it[name])
out.addDataSet(it['fit_' + name])
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
} else if (variable == 'peak_location') {
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
}
}
out.cd('/timelines')
out.addDataSet(gr)
out.writeFile(String.format('alert_atof_z_c4_%s.hipo', variable))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.jlab.clas.timeline.analysis
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
import org.jlab.groot.data.TDirectory
import org.jlab.groot.data.GraphErrors
import org.jlab.clas.timeline.fitter.ALERTFitter

class alert_atof_z_c4_sl {

def data = new ConcurrentHashMap()
def has_data = new AtomicBoolean(false)
int sector
int layer

alert_atof_z_c4_sl(int sector, int layer) {
this.sector = sector
this.layer = layer
}

def getName() {
return String.format("%s_sector%02d_layer%d", this.class.simpleName, sector, layer)
}

def processRun(dir, run) {
data[run] = [run:run]
def h1 = dir.getObject(String.format('/ALERT/ATOF_z_c4_sector%02d_layer%02d', sector, layer))
if (h1 != null) {
if (h1.getBinContent(h1.getMaximumBin()) > 3 && h1.getEntries() > 10) {
def name = String.format('atof_z_c4_sl_s%02d_l%d', sector, layer)
data[run].put(name, h1)
def f1 = ALERTFitter.atof_z_fitter(h1)
data[run].put('fit_' + name, f1)
data[run].put('peak_location_' + name, f1.getParameter(1))
data[run].put('sigma_' + name, f1.getParameter(2).abs())
has_data.set(true)
}
}
}

def write() {
if (!has_data.get()) {
System.err.println "WARNING: no data for this timeline, not producing"
return
}
['peak_location', 'sigma'].each { variable ->
TDirectory out = new TDirectory()
out.mkdir('/timelines')
def name = String.format('atof_z_c4_sl_s%02d_l%d', sector, layer)
def gr = new GraphErrors(name)
gr.setTitle(String.format("ATOF z c4 %s Sector %02d Layer %d", variable.replace('_', ' '), sector, layer))
gr.setTitleY(String.format("ATOF z c4 %s (cm)", variable.replace('_', ' ')))
gr.setTitleX("run number")
data.sort { it.key }.each { run, it ->
out.mkdir('/' + it.run)
out.cd('/' + it.run)
if (it.containsKey(name)) {
out.addDataSet(it[name])
out.addDataSet(it['fit_' + name])
gr.addPoint(it.run, it[variable + '_' + name], 0, 0)
} else if (variable == 'peak_location') {
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
}
}
out.cd('/timelines')
out.addDataSet(gr)
out.writeFile(String.format('alert_atof_z_c4_sl_%s_sector%02d_layer%d.hipo', variable, sector, layer))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.jlab.clas.timeline.analysis
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
import org.jlab.groot.data.TDirectory
import org.jlab.groot.data.GraphErrors

class alert_atof_z_sl {

def data = new ConcurrentHashMap()
def has_data = new AtomicBoolean(false)
int sector
int layer

alert_atof_z_sl(int sector, int layer) {
this.sector = sector
this.layer = layer
}

def getName() {
return String.format("%s_sector%02d_layer%d", this.class.simpleName, sector, layer)
}

def processRun(dir, run) {
data[run] = [run:run]
def h1 = dir.getObject(String.format('/ALERT/ATOF_z_sector%02d_layer%02d', sector, layer))
if (h1 != null) {
if (h1.getEntries() > 10) {
def name = String.format('atof_z_sl_s%02d_l%d', sector, layer)
data[run].put(name, h1)
data[run].put('rms_' + name, h1.getRMS())
has_data.set(true)
}
}
}

def write() {
if (!has_data.get()) {
System.err.println "WARNING: no data for this timeline, not producing"
return
}
TDirectory out = new TDirectory()
out.mkdir('/timelines')
def name = String.format('atof_z_sl_s%02d_l%d', sector, layer)
def gr = new GraphErrors(name)
gr.setTitle(String.format("ATOF z RMS Sector %02d Layer %d", sector, layer))
gr.setTitleY("ATOF z RMS (cm)")
gr.setTitleX("run number")
data.sort { it.key }.each { run, it ->
out.mkdir('/' + it.run)
out.cd('/' + it.run)
if (it.containsKey(name)) {
out.addDataSet(it[name])
gr.addPoint(it.run, it['rms_' + name], 0, 0)
} else {
println(String.format("run %d: %s either does not exist or does not have enough statistics.", it.run, name))
}
}
out.cd('/timelines')
out.addDataSet(gr)
out.writeFile(String.format('alert_atof_z_sl_rms_sector%02d_layer%d.hipo', sector, layer))
}
}
31 changes: 29 additions & 2 deletions src/main/java/org/jlab/clas/timeline/fitter/ALERTFitter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class ALERTFitter{
}


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

static F1D atof_z_fitter(H1F h1){
double maxz = h1.getBinContent(h1.getMaximumBin())
double peak = h1.getAxis().getBinCenter(h1.getMaximumBin())
int bin_low = h1.getAxis().getBin(peak - 10.0)
int bin_high = h1.getAxis().getBin(peak + 10.0)
double sigma = ALERTFitter.getRestrictedRMS(h1, bin_low, bin_high)
if (sigma <= 0 || Double.isNaN(sigma)) sigma = 5.0

def f1 = new F1D("fit:" + h1.getName(), "[amp]*gaus(x,[mean],[sigma])", peak - 2*sigma, peak + 2*sigma)
f1.setLineColor(33)
f1.setLineWidth(10)
f1.setOptStat("1111")
f1.setParameter(0, maxz)
f1.setParameter(1, peak)
f1.setParameter(2, sigma)
if (maxz > 0) f1.setParLimits(0, maxz * 0.5, maxz * 1.5)
f1.setParLimits(1, peak - 5.0, peak + 5.0)
f1.setParLimits(2, 0.01, 10.0)

PrintStream original = System.out
System.setOut(new PrintStream(OutputStream.nullOutputStream()))
DataFitter.fit(f1, h1, "RQ")
System.setOut(original)

return f1
}

static F1D residual_fitter(H1F h1){
def f1 =new F1D("fit:"+h1.getName(),"[amp]*gaus(x,[mean],[sigma])+[cst]", -5.0, 5.0);
f1.setLineColor(33);
Expand Down
Loading