Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DDIRCGeometry.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DDIRCGeometry.cc
4 //
5 #include <unistd.h>
6 #include <DANA/DApplication.h>
7 
8 #include "DDIRCGeometry.h"
9 
10 //---------------------------------
11 // DDIRCGeometry (Constructor)
12 //---------------------------------
14 
15  CHANNEL_PER_PMT = 64;
16  PMT_ROWS = 18;
17  PMT_COLUMNS = 6;
18  DIRC_QZBL_DY = 3.515;
19 
20  // Initialize DDIRCGeometry variables
21  Initialize(runnumber);
22 }
23 
24 void
25 DDIRCGeometry::Initialize(int runnumber) {
26 
27  //Get pointer to DGeometry object
28  DApplication* dapp=dynamic_cast<DApplication*>(japp);
29  JGeometry *jgeom = dapp->GetJGeometry(runnumber);
30  JCalibration *jcalib = japp->GetJCalibration(runnumber);
31  map<string,string> installed;
32  if(jcalib->GetCalib("/DIRC/install_status", installed)) return;
33  if(atoi(installed["status"].data()) == 0) return;
34 
35  vector<double>DIRC;
36  vector<double>DRCC;
37  vector<double>DCML00_XYZ;
38  vector<double>DCML01_XYZ;
39  vector<double>DCML10_XYZ;
40  vector<double>DCML11_XYZ;
41  vector<double>WNGL00_XYZ;
42  vector<double>WNGL01_XYZ;
43  vector<double>WNGL10_XYZ;
44  vector<double>WNGL11_XYZ;
45  vector<double>OWDG_XYZ;
46  bool all_found = true;
47  all_found &= jgeom->Get("//section/composition/posXYZ[@volume='DIRC']/@X_Y_Z", DIRC);
48  all_found &= jgeom->Get("//composition[@name='DIRC']/posXYZ[@volume='DRCC']/@X_Y_Z", DRCC);
49  all_found &= jgeom->Get("//composition[@name='DRCC']/posXYZ[@volume='DCML00']/@X_Y_Z/plane[@value='4']", DCML00_XYZ);
50  all_found &= jgeom->Get("//composition[@name='DRCC']/posXYZ[@volume='DCML01']/@X_Y_Z/plane[@value='3']", DCML01_XYZ);
51  all_found &= jgeom->Get("//composition[@name='DRCC']/posXYZ[@volume='DCML10']/@X_Y_Z/plane[@value='1']", DCML10_XYZ);
52  all_found &= jgeom->Get("//composition[@name='DRCC']/posXYZ[@volume='DCML11']/@X_Y_Z/plane[@value='2']", DCML11_XYZ);
53  all_found &= jgeom->Get("//composition[@name='DCML00']/posXYZ[@volume='WNGL']/@X_Y_Z", WNGL00_XYZ);
54  all_found &= jgeom->Get("//composition[@name='DCML01']/posXYZ[@volume='WNGL']/@X_Y_Z", WNGL01_XYZ);
55  all_found &= jgeom->Get("//composition[@name='DCML10']/posXYZ[@volume='WNGL']/@X_Y_Z", WNGL10_XYZ);
56  all_found &= jgeom->Get("//composition[@name='DCML11']/posXYZ[@volume='WNGL']/@X_Y_Z", WNGL11_XYZ);
57  all_found &= jgeom->Get("//trd[@name='OWDG']/@Xmp_Ymp_Z", OWDG_XYZ);
58 
59  if( !all_found ){
60  jerr << "Problem finding all DIRC geometry elements. Please make sure your HDDS is up to date!" << endl;
61  _exit(-1);
62  }
63 
64  // set array of bar positions
65  for(int i=0; i<48; i++) {
66  // get bar length by looping over individual components
67  DIRC_BAR_L[i] = 0.;
68  for(int j=0; j<4; j++) {
69  vector<double>locBar_XYZ;
70  jgeom->Get(Form("//box[@name='B%02d%c']/@X_Y_Z", i, 'A'+j), locBar_XYZ);
71  vector<double>locGlue_XYZ;
72  jgeom->Get(Form("//box[@name='G%02d%c']/@X_Y_Z", i, 'A'+j), locGlue_XYZ);
73  DIRC_BAR_L[i] += locBar_XYZ[0];
74  DIRC_BAR_L[i] += locGlue_XYZ[0];
75  }
76 
77  // get bar end and Y positions for LUT
78  vector<double>DCBR_XYZ;
79  if(i<12) {
80  DIRC_BAR_END[i] = (DCML10_XYZ[0] - WNGL10_XYZ[0] + OWDG_XYZ[4]);
81 
82  // get center of bar in Y
83  jgeom->Get(Form("//composition[@name='DCML10']/posXYZ[@volume='DCBR%02d']/@X_Y_Z", i), DCBR_XYZ);
84  DIRC_BAR_Y[i] = DCML10_XYZ[1] - DCBR_XYZ[1];
85  }
86  else if(i<24) {
87  DIRC_BAR_END[i] = (DCML11_XYZ[0] - WNGL11_XYZ[0] + OWDG_XYZ[4]);
88 
89  // get center of bar in Y
90  jgeom->Get(Form("//composition[@name='DCML11']/posXYZ[@volume='DCBR%02d']/@X_Y_Z", i), DCBR_XYZ);
91  DIRC_BAR_Y[i] = DCML11_XYZ[1] - DCBR_XYZ[1];
92  }
93  else if(i<36) {
94  DIRC_BAR_END[i] = (DCML01_XYZ[0] + WNGL01_XYZ[0] - OWDG_XYZ[4]);
95 
96  // get center of bar in Y
97  jgeom->Get(Form("//composition[@name='DCML01']/posXYZ[@volume='DCBR%02d']/@X_Y_Z", i), DCBR_XYZ);
98  DIRC_BAR_Y[i] = DCML01_XYZ[1] + DCBR_XYZ[1];
99  }
100  else if(i<48) {
101  DIRC_BAR_END[i] = (DCML00_XYZ[0] + WNGL00_XYZ[0] - OWDG_XYZ[4]);
102 
103  // get center of bar in Y
104  jgeom->Get(Form("//composition[@name='DCML00']/posXYZ[@volume='DCBR%02d']/@X_Y_Z", i), DCBR_XYZ);
105  DIRC_BAR_Y[i] = DCML00_XYZ[1] + DCBR_XYZ[1];
106  }
107  }
108 
109  return;
110 }
111 
112 int
113 DDIRCGeometry::GetPmtID( int channel ) const
114 {
115  int MAX_BOX_CHANNEL = CHANNEL_PER_PMT * PMT_ROWS * PMT_COLUMNS;
116  if(channel < MAX_BOX_CHANNEL)
117  return channel/CHANNEL_PER_PMT;
118  else
119  return (channel-MAX_BOX_CHANNEL)/CHANNEL_PER_PMT;
120 }
121 
122 int
123 DDIRCGeometry::GetPixelID( int channel ) const
124 {
125  return channel%CHANNEL_PER_PMT;
126 }
127 
128 int DDIRCGeometry::GetPmtColumn( int channel ) const
129 {
130  int pmt = GetPmtID(channel);
131  return pmt/PMT_ROWS; // 0 - 5
132 }
133 
134 int DDIRCGeometry::GetPmtRow( int channel ) const
135 {
136  int pmt = GetPmtID(channel);
137  return pmt%PMT_ROWS; // 0 - 17
138 }
139 
140 int DDIRCGeometry::GetPmtPixelColumn( int channel ) const
141 {
142  int pix = GetPixelID(channel);
143  return pix/8; // 0 - 7
144 }
145 
146 int DDIRCGeometry::GetPmtPixelRow( int channel ) const
147 {
148  int pix = GetPixelID(channel);
149  return pix%8; // 0 - 7
150 }
151 
152 int DDIRCGeometry::GetPixelRow( int channel ) const
153 {
154  int pmt_row = GetPmtRow(channel);
155  int pixel_row = GetPmtPixelRow(channel);
156  return 8*pmt_row + pixel_row; // 0 - 143
157 }
158 
159 int DDIRCGeometry::GetPixelColumn( int channel ) const
160 {
161  int pmt_column = GetPmtColumn(channel);
162  int pixel_column = GetPmtPixelColumn(channel);
163  return 8*pmt_column + pixel_column; // 0 - 47
164 }
165 
166 int DDIRCGeometry::GetPixelX( int channel ) const
167 {
168  return abs(GetPixelRow(channel) - 143); // 0 - 143
169 }
170 
171 int DDIRCGeometry::GetPixelY( int channel ) const
172 {
173  return 47 - GetPixelColumn(channel); // 0 - 47
174 }
175 
176 int
177 DDIRCGeometry::GetBar( float y ) const
178 {
179  int locBar = -1;
180 
181  for(int i=0; i<48; i++) {
182  if(y > (DIRC_BAR_Y[i] - DIRC_QZBL_DY/2.0) && y < (DIRC_BAR_Y[i] + DIRC_QZBL_DY/2.0))
183  locBar = i;
184  }
185 
186  return static_cast<int>( locBar );
187 }
188 
189 double
190 DDIRCGeometry::GetBarY( int locBar ) const
191 {
192  if(locBar < 0 || locBar > 47)
193  return -999;
194 
195  return static_cast<double>( DIRC_BAR_Y[locBar] );
196 }
197 
198 double
199 DDIRCGeometry::GetBarEnd( int locBar ) const
200 {
201  if(locBar < 0 || locBar > 47)
202  return -999;
203 
204  return static_cast<double>( DIRC_BAR_END[locBar] );
205 }
206 
207 double
208 DDIRCGeometry::GetBarLength( int locBar ) const
209 {
210  if(locBar < 0 || locBar > 47)
211  return -999;
212 
213  return static_cast<double>( DIRC_BAR_L[locBar] );
214 }
215 
216 
int GetPixelID(int channel) const
DApplication * dapp
int GetPmtRow(int channel) const
double GetBarY(int locBar) const
int GetPixelRow(int channel) const
int GetPixelY(int channel) const
double DIRC_BAR_Y[48]
Definition: DDIRCGeometry.h:62
#define y
int GetPixelColumn(int channel) const
JApplication * japp
int GetPmtColumn(int channel) const
int GetPmtPixelRow(int channel) const
double DIRC_BAR_L[48]
Definition: DDIRCGeometry.h:62
double DIRC_BAR_END[48]
Definition: DDIRCGeometry.h:62
double GetBarEnd(int locBar) const
double GetBarLength(int locBar) const
int GetPmtPixelColumn(int channel) const
double DIRC_QZBL_DY
Definition: DDIRCGeometry.h:64
int GetPmtID(int channel) const
int GetPixelX(int channel) const
void Initialize(int runnumber)
int GetBar(float y) const