Skip to content

Commit

Permalink
Don't use radiusOfInnermostHit for EDM4hep tracks
Browse files Browse the repository at this point in the history
and compute it from hits when going from EDM4hep to LCIO. See
key4hep/EDM4hep#326
  • Loading branch information
jmcarcell authored and tmadlener committed Jul 2, 2024
1 parent f6343b2 commit a391472
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "k4EDM4hep2LcioConv/MappingUtils.h"

#include <cassert>
#include <cmath>
#include <limits>

#include "TMath.h"

Expand All @@ -25,7 +27,15 @@ 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());
lcio_tr->setRadiusOfInnermostHit(edm_tr.getRadiusOfInnermostHit());
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);

// Loop over the hit Numbers in the track
lcio_tr->subdetectorHitNumbers().resize(edm_tr.subdetectorHitNumbers_size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ std::unique_ptr<edm4hep::TrackCollection> convertTracks(const std::string& name,
lval.setNdf(rval->getNdf());
lval.setDEdx(rval->getdEdx());
lval.setDEdxError(rval->getdEdxError());
lval.setRadiusOfInnermostHit(rval->getRadiusOfInnermostHit());

auto subdetectorHitNum = rval->getSubdetectorHitNumbers();
for (auto hitNum : subdetectorHitNum) {
Expand Down
13 changes: 12 additions & 1 deletion tests/src/CompareEDM4hepLCIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "IMPL/TrackerHitImpl.h"

#include <cmath>
#include <cstdint>

#include "TMath.h"
Expand Down Expand Up @@ -314,7 +315,17 @@ bool compare(const EVENT::Track* lcioElem, const edm4hep::Track& edm4hepElem, co
ASSERT_COMPARE_VALS(lcioElem->getdEdx(), dxQuantities[0].value, "dEdx in DxQuantities in Track");
ASSERT_COMPARE_VALS(lcioElem->getdEdxError(), dxQuantities[0].error, "dEdxError in DxQuantities in Track");

ASSERT_COMPARE(lcioElem, edm4hepElem, getRadiusOfInnermostHit, "radiusOfInnermostHit in Track");
double radius = std::numeric_limits<double>::max();
for (const auto& hit : edm4hepElem.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;
}
ASSERT_COMPARE_VALS_FLOAT(lcioElem->getRadiusOfInnermostHit(), radius, lcioElem->getRadiusOfInnermostHit() / 1e6,
"radiusOfInnermostHit in Track");
}

ASSERT_COMPARE_RELATION(lcioElem, edm4hepElem, getTracks, objectMaps.tracks, "Tracks in Track");

Expand Down
1 change: 0 additions & 1 deletion tests/src/EDM4hep2LCIOUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ edm4hep::TrackCollection createTracks(const int num_elements, const int subdetec
elem.setType(2); // TODO specific type
elem.setChi2(i * 10.f);
elem.setNdf(i * 12);
elem.setRadiusOfInnermostHit(i * 5.f);

elem.setDEdx(i);
elem.setDEdxError(i / std::sqrt(i + 1));
Expand Down

0 comments on commit a391472

Please sign in to comment.