Skip to content

Commit d7c13ae

Browse files
author
ziegler
committed
Branch for DCDDAT project.
Contains a service that creates hits with geometry information bank and a bank viewer.
1 parent db81ac1 commit d7c13ae

5 files changed

Lines changed: 845 additions & 4 deletions

File tree

reconstruction/cvt/src/main/java/org/jlab/rec/cvt/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Constants {
2020
public static double CAANGLE4=19.;
2121
public static double CAANGLE5=3.5;
2222
public boolean seedingDebugMode =false;
23-
23+
public boolean QDCDATSample=true;
2424

2525

2626
// private constructor for a singleton

reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ public void fetch_BMTHits(DataEvent event, Swim swim, IndexedTable status,
133133
// create the strip object for the BMT
134134
Strip BmtStrip = new Strip(strip, ADCtoEdep, time);
135135
BmtStrip.setStatus(status.getIntValue("status", sector, layer, strip));
136-
if(Constants.getInstance().timeCuts) {
136+
if(Constants.getInstance().timeCuts
137+
&& !Constants.getInstance().QDCDATSample) {
137138
if(time!=0 && (time<tmin || time>tmax))
138139
BmtStrip.setStatus(2);// calculate the strip parameters for the BMT hit
139140
}
140-
if(Constants.getInstance().bmtHVCuts) {
141+
if(Constants.getInstance().bmtHVCuts
142+
&& !Constants.getInstance().QDCDATSample) {
141143
if(bmtStripVoltage!=null && bmtStripVoltage.hasEntry(sector,layer,0) &&
142144
bmtStripVoltageThresh!=null && bmtStripVoltageThresh.hasEntry(sector,layer,0)) {
143145
double hv = bmtStripVoltage.getDoubleValue("HV", sector,layer,0);
@@ -299,7 +301,8 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere,
299301
if(tdcs.containsKey(key)) {
300302
time = tdcs.get(key);
301303
//time tag
302-
if(Constants.getInstance().useSVTTimingCuts) {
304+
if(Constants.getInstance().useSVTTimingCuts &&
305+
!Constants.getInstance().QDCDATSample) {
303306
if(this.passTimingCuts(ADC, time)==false)
304307
continue;
305308
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package org.jlab.rec.cvt.ml.qcddat;
6+
7+
import javafx.application.Application;
8+
/**
9+
*
10+
* @author veronique
11+
*/
12+
public class Browser {
13+
14+
public static void main(String[] args) {
15+
if (args.length < 1) {
16+
System.err.println("Usage: java Viewer <input.hipo>");
17+
System.err.println("Example: java Viewer file.hipo");
18+
System.exit(1);
19+
}
20+
21+
String inputFile = args[0];
22+
23+
Viewer.configure(inputFile);
24+
Application.launch(Viewer.class);
25+
}
26+
}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
package org.jlab.rec.cvt.ml.qcddat;
2+
3+
import org.jlab.rec.cvt.ml.*;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
import org.jlab.clas.reco.ReconstructionEngine;
9+
import org.jlab.clas.swimtools.Swim;
10+
import org.jlab.detector.base.DetectorType;
11+
import org.jlab.io.base.DataBank;
12+
import org.jlab.io.base.DataEvent;
13+
import org.jlab.rec.cvt.Constants;
14+
import org.jlab.rec.cvt.Geometry;
15+
import org.jlab.rec.cvt.bmt.BMTType;
16+
import org.jlab.rec.cvt.hit.Hit;
17+
import org.jlab.utils.groups.IndexedTable;
18+
19+
import org.jlab.geom.prim.Line3D;
20+
import org.jlab.geom.prim.Arc3D;
21+
import org.jlab.rec.cvt.banks.HitReader;
22+
23+
/**
24+
* Service to return reconstructed TRACKS
25+
* format
26+
*
27+
* @author ziegler
28+
*
29+
*/
30+
public class SampleMaker extends ReconstructionEngine {
31+
32+
33+
private int Run = -1;
34+
35+
private String svtHitBank;
36+
37+
public SampleMaker(String name) {
38+
super(name, "ziegler", "6.0");
39+
}
40+
41+
public SampleMaker() {
42+
super("CVTQCDDATEngine", "ziegler", "6.0");
43+
}
44+
45+
46+
@Override
47+
public boolean init() {
48+
this.initConstantsTables();
49+
this.registerBanks();
50+
return true;
51+
}
52+
53+
public void registerBanks() {
54+
this.setSvtHitBank("CVT::QCDDATHit");
55+
super.registerOutputBank(this.svtHitBank);
56+
}
57+
58+
public int getRun(DataEvent event) {
59+
60+
if (event.hasBank("RUN::config") == false) {
61+
System.err.println("RUN CONDITIONS NOT READ!");
62+
return 0;
63+
}
64+
65+
DataBank bank = event.getBank("RUN::config");
66+
int run = bank.getInt("run", 0);
67+
if(Constants.getInstance().seedingDebugMode) {
68+
System.out.println("EVENT "+bank.getInt("event", 0));
69+
}
70+
return run;
71+
}
72+
73+
74+
75+
@Override
76+
public boolean processDataEvent(DataEvent event) {
77+
78+
int run = this.getRun(event);
79+
Swim swimmer = new Swim();
80+
IndexedTable svtStatus = this.getConstantsManager().getConstants(run, "/calibration/svt/status");
81+
IndexedTable svtLorentz = this.getConstantsManager().getConstants(run, "/calibration/svt/lorentz_angle");
82+
IndexedTable bmtStatus = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_status");
83+
IndexedTable bmtTime = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_time");
84+
IndexedTable bmtVoltage = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_voltage");
85+
IndexedTable bmtStripVoltage = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_strip_voltage");
86+
IndexedTable bmtStripThreshold = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_strip_voltage_thresholds");
87+
IndexedTable adcStatus = this.getConstantsManager().getConstants(run, "/calibration/svt/adcstatus");
88+
89+
Geometry.getInstance().initialize(this.getConstantsManager().getVariation(), run, svtLorentz, bmtVoltage);
90+
91+
HitReader hitRead = new HitReader();
92+
hitRead.fetch_SVTHits(event, -1, -1, svtStatus, adcStatus);
93+
hitRead.fetch_BMTHits(event, swimmer, bmtStatus, bmtTime,
94+
bmtStripVoltage, bmtStripThreshold);
95+
List<ArrayList<Hit>> hits = new ArrayList<>();
96+
if(hitRead.getSVTHits() == null) {
97+
hits.add(new ArrayList<>());
98+
}
99+
else {
100+
hits.add((ArrayList<Hit>) hitRead.getSVTHits());
101+
}
102+
if(hitRead.getBMTHits() == null) {
103+
hits.add(new ArrayList<>());
104+
}
105+
else {
106+
hits.add((ArrayList<Hit>) hitRead.getBMTHits());
107+
}
108+
109+
if (event.hasBank("MC::True")) {
110+
DataBank mcTrue = event.getBank("MC::True");
111+
TrackingPerformance.MatchHitsToMC(hits, mcTrue);
112+
}
113+
114+
if (hits.isEmpty())
115+
return false;
116+
DataBank bank = event.createBank(this.svtHitBank, hits.get(0).size()+hits.get(1).size());
117+
int index=0;
118+
for(int i = 0; i < hits.size(); i++) {
119+
for(int j = 0; j < hits.get(i).size(); j++) {
120+
bank.setShort("id", index, (short) hits.get(i).get(j).getId());
121+
bank.setShort("mctid", index, (short) hits.get(i).get(j).getAssociateMCTrkId());
122+
bank.setByte("sector", index, (byte) hits.get(i).get(j).getSector());
123+
int layer = hits.get(i).get(j).getLayer();
124+
if(i>0) layer+=6;
125+
bank.setByte("layer", index, (byte) layer);
126+
bank.setShort("strip", index, (short) hits.get(i).get(j).getStrip().getStrip());
127+
bank.setFloat("energy", index, (short) hits.get(i).get(j).getStrip().getEdep());
128+
bank.setFloat("time", index, (short) hits.get(i).get(j).getStrip().getTime());
129+
int mctrue=-1;
130+
if(hits.get(i).get(j).MCstatus==0) {
131+
mctrue=0;
132+
} else {
133+
mctrue=1;
134+
}
135+
bank.setByte("mctrue", index, (byte) mctrue);
136+
if(hits.get(i).get(j).getDetector()==DetectorType.BST ||
137+
(hits.get(i).get(j).getDetector()==DetectorType.BMT
138+
&& hits.get(i).get(j).getType()==BMTType.Z)) {
139+
Line3D sline = hits.get(i).get(j).getStrip().getLine();
140+
bank.setFloat("x1", index, (float) sline.origin().x()/10);
141+
bank.setFloat("y1", index, (float) sline.origin().y()/10);
142+
bank.setFloat("z1", index, (float) sline.origin().z()/10);
143+
bank.setFloat("x2", index, (float) sline.midpoint().x()/10);
144+
bank.setFloat("y2", index, (float) sline.midpoint().y()/10);
145+
bank.setFloat("z2", index, (float) sline.midpoint().z()/10);
146+
bank.setFloat("x3", index, (float) sline.end().x()/10);
147+
bank.setFloat("y3", index, (float) sline.end().y()/10);
148+
bank.setFloat("z3", index, (float) sline.end().z()/10);
149+
150+
}
151+
if(hits.get(i).get(j).getDetector()==DetectorType.BMT
152+
&& hits.get(i).get(j).getType()==BMTType.C) {
153+
Arc3D sarc = hits.get(i).get(j).getStrip().getArc();
154+
bank.setFloat("x1", index, (float) sarc.origin().x()/10);
155+
bank.setFloat("y1", index, (float) sarc.origin().y()/10);
156+
bank.setFloat("z1", index, (float) sarc.origin().z()/10);
157+
bank.setFloat("x2", index, (float) sarc.point(sarc.theta()/2).x()/10);
158+
bank.setFloat("y2", index, (float) sarc.point(sarc.theta()/2).y()/10);
159+
bank.setFloat("z2", index, (float) sarc.point(sarc.theta()/2).z()/10);
160+
bank.setFloat("x3", index, (float) sarc.end().x()/10);
161+
bank.setFloat("y3", index, (float) sarc.end().y()/10);
162+
bank.setFloat("z3", index, (float) sarc.end().z()/10);
163+
}
164+
165+
index++;
166+
}
167+
}
168+
//bank.show();
169+
event.appendBanks(bank);
170+
171+
return true;
172+
}
173+
174+
175+
176+
public void initConstantsTables() {
177+
String[] tables = new String[]{
178+
"/calibration/svt/status",
179+
"/calibration/svt/lorentz_angle",
180+
"/calibration/mvt/bmt_time",
181+
"/calibration/mvt/bmt_status",
182+
"/calibration/mvt/bmt_voltage",
183+
"/calibration/mvt/bmt_strip_voltage",
184+
"/calibration/mvt/bmt_strip_voltage_thresholds",
185+
"/geometry/beam/position",
186+
"/calibration/svt/adcstatus"
187+
};
188+
requireConstants(Arrays.asList(tables));
189+
this.getConstantsManager().setVariation("default");
190+
}
191+
192+
public void setSvtHitBank(String bstHitBank) {
193+
this.svtHitBank = bstHitBank;
194+
}
195+
public String getSvtHitBank() {
196+
return this.svtHitBank;
197+
}
198+
199+
200+
201+
202+
}

0 commit comments

Comments
 (0)