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