Skip to content

Commit 4a67272

Browse files
raffaelladevitabaltzell
authored andcommitted
exteding to ctof
1 parent 3e54d69 commit 4a67272

File tree

3 files changed

+168
-2
lines changed

3 files changed

+168
-2
lines changed

etc/bankdefs/hipo4/tof.json

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,43 @@
266266
{"name":"z", "type":"F", "info":"Global Z coor (cm) of cluster seed"},
267267
{"name":"pathLengthThruBar", "type":"F", "info":"pathlength of the track from the entrance point to the exit point through the cluster bars "}
268268
]
269-
}
270-
269+
},
270+
{
271+
"name": "CTOF::calib",
272+
"group": 20400,
273+
"item" : 25,
274+
"info": "reconstructed hit info from CTOF calibration",
275+
"entries": [
276+
{"name":"id", "type":"S", "info":"id of the hit"},
277+
{"name":"status", "type":"S", "info":"hit status defined based on presence (0) or absence (1) of TDCR-TDCL-ADCR-ADCL"},
278+
{"name":"trackid", "type":"S", "info":"matched DC track id"},
279+
{"name":"component", "type":"S", "info":"paddle id of CTOF"},
280+
{"name":"energy", "type":"F", "info":"E dep (MeV) of hit"},
281+
{"name":"time", "type":"F", "info":"Hit time (ns)"},
282+
{"name":"x", "type":"F", "info":"Global X coor (cm) of hit"},
283+
{"name":"y", "type":"F", "info":"Global Y coor (cm) of hit"},
284+
{"name":"z", "type":"F", "info":"Global Z coor (cm) of hit"},
285+
{"name":"tx", "type":"F", "info":"Global X coor (cm) of hit from DC info - trackid index"},
286+
{"name":"ty", "type":"F", "info":"Global Y coor (cm) of hit from DC info - trackid index"},
287+
{"name":"tz", "type":"F", "info":"Global Z coor (cm) of hit from DC info - trackid index"},
288+
{"name":"adc1", "type":"I", "info":"ADCL"},
289+
{"name":"adc2", "type":"I", "info":"ADCR"},
290+
{"name":"tdc1", "type":"I", "info":"TDCL"},
291+
{"name":"tdc2", "type":"I", "info":"TDCR"},
292+
{"name":"pindex", "type":"S", "info":"particle positionin REC::Particle"},
293+
{"name":"pid", "type":"I", "info":"particle id"},
294+
{"name":"charge", "type":"B", "info":"particle charge"},
295+
{"name":"px", "type":"F", "info":"particle momentum x component"},
296+
{"name":"py", "type":"F", "info":"particle momentum y component"},
297+
{"name":"pz", "type":"F", "info":"particle momentum z component"},
298+
{"name":"vx", "type":"F", "info":"particle vertex x coordinate"},
299+
{"name":"vy", "type":"F", "info":"particle vertex y coordinate"},
300+
{"name":"vz", "type":"F", "info":"particle vertex z coordinate"},
301+
{"name":"vt", "type":"F", "info":"vertex-corrected event start time" },
302+
{"name":"chi2", "type":"F", "info":"track chi2"},
303+
{"name":"NDF", "type":"S", "info":"NDF"},
304+
{"name":"pathLength", "type":"F", "info":"pathlength of the track from the vertex (doca point to the beamline to the midpoint between the entrance and exit of the hit bar"},
305+
{"name":"pathLengthThruBar", "type":"F", "info":"pathlength of the track from the entrance point to the exit point through the hit bar "}
306+
]
307+
}
271308
]
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package org.jlab.calibration.detectors;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
import org.jlab.detector.base.DetectorType;
6+
import org.jlab.io.base.DataBank;
7+
import org.jlab.io.base.DataEvent;
8+
9+
/**
10+
*
11+
* @author devita
12+
*/
13+
public class CTOFCalibrator extends DetectorCalibrator {
14+
15+
public CTOFCalibrator() {
16+
super(DetectorType.CTOF);
17+
super.init("CTOF::adc", "CTOF::tdc", "CTOF::hits", "CVTRec::Tracks",
18+
"REC::Track", "REC::Scintillator", "REC::Particle");
19+
}
20+
@Override
21+
public boolean isGoodEvent(DataEvent event) {
22+
23+
DataBank part = event.getBank("REC::Particle");
24+
if(part.rows()<2 ||
25+
part.getInt("pid", 0)!=11 ||
26+
((int) (Math.abs(part.getShort("status", 0))/1000))!=2)
27+
return false;
28+
else {
29+
for(int i=1; i<part.rows(); i++) {
30+
if(part.getByte("charge", i)<0 &&
31+
part.getShort("status", i)>4000)
32+
return true;
33+
}
34+
}
35+
return false;
36+
}
37+
38+
@Override
39+
public DataBank buildCalibBank(DataEvent event) {
40+
DataBank part = event.getBank("REC::Particle");
41+
DataBank scin = event.getBank("REC::Scintillator");
42+
DataBank trac = event.getBank("REC::Track");
43+
DataBank cvts = event.getBank("CVTRec::Tracks");
44+
DataBank hits = event.getBank("CTOF::hits");
45+
DataBank adcs = event.getBank("CTOF::adc");
46+
DataBank tdcs = event.getBank("CTOF::tdc");
47+
48+
Map<Integer,Integer> sinds = new HashMap<>();
49+
for(int is=0; is<scin.rows(); is++) {
50+
int detector = scin.getByte("detector", is);
51+
if(DetectorType.getType(detector)==DetectorType.CTOF) {
52+
int pindex = scin.getShort("pindex", is);
53+
sinds.put(pindex, is);
54+
}
55+
}
56+
57+
58+
Map<Integer,Integer> tinds = new HashMap<>();
59+
for(int it=0; it<trac.rows(); it++) {
60+
int detector = trac.getByte("detector", it);
61+
if(DetectorType.getType(detector)==DetectorType.CVT) {
62+
int index = trac.getShort("index", it);
63+
tinds.put((int) cvts.getShort("ID", index), it);
64+
}
65+
}
66+
67+
int ngood = 0;
68+
for(int i=0; i<hits.rows(); i++) {
69+
int tid = hits.getShort("trkID", i);
70+
if(tid>0 && tinds.containsKey(tid)) {
71+
int tindex = tinds.get(tid);
72+
int pindex = trac.getShort("pindex", tindex);
73+
if(sinds.containsKey(pindex))
74+
ngood++;
75+
}
76+
}
77+
78+
if(ngood>0) {
79+
DataBank calib = event.createBank("CTOF::calib", ngood);
80+
81+
int row =0;
82+
for(int i=0; i<hits.rows(); i++) {
83+
int tid = hits.getShort("trkID", i);
84+
if(tid>0 && tinds.containsKey(tid)) {
85+
int tindex = tinds.get(tid);
86+
int pindex = trac.getShort("pindex", tindex);
87+
if(sinds.containsKey(pindex)) {
88+
int sindex = sinds.get(pindex);
89+
calib.setShort("id", row, hits.getShort("id", i));
90+
calib.setShort("status", row, hits.getShort("status", i));
91+
calib.setShort("trackid", row, hits.getShort("trkID", i));
92+
calib.setShort("pindex", row, (short) pindex);
93+
calib.setShort("component", row, hits.getShort("component", i));
94+
calib.setFloat("energy", row, hits.getFloat("energy", i));
95+
calib.setFloat("time", row, hits.getFloat("time", i));
96+
calib.setFloat("x", row, hits.getFloat("x", i));
97+
calib.setFloat("y", row, hits.getFloat("y", i));
98+
calib.setFloat("z", row, hits.getFloat("z", i));
99+
calib.setFloat("tx", row, scin.getFloat("hx", sindex));
100+
calib.setFloat("ty", row, scin.getFloat("hy", sindex));
101+
calib.setFloat("tz", row, scin.getFloat("hz", sindex));
102+
calib.setInt("pid", row, part.getInt("pid", pindex));
103+
calib.setByte("charge", row, part.getByte("charge", pindex));
104+
calib.setFloat("px", row, part.getFloat("px", pindex));
105+
calib.setFloat("py", row, part.getFloat("py", pindex));
106+
calib.setFloat("pz", row, part.getFloat("pz", pindex));
107+
calib.setFloat("vx", row, part.getFloat("vx", pindex));
108+
calib.setFloat("vy", row, part.getFloat("vy", pindex));
109+
calib.setFloat("vz", row, part.getFloat("vz", pindex));
110+
calib.setFloat("vt", row, part.getFloat("vt", pindex));
111+
calib.setFloat("pathLength", row, scin.getFloat("path", sindex));
112+
calib.setFloat("pathLengthThruBar", row, hits.getFloat("pathLengthThruBar", i));
113+
calib.setFloat("chi2", row, trac.getFloat("chi2", tindex));
114+
calib.setShort("NDF", row, trac.getShort("NDF", tindex));
115+
calib.setInt("adc1", row, adcs.getInt("ADC", hits.getShort("adc_idx1", i)));
116+
calib.setInt("adc2", row, adcs.getInt("ADC", hits.getShort("adc_idx2", i)));
117+
calib.setInt("tdc1", row, tdcs.getInt("TDC", hits.getShort("tdc_idx1", i)));
118+
calib.setInt("tdc2", row, tdcs.getInt("TDC", hits.getShort("tdc_idx2", i)));
119+
row++;
120+
}
121+
}
122+
}
123+
return calib;
124+
}
125+
return null;
126+
}
127+
}

reconstruction/calib/src/main/java/org/jlab/calibration/service/CalibBankEngine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.List;
66
import java.util.Map;
77
import java.util.logging.Logger;
8+
import org.jlab.calibration.detectors.CTOFCalibrator;
89
import org.jlab.calibration.detectors.DCCalibrator;
910
import org.jlab.calibration.detectors.DetectorCalibrator;
1011
import org.jlab.calibration.detectors.FTOFCalibrator;
@@ -31,6 +32,7 @@ public CalibBankEngine() {
3132
super("CALIB", "devita", "1.0");
3233
calibrators.put(DetectorType.DC , new DCCalibrator());
3334
calibrators.put(DetectorType.FTOF, new FTOFCalibrator());
35+
calibrators.put(DetectorType.CTOF, new CTOFCalibrator());
3436
calibrators.put(DetectorType.RICH, new RICHCalibrator());
3537
}
3638

0 commit comments

Comments
 (0)