Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:57

0001 #include "PHG4CylinderGeomv4.h"
0002 
0003 #include <cmath>
0004 
0005 void PHG4CylinderGeomv4::identify(std::ostream& os) const
0006 {
0007   os << "PHG4CylinderGeomv4: layer: " << layer
0008      << ", layer_radius: " << layer_radius
0009      << ", radius_stagger: " << radius_stagger
0010      << ", N_sensors_in_layer: " << N_sensors_in_layer
0011      << ", layer_NZ: " << layer_NZ
0012      << ", segment_z_step: " << segment_z_step
0013      << ", segment_phi_step: " << segment_phi_step
0014      << ", sensor_x_offset: " << sensor_x_offset
0015      << ", sensor_y_offset: " << sensor_y_offset
0016      << ", N_strip_columns: " << N_strip_columns
0017      << ", N_strips_per_column: " << N_strips_per_column
0018      << ", N_staggers " << N_staggers
0019      << ", strip_z_spacing: " << strip_z_spacing
0020      << ", strip_y_spacing: " << strip_y_spacing
0021      << ", strip_tilt: " << strip_tilt
0022      << std::endl;
0023   return;
0024 }
0025 
0026 void PHG4CylinderGeomv4::find_segment_center(int segment_z_bin, int segment_phi_bin, double location[])
0027 {
0028   // NOLINTNEXTLINE(bugprone-integer-division)
0029   double z_location = (double) (segment_z_bin - layer_NZ / 2) * segment_z_step;
0030 
0031   // this determines the stggered layer radius
0032   int istagger = segment_phi_bin % N_staggers;
0033 
0034   // We need to stagger the radii at alternate phi values by radius_stagger, since the ladders overlap in phi
0035   // The number of staggers is an input number, since it has to be the same for both parts of a double layer!
0036   double R_layer = layer_radius + (double) istagger * radius_stagger;
0037 
0038   // Place the ladder segment envelopes at the correct z and phi
0039   double phi = (double) segment_phi_bin * segment_phi_step;
0040 
0041   double x_location = R_layer * cos(phi);
0042   double y_location = R_layer * sin(phi);
0043 
0044   location[0] = x_location;
0045   location[1] = y_location;
0046   location[2] = z_location;
0047 }
0048 
0049 void PHG4CylinderGeomv4::find_strip_center(int segment_z_bin, int segment_phi_bin, int strip_column, int strip_index, double location[])
0050 {
0051   // Start  by getting the ladder segment center location in the sPHENIX frame
0052   find_segment_center(segment_z_bin, segment_phi_bin, location);
0053 
0054   // Now calculate the strip x, y and z position in the frame of the ladder segment
0055   // if N_strip_columns is even, the center of the sensor is a boundary between strip columns, the first sensor is 1/2 strip_z_spacing from zero
0056   // if it is odd, the center of the sensor is in the middle of a strip column, one strip is centered at zero
0057 
0058   double strip_sensor_z = 0.0;
0059   if (N_strip_columns % 2)
0060   {
0061     // NOLINTNEXTLINE(bugprone-integer-division)
0062     strip_sensor_z = ((double) (strip_column - N_strip_columns / 2)) * strip_z_spacing;
0063   }
0064   else
0065   {
0066     // NOLINTNEXTLINE(bugprone-integer-division)
0067     strip_sensor_z = ((double) (strip_column - N_strip_columns / 2) + 0.5) * strip_z_spacing;
0068   }
0069 
0070   double strip_sensor_y = 0.0;
0071   if (N_strips_per_column % 2)
0072   {
0073     // NOLINTNEXTLINE(bugprone-integer-division)
0074     strip_sensor_y = (double) (strip_index - N_strips_per_column / 2) * strip_y_spacing;
0075   }
0076   else
0077   {
0078     // NOLINTNEXTLINE(bugprone-integer-division)
0079     strip_sensor_y = ((double) (strip_index - N_strips_per_column / 2) + 0.5) * strip_y_spacing;
0080   }
0081 
0082   // The sensor is set forward of the center in the ladder segment volume
0083   double strip_sensor_x = sensor_x_offset;
0084 
0085   // If there is only an upper ROC, the sensor is not centered in the ladder segment
0086   // Add the sensor offset to the strip_sensor_y value
0087 
0088   strip_sensor_y += sensor_y_offset;
0089 
0090   // Now we need to transform the position in the ladder segment frame to that in the sPHENIX frame
0091   // this is just a rotation around the z axis in phi
0092   double phi = (double) segment_phi_bin * segment_phi_step;
0093   double x = strip_sensor_x * cos(phi) - strip_sensor_y * sin(phi);
0094   double y = strip_sensor_y * cos(phi) + strip_sensor_x * sin(phi);
0095 
0096   // now add these to the location of the sensor center in the sPHENIX frame
0097   location[0] += x;
0098   location[1] += y;
0099   location[2] += strip_sensor_z;
0100 
0101   return;
0102 }