StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcSmdGeom.cxx
1 /*******************************************************************
2  *
3  * $Id: StEEmcSmdGeom.cxx,v 1.13 2010/08/26 22:48:55 ogrebeny Exp $
4  *
5  * Author: Wei-Ming Zhang
6  *
7  * Revisions:
8  *
9  * 01/28/04 Jason Webb -- StRoot independent code moved to a
10  * separate EEmcSmdGeom class. StEEmcSmdGeom now derives from
11  * that class, implementing functions useful for integrating
12  * with Star. See EEmcSmdGeom.{h,cxx} for further documentation.
13  *
14  *****************************************************************
15  *
16  * Description: Interface to EEMC-SMD database
17  *
18  *****************************************************************/
19 
20 #include "Stiostream.h"
21 #include "StEEmcSmdGeom.h"
22 #include "PhysicalConstants.h"
23 
24 ClassImp(StEEmcSmdGeom);
25 
27 StEEmcSmdGeom *StEEmcSmdGeom::sInstance = 0;
28 
29 StEEmcSmdGeom::StEEmcSmdGeom() : EEmcSmdGeom() {
30 
31 }
32 
33 StEEmcSmdGeom::~StEEmcSmdGeom() {
34  delete sInstance;
35  sInstance = 0;
36 }
37 
38 // Returns the single instance of the class
39 StEEmcSmdGeom* StEEmcSmdGeom::instance() {
40  if(!sInstance){
41  sInstance = new StEEmcSmdGeom();
42  sInstance->init();
43  }
44  return sInstance;
45 }
46 
47 // Returns the single instance of the class for specified sectors
48 
49 StEEmcSmdGeom* StEEmcSmdGeom::instance(intVec sectorIdVec) {
50  if(!sInstance){
51  sInstance = new StEEmcSmdGeom();
52  sInstance->setSectors(sectorIdVec);
53  sInstance->init();
54  }
55  return sInstance;
56 }
57 
58 
60 
61 // return index of a sector from a global point in a plane
62 
63 Int_t StEEmcSmdGeom::getEEmcISec(const Int_t iPlane,
64  const StThreeVectorD& point) const {
65 
66  const TVector3 myPoint ( point[0], point[1], point[2] );
67  Int_t val = EEmcSmdGeom::getEEmcISec( iPlane, myPoint );
68 
69  return val;
70 }
71 
73 
74 // Returns a pointer to the strip which has the smallest DCA (distance of
75 // closest approach) to the specified point.
76 
77 const StructEEmcStrip*
78 StEEmcSmdGeom::getDcaStripPtr(const Int_t iPlane,
79  const Int_t iSec,
80  const StThreeVectorD& point,
81  Float_t* dca) const {
82 
83  const TVector3 myPoint( point[0], point[1], point[2] );
84  return EEmcSmdGeom::getDcaStripPtr( iPlane, iSec, myPoint, dca );
85 
86 }
87 
88 const StructEEmcStrip*
89 StEEmcSmdGeom::getDcaStripPtr(const Int_t iPlane,
90  StThreeVectorD& point,
91  Float_t* dca) const {
92 
93  TVector3 myPoint( point[0], point[1], point[2] );
94  return EEmcSmdGeom::getDcaStripPtr( iPlane, myPoint, dca );
95 
96 }
97 
99 
100  // Given two strips (alternatively sector and strip Id's), return a
101  // vector pointing to the center of the trapezoid formed by their
102  // crossing. These functions may return non-physical locations,
103  // for instance, when a U,V pair does not cross within the
104  // fiducial area of the detector. Note: the z-component returned
105  // will be the average z of the U and V detector planes.
106 
107 StThreeVectorD StEEmcSmdGeom::getIntersection ( Int_t iSec,
108  Int_t iUStrip,
109  Int_t iVStrip ) const {
110 
111  TVector3 myPoint = EEmcSmdGeom::getIntersection(iSec,iUStrip,iVStrip);
112  StThreeVectorD point = StThreeVectorD( myPoint[0], myPoint[1], myPoint[2] );
113  return point;
114 
115 }
116 
117 StThreeVectorD StEEmcSmdGeom::getIntersection ( const StructEEmcStrip *u,
118  const StructEEmcStrip *v ) const {
119 
120  TVector3 myPoint = EEmcSmdGeom::getIntersection(u,v);
121  StThreeVectorD point = StThreeVectorD( myPoint[0], myPoint[1], myPoint[2] );
122  return point;
123 
124 }
125 
127 
128 StThreeVectorD StEEmcSmdGeom::getstripEnd( const StructEEmcStrip &strip,
129  const Int_t endId ) const {
130 
131  TVector3 myPoint = EEmcSmdGeom::getstripEnd( strip, endId );
132  return StThreeVectorD( myPoint[0], myPoint[1], myPoint[2] );
133 
134 }
135 
137 
138 // methods for ITTF
139 
140 // return phiMax and phiMax of a sector including empty sector
141 pairD StEEmcSmdGeom::getEEmcSmdPhiMinMax(const Int_t iPlane, const Int_t iSec) const
142 {
143  pairD phiMinMax;
144  float phiMin, phiMax;
145  //int iUV, antiClockUVId, clockUVId;
146  int iUV, antiClockIUV, clockIUV;
147  int antiClockISec, clockISec;
148 
149  iUV = kEEmcSmdMapUV[iPlane][iSec];
150 
151  if(iUV >= 0) {
152  phiMin = getEEmcSector(iUV, iSec).phiMin;
153  phiMax = getEEmcSector(iUV, iSec).phiMax;
154  }
155  else { // emtry sector
156  // find phiMax in anticlockwise adjacent sector
157  if(iSec != 0) antiClockISec = iSec - 1;
158  else antiClockISec = 11;
159  antiClockIUV = kEEmcSmdMapUV[iPlane][antiClockISec];
160 
161  phiMax = getEEmcSector(antiClockIUV,antiClockISec).phiMin;
162  // find phiMin in clockwise adjacent sector
163  if(iSec != 11) clockISec = iSec + 1;
164  else clockISec = 0;
165  clockIUV = kEEmcSmdMapUV[iPlane][clockISec];
166  phiMin=getEEmcSector(clockIUV,clockISec).phiMax;
167  }
168  phiMinMax.first = (double) phiMin;
169  phiMinMax.second = (double) phiMax;
170 
171  return phiMinMax;
172 }
173 
174 
175 // return delta_phi of a sector including empty sector
176 
177 float StEEmcSmdGeom::getEEmcSmdDelPhi(const Int_t iPlane, const Int_t iSec) const
178 {
179  float delPhi;
180  pairD phiMinMax = getEEmcSmdPhiMinMax(iPlane, iSec);
181  delPhi = (float) phiMinMax.second - (float)phiMinMax.first;
182  if(iSec == kEEmcSmdSectorIdPhiCrossPi - 1) delPhi = 2*pi + delPhi;
183 
184  return delPhi;
185 }
186 
187 
188 
189 // return center phi of a sector including empty sector
190 float StEEmcSmdGeom::getEEmcSmdCenterPhi(const Int_t iPlane,
191  const Int_t iSec) const
192 {
193  float centerPhi;
194  pairD phiMinMax = getEEmcSmdPhiMinMax(iPlane, iSec);
195  centerPhi = 0.5*((float) phiMinMax.second + (float)phiMinMax.first);
196  if(iSec == kEEmcSmdSectorIdPhiCrossPi - 1) {
197  if(centerPhi <= 0) centerPhi= M_PI + centerPhi;
198  else centerPhi = M_PI - centerPhi;
199  }
200 
201  return centerPhi;
202 }
203 
205 
206 void StEEmcSmdGeom::printSectorPhis(const Int_t iPlane, const Int_t iSec,
207  ostream& os ) const {
208  int iUV;
209  iUV = kEEmcSmdMapUV[iPlane][iSec];
210 
211  os << "------EEmcSmdGeom::printPhis()------" << endl;
212  os << " planeId = " << iPlane + 1 << " sectorId = " << iSec + 1 << endl;
213  if(iUV >= 0)
214  os << " " << kEEmcSmdUVChar[iUV] << " Sector" << endl;
215  else
216  os << " Empty" << endl;
217  os << " delPhi = " << getEEmcSmdDelPhi(iPlane, iSec)/degree <<
218  " " << "centerPhi = " << getEEmcSmdCenterPhi(iPlane, iSec)/degree
219  << endl;
220 
221 }
Int_t getEEmcISec(const Int_t iPlane, const TVector3 &point) const
return index of a sector from a point in a plane
StructEEmcSmdSector & getEEmcSector(const Int_t iUV, const Int_t iSec)
return structure-sector from iUV and iSec
Definition: EEmcSmdGeom.h:140
const StructEEmcStrip * getDcaStripPtr(const Int_t iPlane, const TVector3 &point, Float_t *dca) const
TVector3 getstripEnd(const StructEEmcStrip &strip, const Int_t endId) const
return strip-end of 3D-vector
void init()
Initialize geometry class.
Definition: EEmcSmdGeom.cxx:68
TVector3 getIntersection(Int_t iSec, Int_t iUStrip, Int_t iVStrip, const TVector3 &vertex) const
void setSectors(const intVec sectorIdVec)
set sectors for partial EEMC