-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
reconstruction/alert/src/main/java/org/jlab/rec/atof/TrackMatch/TrackProjection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package org.jlab.rec.atof.TrackMatch; | ||
|
||
import org.jlab.geom.prim.Point3D; | ||
|
||
/** | ||
* The {@code TrackProjection} class holds ahdc track information relevant for atof analysis | ||
* i.e projected to the inner surfaces of the bar and wedges | ||
* @author pilleux | ||
*/ | ||
|
||
public class TrackProjection { | ||
|
||
/** | ||
* Intersection point of the track with the inner surface of the bar. | ||
*/ | ||
private Point3D _BarIntersect = new Point3D(); | ||
|
||
/** | ||
* Intersection point of the track with the inner surface of the wedges. | ||
*/ | ||
private Point3D _WedgeIntersect = new Point3D(); | ||
|
||
/** | ||
* Path length of the track from the DOCA to the beam line | ||
* to the inner surface of the bar. | ||
*/ | ||
Float _BarPathLength; | ||
|
||
/** | ||
* Path length of the track from the DOCA to the beam line | ||
* to the inner surface of the wedges. | ||
*/ | ||
Float _WedgePathLength; | ||
|
||
/** | ||
* Default constructor that initializes the intersection points and path lengths to {@code NaN}. | ||
*/ | ||
public TrackProjection() { | ||
_BarIntersect = new Point3D(Double.NaN, Double.NaN, Double.NaN); | ||
_WedgeIntersect = new Point3D(Double.NaN, Double.NaN, Double.NaN); | ||
_BarPathLength = Float.NaN; | ||
_WedgePathLength = Float.NaN; | ||
} | ||
|
||
/** | ||
* Gets the intersection point of the track with the inner surface of the bar. | ||
* | ||
* @return {@link Point3D} bar's intersection point. | ||
*/ | ||
public Point3D get_BarIntersect() { | ||
return _BarIntersect; | ||
} | ||
|
||
/** | ||
* Gets the intersection point of the track with the inner surface of the wedges. | ||
* | ||
* @return {@link Point3D} wedge's intersection point. | ||
*/ | ||
public Point3D get_WedgeIntersect() { | ||
return _WedgeIntersect; | ||
} | ||
|
||
/** | ||
* Gets the path length of the track from the DOCA to the beam line to the inner surface of the bar. | ||
* | ||
* @return {@code Float} path length to the bar's inner surface. | ||
*/ | ||
public Float get_BarPathLength() { | ||
return _BarPathLength; | ||
} | ||
|
||
/** | ||
* Gets the path length of the track from the DOCA to the beam line to the inner surface of the wedges. | ||
* | ||
* @return {@code Float} path length to the wedge's inner surface. | ||
*/ | ||
public Float get_WedgePathLength() { | ||
return _WedgePathLength; | ||
} | ||
|
||
/** | ||
* Sets the intersection point of the track with the inner surface of the bar. | ||
* | ||
* @param BarIntersect {@link Point3D} intersection with the bar. | ||
*/ | ||
public void set_BarIntersect(Point3D BarIntersect) { | ||
this._BarIntersect = BarIntersect; | ||
} | ||
|
||
/** | ||
* Sets the intersection point of the track with the inner surface of the wedges. | ||
* | ||
* @param WedgeIntersect {@link Point3D} intersection with the wedge. | ||
*/ | ||
public void set_WedgeIntersect(Point3D WedgeIntersect) { | ||
this._WedgeIntersect = WedgeIntersect; | ||
} | ||
|
||
/** | ||
* Sets the path length of the track from the DOCA to the beam line to the inner surface of the bar. | ||
* | ||
* @param BarPathLength {@code Float} path length to the bar inner surface. | ||
*/ | ||
public void set_BarPathLength(Float BarPathLength) { | ||
this._BarPathLength = BarPathLength; | ||
} | ||
|
||
/** | ||
* Sets the path length of the track from the DOCA to the beam line to the inner surface of the wedges. | ||
* | ||
* @param WedgePathLength {@code Float} path length to the wedge inner surface. | ||
*/ | ||
public void set_WedgePathLength(Float WedgePathLength) { | ||
this._WedgePathLength = WedgePathLength; | ||
} | ||
|
||
/** | ||
* testing purposes. | ||
* | ||
* @param arg command-line arguments. | ||
*/ | ||
public static void main(String arg[]) { | ||
} | ||
} |
196 changes: 196 additions & 0 deletions
196
reconstruction/alert/src/main/java/org/jlab/rec/atof/TrackMatch/TrackProjector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
package org.jlab.rec.atof.TrackMatch; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jlab.io.base.DataBank; | ||
import org.jlab.io.base.DataEvent; | ||
import org.jlab.clas.tracking.trackrep.Helix; | ||
import org.jlab.clas.tracking.kalmanfilter.Units; | ||
import org.jlab.io.hipo.HipoDataSource; | ||
import org.jlab.clas.swimtools.Swim; | ||
import org.jlab.utils.CLASResources; | ||
import cnuphys.magfield.MagneticFields; | ||
|
||
/** | ||
* The {@code TrackProjector} class projects ahdc tracks to the inner surfaces | ||
* of the bar and wedges of the atof | ||
* | ||
* <p> | ||
* Uses ahdc track bank information (for now position, momentum) Creates a | ||
* {@link TrackProjection} for each track. | ||
* </p> | ||
* | ||
* <p> | ||
* TO DO: - replace hardcoded values with database values. - magnetic field ? | ||
* use swimmer tools? - charge ? | ||
* </p> | ||
* | ||
* @author pilleux | ||
*/ | ||
public class TrackProjector { | ||
|
||
/** | ||
* projections of tracks. | ||
*/ | ||
private List<TrackProjection> Projections; | ||
|
||
/** | ||
* solenoid magnitude | ||
*/ | ||
private Double B; | ||
|
||
/** | ||
* Default constructor that initializes the list of projections as new empty | ||
* list and the magnetic field to 5T. | ||
*/ | ||
public TrackProjector() { | ||
Projections = new ArrayList<TrackProjection>(); | ||
B = 5.0; | ||
} | ||
|
||
/** | ||
* Gets the list of track projections. | ||
* | ||
* @return a {@link List} of {@link TrackProjection} objects representing | ||
* the projections. | ||
*/ | ||
public List<TrackProjection> getProjections() { | ||
return Projections; | ||
} | ||
|
||
/** | ||
* Gets the solenoid magnitude | ||
* | ||
* @return solenoid magnitude | ||
*/ | ||
public Double getB() { | ||
return B; | ||
} | ||
|
||
/** | ||
* Sets the list of track projections. | ||
* | ||
* @param Projections a {@link List} of {@link TrackProjection}. | ||
*/ | ||
public void setProjections(List<TrackProjection> Projections) { | ||
this.Projections = Projections; | ||
} | ||
|
||
/** | ||
* Sets the solenoid magnitude. | ||
* | ||
* @param B a double. | ||
*/ | ||
public void setB(Double B) { | ||
this.B = B; | ||
} | ||
|
||
/** | ||
* Projects the ahdc tracks in the event onto the atof using a {@link Helix} | ||
* model. | ||
* | ||
* @param event the {@link DataEvent} containing track data to be projected. | ||
*/ | ||
public void ProjectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) { | ||
|
||
Projections.clear(); | ||
|
||
double bar_innerradius = 77; //NEEDS TO BE REPLACED WITH DB CONSTANTS something like ccdb.INNERRADIUS[0] | ||
double wedge_innerradius = 80; | ||
|
||
String track_bank_name = "AHDC::Track"; | ||
|
||
if (event == null) { // check if there is an event | ||
//System.out.print(" no event"); | ||
} else if (event.hasBank(track_bank_name) == false) { | ||
// check if there are ahdc tracks in the event | ||
//System.out.print("no tracks"); | ||
} else { | ||
DataBank bank = event.getBank(track_bank_name); | ||
|
||
int nt = bank.rows(); // number of tracks | ||
TrackProjection projection = new TrackProjection(); | ||
DataBank outputBank = event.createBank("AHDC::Projections", nt); | ||
|
||
for (int i = 0; i < nt; i++) { | ||
|
||
double x = bank.getFloat("x", i); | ||
double y = bank.getFloat("y", i); | ||
double z = bank.getFloat("z", i); | ||
double px = bank.getFloat("px", i); | ||
double py = bank.getFloat("py", i); | ||
double pz = bank.getFloat("pz", i); | ||
|
||
int q = 1; //this has to be changed, we need the charge info from tracking | ||
|
||
Units units = Units.MM; //can be MM or CM. | ||
|
||
double xb = 0; | ||
double yb = 0; | ||
|
||
Helix helix = new Helix(x, y, z, px, py, pz, q, B, xb, yb, units); | ||
|
||
projection.set_BarIntersect(helix.getHelixPointAtR(bar_innerradius)); | ||
projection.set_WedgeIntersect(helix.getHelixPointAtR(wedge_innerradius)); | ||
|
||
projection.set_BarPathLength((float) helix.getLAtR(bar_innerradius)); | ||
projection.set_WedgePathLength((float) helix.getLAtR(wedge_innerradius)); | ||
|
||
Projections.add(projection); | ||
fill_out_bank(outputBank, projection, i); | ||
} | ||
event.appendBank(outputBank); | ||
} | ||
} | ||
|
||
public static void fill_out_bank(DataBank outputBank, TrackProjection projection, int i) { | ||
outputBank.setFloat("x_at_bar", i, (float) projection.get_BarIntersect().x()); | ||
outputBank.setFloat("y_at_bar", i, (float) projection.get_BarIntersect().y()); | ||
outputBank.setFloat("z_at_bar", i, (float) projection.get_BarIntersect().z()); | ||
outputBank.setFloat("L_at_bar", i, (float) projection.get_BarPathLength()); | ||
outputBank.setFloat("x_at_wedge", i, (float) projection.get_WedgeIntersect().x()); | ||
outputBank.setFloat("y_at_wedge", i, (float) projection.get_WedgeIntersect().y()); | ||
outputBank.setFloat("z_at_wedge", i, (float) projection.get_WedgeIntersect().z()); | ||
outputBank.setFloat("L_at_wedge", i, (float) projection.get_WedgePathLength()); | ||
} | ||
|
||
public static void main(String arg[]) { | ||
|
||
//READING MAG FIELD MAP | ||
System.setProperty("CLAS12DIR", "../../"); | ||
|
||
String mapDir = CLASResources.getResourcePath("etc") + "/data/magfield"; | ||
try { | ||
MagneticFields.getInstance().initializeMagneticFields(mapDir, | ||
"Symm_torus_r2501_phi16_z251_24Apr2018.dat", "Symm_solenoid_r601_phi1_z1201_13June2018.dat"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
float[] b = new float[3]; | ||
Swim swimmer = new Swim(); | ||
swimmer.BfieldLab(0, 0, 0, b); | ||
double B = Math.abs(b[2]); | ||
|
||
//Track Projector Initialisation with B field | ||
TrackProjector projector = new TrackProjector(); | ||
projector.setB(B); | ||
|
||
//Input to be read | ||
String input = "/Users/npilleux/Desktop/alert/atof-reconstruction/coatjava/test_updated_2.hipo"; | ||
HipoDataSource reader = new HipoDataSource(); | ||
reader.open(input); | ||
|
||
int event_number = 0; | ||
while (reader.hasEvent()) { | ||
DataEvent event = (DataEvent) reader.getNextEvent(); | ||
event_number++; | ||
|
||
projector.ProjectTracks(event); | ||
//event.getBank("AHDC::Projections").show(); | ||
} | ||
|
||
System.out.print("Read " + event_number + " events"); | ||
} | ||
} |