StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBbcGeom.cxx
1 #include "StBbcGeom.h"
2 #include "TMath.h"
3 #include <iostream>
4 
5 using namespace std;
6 
7 ClassImp(StBbcGeom)
8 
10  InitializeGeometry();
11 }
12 
13 StBbcGeom::~StBbcGeom(){
14  /* no-op */
15 }
16 
17 void StBbcGeom::InitializeGeometry(){
18 
19  double h=9.65; // height of the hexagonal inner tiles, in cm.
20  double zBBC = 380; // 5 cm behind the EPD
21 
22  //---------- corners of a hex tile centered at (x,y)=(0,0) -------
23  double xh = h/(4.0*sin(60.0*TMath::Pi()/180.0));
24  double yh = h/2.0;
25  mX[0] = -2.0*xh; mY[0] = 0.0;
26  mX[1] = -xh; mY[1] = yh;
27  mX[2] = xh; mY[2] = yh;
28  mX[3] = 2.0*xh; mY[3] = 0.0;
29  mX[4] = xh; mY[4] = -yh;
30  mX[5] = -xh; mY[5] = -yh;
31  //----------------------------------------------------------------
32 
33  //---------- locations of centers of tiles -----------------------
34  double radius,phi,xc,yc,zc;
35 
36  // first, East:
37  for (int iTile=1; iTile<19; iTile++){
38  if (iTile<7){ // Tiles 1-6
39  radius = h;
40  phi = TMath::Pi()/2.0 + (iTile-1)*60.0*TMath::Pi()/180.0;
41  }
42  if ((iTile>6)&&(iTile%2==0)){ // tiles 8,10,12,14,16,18
43  radius = 2.0*h;
44  phi = TMath::Pi()/2.0 +(iTile/2-4)*60.0*TMath::Pi()/180.0;
45  }
46  if ((iTile>6)&&(iTile%2==1)){ // tiles 7,9,11,13,15,17
47  radius = h*(1.0+cos(60.0*TMath::Pi()/180.0))/sin(60.0*TMath::Pi()/180.0);
48  phi = TMath::Pi()*60.0/180.0 + ((iTile-1)/2-3)*60*TMath::Pi()/180.0;
49  }
50  xc = radius*cos(phi);
51  yc = radius*sin(phi);
52  zc = -zBBC;
53  mEastTileCenter[iTile-1].SetXYZ(xc,yc,zc);
54  }
55 
56  // then, West:
57  for (int iTile=1; iTile<19; iTile++){
58  if (iTile<7){ // Tiles 1-6
59  radius = h;
60  phi = TMath::Pi()/2.0 - (iTile-1)*60.0*TMath::Pi()/180.0;
61  }
62  if ((iTile>6)&&(iTile%2==0)){ // tiles 8,10,12,14,16,18
63  radius = 2.0*h;
64  phi = TMath::Pi()/2.0 -(iTile/2-4)*60.0*TMath::Pi()/180.0;
65  }
66  if ((iTile>6)&&(iTile%2==1)){ // tiles 7,9,11,13,15,17
67  radius = h*(1.0+cos(60.0*TMath::Pi()/180.0))/sin(60.0*TMath::Pi()/180.0);
68  phi = TMath::Pi()*120.0/180.0 - ((iTile-1)/2-3)*60*TMath::Pi()/180.0;
69  }
70  xc = radius*cos(phi);
71  yc = radius*sin(phi);
72  zc = zBBC;
73  mWestTileCenter[iTile-1].SetXYZ(xc,yc,zc);
74  }
75 
76  //------------- fill member array of phototube numbers.
77  //------------- I am too stupid to figure out a better way of doing this:
78 
79  for (int pmt=0; pmt<16; pmt++){
80  mNtilesOfPmt[pmt] = 0;
81  mTileNumbersOfPmt[pmt][0] = 0;
82  mTileNumbersOfPmt[pmt][1] = 0;
83  }
84 
85  // phototube number corresponding to a given inner BBC tile. Same for east and west BBCs
86  // Tile# 1 2 3 4 5 6 7 8 9 10 11 12 12 14 15 16 17 18
87  unsigned short pmt[18] = {1, 2, 3, 4, 5, 6, 7, 8, 7, 9, 10, 11, 12, 13, 12, 14, 15, 16};
88  for (int itile=0; itile<18; itile++){
89  mPMT[itile] = pmt[itile];
90  // note ordering of the following two statements
91  mTileNumbersOfPmt[pmt[itile]-1][mNtilesOfPmt[pmt[itile]-1]] = itile+1;
92  mNtilesOfPmt[pmt[itile]-1]++;
93  }
94 }
95 
96 //-------------------------------------------------------
97 void StBbcGeom::GetTilesOfPmt(unsigned short pmtNumber, unsigned short *nTiles, unsigned short* tileNumbers){
98  *nTiles = mNtilesOfPmt[pmtNumber-1]; // will usually be 1. Will be 2 for pmt #7 and #12
99  tileNumbers[0] = mTileNumbersOfPmt[pmtNumber-1][0];
100  tileNumbers[1] = mTileNumbersOfPmt[pmtNumber-1][1]; // this will usually be zero except for pmt #7 and #12
101 }
102 
103 
104 
105 
106 //-------------------------------------------------------
107 TVector3 StBbcGeom::TileCenter(short tileId){
108  // short index = abs(tileId) - 1;
109  // if (tileId<0){return mEastTileCenter[index];}
110  // else {return mWestTileCenter[index];}
111  unsigned short absValTile = abs(tileId);
112  return (tileId<0)?TileCenter(absValTile,0):TileCenter(absValTile,1);
113 }
114 TVector3 StBbcGeom::TileCenter(unsigned short absValueTileNumber, short eastwest){
115  return (eastwest>0)?mWestTileCenter[absValueTileNumber-1]:mEastTileCenter[absValueTileNumber-1];
116 }
117 
118 
119 
120 //-------------------------------------------------------
121 void StBbcGeom::GetCorners(short tileId, double* x, double* y){
122  unsigned short absValTile = abs(tileId);
123  return (tileId<0)?GetCorners(absValTile,0,x,y):GetCorners(absValTile,1,x,y);
124 }
125 /*
126 
127  TVector3 cent = this->TileCenter(tileId);
128  double xcent = cent.X();
129  double ycent = cent.Y();
130  for (int i=0; i<6; i++){
131  x[i] = mX[i]+xcent;
132  y[i] = mY[i]+ycent;
133  }
134 }
135 */
136 void StBbcGeom::GetCorners(unsigned short absValueTileNumber, short eastwest, double* x, double* y){
137  TVector3 cent = this->TileCenter(absValueTileNumber,eastwest);
138  double xcent = cent.X();
139  double ycent = cent.Y();
140  for (int i=0; i<6; i++){
141  x[i] = mX[i]+xcent;
142  y[i] = mY[i]+ycent;
143  }
144 }
145 
146 //-------------------------------------------------------
147 bool StBbcGeom::IsInTile(short tileId, double x, double y){
148  unsigned short absValTile = abs(tileId);
149  return (tileId<0)?IsInTile(absValTile,0,x,y):IsInTile(absValTile,1,x,y);
150 }
151 bool StBbcGeom::IsInTile(unsigned short absValueTileNumber, short eastwest, double x, double y){
152  double PolygonX[7];
153  double PolygonY[7];
154  GetCorners(absValueTileNumber,eastwest,PolygonX,PolygonY);
155  PolygonX[6]=PolygonX[0]; // must close the polygon
156  PolygonY[6]=PolygonY[0]; // must close the polygon
157  return TMath::IsInside(x,y,7,PolygonX,PolygonY);
158 }
159 
160 //-------------------------------------------------------
162  int* nOverlappingEpdTiles, short* EpdTileIDs){
163  unsigned short absValTile = abs(tileId);
164  if (tileId<0) {GetOverlappingEpdTiles(absValTile,-1,nOverlappingEpdTiles,EpdTileIDs);}
165  else {GetOverlappingEpdTiles(absValTile,1,nOverlappingEpdTiles,EpdTileIDs);}
166 }
167 void StBbcGeom::GetOverlappingEpdTiles(unsigned short BB, short eastwest,
168  int* nOverlappingEpdTiles, short* EpdTileIDs){
169  if ((BB==0)||(BB>18)){
170  *nOverlappingEpdTiles=0;
171  return;
172  }
173  if (eastwest<0){ // East
174  *nOverlappingEpdTiles = mEastNumberOfOverlappingEpdTiles[BB-1];
175  for (int i=0; i<*nOverlappingEpdTiles; i++){
176  EpdTileIDs[i] = mEastEpdTilesWhichOverlap[BB-1][i];
177  }
178  }
179  else{ // west
180  *nOverlappingEpdTiles = mWestNumberOfOverlappingEpdTiles[BB-1];
181  for (int i=0; i<*nOverlappingEpdTiles; i++){
182  EpdTileIDs[i] = mWestEpdTilesWhichOverlap[BB-1][i];
183  }
184  }
185  for (int i=*nOverlappingEpdTiles; i<10; i++){
186  EpdTileIDs[i] = 0;
187  }
188 }
189 
190 
191 
192 //-------------------------------------------------------
193 // EastNumberOfOverlappingEpdTiles[BB-1] gives the number of EPD tiles that have any overlap with BBC tile BB
194 short StBbcGeom::mEastNumberOfOverlappingEpdTiles[18] = { 8, 8, 8, 8, 8, 8, 10, 8, 10, 8, 10, 8, 9, 8, 10, 8, 10, 8};
195 
196 // EastEpdTilesWhichOverlap[BB-1][i] gives the EPD tile id of the jth EPD tile that overlaps BBC inner tile BB
197 short StBbcGeom::mEastEpdTilesWhichOverlap[18][10] = {
198  { -101, -102, -103, -105, -1201, -1202, -1203, -1204, 0, 0}, // BBC tile #1
199  { -1001, -1002, -1003, -1004, -1101, -1102, -1103, -1105, 0, 0}, // BBC tile #2
200  { -801, -802, -803, -804, -901, -902, -903, -905, 0, 0}, // BBC tile #3
201  { -601, -602, -603, -604, -701, -702, -703, -705, 0, 0}, // BBC tile #4
202  { -401, -402, -403, -404, -501, -502, -503, -505, 0, 0}, // BBC tile #5
203  { -201, -202, -203, -204, -301, -302, -303, -305, 0, 0}, // BBC tile #6
204  { -102, -104, -105, -106, -107, -203, -204, -205, -206, -207}, // BBC tile #7
205  { -105, -106, -107, -109, -1204, -1206, -1207, -1208, 0, 0}, // BBC tile #8
206  { -1102, -1104, -1105, -1106, -1107, -1203, -1204, -1205, -1206, -1207}, // BBC tile #9
207  { -1004, -1006, -1007, -1008, -1105, -1106, -1107, -1109, 0, 0}, // BBC tile #10
208  { -902, -904, -905, -906, -907, -1003, -1004, -1005, -1006, -1007}, // BBC tile #11
209  { -804, -806, -807, -808, -905, -906, -907, -909, 0, 0}, // BBC tile #12
210  { -702, -704, -705, -706, -707, -803, -804, -805, -807, 0}, // BBC tile #13
211  { -604, -606, -607, -608, -705, -706, -707, -709, 0, 0}, // BBC tile #14
212  { -502, -504, -505, -506, -507, -603, -604, -605, -606, -607}, // BBC tile #15
213  { -404, -406, -407, -408, -505, -506, -507, -509, 0, 0}, // BBC tile #16
214  { -302, -304, -305, -306, -307, -403, -404, -405, -406, -407}, // BBC tile #17
215  { -204, -206, -207, -208, -305, -306, -307, -309, 0, 0} // BBC tile #18
216 };
217 
218 // WestNumberOfOverlappingEpdTiles[BB-1] gives the number of EPD tiles that have any overlap with BBC tile BB
219 short StBbcGeom::mWestNumberOfOverlappingEpdTiles[18] = { 8, 8, 8, 8, 8, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8};
220 
221 // WestEpdTilesWhichOverlap[BB-1][i] gives the EPD tile id of the jth EPD tile that overlaps BBC inner tile BB
222 short StBbcGeom::mWestEpdTilesWhichOverlap[18][10] = {
223  { 101, 102, 103, 105, 1201, 1202, 1203, 1204, 0, 0}, // BBC tile #1
224  { 1001, 1002, 1003, 1004, 1101, 1102, 1103, 1105, 0, 0}, // BBC tile #2
225  { 801, 802, 803, 804, 901, 902, 903, 905, 0, 0}, // BBC tile #3
226  { 601, 602, 603, 604, 701, 702, 703, 705, 0, 0}, // BBC tile #4
227  { 401, 402, 403, 404, 501, 502, 503, 505, 0, 0}, // BBC tile #5
228  { 201, 202, 203, 204, 301, 302, 303, 305, 0, 0}, // BBC tile #6
229  { 102, 104, 105, 106, 107, 203, 204, 205, 206, 207}, // BBC tile #7
230  { 105, 106, 107, 109, 1204, 1206, 1207, 1208, 0, 0}, // BBC tile #8
231  { 1102, 1104, 1105, 1106, 1107, 1203, 1204, 1205, 1206, 1207}, // BBC tile #9
232  { 1004, 1006, 1007, 1008, 1105, 1106, 1107, 1109, 0, 0}, // BBC tile #10
233  { 902, 904, 905, 906, 907, 1003, 1004, 1005, 1006, 1007}, // BBC tile #11
234  { 804, 806, 807, 808, 905, 906, 907, 909, 0, 0}, // BBC tile #12
235  { 702, 704, 705, 706, 707, 803, 804, 805, 806, 807}, // BBC tile #13
236  { 604, 606, 607, 608, 705, 706, 707, 709, 0, 0}, // BBC tile #14
237  { 502, 504, 505, 506, 507, 603, 604, 605, 606, 607}, // BBC tile #15
238  { 404, 406, 407, 408, 505, 506, 507, 509, 0, 0}, // BBC tile #16
239  { 302, 304, 305, 306, 307, 403, 404, 405, 406, 407}, // BBC tile #17
240  { 204, 206, 207, 208, 305, 306, 307, 309, 0, 0} // BBC tile #18
241 };
242 
243 
bool IsInTile(short tileId, double x, double y)
Definition: StBbcGeom.cxx:147
void GetOverlappingEpdTiles(short tileId, int *nOverlappingEpdTiles, short *EpdTileIDs)
Definition: StBbcGeom.cxx:161
void GetTilesOfPmt(unsigned short pmtNumber, unsigned short *nTiles, unsigned short *tileNumbers)
Definition: StBbcGeom.cxx:97
TVector3 TileCenter(short tileId)
Definition: StBbcGeom.cxx:107
void GetCorners(short tileId, double *x, double *y)
Definition: StBbcGeom.cxx:121