StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtGeom.cxx
1 // $Id: StFgtGeom.cxx,v 1.1 2011/04/07 19:31:22 balewski Exp $
2 #include <cmath>
3 #include <assert.h>
4 #include <StMessMgr.h>
5 
6 #include "StFgtGeom.h"
7 
8 ClassImp(StFgtGeom)
9 
10 //===============================
11 //===============================
13  printf("inFGT geom\n");
14 // More parameters are printed out with method printParam()
15 // LOG_INFO<<Form("StFgtGeom::Pitch RadStrip =%f PhiStrip/cm =%f ",radStrip_pitch(), phiStrip_pitch()*Rout())<<endm;
16 
17  initialize();
18 }
19 
20 //===============================
21 //===============================
22 void
23 StFgtGeom::initialize() {
24 
25  // predefine Z_location of disks
26  double zDisk[kFgtMxDisk+1]={69.08, 79.08, 89.08, 99.08, 109.08, 119.08, 168.68, 218.68, 66.98};// UPGR16
27  for(int i=0;i<kFgtMxDisk+1;i++)mDiskZ[i]=zDisk[i];
28 // for(int i=0;i<kFgtMxDisk+1;i++)mDiskZ[i]=zDisk[i]+15.0;
29 
30  // calculate numbers of strips
31  pi=2.*acos(0.);
32  dpi=2.*pi; // double pi
33  halfpi=0.5*pi; // halfphi
34 
35  mRadStripOff = ((Rout()-Rin())/radStrip_pitch() -
36  int( (Rout()-Rin())/radStrip_pitch())) * radStrip_pitch();
37 
38  mRadStripLOCId_number = int ((Rout()-Rin()-radStripOff())/radStrip_pitch()) + 5;
39 
40  mPhiStripOff = (halfpi/phiStrip_pitch() -
41  int( halfpi/phiStrip_pitch())) * phiStrip_pitch();
42  mPhiStripLOCId_number = int ((halfpi-phiStripOff())/phiStrip_pitch()) + 5;
43 
44  mRadStripGBLId_number = kFgtMxQuad * radStripLOCId_number();
45  mPhiStripGBLId_number = kFgtMxQuad * phiStripLOCId_number();
46 
47 }
48 
49 //===============================
50 //===============================
51 bool
52 StFgtGeom::inDisk(TVector3 r){ // 'r' in LAB ref
53  float Rxy=r.Perp();
54  if(Rxy<Rin()) return false;
55  if(Rxy>Rout()) return false;
56  if(fabs(r.y())>yLimit()) return false;
57  return true;
58 }
59 
60 //===============================
61 //===============================
62 int
63 StFgtGeom::getQuad(double phiLab){
64  //printf("aa %10f %f\n",phiLab,pi);
65  assert(phiLab<=pi);
66  assert(phiLab>=-pi);
67  if(phiLab>phiQuadXaxis(0) && phiLab<=phiQuadXaxis(1)) return 0;
68  if(phiLab>phiQuadXaxis(1) && phiLab<=phiQuadXaxis(2)) return 1;
69  if(phiLab>phiQuadXaxis(3) && phiLab<=phiQuadXaxis(0)) return 3;
70  return 2;
71 }
72 
73 //===============================
74 //===============================
75 double
76 StFgtGeom::phiQuadXaxis(int iquad) {
77 
78  switch(iquad) {
79 /*
80  case 0: return -0.261799387; // - 15 deg
81  case 1: return 1.308996939; // +75 deg
82  case 2: return 2.879793266; // +165 deg
83  case 3: return -1.832595715; // -105 deg
84 */
85  case 0: return -15.0*pi/180.0; // - 15 deg
86  case 1: return 75.0*pi/180.0; // +75 deg
87  case 2: return 165.0*pi/180.0; // +165 deg
88  case 3: return -105.0*pi/180.0; // -105 deg
89  default:
90  assert(2==3);
91  }
92 }
93 
94 //===============================
95 //===============================
96 bool
97 StFgtGeom::localXYtoStripID( int iquad, double xLoc, double yLoc,int &iRadID,int &iPhiID, int dbg){ // returns false if out of range
98 
99  iRadID= iPhiID=-1;
100  int locRadID, locPhiID;
101  double r=sqrt(xLoc*xLoc+yLoc*yLoc);
102  //.............. trim outside of active area
103  if(r< Rin() ) return false;
104  if(r> Rout() ) return false;
105 
106  //............. find phi in lab ref
107  double phiLoc=atan2(yLoc,xLoc); // [0,pi/2] in local ref frame
108 
109  // assume all 9 disks have identical strip numbering scheme
110  double radBinFrac,phiBinFrac; // optional , for QA
111  locRadID=rad2LocalStripId(r,&radBinFrac); // no quad/disk dependence
112  locPhiID=phiLoc2LocalStripId(phiLoc,&phiBinFrac);// no quad/disk dependence
113 
114  iRadID = radIdLocal2Global(iquad, locRadID);
115  iPhiID = phiIdLocal2Global(iquad, locPhiID);
116 
117  if(dbg) {
118  printf("strip: yLoc=%f xLoc=%f phi=%f, lradID=%d, lphiID=%d\n",yLoc,xLoc,phiLoc*57.3,locRadID,locPhiID);
119  printf("strip: radID=%d +(%.2f) phiID=%d +(%.2f)\n",iRadID,radBinFrac, iPhiID,phiBinFrac);
120  }
121  return true;
122 }
123 
124 //===============================
125 //===============================
126 double
127 StFgtGeom::stripID2Rxy(double fRadBin){
128 
129  int iRadId = (int)fRadBin;
130  if (iRadId < 0) return -1;
131  double eps=fRadBin-iRadId;
132  int localId = radIdGlobal2Local(iRadId);
133  double pos = Rout()-(localId + eps)*radStrip_pitch();
134 
135  return pos;
136 }
137 
138 //===============================
139 //===============================
140 double
141 StFgtGeom::stripID2PhiLoc( double fPhiBin){
142 
143  int iPhiId = (int)fPhiBin;
144  if (iPhiId < 0) return -999.0;
145  double eps=fPhiBin-iPhiId;
146  int localId = phiIdGlobal2Local(iPhiId);
147  double phiLocal = (localId+eps)*phiStrip_pitch();
148 
149  return phiLocal;
150 }
151 
152 //===============================
153 //===============================
154 double
155 StFgtGeom::stripID2PhiLab(double fPhiBin){
156 
157  double phiLab;
158  double phiLocal = stripID2PhiLoc(fPhiBin);
159  int iPhiId = (int)fPhiBin;
160  int iquad = iPhiId/phiStripLOCId_number();
161 
162 // offset for quad1-3 is added here
163  phiLab = (phiLocal != -999.0)?
164 // Bug of adding iquad*phiStripOff() fixed WMZ 8/14/09
165 // phiLocal + phiQuadXaxis(iquad) + iquad*phiStripOff(): phiLocal;
166  phiLocal + phiQuadXaxis(iquad): phiLocal;
167 
168  return phiLab;
169 }
170 
171 //===============================
172 //===============================
173 void
174 StFgtGeom::printParam(){
175  cout << " Parementers of StFgtGeom" << endl;
176  cout << " -------------------------" << endl;
177  cout << "\tRout, Rmid, Rin = " << Rout() << " cm, " << Rmid() << " cm, "
178  << Rin() << " cm" << endl;
179  cout << "\tRad/Phi Strip pitch = " << radStrip_pitch() << " cm, "
180  << kFgtPhiPitch << " cm" << endl;
181  cout << "\tOffset of Rad/Phi = " << radStripOff() << " cm, "
182  << phiStripOff()*Rout() << " cm"<< endl;
183  cout << "\tNumber of Rad/Phi Strip Ids = " << radStripLOCId_number() << " "
184  << phiStripLOCId_number() << endl;
185  cout << "\tZ0 - Z4 = " << mDiskZ[0] << " " << mDiskZ[1] << " "
186  << mDiskZ[2] << " " << mDiskZ[3] << " "
187  << mDiskZ[4] << " cm" << endl;
188  cout << "\tZ5 - Z8 = " << mDiskZ[5] << " " << mDiskZ[6] << " "
189  << mDiskZ[7] << " " << mDiskZ[8] << " cm" << endl;
190  cout << endl;
191 }
192 
193 // mothods involving local IDs
194 //===============================
195 //===============================
196 int
197 StFgtGeom::rad2LocalStripId( double rad, double *binFrac){
198  // returns -1 on error
199  // 2nd argument is optional, returns fraction of the bin size [0,1.)
200  double ratio=(Rout()-rad)/radStrip_pitch();
201  int irad=(int) ratio;
202  if(binFrac) *binFrac=ratio-irad;
203  if(irad >= 0 && irad < radStripLOCId_number())
204  return irad;
205  else
206  return -1;
207 }
208 
209 //===============================
210 //===============================
211 int
212 StFgtGeom::phiLoc2LocalStripId(double phiLoc, double *binFrac){ // return -1 on error
213  // 2nd argument is optional, returns fraction of the bin size [0,1.)
214  // phiLoc is in range [0,pi/2)
215  double ratio=phiLoc/phiStrip_pitch();
216  int iphi=(int) ratio;
217  if(binFrac) *binFrac=ratio-iphi;
218  if(iphi >=0 && iphi < phiStripLOCId_number())
219  return iphi;
220  else
221  return -1;
222 }
223 
224 //===============================
225 //===============================
226 int
227 StFgtGeom::phiLab2LocalStripId(int iquad, double phiLab, double *binFrac){ // return -1 on error
228  // 2nd argument is optional, returns fraction of the bin size [0,1.)
229 
230  double phi=phiLab-phiQuadXaxis(iquad);
231  while(phi<0.) phi+=dpi;
232  while(phi>=dpi) phi-=dpi;
233  double phiBinFrac;
234  int iphi = phiLoc2LocalStripId(phi, &phiBinFrac);
235  *binFrac=phiBinFrac;
236  return iphi;
237 }
238 
239 // $Log: StFgtGeom.cxx,v $
240 // Revision 1.1 2011/04/07 19:31:22 balewski
241 // start
242 //