Skip to content

Commit

Permalink
Merge branch 'main' into fix-kf-angle-periodicity
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 18, 2024
2 parents 1965702 + 2a82fda commit 468fd86
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class RootAthenaDumpReader : public IReader {
std::vector<std::tuple<std::uint32_t, std::size_t, std::size_t>> m_eventMap;
std::shared_ptr<TChain> m_inputchain;
long unsigned int m_events;
bool m_haveStripFeatures = true;

static constexpr unsigned int maxCL = 1500000;
static constexpr unsigned int maxSP = 1500000;
Expand All @@ -189,7 +190,7 @@ class RootAthenaDumpReader : public IReader {
int CLindex[maxCL] = {}; //[nCL]

// Clusters
std::vector<std::string> *CLhardware;
std::vector<std::string> *CLhardware{};
Double_t CLx[maxCL] = {}; //[nCL]
Double_t CLy[maxCL] = {}; //[nCL]
Double_t CLz[maxCL] = {}; //[nCL]
Expand All @@ -199,13 +200,13 @@ class RootAthenaDumpReader : public IReader {
Int_t CLphi_module[maxCL] = {}; //[nCL]
Int_t CLside[maxCL] = {}; //[nCL]
ULong64_t CLmoduleID[maxCL] = {}; //[nCL]
std::vector<std::vector<int>> *CLparticleLink_eventIndex;
std::vector<std::vector<int>> *CLparticleLink_barcode;
std::vector<std::vector<bool>> *CLbarcodesLinked;
std::vector<std::vector<float>> *CLparticle_charge;
std::vector<std::vector<int>> *CLphis;
std::vector<std::vector<int>> *CLetas;
std::vector<std::vector<int>> *CLtots;
std::vector<std::vector<int>> *CLparticleLink_eventIndex{};
std::vector<std::vector<int>> *CLparticleLink_barcode{};
std::vector<std::vector<bool>> *CLbarcodesLinked{};
std::vector<std::vector<float>> *CLparticle_charge{};
std::vector<std::vector<int>> *CLphis{};
std::vector<std::vector<int>> *CLetas{};
std::vector<std::vector<int>> *CLtots{};
Double_t CLloc_direction1[maxCL] = {}; //[nCL]
Double_t CLloc_direction2[maxCL] = {}; //[nCL]
Double_t CLloc_direction3[maxCL] = {}; //[nCL]
Expand All @@ -223,7 +224,7 @@ class RootAthenaDumpReader : public IReader {
Float_t CLnorm_x[maxCL] = {}; //[nCL]
Float_t CLnorm_y[maxCL] = {}; //[nCL]
Float_t CLnorm_z[maxCL] = {}; //[nCL]
std::vector<std::vector<double>> *CLlocal_cov;
std::vector<std::vector<double>> *CLlocal_cov{};

// Particles
Int_t nPartEVT = 0;
Expand All @@ -246,8 +247,8 @@ class RootAthenaDumpReader : public IReader {
Int_t Part_vProdNout[maxPart] = {}; //[nPartEVT]
Int_t Part_vProdStatus[maxPart] = {}; //[nPartEVT]
Int_t Part_vProdBarcode[maxPart] = {}; //[nPartEVT]
std::vector<std::vector<int>> *Part_vParentID;
std::vector<std::vector<int>> *Part_vParentBarcode;
std::vector<std::vector<int>> *Part_vParentID{};
std::vector<std::vector<int>> *Part_vParentBarcode{};

// Spacepoints
Int_t nSP = 0;
Expand All @@ -263,27 +264,27 @@ class RootAthenaDumpReader : public IReader {
double SPcovz[maxSP] = {}; //[nSP]
float SPhl_topstrip[maxSP] = {}; //[nSP]
float SPhl_botstrip[maxSP] = {}; //[nSP]
std::vector<std::vector<float>> *SPtopStripDirection;
std::vector<std::vector<float>> *SPbottomStripDirection;
std::vector<std::vector<float>> *SPstripCenterDistance;
std::vector<std::vector<float>> *SPtopStripCenterPosition;
std::vector<std::vector<float>> *SPtopStripDirection{};
std::vector<std::vector<float>> *SPbottomStripDirection{};
std::vector<std::vector<float>> *SPstripCenterDistance{};
std::vector<std::vector<float>> *SPtopStripCenterPosition{};

// Tracks
Int_t nTRK = 0;
Int_t TRKindex[maxTRK] = {}; //[nTRK]
Int_t TRKtrack_fitter[maxTRK] = {}; //[nTRK]
Int_t TRKparticle_hypothesis[maxTRK] = {}; //[nTRK]
std::vector<std::vector<int>> *TRKproperties;
std::vector<std::vector<int>> *TRKpattern;
std::vector<std::vector<int>> *TRKproperties{};
std::vector<std::vector<int>> *TRKpattern{};
Int_t TRKndof[maxTRK] = {}; //[nTRK]
Int_t TRKmot[maxTRK] = {}; //[nTRK]
Int_t TRKoot[maxTRK] = {}; //[nTRK]
Float_t TRKchiSq[maxTRK] = {}; //[nTRK]
std::vector<std::vector<int>> *TRKmeasurementsOnTrack_pixcl_sctcl_index;
std::vector<std::vector<int>> *TRKoutliersOnTrack_pixcl_sctcl_index;
std::vector<std::vector<int>> *TRKmeasurementsOnTrack_pixcl_sctcl_index{};
std::vector<std::vector<int>> *TRKoutliersOnTrack_pixcl_sctcl_index{};
Int_t TRKcharge[maxTRK] = {}; //[nTRK]
std::vector<std::vector<double>> *TRKperigee_position;
std::vector<std::vector<double>> *TRKperigee_momentum;
std::vector<std::vector<double>> *TRKperigee_position{};
std::vector<std::vector<double>> *TRKperigee_momentum{};
Int_t TTCindex[maxTRK] = {}; //[nTRK]
Int_t TTCevent_index[maxTRK] = {}; //[nTRK]
Int_t TTCparticle_link[maxTRK] = {}; //[nTRK]
Expand All @@ -293,10 +294,10 @@ class RootAthenaDumpReader : public IReader {
Int_t nDTT = 0;
Int_t DTTindex[maxDTT] = {}; //[nDTT]
Int_t DTTsize[maxDTT] = {}; //[nDTT]
std::vector<std::vector<int>> *DTTtrajectory_eventindex;
std::vector<std::vector<int>> *DTTtrajectory_barcode;
std::vector<std::vector<int>> *DTTstTruth_subDetType;
std::vector<std::vector<int>> *DTTstTrack_subDetType;
std::vector<std::vector<int>> *DTTstCommon_subDetType;
std::vector<std::vector<int>> *DTTtrajectory_eventindex{};
std::vector<std::vector<int>> *DTTtrajectory_barcode{};
std::vector<std::vector<int>> *DTTstTruth_subDetType{};
std::vector<std::vector<int>> *DTTstTrack_subDetType{};
std::vector<std::vector<int>> *DTTstCommon_subDetType{};
};
} // namespace ActsExamples
47 changes: 28 additions & 19 deletions Examples/Io/Root/src/RootAthenaDumpReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ RootAthenaDumpReader::RootAthenaDumpReader(
m_outputMeasurements.initialize(m_cfg.outputMeasurements);
}

if (m_inputchain->GetBranch("SPtopStripDirection") == nullptr) {
ACTS_WARNING("Additional SP strip features not available");
m_haveStripFeatures = false;
}

// Set the branches

// Set object pointer
Expand Down Expand Up @@ -192,13 +197,13 @@ RootAthenaDumpReader::RootAthenaDumpReader(
m_inputchain->SetBranchAddress("SPcovz", SPcovz);
m_inputchain->SetBranchAddress("SPhl_topstrip", SPhl_topstrip);
m_inputchain->SetBranchAddress("SPhl_botstrip", SPhl_botstrip);
m_inputchain->SetBranchAddress("SPtopStripDirection", SPtopStripDirection);
m_inputchain->SetBranchAddress("SPtopStripDirection", &SPtopStripDirection);
m_inputchain->SetBranchAddress("SPbottomStripDirection",
SPbottomStripDirection);
&SPbottomStripDirection);
m_inputchain->SetBranchAddress("SPstripCenterDistance",
SPstripCenterDistance);
&SPstripCenterDistance);
m_inputchain->SetBranchAddress("SPtopStripCenterPosition",
SPtopStripCenterPosition);
&SPtopStripCenterPosition);

m_inputchain->SetBranchAddress("nTRK", &nTRK);
m_inputchain->SetBranchAddress("TRKindex", TRKindex);
Expand Down Expand Up @@ -578,21 +583,25 @@ RootAthenaDumpReader::readSpacepoints(
sLinks.emplace_back(second);

using Vector3f = Eigen::Matrix<float, 3, 1>;
const Vector3f topStripDirection{SPtopStripDirection->at(isp).at(0),
SPtopStripDirection->at(isp).at(1),
SPtopStripDirection->at(isp).at(2)};
const Vector3f bottomStripDirection{
SPbottomStripDirection->at(isp).at(0),
SPbottomStripDirection->at(isp).at(1),
SPbottomStripDirection->at(isp).at(2)};
const Vector3f stripCenterDistance{SPstripCenterDistance->at(isp).at(0),
SPstripCenterDistance->at(isp).at(1),
SPstripCenterDistance->at(isp).at(2)};
const Vector3f topStripCenterPosition{
SPtopStripCenterPosition->at(isp).at(0),
SPtopStripCenterPosition->at(isp).at(1),
SPtopStripCenterPosition->at(isp).at(2)};

Vector3f topStripDirection = Vector3f::Zero();
Vector3f bottomStripDirection = Vector3f::Zero();
Vector3f stripCenterDistance = Vector3f::Zero();
Vector3f topStripCenterPosition = Vector3f::Zero();

if (m_haveStripFeatures) {
topStripDirection = {SPtopStripDirection->at(isp).at(0),
SPtopStripDirection->at(isp).at(1),
SPtopStripDirection->at(isp).at(2)};
bottomStripDirection = {SPbottomStripDirection->at(isp).at(0),
SPbottomStripDirection->at(isp).at(1),
SPbottomStripDirection->at(isp).at(2)};
stripCenterDistance = {SPstripCenterDistance->at(isp).at(0),
SPstripCenterDistance->at(isp).at(1),
SPstripCenterDistance->at(isp).at(2)};
topStripCenterPosition = {SPtopStripCenterPosition->at(isp).at(0),
SPtopStripCenterPosition->at(isp).at(1),
SPtopStripCenterPosition->at(isp).at(2)};
}
sp = SimSpacePoint(globalPos, std::nullopt, spCovr, spCovz, std::nullopt,
sLinks, SPhl_topstrip[isp], SPhl_botstrip[isp],
topStripDirection.cast<double>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

namespace Acts {

namespace Experimental {
class DetectorVolume;
}

using DetrayHostDetector = detray::detector<detray::default_metadata>;

namespace DetrayConversionUtils {
Expand All @@ -28,12 +32,37 @@ namespace DetrayConversionUtils {
///
/// This object is used to synchronize link information between the
/// different converters (geometry, material, surface grids)
struct GeometryIdCache {
/// This is a multimap to pass volume local surface link information
/// The portal splitting requires a multimap implementation here
std::multimap<GeometryIdentifier, unsigned long> localSurfaceLinks;
struct Cache {
/// Explicit constructor with detector volumes
///
/// @param detectorVolumes the number of detector volumes
Cache(const std::vector<const Acts::Experimental::DetectorVolume*>& dVolumes)
: detectorVolumes(dVolumes) {}

/// The volumes of the detector for index lookup
std::vector<const Acts::Experimental::DetectorVolume*> detectorVolumes;
/// This is a map to pass on volume link information
std::map<GeometryIdentifier, unsigned long> volumeLinks;
/// This is a multimap to pass volume local surface link information
/// The portal splitting requires a multimap implementation here
///
/// These are volume local, hence indexed per volumes
std::map<std::size_t, std::multimap<GeometryIdentifier, unsigned long>>
localSurfaceLinks;

/// Find the position of the volume to point to
///
/// @param volume the volume to find
///
/// @note throws exception if volume is not found
std::size_t volumeIndex(
const Acts::Experimental::DetectorVolume* volume) const {
auto candidate = std::ranges::find(detectorVolumes, volume);
if (candidate != detectorVolumes.end()) {
return std::distance(detectorVolumes.begin(), candidate);
}
throw std::invalid_argument("Volume not found in the cache");
}
};

/// Convert the binning option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class DetrayConverter {
const Experimental::Detector& detector,
vecmem::memory_resource& mr, const Options& options) {
// The building cache object
DetrayConversionUtils::GeometryIdCache geoIdCache;
DetrayConversionUtils::Cache cCache(detector.volumes());

typename detector_t::name_map names = {{0u, detector.name()}};

// build detector
detray::detector_builder<typename detector_t::metadata> detectorBuilder{};
// (1) geometry
detray::io::detector_payload detectorPayload =
DetrayGeometryConverter::convertDetector(geoIdCache, gctx, detector,
DetrayGeometryConverter::convertDetector(cCache, gctx, detector,
logger());
detray::io::geometry_reader::convert<detector_t>(detectorBuilder, names,
detectorPayload);
Expand All @@ -72,7 +72,7 @@ class DetrayConverter {
if (options.convertMaterial) {
detray::io::detector_homogeneous_material_payload materialSlabsPayload =
DetrayMaterialConverter::convertHomogeneousSurfaceMaterial(
geoIdCache, detector, logger());
cCache, detector, logger());
detray::io::homogeneous_material_reader::convert<detector_t>(
detectorBuilder, names, std::move(materialSlabsPayload));
}
Expand All @@ -85,7 +85,7 @@ class DetrayConverter {
detray::io::material_id>
materialGridsPayload =
DetrayMaterialConverter::convertGridSurfaceMaterial(
geoIdCache, detector, logger());
cCache, detector, logger());
detray::io::material_map_reader<std::integral_constant<
std::size_t, 2>>::convert<detector_t>(detectorBuilder, names,
std::move(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,49 +64,46 @@ detray::io::surface_payload convertSurface(const GeometryContext& gctx,

/// Conversion method for Portal object to detray::portal payloads
///
/// @param cCache [in, out] object
/// @param gctx the geometry context
/// @param portal the portal to be converted
/// @param ip the portal index
/// @param volume the volume to which the portal belongs
/// @param orientedSurfaces the oriented surfaces of the portal
/// @param detectorVolumes the detector volumes for the link lookup
///
/// @note due to portal splitting this can add up in N portals for one initial one
///
/// @brief convert the acts portal to detray surface payload and populate the payload
std::vector<detray::io::surface_payload> convertPortal(
const GeometryContext& gctx, const Experimental::Portal& portal,
std::size_t ip, const Experimental::DetectorVolume& volume,
const std::vector<OrientedSurface>& orientedSurfaces,
const std::vector<const Experimental::DetectorVolume*>& detectorVolumes);
DetrayConversionUtils::Cache& cCache, const GeometryContext& gctx,
const Experimental::Portal& portal, std::size_t ip,
const Experimental::DetectorVolume& volume,
const std::vector<OrientedSurface>& orientedSurfaces);

/// Conversion method for volume objects to detray::volume payloads
///
/// @param geoIdCache [in, out] object
/// @param cCache [in, out] object
/// @param gctx the geometry context
/// @param volume the volume to be converted
/// @param detectorVolumes the detector volumes for the link lookup
/// @param logger the logger object for screen output
///
/// @return the volume_payload for portals and volumes by @param volume acts object
detray::io::volume_payload convertVolume(
DetrayConversionUtils::GeometryIdCache& geoIdCache,
const GeometryContext& gctx, const Experimental::DetectorVolume& volume,
const std::vector<const Experimental::DetectorVolume*>& detectorVolumes,
const Acts::Logger& logger);
DetrayConversionUtils::Cache& cCache, const GeometryContext& gctx,
const Experimental::DetectorVolume& volume, const Acts::Logger& logger);

/// Conversion method for detector objects to detray::detector payload
///
/// @param geoIdCache [in, out] object
/// @param cCache [in, out] object
/// @param gctx the geometry context
/// @param detector the detector to be converted
/// @param logger the logger object for screen output
///
/// @return the detector_payload for portals and volumes by @param detector acts object
detray::io::detector_payload convertDetector(
DetrayConversionUtils::GeometryIdCache& geoIdCache,
const GeometryContext& gctx, const Experimental::Detector& detector,
const Acts::Logger& logger);
DetrayConversionUtils::Cache& cCache, const GeometryContext& gctx,
const Experimental::Detector& detector, const Acts::Logger& logger);

} // namespace DetrayGeometryConverter
} // namespace Acts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ detray::io::material_slab_payload convertMaterialSlab(

/// Conversion method for homogeneous material
///
/// @param geoIdCache object to have the link association from the geometry building
/// @param cCache object to have the link association from the geometry building
/// @param detector the detector object
/// @param logger the logger object for screen output
///
/// @return the volume_payload for portals and volumes by @param volume acts object
detray::io::detector_homogeneous_material_payload
convertHomogeneousSurfaceMaterial(
const DetrayConversionUtils::GeometryIdCache& geoIdCache,
const Experimental::Detector& detector, const Logger& logger);
convertHomogeneousSurfaceMaterial(const DetrayConversionUtils::Cache& cCache,
const Experimental::Detector& detector,
const Logger& logger);

/// Conversion method for grid based surface material
///
Expand All @@ -58,16 +58,16 @@ convertGridSurfaceMaterial(const ISurfaceMaterial& material,

/// Conversion method for material grids
///
/// @param geoIdCache object to have the link association from the geometry building
/// @param cCache object to have the link association from the geometry building
/// @param detector the detector object
/// @param logger the logger object for screen output
///
/// @return the volume_payload for portals and volumes by @param volume acts object
detray::io::detector_grids_payload<detray::io::material_slab_payload,
detray::io::material_id>
convertGridSurfaceMaterial(
const DetrayConversionUtils::GeometryIdCache& geoIdCache,
const Experimental::Detector& detector, const Logger& logger);
convertGridSurfaceMaterial(const DetrayConversionUtils::Cache& cCache,
const Experimental::Detector& detector,
const Logger& logger);

} // namespace DetrayMaterialConverter

Expand Down
Loading

0 comments on commit 468fd86

Please sign in to comment.