File indexing completed on 2025-12-17 09:22:07
0001
0002
0003
0004
0005
0006
0007 #include "PHG4MicromegasSurvey.h"
0008
0009 #include <Geant4/G4RotationMatrix.hh>
0010 #include <Geant4/G4SystemOfUnits.hh>
0011 #include <Geant4/G4ThreeVector.hh>
0012
0013
0014 PHG4MicromegasSurvey::PHG4MicromegasSurvey()
0015 :
0016 m_tile_map{
0017 {{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"}}
0018 ,
0019
0020
0021
0022
0023
0024
0025 m_transformation_map{
0026 {"M10P",
0027 {{0.0238291, -0.0610202, 359.729},
0028 {0.32958, 0.104316, 0.491085}}},
0029 {"M10Z",
0030 {{0.0240982, -0.01546, -0.267002},
0031 {0.196309, -0.00618558, 0.126347}}},
0032 {"M4P",
0033 {{0.10541, 0.135221, -0.691686},
0034 {0.775549, 0.281716, 0.603817}}},
0035 {"M4Z",
0036 {{0.10526, 0.122168, -0.691598},
0037 {0.691176, 0.259581, 0.233525}}},
0038 {"M8P",
0039 {{-0.417662, 0.0569648, -0.0964277},
0040 {-0.0666588, 0.366775, -0.147532}}},
0041 {"M8Z",
0042 {{-0.417529, 0.120316, -0.0951897},
0043 {-0.086922, 0.333419, -0.512579}}},
0044 {"M5P",
0045 {{-0.202661, 0.0403903, -0.235734},
0046 {0.153994, 0.313934, 0.13618}}},
0047 {"M5Z",
0048 {{-0.203231, 0.0481545, -0.228361},
0049 {0.0652422, 0.30468, -0.241307}}},
0050 {"M2P",
0051 {{0.0243278, 0.0186967, 0.524609},
0052 {-1.1679, 0.746204, 0.704047}}},
0053 {"M2Z",
0054 {{-0.00159013, -0.0326792, 0.522416},
0055 {-1.21045, 0.7655, 0.315458}}},
0056 {"M9P",
0057 {{-0.172856, 0.156516, 0.630981},
0058 {-1.23611, 0.828348, 0.349842}}},
0059 {"M9Z",
0060 {{-0.174169, 0.153218, 0.632272},
0061 {-1.32091, 0.861492, -0.0240633}}},
0062 {"M7P",
0063 {{-0.0802472, 0.12362, 0.804231},
0064 {-1.15284, -0.140113, 0.102525}}},
0065 {"M7Z",
0066 {{-0.0822581, 0.127216, 0.803837},
0067 {-1.20763, -0.242328, -0.269243}}},
0068 {"M6P",
0069 {{-0.221227, -0.0357901, 0.597703},
0070 {-0.951645, 0.183264, -0.169542}}},
0071 {"M6Z",
0072 {{-0.169038, -0.126228, 0.59627},
0073 {-0.99097, -0.0452179, -0.574241}}}}
0074 {
0075 }
0076
0077
0078 std::string PHG4MicromegasSurvey::get_module_name(int layer, uint tile) const
0079 {
0080 const auto iter = m_tile_map.find({layer, tile});
0081 if (iter == m_tile_map.end())
0082 {
0083 std::cout << " PHG4MicromegasSurvey::get_module_name - module not found. layer: " << layer << " tile: " << tile << std::endl;
0084 return std::string();
0085 }
0086
0087 return iter->second;
0088 }
0089
0090
0091 G4Transform3D PHG4MicromegasSurvey::get_transformation(int layer, uint tile) const
0092 {
0093 const auto tile_iter = m_tile_map.find({layer, tile});
0094 if (tile_iter == m_tile_map.end())
0095 {
0096 std::cout << " PHG4MicromegasSurvey::get_transformation - module not found. layer: " << layer << " tile: " << tile << std::endl;
0097 return G4Transform3D();
0098 }
0099
0100 const auto& tile_name = tile_iter->second;
0101 const auto transform_iter = m_transformation_map.find(tile_name);
0102 if (transform_iter == m_transformation_map.end())
0103 {
0104 std::cout
0105 << " PHG4MicromegasSurvey::get_transformation - transformation not found."
0106 << " layer: " << layer
0107 << " tile: " << tile
0108 << " tile_name: " << tile_name
0109 << std::endl;
0110 return G4Transform3D();
0111 }
0112
0113
0114 const auto& transformation = transform_iter->second;
0115
0116
0117 const G4ThreeVector translation(
0118 transformation.m_translation[0] * cm,
0119 transformation.m_translation[1] * cm,
0120 transformation.m_translation[2] * cm);
0121
0122
0123 G4RotationMatrix rotation;
0124 rotation.rotateX(transformation.m_rotation[0] * deg);
0125 rotation.rotateY(transformation.m_rotation[1] * deg);
0126 rotation.rotateZ(transformation.m_rotation[2] * deg);
0127
0128 return G4Transform3D(rotation, translation);
0129 }