Skip to content

Commit 8cacbbe

Browse files
committed
feat: CVT NN stuff, factored out of CVT_QCDDAT branch
This reverts commit d5fbade.
1 parent d5fbade commit 8cacbbe

7 files changed

Lines changed: 1597 additions & 0 deletions

File tree

etc/bankdefs/hipo4/cvtnn.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[
2+
{
3+
"name": "CVTRec::MLHit",
4+
"group": 20500,
5+
"item" : 51,
6+
"info": "reconstructed hits (1st pass tracking)",
7+
"entries": [
8+
{"name":"id", "type":"S", "info":"id of the hit"},
9+
{"name":"sidx", "type":"S", "info":"row in the MLSeed bank"},
10+
{"name":"tidx", "type":"S", "info":"row in the MLTrack bank"},
11+
{"name":"rectid", "type":"S", "info":"reconstructed track id associated with the hit"},
12+
{"name":"recsid", "type":"S", "info":"reconstructed seed id associated with the hit"},
13+
{"name":"mctid", "type":"S", "info":"MC track id associated with the hit"},
14+
{"name":"sector", "type":"B", "info":"sector"},
15+
{"name":"layer", "type":"B", "info":"layer (1...6)=SVT; (7...12)=BMT"},
16+
{"name":"type", "type":"B", "info":"detector type: 0=SVT; 1=BMT-Z; 2=BMT-C"},
17+
{"name":"strip", "type":"S", "info":"strip number"},
18+
{"name":"order", "type":"B", "info":"order 0=MC hit-on-track; 1=noise hit"},
19+
{"name":"cid", "type":"S", "info":"associated cluster id"},
20+
{"name":"cweight", "type":"F", "info":"1/1+|difference to associated cluster centroid|"},
21+
{"name":"sweight", "type":"F", "info":"1/1+|normalized difference to associated cluster seed|"},
22+
{"name":"x1", "type":"F", "info":"geometric strip first end-point x-coordinate"},
23+
{"name":"y1", "type":"F", "info":"geometric strip first end-point y-coordinate"},
24+
{"name":"z1", "type":"F", "info":"geometric strip first end-point z-coordinate"},
25+
{"name":"x2", "type":"F", "info":"geometric strip second end-point x-coordinate"},
26+
{"name":"y2", "type":"F", "info":"geometric strip second end-point y-coordinate"},
27+
{"name":"z2", "type":"F", "info":"geometric strip second end-point z-coordinate"}
28+
]
29+
},
30+
{
31+
"name": "CVT::MLHit",
32+
"group": 20500,
33+
"item" : 52,
34+
"info": "reconstructed hits (2nd pass tracking)",
35+
"entries": [
36+
{"name":"id", "type":"S", "info":"id of the hit"},
37+
{"name":"sidx", "type":"S", "info":"row in the MLSeed bank"},
38+
{"name":"tidx", "type":"S", "info":"row in the MLTrack bank"},
39+
{"name":"rectid", "type":"S", "info":"reconstructed track id associated with the hit"},
40+
{"name":"recsid", "type":"S", "info":"reconstructed seed id associated with the hit"},
41+
{"name":"mctid", "type":"S", "info":"MC track id associated with the hit"},
42+
{"name":"sector", "type":"B", "info":"sector"},
43+
{"name":"layer", "type":"B", "info":"layer (1...6)=SVT; (7...12)=BMT"},
44+
{"name":"type", "type":"B", "info":"detector type: 0=SVT; 1=BMT-Z; 2=BMT-C"},
45+
{"name":"strip", "type":"S", "info":"strip number"},
46+
{"name":"order", "type":"B", "info":"order 0=MC hit-on-track; 1=noise hit"},
47+
{"name":"cid", "type":"S", "info":"associated cluster id"},
48+
{"name":"cweight", "type":"F", "info":"1/1+|normalized difference to associated cluster centroid|"},
49+
{"name":"sweight", "type":"F", "info":"1/1+|normalized difference to associated cluster seed|"},
50+
{"name":"x1", "type":"F", "info":"geometric strip first end-point x-coordinate"},
51+
{"name":"y1", "type":"F", "info":"geometric strip first end-point y-coordinate"},
52+
{"name":"z1", "type":"F", "info":"geometric strip first end-point z-coordinate"},
53+
{"name":"x2", "type":"F", "info":"geometric strip second end-point x-coordinate"},
54+
{"name":"y2", "type":"F", "info":"geometric strip second end-point y-coordinate"},
55+
{"name":"z2", "type":"F", "info":"geometric strip second end-point z-coordinate"}
56+
]
57+
},
58+
{
59+
"name": "CVTRec::MLSeed",
60+
"group": 20500,
61+
"item" : 61,
62+
"info": "reconstructed seeds (1st pass tracking)",
63+
"entries": [
64+
{"name":"id", "type":"S", "info":"id of the seed"},
65+
{"name":"purity", "type":"F", "info":"seed purity: Nb of reconstructed true hits in seed / total hits on seed"},
66+
{"name":"efficiency", "type":"F", "info":"seed purity: Nb of reconstructed true hits in seed / MC hits in gemerated track"}
67+
]
68+
},
69+
{
70+
"name": "CVTRec::MLTrack",
71+
"group": 20500,
72+
"item" : 62,
73+
"info": "reconstructed seeds (1st pass tracking)",
74+
"entries": [
75+
{"name":"id", "type":"S", "info":"id of the seed"},
76+
{"name":"purity", "type":"F", "info":"seed purity: Nb of reconstructed true hits in track / total hits on track"},
77+
{"name":"efficiency", "type":"F", "info":"seed purity: Nb of reconstructed true hits in track / MC hits in gemerated track"}
78+
]
79+
},
80+
{
81+
"name": "CVT::MLSeed",
82+
"group": 20500,
83+
"item" : 63,
84+
"info": "reconstructed seeds (2nd pass tracking)",
85+
"entries": [
86+
{"name":"id", "type":"S", "info":"id of the track"},
87+
{"name":"purity", "type":"F", "info":"seed purity: Nb of reconstructed true hits in seed / total hits on seed"},
88+
{"name":"efficiency", "type":"F", "info":"seed purity: Nb of reconstructed true hits in seed / MC hits in gemerated track"}
89+
]
90+
},
91+
{
92+
"name": "CVT::MLTrack",
93+
"group": 20500,
94+
"item" : 64,
95+
"info": "reconstructed seeds (2nd pass tracking)",
96+
"entries": [
97+
{"name":"id", "type":"S", "info":"id of the track"},
98+
{"name":"purity", "type":"F", "info":"seed purity: Nb of reconstructed true hits in track / total hits on track"},
99+
{"name":"efficiency", "type":"F", "info":"seed purity: Nb of reconstructed true hits in track / MC hits in gemerated track"}
100+
]
101+
}
102+
103+
104+
]

