Skip to content

Commit

Permalink
Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 30, 2025
1 parent 223996e commit dbb0de1
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 43 deletions.
6 changes: 4 additions & 2 deletions Ecal/include/Ecal/EcalVetoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ class EcalVetoProcessor : public framework::Producer {
int firstNearPhLayer_{0};
/// Number of hits near the photon trajectory
int nNearPhHits_{0};
/// Angular separation between the projected photon and electron trajectories as projected at ECAL
/// Angular separation between the projected photon and electron trajectories
/// as projected at ECAL
float epAngAtEcal_{0};
/// Angular separation between the projected photon and electron trajectories as at Target
/// Angular separation between the projected photon and electron trajectories
/// as at Target
float epAngAtTarget_{0};
/// Distance between the projected photon and electron trajectories at the
/// ECal face
Expand Down
17 changes: 10 additions & 7 deletions Ecal/include/Ecal/Event/EcalVetoResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class EcalVetoResult {
int nStraightTracks, int nLinregTracks,
int firstNearPhLayer, int nNearPhHits,
int photonTerritoryHits, float epAngAtEcal_,
float epAngAtTarget_,
float epSep,
float epDotAtEcal_,
float epAngAtTarget_, float epSep, float epDotAtEcal_,
std::vector<float> electronContainmentEnergy,
std::vector<float> photonContainmentEnergy,
std::vector<float> outsideContainmentEnergy,
Expand Down Expand Up @@ -219,7 +217,9 @@ class EcalVetoResult {
void setFiducial(bool fiducial) { fiducial_ = fiducial; }

// Fiducial from the recoil tracking point of view
void setTrackingFiducial(bool tracking_fiducial) { tracking_fiducial_ = tracking_fiducial; }
void setTrackingFiducial(bool tracking_fiducial) {
tracking_fiducial_ = tracking_fiducial;
}

/** Return the momentum of the recoil at the Ecal face. */
const std::vector<double> getRecoilMomentum() const {
Expand Down Expand Up @@ -274,14 +274,17 @@ class EcalVetoResult {
int nNearPhHits_{0};
/// Number of hits in the photon territory
int photonTerritoryHits_{0};
/// Angular separation between the projected photon and electron trajectories as projected at ECAL
/// Angular separation between the projected photon and electron trajectories
/// as projected at ECAL
float epAngAtEcal_{0};
/// Angular separation between the projected photon and electron trajectories as at Target
/// Angular separation between the projected photon and electron trajectories
/// as at Target
float epAngAtTarget_{0};
/// Distance between the projected photon and electron trajectories at the
/// ECal face
float epSep_{0};
/// Dot product of the photon and electron momenta unit vectors as projected at ECAL
/// Dot product of the photon and electron momenta unit vectors as projected
/// at ECAL
float epDotAtEcal_{0};
/// Dot product of the photon and electron momenta unit vectors as at Target
float epDotAtTarget_{0};
Expand Down
70 changes: 38 additions & 32 deletions Ecal/src/Ecal/EcalVetoProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ void EcalVetoProcessor::produce(framework::Event &event) {

ldmx::TrackStateType ts_type_ecal = ldmx::TrackStateType::AtECAL;
ldmx::TrackStateType ts_type_target = ldmx::TrackStateType::AtTarget;
auto recoil_track_states_at_ecal = trackProp(recoil_tracks, ts_type_ecal, "ecal");
auto recoil_track_states_at_target = trackProp(recoil_tracks, ts_type_target, "target");
auto recoil_track_states_at_ecal =
trackProp(recoil_tracks, ts_type_ecal, "ecal");
auto recoil_track_states_at_target =
trackProp(recoil_tracks, ts_type_target, "target");

// Redefining recoilPos now to come from the track state
// track_state_loc0 is recoilPos[0] and track_state_loc1 is recoilPos[1]
Expand All @@ -279,17 +281,21 @@ void EcalVetoProcessor::produce(framework::Event &event) {
recoilPAtTarget[1] = recoil_track_states_at_target[4];
recoilPAtTarget[2] = recoil_track_states_at_target[5];
}
ldmx_log(info) << " Recoil tracking for projections; with " << recoil_tracks.size() << " tracks, fiducial in tracker = " << fiducial_in_tracker;
ldmx_log(info) << " Recoil tracking for projections; with "
<< recoil_tracks.size()
<< " tracks, fiducial in tracker = " << fiducial_in_tracker;
}

if (verbose_) {
ldmx_log(debug) << " Get projected trajectories for electron and photon";
}
// Get projected trajectories for electron and photon
std::vector<XYCoords> ele_trajectory, photon_trajectory, ele_trajectory_at_target;
std::vector<XYCoords> ele_trajectory, photon_trajectory,
ele_trajectory_at_target;
if (!recoilP.empty() && !recoilPos.empty()) {
ele_trajectory = getTrajectory(recoilP, recoilPos);
ele_trajectory_at_target = getTrajectory(recoilPAtTarget, recoilPosAtTarget);
ele_trajectory_at_target =
getTrajectory(recoilPAtTarget, recoilPosAtTarget);
std::vector<double> pvec = recoilPAtTarget.size()
? recoilPAtTarget
: std::vector<double>{0.0, 0.0, 0.0};
Expand Down Expand Up @@ -747,30 +753,32 @@ void EcalVetoProcessor::produce(framework::Event &event) {
e_traj_end.SetXYZ(ele_trajectory[(nEcalLayers_ - 1)].first,
ele_trajectory[(nEcalLayers_ - 1)].second,
geometry_->getZPosition((nEcalLayers_ - 1)));
// Calculate the electron trajectory with positions and momentum as measured at the target
e_traj_target_start.SetXYZ(ele_trajectory_at_target[0].first, ele_trajectory_at_target[0].second,
geometry_->getZPosition(0));
e_traj_target_end.SetXYZ(ele_trajectory_at_target[(0)].first,
ele_trajectory_at_target[(0)].second,
geometry_->getZPosition((nEcalLayers_ - 1)));
// Calculate the electron trajectory with positions and momentum as measured
// at the target
e_traj_target_start.SetXYZ(ele_trajectory_at_target[0].first,
ele_trajectory_at_target[0].second,
geometry_->getZPosition(0));
e_traj_target_end.SetXYZ(ele_trajectory_at_target[(0)].first,
ele_trajectory_at_target[(0)].second,
geometry_->getZPosition((nEcalLayers_ - 1)));
p_traj_start.SetXYZ(photon_trajectory[0].first, photon_trajectory[0].second,
geometry_->getZPosition(0));
p_traj_end.SetXYZ(photon_trajectory[(nEcalLayers_ - 1)].first,
photon_trajectory[(nEcalLayers_ - 1)].second,
geometry_->getZPosition((nEcalLayers_ - 1)));


TVector3 evec = e_traj_end - e_traj_start;
TVector3 e_norm = evec.Unit();
TVector3 pvec = p_traj_end - p_traj_start;
TVector3 p_norm = pvec.Unit();
// Calculate the angle between the projected electron at Ecal and the photon (at target)
// Calculate the angle between the projected electron at Ecal and the photon
// (at target)
epDotAtEcal_ = e_norm.Dot(p_norm);
epAngAtEcal_ = acos(epDotAtEcal_) * 180.0 / M_PI;
// Now calculate the angle w/o any projections
TVector3 evec_target = e_traj_target_end - e_traj_target_start;
TVector3 e_norm_target = evec_target.Unit();
auto epDotAtTarget = e_norm_target.Dot(p_norm); // TADA
auto epDotAtTarget = e_norm_target.Dot(p_norm); // TADA
epAngAtTarget_ = acos(epDotAtTarget) * 180.0 / M_PI;
epSep_ = sqrt(pow(e_traj_start.X() - p_traj_start.X(), 2) +
pow(e_traj_start.Y() - p_traj_start.Y(), 2));
Expand Down Expand Up @@ -1162,14 +1170,14 @@ void EcalVetoProcessor::produce(framework::Event &event) {
nReadoutHits_, deepestLayerHit_, summedDet_, summedTightIso_, maxCellDep_,
showerRMS_, xStd_, yStd_, avgLayerHit_, stdLayerHit_, ecalBackEnergy_,
nStraightTracks_, nLinregTracks_, firstNearPhLayer_, nNearPhHits_,
photonTerritoryHits_, epAngAtEcal_, epAngAtTarget_, epSep_, epDotAtEcal_, electronContainmentEnergy,
photonContainmentEnergy, outsideContainmentEnergy,
outsideContainmentNHits, outsideContainmentXstd, outsideContainmentYstd,
energySeg, xMeanSeg, yMeanSeg, xStdSeg, yStdSeg, layerMeanSeg,
layerStdSeg, eContEnergy, eContXMean, eContYMean, gContEnergy, gContNHits,
gContXMean, gContYMean, oContEnergy, oContNHits, oContXMean, oContYMean,
oContXStd, oContYStd, oContLayerMean, oContLayerStd,
ecalLayerEdepReadout_, recoilP, recoilPos);
photonTerritoryHits_, epAngAtEcal_, epAngAtTarget_, epSep_, epDotAtEcal_,
electronContainmentEnergy, photonContainmentEnergy,
outsideContainmentEnergy, outsideContainmentNHits, outsideContainmentXstd,
outsideContainmentYstd, energySeg, xMeanSeg, yMeanSeg, xStdSeg, yStdSeg,
layerMeanSeg, layerStdSeg, eContEnergy, eContXMean, eContYMean,
gContEnergy, gContNHits, gContXMean, gContYMean, oContEnergy, oContNHits,
oContXMean, oContYMean, oContXStd, oContYStd, oContLayerMean,
oContLayerStd, ecalLayerEdepReadout_, recoilP, recoilPos);

buildBDTFeatureVector(result);
ldmx::Ort::FloatArrays inputs({bdtFeatures_});
Expand All @@ -1187,7 +1195,6 @@ void EcalVetoProcessor::produce(framework::Event &event) {
result.setFiducial(inside_ecal_cell);
result.setFiducial(fiducial_in_tracker);


// If the event passes the veto, keep it. Otherwise,
// drop the event.
if (result.passesVeto()) {
Expand Down Expand Up @@ -1348,7 +1355,7 @@ std::vector<float> EcalVetoProcessor::trackProp(const ldmx::Tracks &tracks,
auto trk_ts = track.getTrackState(ts_type);
// Continue if there's no value
if (!trk_ts.has_value()) continue;
// This is either ECAL or Target
// This is either ECAL or Target
ldmx::Track::TrackState &track_state = trk_ts.value();

// Check that the track state is filled
Expand All @@ -1363,28 +1370,27 @@ std::vector<float> EcalVetoProcessor::trackProp(const ldmx::Tracks &tracks,
// convert qop [1/GeV] to p [MeV]
float p_track_state = (-1 / track_state.params[4]) * 1000;
// p * sin(theta) * sin(phi)
float recoil_mom_x = p_track_state * sin(track_state.params[3]) *
sin(track_state.params[2]);
float recoil_mom_x =
p_track_state * sin(track_state.params[3]) * sin(track_state.params[2]);
// p * cos(theta)
float recoil_mom_y = p_track_state * cos(track_state.params[3]);
// p * sin(theta) * cos(phi)
float recoil_mom_z = p_track_state * sin(track_state.params[3]) *
cos(track_state.params[2]);
float recoil_mom_z =
p_track_state * sin(track_state.params[3]) * cos(track_state.params[2]);

// Store the new track state variables
new_track_states.push_back(track_state_loc0);
new_track_states.push_back(track_state_loc1);
// z-position at the ECAL scoring plane
// z-position at the ECAL (4) or Target (1)
if (ts_type == 4){
if (ts_type == 4) {
// this should match `ECAL_SCORING_PLANE` in CKFProcessor
new_track_states.push_back(240.5);
}
else if (ts_type == 1){
} else if (ts_type == 1) {
// This should match `target_surface` in CKFProcessor
new_track_states.push_back(0.0);
}

new_track_states.push_back(recoil_mom_x);
new_track_states.push_back(recoil_mom_y);
new_track_states.push_back(recoil_mom_z);
Expand Down
3 changes: 1 addition & 2 deletions Ecal/src/Ecal/Event/EcalVetoResult.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ void EcalVetoResult::setVariables(
float yStd, float avgLayerHit, float stdLayerHit, float ecalBackEnergy,
int nStraightTracks, int nLinregTracks, int firstNearPhLayer,
int nNearPhHits, int photonTerritoryHits, float epAngAtEcal,
float epAngAtTarget, float epSep,
float epDotAtEcal,
float epAngAtTarget, float epSep, float epDotAtEcal,

std::vector<float> electronContainmentEnergy,
std::vector<float> photonContainmentEnergy,
Expand Down

0 comments on commit dbb0de1

Please sign in to comment.