Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy compatibility and require minimum EDM4hep version #38

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,13 @@
#include <edm4hep/ReconstructedParticleCollection.h>
#include <edm4hep/SimCalorimeterHitCollection.h>
#include <edm4hep/SimTrackerHitCollection.h>
#if __has_include("edm4hep/RawTimeSeriesCollection.h")
#include <edm4hep/RawTimeSeriesCollection.h>
#else
#include <edm4hep/TPCHitCollection.h>
namespace edm4hep {
using RawTimeSeries = TPCHit;
using MutableRawTimeSeries = MutableTPCHit;
using RawTimeSeriesCollection = TPCHitCollection;
} // namespace edm4hep
#endif

#include <edm4hep/TrackCollection.h>
#include <edm4hep/TrackerHitCollection.h>
#include <edm4hep/TrackerHitPlaneCollection.h>
#include <edm4hep/VertexCollection.h>

#if __has_include("edm4hep/EDM4hepVersion.h")
#include "edm4hep/EDM4hepVersion.h"
#else
// Copy the necessary parts from the header above to make whatever we need to work here
#define EDM4HEP_VERSION(major, minor, patch) ((UINT64_C(major) << 32) | (UINT64_C(minor) << 16) | (UINT64_C(patch)))
// v00-07-02 is the last version without that still has TPCHits
#if __has_include("edm4hep/TPCHitCollection.h")
#define EDM4HEP_BUILD_VERSION EDM4HEP_VERSION(0, 7, 2)
#else
// v00-09 is the last version without the capitalization change of the track vector members
#define EDM4HEP_BUILD_VERSION EDM4HEP_VERSION(0, 9, 0)
#endif
#endif

#include "podio/Frame.h"

// LCIO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace EDM4hep2LCIOConv {
lcio_tr->setdEdxError(edm_tr.getDEdxError());
lcio_tr->setRadiusOfInnermostHit(edm_tr.getRadiusOfInnermostHit());

#if EDM4HEP_BUILD_VERSION > EDM4HEP_VERSION(0, 9, 0)
// Loop over the hit Numbers in the track
lcio_tr->subdetectorHitNumbers().resize(edm_tr.subdetectorHitNumbers_size());
for (int i = 0; i < edm_tr.subdetectorHitNumbers_size(); ++i) {
Expand All @@ -46,22 +45,6 @@ namespace EDM4hep2LCIOConv {
lcio_tr->subdetectorHitNumbers()[i] = 0;
}
}
#else
// Loop over the hit Numbers in the track
lcio_tr->subdetectorHitNumbers().resize(edm_tr.subDetectorHitNumbers_size());
for (int i = 0; i < edm_tr.subDetectorHitNumbers_size(); ++i) {
lcio_tr->subdetectorHitNumbers()[i] = edm_tr.getSubDetectorHitNumbers(i);
}

// Pad until 50 hitnumbers are resized
const int hit_number_limit = 50;
if (edm_tr.subDetectorHitNumbers_size() < hit_number_limit) {
lcio_tr->subdetectorHitNumbers().resize(hit_number_limit);
for (int i = edm_tr.subDetectorHitNumbers_size(); i < hit_number_limit; ++i) {
lcio_tr->subdetectorHitNumbers()[i] = 0;
}
}
#endif

// Link multiple associated TrackerHits if found in converted ones
for (const auto& edm_rp_trh : edm_tr.getTrackerHits()) {
Expand Down Expand Up @@ -362,19 +345,11 @@ namespace EDM4hep2LCIOConv {
lcio_tpchit->setQuality(edm_tpchit.getQuality());

std::vector<int> rawdata;
#if EDM4HEP_BUILD_VERSION > EDM4HEP_VERSION(0, 7, 2)
for (int i = 0; i < edm_tpchit.adcCounts_size(); ++i) {
rawdata.push_back(edm_tpchit.getAdcCounts(i));
}

lcio_tpchit->setRawData(rawdata.data(), edm_tpchit.adcCounts_size());
#else
for (int i = 0; i < edm_tpchit.rawDataWords_size(); ++i) {
rawdata.push_back(edm_tpchit.getRawDataWords(i));
}

lcio_tpchit->setRawData(rawdata.data(), edm_tpchit.rawDataWords_size());
#endif

// Save TPC Hits LCIO and EDM4hep collections
k4EDM4hep2LcioConv::detail::mapInsert(lcio_tpchit, edm_tpchit, tpc_hits_vec);
Expand Down
Loading