etc/services/mc-mlcvt.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
io-services:
2+
reader:
3+
class: org.jlab.io.clara.HipoToHipoReader
4+
name: HipoToHipoReader
5+
writer:
6+
class: org.jlab.io.clara.HipoToHipoWriter
7+
name: HipoToHipoWriter
8+
services:
9+
- class: org.jlab.clas.swimtools.MagFieldsEngine
10+
name: MAGFIELDS
11+
- class: org.jlab.rec.cvt.ml.SampleMaker
12+
name: CVTFP
13+
configuration:
14+
global:
15+
variation: rga_fall2018_bg
16+
# dcMinistagger: "NOTONREFWIRE"
17+
# dcFeedthroughs: "OFF"
18+
# io-services:
19+
# writer:
20+
# schema_dir: "absolute-path-to-schema-folder"
21+
services:
22+
MAGFIELDS:
23+
magfieldSolenoidMap: Symm_solenoid_r601_phi1_z1201_13June2018.dat
24+
magfieldTorusMap: Symm_torus_r2501_phi16_z251_24Apr2018.dat
25+
26+
mime-types:
27+
- binary/data-hipo

etc/services/mc-mlcvtfilter.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
io-services:
2+
reader:
3+
class: org.jlab.io.clara.HipoToHipoReader
4+
name: HipoToHipoReader
5+
writer:
6+
class: org.jlab.io.clara.HipoToHipoWriter
7+
name: HipoToHipoWriter
8+
services:
9+
- class: org.jlab.clas.swimtools.MagFieldsEngine
10+
name: MAGFIELDS
11+
- class: org.jlab.rec.cvt.ml.CVTFilter
12+
name: CVTFP
13+
configuration:
14+
global:
15+
variation: rga_fall2018_bg
16+
# dcMinistagger: "NOTONREFWIRE"
17+
# dcFeedthroughs: "OFF"
18+
# io-services:
19+
# writer:
20+
# schema_dir: "absolute-path-to-schema-folder"
21+
services:
22+
MAGFIELDS:
23+
magfieldSolenoidMap: Symm_solenoid_r601_phi1_z1201_13June2018.dat
24+
magfieldTorusMap: Symm_torus_r2501_phi16_z251_24Apr2018.dat
25+
26+
mime-types:
27+
- binary/data-hipo

