Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CylinderGeomv4.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CylinderGeomv4.cc
1 #include "PHG4CylinderGeomv4.h"
2 
3 #include <cmath>
4 
5 void PHG4CylinderGeomv4::identify(std::ostream& os) const
6 {
7  os << "PHG4CylinderGeomv4: layer: " << layer
8  << ", layer_radius: " << layer_radius
9  << ", radius_stagger: " << radius_stagger
10  << ", N_sensors_in_layer: " << N_sensors_in_layer
11  << ", layer_NZ: " << layer_NZ
12  << ", segment_z_step: " << segment_z_step
13  << ", segment_phi_step: " << segment_phi_step
14  << ", sensor_x_offset: " << sensor_x_offset
15  << ", sensor_y_offset: " << sensor_y_offset
16  << ", N_strip_columns: " << N_strip_columns
17  << ", N_strips_per_column: " << N_strips_per_column
18  << ", N_staggers " << N_staggers
19  << ", strip_z_spacing: " << strip_z_spacing
20  << ", strip_y_spacing: " << strip_y_spacing
21  << ", strip_tilt: " << strip_tilt
22  << std::endl;
23  return;
24 }
25 
26 void PHG4CylinderGeomv4::find_segment_center(int segment_z_bin, int segment_phi_bin, double location[])
27 {
28  double z_location = (double) (segment_z_bin - layer_NZ / 2) * segment_z_step;
29 
30  // this determines the stggered layer radius
31  int istagger = segment_phi_bin % N_staggers;
32 
33  // We need to stagger the radii at alternate phi values by radius_stagger, since the ladders overlap in phi
34  // The number of staggers is an input number, since it has to be the same for both parts of a double layer!
35  double R_layer = layer_radius + (double) istagger * radius_stagger;
36 
37  // Place the ladder segment envelopes at the correct z and phi
38  double phi = (double) segment_phi_bin * segment_phi_step;
39 
40  double x_location = R_layer * cos(phi);
41  double y_location = R_layer * sin(phi);
42 
43  location[0] = x_location;
44  location[1] = y_location;
45  location[2] = z_location;
46 }
47 
48 void PHG4CylinderGeomv4::find_strip_center(int segment_z_bin, int segment_phi_bin, int strip_column, int strip_index, double location[])
49 {
50  // Start by getting the ladder segment center location in the sPHENIX frame
51  find_segment_center(segment_z_bin, segment_phi_bin, location);
52 
53  // Now calculate the strip x, y and z position in the frame of the ladder segment
54  // 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
55  // if it is odd, the center of the sensor is in the middle of a strip column, one strip is centered at zero
56 
57  double strip_sensor_z = 0.0;
58  if (N_strip_columns % 2)
59  strip_sensor_z = ((double) (strip_column - N_strip_columns / 2)) * strip_z_spacing;
60  else
61  strip_sensor_z = ((double) (strip_column - N_strip_columns / 2) + 0.5) * strip_z_spacing;
62 
63  double strip_sensor_y = 0.0;
64  if (N_strips_per_column % 2)
65  strip_sensor_y = (double) (strip_index - N_strips_per_column / 2) * strip_y_spacing;
66  else
67  strip_sensor_y = ((double) (strip_index - N_strips_per_column / 2) + 0.5) * strip_y_spacing;
68 
69  // The sensor is set forward of the center in the ladder segment volume
70  double strip_sensor_x = sensor_x_offset;
71 
72  // If there is only an upper ROC, the sensor is not centered in the ladder segment
73  // Add the sensor offset to the strip_sensor_y value
74 
75  strip_sensor_y += sensor_y_offset;
76 
77  // Now we need to transform the position in the ladder segment frame to that in the sPHENIX frame
78  // this is just a rotation around the z axis in phi
79  double phi = (double) segment_phi_bin * segment_phi_step;
80  double x = strip_sensor_x * cos(phi) - strip_sensor_y * sin(phi);
81  double y = strip_sensor_y * cos(phi) + strip_sensor_x * sin(phi);
82 
83  // now add these to the location of the sensor center in the sPHENIX frame
84  location[0] += x;
85  location[1] += y;
86  location[2] += strip_sensor_z;
87 
88  return;
89 }