Skip to content

Commit

Permalink
feat: saving track ID in projection bank
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Plx committed Feb 22, 2025
1 parent b9e2750 commit cd9acdc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
4 changes: 4 additions & 0 deletions etc/bankdefs/hipo4/alert.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"name": "id",
"type": "S",
"info": "projection id"
},{
"name": "trackID",
"type": "S",
"info": "id of the track that was projected"
}, {
"name": "x_at_bar",
"type": "F",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class TrackProjection {
*/
Float wedgeInPathLength;

int trackID;


/**
* Default constructor that initializes the intersection points and path lengths to {@code NaN}.
Expand Down Expand Up @@ -165,6 +167,14 @@ public void setWedgeInPathLength(Float WedgeInPathLength) {
this.wedgeInPathLength = WedgeInPathLength;
}

public void setTrackID(int trackID) {
this.trackID = trackID;
}

public int getTrackID() {
return trackID;
}

/**
* testing purposes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TrackProjector {
* projections of tracks.
*/
private ArrayList<TrackProjection> projections;

/**
* solenoid magnitude
*/
Expand All @@ -54,8 +54,8 @@ public TrackProjector() {
public ArrayList<TrackProjection> getProjections() {
return projections;
}
/**

/**
* Gets the solenoid magnitude
*
* @return solenoid magnitude
Expand All @@ -72,8 +72,8 @@ public Double getB() {
public void setProjections(ArrayList<TrackProjection> Projections) {
this.projections = Projections;
}
/**

/**
* Sets the solenoid magnitude.
*
* @param B a double.
Expand All @@ -91,9 +91,8 @@ public void setB(Double B) {
public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) {

projections.clear();

String track_bank_name = "AHDC::Track";

String track_bank_name = "AHDC::Track";
if (event == null) { // check if there is an event
//System.out.print(" no event \n");
} else if (event.hasBank(track_bank_name) == false) {
Expand All @@ -104,13 +103,13 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb)
int nt = bank.rows(); // number of tracks
TrackProjection projection = new TrackProjection();
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 id = nt + 1;//To be replaced by track id if it is added to the out bank

int q = -1; //need the charge sign from tracking

Expand All @@ -120,7 +119,7 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb)
double yb = 0;

//momenta must be in GeV for the helix class
Helix helix = new Helix(x, y, z, px/1000., py/1000., pz/1000., q, b, xb, yb, units);
Helix helix = new Helix(x, y, z, px / 1000., py / 1000., pz / 1000., q, b, xb, yb, units);

//Intersection points with the middle of the bar or wedge
projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS));
Expand All @@ -129,25 +128,26 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb)
//Path length to the middle of the bar or wedge
projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS)));
projection.setWedgePathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_INNER_RADIUS)));

//Path length from the inner radius to the middle radius
projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength());
projection.setWedgeInPathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_MIDDLE_RADIUS)) - projection.getWedgePathLength());
projection.setTrackID(id);
projections.add(projection);
}

}
}

/**
* Projects the MC particles onto the atof using a {@link Helix}
* model.
* Projects the MC particles onto the atof using a {@link Helix} model.
*
* @param event the {@link DataEvent} containing track data to be projected.
*/
public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) {

projections.clear();

String track_bank_name = "MC::Particle";
if (event == null) { // check if there is an event
//System.out.print(" no event \n");
Expand All @@ -168,15 +168,14 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd
double px = bank.getFloat("px", i);
double py = bank.getFloat("py", i);
double pz = bank.getFloat("pz", i);

int id = bank.getShort("id", i);
//Put everything in MM
x = x * 10;
y = y * 10;
z = z * 10;

x = x*10;
y = y*10;
z = z*10;
Units units = Units.MM;

Units units = Units.MM;

int q = -1; //need the charge sign from tracking

double xb = 0;
Expand All @@ -186,24 +185,23 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd
Helix helix = new Helix(x, y, z, px, py, pz, q, b, xb, yb, units);

//Intersection points with the middle of the bar or wedge
projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS));
projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS));
projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS));

//Path length to the middle of the bar or wedge

projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS)));
projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS)));
projection.setWedgePathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_INNER_RADIUS)));

//Path length from the inner radius to the middle radius

projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength());
//Path length from the inner radius to the middle radius
projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength());
projection.setWedgeInPathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_MIDDLE_RADIUS)) - projection.getWedgePathLength());
projection.setTrackID(id);
projections.add(projection);
}
}
}

public static void main(String arg[]) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public static DataBank fillProjectionsBank(DataEvent event, ArrayList<TrackProje
System.err.println("COULD NOT CREATE A ALERT::Projections BANK!!!!!!");
return null;
}

for (int i = 0; i < projections.size(); i++) {
TrackProjection projection = projections.get(i);
bank.setShort("id", i, (short) (i + 1));
bank.setShort("trackID", i, (short) projection.getTrackID());
bank.setFloat("x_at_bar", i, (float) projection.getBarIntersect().x());
bank.setFloat("y_at_bar", i, (float) projection.getBarIntersect().y());
bank.setFloat("z_at_bar", i, (float) projection.getBarIntersect().z());
Expand Down

0 comments on commit cd9acdc

Please sign in to comment.