StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTpcDbGeometry.cc
1 /*****************************************************************
2  *
3  * $Id: StTpcDbGeometry.cc,v 1.12 2018/06/21 22:23:08 perev Exp $
4  *
5  * Authors: Brain Lasiuk & Manuel Calderon de la Barca Sanchez September 8, 1999
6  *
7  *****************************************************************
8  * Description: Database for Geometrical parameters for TRS using
9  * the STAR Main TPC DB made by Dave Hardtke
10  *
11  *****************************************************************
12  *
13  * $Log: StTpcDbGeometry.cc,v $
14  * Revision 1.12 2018/06/21 22:23:08 perev
15  * TpcGroup fixes
16  *
17  * Revision 1.11 2018/02/20 22:45:53 smirnovd
18  * Revert "Changes from Irakli's directory to make the code compile"
19  *
20  * Revision 1.9 2003/09/02 17:59:18 perev
21  * gcc 3.2 updates + WarnOff
22  *
23  * Revision 1.8 2001/03/30 21:22:52 jeromel
24  * Fixes for Insure smooth compilation
25  *
26  * Revision 1.7 2000/06/07 02:03:11 lasiuk
27  * exit/abort ultimatum
28  *
29  * Revision 1.6 2000/03/15 17:39:48 calderon
30  * Remove beeps
31  *
32  * Revision 1.5 2000/02/25 17:25:36 long
33  * move hardwired parameters into database
34  *
35  * Revision 1.4 2000/02/10 01:21:49 calderon
36  * Switch to use StTpcDb.
37  * Coordinates checked for consistency.
38  * Fixed problems with StTrsIstream & StTrsOstream.
39  *
40  * Revision 1.3 2000/01/10 23:14:29 lasiuk
41  * Include MACROS for compatiblity with SUN CC5
42  *
43  * Revision 1.2 1999/12/08 02:10:41 calderon
44  * Modified to eliminate warnings on Linux.
45  *
46  * Revision 1.1 1999/10/11 23:55:21 calderon
47  * Version with Database Access and persistent file.
48  * Not fully tested due to problems with cons, it
49  * doesn't find the local files at compile time.
50  * Yuri suggests forcing commit to work directly with
51  * files in repository.
52  *
53  *
54  *******************************************************************/
55 
56 #ifndef ST_NO_EXCEPTIONS
57 #include <stdexcept>
58 #endif
59 
60 #include "SystemOfUnits.h"
61 #ifndef ST_NO_NAMESPACES
62 using namespace units;
63 #endif
64 
65 #ifndef ST_NO_EXCEPTIONS
66 # include <stdexcept>
67 # if !defined(ST_NO_NAMESPACES)
68  using std::invalid_argument;
69  using std::range_error;
70 # endif
71 #endif
72 
73 #include "StTpcDbGeometry.hh"
74 //#include "StUtilities/StMessMgr.h"
75 #include "StTpcDb/StTpcDb.h"
76 
77 // public Memeber functions of StTpcDb class
78 // StTpcDb(StMaker* mk);
79 // ~StTpcDb();
80 // StTpcPadPlaneI* PadPlaneGeometry();
81 // StTpcWirePlaneI* WirePlaneGeometry();
82 // StTpcDimensionsI* Dimensions();
83 // StTpcSlowControlSimI* SlowControlSim();
84 // StTpcGainI* Gain(int sector);
85 // StTpcT0I* T0(int sector);
86 
87 StTpcGeometry* StTpcDbGeometry::mInstance = 0; // static data member
88 
89 // Constructor for the Geometry DB based on the global pointer
90 // to the STAR TPC DB.
91 StTpcDbGeometry::StTpcDbGeometry(StTpcDb* globalDbPointer)
92 {
93  gTpcDbPtr = globalDbPointer;
94  mPadRows = St_tpcPadConfigC::instance()->numberOfRows(20);
95  mInnerPadRows = St_tpcPadConfigC::instance()->numberOfInnerRows(20);
96  mInnerPadRows48 = St_tpcPadConfigC::instance()->numberOfInnerRows48(20);
97  mInnerPadRows52 = St_tpcPadConfigC::instance()->numberOfInnerRows52(20);
98  mOuterPadRows = St_tpcPadConfigC::instance()->numberOfOuterRows(20);
99  mInnerSectorPadWidth = St_tpcPadConfigC::instance()->innerSectorPadWidth(20);
100  mInnerSectorPadLength = St_tpcPadConfigC::instance()->innerSectorPadLength(20);
101  mInnerSectorPadPitch = St_tpcPadConfigC::instance()->innerSectorPadPitch(20);
102  mInnerSectorRowPitch1 = St_tpcPadConfigC::instance()->innerSectorRowPitch1(20);
103  mInnerSectorRowPitch2 = St_tpcPadConfigC::instance()->innerSectorRowPitch2(20);
104  mFirstPadRow = St_tpcPadConfigC::instance()->firstPadRow(20);
105  mFirstOuterSectorPadRow = St_tpcPadConfigC::instance()->firstOuterSectorPadRow(20);
106  mLastOuterSectorPadRow = St_tpcPadConfigC::instance()->lastOuterSectorPadRow(20);
107  mFirstRowWidth = St_tpcPadConfigC::instance()->firstRowWidth(20);
108  mLastRowWidth = St_tpcPadConfigC::instance()->lastRowWidth(20);
109  mOuterSectorPadWidth = St_tpcPadConfigC::instance()->outerSectorPadWidth(20);
110  mOuterSectorPadLength = St_tpcPadConfigC::instance()->outerSectorPadLength(20);
111  mOuterSectorPadPitch = St_tpcPadConfigC::instance()->outerSectorPadPitch(20);
112  mOuterSectorRowPitch = St_tpcPadConfigC::instance()->outerSectorRowPitch(20);
113  mOuterSectorLength = St_tpcPadConfigC::instance()->outerSectorLength(20);
114  mIoSectorSeparation = St_tpcPadConfigC::instance()->ioSectorSeparation(20);
115  mInnerSectorEdge = St_tpcPadConfigC::instance()->innerSectorEdge(20);
116  mOuterSectorEdge = St_tpcPadConfigC::instance()->outerSectorEdge(20);
117 
118  mSectors = gTpcDbPtr->Dimensions()->numberOfSectors();
119  mIfcRadius = gTpcDbPtr->Dimensions()->ifcRadius();
120  mOfcRadius = gTpcDbPtr->Dimensions()->ofcRadius();
121 
122  mAnodeWireRadius = gTpcDbPtr->WirePlaneGeometry()->anodeWireRadius();
123  mFrischGridWireRadius = gTpcDbPtr->WirePlaneGeometry()->frischGridWireRadius();
124  mGateWireRadius = gTpcDbPtr->WirePlaneGeometry()->gateWireRadius();
125  mAnodeWirePitch = gTpcDbPtr->WirePlaneGeometry()->anodeWirePitch();
126  mFrischGridWirePitch = gTpcDbPtr->WirePlaneGeometry()->frischGridPitch();
127  mGateWirePitch = gTpcDbPtr->WirePlaneGeometry()->gatePitch();
128 
129  mInnerSectorAnodeWirePadPlaneSeparation = gTpcDbPtr->WirePlaneGeometry()->innerSectorAnodeWirePadPlaneSeparation();
130  mInnerSectorFrischGridPadPlaneSeparation = gTpcDbPtr->WirePlaneGeometry()->innerSectorFrischGridPadPlaneSeparation();
131  mInnerSectorGatingGridPadPlaneSeparation = gTpcDbPtr->WirePlaneGeometry()->innerSectorGatingGridPadPlaneSeparation();
132  mOuterSectorAnodeWirePadPlaneSeparation = gTpcDbPtr->WirePlaneGeometry()->outerSectorAnodeWirePadPlaneSeparation();
133  mOuterSectorFrischGridPadPlaneSeparation = gTpcDbPtr->WirePlaneGeometry()->outerSectorFrischGridPadPlaneSeparation();
134  mOuterSectorGatingGridPadPlaneSeparation = gTpcDbPtr->WirePlaneGeometry()->outerSectorGatingGridPadPlaneSeparation();
135 
136  mNumberOfInnerSectorAnodeWires = gTpcDbPtr->WirePlaneGeometry()->numberOfInnerSectorAnodeWires();
137  mFirstInnerSectorAnodeWire = gTpcDbPtr->WirePlaneGeometry()->firstInnerSectorAnodeWire();
138  mLastInnerSectorAnodeWire = gTpcDbPtr->WirePlaneGeometry()->lastInnerSectorAnodeWire();
139 
140  mNumberOfOuterSectorAnodeWires = gTpcDbPtr->WirePlaneGeometry()->numberOfOuterSectorAnodeWires();
141  mFirstOuterSectorAnodeWire = gTpcDbPtr->WirePlaneGeometry()->firstOuterSectorAnodeWire();
142  mLastOuterSectorAnodeWire = gTpcDbPtr->WirePlaneGeometry()->lastOuterSectorAnodeWire();
143 
144 // mTimeBuckets = gTpcDbPtr->()->();
145 // mEndCapZ = gTpcDbPtr->()->();
146 // mFrischGrid = gTpcDbPtr->()->();
147 // mInnerSectorzOffSet = gTpcDbPtr->()->();
148 // mOuterSectorzOffSet = gTpcDbPtr->()->();
149 // mDriftDistance = gTpcDbPtr->()->();
150 
151  mTimeBuckets = gTpcDbPtr->Electronics()->numberOfTimeBins();
152  mEndCapZ = 200.;
153  mFrischGrid = St_tpcPadConfigC::instance()->outerSectorPadPlaneZ(20) -
154  gTpcDbPtr->WirePlaneGeometry()->outerSectorFrischGridPadPlaneSeparation();
155  mInnerSectorzOffSet = gTpcDbPtr->Dimensions()->zInnerOffset();
156  mOuterSectorzOffSet = gTpcDbPtr->Dimensions()->zOuterOffset();
157  mDriftDistance = gTpcDbPtr->Dimensions()->gatingGridZ();
158 
159 
160  //mIoSectorSpacing = gTpcDbPtr->()->();
161 
162  // should be assign --- not supported by egcs 1.0.2
163  //mPadsInRow.assign(mPadRows);
164  mPadsInRow.resize(mPadRows);
165  for(unsigned int ii=0; ii<mPadsInRow.size(); ii++)
166  mPadsInRow[ii] = St_tpcPadConfigC::instance()->numberOfPadsAtRow(20,ii+1); //careful indexing..
167  //mRadialDistanceAtRow.assign(mPadRows);
168  mRadialDistanceAtRow.resize(mPadRows);
169 
170  // Initialize pad map
171 
172  // The variables used to create the pad map have been already created
173  // from the DB, so can leave this part as is. However, since the DB is
174  // there already, we can just loop over it. Does this help?
175 
176  for(unsigned int jj=1; jj<46; jj++)
177  mRadialDistanceAtRow[jj-1] = St_tpcPadConfigC::instance()->radialDistanceAtRow(20,jj);
178 
179  // Make sure units are as expected, the DB units are centimeters and so are SCL units:
180 
181  mIfcRadius *= centimeter;
182  mOfcRadius *= centimeter;
183  mEndCapZ *= centimeter;
184  mInnerSectorPadWidth *= centimeter;
185  mInnerSectorPadLength *= centimeter;
186  mInnerSectorPadPitch *= centimeter;
187  mInnerSectorRowPitch1 *= centimeter;
188  mInnerSectorRowPitch2 *= centimeter;
189  mFirstPadRow *= centimeter;
190  mFirstOuterSectorPadRow *= centimeter;
191  mLastOuterSectorPadRow *= centimeter;
192  mFirstRowWidth *= centimeter;
193  mLastRowWidth *= centimeter;
194  mInnerSectorEdge *= centimeter;
195 
196  mOuterSectorPadWidth *= centimeter;
197  mOuterSectorPadLength *= centimeter;
198  mOuterSectorPadPitch *= centimeter;
199  mOuterSectorRowPitch *= centimeter;
200  mOuterSectorLength *= centimeter;
201 
202  mIoSectorSeparation *= centimeter;
203  mOuterSectorEdge *= centimeter;
204  //mIoSectorSpacing *= centimeter;
205 
206  mFrischGrid *= centimeter;
207  mDriftDistance *= centimeter;
208  mInnerSectorzOffSet *= centimeter;
209  mOuterSectorzOffSet *= centimeter;
210 
211  for(unsigned int k=0; k<mRadialDistanceAtRow.size(); k++)
212  mRadialDistanceAtRow[k] *= centimeter;
213 
214  // Wires
215  mAnodeWirePitch *= centimeter;
216  mFrischGridWirePitch *= centimeter;
217  mGateWirePitch *= centimeter;
218  mAnodeWireRadius *= centimeter;
219  mFrischGridWireRadius *= centimeter;
220  mGateWireRadius *= centimeter;
221 
222  mInnerSectorAnodeWirePadPlaneSeparation *= centimeter;
223  mInnerSectorFrischGridPadPlaneSeparation *= centimeter;
224  mInnerSectorGatingGridPadPlaneSeparation *= centimeter;
225 
226  mOuterSectorAnodeWirePadPlaneSeparation *= centimeter;
227  mOuterSectorFrischGridPadPlaneSeparation *= centimeter;
228  mOuterSectorGatingGridPadPlaneSeparation *= centimeter;
229 
230  mFirstInnerSectorAnodeWire *= centimeter;
231  mLastInnerSectorAnodeWire *= centimeter;
232 
233  mFirstOuterSectorAnodeWire *= centimeter;
234  mLastOuterSectorAnodeWire *= centimeter;
235 }
236 StTpcDbGeometry::~StTpcDbGeometry()
237 {
238  mPadsInRow.clear();
239  mRadialDistanceAtRow.clear();
240 }
242 StTpcDbGeometry::instance()
243 {
244  if (!mInstance) {
245 #ifndef ST_NO_EXCEPTIONS
246  throw invalid_argument("StTpcDbGeometry::getInstance(): Argument Missing!");
247 #else
248  std::cerr << "StTpcDbGeometry::getInstance(): Argument Missing!" << endl;
249  std::cerr << "No arguments for instantiantion" << endl;
250  std::cerr << "Aborting..." << endl;
251  abort();
252 #endif
253  }
254  return mInstance;
255 }
256 
258 StTpcDbGeometry::instance(StTpcDb* gDbPtr)
259 {
260  if (!mInstance) {
261  mInstance = new StTpcDbGeometry(gDbPtr);
262  }
263  else {
264  std::cerr << "StTpcDbGeometry::instance()" << endl;
265  std::cerr << "\tWARNING:" << endl;
266  std::cerr << "\tSingleton class is already instantiated" << endl;
267  std::cerr << "\tDataSet Argument ignored!!" << endl;
268  std::cerr << "\tContinuing..." << endl;
269  }
270  return mInstance;
271 }
272 
273 int StTpcDbGeometry::numberOfPadsAtRow(int r) const
274 {
275  if(r<1 || r>mPadRows) {
276 #ifndef ST_NO_EXCEPTIONS
277  throw invalid_argument("Row limits are from 1--45");
278 #else
279  std::cerr << "Error in StTpcDbGeometry::numberOfPadsAtRow() "
280  << "Row limits [1--" << mPadRows << "]"
281  << " (r=" << r << ")" << endl;
282  abort();
283 #endif
284  }
285  return (mPadsInRow[r-1]); // careful indexing...
286 }
287 
288 double StTpcDbGeometry::radialDistanceAtRow(int r) const
289 {
290  if(r<0 || r>mPadRows) {
291 #ifndef ST_NO_EXCEPTIONS
292  throw invalid_argument("Row limits are from 1--45");
293 #else
294  std::cerr << "Error in StTpcDbGeometry::numberOfPadsAtRow() "
295  << "Row limits [1--" << mPadRows << "]"
296  << " (r=" << r << ")" << endl;
297  abort();
298 #endif
299  }
300  return (mRadialDistanceAtRow[r-1]); // careful indexing...
301 }
302 
303 double StTpcDbGeometry::outerSectorAnodeWire(int n) const
304 {
305  if(n>0 && n<numberOfOuterSectorAnodeWires()) {
306 #ifndef ST_NO_EXCEPTIONS
307  throw range_error("Invalid wire number");
308 #else
309  std::cerr << "Wire Range must be 0 < n < " << numberOfOuterSectorAnodeWires() << endl;
310  std::cerr << "Aborting..." << endl;
311  abort();
312 #endif
313  }
314  return (firstOuterSectorAnodeWire() + (n-1)*anodeWirePitch());
315 }
316 
317 double StTpcDbGeometry::innerSectorAnodeWire(int n) const
318 {
319  if(n>0 && n<numberOfInnerSectorAnodeWires()) {
320 #ifndef ST_NO_EXCEPTIONS
321  throw range_error("Invalid wire number");
322 #else
323  std::cerr << "Wire Range must be 0 < n < " << numberOfInnerSectorAnodeWires() << endl;
324  std::cerr << "Aborting..." << endl;
325  abort();
326 #endif
327  }
328  return (firstInnerSectorAnodeWire() + (n-1)*anodeWirePitch());
329 }
330 
331 // change return type for sun ??
332 bool StTpcDbGeometry::acceptance(StThreeVector<StDouble>& tmp) const
333 {
334  double radial = ::sqrt((tmp.x()*tmp.x())+(tmp.y()*tmp.y()));
335 
336  if((radial > mIfcRadius) &&
337  (radial < mOfcRadius) &&
338  (fabs(tmp.z()) < mEndCapZ))
339  return true;
340  else
341  return false;
342 }
343 
344 void StTpcDbGeometry::print(ostream& os) const
345 {
346  os.width(23);
347  os << "STAR-TPC DataBase" << endl;
348  os << "==========================================" << endl;
349  os << "padRows = " << mPadRows << endl;
350  os << "timeBuckets = " << mTimeBuckets << endl;
351  os << "sectors = " << mSectors << endl;
352  os << "\nField Cage:" << endl;
353  os << "ifcRadius = " << mIfcRadius/millimeter << " mm" << endl;
354  os << "ofcRadius = " << mOfcRadius/millimeter << " mm" << endl;
355  os << "endCapZ = " << mEndCapZ/millimeter << " mm" << endl;
356  os << "DriftDistance = " << mDriftDistance/millimeter << " mm" << endl;
357  os << "innerSectorzOffSet = " << mInnerSectorzOffSet/millimeter << " mm" << endl;
358  os << "outerSectorzOffSet = " << mOuterSectorzOffSet/millimeter << " mm" << endl;
359  os << "\nPads & Rows:" << endl;
360  os << "innerSectorPadWidth = " << mInnerSectorPadWidth/millimeter << " mm" << endl;
361  os << "innerSectorPadLength = " << mInnerSectorPadLength/millimeter << " mm" << endl;
362  os << "innerSectorPadPitch = " << mInnerSectorPadPitch/millimeter << " mm" << endl;
363  os << "innerSectorRowPitch1 = " << mInnerSectorRowPitch1/millimeter << " mm" << endl;
364  os << "innerSectorRowPitch2 = " << mInnerSectorRowPitch2/millimeter << " mm" << endl;
365  os << "firstPadRow = " << mFirstPadRow/millimeter << " mm" << endl;
366  os << "firstOuterSectorPadRow = " << mFirstOuterSectorPadRow/millimeter << " mm" << endl;
367  os << "lastOuterSectorPadRow = " << mLastOuterSectorPadRow/millimeter << " mm" << endl;
368  os << "firstRowWidth = " << mFirstRowWidth/millimeter << " mm" << endl;
369  os << "lastRowWidth = " << mLastRowWidth/millimeter << " mm" << endl;
370  os << "outerSectorPadWidth = " << mOuterSectorPadWidth/millimeter << " mm" << endl;
371  os << "outerSectorPadLength = " << mOuterSectorPadLength/millimeter << " mm" << endl;
372  os << "outerSectorPadPitch = " << mOuterSectorPadPitch /millimeter << " mm" << endl;
373  os << "outerSectorRowPitch = " << mOuterSectorRowPitch/millimeter << " mm" << endl;
374  os << "outerSectorLength = " << mOuterSectorLength /millimeter << " mm" << endl;
375  os << "ioSectorSeparation = " << mIoSectorSeparation/millimeter << " mm" << endl;
376  os << "frischGrid = " << mFrischGrid/millimeter << " mm" << endl;
377  os << "\nWires:" << endl;
378  os << "anodeWirePitch = " << mAnodeWirePitch/millimeter << " mm" << endl;
379  os << "frischGridWirePitch = " << mFrischGridWirePitch/millimeter << " mm" << endl;
380  os << "gatingGridWirePitch = " << mGateWirePitch/millimeter << " mm" << endl;
381  os << "anodeWireRadius = " << mAnodeWireRadius/millimeter << " um" << endl;
382  os << "frischGridWireRadius = " << mFrischGridWireRadius/millimeter << " um" << endl;
383  os << "gatingGridWireRadius = " << mGateWireRadius/millimeter << " um" << endl;
384 
385  os << "Inner Sector:" << endl;
386  os << "AnodeWirePadPlane Sep = " << mInnerSectorAnodeWirePadPlaneSeparation/millimeter << " mm" << endl;
387  os << "FrischGridPadPlane Sep = " << mInnerSectorFrischGridPadPlaneSeparation/millimeter << " mm" << endl;
388  os << "GatingGridPadPlane Sep = " << mInnerSectorGatingGridPadPlaneSeparation/millimeter << " mm" << endl;
389 
390  os << "Outer Sector:" << endl;
391  os << "AnodeWirePadPlane Sep = " << mOuterSectorAnodeWirePadPlaneSeparation/millimeter << " mm" << endl;
392  os << "FrischGridPadPlane Sep = " << mOuterSectorFrischGridPadPlaneSeparation/millimeter << " mm" << endl;
393  os << "GatingGridPadPlane Sep = " << mOuterSectorGatingGridPadPlaneSeparation/millimeter << " mm" << endl;
394 
395  os << "numberOfInnerSectorAnodeWires = " << mNumberOfInnerSectorAnodeWires << endl;
396  os << "firstInnerSectorAnodeWire = " << mFirstInnerSectorAnodeWire/millimeter << " mm" << endl;
397  os << "lastInnerSectorAnodeWire = " << mLastInnerSectorAnodeWire/millimeter << " mm" << endl;
398  os << "numberOfOuterSectorAnodeWires = " << mNumberOfOuterSectorAnodeWires << endl;
399  os << "firstOuterSectorAnodeWire = " << mFirstOuterSectorAnodeWire/millimeter << " mm" << endl;
400  os << "lastOuterSectorAnodeWire = " << mLastOuterSectorAnodeWire/millimeter << " mm" << endl;
401  os << "innerSectorEdge = " << mInnerSectorEdge/millimeter << " mm" << endl;
402  os << "outerSectorEdge = " << mOuterSectorEdge/millimeter << " mm" << endl;
403  //os << "ioSectorSpacing = " << mIoSectorSpacing/millimeter << " mm" << endl;
404  os << endl;
405  os << " Row Pads Radial Distance to Row" << endl;
406  os << "==========================================" << endl;
407  for(int i=0; i<mPadRows; i++) {
408  os.width(3);
409  os.setf(std::ios::right,std::ios::adjustfield);
410  os << i+1;
411  os.width(9);
412  os << mPadsInRow[i];
413  os.width(15);
414  os << mRadialDistanceAtRow[i]/millimeter << " mm" << endl;
415  }
416  os << endl;
417 }