Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTOFGeometry.cc
Go to the documentation of this file.
1 // TOF Geometry class
2 #include <DTOFGeometry.h>
3 #include <map>
4 #include <vector>
5 
6 // Constructor
7 DTOFGeometry::DTOFGeometry(const DGeometry* locGeometry) {
8  vector<double> tmp;
9  locGeometry->GetTOFZ(tmp);
10 
11  // Store the z position for both planes
12  vector<double>tof_face;
13  locGeometry->Get("//section/composition/posXYZ[@volume='ForwardTOF']/@X_Y_Z",tof_face);
14  vector<double>tof_plane0;
15  locGeometry->Get("//composition[@name='ForwardTOF']/posXYZ[@volume='forwardTOF']/@X_Y_Z/plane[@value='0']", tof_plane0);
16  vector<double>tof_plane1;
17  locGeometry->Get("//composition[@name='ForwardTOF']/posXYZ[@volume='forwardTOF']/@X_Y_Z/plane[@value='1']", tof_plane1);
18  CenterVPlane=tof_face[2]+tof_plane1[2];
19  CenterHPlane=tof_face[2]+tof_plane0[2];
20  // also save position midway between the two planes
22 
23  // load more geometry parameters
24  if(!locGeometry->GetTOFPaddlePerpPositions(YPOS))
25  jerr << "Problem loading TOF Geometry!" << endl;
26 
27  map<string,double> paddle_params;
28  if(!locGeometry->GetTOFPaddleParameters(paddle_params))
29  jerr << "Problem loading TOF Geometry!" << endl;
30  else {
31  NLONGBARS = paddle_params["NLONGBARS"];
32  NSHORTBARS = paddle_params["NSHORTBARS"];
33  BARWIDTH = paddle_params["BARWIDTH"];
34 
35  LONGBARLENGTH = paddle_params["LONGBARLENGTH"];
36  HALFLONGBARLENGTH = paddle_params["HALFLONGBARLENGTH"];
37  SHORTBARLENGTH = paddle_params["SHORTBARLENGTH"];
38  HALFSHORTBARLENGTH = paddle_params["HALFSHORTBARLENGTH"];
39 
40  FirstShortBar = paddle_params["FIRSTSHORTBAR"];
41  LastShortBar = paddle_params["LASTSHORTBAR"];
42  }
43 
44  // save the number of bars that exist along one side of the detector
46 
47  // hardcode these for now, they are not likely to change anytime soon
48  NLAYERS = 2;
49  NENDS = 2;
50 
51 }
52 
53 float DTOFGeometry::bar2y(int bar, int end) const
54 ///> convert bar number to the
55 ///> position of the center of the
56 ///> bar in local coordinations
57 {
58  float y;
59  y = YPOS.at(bar);
60 
61  // handle position of short bars
62  if (bar>=FirstShortBar && bar<=LastShortBar && end != 0) y *= -1.0;
63 
64  return y;
65 }
66 
67 
68 int DTOFGeometry::y2bar(double y) const ///> convert local position y to bar number
69 ///> (where y is the position perpendicular to the bar length)
70 {
71  if(y < (YPOS.at(1) - BARWIDTH/2.0))
72  return 0;
73  if(y > (YPOS.at(NINSTALLBARS) + BARWIDTH/2.0))
74  return 0;
75 
76  int jm=1;
77  if (y>YPOS.at(1))
78  {
79  int jl=-1;
80  int ju=NINSTALLBARS;
81  while(ju - jl > 1)
82  {
83  jm = (ju + jl) >> 1;
84  if (y >= YPOS.at(jm))
85  jl = jm;
86  else
87  ju = jm;
88  }
89  if (fabs(y - YPOS.at(jm - 1)) < fabs(y - YPOS.at(jm)))
90  return jm - 1;
91  if (fabs(y - YPOS.at(jm + 1)) < fabs(y - YPOS.at(jm)))
92  return jm + 1;
93  }
94 
95  return jm;
96 }
#define y
bool Get(string xpath, string &sval) const
Definition: DGeometry.h:50
float CenterHPlane
center z position of Vertical Plane
Definition: DTOFGeometry.h:82
float LONGBARLENGTH
bar number of last short bar of same type north
Definition: DTOFGeometry.h:75
float CenterVPlane
width of the scintillator bars
Definition: DTOFGeometry.h:81
float BARWIDTH
middle of the short scintillators
Definition: DTOFGeometry.h:79
int FirstShortBar
number of bars vertically = NLONGBARS + NSHORTBARS/2
Definition: DTOFGeometry.h:72
int NENDS
number of scintillator layers
Definition: DTOFGeometry.h:64
DTOFGeometry(const DGeometry *locGeometry)
Definition: DTOFGeometry.cc:7
int NLONGBARS
maximum number of ends that are read out (should be 2!)
Definition: DTOFGeometry.h:66
bool GetTOFPaddlePerpPositions(vector< double > &y_tof) const
Definition: DGeometry.cc:1841
float HALFLONGBARLENGTH
length of the long scintillators
Definition: DTOFGeometry.h:76
float bar2y(int bar, int end=0) const
convert bar number to the position of the center of the bar in local coordinations ...
Definition: DTOFGeometry.cc:53
int NSHORTBARS
number of long scintillator bars
Definition: DTOFGeometry.h:68
bool GetTOFZ(vector< double > &z_tof) const
z-location of front face of each of TOF in cm
Definition: DGeometry.cc:1761
float HALFSHORTBARLENGTH
length of the short scintillators
Definition: DTOFGeometry.h:78
bool GetTOFPaddleParameters(map< string, double > &paddle_params) const
Definition: DGeometry.cc:1783
int NINSTALLBARS
number of long scintillator bars
Definition: DTOFGeometry.h:70
float CenterMPlane
center z position of Horizontal Plane
Definition: DTOFGeometry.h:83
int y2bar(double y) const
&gt; convert local position y to bar number (where y is the position pe...
Definition: DTOFGeometry.cc:68
float SHORTBARLENGTH
middle of the long scintillators
Definition: DTOFGeometry.h:77
vector< double > YPOS
center z position between the two Plane
Definition: DTOFGeometry.h:85
int LastShortBar
bar number of first short bar
Definition: DTOFGeometry.h:73