diff --git a/StRoot/StDetectorDbMaker/StDetectorDbChairs.cxx b/StRoot/StDetectorDbMaker/StDetectorDbChairs.cxx index c2edc1e7067..13379580420 100644 --- a/StRoot/StDetectorDbMaker/StDetectorDbChairs.cxx +++ b/StRoot/StDetectorDbMaker/StDetectorDbChairs.cxx @@ -1363,7 +1363,7 @@ St_tpcRDOMasksC *St_tpcRDOMasksC::instance() { } if (needReorder) { LOG_WARN << "St_tpcRDOMasksC::instance RunLog/onl/tpcRDOMasks has to be reordered" << endm; - tpcRDOMasks_st rows[12]; + tpcRDOMasks_st rows[12] = {0}; Int_t OldRun = -1; for (UInt_t i = 0; i < N; i++) { if ((row+i)->sector == 2*i + 1) { @@ -1404,6 +1404,10 @@ St_tpcRDOMasksC *St_tpcRDOMasksC::instance() { table->Print(0,12); } fgInstance = new St_tpcRDOMasksC(table); + if (StDetectorDbMaker::instance()) { + fgInstance->SetName("tpcRDOMasksC"); + StDetectorDbMaker::instance()->AddConst(fgInstance); + } return fgInstance; } //________________________________________________________________________________ @@ -1500,6 +1504,10 @@ St_tpcPadGainT0C *St_tpcPadGainT0C::instance() { assert(table); } fgInstance = new St_tpcPadGainT0C(table); + if (StDetectorDbMaker::instance()) { + fgInstance->SetName("tpcPadGainT0C"); + StDetectorDbMaker::instance()->AddConst(fgInstance); + } // Apply additional correction for gain tables Int_t run = StMaker::GetChain()->GetRunNumber(); St_tpcExtraGainCorrectionC *extra = St_tpcExtraGainCorrectionC::instance(); @@ -1817,6 +1825,10 @@ St_itpcPadGainT0C *St_itpcPadGainT0C::instance() { assert(table); } fgInstance = new St_itpcPadGainT0C(table); + if (StDetectorDbMaker::instance()) { + fgInstance->SetName("itpcPadGainT0C"); + StDetectorDbMaker::instance()->AddConst(fgInstance); + } // Apply additional correction for gain tables Int_t run = StMaker::GetChain()->GetRunNumber(); St_tpcExtraGainCorrectionC *extra = St_tpcExtraGainCorrectionC::instance(); @@ -2999,7 +3011,51 @@ MakeChairInstance(tofTrgWindow,Calibrations/tof/tofTrgWindow); #include "St_tofTzeroC.h" MakeChairInstance(tofTzero,Calibrations/tof/tofTzero); #include "St_tofSimResParamsC.h" -MakeChairInstance(tofSimResParams,Calibrations/tof/tofSimResParams); +//MakeChairInstance(tofSimResParams,Calibrations/tof/tofSimResParams); +St_tofSimResParamsC *St_tofSimResParamsC::fgInstance = 0; +Double_t St_tofSimResParamsC::params[120][192] = {0}; +Double_t St_tofSimResParamsC::mAverageTimeResTof = 0; + +St_tofSimResParamsC *St_tofSimResParamsC::instance() { + if (fgInstance) return fgInstance; + St_tofSimResParams *table = (St_tofSimResParams *) StMaker::GetChain()->GetDataBase("Calibrations/tof/tofSimResParams"); + if (! table) { + LOG_WARN << "St_tofSimResParamsC::instance Calibrations/tof/tofSimResParams was not found" << endm; + assert(table); + } + DEBUGTABLE(tofSimResParams); + fgInstance = new St_tofSimResParamsC(table); + mAverageTimeResTof=0; + for ( int i = 0; i < 120; i++ ){ // nTrays + for ( int j = 0; j < 192; j++ ){ + size_t index = i * 120 + j; + params[i][j] = St_tofSimResParamsC::instance()->resolution()[index]; + mAverageTimeResTof+=params[i][j]; + LOG_DEBUG << "tray:" << i << ", mod cell:" << j << " = " << St_tofSimResParamsC::instance()->resolution()[index] << " == " << params[i][j] << endm; + } + } + mAverageTimeResTof=mAverageTimeResTof/(120*192); + LOG_INFO << "Loaded tofSimResParams. Average = " << mAverageTimeResTof << endm; + + if (StDetectorDbMaker::instance()) { + fgInstance->SetName("tofSimResParamsC"); + StDetectorDbMaker::instance()->AddConst(fgInstance); + } + return fgInstance; +} +//________________________________________________________________________________ +Double_t St_tofSimResParamsC::timeres_tof(UInt_t itray, UInt_t imodule, UInt_t icell) { + /* + * Calculates the average resolution across all 38 tubes (discounts inactive tubes) + * then returns a single vertex resolution (in ps) for use in embedding w/ vpdStart + */ + Double_t result = 8.5e-11; + if ( itray > 120 || imodule > 32 || icell > 6 ) + return result; + + return params[ itray ][ imodule * 6 + icell ]; + +} #include "St_vpdDelayC.h" MakeChairInstance(vpdDelay,Calibrations/tof/vpdDelay); #include "St_vpdTotCorrC.h" diff --git a/StRoot/StDetectorDbMaker/StDetectorDbMaker.cxx b/StRoot/StDetectorDbMaker/StDetectorDbMaker.cxx index ee32c760d09..e93b1c16d44 100755 --- a/StRoot/StDetectorDbMaker/StDetectorDbMaker.cxx +++ b/StRoot/StDetectorDbMaker/StDetectorDbMaker.cxx @@ -10,8 +10,15 @@ #endif St_trigDetSums* St_trigDetSumsC::fgTableCopy = 0; Int_t StDetectorDbMaker::_debug = 0; +StDetectorDbMaker *StDetectorDbMaker::fgStDetectorDbMaker = 0; ClassImp(StDetectorDbMaker) //_____________________________________________________________________________ +//_____________________________________________________________________________ +Int_t StDetectorDbMaker::InitRun (Int_t runumber) { + if (m_ConstSet) m_ConstSet->Delete(); // Clear Chair Instances + return 0; +} +//_____________________________________________________________________________ Int_t StDetectorDbMaker::Make(){ #if 0 /* Move to St_trigDetSumsC to unify reading daq and StEvent files */ // Also need to update instances for classes done in InitRun. diff --git a/StRoot/StDetectorDbMaker/StDetectorDbMaker.h b/StRoot/StDetectorDbMaker/StDetectorDbMaker.h index 29da085a816..bc7416741c5 100644 --- a/StRoot/StDetectorDbMaker/StDetectorDbMaker.h +++ b/StRoot/StDetectorDbMaker/StDetectorDbMaker.h @@ -7,13 +7,16 @@ class StDetectorDbMaker : public StMaker { public: - StDetectorDbMaker(const char *name="DetectorDb") : StMaker(name) {} - virtual ~StDetectorDbMaker() {} + StDetectorDbMaker(const char *name="DetectorDb") : StMaker(name) {fgStDetectorDbMaker = this; } + virtual ~StDetectorDbMaker() {fgStDetectorDbMaker = 0;} + virtual Int_t InitRun(Int_t runumber); virtual Int_t Make(); + static StDetectorDbMaker *instance() {return fgStDetectorDbMaker;} + private: static Int_t _debug; virtual const char *GetCVS() const {static const char cvs[]="Tag $Name: $ $Id: StDetectorDbMaker.h,v 1.5 2015/12/23 23:34:09 fisyak Exp $ built " __DATE__ " " __TIME__ ; return cvs;} - + static StDetectorDbMaker *fgStDetectorDbMaker; ClassDef(StDetectorDbMaker,0) //StAF chain virtual base class for Makers }; diff --git a/StRoot/StDetectorDbMaker/St_itpcPadGainT0C.h b/StRoot/StDetectorDbMaker/St_itpcPadGainT0C.h index 902f8a4c0a5..a759dedabee 100644 --- a/StRoot/StDetectorDbMaker/St_itpcPadGainT0C.h +++ b/StRoot/StDetectorDbMaker/St_itpcPadGainT0C.h @@ -3,7 +3,7 @@ #include "TChair.h" #include "tables/St_itpcPadGainT0_Table.h" - +class TBrowser; struct rowpadFEEmap_t {// FEE & RDO map for iTPC Int_t row, padMin, padMax, fee, rdo; }; @@ -26,6 +26,7 @@ class St_itpcPadGainT0C : public TChair { for (Int_t pad=1; pad<=120; pad++) if (Gain(sector,row,pad)>0) return kTRUE; return kFALSE; } + void Browse(TBrowser *b) {} static rowpadFEEmap_t rowpadFEE[]; static Int_t NCrowpadFEE; protected: diff --git a/StRoot/StDetectorDbMaker/St_tofSimResParamsC.h b/StRoot/StDetectorDbMaker/St_tofSimResParamsC.h index ebc5f9ceb5a..19312ba1160 100644 --- a/StRoot/StDetectorDbMaker/St_tofSimResParamsC.h +++ b/StRoot/StDetectorDbMaker/St_tofSimResParamsC.h @@ -3,6 +3,7 @@ #include "TChair.h" #include "tables/St_tofSimResParams_Table.h" +class TBrowser; class St_tofSimResParamsC : public TChair { public: @@ -11,7 +12,12 @@ class St_tofSimResParamsC : public TChair { UInt_t getNumRows() const {return GetNRows();} UShort_t * resolution(Int_t i = 0) const {return Struct(i)->resolution;} UChar_t* algoFlag(Int_t i = 0) const {return Struct(i)->algoFlag;} + static Double_t average_timeres_tof(){return mAverageTimeResTof;} + static Double_t timeres_tof(UInt_t itray, UInt_t imodule, UInt_t icell); + void Browse(TBrowser *b) {} protected: + static Double_t params[120][192]; + static Double_t mAverageTimeResTof; St_tofSimResParamsC(St_tofSimResParams *table=0) : TChair(table) {} virtual ~St_tofSimResParamsC() {fgInstance = 0;} private: diff --git a/StRoot/StDetectorDbMaker/St_tpcMaxHitsC.h b/StRoot/StDetectorDbMaker/St_tpcMaxHitsC.h index 16443fc96d5..1795affa638 100644 --- a/StRoot/StDetectorDbMaker/St_tpcMaxHitsC.h +++ b/StRoot/StDetectorDbMaker/St_tpcMaxHitsC.h @@ -2,12 +2,14 @@ #define St_tpcMaxHitsC_h #include "TChair.h" #include "tables/St_tpcMaxHits_Table.h" +class TBrowser; class St_tpcMaxHitsC : public TChair { public: static St_tpcMaxHitsC* instance(); tpcMaxHits_st *Struct(Int_t i = 0) {return ((St_tpcMaxHits*) Table())->GetTable()+i;} Int_t maxSectorHits() {return Struct()->maxSectorHits;} Int_t maxBinZeroHits() {return Struct()->maxBinZeroHits;} + void Browse(TBrowser *b) {} protected: St_tpcMaxHitsC(St_tpcMaxHits *table=0) : TChair(table) {} virtual ~St_tpcMaxHitsC() {fgInstance = 0;} diff --git a/StRoot/StDetectorDbMaker/St_tpcPadGainT0C.h b/StRoot/StDetectorDbMaker/St_tpcPadGainT0C.h index 8d692151502..71f4d2abc33 100644 --- a/StRoot/StDetectorDbMaker/St_tpcPadGainT0C.h +++ b/StRoot/StDetectorDbMaker/St_tpcPadGainT0C.h @@ -4,6 +4,7 @@ #include "TChair.h" #include "tables/St_tpcPadGainT0_Table.h" #include "St_tpcPadConfigC.h" +class TBrowser; class St_tpcPadGainT0C : public TChair { public: static St_tpcPadGainT0C* instance(); @@ -28,6 +29,7 @@ class St_tpcPadGainT0C : public TChair { for (Int_t pad=1; pad<=182; pad++) if (Gain(sector,row,pad)>0) return kTRUE; return kFALSE; } + void Browse(TBrowser *b) {} protected: St_tpcPadGainT0C(St_tpcPadGainT0 *table=0) : TChair(table) {} virtual ~St_tpcPadGainT0C() {fgInstance = 0;}