File indexing completed on 2025-08-06 08:19:26
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 else
0087 {
0088 return iter->second;
0089 }
0090 }
0091
0092
0093 G4Transform3D PHG4MicromegasSurvey::get_transformation(int layer, uint tile) const
0094 {
0095 const auto tile_iter = m_tile_map.find({layer, tile});
0096 if (tile_iter == m_tile_map.end())
0097 {
0098 std::cout << " PHG4MicromegasSurvey::get_transformation - module not found. layer: " << layer << " tile: " << tile << std::endl;
0099 return G4Transform3D();
0100 }
0101
0102 const auto& tile_name = tile_iter->second;
0103 const auto transform_iter = m_transformation_map.find(tile_name);
0104 if (transform_iter == m_transformation_map.end())
0105 {
0106 std::cout
0107 << " PHG4MicromegasSurvey::get_transformation - transformation not found."
0108 << " layer: " << layer
0109 << " tile: " << tile
0110 << " tile_name: " << tile_name
0111 << std::endl;
0112 return G4Transform3D();
0113 }
0114
0115
0116 const auto& transformation = transform_iter->second;
0117
0118
0119 const G4ThreeVector translation(
0120 transformation.m_translation[0] * cm,
0121 transformation.m_translation[1] * cm,
0122 transformation.m_translation[2] * cm);
0123
0124
0125 G4RotationMatrix rotation;
0126 rotation.rotateX(transformation.m_rotation[0] * deg);
0127 rotation.rotateY(transformation.m_rotation[1] * deg);
0128 rotation.rotateZ(transformation.m_rotation[2] * deg);
0129
0130 return G4Transform3D(rotation, translation);
0131 }