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 "Tracking/geo/DetectorElement.h"
34
35namespace tracking::geo {
36
50 public:
57 TrackingGeometry(const std::string& name, const Acts::GeometryContext& gctx,
58 const std::string& gdml, bool debug);
59
61 virtual ~TrackingGeometry() = default;
62
63 G4VPhysicalVolume* findDaughterByName(G4VPhysicalVolume* pvol, G4String name);
64 void getAllDaughters(G4VPhysicalVolume* pvol);
65
66 static bool compareZlocation(const G4VPhysicalVolume& pvol_a,
67 const G4VPhysicalVolume& pvol_b) {
68 return (pvol_a.GetTranslation().z() < pvol_b.GetTranslation().z());
69 };
70
71 void ConvertG4Rot(const G4RotationMatrix* g4rot,
72 Acts::RotationMatrix3& rot) const;
73 Acts::Vector3 ConvertG4Pos(const G4ThreeVector& g4pos) const;
74
75 void dumpGeometry(const std::string& outputDir,
76 const Acts::GeometryContext& gctx) const;
77
78 std::shared_ptr<const Acts::TrackingGeometry> getTG() const {
79 return tGeometry_;
80 };
81
82 Acts::Transform3 GetTransform(const G4VPhysicalVolume& phex,
83 bool toTrackingFrame = false) const;
84
85 Acts::Transform3 toTracker(const Acts::Transform3& trans) const;
86
87 // Tagger tracker: vol=2 , layer = [2,4,6,8,10,12,14], sensor=[1,2]
88 // Recoil tracker: vol=3 , layer = [2,4,6,8,10,12],
89 // sensor=[1,2,3,4,5,6,7,8,9,10]
90 void makeLayerSurfacesMap();
91
92 void getSurfaces(std::vector<const Acts::Surface*>& surfaces) const;
93
94 const Acts::Surface* getSurface(int layerid) const {
95 return layer_surface_map_.at(layerid);
96 }
97
98 std::unordered_map<unsigned int, const Acts::Surface*> layer_surface_map_;
99
100 // Global vector holding all the alignable detector elements of the tracking
101 // geometry.
102 std::vector<std::shared_ptr<DetectorElement>> detElements;
103
104 protected:
105 // This is not actually used anywhere
106 // TODO:: Remove this.
107 const Acts::GeometryContext& gctx_;
108
109 std::string gdml_{""};
110 bool debug_{false};
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> tGeometry_{nullptr};
114 G4VPhysicalVolume* fWorldPhysVol_{nullptr};
115};
116} // 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.
Visualization.