File indexing completed on 2025-08-06 08:17:39
0001 #include "CylinderGeomIntt.h"
0002
0003 #include <algorithm>
0004 #include <cmath>
0005 #include <memory> // for __shared_ptr_access
0006 #include <utility>
0007
0008 void CylinderGeomIntt::identify(std::ostream& os) const
0009 {
0010 os << "CylinderGeomIntt Object" << std::endl;
0011 os << "layer: " << get_layer() << std::endl;
0012 os << "Radius: " << get_radius() << std::endl;
0013 }
0014
0015 void CylinderGeomIntt::find_indices_from_world_location(int& segment_z_bin, int& segment_phi_bin, double location[])
0016 {
0017 double signz = (location[2] > 0) ? 1. : -1;
0018 double phi = atan2(location[1], location[0]);
0019 double tolerance_phi = 0.05;
0020 double tolerance_z = 0.5;
0021
0022 if (fabs(phi - m_OffsetPhi) > tolerance_phi && phi < 0)
0023 {
0024 phi += 2.0 * M_PI;
0025 }
0026 double segment_phi_bin_tmp = (phi - m_OffsetPhi) / m_dPhi;
0027 segment_phi_bin = round(segment_phi_bin_tmp);
0028
0029 double z_tmp = location[2] / signz;
0030
0031
0032 int itype;
0033
0034 if (fabs((1.0 - z_tmp / m_LadderZ[0])) < tolerance_z)
0035 {
0036 itype = 0;
0037 }
0038 else
0039 {
0040 itype = 1;
0041 }
0042
0043 if (signz < 0)
0044 {
0045 segment_z_bin = itype;
0046 }
0047 else
0048 {
0049 segment_z_bin = itype + 2;
0050 }
0051 }
0052
0053 void CylinderGeomIntt::find_indices_from_segment_center(int& segment_z_bin, int& segment_phi_bin, double location[])
0054 {
0055 double signz = (location[2] > 0) ? 1. : -1;
0056 double phi = atan2(location[1], location[0]);
0057
0058 double tolerance_phi = 0.05;
0059 double tolerance_z = 0.5;
0060 if (fabs(phi - m_OffsetPhi) > tolerance_phi && phi < 0)
0061 {
0062 phi += 2.0 * M_PI;
0063 }
0064 double segment_phi_bin_tmp = (phi - m_OffsetPhi) / m_dPhi;
0065 segment_phi_bin = lround(segment_phi_bin_tmp);
0066
0067
0068
0069 double z_tmp = location[2] / signz;
0070
0071
0072 int itype;
0073 if (fabs((1.0 - z_tmp / m_LadderZ[0])) < tolerance_z)
0074 {
0075 itype = 0;
0076 }
0077 else
0078 {
0079 itype = 1;
0080 }
0081
0082 if (signz < 0)
0083 {
0084 segment_z_bin = itype;
0085 }
0086 else
0087 {
0088 segment_z_bin = itype + 2;
0089 }
0090
0091
0092
0093 }
0094
0095 void CylinderGeomIntt::find_strip_index_values(const int segment_z_bin, const double yin, const double zin, int& strip_y_index, int& strip_z_index)
0096 {
0097
0098
0099
0100 const int itype = segment_z_bin % 2;
0101 if (itype != 0 && itype != 1)
0102 {
0103 std::cout << "Problem: itype = " << itype << std::endl;
0104 return;
0105 }
0106
0107
0108 double zpos = zin;
0109 double ypos = yin;
0110
0111 const double strip_z = m_StripZ[itype];
0112 const int nstrips_z_sensor = m_NStripsZSensor[itype];
0113 const int nstrips_y_sensor = m_NStripsPhiCell;
0114
0115
0116 double zup = (double) nstrips_z_sensor * strip_z / 2.0 + zpos;
0117 strip_z_index = floor(zup / strip_z);
0118
0119
0120 double yup = (double) nstrips_y_sensor * m_StripY / 2.0 + ypos;
0121 strip_y_index = floor(yup / m_StripY);
0122
0123
0124
0125
0126
0127
0128
0129 }
0130
0131
0132
0133 void CylinderGeomIntt::find_strip_center_localcoords(const int segment_z_bin, const int strip_y_index, const int strip_z_index, double location[])
0134 {
0135
0136 const int itype = segment_z_bin % 2;
0137 if (itype != 0 && itype != 1)
0138 {
0139 std::cout << "Problem: itype = " << itype << std::endl;
0140 return;
0141 }
0142
0143 const double strip_z = m_StripZ[itype];
0144 const int nstrips_z_sensor = m_NStripsZSensor[itype];
0145 const int nstrips_y_sensor = m_NStripsPhiCell;
0146
0147
0148 double ypos = (double) strip_y_index * m_StripY + m_StripY / 2.0 - (double) nstrips_y_sensor * m_StripY / 2.0;
0149
0150
0151 double zpos = (double) strip_z_index * strip_z + strip_z / 2.0 - (double) nstrips_z_sensor * strip_z / 2.0;
0152
0153 location[0] = 0.0;
0154 location[1] = ypos;
0155 location[2] = zpos;
0156 }