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"
39
40namespace tracking::geo {
41
55 public:
61 TrackingGeometry(const std::string& name, const Acts::GeometryContext& gctx,
62 const std::string& gdml);
63
65 virtual ~TrackingGeometry() = default;
66
67 G4VPhysicalVolume* findDaughterByName(G4VPhysicalVolume* pvol, G4String name);
68 void getAllDaughters(G4VPhysicalVolume* pvol);
69
70 static bool compareZlocation(const G4VPhysicalVolume& pvol_a,
71 const G4VPhysicalVolume& pvol_b) {
72 return (pvol_a.GetTranslation().z() < pvol_b.GetTranslation().z());
73 };
74
75 void convertG4Rot(const G4RotationMatrix* g4rot,
76 Acts::RotationMatrix3& rot) const;
77 Acts::Vector3 convertG4Pos(const G4ThreeVector& g4pos) const;
78
79 void dumpGeometry(const std::string& outputDir,
80 const Acts::GeometryContext& gctx) const;
81
82 std::shared_ptr<const Acts::TrackingGeometry> getTG() const {
83 return t_geometry_;
84 };
85
86 Acts::Transform3 getTransform(const G4VPhysicalVolume& phex,
87 bool toTrackingFrame = false) const;
88
89 Acts::Transform3 toTracker(const Acts::Transform3& trans) const;
90
91 // Tagger tracker: vol=2 , layer = [2,4,6,8,10,12,14], sensor=[1,2]
92 // Recoil tracker: vol=3 , layer = [2,4,6,8,10,12],
93 // sensor=[1,2,3,4,5,6,7,8,9,10]
94 void makeLayerSurfacesMap();
95
96 void getSurfaces(std::vector<const Acts::Surface*>& surfaces) const;
97
98 const Acts::Surface* getSurface(int layerid) const {
99 return layer_surface_map_.at(layerid);
100 }
101
102 std::unordered_map<unsigned int, const Acts::Surface*> layer_surface_map_;
103
104 // Global vector holding all the alignable detector elements of the tracking
105 // geometry.
106 std::vector<std::shared_ptr<DetectorElement>> det_elements_;
107
108 protected:
109 const Acts::GeometryContext& gctx_;
110 std::string gdml_{""};
111 // The rotation matrices to go from global to tracking frame.
112 Acts::RotationMatrix3 x_rot_, y_rot_;
113 std::shared_ptr<const Acts::TrackingGeometry> t_geometry_{nullptr};
114 G4VPhysicalVolume* f_world_phys_vol_{nullptr};
115
116 private:
117 enableLogging("TrackingGeometry")
118};
119} // 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.
TrackingGeometry(const std::string &name, const Acts::GeometryContext &gctx, const std::string &gdml)
Visualization.