LDMX Software
TrackingGeometry.h
1#pragma once
2
3// Acts
4#include <Acts/Geometry/CuboidVolumeBuilder.hpp>
5#include <Acts/Geometry/TrackingGeometry.hpp>
6#include <Acts/Geometry/TrackingGeometryBuilder.hpp>
7#include <Acts/Surfaces/DiamondBounds.hpp>
8#include <Acts/Surfaces/PlaneSurface.hpp>
9
10#include "Acts/Definitions/Units.hpp"
11#include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
12#include "Acts/Material/HomogeneousVolumeMaterial.hpp"
13
14// Visualization
15#include <Acts/Visualization/GeometryView3D.hpp>
16#include <Acts/Visualization/ObjVisualization3D.hpp>
17#include <Acts/Visualization/ViewConfig.hpp>
18
19// G4
20#include <G4Box.hh>
21#include <G4GDMLParser.hh>
22#include <G4LogicalVolume.hh>
23#include <G4Material.hh>
24#include <G4Polyhedra.hh>
25#include <G4Types.hh>
26#include <G4VPhysicalVolume.hh>
27#include <boost/filesystem.hpp>
28#include <string>
29
31#include "Framework/Configure/Parameters.h"
32#include "Framework/Exception/Exception.h"
33#include "Framework/Logger.h"
34#include "G4RunManager.hh"
35#include "G4UIsession.hh"
36#include "G4strstreambuf.hh"
37#include "Tracking/geo/DetectorElement.h"
38#include "Tracking/geo/GeoUtils.h"
39namespace tracking::geo {
40
54 public:
60 TrackingGeometry(const std::string& name, const Acts::GeometryContext& gctx,
61 const std::string& gdml);
62
64 virtual ~TrackingGeometry() = default;
65
66 G4VPhysicalVolume* findDaughterByName(G4VPhysicalVolume* pvol, G4String name);
67 void getAllDaughters(G4VPhysicalVolume* pvol);
68
69 static bool compareZlocation(const G4VPhysicalVolume& pvol_a,
70 const G4VPhysicalVolume& pvol_b) {
71 return (pvol_a.GetTranslation().z() < pvol_b.GetTranslation().z());
72 };
73
74 void convertG4Rot(const G4RotationMatrix* g4rot,
75 Acts::RotationMatrix3& rot) const;
76 Acts::Vector3 convertG4Pos(const G4ThreeVector& g4pos) const;
77
78 void dumpGeometry(const std::string& outputDir,
79 const Acts::GeometryContext& gctx) const;
80
81 std::shared_ptr<const Acts::TrackingGeometry> getTG() const {
82 return t_geometry_;
83 };
84
85 Acts::Transform3 getTransform(const G4VPhysicalVolume& phex,
86 bool toTrackingFrame = false) const;
87
88 Acts::Transform3 toTracker(const Acts::Transform3& trans) const;
89
90 // Tagger tracker: vol=2 , layer = [2,4,6,8,10,12,14], sensor=[1,2]
91 // Recoil tracker: vol=3 , layer = [2,4,6,8,10,12],
92 // sensor=[1,2,3,4,5,6,7,8,9,10]
93 void makeLayerSurfacesMap();
94
95 void getSurfaces(std::vector<const Acts::Surface*>& surfaces) const;
96
97 const Acts::Surface* getSurface(int layerid) const {
98 return layer_surface_map_.at(layerid);
99 }
100
101 std::unordered_map<unsigned int, const Acts::Surface*> layer_surface_map_;
102
105 const std::string& fieldMapFile() const { return field_map_file_; }
106
107 // Global vector holding all the alignable detector elements of the tracking
108 // geometry.
109 // std::vector<std::shared_ptr<DetectorElement>> det_elements_;
110 std::vector<std::shared_ptr<tracking::geo::DetectorElement>> det_elements_;
111
112 protected:
113 const Acts::GeometryContext& gctx_;
114 std::string gdml_{""};
115 // The rotation matrices to go from global to tracking frame.
116 Acts::RotationMatrix3 x_rot_, y_rot_;
117 std::shared_ptr<const Acts::TrackingGeometry> t_geometry_{nullptr};
118 G4VPhysicalVolume* f_world_phys_vol_{nullptr};
119
120 private:
121 std::string field_map_file_{""};
122 enableLogging("TrackingGeometry")
123};
124} // namespace tracking::geo
Base class for conditions information like pedestals, gains, electronics maps, etc.
Base class for all conditions objects, very simple.
This class is a abstract base class (ABC) doing common tasks that tracking geometries need done.
virtual ~TrackingGeometry()=default
Destructor.
const std::string & fieldMapFile() const
Full path to the field map file extracted from the GDML auxiliary data.
TrackingGeometry(const std::string &name, const Acts::GeometryContext &gctx, const std::string &gdml)
Visualization.