66import org .jlab .rec .atof .cluster .AtofCluster ;
77import org .jlab .rec .atof .hit .AtofHit ;
88import org .jlab .rec .atof .hit .BarHit ;
9+ import org .jlab .rec .atof .trackMatch .TrackProjection ;
910
1011/**
11- * The {@code RecoBankWriter} writes the banks needed for the atof reconstruction:
12- * track projections, hits and clusters info.
13- *
12+ * The {@code RecoBankWriter} writes the banks needed for the atof
13+ * reconstruction: track projections, hits and clusters info.
14+ *
1415 * @author pilleux
1516 */
1617public class RecoBankWriter {
17-
18+
1819 /**
1920 * Writes the bank of atof hits.
20- *
21+ *
2122 * @param event the {@link DataEvent} in which to add the bank
22- * @param wedgeHits the {@link ArrayList} of {@link AtofHit}
23- * containing the wedge hits to be added to the bank
24- * @param barHits the {@link ArrayList} of {@link BarHit}
25- * containing the bar hits to be added to the bank
26- *
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+ *
2728 * @return {@link DataBank} the bank with all the hits read in the event.
28- *
29+ *
2930 */
3031 public static DataBank fillAtofHitBank (DataEvent event , ArrayList <AtofHit > wedgeHits , ArrayList <BarHit > barHits ) {
31-
32+
3233 ArrayList <AtofHit > hitList = new ArrayList <>();
3334 hitList .addAll (wedgeHits );
3435 hitList .addAll (barHits );
35-
36- DataBank bank = event .createBank ("ATOF::hits" , hitList .size ());
37-
36+
37+ DataBank bank = event .createBank ("ATOF::hits" , hitList .size ());
38+
3839 if (bank == null ) {
3940 System .err .println ("COULD NOT CREATE A ATOF::hits BANK!!!!!!" );
4041 return null ;
4142 }
42-
43- for (int i =0 ; i < hitList .size (); i ++) {
44- bank .setShort ("id" ,i , (short )( i + 1 ));
45- bank .setInt ("sector" ,i , (int ) hitList .get (i ).getSector ());
46- bank .setInt ("layer" ,i , (int ) hitList .get (i ).getLayer ());
47- bank .setInt ("component" ,i , (int ) hitList .get (i ).getComponent ());
48- bank .setFloat ("time" ,i , (float ) hitList .get (i ).getTime ());
49- bank .setFloat ("x" ,i , (float ) (hitList .get (i ).getX ()));
50- bank .setFloat ("y" ,i , (float ) (hitList .get (i ).getY ()));
51- bank .setFloat ("z" ,i , (float ) (hitList .get (i ).getZ ()));
52- bank .setFloat ("energy" ,i , (float ) hitList .get (i ).getEnergy ());
53- bank .setFloat ("inlength" ,i , (float ) (hitList .get (i ).getInPathLength ()));
54- bank .setFloat ("pathlength" ,i , (float ) (hitList .get (i ).getPathLength ()));
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+ bank .setFloat ("inlength" , i , (float ) (hitList .get (i ).getInPathLength ()));
55+ bank .setFloat ("pathlength" , i , (float ) (hitList .get (i ).getPathLength ()));
5556 }
5657 return bank ;
5758 }
58-
59+
5960 /**
6061 * Writes the bank of atof clusters.
61- *
62+ *
6263 * @param event the {@link DataEvent} in which to add the bank
63- * @param clusterList the {@link ArrayList} of {@link AtofCluster}
64+ * @param clusterList the {@link ArrayList} of {@link AtofCluster}
6465 * containing the clusters info to be added to the bank
65- *
66- * @return {@link DataBank} the bank with all the clusters built in the event.
67- *
66+ *
67+ * @return {@link DataBank} the bank with all the clusters built in the
68+ * event.
69+ *
6870 */
6971 public static DataBank fillAtofClusterBank (DataEvent event , ArrayList <AtofCluster > clusterList ) {
70-
71- DataBank bank = event .createBank ("ATOF::clusters" , clusterList .size ());
72-
72+
73+ DataBank bank = event .createBank ("ATOF::clusters" , clusterList .size ());
74+
7375 if (bank == null ) {
7476 System .err .println ("COULD NOT CREATE A ATOF::clusters BANK!!!!!!" );
7577 return null ;
7678 }
77-
78- for (int i =0 ; i < clusterList .size (); i ++) {
79- bank .setShort ("id" ,i , (short )( i + 1 ));
80- bank .setInt ("barsize" ,i , (int ) clusterList .get (i ).getBarHits ().size ());
81- bank .setInt ("wedgesize" ,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- bank .setFloat ("inpathlength" ,i , (float ) (clusterList .get (i ).getInPathLength ()));
88- bank .setFloat ("pathlength" ,i , (float ) (clusterList .get (i ).getPathLength ()));
79+
80+ for (int i = 0 ; i < clusterList .size (); i ++) {
81+ bank .setShort ("id" , i , (short ) ( i + 1 ));
82+ bank .setInt ("barsize" , i , (int ) clusterList .get (i ).getBarHits ().size ());
83+ bank .setInt ("wedgesize" , i , (int ) clusterList .get (i ).getWedgeHits ().size ());
84+ bank .setFloat ("time" , i , (float ) clusterList .get (i ).getTime ());
85+ bank .setFloat ("x" , i , (float ) (clusterList .get (i ).getX ()));
86+ bank .setFloat ("y" , i , (float ) (clusterList .get (i ).getY ()));
87+ bank .setFloat ("z" , i , (float ) (clusterList .get (i ).getZ ()));
88+ bank .setFloat ("energy" , i , (float ) clusterList .get (i ).getEnergy ());
89+ bank .setFloat ("inpathlength" , i , (float ) (clusterList .get (i ).getInPathLength ()));
90+ bank .setFloat ("pathlength" , i , (float ) (clusterList .get (i ).getPathLength ()));
8991 }
9092 return bank ;
9193 }
92-
94+
95+ /**
96+ * Writes the bank of track projections.
97+ *
98+ * @param event the {@link DataEvent} in which to add the bank
99+ * @param projections the {@link ArrayList} of {@link TrackProjection}
100+ * containing the track projection info to be added to the bank
101+ *
102+ * @return {@link DataBank} the bank with all the projected tracks in the
103+ * event.
104+ *
105+ */
106+ public static DataBank fillProjectionsBank (DataEvent event , ArrayList <TrackProjection > projections ) {
107+
108+ DataBank bank = event .createBank ("AHDC::Projections" , projections .size ());
109+
110+ if (bank == null ) {
111+ System .err .println ("COULD NOT CREATE A AHDC::Projections BANK!!!!!!" );
112+ return null ;
113+ }
114+
115+ for (int i = 0 ; i < projections .size (); i ++) {
116+ TrackProjection projection = projections .get (i );
117+ bank .setFloat ("x_at_bar" , i , (float ) projection .getBarIntersect ().x ());
118+ bank .setFloat ("y_at_bar" , i , (float ) projection .getBarIntersect ().y ());
119+ bank .setFloat ("z_at_bar" , i , (float ) projection .getBarIntersect ().z ());
120+ bank .setFloat ("L_at_bar" , i , (float ) projection .getBarPathLength ());
121+ bank .setFloat ("L_in_bar" , i , (float ) projection .getBarInPathLength ());
122+ bank .setFloat ("x_at_wedge" , i , (float ) projection .getWedgeIntersect ().x ());
123+ bank .setFloat ("y_at_wedge" , i , (float ) projection .getWedgeIntersect ().y ());
124+ bank .setFloat ("z_at_wedge" , i , (float ) projection .getWedgeIntersect ().z ());
125+ bank .setFloat ("L_at_wedge" , i , (float ) projection .getWedgePathLength ());
126+ bank .setFloat ("L_in_wedge" , i , (float ) projection .getWedgeInPathLength ());
127+ }
128+ return bank ;
129+ }
130+
93131 /**
94132 * Appends the atof banks to an event.
95- *
133+ *
96134 * @param event the {@link DataEvent} in which to append the banks
97- * @param clusterList the {@link ArrayList} of {@link AtofCluster}
135+ * @param clusterList the {@link ArrayList} of {@link AtofCluster}
98136 * containing the clusters info to be added to the bank
99- * @param wedgeHits the {@link ArrayList} of {@link AtofHit}
100- * containing the wedge hits info to be added
101- * @param barHits the {@link ArrayList} of {@link BarHit}
102- * containing the bar hits info to be added
103- *
137+ * @param wedgeHits the {@link ArrayList} of {@link AtofHit} containing the
138+ * wedge hits info to be added
139+ * @param barHits the {@link ArrayList} of {@link BarHit} containing the bar
140+ * hits info to be added
141+ * @param projections the {@link ArrayList} of {@link TrackProjection} containing the
142+ * track projections info to be added
143+ *
104144 * @return 0 if it worked, 1 if it failed
105- *
145+ *
106146 */
107- public int appendAtofBanks (DataEvent event , ArrayList <AtofHit > wedgeHits , ArrayList <BarHit > barHits , ArrayList <AtofCluster > clusterList ) {
147+ public int appendAtofBanks (DataEvent event , ArrayList <AtofHit > wedgeHits , ArrayList <BarHit > barHits , ArrayList <AtofCluster > clusterList , ArrayList <TrackProjection > projections ) {
148+
149+ DataBank projbank = this .fillProjectionsBank (event , projections );
150+ if (projbank != null ) {
151+ event .appendBank (projbank );
152+ } else {
153+ return 1 ;
154+ }
108155
109156 DataBank hitbank = this .fillAtofHitBank (event , wedgeHits , barHits );
110157 if (hitbank != null ) {
111158 event .appendBank (hitbank );
159+ } else {
160+ return 1 ;
112161 }
113- else return 1 ;
114162
115163 DataBank clusterbank = fillAtofClusterBank (event , clusterList );
116164 if (clusterbank != null ) {
117165 event .appendBank (clusterbank );
166+ } else {
167+ return 1 ;
118168 }
119- else return 1 ;
120-
169+
121170 return 0 ;
122171 }
123172
@@ -126,5 +175,5 @@ public int appendAtofBanks(DataEvent event, ArrayList<AtofHit> wedgeHits, ArrayL
126175 */
127176 public static void main (String [] args ) {
128177 }
129-
178+
130179}
0 commit comments