StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TpcLocalTransform.cc
1 
2 #include "StThreeVectorF.hh"
3 #include "StEvent/StTpcHit.h"
4 #include "TMath.h"
5 
6 
7 //__________________________________
8 
9 
10 
11 int TpcLocalTransform(StThreeVectorD& aPoint, int& aSector, int& aRow,
12  float& aU, double& aPhi){
13  static int tNPadAtRow[45]={
14  88,96,104,112,118,126,134,142,150,158,166,174,182,
15  98,100,102,104,106,106,108,110,112,112,114,116,118,120,122,122,
16  124,126,128,128,130,132,134,136,138,138,140,142,144,144,144,144};
17  static double tSectToPhi[24]={2.,1.,0.,11.,10.,9.,8. ,7. ,6.,5.,4.,3.,
18  4.,5.,6., 7., 8.,9.,10.,11.,0.,1.,2.,3.};
19  //static double tPhiToSect[24]={2.,1.,0.,11.,10.,9.,8. ,7. ,6.,5.,4.,3.,
20  // 4.,5.,6., 7., 8.,9.,10.,11.,0.,1.,2.,3.};
21  static double tPadWidthInner = 0.335;
22  static double tPadWidthOuter = 0.67;
23 
24  static double tPi = TMath::Pi();
25  // --- find sector number
26  aPhi = aPoint.phi();
27  if(aPhi<0.) aPhi+=(2*tPi);
28  aPhi += tPi/12.;
29  if(aPhi>2*tPi) aPhi-=2*tPi;
30  int tiPhi = (int) (aPhi/tPi*6.);
31  if(aPoint.z()<0) {
32  aSector = (tiPhi<3)? 3-tiPhi : 15-tiPhi;
33  }
34  else{
35  aSector = (tiPhi<4)? 21+tiPhi : 9+tiPhi;
36  }
37  aPhi = tSectToPhi[aSector-1]*tPi/6.;
38  //if((fabs(aPhi-aPoint.phi())>(tPi/12)){
39  //cout << "Sector missmatch " << aPhi << " " << aPoint.phi() << " "
40  // << aSector << endl;
41  //}
42 
43  // --- calculate local coordinate
44  float tR = aPoint.x()*cos(aPhi)+aPoint.y()*sin(aPhi);
45  aU = -aPoint.x()*sin(aPhi)+aPoint.y()*cos(aPhi);
46 
47  // --- find pad row
48  if(tR<57.6) {
49  aRow = 0;
50  return 1;
51  }
52  float radmax = 62.4;
53  float spacing= 4.8;
54  aRow=1;
55  while(tR>radmax && aRow<46){
56  aRow++;
57  if(aRow==8){
58  radmax = 96.2;
59  spacing = 5.2;
60  }
61  else{
62  if (aRow==13){
63  radmax = 126.195; // lots of stuf in row 13!
64  spacing = 2.0;
65  }
66  else{
67  radmax+=spacing;
68  }
69  }
70  }
71  if(aRow>45){
72  //cout << "No pad row " << tR << endl;
73  return 2;
74  }
75 
76  // --- Check if u (=aU) inbound
77  double tPadWidth = aRow<14? tPadWidthInner : tPadWidthOuter;
78  if(fabs(aU) > tNPadAtRow[aRow-1]*tPadWidth/2.){
79  return 3;
80  }
81 
82  return 0;
83 }
84 
85 
86 
87 
88 
89