Skip to content

Commit ec5c5e1

Browse files
N-PlxChuramani PaudelWhitney Armstrong
authored
430 atof reconstruction (#436)
* Definition of atof hits * Definition of bar hits * Building hit lists * First clustering, to be revisited * ahdc track projection * Path length * Hits sorted by energy * Some more clustering algo, resolutions need to be set * Track projection bank def * Track projection to the middle of elements * Track projection surfaces redefinition * Some naming conventions * Handling parameters + method for testing * Handling parameters + bank input * Correcting conversion to MeV * Refactoring BarHit definition, now inherits from AtofHit * ATOF hit bank * ATOF bank writer * viewed clustering logic * will work on this branch * proximity checks for ClusterFinder::improved logic * Fixing conversions tdc/tot to time/energy and cleanup * Fixing time/energy computation and some cleanup * Fixing energy sorting and some cleanup * handling clustering parameters * cluster parameters definition * fix hit order * cluster bank definition * charge sign fix and projection from MC Particle info * draft atof engine to be completed * appending output banks * fix:but writing output banks * style: naming conventions and some cleaning * style: fixed naming conventions and some cleaning * fix: file name matches class name * style: some more documentation * refactor: move writing of the projection bank * Definition of atof hits * Definition of bar hits * Building hit lists * First clustering, to be revisited * ahdc track projection * Path length * Hits sorted by energy * Some more clustering algo, resolutions need to be set * Track projection bank def * Track projection to the middle of elements * Track projection surfaces redefinition * Some naming conventions * Handling parameters + method for testing * Handling parameters + bank input * Correcting conversion to MeV * Refactoring BarHit definition, now inherits from AtofHit * ATOF hit bank * ATOF bank writer * viewed clustering logic * will work on this branch * proximity checks for ClusterFinder::improved logic * Fixing conversions tdc/tot to time/energy and cleanup * Fixing time/energy computation and some cleanup * Fixing energy sorting and some cleanup * handling clustering parameters * cluster parameters definition * fix hit order * cluster bank definition * charge sign fix and projection from MC Particle info * draft atof engine to be completed * appending output banks * fix:but writing output banks * style: naming conventions and some cleaning * style: fixed naming conventions and some cleaning * fix: file name matches class name * style: some more documentation * refactor: move writing of the projection bank * refactor: move track matching from hit to cluster level * refactor: changing paths * feat: reading magnetic field using swimmer tools * fix: missing closing bracket * Renamed things to use ATOF instead of Atof * More name changes * Missed bank name change. * Missed AHDC -> ALERT Projections --------- Co-authored-by: Churamani Paudel <[email protected]> Co-authored-by: Whitney Armstrong <[email protected]>
1 parent e4be634 commit ec5c5e1

File tree

11 files changed

+2184
-180
lines changed

11 files changed

+2184
-180
lines changed

etc/bankdefs/hipo4/alert.json

Lines changed: 320 additions & 180 deletions
Large diffs are not rendered by default.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
package org.jlab.rec.atof.banks;
2+
3+
import java.util.ArrayList;
4+
import org.jlab.io.base.DataBank;
5+
import org.jlab.io.base.DataEvent;
6+
import org.jlab.rec.atof.cluster.ATOFCluster;
7+
import org.jlab.rec.atof.hit.ATOFHit;
8+
import org.jlab.rec.atof.hit.BarHit;
9+
import org.jlab.rec.atof.trackMatch.TrackProjection;
10+
11+
/**
12+
* The {@code RecoBankWriter} writes the banks needed for the atof
13+
* reconstruction: track projections, hits and clusters info.
14+
*
15+
* @author pilleux
16+
*/
17+
public class RecoBankWriter {
18+
19+
/**
20+
* Writes the bank of atof hits.
21+
*
22+
* @param event the {@link DataEvent} in which to add the bank
23+
* @param wedgeHits the {@link ArrayList} of {@link ATOFHit} containing the
24+
* wedge hits to be added to the bank
25+
* @param barHits the {@link ArrayList} of {@link BarHit} containing the bar
26+
* hits to be added to the bank
27+
*
28+
* @return {@link DataBank} the bank with all the hits read in the event.
29+
*
30+
*/
31+
public static DataBank fillATOFHitBank(DataEvent event, ArrayList<ATOFHit> wedgeHits, ArrayList<BarHit> barHits) {
32+
33+
ArrayList<ATOFHit> hitList = new ArrayList<>();
34+
hitList.addAll(wedgeHits);
35+
hitList.addAll(barHits);
36+
37+
DataBank bank = event.createBank("ATOF::hits", hitList.size());
38+
39+
if (bank == null) {
40+
System.err.println("COULD NOT CREATE A ATOF::hits BANK!!!!!!");
41+
return null;
42+
}
43+
44+
for (int i = 0; i < hitList.size(); i++) {
45+
bank.setShort("id", i, (short) (i + 1));
46+
bank.setInt("sector", i, (int) hitList.get(i).getSector());
47+
bank.setInt("layer", i, (int) hitList.get(i).getLayer());
48+
bank.setInt("component", i, (int) hitList.get(i).getComponent());
49+
bank.setFloat("time", i, (float) hitList.get(i).getTime());
50+
bank.setFloat("x", i, (float) (hitList.get(i).getX()));
51+
bank.setFloat("y", i, (float) (hitList.get(i).getY()));
52+
bank.setFloat("z", i, (float) (hitList.get(i).getZ()));
53+
bank.setFloat("energy", i, (float) hitList.get(i).getEnergy());
54+
}
55+
return bank;
56+
}
57+
58+
/**
59+
* Writes the bank of atof clusters.
60+
*
61+
* @param event the {@link DataEvent} in which to add the bank
62+
* @param clusterList the {@link ArrayList} of {@link ATOFCluster}
63+
* containing the clusters info to be added to the bank
64+
*
65+
* @return {@link DataBank} the bank with all the clusters built in the
66+
* event.
67+
*
68+
*/
69+
public static DataBank fillATOFClusterBank(DataEvent event, ArrayList<ATOFCluster> clusterList) {
70+
71+
DataBank bank = event.createBank("ATOF::clusters", clusterList.size());
72+
73+
if (bank == null) {
74+
System.err.println("COULD NOT CREATE A ATOF::clusters BANK!!!!!!");
75+
return null;
76+
}
77+
78+
for (int i = 0; i < clusterList.size(); i++) {
79+
bank.setShort("id", i, (short) (i + 1));
80+
bank.setInt("N_bar", i, (int) clusterList.get(i).getBarHits().size());
81+
bank.setInt("N_wedge", i, (int) clusterList.get(i).getWedgeHits().size());
82+
bank.setFloat("time", i, (float) clusterList.get(i).getTime());
83+
bank.setFloat("x", i, (float) (clusterList.get(i).getX()));
84+
bank.setFloat("y", i, (float) (clusterList.get(i).getY()));
85+
bank.setFloat("z", i, (float) (clusterList.get(i).getZ()));
86+
bank.setFloat("energy", i, (float) clusterList.get(i).getEnergy());
87+
}
88+
return bank;
89+
}
90+
91+
/**
92+
* Writes the bank of track projections.
93+
*
94+
* @param event the {@link DataEvent} in which to add the bank
95+
* @param projections the {@link ArrayList} of {@link TrackProjection}
96+
* containing the track projection info to be added to the bank
97+
*
98+
* @return {@link DataBank} the bank with all the projected tracks in the
99+
* event.
100+
*
101+
*/
102+
public static DataBank fillProjectionsBank(DataEvent event, ArrayList<TrackProjection> projections) {
103+
104+
DataBank bank = event.createBank("ALERT::Projections", projections.size());
105+
106+
if (bank == null) {
107+
System.err.println("COULD NOT CREATE A ALERT::Projections BANK!!!!!!");
108+
return null;
109+
}
110+
111+
for (int i = 0; i < projections.size(); i++) {
112+
TrackProjection projection = projections.get(i);
113+
bank.setFloat("x_at_bar", i, (float) projection.getBarIntersect().x());
114+
bank.setFloat("y_at_bar", i, (float) projection.getBarIntersect().y());
115+
bank.setFloat("z_at_bar", i, (float) projection.getBarIntersect().z());
116+
bank.setFloat("L_at_bar", i, (float) projection.getBarPathLength());
117+
bank.setFloat("L_in_bar", i, (float) projection.getBarInPathLength());
118+
bank.setFloat("x_at_wedge", i, (float) projection.getWedgeIntersect().x());
119+
bank.setFloat("y_at_wedge", i, (float) projection.getWedgeIntersect().y());
120+
bank.setFloat("z_at_wedge", i, (float) projection.getWedgeIntersect().z());
121+
bank.setFloat("L_at_wedge", i, (float) projection.getWedgePathLength());
122+
bank.setFloat("L_in_wedge", i, (float) projection.getWedgeInPathLength());
123+
}
124+
return bank;
125+
}
126+
127+
/**
128+
* Appends the atof banks to an event.
129+
*
130+
* @param event the {@link DataEvent} in which to append the banks
131+
* @param clusterList the {@link ArrayList} of {@link ATOFCluster}
132+
* containing the clusters info to be added to the bank
133+
* @param wedgeHits the {@link ArrayList} of {@link ATOFHit} containing the
134+
* wedge hits info to be added
135+
* @param barHits the {@link ArrayList} of {@link BarHit} containing the bar
136+
* hits info to be added
137+
*
138+
* @return 0 if it worked, 1 if it failed
139+
*
140+
*/
141+
public int appendATOFBanks(DataEvent event, ArrayList<ATOFHit> wedgeHits, ArrayList<BarHit> barHits, ArrayList<ATOFCluster> clusterList) {
142+
143+
DataBank hitbank = this.fillATOFHitBank(event, wedgeHits, barHits);
144+
if (hitbank != null) {
145+
event.appendBank(hitbank);
146+
} else {
147+
return 1;
148+
}
149+
150+
DataBank clusterbank = fillATOFClusterBank(event, clusterList);
151+
if (clusterbank != null) {
152+
event.appendBank(clusterbank);
153+
} else {
154+
return 1;
155+
}
156+
157+
return 0;
158+
}
159+
160+
/**
161+
* Appends the alert match banks to an event.
162+
*
163+
* @param event the {@link DataEvent} in which to append the banks
164+
* @param projections the {@link ArrayList} of {@link TrackProjection} containing the
165+
* track projections info to be added
166+
*
167+
* @return 0 if it worked, 1 if it failed
168+
*
169+
*/
170+
public int appendMatchBanks(DataEvent event, ArrayList<TrackProjection> projections) {
171+
172+
DataBank projbank = this.fillProjectionsBank(event, projections);
173+
if (projbank != null) {
174+
event.appendBank(projbank);
175+
} else {
176+
return 1;
177+
}
178+
return 0;
179+
}
180+
181+
/**
182+
* @param args the command line arguments
183+
*/
184+
public static void main(String[] args) {
185+
}
186+
187+
}

0 commit comments

Comments
 (0)