Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4MicromegasSurvey.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4MicromegasSurvey.cc
1 
7 #include "PHG4MicromegasSurvey.h"
8 
9 #include <Geant4/G4RotationMatrix.hh>
10 #include <Geant4/G4SystemOfUnits.hh>
11 #include <Geant4/G4ThreeVector.hh>
12 
13 //____________________________________________________________________________________________________
15  : // map layer and tile number to detector name
16  m_tile_map{
17  {{55, 0}, "M5P"}, {{56, 0}, "M5Z"}, {{55, 1}, "M8P"}, {{56, 1}, "M8Z"}, {{55, 2}, "M4P"}, {{56, 2}, "M4Z"}, {{55, 3}, "M10P"}, {{56, 3}, "M10Z"}, {{55, 4}, "M9P"}, {{56, 4}, "M9Z"}, {{55, 5}, "M2P"}, {{56, 5}, "M2Z"}, {{55, 6}, "M6P"}, {{56, 6}, "M6Z"}, {{55, 7}, "M7P"}, {{56, 7}, "M7Z"}}
18  ,
19 
20  // map module name to transformation
21  /*
22  * these are constructing by mapping the first and last strip positions as given by GEANT4 default implementation of TPOT
23  * to the ones measured by the survey crew
24  */
25  m_transformation_map{
26  {"M10P",
27  {{0.0238291, -0.0610202, 359.729},
28  {0.32958, 0.104316, 0.491085}}},
29  {"M10Z",
30  {{0.0240982, -0.01546, -0.267002},
31  {0.196309, -0.00618558, 0.126347}}},
32  {"M4P",
33  {{0.10541, 0.135221, -0.691686},
34  {0.775549, 0.281716, 0.603817}}},
35  {"M4Z",
36  {{0.10526, 0.122168, -0.691598},
37  {0.691176, 0.259581, 0.233525}}},
38  {"M8P",
39  {{-0.417662, 0.0569648, -0.0964277},
40  {-0.0666588, 0.366775, -0.147532}}},
41  {"M8Z",
42  {{-0.417529, 0.120316, -0.0951897},
43  {-0.086922, 0.333419, -0.512579}}},
44  {"M5P",
45  {{-0.202661, 0.0403903, -0.235734},
46  {0.153994, 0.313934, 0.13618}}},
47  {"M5Z",
48  {{-0.203231, 0.0481545, -0.228361},
49  {0.0652422, 0.30468, -0.241307}}},
50  {"M2P",
51  {{0.0243278, 0.0186967, 0.524609},
52  {-1.1679, 0.746204, 0.704047}}},
53  {"M2Z",
54  {{-0.00159013, -0.0326792, 0.522416},
55  {-1.21045, 0.7655, 0.315458}}},
56  {"M9P",
57  {{-0.172856, 0.156516, 0.630981},
58  {-1.23611, 0.828348, 0.349842}}},
59  {"M9Z",
60  {{-0.174169, 0.153218, 0.632272},
61  {-1.32091, 0.861492, -0.0240633}}},
62  {"M7P",
63  {{-0.0802472, 0.12362, 0.804231},
64  {-1.15284, -0.140113, 0.102525}}},
65  {"M7Z",
66  {{-0.0822581, 0.127216, 0.803837},
67  {-1.20763, -0.242328, -0.269243}}},
68  {"M6P",
69  {{-0.221227, -0.0357901, 0.597703},
70  {-0.951645, 0.183264, -0.169542}}},
71  {"M6Z",
72  {{-0.169038, -0.126228, 0.59627},
73  {-0.99097, -0.0452179, -0.574241}}}}
74 {
75 }
76 
77 //____________________________________________________________________________________________________
79 {
80  const auto iter = m_tile_map.find({layer, tile});
81  if (iter == m_tile_map.end())
82  {
83  std::cout << " PHG4MicromegasSurvey::get_module_name - module not found. layer: " << layer << " tile: " << tile << std::endl;
84  return std::string();
85  }
86  else
87  {
88  return iter->second;
89  }
90 }
91 
92 //____________________________________________________________________________________________________
93 G4Transform3D PHG4MicromegasSurvey::get_transformation(int layer, uint tile) const
94 {
95  const auto tile_iter = m_tile_map.find({layer, tile});
96  if (tile_iter == m_tile_map.end())
97  {
98  std::cout << " PHG4MicromegasSurvey::get_transformation - module not found. layer: " << layer << " tile: " << tile << std::endl;
99  return G4Transform3D();
100  }
101 
102  const auto& tile_name = tile_iter->second;
103  const auto transform_iter = m_transformation_map.find(tile_name);
104  if (transform_iter == m_transformation_map.end())
105  {
106  std::cout
107  << " PHG4MicromegasSurvey::get_transformation - transformation not found."
108  << " layer: " << layer
109  << " tile: " << tile
110  << " tile_name: " << tile_name
111  << std::endl;
112  return G4Transform3D();
113  }
114 
115  // get transformation
116  const auto& transformation = transform_iter->second;
117 
118  // translation
119  const G4ThreeVector translation(
120  transformation.m_translation[0] * cm,
121  transformation.m_translation[1] * cm,
122  transformation.m_translation[2] * cm);
123 
124  // rotation
125  G4RotationMatrix rotation;
126  rotation.rotateX(transformation.m_rotation[0] * deg);
127  rotation.rotateY(transformation.m_rotation[1] * deg);
128  rotation.rotateZ(transformation.m_rotation[2] * deg);
129 
130  return G4Transform3D(rotation, translation);
131 }