reconstruction/cvt/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
<groupId>junit</groupId>
9696
<artifactId>junit</artifactId>
9797
</dependency>
98+
<dependency>
99+
<groupId>org.jlab.jnp</groupId>
100+
<artifactId>jnp-hipo4</artifactId>
101+
</dependency>
98102
</dependencies>
99103

100104
</project>
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
import org.jlab.detector.base.DetectorType;
10+
import org.jlab.io.base.DataBank;
11+
import org.jlab.io.base.DataEvent;
12+
import org.jlab.rec.cvt.bmt.BMTType;
13+
import org.jlab.rec.cvt.hit.Hit;
14+
import org.jlab.rec.cvt.track.Seed;
15+
import org.jlab.rec.cvt.track.Track;
16+
17+
/**
18+
*
19+
* @author ziegler
20+
*/
21+
public class BankOutput {
22+
public static DataBank fillHitsBank(DataEvent event, List<ArrayList<Hit>>hits, String bankName) {
23+
if (hits == null || hits.isEmpty()) return null;
24+
DataBank bank = event.createBank(bankName, hits.get(0).size()+hits.get(1).size());
25+
int index=0;
26+
for(int i = 0; i < hits.size(); i++) {
27+
for(int j = 0; j < hits.get(i).size(); j++) {
28+
bank.setShort("id", index, (short) hits.get(i).get(j).getId());
29+
bank.setShort("sidx", index, (short) hits.get(i).get(j).getSeedBankRow());
30+
bank.setShort("tidx", index, (short) hits.get(i).get(j).getTrackBankRow());
31+
bank.setShort("recsid", index, (short) hits.get(i).get(j).getAssociatedSeedID());
32+
bank.setShort("rectid", index, (short) hits.get(i).get(j).getAssociatedTrackID());
33+
bank.setShort("mctid", index, (short) hits.get(i).get(j).getAssociateMCTrkId());
34+
bank.setByte("sector", index, (byte) hits.get(i).get(j).getSector());
35+
int layer = hits.get(i).get(j).getLayer();
36+
if(i>0) layer+=6;
37+
bank.setByte("layer", index, (byte) layer);
38+
bank.setByte("type", index, getType(hits.get(i).get(j)));
39+
bank.setShort("strip", index, (short) hits.get(i).get(j).getStrip().getStrip());
40+
bank.setByte("order", index, (byte) hits.get(i).get(j).MCstatus);
41+
bank.setShort("cid", index, (short) hits.get(i).get(j).getAssociatedClusterID());
42+
bank.setFloat("cweight", index, (float) hits.get(i).get(j).getCweight());
43+
bank.setFloat("sweight", index, (float) hits.get(i).get(j).getSweight());
44+
if(hits.get(i).get(j).getDetector()==DetectorType.BST ||
45+
(hits.get(i).get(j).getDetector()==DetectorType.BMT
46+
&& hits.get(i).get(j).getType()==BMTType.Z)) {
47+
bank.setFloat("x1", index, (float) hits.get(i).get(j).getStrip().getLine().origin().x()/10);
48+
bank.setFloat("y1", index, (float) hits.get(i).get(j).getStrip().getLine().origin().y()/10);
49+
bank.setFloat("z1", index, (float) hits.get(i).get(j).getStrip().getLine().origin().z()/10);
50+
bank.setFloat("x2", index, (float) hits.get(i).get(j).getStrip().getLine().end().x()/10);
51+
bank.setFloat("y2", index, (float) hits.get(i).get(j).getStrip().getLine().end().y()/10);
52+
bank.setFloat("z2", index, (float) hits.get(i).get(j).getStrip().getLine().end().z()/10);
53+
54+
}
55+
if(hits.get(i).get(j).getDetector()==DetectorType.BMT
56+
&& hits.get(i).get(j).getType()==BMTType.C) {
57+
bank.setFloat("x1", index, (float) hits.get(i).get(j).getStrip().getArc().origin().x()/10);
58+
bank.setFloat("y1", index, (float) hits.get(i).get(j).getStrip().getArc().origin().y()/10);
59+
bank.setFloat("z1", index, (float) hits.get(i).get(j).getStrip().getArc().origin().z()/10);
60+
bank.setFloat("x2", index, (float) hits.get(i).get(j).getStrip().getArc().end().x()/10);
61+
bank.setFloat("y2", index, (float) hits.get(i).get(j).getStrip().getArc().end().y()/10);
62+
bank.setFloat("z2", index, (float) hits.get(i).get(j).getStrip().getArc().end().z()/10);
63+
64+
}
65+
66+
index++;
67+
}
68+
}
69+
return bank;
70+
}
71+
72+
public static DataBank fillSeedsBank(DataEvent event, List<Seed> seeds, String bankName) {
73+
if (seeds == null || seeds.isEmpty()) return null;
74+
75+
DataBank bank = event.createBank(bankName, seeds.size());
76+
77+
for (int i = 0; i < seeds.size(); i++) {
78+
if(seeds.get(i)==null)
79+
continue;
80+
bank.setShort("id", i, (short) seeds.get(i).getId());
81+
bank.setFloat("purity", i, (float) seeds.get(i).getPurity());
82+
bank.setFloat("efficiency", i, (float) seeds.get(i).getEffs()[2]);
83+
}
84+
return bank;
85+
}
86+
87+
public static DataBank fillTracksBank(DataEvent event, List<Track> tracks, String bankName) {
88+
if (tracks == null || tracks.isEmpty()) return null;
89+
90+
DataBank bank = event.createBank(bankName, tracks.size());
91+
92+
for (int i = 0; i < tracks.size(); i++) {
93+
if(tracks.get(i)==null)
94+
continue;
95+
bank.setShort("id", i, (short) tracks.get(i).getId());
96+
bank.setFloat("purity", i, (float) tracks.get(i).getPurity());
97+
bank.setFloat("efficiency", i, (float) tracks.get(i).getEffs()[2]);
98+
}
99+
return bank;
100+
}
101+
102+
103+
private static byte getType(Hit h) {
104+
DetectorType detector = h.getDetector();
105+
106+
if (detector == DetectorType.BST) {
107+
return 0;
108+
}
109+
110+
if (detector == DetectorType.BMT) {
111+
BMTType type = h.getType();
112+
switch (type) {
113+
case Z: return 1;
114+
case C: return 2;
115+
default: return -1;
116+
}
117+
}
118+
119+
return -1;
120+
}
121+
122+
}

0 commit comments

Comments
 (0)