StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcParamReader.cc
1 // $Id: StFtpcParamReader.cc,v 1.30 2007/01/26 12:46:06 jcs Exp $
2 //
3 // $Log: StFtpcParamReader.cc,v $
4 // Revision 1.30 2007/01/26 12:46:06 jcs
5 // replace //LOG_INFO with LOG_DEBUG
6 //
7 // Revision 1.29 2007/01/15 07:49:22 jcs
8 // replace printf, cout and gMesMgr with Logger
9 //
10 // Revision 1.28 2006/03/13 19:26:59 jcs
11 // add constructor StFtpcCalibMaker
12 //
13 // Revision 1.27 2004/01/28 01:41:15 jeromel
14 // Change OST to OS everywhere since defaultoption is now not to print
15 // the date.
16 //
17 // Revision 1.26 2003/10/10 12:37:14 jcs
18 // remove parameters used to calculate the FTPC geant volume id using the obsolete method
19 //
20 // Revision 1.25 2003/06/11 11:10:15 jcs
21 // remove inner cathode and cluster geometry parameters from ftpcClusterPars
22 //
23 // Revision 1.24 2003/06/10 13:11:51 jcs
24 // min,max gas temperature and pressure limits removed from ftpcClusterPars
25 //
26 // Revision 1.23 2003/05/07 15:10:26 putschke
27 // improvements for cathode offset corretions
28 //
29 // Revision 1.22 2003/04/15 11:36:11 putschke
30 // Include corrections for inner cathode offset and move some parameter to database
31 //
32 // Revision 1.21 2003/02/27 22:47:40 jcs
33 // make the temperature and pressure parameters available to the Ftpc slow simulator
34 // (needed for embedding)
35 //
36 // Revision 1.20 2002/03/01 14:22:20 jcs
37 // add additional histograms to monitor cluster finding
38 //
39 // Revision 1.18 2002/01/21 22:14:56 jcs
40 // added values for temperature/pressure calculations to ftpcClusterPars
41 //
42 // Revision 1.17 2001/07/11 21:19:31 jcs
43 // remove obsolete entries in tables
44 //
45 // Revision 1.16 2001/04/24 07:11:39 oldi
46 // Float_t mSlowSimPressure introduced to replace mNormalizedNowPressure in
47 // StFtpcSlowSimMaker.
48 //
49 // Revision 1.15 2001/04/02 12:10:26 jcs
50 // get FTPC calibrations,geometry from MySQL database and code parameters
51 // from StarDb/ftpc
52 //
53 // Revision 1.14 2001/03/19 15:52:48 jcs
54 // use ftpcDimensions from database
55 //
56 // Revision 1.13 2001/03/06 23:34:12 jcs
57 // use database instead of params
58 //
59 // Revision 1.12 2001/01/27 20:07:46 jcs
60 // change name of parameter
61 //
62 // Revision 1.11 2001/01/15 16:08:41 jcs
63 // get phiOrigin and phiPerSector fro ftpcDimensions
64 //
65 // Revision 1.10 2001/01/08 17:07:09 jcs
66 // move remaining constants from code to database
67 //
68 // Revision 1.9 2000/12/11 16:39:07 jcs
69 // move FTPC geant volume id and cluster flags from code to parameter reader
70 //
71 // Revision 1.8 2000/11/27 14:09:20 hummler
72 // implement tzero and lorentz angle correction factor
73 //
74 // Revision 1.7 2000/11/14 13:08:26 hummler
75 // add charge step calculation, minor cleanup
76 //
77 // Revision 1.6 2000/11/06 13:42:57 hummler
78 // include latest changes in second constructor as well
79 //
80 // Revision 1.3 2000/10/31 09:52:13 hummler
81 // add parameters for slow simulator
82 //
83 // Revision 1.2 2000/09/18 14:26:50 hummler
84 // expand StFtpcParamReader to supply data for slow simulator as well
85 // introduce StFtpcGeantReader to separate g2t tables from simulator code
86 // implement StFtpcGeantReader in StFtpcFastSimu
87 //
88 // Revision 1.1 2000/08/03 14:39:00 hummler
89 // Create param reader to keep parameter tables away from cluster finder and
90 // fast simulator. StFtpcClusterFinder now knows nothing about tables anymore!
91 //
92 
93 #include "StFtpcParamReader.hh"
94 #include "PhysicalConstants.h"
95 #include "SystemOfUnits.h"
96 
97 #include <math.h>
98 #include "StMessMgr.h"
99 
100 // For StFtpcClusterMaker
101 StFtpcParamReader::StFtpcParamReader(St_ftpcClusterPars *det,
102  St_ftpcFastSimGas *gaspar,
103  St_ftpcFastSimPars *param)
104 {
105 
106  mStandardPressure = atmosphere/(100*pascal);
107 
108  returnCode = kStOK;
109  returnCode += FtpcClusterPars(det);
110  returnCode += FtpcFastSimGas(gaspar);
111  returnCode += FtpcFastSimPars(param);
112 
113  // create empty dummy of fss gas table, to keep destructor uniform
114  mNumberOfFssGasValues = 0;
115  mFssGasEField = new Float_t[1];
116  mFssGasVDrift = new Float_t[1];
117  mFssGasDiffusionX = new Float_t[1];
118  mFssGasDiffusionY = new Float_t[1];
119  mFssGasDiffusionZ = new Float_t[1];
120  mFssGasLorentzAngle = new Float_t[1];
121 
122  LOG_DEBUG << "StFtpcParamReader constructed from StFtpcClusterMaker tables" << endm;
123 }
124 
125 // For StFtpcSlowSimMaker
126 StFtpcParamReader::StFtpcParamReader(St_ftpcClusterPars *det,
127  St_ftpcSlowSimGas *gas,
128  St_ftpcSlowSimPars *param)
129 {
130 
131  mStandardPressure = atmosphere/(100*pascal);
132 
133  returnCode = kStOK;
134  returnCode += FtpcClusterPars(det);
135  returnCode += FtpcSlowSimGas(gas);
136  returnCode += FtpcSlowSimPars(param);
137 
138  LOG_DEBUG << "StFtpcParamReader constructed from StFtpcSlowSimMaker tables" << endm;
139 }
140 
141 // For StFtpcCalibMaker
142 StFtpcParamReader::StFtpcParamReader(St_ftpcClusterPars *det)
143 {
144 
145  returnCode = kStOK;
146  returnCode += FtpcClusterPars(det);
147 
148  // create empty dummy of fss gas table, to keep destructor uniform
149  mNumberOfFssGasValues = 0;
150  mFssGasEField = new Float_t[1];
151  mFssGasVDrift = new Float_t[1];
152  mFssGasDiffusionX = new Float_t[1];
153  mFssGasDiffusionY = new Float_t[1];
154  mFssGasDiffusionZ = new Float_t[1];
155  mFssGasLorentzAngle = new Float_t[1];
156 }
157 
158 
159 StFtpcParamReader::~StFtpcParamReader()
160 {
161 
162  // write back clusterpars table entries that have set functions:
163  mClusterParsTable->normalizedNowPressure = mNormalizedNowPressure;
164  mClusterParsTable->adjustedAirPressureWest = mAdjustedAirPressureWest;
165  mClusterParsTable->adjustedAirPressureEast = mAdjustedAirPressureEast;
166  mClusterParsTable->gasTemperatureWest = mGasTemperatureWest;
167  mClusterParsTable->gasTemperatureEast = mGasTemperatureEast;
168 
169  // delete allocated memory
170  delete[] mFssGasEField;
171  delete[] mFssGasVDrift;
172  delete[] mFssGasDiffusionX;
173  delete[] mFssGasDiffusionY;
174  delete[] mFssGasDiffusionZ;
175  delete[] mFssGasLorentzAngle;
176 
177  LOG_DEBUG << "StFtpcParamReader destructed" << endm;
178 }
179 
180 //===============================================================
181 
182 Int_t StFtpcParamReader::FtpcClusterPars(St_ftpcClusterPars *det)
183 {
184 
185  // ftpcClusterPars table exists only once, just copy
186  ftpcClusterPars_st *detTable = det->GetTable();
187  if(detTable){
188  mClusterParsTable = detTable; // copy to data member to write parameters back
189  mGaussFittingFlags = detTable->gaussFittingFlags;
190  mMinimumClusterMaxADC = detTable->minimumClusterMaxADC;
191  mNumberOfDriftSteps = detTable->numberOfDriftSteps;
192  mOrderOfDiffusionErrors = detTable->orderOfDiffusionErrors;
193  mPadDiffusionErrors = (Float_t *) detTable->padDiffusionErrors;
194  mTimeDiffusionErrors = (Float_t *) detTable->timeDiffusionErrors;
195  mLorentzAngleFactor = detTable->lorentzAngleFactor;
196  mPadBadFitError = detTable->padBadFitError;
197  mTimeBadFitError = detTable->timeBadFitError;
198  mPadUnfoldError = detTable->padUnfoldError;
199  mTimeUnfoldError = detTable->timeUnfoldError;
200  mPadFailedFitError = detTable->padFailedFitError;
201  mTimeFailedFitError = detTable->timeFailedFitError;
202  mPadCutoffClusterError = detTable->padCutoffClusterError;
203  mTimeCutoffClusterError = detTable->timeCutoffClusterError;
204  mPadSaturatedClusterError = detTable->padSaturatedClusterError;
205  mTimeSaturatedClusterError = detTable->timeSaturatedClusterError;
206  m2PadWeightedError = detTable->twoPadWeightedError;
207  m2PadGaussError = detTable->twoPadGaussError;
208  m3PadWeightedError = detTable->threePadWeightedError;
209  m3PadGaussError = detTable->threePadGaussError;
210  mZDirectionError = detTable->zDirectionError;
211  mNormalizedNowPressure = detTable->normalizedNowPressure;
212  mAdjustedAirPressureWest = detTable->adjustedAirPressureWest;
213  mAdjustedAirPressureEast = detTable->adjustedAirPressureEast;
214  mGasTemperatureWest = detTable->gasTemperatureWest;
215  mGasTemperatureEast = detTable->gasTemperatureEast;
216  mMaxNumSequences = detTable->maxNumSequences ;
217  mMaxNumSeqPeaks = detTable->maxNumSeqPeaks;
218  mMaxNumPeaks = detTable->maxNumPeaks;
219  mMaxNumCUC = detTable->maxNumCUC;
220  mMaxLoops = detTable->maxLoops;
221  mMaxFastLoops = detTable->maxFastLoops;
222  mUnfoldLimit = detTable->unfoldLimit;
223  mUnfoldFailedLimit = detTable->unfoldFailedLimit;
224  return kStOK;
225  } else {
226  LOG_ERROR << "No data in table class St_ftpcClusterPars" << endm;
227  return kStERR;
228  }
229 }
230 
231 //----------------------------------------------------------------------------
232 
233 Int_t StFtpcParamReader::FtpcFastSimGas(St_ftpcFastSimGas *gaspar)
234 {
235  // just copy gaspar array pointers
236  ftpcFastSimGas_st *gasTable = gaspar->GetTable();
237  if(gasTable){
238  mOrderOfFastEstimates = gasTable->orderOfFastEstimates;
239  mVDriftEstimates = (Float_t *) &(gaspar->GetTable()->driftVelocityEstimates);
240  mTDriftEstimates = (Float_t *) &(gaspar->GetTable()->driftTimeEstimates);
241  mSigmaRadialEstimates = (Float_t *) &(gaspar->GetTable()->sigmaRadialEstimates);
242  mSigmaAzimuthalEstimates = (Float_t *) &(gaspar->GetTable()->sigmaAzimuthalEstimates);
243  mErrorRadialEstimates = (Float_t *) &(gaspar->GetTable()->errorRadialEstimates);
244  mErrorAzimuthalEstimates = (Float_t *) &(gaspar->GetTable()->errorAzimuthalEstimates);
245  return kStOK;
246  } else {
247  LOG_ERROR << "No data in table class St_ftpcFastSimGas" << endm;
248  return kStERR;
249  }
250 }
251 
252 //----------------------------------------------------------------------------
253 
254 Int_t StFtpcParamReader::FtpcFastSimPars(St_ftpcFastSimPars *param)
255 {
256  // ftpcFastSimPars table exists only once, just copy
257  ftpcFastSimPars_st *paramTable = param->GetTable();
258  if(paramTable){
259  mUnfoldedClusterFlag = paramTable->unfoldedClusterFlag;
260  mBadShapeClusterFlag = paramTable->badShapeClusterFlag;
261  mMergedClusterFlag = paramTable->mergedClusterFlag;
262  mNumberOfPadsDedxSmearing = paramTable->numberOfPadsDedxSmearing;
263  mNumberOfBinsDedxSmearing = paramTable->numberOfBinsDedxSmearing;
264  mRadiusTolerance = paramTable->radiusTolerance;
265  mSigmaSpacingFactor = paramTable->sigmaSpacingFactor;
266  mAdcConversionFactor = paramTable->adcConversionFactor;
267  mClusterChargeConversionFactor = paramTable->clusterChargeConversionFactor;
268  return kStOK;
269  } else {
270  LOG_ERROR << "No data in table class St_ftpcFastSimPars" << endm;
271  return kStERR;
272  }
273 }
274 
275 //----------------------------------------------------------------------------
276 
277 Int_t StFtpcParamReader::FtpcSlowSimGas(St_ftpcSlowSimGas *gas)
278 {
279  // slow simulator gas table has to be copied to be accessible as separate arrays
280  mNumberOfFssGasValues = gas->GetNRows();
281  mFssGasEField = new Float_t[mNumberOfFssGasValues];
282  mFssGasVDrift = new Float_t[mNumberOfFssGasValues];
283  mFssGasDiffusionX = new Float_t[mNumberOfFssGasValues];
284  mFssGasDiffusionY = new Float_t[mNumberOfFssGasValues];
285  mFssGasDiffusionZ = new Float_t[mNumberOfFssGasValues];
286  mFssGasLorentzAngle = new Float_t[mNumberOfFssGasValues];
287  Int_t i;
288  ftpcSlowSimGas_st *gasTable = gas->GetTable();
289  if (gasTable) {
290  for(i=0; i<mNumberOfFssGasValues; i++)
291  {
292  mFssGasEField[i] = gasTable[i].electricField;
293  mFssGasVDrift[i] = gasTable[i].driftVelocity;
294  mFssGasDiffusionX[i] = gasTable[i].diffusionX;
295  mFssGasDiffusionY[i] = gasTable[i].diffusionY;
296  mFssGasDiffusionZ[i] = gasTable[i].diffusionZ;
297  mFssGasLorentzAngle[i] = gasTable[i].lorentzAngle;
298  }
299  return kStOK;
300  }
301  else {
302  LOG_ERROR << "No data in table class St_ftpcSlowSimGas" << endm;
303  return kStERR;
304  }
305 }
306 
307 //----------------------------------------------------------------------------
308 
309 Int_t StFtpcParamReader::FtpcSlowSimPars(St_ftpcSlowSimPars *param)
310 {
311  // ftpcSlowSimPars table exists only once, just copy
312  ftpcSlowSimPars_st *paramTable = param->GetTable();
313  if(paramTable){
314  mRandomNumberGenerator = paramTable->randomNumberGenerator;
315  mZeroSuppressThreshold = paramTable->zeroSuppressThreshold;
316  mNumSlowSimGridPoints = paramTable->numSlowSimGridPoints;
317  mMaxAdc = paramTable->maxAdc;
318  mGaussIntegrationSteps = paramTable->numGaussIntSteps;
319  mDiffusionCoarseness = paramTable->diffusionCoarseness;
320  mAdcConversion = paramTable->adcConversion;
321  mChamberCathodeVoltage = paramTable->chamberCathodeVoltage;
322  mSigmaPadResponseFuntion = paramTable->sigmaPadResponseFuntion;
323  mReadoutShaperTime = paramTable->shaperTime;
324  mSlowSimPressure = paramTable->slowSimPressure;
325  return kStOK;
326  } else {
327  LOG_ERROR << "No data in table class St_ftpcSlowSimPars" << endm;
328  return kStERR;
329  }
330 }
331 
332 //===============================================================
333 
334 
335 Float_t StFtpcParamReader::padDiffusionErrors(Int_t i)
336 {
337  if(i>=0 && i<mOrderOfDiffusionErrors)
338  {
339  return mPadDiffusionErrors[i];
340  }
341  else
342  {
343  LOG_WARN << "StFtpcParamReader: padDiffusionErrors index out of range, using 0" << endm;
344  return mPadDiffusionErrors[0];
345  }
346 }
347 
348 //----------------------------------------------------------------------------
349 
350 Float_t StFtpcParamReader::timeDiffusionErrors(Int_t i)
351 {
352  if(i>=0 && i<mOrderOfDiffusionErrors)
353  {
354  return mTimeDiffusionErrors[i];
355  }
356  else
357  {
358  LOG_WARN << "StFtpcParamReader: timeDiffusionErrors index out of range, using 0" << endm;
359  return mTimeDiffusionErrors[0];
360  }
361 }
362 
363 //----------------------------------------------------------------------------
364 
365 Float_t StFtpcParamReader::vDriftEstimates(Int_t i)
366 {
367  if(i>=0 && i<mOrderOfFastEstimates)
368  {
369  return mVDriftEstimates[i];
370  }
371  else
372  {
373  LOG_WARN << "StFtpcParamReader: vDriftEstimates index out of range, using 0" << endm;
374  return mVDriftEstimates[0];
375  }
376 }
377 
378 //----------------------------------------------------------------------------
379 
380 Float_t StFtpcParamReader::tDriftEstimates(Int_t i)
381 {
382  if(i>=0 && i<mOrderOfFastEstimates)
383  {
384  return mTDriftEstimates[i];
385  }
386  else
387  {
388  LOG_WARN << "StFtpcParamReader: tDriftEstimates index out of range, using 0" << endm;
389  return mTDriftEstimates[0];
390  }
391 }
392 
393 //----------------------------------------------------------------------------
394 
395 Float_t StFtpcParamReader::sigmaRadialEstimates(Int_t i)
396 {
397  if(i>=0 && i<mOrderOfFastEstimates)
398  {
399  return mSigmaRadialEstimates[i];
400  }
401  else
402  {
403  LOG_WARN << "StFtpcParamReader: sigmaRadialEstimates index out of range, using 0" << endm;
404  return mSigmaRadialEstimates[0];
405  }
406 }
407 
408 //----------------------------------------------------------------------------
409 
410 Float_t StFtpcParamReader::sigmaAzimuthalEstimates(Int_t i)
411 {
412  if(i>=0 && i<mOrderOfFastEstimates)
413  {
414  return mSigmaAzimuthalEstimates[i];
415  }
416  else
417  {
418  LOG_WARN << "StFtpcParamReader: sigmaAzimuthalEstimates index out of range, using 0" << endm;
419  return mSigmaAzimuthalEstimates[0];
420  }
421 }
422 
423 //----------------------------------------------------------------------------
424 
425 Float_t StFtpcParamReader::errorRadialEstimates(Int_t i)
426 {
427  if(i>=0 && i<mOrderOfFastEstimates)
428  {
429  return mErrorRadialEstimates[i];
430  }
431  else
432  {
433  LOG_WARN << "StFtpcParamReader: errorRadialEstimates index out of range, using 0" << endm;
434  return mErrorRadialEstimates[0];
435  }
436 }
437 
438 //----------------------------------------------------------------------------
439 
440 Float_t StFtpcParamReader::errorAzimuthalEstimates(Int_t i)
441 {
442  if(i>=0 && i<mOrderOfFastEstimates)
443  {
444  return mErrorAzimuthalEstimates[i];
445  }
446  else
447  {
448  LOG_WARN << "StFtpcParamReader: errorAzimuthalEstimates index out of range, using 0" << endm;
449  return mErrorAzimuthalEstimates[0];
450  }
451 }
452 
453 //----------------------------------------------------------------------------
454 
455 Float_t StFtpcParamReader::fssGasEField(Int_t i)
456 {
457  if(i>=0 && i<mNumberOfFssGasValues)
458  {
459  return mFssGasEField[i];
460  }
461  else
462  {
463  LOG_WARN << "StFtpcParamReader: fssGasEField index out of range, using 0" << endm;
464  return mFssGasEField[0];
465  }
466 }
467 
468 //----------------------------------------------------------------------------
469 
470 Float_t StFtpcParamReader::fssGasVDrift(Int_t i)
471 {
472  if(i>=0 && i<mNumberOfFssGasValues)
473  {
474  return mFssGasVDrift[i];
475  }
476  else
477  {
478  LOG_WARN << "StFtpcParamReader: fssGasVDrift index out of range, using 0" << endm;
479  return mFssGasVDrift[0];
480  }
481 }
482 
483 //----------------------------------------------------------------------------
484 
485 Float_t StFtpcParamReader::fssGasDiffusionX(Int_t i)
486 {
487  if(i>=0 && i<mNumberOfFssGasValues)
488  {
489  return mFssGasDiffusionX[i];
490  }
491  else
492  {
493  LOG_WARN << "StFtpcParamReader: fssGasDiffusionX index out of range, using 0" << endm;
494  return mFssGasDiffusionX[0];
495  }
496 }
497 
498 //----------------------------------------------------------------------------
499 
500 Float_t StFtpcParamReader::fssGasDiffusionY(Int_t i)
501 {
502  if(i>=0 && i<mNumberOfFssGasValues)
503  {
504  return mFssGasDiffusionY[i];
505  }
506  else
507  {
508  LOG_WARN << "StFtpcParamReader: fssGasDiffusionY index out of range, using 0" << endm;
509  return mFssGasDiffusionY[0];
510  }
511 }
512 
513 //----------------------------------------------------------------------------
514 
515  Float_t StFtpcParamReader::fssGasDiffusionZ(Int_t i)
516 {
517  if(i>=0 && i<mNumberOfFssGasValues)
518  {
519  return mFssGasDiffusionZ[i];
520  }
521  else
522  {
523  LOG_WARN << "StFtpcParamReader: fssGasDiffusionZ index out of range, using 0" << endm;
524  return mFssGasDiffusionZ[0];
525  }
526 }
527 
528 //----------------------------------------------------------------------------
529 
530  Float_t StFtpcParamReader::fssGasLorentzAngle(Int_t i)
531 {
532  if(i>=0 && i<mNumberOfFssGasValues)
533  {
534  return mFssGasLorentzAngle[i];
535  }
536  else
537  {
538  LOG_WARN << "StFtpcParamReader: fssGasLorentzAngle index out of range, using 0" << endm;
539  return mFssGasLorentzAngle[0];
540  }
541 }
542 
543 
Definition: Stypes.h:40
Definition: Stypes.h:45