14 #include "StEpdGeom.h"
24 pRan = (TRandom3*)gRandom;
27 pRan =
new TRandom3();
33 StEpdGeom::~StEpdGeom(){
34 if ( pRan && pRan != gRandom )
delete pRan;
37 void StEpdGeom::InitializeGeometry(){
43 double DeltaPhiSS = 30.0*TMath::Pi()/180.0;
45 for (
int PP=1; PP<13; PP++){
46 double phiSS = TMath::Pi()/2.0 - (PP-0.5)*DeltaPhiSS;
47 if (phiSS<0.0) phiSS += 2.0*TMath::Pi();
48 mPhiCenter[PP-1][0][EW] = phiSS;
49 for (
int TT=2;
TT<32;
TT+=2){
50 mPhiCenter[PP-1][
TT-1][EW] = phiSS - DeltaPhiSS/4.0;
52 for (
int TT=3;
TT<32;
TT+=2){
53 mPhiCenter[PP-1][
TT-1][EW] = phiSS + DeltaPhiSS/4.0;
57 for (
int PP=1; PP<13; PP++){
58 double phiSS = TMath::Pi()/2.0 + (PP-0.5)*DeltaPhiSS;
59 if (phiSS>2.0*TMath::Pi()) phiSS -= 2.0*TMath::Pi();
60 mPhiCenter[PP-1][0][EW] = phiSS;
61 for (
int TT=2;
TT<32;
TT+=2){
62 mPhiCenter[PP-1][
TT-1][EW] = phiSS + DeltaPhiSS/4.0;
64 for (
int TT=3;
TT<32;
TT+=2){
65 mPhiCenter[PP-1][
TT-1][EW] = phiSS - DeltaPhiSS/4.0;
70 double RowHeight[16]={4.4, 4.4, 4.4, 5.53, 5.53, 5.53,
71 5.53, 5.53, 5.53, 5.53, 5.53, 5.53, 5.53, 5.53, 5.53, 5.53};
72 double Rminimum = 4.6;
74 for (
int irow=1; irow<16; irow++){
75 mRmin[irow]=mRmin[irow-1]+RowHeight[irow-1];
76 mRmax[irow-1]=mRmin[irow];
78 mRmax[15]=mRmin[15]+RowHeight[15];
79 for (
int irow=0; irow<16; irow++){
80 mRave[irow] = 0.5*(mRmin[irow]+mRmax[irow]);
86 void StEpdGeom::SetPpTtEw(
short uniqueID){
87 mPP = std::abs(uniqueID/100);
88 mTT = std::abs(uniqueID % 100);
89 mEW = (uniqueID>0)?+1:-1;
92 double StEpdGeom::GetZwheel(){
93 const double z_EPD = 375.0;
136 short StEpdGeom::Row(
short uniqueID){
140 short StEpdGeom::Row(
short PP,
short TT,
short EW){
146 short StEpdGeom::Row(){
151 TVector3 StEpdGeom::TileCenter(
short uniqueID){
153 return this->TileCenter();
155 TVector3 StEpdGeom::TileCenter(
short PP,
short TT,
short EW){
159 return this->TileCenter();
161 TVector3 StEpdGeom::TileCenter(){
164 double ZZ = this->GetZwheel();
165 TVector3 cent(mRave[this->Row()-1],0.0,ZZ);
168 int ew = (mEW>0)?1:0;
169 cent.RotateZ(mPhiCenter[mPP-1][mTT-1][ew]);
174 TVector3 StEpdGeom::RandomPointOnTile(
short uniqueID){
176 return this->RandomPointOnTile();
178 TVector3 StEpdGeom::RandomPointOnTile(
short PP,
short TT,
short EW){
182 return this->RandomPointOnTile();
184 TVector3 StEpdGeom::RandomPointOnTile(){
186 double GapWidth = 0.08;
187 double Aparam = 2.0*tan(7.5*TMath::Pi()/180.0);
188 double Bparam = -2.0*GapWidth;
190 double ZZ = this->GetZwheel();
191 short RR=this->Row();
192 double Rmin = mRmin[RR-1];
193 double Rmax = mRmax[RR-1];
195 double Xmin = Rmin + GapWidth;
196 double Xmax = Rmax - GapWidth;
197 if (1==RR) Xmin -= 2.0*GapWidth;
198 if (16==RR) Xmax += GapWidth;
204 if (1==RR) Xmax += GapWidth;
209 double gamma = 0.5*A*pow(Xmin,2)+Bparam*Xmin;
210 double alpha = 0.5*A*pow(Xmax,2)+Bparam*Xmax-gamma;
212 double q = pRan->Rndm();
213 double XX = (sqrt(pow(Bparam,2)+2.0*A*(alpha*q+gamma)) - Bparam)/A;
215 double DeltaY = A*XX+Bparam;
216 double YY = (q-0.5)*DeltaY;
218 TVector3 Point(XX,YY,ZZ);
220 int ew = (mEW>0)?1:0;
221 Point.RotateZ(mPhiCenter[mPP-1][mTT-1][ew]);
229 if (!(this->IsInTile(Point.X(),Point.Y())))
return this->RandomPointOnTile();}
235 void StEpdGeom::GetCorners(
short uniqueID,
236 int* nCorners,
double* x,
double* y){
238 GetCorners(nCorners,x,y);
240 void StEpdGeom::GetCorners(
short position,
short tilenumber,
short eastwest,
241 int* nCorners,
double* x,
double* y){
245 GetCorners(nCorners,x,y);
247 void StEpdGeom::GetCorners(
int* nCorners,
double* xc,
double* yc){
252 double OpeningAngle = 7.5*TMath::Pi()/180.0;
253 double GapWidth = 0.08;
254 short RR = this->Row();
256 double Rmin=mRmin[RR-1];
257 double Rmax=mRmax[RR-1];
261 double xtmp[3], ytmp[3];
262 xtmp[0] = Rmin; ytmp[0] = +Rmin*tan(OpeningAngle);
263 xtmp[1] = Rmax; ytmp[1] = +Rmax*tan(OpeningAngle);
264 xtmp[2] = Rmax; ytmp[2] = -Rmax*tan(OpeningAngle);
265 for (
int ic=0; ic<3; ic++){
266 x[ic] = xtmp[ic]*cos(OpeningAngle) - ytmp[ic]*sin(OpeningAngle);
267 y[ic] = +xtmp[ic]*sin(OpeningAngle) + ytmp[ic]*cos(OpeningAngle);
273 x[3] = x[1]; y[3] = -y[1];
274 x[4] = x[0]; y[4] = -y[0];
278 x[0] = Rmin + GapWidth; y[0] = +Rmin*tan(OpeningAngle) - GapWidth;
279 x[1] = Rmax - GapWidth; y[1] = +Rmax*tan(OpeningAngle) - GapWidth;
280 x[2] = Rmax - GapWidth; y[2] = -Rmax*tan(OpeningAngle) + GapWidth;
281 x[3] = Rmin + GapWidth; y[3] = -Rmin*tan(OpeningAngle) + GapWidth;
282 x[4] = -999; y[4] = -999;
291 double phi = mPhiCenter[mPP-1][mTT-1][ew];
292 for (
int icorn=0; icorn<(*nCorners); icorn++){
293 xc[icorn] = +x[icorn]*cos(phi) - y[icorn]*sin(phi);
294 yc[icorn] = +x[icorn]*sin(phi) + y[icorn]*cos(phi);
299 bool StEpdGeom::IsInTile(
short uniqueID,
302 return this->IsInTile(x,y);
304 bool StEpdGeom::IsInTile(
short position,
short tilenumber,
short eastwest,
309 return this->IsInTile(x,y);
311 bool StEpdGeom::IsInTile(
double x,
double y){
315 this->GetCorners(&numberOfCorners,PolygonX,PolygonY);
316 PolygonX[numberOfCorners] = PolygonX[0]; PolygonY[numberOfCorners] = PolygonY[0];
317 return TMath::IsInside(x,y,numberOfCorners+1,PolygonX,PolygonY);
323 void StEpdGeom::GetOverlappingBbcTiles(
short uniqueID,
324 int* nOverlappingBbcTiles,
short* BbcTileIDs){
326 GetOverlappingBbcTiles(nOverlappingBbcTiles,BbcTileIDs);
329 void StEpdGeom::GetOverlappingBbcTiles(
short position,
short tilenumber,
short eastwest,
330 int* nOverlappingBbcTiles,
short* BbcTileIDs){
334 GetOverlappingBbcTiles(nOverlappingBbcTiles,BbcTileIDs);
336 void StEpdGeom::GetOverlappingBbcTiles(
int* nOverlappingBbcTiles,
short* BbcTileIDs){
338 nOverlappingBbcTiles=0;
342 *nOverlappingBbcTiles = mEastNumberOfOverlappingBbcTiles[mPP-1][mTT-1];
343 for (
int i=0; i<*nOverlappingBbcTiles; i++){
344 BbcTileIDs[i] = mEastBbcTilesWhichOverlap[mPP-1][mTT-1][i];
346 for (
int i=*nOverlappingBbcTiles; i<10; i++){
351 *nOverlappingBbcTiles = mWestNumberOfOverlappingBbcTiles[mPP-1][mTT-1];
352 for (
int i=0; i<*nOverlappingBbcTiles; i++){
353 BbcTileIDs[i] = mWestBbcTilesWhichOverlap[mPP-1][mTT-1][i];
355 for (
int i=*nOverlappingBbcTiles; i<10; i++){
365 short StEpdGeom::mEastNumberOfOverlappingBbcTiles[12][9] = {
366 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
367 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
368 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
369 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
370 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
371 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
372 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
373 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
374 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
375 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
376 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
377 { 1, 1, 2, 3, 1, 2, 2, 1, 0}
381 short StEpdGeom::mEastBbcTilesWhichOverlap[12][9][3] = {
505 short StEpdGeom::mWestNumberOfOverlappingBbcTiles[12][9] = {
506 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
507 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
508 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
509 { 1, 1, 2, 3, 1, 1, 2, 1, 0},
510 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
511 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
512 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
513 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
514 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
515 { 1, 1, 2, 3, 1, 2, 2, 1, 0},
516 { 1, 2, 1, 1, 3, 2, 2, 0, 1},
517 { 1, 1, 2, 3, 1, 2, 2, 1, 0}
521 short StEpdGeom::mWestBbcTilesWhichOverlap[12][9][3] = {