Skip to content

Commit 84a4625

Browse files
N-Plxwhit2333
authored andcommitted
style: some more documentation
1 parent 9e71804 commit 84a4625

File tree

5 files changed

+233
-45
lines changed

5 files changed

+233
-45
lines changed

reconstruction/alert/src/main/java/org/jlab/rec/atof/Cluster/AtofCluster.java

Lines changed: 103 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,32 @@
55
import org.jlab.rec.atof.hit.BarHit;
66

77
/**
8+
* The {@code AtofCluster} represents clusters in the atof
89
*
9-
* @author npilleux
10+
* <p>
11+
* Create clusters and compute their basic properties from the hits composing
12+
* them.
13+
* </p>
14+
*
15+
* @author pilleux
1016
*/
1117
public class AtofCluster {
12-
18+
19+
/**
20+
* list of hits in the bars.
21+
*/
1322
ArrayList<BarHit> barHits;
23+
/**
24+
* list of hits in the wedges.
25+
*/
1426
ArrayList<AtofHit> wedgeHits;
15-
double x,y,z,time,energy;
27+
/**
28+
* cluster properties:position [cm], time [ns], energy[MeV], path length
29+
* [cm] and length through the atof [cm].
30+
*/
31+
double x, y, z, time, energy;
1632
double pathLength, inPathLength;
17-
33+
1834
public ArrayList<BarHit> getBarHits() {
1935
return barHits;
2036
}
@@ -70,58 +86,66 @@ public double getEnergy() {
7086
public void setEnergy(double energy) {
7187
this.energy = energy;
7288
}
73-
89+
7490
public double getPathLength() {
7591
return pathLength;
7692
}
7793

7894
public void setPathLength(double pathLength) {
7995
this.pathLength = pathLength;
8096
}
81-
97+
8298
public double getInPathLength() {
8399
return inPathLength;
84100
}
85101

86102
public void setInPathLength(double inPathLength) {
87103
this.inPathLength = inPathLength;
88104
}
89-
90-
//Cluster coordinates and time are defined as the coordinates and time of the max energy hit
91-
//Can be changed later
105+
106+
/**
107+
* Compute the cluster properties.
108+
*
109+
* Cluster coordinates and time are defined as the coordinates and time of
110+
* the max energy hit.
111+
*
112+
* TO DO: Test other choices for the definitions.
113+
*
114+
*/
92115
public final void computeClusterProperties() {
93-
this.energy=0;
116+
this.energy = 0;
94117
double max_energy = -1;
95118
AtofHit max_energy_hit = new AtofHit();
96119
BarHit max_energy_barhit = new BarHit();
97120

98-
for(int i_wedge = 0; i_wedge<this.wedgeHits.size(); i_wedge++)
99-
{
121+
for (int i_wedge = 0; i_wedge < this.wedgeHits.size(); i_wedge++) {
100122
AtofHit this_wedge_hit = this.wedgeHits.get(i_wedge);
101123
double this_energy = this_wedge_hit.getEnergy();
102-
this.energy+=this_energy;
103-
if(this_energy>max_energy){max_energy_hit = this_wedge_hit; max_energy = this_energy;}
124+
this.energy += this_energy;
125+
if (this_energy > max_energy) {
126+
max_energy_hit = this_wedge_hit;
127+
max_energy = this_energy;
128+
}
104129
}
105-
106-
for(int i_bar = 0; i_bar<this.barHits.size(); i_bar++)
107-
{
130+
131+
for (int i_bar = 0; i_bar < this.barHits.size(); i_bar++) {
108132
BarHit this_bar_hit = this.barHits.get(i_bar);
109133
double this_energy = this_bar_hit.getEnergy();
110-
this.energy+=this_energy;
111-
if(this_energy>max_energy){max_energy_barhit = this_bar_hit; max_energy = this_energy;}
134+
this.energy += this_energy;
135+
if (this_energy > max_energy) {
136+
max_energy_barhit = this_bar_hit;
137+
max_energy = this_energy;
138+
}
112139
}
113-
114-
if(max_energy_hit.getEnergy() > max_energy_barhit.getEnergy())
115-
{
140+
141+
if (max_energy_hit.getEnergy() > max_energy_barhit.getEnergy()) {
116142
this.time = max_energy_hit.getTime();
117143
this.x = max_energy_hit.getX();
118144
this.y = max_energy_hit.getY();
119145
this.z = max_energy_hit.getZ();
120146
this.pathLength = max_energy_hit.getPathLength();
121147
this.inPathLength = max_energy_hit.getInPathLength();
122-
}
123-
else
124-
{
148+
} else {
125149
this.time = max_energy_barhit.getTime();
126150
this.x = max_energy_barhit.getX();
127151
this.y = max_energy_barhit.getY();
@@ -130,28 +154,66 @@ public final void computeClusterProperties() {
130154
this.inPathLength = max_energy_barhit.getInPathLength();
131155
}
132156
}
133-
134-
public double getPhi()
135-
{
136-
return Math.atan2(this.y, this.x);
157+
158+
public double getEdepWedge() {
159+
double energy = 0;
160+
for (int i = 0; i < this.wedgeHits.size(); i++) {
161+
AtofHit this_hit = this.wedgeHits.get(i);
162+
energy += this_hit.getEnergy();
163+
}
164+
return energy;
137165
}
138-
139-
public double getBeta()
140-
{
141-
return (this.pathLength / this.time) / (2.9979 * Math.pow(10, 2));//to do: Change to non-hardcoded value for c
142-
}
143-
144-
public AtofCluster(ArrayList<BarHit> bar_hits, ArrayList<AtofHit> wedge_hits)
145-
{
146-
this.barHits = bar_hits;
147-
this.wedgeHits = wedge_hits;
148-
this.computeClusterProperties();
166+
167+
public double getEdepBar() {
168+
double energy = 0;
169+
for (int i = 0; i < this.barHits.size(); i++) {
170+
AtofHit this_hit = this.barHits.get(i);
171+
energy += this_hit.getEnergy();
149172
}
173+
return energy;
174+
}
175+
176+
/**
177+
* Compute the cluster phi angle in radians.
178+
*
179+
* @return a double that is angle in radians
180+
*
181+
*/
182+
public double getPhi() {
183+
return Math.atan2(this.y, this.x);
184+
}
185+
186+
/**
187+
* Compute the cluster beta from the path length and time.
188+
*
189+
* @return a double that is beta
190+
*
191+
* - TO DO: Change to non-hardcoded value for c
192+
*
193+
*/
194+
public double getBeta() {
195+
//Need to change to non hardcoded value
196+
return (this.pathLength / this.time) / (2.9979 * Math.pow(10, 2));
197+
}
198+
199+
/**
200+
* Constructor that initializes the list of bar hits and list of wedge hits
201+
* and computes the cluster properties.
202+
*
203+
* @param bar_hits a {@link ArrayList} of {@link BarHit}.
204+
* @param wedge_hits a {@link ArrayList} of {@link AtofHit}.
205+
*
206+
*/
207+
public AtofCluster(ArrayList<BarHit> bar_hits, ArrayList<AtofHit> wedge_hits) {
208+
this.barHits = bar_hits;
209+
this.wedgeHits = wedge_hits;
210+
this.computeClusterProperties();
211+
}
150212

151213
/**
152214
* @param args the command line arguments
153215
*/
154216
public static void main(String[] args) {
155217
}
156-
218+
157219
}

reconstruction/alert/src/main/java/org/jlab/rec/atof/Cluster/ClusterFinder.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,51 @@
88
import org.jlab.rec.atof.hit.HitFinder;
99

1010
/**
11+
* The {@code ClusterFinder} class builds clusters in the atof
1112
*
12-
* @author npilleux
13+
* <p>
14+
* Uses found hits information.
15+
* Creates a {@link AtofCluster} matching them.
16+
* </p>
17+
*
18+
* @author pilleux
1319
*/
1420
public class ClusterFinder {
1521

22+
/**
23+
* list of clusters.
24+
*/
1625
private ArrayList<AtofCluster> clusters;
1726

27+
/**
28+
* Sets the list of clusters.
29+
*
30+
* @param clusters a {@link ArrayList} of {@link AtofCluster}.
31+
*
32+
*/
1833
public void setClusters(ArrayList<AtofCluster> clusters) {
1934
this.clusters = clusters;
2035
}
2136

37+
/**
38+
* Gets the list of clusters.
39+
*
40+
* @return a {@link ArrayList} of {@link AtofCluster}.
41+
*
42+
*/
2243
public ArrayList<AtofCluster> getClusters() {
2344
return clusters;
2445
}
2546

47+
/**
48+
* Builds clusters in the {@link DateEvent} using hits found and
49+
* stored in a {@link HitFinder}.
50+
*
51+
* @param event the {@link DataEvent} containing the clusters to be built
52+
*
53+
* @param hitfinder the {@link HitFinder} containing the hits that were found
54+
*
55+
*/
2656
public void makeClusters(DataEvent event, HitFinder hitfinder) {
2757

2858
//A list of clusters is built for each event
@@ -162,6 +192,10 @@ public void makeClusters(DataEvent event, HitFinder hitfinder) {
162192
}
163193
}
164194

195+
/**
196+
* Default constructor that initializes the list clusters as new empty
197+
* list.
198+
*/
165199
public ClusterFinder() {
166200
clusters = new ArrayList<>();
167201
}

reconstruction/alert/src/main/java/org/jlab/rec/atof/Hit/AtofHit.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,19 @@ public void setInPathLength(double inpath_length) {
147147
this.inPathLength = inpath_length;
148148
}
149149

150+
/**
151+
* Computes the module index for the hit.
152+
*
153+
*/
150154
public int computeModuleIndex() {
151155
//Index ranging 0 to 60 for each wedge+bar module
152156
return 4 * this.sector + this.layer;
153157
}
154158

159+
/**
160+
* Assigns a type to the hit.
161+
*
162+
*/
155163
public final String makeType() {
156164
//Type of hit can be wedge, bar up, bar down or bar.
157165
//Avoids testing components and order every time.
@@ -458,6 +466,15 @@ public final void matchTrack(TrackProjector track_projector) {
458466
}
459467
}
460468

469+
/**
470+
* Matches the current track with ahdc tracks projections that have been written to the banks.
471+
* Calculates the match by comparing the hit's azimuthal angle and longitudinal position
472+
* (z) with the track projection. If a match is found within defined
473+
* tolerances for phi and z, the path length of the matched hit is updated.
474+
*
475+
* @param event a @link{DataEvent} in which the track projections bank has been written.
476+
*
477+
*/
461478
public int matchTrack(DataEvent event) {
462479

463480
String track_bank_name = "AHDC::Projections";

reconstruction/alert/src/main/java/org/jlab/rec/atof/Hit/HitFinder.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,33 @@
88
import org.jlab.rec.atof.trackMatch.TrackProjector;
99

1010
/**
11+
* The {@code HitFinder} class finds hits in the atof.
12+
*
13+
* <p>
14+
* Uses atof tdc bank information
15+
*
16+
* Creates a {@link ArrayList} of {@link BarHit} for bar hits read.
17+
* Creates a {@link ArrayList} of {@link AtofHit} for wedge hits read.
18+
*
19+
* </p>
1120
*
12-
* @author npilleux
21+
* @author pilleux
1322
*/
1423
public class HitFinder {
1524

25+
/**
26+
* list of bar hits
27+
*/
1628
private ArrayList<BarHit> barHits;
29+
/**
30+
* list of wedge hits
31+
*/
1732
private ArrayList<AtofHit> wedgeHits;
1833

34+
/**
35+
* Default constructor that initializes the list of hits as new empty
36+
* lists.
37+
*/
1938
public HitFinder() {
2039
this.barHits = new ArrayList<>();
2140
this.wedgeHits = new ArrayList<>();
@@ -38,6 +57,16 @@ public void setWedgeHits(ArrayList<AtofHit> wedge_hits) {
3857
this.wedgeHits = wedge_hits;
3958
}
4059

60+
/**
61+
* Find hits in the event, matches them to tracks found in the ahdc
62+
* and build their properties.
63+
*
64+
* @param event the {@link DataEvent} containing hits.
65+
* @param atof the {@link Detector} representing the atof geometry to match
66+
* the sector/layer/component to x/y/z.
67+
* @param track_projector the {@link TrackProjector} containing the ahdc tracks projected
68+
* to the atof for matching.
69+
*/
4170
public void findHits(DataEvent event, Detector atof, TrackProjector track_projector) {
4271
//For each event a list of bar hits and a list of wedge hits are filled
4372
this.barHits.clear();
@@ -103,6 +132,14 @@ public void findHits(DataEvent event, Detector atof, TrackProjector track_projec
103132
Collections.sort(this.wedgeHits, (hit1, hit2) -> Double.compare(hit2.getEnergy(), hit1.getEnergy()));
104133
}
105134

135+
/**
136+
* Find hits in the event, matches them to tracks in the
137+
* projections bank and build their properties.
138+
*
139+
* @param event the {@link DataEvent} containing hits and the bank with ahdc track projections.
140+
* @param atof the {@link Detector} representing the atof geometry to match
141+
* the sector/layer/component to x/y/z.
142+
*/
106143
public void findHits(DataEvent event, Detector atof) {
107144

108145
//For each event a list of bar hits and a list of wedge hits are filled

0 commit comments

Comments
 (0)