Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add helicity timeline #161

Merged
merged 7 commits into from
Jan 26, 2024
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
1 change: 1 addition & 0 deletions bin/run-detectors-timelines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ detDirs=(
forward
ft
ftof
helicity
htcc
ltcc
m2_ctof_ftof
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.jlab.clas.timeline.timeline.helicity
import java.util.concurrent.ConcurrentHashMap
import org.jlab.groot.data.TDirectory
import org.jlab.groot.data.GraphErrors

class helicity {

def data = new ConcurrentHashMap()

def processDirectory(dir, run) {
def h1 = dir.getObject('/HELICITY/offlineRaw')
def h2 = dir.getObject('/HELICITY/onlineRaw')
data[run] = [run:run, OfflineRaw:h1, OnlineRaw:h2]
}

def close() {
TDirectory out = new TDirectory()
out.mkdir('/timelines')
["OfflineRaw", "OnlineRaw"].each{ name ->
def gr = new GraphErrors(name)
gr.setTitle("Helicity Delay Correction Infficiency")
gr.setTitleY("Efficiency")
gr.setTitleX("run number")
data.sort{it.key}.each{run,it->
out.mkdir('/'+it.run)
out.cd('/'+it.run)
out.addDataSet(it[name])
def minus = it[name].getBinContent(it[name].getAxis().getBin(-1.0));
def plus = it[name].getBinContent(it[name].getAxis().getBin(1.0));
def udf = it[name].getBinContent(it[name].getAxis().getBin(0.0));
if ((minus+plus+udf) > 0)
gr.addPoint(it.run, (minus+plus)/(minus+plus+udf), 0, 0)
else
gr.addPoint(it.run, -1, 0, 0)
}
out.cd('/timelines')
out.addDataSet(gr)
}
out.writeFile('helicity_efficiency.hipo')
}

}
3 changes: 2 additions & 1 deletion detectors/src/main/java/org/jlab/clas/timeline/run.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def engines = [
new rich.rich_nkm_m(),
new rich.rich_nkp_m(),
new rich.rich_npro_m(),
new rich.rich_npbar_m()]
new rich.rich_npbar_m()],
out_HELICITY: [new helicity.helicity()]
c-dilks marked this conversation as resolved.
Show resolved Hide resolved
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def engines = [
new rich.rich_nkp_m(),
new rich.rich_npro_m(),
new rich.rich_npbar_m()],
out_HELICITY: [new helicity.helicity()],
dst_mon: [new particle_mass_ctof_and_ftof.ftof_m2_p1a_pim(),
new particle_mass_ctof_and_ftof.ftof_m2_p1a_pip(),
new particle_mass_ctof_and_ftof.ftof_m2_p1a_prot(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static void main(String[] args) {
FT ana_ft = new FT(runNum,outputDir,useTB);
dst_mon ana_dst_mon = new dst_mon(runNum,outputDir,EB);
BAND ana_band = new BAND(runNum,outputDir,EB,useTB);
helicity helicity = new helicity();
//deuterontarget ana_deuteron = new deuterontarget(runNum,EB,useTB);
List<String> toProcessFileNames = new ArrayList<String>();
File file = new File(filelist);
Expand Down Expand Up @@ -90,6 +91,7 @@ public static void main(String[] args) {
ana_band.processEvent(event);
ana_rich.processEvent(event);
//ana_deuteron.processEvent(event);
helicity.processEvent(event);
filecount++;count++;
if(count%10000 == 0){
long nowTime = System.currentTimeMillis();
Expand Down Expand Up @@ -132,5 +134,6 @@ public static void main(String[] args) {
ana_rich.postProcess();
ana_rich.write();
//ana_deuteron.plot();
helicity.write(outputDir, runNum);
}
}
54 changes: 54 additions & 0 deletions monitoring/src/main/java/org/jlab/clas12/monitoring/helicity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.jlab.clas12.monitoring;

import java.util.ArrayList;
import org.jlab.groot.data.H1F;
import org.jlab.groot.data.TDirectory;
import org.jlab.io.base.DataEvent;

/**
*
* @author baltzell
*/
public class helicity {

private class H1Fb extends H1F {
String bankName;
String varName;
public H1Fb(String name, String bankName, String varName) {
super(name,3,-1.5,1.5);
this.bankName = bankName;
this.varName = varName;
}
public void fill(DataEvent event) {
if (event.hasBank(this.bankName) && event.getBank(this.bankName).rows()>0) {
this.fill(event.getBank(this.bankName).getByte(this.varName, 0));
}
}
}

ArrayList<H1Fb> histos;

public helicity() {
histos = new ArrayList<>();
histos.add(new H1Fb("onlineRaw","HEL::online","helicityRaw"));
histos.add(new H1Fb("offlineRaw","REC::Event","helicityRaw"));
histos.add(new H1Fb("online","HEL::online","helicity"));
histos.add(new H1Fb("offline","REC::Event","helicity"));
histos.add(new H1Fb("boardRaw","HEL::decoder","helicity"));
}

public void processEvent(DataEvent event){
for (H1Fb h : this.histos) {
h.fill(event);
}
}

public void write(String outputDir, int runNumber) {
TDirectory dir = new TDirectory();
dir.mkdir("/HELICITY/");
dir.cd("/HELICITY/");
for (H1Fb h : this.histos) dir.addDataSet(h);
dir.writeFile(outputDir + String.format("/out_HELICITY_%d.hipo",runNumber));
}

}
Loading