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
8// Visualization
9#include <Acts/Visualization/GeometryView3D.hpp>
10
11// G4
12#include <G4VPhysicalVolume.hh>
13#include <string>
14
16#include "Framework/Logger.h"
17#include "G4RunManager.hh"
18#include "Tracking/geo/DetectorElement.h"
19namespace tracking::geo {
20
34 public:
40 TrackingGeometry(const std::string& name, const Acts::GeometryContext& gctx,
41 const std::string& gdml);
42
44 virtual ~TrackingGeometry() = default;
45
46 G4VPhysicalVolume* findDaughterByName(G4VPhysicalVolume* pvol, G4String name);
47 void getAllDaughters(G4VPhysicalVolume* pvol);
48
49 static bool compareZlocation(const G4VPhysicalVolume& pvol_a,
50 const G4VPhysicalVolume& pvol_b) {
51 return (pvol_a.GetTranslation().z() < pvol_b.GetTranslation().z());
52 };
53
54 void convertG4Rot(const G4RotationMatrix* g4rot,
55 Acts::RotationMatrix3& rot) const;
56 Acts::Vector3 convertG4Pos(const G4ThreeVector& g4pos) const;
57
58 void dumpGeometry(const std::string& outputDir,
59 const Acts::GeometryContext& gctx) const;
60
61 std::shared_ptr<const Acts::TrackingGeometry> getTG() const {
62 return t_geometry_;
63 };
64
65 Acts::Transform3 getTransform(const G4VPhysicalVolume& phex,
66 bool toTrackingFrame = false) const;
67
68 Acts::Transform3 toTracker(const Acts::Transform3& trans) const;
69
70 // Tagger tracker: vol=2 , layer = [2,4,6,8,10,12,14], sensor=[1,2]
71 // Recoil tracker: vol=3 , layer = [2,4,6,8,10,12],
72 // sensor=[1,2,3,4,5,6,7,8,9,10]
73 void makeLayerSurfacesMap();
74
75 void getSurfaces(std::vector<const Acts::Surface*>& surfaces) const;
76
77 const Acts::Surface* getSurface(int layerid) const {
78 return layer_surface_map_.at(layerid);
79 }
80
81 std::unordered_map<unsigned int, const Acts::Surface*> layer_surface_map_;
82
85 const std::string& fieldMapFile() const { return field_map_file_; }
86
87 // Global vector holding all the alignable detector elements of the tracking
88 // geometry.
89 // std::vector<std::shared_ptr<DetectorElement>> det_elements_;
90 std::vector<std::shared_ptr<tracking::geo::DetectorElement>> det_elements_;
91
92 protected:
93 const Acts::GeometryContext& gctx_;
94 std::string gdml_{""};
95 // The rotation matrices to go from global to tracking frame.
96 Acts::RotationMatrix3 x_rot_, y_rot_;
97 std::shared_ptr<const Acts::TrackingGeometry> t_geometry_{nullptr};
98 G4VPhysicalVolume* f_world_phys_vol_{nullptr};
99
100 private:
101 std::string field_map_file_{""};
102 enableLogging("TrackingGeometry")
103};
104} // 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.