StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcDbReader.cc
1 // $Id: StFtpcDbReader.cc,v 1.46 2010/04/08 16:46:16 jcs Exp $
2 //
3 // $Log: StFtpcDbReader.cc,v $
4 // Revision 1.46 2010/04/08 16:46:16 jcs
5 // swap data for RDO6,RDO7 FTPC East when Calibrations_ftpc/ftpcElectronics->swapRDO6RDO7East=1
6 //
7 // Revision 1.45 2010/01/14 18:23:00 jcs
8 // store laser tZero in electronicsTable for laser runs so that all events in a
9 // laser run are reconstructed with the laser tZero
10 //
11 // Revision 1.44 2009/12/11 15:41:06 jcs
12 // For laser run use laserTZero and no inner cathode correction
13 //
14 // Revision 1.43 2009/08/04 08:37:28 jcs
15 // When the flaser option is included in the bfc, the 'perfect' gain table and
16 // adjustAverageWest = adjustAverageEast = 0.0, will be used for cluster finding
17 //
18 // Revision 1.42 2008/07/30 14:47:30 jcs
19 // if microsecondsPerTimebin calculated from RHIC clock, write the new value for mMicrosecondsPerTimebin back into
20 // Calibrations_ftpc/ftpcElectronics table
21 //
22 // Revision 1.41 2008/05/13 19:12:00 jcs
23 // added laserTZero to Calibrations_ftpc/ftpcElectronics
24 //
25 // Revision 1.40 2007/11/13 10:54:37 jcs
26 // Code to mask out Ftpc East sectors 1,3 and 5
27 // Necessary for calculating rotation offset values when one sector is turned off
28 // as was the case for the 2007 RFF runs
29 //
30 // Revision 1.39 2007/02/01 11:57:04 jcs
31 // move unessential output from INFO to DEBUG
32 //
33 // Revision 1.38 2007/01/15 07:49:22 jcs
34 // replace printf, cout and gMesMgr with Logger
35 //
36 // Revision 1.37 2006/10/17 19:11:43 fisyak
37 // Add definition of mPadPitch
38 //
39 // Revision 1.36 2006/03/13 19:26:58 jcs
40 // add constructor StFtpcCalibMaker
41 //
42 // Revision 1.35 2006/01/13 12:36:41 jcs
43 // If no RHIC clock frequency value available, set mMicrosecondsPerTimebin to
44 // dimensionsTable->sizeOfTimebin for DbV options earlier than 20051021
45 // otherwise use electronicsTable->uSecondsPerTimebin as the default value for mMicrosecondsPerTimebin
46 //
47 // Revision 1.34 2005/12/12 14:46:53 jcs
48 // comment out debug output
49 //
50 // Revision 1.33 2005/12/12 13:40:12 jcs
51 // simplify StFtpcDbReader
52 //
53 // Revision 1.32 2005/10/26 14:03:43 jcs
54 // Change setMicrosecondsPerTimebin
55 //
56 // Revision 1.31 2005/10/25 14:38:28 jcs
57 // correct electronicsTable definition used for StFtpcSlowSimMaker
58 //
59 // Revision 1.30 2005/10/24 13:43:01 jcs
60 // If microsecondsPerTimebin calculated from RHIC clock frequency, store in
61 // Calibrations_ftpc/ftpcElectronics database table. Otherwise get default
62 // value from Calibrations_ftpc/ftpcElectronics database table.
63 //
64 // Revision 1.29 2005/04/13 08:14:17 jcs
65 // Invert sector numbering for Ftpc East when accessing the gain table (ftpcAmpSlope)
66 // since this wasn't done when the gain table was produced
67 //
68 // Revision 1.28 2004/07/18 14:10:09 jcs
69 // get adjustAverageWest/East from Calibrations_ftpc/ftpcGas
70 //
71 // Revision 1.27 2004/01/28 01:41:15 jeromel
72 // Change OST to OS everywhere since defaultoption is now not to print
73 // the date.
74 //
75 // Revision 1.26 2003/07/03 13:21:50 fsimon
76 // Added cathode offset information to constructor for SlowSimulator
77 //
78 // Revision 1.25 2003/06/12 10:01:25 jcs
79 // renamed ftpcClusterGeometry database table to ftpcClusterGeom
80 // (name was too long)
81 //
82 // Revision 1.24 2003/06/11 12:06:03 jcs
83 // get inner cathode and cluster geometry parameters from database
84 //
85 // Revision 1.23 2003/06/10 13:13:51 jcs
86 // get mix,max gas temperature and pressure limits from database
87 //
88 // Revision 1.22 2003/05/06 20:19:40 mora
89 // Add a new constructor only with FTPC dimensions and geometry for ITTF
90 //
91 // Revision 1.21 2003/02/27 22:53:12 jcs
92 // make default temperature values from database available to the FTPC slow simulator (needed for embedding)
93 //
94 // Revision 1.20 2003/02/19 14:51:46 jcs
95 // get default temperatures from database
96 //
97 // Revision 1.19 2003/01/15 10:39:31 jcs
98 // Correct error in message
99 //
100 // Revision 1.18 2003/01/14 12:58:01 jcs
101 // use Geometry_ftpc/ftpcAsicMap to control corrections for error in Y2001-2002
102 // FTPC asic mapping
103 //
104 // Revision 1.17 2003/01/07 16:15:18 jcs
105 // get all values in ftpcGas table for cluster finding
106 //
107 // Revision 1.16 2002/10/16 12:25:13 fsimon
108 // Cleanup: Use gMessMgr instead of cout
109 //
110 // Revision 1.15 2002/10/15 09:46:44 fsimon
111 // Constructor used by SlowSimulator changed to include Db access to
112 // ftpcAmpSlope, ftpcAmpOffset and ftpcTimeOffset
113 //
114 // Revision 1.14 2002/10/11 15:37:36 oldi
115 // Minor cosmetics.
116 //
117 // Revision 1.13 2002/01/31 19:35:38 jcs
118 // get temperatureDifference from data base
119 //
120 // Revision 1.12 2002/01/21 22:12:53 jcs
121 // add gas temperature difference between west and east FTPC to database
122 //
123 // Revision 1.11 2001/11/21 12:36:27 jcs
124 // make ftpcGas database table available to FTPC cluster maker
125 //
126 // Revision 1.10 2001/10/29 12:54:43 jcs
127 // add new constructor for StFtpcDriftMapMaker
128 //
129 // Revision 1.9 2001/10/19 09:40:11 jcs
130 // tZero now in data base in ftpcElectronics
131 //
132 // Revision 1.8 2001/08/21 19:51:06 jcs
133 // correct value of sizeOfTimebin now in MySQL database - remove from code
134 //
135 // Revision 1.7 2001/08/16 18:32:20 jcs
136 // set value of tzero = 1.937
137 //
138 // Revision 1.6 2001/07/12 10:26:34 jcs
139 // temporarily set mMicrosecondsPerTimeBin and mTZero in code instead of in MySQLDB
140 //
141 // Revision 1.5 2001/07/11 21:18:02 jcs
142 // changes for new FTPC database structures
143 //
144 // Revision 1.4 2001/04/04 17:08:42 jcs
145 // remove references to StFtpcParamReader from StFtpcDbReader
146 //
147 // Revision 1.3 2001/04/02 12:10:22 jcs
148 // get FTPC calibrations,geometry from MySQL database and code parameters
149 // from StarDb/ftpc
150 //
151 // Revision 1.2 2001/03/19 15:52:47 jcs
152 // use ftpcDimensions from database
153 //
154 // Revision 1.1 2001/03/06 23:34:00 jcs
155 // use database instead of params
156 //
157 //
158 
159 #include "StFtpcDbReader.hh"
160 #include "StMessMgr.h"
161 
162 // for StFtpcClusterMaker
163 StFtpcDbReader::StFtpcDbReader(St_ftpcDimensions *dimensions,
164  St_ftpcPadrowZ *zrow,
165  St_ftpcAsicMap *asicmap,
166  St_ftpcEField *efield,
167  St_ftpcVDrift *vdrift,
168  St_ftpcDeflection *deflection,
169  St_ftpcdVDriftdP *dvdriftdp,
170  St_ftpcdDeflectiondP *ddeflectiondp,
171  St_ftpcAmpSlope *ampslope,
172  St_ftpcAmpOffset *ampoffset,
173  St_ftpcTimeOffset *timeoffset,
174  St_ftpcDriftField *driftfield,
175  St_ftpcGas *gas,
176  St_ftpcElectronics *electronics,
177  St_ftpcInnerCathode *cathode,
178  St_ftpcClusterGeom *clustergeo)
179 {
180 
181  returnCode = kStOK;
182  returnCode += FtpcDimensions(dimensions);
183  returnCode += FtpcPadrowZ(zrow);
184  returnCode += FtpcAsicMap(asicmap);
185  returnCode += FtpcEField(efield);
186  returnCode += FtpcVDrift(vdrift);
187  returnCode += FtpcDeflection(deflection);
188  returnCode += FtpcdVDriftdP(dvdriftdp);
189  returnCode += FtpcdDeflectiondP(ddeflectiondp);
190  returnCode += FtpcAmpSlope(ampslope);
191  returnCode += FtpcAmpOffset(ampoffset);
192  returnCode += FtpcTimeOffset(timeoffset);
193  returnCode += FtpcDriftField(driftfield);
194  returnCode += FtpcGas(gas);
195  returnCode += FtpcElectronics(electronics);
196  returnCode += FtpcInnerCathode(cathode);
197  returnCode += FtpcClusterGeom(clustergeo);
198 
199  mLaserRun = (Bool_t)kFALSE;
200  //LOG_DEBUG << "StFtpcDbReader constructed for StFtpcClusterMaker" << endm;
201 
202 }
203 
204 // for StFtpcSlowSimMaker
205 StFtpcDbReader::StFtpcDbReader(St_ftpcDimensions *dimensions,
206  St_ftpcAsicMap *asicmap,
207  St_ftpcEField *efield,
208  St_ftpcVDrift *vdrift,
209  St_ftpcDeflection *deflection,
210  St_ftpcdVDriftdP *dvdriftdp,
211  St_ftpcdDeflectiondP *ddeflectiondp,
212  St_ftpcGas *gas,
213  St_ftpcDriftField *driftfield,
214  St_ftpcElectronics *electronics,
215  St_ftpcAmpSlope *ampslope,
216  St_ftpcAmpOffset *ampoffset,
217  St_ftpcTimeOffset *timeoffset,
218  St_ftpcInnerCathode *cathode)
219 {
220 
221  returnCode = kStOK;
222  returnCode += FtpcDimensions(dimensions);
223  returnCode += FtpcAsicMap(asicmap);
224  returnCode += FtpcEField(efield);
225  returnCode += FtpcVDrift(vdrift);
226  returnCode += FtpcDeflection(deflection);
227  returnCode += FtpcdVDriftdP(dvdriftdp);
228  returnCode += FtpcdDeflectiondP(ddeflectiondp);
229  returnCode += FtpcGas(gas);
230  returnCode += FtpcDriftField(driftfield);
231  returnCode += FtpcElectronics(electronics);
232  returnCode += FtpcAmpSlope(ampslope);
233  returnCode += FtpcAmpOffset(ampoffset);
234  returnCode += FtpcTimeOffset(timeoffset);
235  returnCode += FtpcInnerCathode(cathode);
236 
237  mLaserRun = (Bool_t)kFALSE;
238  //LOG_DEBUG << "StFtpcDbReader constructed for StFtpcSlowSimMaker" << endm;
239 }
240 
241 // for StFtpcDriftMapMaker
242 StFtpcDbReader::StFtpcDbReader(St_ftpcDimensions *dimensions,
243  St_ftpcPadrowZ *zrow,
244  St_ftpcEField *efield,
245  St_ftpcVDrift *vdrift,
246  St_ftpcDeflection *deflection,
247  St_ftpcdVDriftdP *dvdriftdp,
248  St_ftpcdDeflectiondP *ddeflectiondp,
249  St_ftpcGas *gas,
250  St_ftpcDriftField *driftfield)
251 {
252 
253  returnCode = kStOK;
254  returnCode += FtpcDimensions(dimensions);
255  returnCode += FtpcPadrowZ(zrow);
256  returnCode += FtpcEField(efield);
257  returnCode += FtpcVDrift(vdrift);
258  returnCode += FtpcDeflection(deflection);
259  returnCode += FtpcdVDriftdP(dvdriftdp);
260  returnCode += FtpcdDeflectiondP(ddeflectiondp);
261  returnCode += FtpcGas(gas);
262  returnCode += FtpcDriftField(driftfield);
263 
264  mLaserRun = (Bool_t)kFALSE;
265  //LOG_DEBUG << "StFtpcDbReader constructed for StFtpcDriftMapMaker" << endm;
266 }
267 
268 // for StFtpcCalibMaker
269 StFtpcDbReader::StFtpcDbReader(St_ftpcDimensions *dimensions,
270  St_ftpcPadrowZ *zrow,
271  St_ftpcEField *efield,
272  St_ftpcVDrift *vdrift,
273  St_ftpcDeflection *deflection,
274  St_ftpcdVDriftdP *dvdriftdp,
275  St_ftpcdDeflectiondP *ddeflectiondp,
276  St_ftpcElectronics *electronics,
277  St_ftpcGas *gas,
278  St_ftpcDriftField *driftfield)
279 {
280 
281  returnCode = kStOK;
282  returnCode += FtpcDimensions(dimensions);
283  returnCode += FtpcPadrowZ(zrow);
284  returnCode += FtpcEField(efield);
285  returnCode += FtpcVDrift(vdrift);
286  returnCode += FtpcDeflection(deflection);
287  returnCode += FtpcdVDriftdP(dvdriftdp);
288  returnCode += FtpcdDeflectiondP(ddeflectiondp);
289  returnCode += FtpcElectronics(electronics);
290  returnCode += FtpcGas(gas);
291  returnCode += FtpcDriftField(driftfield);
292 
293  mLaserRun = (Bool_t)kFALSE;
294  //LOG_DEBUG << "StFtpcDbReader constructed for StFtpcCalibMaker" << endm;
295 }
297 // for Sti/StFtpcDetectorBuilder
298 StFtpcDbReader::StFtpcDbReader(St_ftpcDimensions *dimensions,
299  St_ftpcPadrowZ *zrow )
300 {
301 
302  returnCode = kStOK;
303  returnCode += FtpcDimensions(dimensions);
304  returnCode += FtpcPadrowZ(zrow);
305 
306  mLaserRun = (Bool_t)kFALSE;
307  //LOG_DEBUG << "StFtpcDbReader constructed for Sti/StFtpcDetectorBuilder" << endm;
308 
309 }
310 
311 StFtpcDbReader::~StFtpcDbReader()
312 {
313 // LOG_DEBUG << "StFtpcDbReader destructed" << endm;
314 }
315 
316 //===============================================================
317 
318 Int_t StFtpcDbReader::FtpcDimensions(St_ftpcDimensions *dimensions)
319 {
320 
321 
322  // just copy dimensions table start to pointer
323  ftpcDimensions_st* dimensionsTable = (ftpcDimensions_st*)dimensions->GetTable();
324  if(dimensionsTable){
325  mNumberOfPadrows = dimensionsTable->totalNumberOfPadrows;
326  mNumberOfPadrowsPerSide = dimensionsTable->numberOfPadrowsPerSide;
327  mFirstPadrowToSearch = dimensionsTable->firstPadrowToSearch;
328  mLastPadrowToSearch = dimensionsTable->lastPadrowToSearch;
329  mNumberOfSectors = dimensionsTable->numberOfSectorsPerPadrow;
330  mFirstSectorToSearch = dimensionsTable->firstSectorToSearch;
331  mLastSectorToSearch = dimensionsTable->lastSectorToSearch;
332  mPhiOrigin = dimensionsTable->phiOrigin;
333  mPhiPerSector = dimensionsTable->phiPerSector;
334  mNumberOfPads = dimensionsTable->numberOfPadsPerSector;
335  mPadLength = dimensionsTable->padLength;
336  mPadPitch = dimensionsTable->padPitch;
337  mRadiansPerPad = dimensionsTable->radiansPerPad;
338  mRadiansPerBoundary = dimensionsTable->radiansPerGap;
339  mNumberOfTimebins = dimensionsTable->numberOfTimebinsPerSector;
340  mMicrosecondsPerTimebin = dimensionsTable->sizeOfTimebin;
341  mSensitiveVolumeInnerRadius = dimensionsTable->innerRadiusSensitiveVolume;
342  mSensitiveVolumeOuterRadius = dimensionsTable->outerRadiusSensitiveVolume;
343  return kStOK;
344  } else {
345  LOG_ERROR << " No data in table class St_ftpcDimensions" << endm;
346  return kStERR;
347  }
348 }
349 
350 //----------------------------------------------------------------------------
351 
352 Int_t StFtpcDbReader::FtpcPadrowZ(St_ftpcPadrowZ *zrow)
353 {
354 
355  // just copy zrow table start to pointer
356  ftpcPadrowZ_st* padrowzTable = (ftpcPadrowZ_st*)zrow->GetTable();
357  if(padrowzTable){
358  mPadrowZPosition = (Float_t *)padrowzTable->z;
359  return kStOK;
360  } else {
361  LOG_ERROR << " No data in table class St_ftpcPadrowZ" << endm;
362  return kStERR;
363  }
364 }
365 
366 //----------------------------------------------------------------------------
367 
368 Int_t StFtpcDbReader::FtpcAsicMap(St_ftpcAsicMap *asicmap)
369 {
370 
371  // just copy asicmap table start to pointer
372  ftpcAsicMap_st* asicmapTable = (ftpcAsicMap_st*)asicmap->GetTable();
373  if(asicmapTable){
374  mEastIsInverted = asicmapTable->EastIsInverted;
375  mAsic2EastNotInverted = asicmapTable->Asic2EastNotInverted;
376  return kStOK;
377  } else {
378  LOG_ERROR << " No data in table class St_ftpcAsicMap" << endm;
379  return kStERR;
380  }
381 }
382 
383 //----------------------------------------------------------------------------
384 
385 Int_t StFtpcDbReader::FtpcEField(St_ftpcEField *efield)
386 {
387 
388  // just copy EField table start to pointer
389  ftpcEField_st* efieldTable = (ftpcEField_st*)efield->GetTable();
390  if(efieldTable){
391  mMagboltzEField = (Float_t *)efieldTable->e;
392  return kStOK;
393  } else {
394  LOG_ERROR << " No data in table class St_ftpcEField" << endm;
395  return kStERR;
396  }
397 }
398 
399 //----------------------------------------------------------------------------
400 Int_t StFtpcDbReader::FtpcVDrift(St_ftpcVDrift *vdrift)
401 {
402 
403  // just copy VDrift table start to pointer
404  ftpcVDrift_st* vdriftTable = (ftpcVDrift_st*)vdrift->GetTable();
405  if(vdriftTable){
406  mMagboltzVDrift = (Float_t *)vdriftTable->v;
407  return kStOK;
408  } else {
409  LOG_ERROR << " No data in table class St_ftpcVDrift" << endm;
410  return kStERR;
411  }
412 }
413 //----------------------------------------------------------------------------
414 Int_t StFtpcDbReader::FtpcDeflection(St_ftpcDeflection *deflection)
415 {
416 
417  // just copy Deflection table start to pointer
418  ftpcDeflection_st* deflectionTable = (ftpcDeflection_st*)deflection->GetTable();
419  if(deflectionTable){
420  mMagboltzDeflection = (Float_t *)deflectionTable->psi;
421  return kStOK;
422  } else {
423  LOG_ERROR << " No data in table class St_ftpcDeflection" << endm;
424  return kStERR;
425  }
426 }
427 
428 //----------------------------------------------------------------------------
429 Int_t StFtpcDbReader::FtpcdVDriftdP(St_ftpcdVDriftdP *dvdriftdp)
430 {
431 
432  // just copy dVDriftdP table start to pointer
433  ftpcdVDriftdP_st* dvriftdpTable = (ftpcdVDriftdP_st*)dvdriftdp->GetTable();
434  if(dvriftdpTable){
435  mMagboltzdVDriftdP = (Float_t *)dvriftdpTable->dv_dp;
436  return kStOK;
437  } else {
438  LOG_ERROR << " No data in table class St_ftpcdVDriftdP" << endm;
439  return kStERR;
440  }
441 }
442 
443 //----------------------------------------------------------------------------
444 Int_t StFtpcDbReader::FtpcdDeflectiondP(St_ftpcdDeflectiondP *ddeflectiondp)
445 {
446 
447  // just copy dDeflectiondP table start to pointer
448  ftpcdDeflectiondP_st* ddeflectiondpTable = (ftpcdDeflectiondP_st*)ddeflectiondp->GetTable();
449  if(ddeflectiondpTable){
450  mMagboltzdDeflectiondP = (Float_t *)ddeflectiondpTable->dpsi_dp;
451  return kStOK;
452  } else {
453  LOG_ERROR << " No data in table class St_ftpcdDeflectiondP" << endm;
454  return kStERR;
455  }
456 }
457 
458 //----------------------------------------------------------------------------
459 Int_t StFtpcDbReader::FtpcAmpSlope(St_ftpcAmpSlope *ampslope)
460 {
461 
462  // just copy AmpSlope table start to pointer
463  ampslopeTable = (ftpcAmpSlope_st*)ampslope->GetTable();
464  if(!ampslopeTable){
465  LOG_ERROR << " No data in table class St_ftpcAmpSlope" << endm;
466  return kStERR;
467  }
468  return kStOK;
469 }
470 
471 //----------------------------------------------------------------------------
472 Int_t StFtpcDbReader::FtpcAmpOffset(St_ftpcAmpOffset *ampoffset)
473 {
474 
475  // just copy AmpOffset table start to pointer
476  ampoffsetTable = (ftpcAmpOffset_st*)ampoffset->GetTable();
477  if(!ampoffsetTable){
478  LOG_ERROR << " No data in table class St_ftpcAmpOffset" << endm;
479  return kStERR;
480  }
481  return kStOK;
482 }
483 
484 //----------------------------------------------------------------------------
485 Int_t StFtpcDbReader::FtpcTimeOffset(St_ftpcTimeOffset *timeoffset)
486 {
487 
488  // just copy TimeOffset table start to pointer
489  timeoffsetTable = (ftpcTimeOffset_st*)timeoffset->GetTable();
490  if(!timeoffsetTable){
491  LOG_ERROR << " No data in table class St_ftpcTimeOffset" << endm;
492  return kStERR;
493  }
494  return kStOK;
495 }
496 
497 //----------------------------------------------------------------------------
498 Int_t StFtpcDbReader::FtpcDriftField(St_ftpcDriftField *driftfield)
499 {
500  // just copy driftfield table start to pointer
501  ftpcDriftField_st* driftfieldTable = (ftpcDriftField_st*)driftfield->GetTable();
502  if(driftfieldTable){
503  mNumberOfMagboltzBins = driftfieldTable->numberOfEFieldBinsUsed;
504  mMaximumNumberOfMagboltzBins = driftfieldTable->maximumNumberOfEFieldBins;
505  mDriftCathodeVoltage = driftfieldTable->driftCathodeVoltage;
506  mMinimumDriftField = driftfieldTable->minimumDriftField;
507  mStepSizeDriftField = driftfieldTable->stepSizeDriftField;
508  mRadiusTimesField = driftfieldTable->radiusTimesField;
509  return kStOK;
510  } else {
511  LOG_ERROR << " No data in table class St_ftpcDriftField" << endm;
512  return kStERR;
513  }
514 }
515 
516 //----------------------------------------------------------------------------
517 Int_t StFtpcDbReader::FtpcGas(St_ftpcGas *gas)
518 {
519  // just copy gas table start to pointer
520  gasTable = (ftpcGas_st*)gas->GetTable();
521  if(gasTable){
522  mPercentAr = gasTable->percentAr;
523  mPercentCO2 = gasTable->percentCO2;
524  mPercentNe = gasTable->percentNe;
525  mPercentHe = gasTable->percentHe;
526  mGasGain = gasTable->gasGain;
527  mGasAttenuation = gasTable->gasAttenuation;
528  mGasIonizationPotential = gasTable->gasIonizationPotential;
529  mBaseTemperature = gasTable->baseTemperature;
530  mBasePressure = gasTable->basePressure;
531  mPressureOffset = gasTable->pressureOffset;
532  mTemperatureDifference = gasTable->temperatureDifference;
533  mDefaultTemperatureWest = gasTable->defaultTemperatureWest;
534  mDefaultTemperatureEast = gasTable->defaultTemperatureEast;
535  mMinPressure = gasTable->minPressure;
536  mMaxPressure = gasTable->maxPressure;
537  mMinGasTemperature = gasTable->minGasTemperature;
538  mMaxGasTemperature = gasTable->maxGasTemperature;
539  mAdjustAverageWest = gasTable->adjustAverageWest;
540  mAdjustAverageEast = gasTable->adjustAverageEast;
541  return kStOK;
542  } else {
543  LOG_ERROR << " No data in table class St_ftpcGas" << endm;
544  return kStERR;
545  }
546 }
547 
548 //----------------------------------------------------------------------------
549 Int_t StFtpcDbReader::FtpcElectronics(St_ftpcElectronics *electronics)
550 {
551  // just copy electronics table start to pointer
552  electronicsTable = (ftpcElectronics_st*)electronics->GetTable();
553  if(electronicsTable){
554  mTZero = electronicsTable->tZero;
555  mLaserTZero = electronicsTable->laserTZero;
556  if (electronicsTable->uSecondsPerTimebin != 0 )
557  mMicrosecondsPerTimebin = electronicsTable->uSecondsPerTimebin;
558  mSwapRDO6RDO7East = electronicsTable->swapRDO6RDO7East;
559  return kStOK;
560  } else {
561  LOG_ERROR << " No data in table class St_ftpcElectronics" << endm;
562  return kStERR;
563  }
564 }
565 
566 //----------------------------------------------------------------------------
567 Int_t StFtpcDbReader::FtpcInnerCathode(St_ftpcInnerCathode *cathode)
568 {
569  // just copy inner cathode table start to pointer
570  ftpcInnerCathode_st* cathodeTable = (ftpcInnerCathode_st*)cathode->GetTable();
571  if(cathodeTable){
572  mOffsetCathodeWest = cathodeTable->offsetCathodeWest;
573  mOffsetCathodeEast = cathodeTable->offsetCathodeEast;
574  mAngleOffsetWest = cathodeTable->angleOffsetWest;
575  mAngleOffsetEast = cathodeTable->angleOffsetEast;
576  return kStOK;
577  } else {
578  LOG_ERROR << " No data in table class St_ftpcInnerCathode"<< endm;
579  return kStERR;
580  }
581 }
582 
583 //----------------------------------------------------------------------------
584 Int_t StFtpcDbReader::FtpcClusterGeom(St_ftpcClusterGeom *clustergeo)
585 {
586 
587  // just copy cluster geometry table start to pointer
588  ftpcClusterGeom_st* clustergeoTable = (ftpcClusterGeom_st*)clustergeo->GetTable();
589  if(clustergeoTable){
590  mMinTimeBin = clustergeoTable->minTimebin;
591  mMinTimeBinMed = clustergeoTable->minTimebinMed;
592  mMinTimeBinOut = clustergeoTable->minTimebinOut;
593  mMaxTimeLength = clustergeoTable->maxTimelength;
594  mMaxTimeLengthMed = clustergeoTable->maxTimelengthMed;
595  mMaxTimeLengthOut = clustergeoTable->maxTimelengthOut;
596  mMaxPadLength = clustergeoTable->maxPadlength;
597  mMaxPadLengthMed = clustergeoTable->maxPadlengthMed;
598  mMaxPadLengthOut = clustergeoTable->maxPadlengthOut;
599  mDeltaTime = clustergeoTable->deltaTime;
600  mDeltaPad = clustergeoTable->deltaPad;
601  mMinChargeWindow = clustergeoTable->minChargeWindow;
602  return kStOK;
603  } else {
604  LOG_ERROR << " No data in table class St_ftpcClusterGeom" << endm;
605  return kStERR;
606  }
607 }
608 //===============================================================
609 
610 Float_t StFtpcDbReader::padrowZPosition(Int_t i)
611 {
612  if(i>=0 && i<numberOfPadrows())
613  {
614  return mPadrowZPosition[i];
615  }
616  else
617  {
618  LOG_WARN << "StFtpcDbReader: padrowZPosition index out of range, using 0" << endm;
619  return mPadrowZPosition[0];
620  }
621 }
622 
623 
624 Float_t StFtpcDbReader::magboltzEField(Int_t i)
625 {
626  if(i>=0 && i<mNumberOfMagboltzBins)
627  {
628  return mMagboltzEField[i];
629  }
630  else
631  {
632  LOG_WARN << "StFtpcDbReader: magboltzEField index out of range, using 0" << endm;
633  return mMagboltzEField[0];
634  }
635 }
636 
637 Float_t StFtpcDbReader::magboltzVDrift(Int_t i, Int_t padrow)
638 {
639  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
640  {
641  return mMagboltzVDrift[padrow+numberOfPadrowsPerSide()*i];
642  }
643  else
644  {
645  LOG_WARN << "StFtpcDbReader: magboltzVDrift index out of range, using 0" << endm;
646  return mMagboltzVDrift[0];
647  }
648 }
649 
650 Float_t StFtpcDbReader::magboltzDeflection(Int_t i, Int_t padrow)
651 {
652  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
653  {
654  return mMagboltzDeflection[padrow+numberOfPadrowsPerSide()*i];
655  }
656  else
657  {
658  LOG_WARN << "StFtpcDbReader: magboltzDeflection index out of range, using 0" << endm;
659  return mMagboltzDeflection[0];
660  }
661 }
662 
663 Float_t StFtpcDbReader::magboltzdVDriftdP(Int_t i, Int_t padrow)
664 {
665  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
666  {
667  return mMagboltzdVDriftdP[padrow+numberOfPadrowsPerSide()*i];
668  }
669  else
670  {
671  LOG_WARN << "StFtpcDbReader: magboltzdVDriftdP index out of range, using 0" << endm;
672  return mMagboltzdVDriftdP[0];
673  }
674 }
675 
676 Float_t StFtpcDbReader::magboltzdDeflectiondP(Int_t i, Int_t padrow)
677 {
678  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
679  {
680  return mMagboltzdDeflectiondP[padrow+numberOfPadrowsPerSide()*i];
681  }
682  else
683  {
684  LOG_WARN << "StFtpcDbReader: magboltzdDeflectiondP index out of range, using 0" << endm;
685  return mMagboltzdDeflectiondP[0];
686  }
687 }
688 
689 Float_t StFtpcDbReader::amplitudeSlope(Int_t i, Int_t padrow)
690 {
691  // User "perfect" gain table for laser runs
692  if (mLaserRun) {
693  return 1.0;
694  }
695 
696  if(i>0 && i<=(numberOfSectors()*numberOfPads()) && padrow>=0 && padrow<numberOfPadrows())
697  {
698  // Since the gain tables were produced without inverting the sector
699  // numbering in FTPC East, we invert the sector numbering when accessing
700  // the gain table
701  if (padrow>=10) {
702  Int_t isec = (i-1)/numberOfPads();
703  Int_t ipad = i -isec*numberOfPads();
704  i = (5-isec)*numberOfPads()+ipad;
705 // mask out Ftpc East sectors 1,3 and 5
706 // This is necessary for calculating rotation offset values when one sector is turned off as it was
707 // for a large part of the 2007 run. Using 5 sectors may cause a bias due to lack of azimuthal symmetry)
708 // if ( isec==0 || isec==2 || isec==4 ) return 0;
709  }
710  return ampslopeTable[padrow].slope[i-1];
711  }
712  else
713  {
714  LOG_WARN << "StFtpcDbReader: amplitudeSlope index out of range, using 0" << endm;
715  return ampslopeTable[0].slope[0];
716  }
717 }
718 
719 Float_t StFtpcDbReader::amplitudeOffset(Int_t i, Int_t padrow)
720 {
721  if(i>0 && i<=(numberOfSectors()*numberOfPads()) && padrow>=0 && padrow<numberOfPadrows())
722  {
723  return ampoffsetTable[padrow].offset[i-1];
724  }
725  else
726  {
727  LOG_WARN << "StFtpcDbReader: amplitudeOffset index out of range, using 0" << endm;
728  return ampoffsetTable[0].offset[0];
729  }
730 }
731 
732 Float_t StFtpcDbReader::timeOffset(Int_t i, Int_t padrow)
733 {
734  if(i>0 && i<=(numberOfSectors()*numberOfPads()) && padrow>=0 && padrow<numberOfPadrows())
735  {
736  return timeoffsetTable[padrow].offset[i-1];
737  }
738  else
739  {
740  LOG_WARN << "StFtpcDbReader: timeOffset index out of range, using 0" << endm;
741  return timeoffsetTable[0].offset[0];
742  }
743 }
744 
745 
746 Int_t StFtpcDbReader::setMagboltzEField(Int_t i, Float_t newvalue)
747 {
748  if(i>=0 && i<mNumberOfMagboltzBins)
749  {
750  mMagboltzEField[i]=newvalue;
751  return 1;
752  }
753  else
754  {
755  LOG_WARN << "StFtpcDbReader: magboltzEField index out of range, not changed" << endm;
756  return 0;
757  }
758 }
759 
760 Int_t StFtpcDbReader::setMagboltzVDrift(Int_t i, Int_t padrow, Float_t newvalue)
761 {
762  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
763  {
764  mMagboltzVDrift[padrow+numberOfPadrowsPerSide()*i]=newvalue;
765  return 1;
766  }
767  else
768  {
769  LOG_WARN << "StFtpcDbReader: magboltzVDrift index out of range, not changed" << endm;
770  return 0;
771  }
772 }
773 
774 Int_t StFtpcDbReader::setMagboltzDeflection(Int_t i, Int_t padrow, Float_t newvalue)
775 {
776  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
777  {
778  mMagboltzDeflection[padrow+numberOfPadrowsPerSide()*i]=newvalue;
779  return 1;
780  }
781  else
782  {
783  LOG_WARN << "StFtpcDbReader: magboltzDeflection index out of range, not changed" << endm;
784  return 0;
785  }
786 }
787 
788 Int_t StFtpcDbReader::setMagboltzdVDriftdP(Int_t i, Int_t padrow, Float_t newvalue)
789 {
790  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
791  {
792  mMagboltzdVDriftdP[padrow+numberOfPadrowsPerSide()*i]=newvalue;
793  return 1;
794  }
795  else
796  {
797  LOG_WARN << "StFtpcDbReader: magboltzdVDriftdP index out of range, not changed" << endm;
798  return 0;
799  }
800 }
801 
802 Int_t StFtpcDbReader::setMagboltzdDeflectiondP(Int_t i, Int_t padrow, Float_t newvalue)
803 {
804  if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
805  {
806  mMagboltzdDeflectiondP[padrow+numberOfPadrowsPerSide()*i]=newvalue;
807  return 1;
808  }
809  else
810  {
811  LOG_WARN << "StFtpcDbReader: magboltzdDeflectiondP index out of range, not changed" << endm;
812  return 0;
813  }
814 }
815 
816 Int_t StFtpcDbReader::setMicrosecondsPerTimebin(Float_t newvalue)
817 {
818  mMicrosecondsPerTimebin = newvalue;
819  // write the new value for mMicrosecondsPerTimebin back into electronicsTable
820  electronicsTable->uSecondsPerTimebin = mMicrosecondsPerTimebin;
821 
822  return 0;
823 }
824 
825 Bool_t StFtpcDbReader::setLaserRun(Bool_t laserRun)
826 {
827  mLaserRun = laserRun;
828  if (mLaserRun) {
829  mAdjustAverageWest = 0.0;
830  mAdjustAverageEast = 0.0;
831  // set adjustAverageWest/East = 0.0 in gasTable
832  gasTable->adjustAverageWest = 0.0;
833  gasTable->adjustAverageEast = 0.0;
834  LOG_INFO << "LASER RUN: Using 'perfect' gain table and adjustAverageWest = adjustAverageEast = 0.0"<< endm;
835  mTZero = mLaserTZero;
836  // set mTZero = mLaserTzero in electronicsTable
837  electronicsTable->tZero = mLaserTZero;
838  LOG_INFO << " mTZero = mLaserTZero = "<<mTZero<<endm;
839  }
840  return 0;
841 }
Definition: Stypes.h:40
Definition: Stypes.h:45