Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:28:29

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2024, Whitney Armstrong, Wouter Deconinck
0003 
0004 #include "DD4hep/Detector.h"
0005 
0006 #include <Acts/Geometry/TrackingGeometry.hpp>
0007 #include <Acts/Geometry/TrackingVolume.hpp>
0008 #include <Acts/Visualization/GeometryView3D.hpp>
0009 #include <Acts/Visualization/ObjVisualization3D.hpp>
0010 #include <Acts/Visualization/PlyVisualization3D.hpp>
0011 #include <Acts/Visualization/ViewConfig.hpp>
0012 
0013 #if __has_include(<ActsPlugins/DD4hep/ConvertDD4hepDetector.hpp>)
0014 // Acts_MAJOR_VERSION >= 44
0015 #include <ActsPlugins/DD4hep/ConvertDD4hepDetector.hpp>
0016 using ActsPlugins::convertDD4hepDetector;
0017 #else
0018 // Acts_MAJOR_VERSION < 44
0019 #include <Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp>
0020 using Acts::convertDD4hepDetector;
0021 #endif
0022 
0023 /** Example loading ACTs.
0024  *
0025  *
0026  */
0027 void test_ACTS(const char* compact = "epic.xml") {
0028   // -------------------------
0029   // Get the DD4hep instance
0030   // Load the compact XML file
0031   // Initialize the position converter tool
0032   auto detector = dd4hep::Detector::make_unique("");
0033   detector->fromCompact(compact);
0034 
0035   auto logger                 = Acts::getDefaultLogger("Acts", Acts::Logging::Level::VERBOSE);
0036   auto acts_tracking_geometry = convertDD4hepDetector(detector->world(), *logger);
0037 
0038   // Visit all surfaces
0039   acts_tracking_geometry->visitSurfaces([](const Acts::Surface* surface) {});
0040 
0041   // Export to obj+mtl and ply collections
0042   Acts::ViewConfig containerView{.color = {220, 220, 220}}; // alto
0043   Acts::ViewConfig volumeView{.color = {220, 220, 0}};      // barberry yellow
0044   Acts::ViewConfig sensitiveView{.color = {0, 180, 240}};   // picton blue
0045   Acts::ViewConfig passiveView{.color = {240, 180, 0}};     // lightning yellow
0046   Acts::ViewConfig gridView{.color = {220, 0, 0}};          // scarlet red
0047   Acts::GeometryContext trackingGeoCtx;
0048   const Acts::TrackingVolume* world = acts_tracking_geometry->highestTrackingVolume();
0049   // Export to obj+mtl
0050   Acts::ObjVisualization3D objVis;
0051   Acts::GeometryView3D::drawTrackingVolume(objVis, *world, trackingGeoCtx, containerView,
0052                                            volumeView, passiveView, sensitiveView, gridView, true,
0053                                            "", "");
0054   // Export to ply
0055   Acts::PlyVisualization3D plyVis;
0056   Acts::GeometryView3D::drawTrackingVolume(plyVis, *world, trackingGeoCtx, containerView,
0057                                            volumeView, passiveView, sensitiveView, gridView, true,
0058                                            "", "");
0059 }