diff --git a/src/THcScalerEvtHandler.cxx b/src/THcScalerEvtHandler.cxx index 8bc751cde138b94b7f302a2d5689bab3a83e8bde..f8c309f0d2d0d5a5944f65c49b9ded7a4dba3967 100644 --- a/src/THcScalerEvtHandler.cxx +++ b/src/THcScalerEvtHandler.cxx @@ -44,6 +44,9 @@ To enable debugging you may try this in the setup script #include "Scaler9250.h" #include "THaCodaData.h" #include "THaEvData.h" +#include "THcParmList.h" +#include "THcGlobals.h" +#include "THaGlobals.h" #include "TNamed.h" #include "TMath.h" #include "TString.h" @@ -97,6 +100,40 @@ Int_t THcScalerEvtHandler::End( THaRunBase* r) return 0; } + +Int_t THcScalerEvtHandler::ReadDatabase(const TDatime& date ) +{ + char prefix[2]; + prefix[0]='g'; + prefix[1]='\0'; + DBRequest list[]={ + {"NumBCMs",&fNumBCMs, kInt}, + {0} + }; + gHcParms->LoadParmValues((DBRequest*)&list, prefix); + cout << " NUmber of BCMs = " << fNumBCMs << endl; + // + fBCM_Gain = new Double_t[fNumBCMs]; + fBCM_Offset = new Double_t[fNumBCMs]; + string bcm_namelist; + DBRequest list2[]={ + {"BCM_Gain", fBCM_Gain, kDouble, (UInt_t) fNumBCMs}, + {"BCM_Offset", fBCM_Offset, kDouble,(UInt_t) fNumBCMs}, + {"BCM_Names", &bcm_namelist, kString}, + {0} + }; + gHcParms->LoadParmValues((DBRequest*)&list2, prefix); + vector<string> bcm_names = vsplit(bcm_namelist); + fBCM_Name = new char* [fNumBCMs]; + for(Int_t i=0;i<fNumBCMs;i++) { + fBCM_Name[i] = new char[bcm_names[i].length()+1]; + strcpy(fBCM_Name[i], bcm_names[i].c_str()); + cout << fBCM_Gain[i] << " " << fBCM_Offset[i] << " " << fBCM_Name[i] << endl; + } + // + // + return kOK; +} void THcScalerEvtHandler::SetDelayedType(int evtype) { /** * \brief Delay analysis of this event type to end. @@ -123,6 +160,7 @@ Int_t THcScalerEvtHandler::Analyze(THaEvData *evdata) if (lfirst && !fScalerTree) { + lfirst = 0; // Can't do this in Init for some reason TString sname1 = "TS"; @@ -318,6 +356,8 @@ Int_t THcScalerEvtHandler::AnalyzeBuffer(UInt_t* rdata) THaAnalysisObject::EStatus THcScalerEvtHandler::Init(const TDatime& date) { + // + ReadDatabase(date); const int LEN = 200; char cbuf[LEN]; diff --git a/src/THcScalerEvtHandler.h b/src/THcScalerEvtHandler.h index fa9ce3f6fcc3810cf5befc2c79f97fc976ce2659..6a56e78f587a2e87c5d0ce44a172228a3ae360d7 100644 --- a/src/THcScalerEvtHandler.h +++ b/src/THcScalerEvtHandler.h @@ -37,6 +37,7 @@ public: Int_t Analyze(THaEvData *evdata); Int_t AnalyzeBuffer(UInt_t *rdata); virtual EStatus Init( const TDatime& run_time); + virtual Int_t ReadDatabase(const TDatime& date ); virtual Int_t End( THaRunBase* r=0 ); virtual void SetUseFirstEvent(Bool_t b = kFALSE) {fUseFirstEvent = b;} virtual void SetDelayedType(int evtype); @@ -50,6 +51,10 @@ private: std::vector<Decoder::GenScaler*> scalers; std::vector<HCScalerLoc*> scalerloc; + Int_t fNumBCMs; + Double_t *fBCM_Gain; + Double_t *fBCM_Offset; + char** fBCM_Name; UInt_t evcount; Double_t evcountR; Int_t Nvars, ifound, fNormIdx, nscalers;