Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeActsGeometry.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MakeActsGeometry.h
1 
8 #ifndef MAKE_ACTS_GEOMETRY_H
9 #define MAKE_ACTS_GEOMETRY_H
10 
11 #include <fun4all/SubsysReco.h>
12 #include <trackbase/TrkrDefs.h>
13 
14 #include <trackbase/ActsGeometry.h>
15 
18 #include <Acts/Utilities/Logger.hpp>
24 
26 
27 #include <boost/program_options.hpp>
28 
29 #include <map>
30 #include <memory>
31 #include <string>
32 #include <vector>
33 
34 class PHCompositeNode;
37 class TGeoManager;
38 class TGeoNode;
39 class TGeoVolume;
40 
41 namespace Acts
42 {
43  class Surface;
44 }
45 
46 using Surface = std::shared_ptr<const Acts::Surface>;
47 using TrackingGeometry = std::shared_ptr<const Acts::TrackingGeometry>;
48 //using TrackingGeometry = std::shared_ptr<Acts::TrackingGeometry>;
49 using TrackingVolumePtr = std::shared_ptr<const Acts::TrackingVolume>;
50 
59 {
60  public:
61 
63  MakeActsGeometry(const std::string& name = "MakeActsGeometry");
64 
66  ~MakeActsGeometry() override = default;
67 
68  int Init(PHCompositeNode *topNode) override;
69  int InitRun(PHCompositeNode *topNode) override;
70 
71  void loadMagField(const bool field) { m_useField = field; }
72  void setMagField(const std::string &magField)
73  {m_magField = magField;}
74  void setMagFieldRescale(double magFieldRescale)
75  {m_magFieldRescale = magFieldRescale;}
76 
77 
78  void setMvtxDev(double array[6])
79  {
80  m_mvtxDevs[0] = array[0];
81  m_mvtxDevs[1] = array[1];
82  m_mvtxDevs[2] = array[2];
83  m_mvtxDevs[3] = array[3];
84  m_mvtxDevs[4] = array[4];
85  m_mvtxDevs[5] = array[5];
86 
87  mvtxParam = true;
88  }
89  void setInttDev(double array[6])
90  {
91  m_inttDevs[0] = array[0];
92  m_inttDevs[1] = array[1];
93  m_inttDevs[2] = array[2];
94  m_inttDevs[3] = array[3];
95  m_inttDevs[4] = array[4];
96  m_inttDevs[5] = array[5];
97 
98  inttParam = true;
99  }
100  void setTpcDev(double array[6])
101  {
102  m_tpcDevs[0] = array[0];
103  m_tpcDevs[1] = array[1];
104  m_tpcDevs[2] = array[2];
105  m_tpcDevs[3] = array[3];
106  m_tpcDevs[4] = array[4];
107  m_tpcDevs[5] = array[5];
108 
109  tpcParam = true;
110  }
111  void setMmDev(double array[6])
112  {
113  m_mmDevs[0] = array[0];
114  m_mmDevs[1] = array[1];
115  m_mmDevs[2] = array[2];
116  m_mmDevs[3] = array[3];
117  m_mmDevs[4] = array[4];
118  m_mmDevs[5] = array[5];
119 
120  mmParam = true;
121  }
122 
123 
124  void misalignmentFactor(uint8_t layer, const double misalignment)
125  {
126  auto it = m_misalignmentFactor.find(layer);
127  if(it != m_misalignmentFactor.end())
128  {
129  it->second = misalignment;
130  return;
131  }
132  }
133 
134  double getSurfStepPhi() {return m_surfStepPhi;}
135  double getSurfStepZ() {return m_surfStepZ;}
136 
137  void set_drift_velocity(double vd){m_drift_velocity = vd;}
138 
139  void set_nSurfPhi( unsigned int value )
140  { m_nSurfPhi = value; }
141  void set_intt_survey(bool surv) { m_inttSurvey = surv; }
142 
143  private:
145  int buildAllGeometry(PHCompositeNode *topNode);
146 
149 
152 
155  void editTPCGeometry(PHCompositeNode *topNode);
156  void addActsTpcSurfaces(TGeoVolume *tpc_gas_vol,
157  TGeoManager *geoManager);
158 
160  void buildActsSurfaces();
161 
163  void makeGeometry(int argc, char* argv[],
165  std::pair<std::shared_ptr<const Acts::TrackingGeometry>,
166  std::vector<std::shared_ptr<ActsExamples::IContextDecorator>>>
167  build(const boost::program_options::variables_map& vm,
169 
172 
173  void setMaterialResponseFile(std::string& responseFile,
174  std::string& materialFile);
175 
177  void getInttKeyFromNode(TGeoNode *gnode);
178  void getMvtxKeyFromNode(TGeoNode *gnode);
179  void getTpcKeyFromNode(TGeoNode *gnode);
180 
183  void makeMvtxMapPairs(TrackingVolumePtr &mvtxVolume);
184  void makeInttMapPairs(TrackingVolumePtr &inttVolume);
185  void makeTpcMapPairs(TrackingVolumePtr &tpcVolume);
186 
188  void makeMmMapPairs(TrackingVolumePtr &tpcVolume);
189 
192  std::vector<double> &world);
194  std::vector<double> &world);
195  TrkrDefs::hitsetkey getTpcHitSetKeyFromCoords(std::vector<double> &world);
196 
197 // /// Helper diagnostic function for identifying active layers in subdetectors
198 // void isActive(TGeoNode *gnode, int nmax_print);
199 
200 // /// Makes map of TrkrHitSetKey<-->TGeoNode
201 // void makeTGeoNodeMap(PHCompositeNode *topNode);
202 
203  void unpackVolumes();
204 
210  TGeoManager* m_geoManager = nullptr;
211 
212  bool m_inttSurvey = false;
213 
214  bool m_useField = true;
215  std::map<uint8_t, double> m_misalignmentFactor;
216 
218  std::map<TrkrDefs::hitsetkey, TGeoNode*> m_clusterNodeMap;
219  std::map<TrkrDefs::hitsetkey, Surface> m_clusterSurfaceMapSilicon;
220  std::map<unsigned int, std::vector<Surface>> m_clusterSurfaceMapTpcEdit; // uses layer as key
221  std::map<TrkrDefs::hitsetkey, Surface> m_clusterSurfaceMapMmEdit;
222 
224  static constexpr unsigned int m_nTpcLayers = 48;
225  static constexpr unsigned int m_nTpcModulesPerLayer = 12;
226  static constexpr unsigned int m_nTpcSides = 2;
227 
229  double m_minSurfZ = 0.;
232  double m_maxSurfZ = 105.42;
233  unsigned int m_nSurfZ = 1;
234  unsigned int m_nSurfPhi = 12;
235  double m_surfStepPhi = 0;
236  double m_surfStepZ = 0;
237  double m_moduleStepPhi = 0;
238  double m_modulePhiStart = 0;
239 
241  int nprint_tpc = 0;
242 
244  const static int m_nTpcSectors = 3;
245 
248 
249  // Spaces to prevent boxes from touching when placed
250  const double half_width_clearance_thick = 0.4999;
251  const double half_width_clearance_phi = 0.4999;
253  const double half_width_clearance_z = 0.5;
254 
257 
260  std::shared_ptr<Acts::MagneticFieldProvider> m_magneticField;
262 
265 
267  int m_verbosity = 0;
268 
269  double m_drift_velocity = 8.0e-03; // cm/ns, override from macro
270 
273  double m_magFieldRescale = -1.;
274 
275  double m_mvtxDevs[6] = {0};
276  double m_inttDevs[6] = {0};
277  double m_tpcDevs[6] = {0};
278  double m_mmDevs[6] = {0};
279 
280  bool mvtxParam = false;
281  bool inttParam = false;
282  bool tpcParam = false;
283  bool mmParam = false;
284 
285 };
286 
287 #endif