159 #include "StFtpcDbReader.hh"
160 #include "StMessMgr.h"
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,
176 St_ftpcElectronics *electronics,
177 St_ftpcInnerCathode *cathode,
178 St_ftpcClusterGeom *clustergeo)
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);
199 mLaserRun = (Bool_t)kFALSE;
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,
213 St_ftpcDriftField *driftfield,
214 St_ftpcElectronics *electronics,
215 St_ftpcAmpSlope *ampslope,
216 St_ftpcAmpOffset *ampoffset,
217 St_ftpcTimeOffset *timeoffset,
218 St_ftpcInnerCathode *cathode)
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);
237 mLaserRun = (Bool_t)kFALSE;
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,
250 St_ftpcDriftField *driftfield)
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);
264 mLaserRun = (Bool_t)kFALSE;
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,
278 St_ftpcDriftField *driftfield)
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);
293 mLaserRun = (Bool_t)kFALSE;
298 StFtpcDbReader::StFtpcDbReader(St_ftpcDimensions *dimensions,
299 St_ftpcPadrowZ *zrow )
303 returnCode += FtpcDimensions(dimensions);
304 returnCode += FtpcPadrowZ(zrow);
306 mLaserRun = (Bool_t)kFALSE;
311 StFtpcDbReader::~StFtpcDbReader()
318 Int_t StFtpcDbReader::FtpcDimensions(St_ftpcDimensions *dimensions)
323 ftpcDimensions_st* dimensionsTable = (ftpcDimensions_st*)dimensions->GetTable();
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;
345 LOG_ERROR <<
" No data in table class St_ftpcDimensions" << endm;
352 Int_t StFtpcDbReader::FtpcPadrowZ(St_ftpcPadrowZ *zrow)
356 ftpcPadrowZ_st* padrowzTable = (ftpcPadrowZ_st*)zrow->GetTable();
358 mPadrowZPosition = (Float_t *)padrowzTable->z;
361 LOG_ERROR <<
" No data in table class St_ftpcPadrowZ" << endm;
368 Int_t StFtpcDbReader::FtpcAsicMap(St_ftpcAsicMap *asicmap)
372 ftpcAsicMap_st* asicmapTable = (ftpcAsicMap_st*)asicmap->GetTable();
374 mEastIsInverted = asicmapTable->EastIsInverted;
375 mAsic2EastNotInverted = asicmapTable->Asic2EastNotInverted;
378 LOG_ERROR <<
" No data in table class St_ftpcAsicMap" << endm;
385 Int_t StFtpcDbReader::FtpcEField(St_ftpcEField *efield)
389 ftpcEField_st* efieldTable = (ftpcEField_st*)efield->GetTable();
391 mMagboltzEField = (Float_t *)efieldTable->e;
394 LOG_ERROR <<
" No data in table class St_ftpcEField" << endm;
400 Int_t StFtpcDbReader::FtpcVDrift(St_ftpcVDrift *vdrift)
404 ftpcVDrift_st* vdriftTable = (ftpcVDrift_st*)vdrift->GetTable();
406 mMagboltzVDrift = (Float_t *)vdriftTable->v;
409 LOG_ERROR <<
" No data in table class St_ftpcVDrift" << endm;
414 Int_t StFtpcDbReader::FtpcDeflection(St_ftpcDeflection *deflection)
418 ftpcDeflection_st* deflectionTable = (ftpcDeflection_st*)deflection->GetTable();
420 mMagboltzDeflection = (Float_t *)deflectionTable->psi;
423 LOG_ERROR <<
" No data in table class St_ftpcDeflection" << endm;
429 Int_t StFtpcDbReader::FtpcdVDriftdP(St_ftpcdVDriftdP *dvdriftdp)
433 ftpcdVDriftdP_st* dvriftdpTable = (ftpcdVDriftdP_st*)dvdriftdp->GetTable();
435 mMagboltzdVDriftdP = (Float_t *)dvriftdpTable->dv_dp;
438 LOG_ERROR <<
" No data in table class St_ftpcdVDriftdP" << endm;
444 Int_t StFtpcDbReader::FtpcdDeflectiondP(St_ftpcdDeflectiondP *ddeflectiondp)
448 ftpcdDeflectiondP_st* ddeflectiondpTable = (ftpcdDeflectiondP_st*)ddeflectiondp->GetTable();
449 if(ddeflectiondpTable){
450 mMagboltzdDeflectiondP = (Float_t *)ddeflectiondpTable->dpsi_dp;
453 LOG_ERROR <<
" No data in table class St_ftpcdDeflectiondP" << endm;
459 Int_t StFtpcDbReader::FtpcAmpSlope(St_ftpcAmpSlope *ampslope)
463 ampslopeTable = (ftpcAmpSlope_st*)ampslope->GetTable();
465 LOG_ERROR <<
" No data in table class St_ftpcAmpSlope" << endm;
472 Int_t StFtpcDbReader::FtpcAmpOffset(St_ftpcAmpOffset *ampoffset)
476 ampoffsetTable = (ftpcAmpOffset_st*)ampoffset->GetTable();
478 LOG_ERROR <<
" No data in table class St_ftpcAmpOffset" << endm;
485 Int_t StFtpcDbReader::FtpcTimeOffset(St_ftpcTimeOffset *timeoffset)
489 timeoffsetTable = (ftpcTimeOffset_st*)timeoffset->GetTable();
490 if(!timeoffsetTable){
491 LOG_ERROR <<
" No data in table class St_ftpcTimeOffset" << endm;
498 Int_t StFtpcDbReader::FtpcDriftField(St_ftpcDriftField *driftfield)
501 ftpcDriftField_st* driftfieldTable = (ftpcDriftField_st*)driftfield->GetTable();
503 mNumberOfMagboltzBins = driftfieldTable->numberOfEFieldBinsUsed;
504 mMaximumNumberOfMagboltzBins = driftfieldTable->maximumNumberOfEFieldBins;
505 mDriftCathodeVoltage = driftfieldTable->driftCathodeVoltage;
506 mMinimumDriftField = driftfieldTable->minimumDriftField;
507 mStepSizeDriftField = driftfieldTable->stepSizeDriftField;
508 mRadiusTimesField = driftfieldTable->radiusTimesField;
511 LOG_ERROR <<
" No data in table class St_ftpcDriftField" << endm;
517 Int_t StFtpcDbReader::FtpcGas(St_ftpcGas *gas)
520 gasTable = (ftpcGas_st*)gas->GetTable();
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;
543 LOG_ERROR <<
" No data in table class St_ftpcGas" << endm;
549 Int_t StFtpcDbReader::FtpcElectronics(St_ftpcElectronics *electronics)
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;
561 LOG_ERROR <<
" No data in table class St_ftpcElectronics" << endm;
567 Int_t StFtpcDbReader::FtpcInnerCathode(St_ftpcInnerCathode *cathode)
570 ftpcInnerCathode_st* cathodeTable = (ftpcInnerCathode_st*)cathode->GetTable();
572 mOffsetCathodeWest = cathodeTable->offsetCathodeWest;
573 mOffsetCathodeEast = cathodeTable->offsetCathodeEast;
574 mAngleOffsetWest = cathodeTable->angleOffsetWest;
575 mAngleOffsetEast = cathodeTable->angleOffsetEast;
578 LOG_ERROR <<
" No data in table class St_ftpcInnerCathode"<< endm;
584 Int_t StFtpcDbReader::FtpcClusterGeom(St_ftpcClusterGeom *clustergeo)
588 ftpcClusterGeom_st* clustergeoTable = (ftpcClusterGeom_st*)clustergeo->GetTable();
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;
604 LOG_ERROR <<
" No data in table class St_ftpcClusterGeom" << endm;
610 Float_t StFtpcDbReader::padrowZPosition(Int_t i)
612 if(i>=0 && i<numberOfPadrows())
614 return mPadrowZPosition[i];
618 LOG_WARN <<
"StFtpcDbReader: padrowZPosition index out of range, using 0" << endm;
619 return mPadrowZPosition[0];
624 Float_t StFtpcDbReader::magboltzEField(Int_t i)
626 if(i>=0 && i<mNumberOfMagboltzBins)
628 return mMagboltzEField[i];
632 LOG_WARN <<
"StFtpcDbReader: magboltzEField index out of range, using 0" << endm;
633 return mMagboltzEField[0];
637 Float_t StFtpcDbReader::magboltzVDrift(Int_t i, Int_t padrow)
639 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
641 return mMagboltzVDrift[padrow+numberOfPadrowsPerSide()*i];
645 LOG_WARN <<
"StFtpcDbReader: magboltzVDrift index out of range, using 0" << endm;
646 return mMagboltzVDrift[0];
650 Float_t StFtpcDbReader::magboltzDeflection(Int_t i, Int_t padrow)
652 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
654 return mMagboltzDeflection[padrow+numberOfPadrowsPerSide()*i];
658 LOG_WARN <<
"StFtpcDbReader: magboltzDeflection index out of range, using 0" << endm;
659 return mMagboltzDeflection[0];
663 Float_t StFtpcDbReader::magboltzdVDriftdP(Int_t i, Int_t padrow)
665 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
667 return mMagboltzdVDriftdP[padrow+numberOfPadrowsPerSide()*i];
671 LOG_WARN <<
"StFtpcDbReader: magboltzdVDriftdP index out of range, using 0" << endm;
672 return mMagboltzdVDriftdP[0];
676 Float_t StFtpcDbReader::magboltzdDeflectiondP(Int_t i, Int_t padrow)
678 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
680 return mMagboltzdDeflectiondP[padrow+numberOfPadrowsPerSide()*i];
684 LOG_WARN <<
"StFtpcDbReader: magboltzdDeflectiondP index out of range, using 0" << endm;
685 return mMagboltzdDeflectiondP[0];
689 Float_t StFtpcDbReader::amplitudeSlope(Int_t i, Int_t padrow)
696 if(i>0 && i<=(numberOfSectors()*numberOfPads()) && padrow>=0 && padrow<numberOfPadrows())
702 Int_t isec = (i-1)/numberOfPads();
703 Int_t ipad = i -isec*numberOfPads();
704 i = (5-isec)*numberOfPads()+ipad;
710 return ampslopeTable[padrow].slope[i-1];
714 LOG_WARN <<
"StFtpcDbReader: amplitudeSlope index out of range, using 0" << endm;
715 return ampslopeTable[0].slope[0];
719 Float_t StFtpcDbReader::amplitudeOffset(Int_t i, Int_t padrow)
721 if(i>0 && i<=(numberOfSectors()*numberOfPads()) && padrow>=0 && padrow<numberOfPadrows())
723 return ampoffsetTable[padrow].offset[i-1];
727 LOG_WARN <<
"StFtpcDbReader: amplitudeOffset index out of range, using 0" << endm;
728 return ampoffsetTable[0].offset[0];
732 Float_t StFtpcDbReader::timeOffset(Int_t i, Int_t padrow)
734 if(i>0 && i<=(numberOfSectors()*numberOfPads()) && padrow>=0 && padrow<numberOfPadrows())
736 return timeoffsetTable[padrow].offset[i-1];
740 LOG_WARN <<
"StFtpcDbReader: timeOffset index out of range, using 0" << endm;
741 return timeoffsetTable[0].offset[0];
746 Int_t StFtpcDbReader::setMagboltzEField(Int_t i, Float_t newvalue)
748 if(i>=0 && i<mNumberOfMagboltzBins)
750 mMagboltzEField[i]=newvalue;
755 LOG_WARN <<
"StFtpcDbReader: magboltzEField index out of range, not changed" << endm;
760 Int_t StFtpcDbReader::setMagboltzVDrift(Int_t i, Int_t padrow, Float_t newvalue)
762 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
764 mMagboltzVDrift[padrow+numberOfPadrowsPerSide()*i]=newvalue;
769 LOG_WARN <<
"StFtpcDbReader: magboltzVDrift index out of range, not changed" << endm;
774 Int_t StFtpcDbReader::setMagboltzDeflection(Int_t i, Int_t padrow, Float_t newvalue)
776 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
778 mMagboltzDeflection[padrow+numberOfPadrowsPerSide()*i]=newvalue;
783 LOG_WARN <<
"StFtpcDbReader: magboltzDeflection index out of range, not changed" << endm;
788 Int_t StFtpcDbReader::setMagboltzdVDriftdP(Int_t i, Int_t padrow, Float_t newvalue)
790 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
792 mMagboltzdVDriftdP[padrow+numberOfPadrowsPerSide()*i]=newvalue;
797 LOG_WARN <<
"StFtpcDbReader: magboltzdVDriftdP index out of range, not changed" << endm;
802 Int_t StFtpcDbReader::setMagboltzdDeflectiondP(Int_t i, Int_t padrow, Float_t newvalue)
804 if(i>=0 && i<mNumberOfMagboltzBins && padrow>=0 && padrow<numberOfPadrowsPerSide())
806 mMagboltzdDeflectiondP[padrow+numberOfPadrowsPerSide()*i]=newvalue;
811 LOG_WARN <<
"StFtpcDbReader: magboltzdDeflectiondP index out of range, not changed" << endm;
816 Int_t StFtpcDbReader::setMicrosecondsPerTimebin(Float_t newvalue)
818 mMicrosecondsPerTimebin = newvalue;
820 electronicsTable->uSecondsPerTimebin = mMicrosecondsPerTimebin;
825 Bool_t StFtpcDbReader::setLaserRun(Bool_t laserRun)
827 mLaserRun = laserRun;
829 mAdjustAverageWest = 0.0;
830 mAdjustAverageEast = 0.0;
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;
837 electronicsTable->tZero = mLaserTZero;
838 LOG_INFO <<
" mTZero = mLaserTZero = "<<mTZero<<endm;