Skip to content

Commit

Permalink
Introdue utility function to determine radius of innermost hit
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jul 2, 2024
1 parent 3e4d903 commit 475ff4f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ convEvent(const podio::Frame& edmEvent, const podio::Frame& metadata = podio::Fr
return convertEvent(edmEvent, metadata);
}

/**
* Get the 3D radius of the TrackState at the IP from the given track. This is
* used to set the radiusOfInnermostHit in the LCIO track during the conversion
*/
std::optional<double> getRadiusOfStateAtIP(const edm4hep::Track& track);

} // namespace EDM4hep2LCIOConv

#include "k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ std::unique_ptr<lcio::LCCollectionVec> convertTracks(const edm4hep::TrackCollect
lcio_tr->setNdf(edm_tr.getNdf());
lcio_tr->setdEdx(edm_tr.getDEdx());
lcio_tr->setdEdxError(edm_tr.getDEdxError());
double radius = std::numeric_limits<double>::max();
for (const auto& hit : edm_tr.getTrackerHits()) {
radius = std::min(radius, std::sqrt(hit.getPosition()[0] * hit.getPosition()[0] +
hit.getPosition()[1] * hit.getPosition()[1]));
}
if (radius == std::numeric_limits<double>::max()) {
radius = 0;
}
lcio_tr->setRadiusOfInnermostHit(radius);
lcio_tr->setRadiusOfInnermostHit(getRadiusOfStateAtIP(edm_tr).value_or(-1.0));

// Loop over the hit Numbers in the track
lcio_tr->subdetectorHitNumbers().resize(edm_tr.subdetectorHitNumbers_size());
Expand Down
10 changes: 10 additions & 0 deletions k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,14 @@ std::unique_ptr<lcio::LCEventImpl> convertEvent(const podio::Frame& edmEvent, co
return lcioEvent;
}

std::optional<double> getRadiusOfStateAtIP(const edm4hep::Track& track) {
for (const auto& state : track.getTrackStates()) {
if (state.location == edm4hep::TrackState::AtIP) {
const auto refP = state.referencePoint;
return std::sqrt(refP.x * refP.x + refP.y * refP.y + refP.z * refP.z);
}
}
return std::nullopt;
}

} // namespace EDM4hep2LCIOConv

0 comments on commit 475ff4f

Please sign in to comment.