From a7f5da2eb383d81371486f34110a68c1fdc1b767 Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Thu, 15 Jun 2017 16:49:17 -0400 Subject: [PATCH] Add THcRunParms. Get beam energy without db_run.dat With this commit, db_run.dat is not needed in hcana If THcRunParms is used, hcana will get the beam momentum from the parameter "gpbeam" instead of db_run.dat. To use, use the THaRun::SetRunParamClass method to set the run parameter class to "THcRunParameters". THaRun* run = new THaRun(RunFileName); run->SetRunParamClass("THcRunParameters"); --- examples/db_run.dat | 7 ----- examples/hodtest.C | 3 ++ podd | 2 +- src/THcRunParameters.cxx | 61 ++++++++++++++++++++++++++++++++++++++++ src/THcRunParameters.h | 22 +++++++++++++++ 5 files changed, 87 insertions(+), 8 deletions(-) delete mode 100755 examples/db_run.dat create mode 100644 src/THcRunParameters.cxx create mode 100644 src/THcRunParameters.h diff --git a/examples/db_run.dat b/examples/db_run.dat deleted file mode 100755 index 6dd115d..0000000 --- a/examples/db_run.dat +++ /dev/null @@ -1,7 +0,0 @@ -# Test run database - -# DAQ04 ---------[ 2000-01-01 01:00:00 ] - -#A1 2202 pedestal -ebeam = 4.02187 diff --git a/examples/hodtest.C b/examples/hodtest.C index 1bc31d4..53932fd 100644 --- a/examples/hodtest.C +++ b/examples/hodtest.C @@ -86,7 +86,10 @@ // We just set up one, but this could be many. char RunFileName[100]; sprintf(RunFileName,RunFileNamePattern,RunNumber); + THaRun* run = new THaRun(RunFileName); + run->SetRunParamClass("THcRunParameters"); + // Perhaps we should make a THcRun that does this // Eventually need to learn to skip over, or properly analyze // the pedestal events diff --git a/podd b/podd index 30d5faa..8fd79c6 160000 --- a/podd +++ b/podd @@ -1 +1 @@ -Subproject commit 30d5faa30f82668188139378978f86661e5e31b2 +Subproject commit 8fd79c686375066a97b6e41c8b6bc7df55492a7d diff --git a/src/THcRunParameters.cxx b/src/THcRunParameters.cxx new file mode 100644 index 0000000..6f09dc7 --- /dev/null +++ b/src/THcRunParameters.cxx @@ -0,0 +1,61 @@ +/** \class THcRunParameters + \ingroup Base + +Get the run parameters from the Hall C style parameter database +so that db_run.dat is not needed in hcana. + +\author S. A. Wood 15-June-2017 + +*/ +#include "THcRunParameters.h" +#include "THaAnalysisObject.h" +#include "TMath.h" +#include "THcParmList.h" +#include "THcGlobals.h" +#include <iostream> +/*#include "TDatime.h" +#include "TError.h" +#include "TMath.h" +#include "THaEvData.h" +#include <iostream> +*/ + +using namespace std; + +//_____________________________________________________________________________ +THcRunParameters::THcRunParameters() : THaRunParameters() +{ + // Default constructor +} + +//_____________________________________________________________________________ +THcRunParameters::~THcRunParameters() +{ + // Destructor +} +Int_t THcRunParameters::ReadDatabase( const TDatime& date ) +{ + // Query the run database for the beam and target parameters + // The date/time is ignored as it is assumed that run number + // parameter lookup has already occured. + + // Return 0 if success, <0 if file error, >0 if not all required data found. + Double_t P, E, M = 0.511e-3, Q = -1.0, dE = 0.0; + + DBRequest request[] = { + { "gpbeam", &P }, + { "mbeam", &M, kDouble, 0, 1 }, + { "qbeam", &Q, kDouble, 0, 1 }, + { "dEbeam", &dE, kDouble, 0, 1 }, + { 0 } + }; + + gHcParms->LoadParmValues((DBRequest*)&request, ""); + + E = TMath::Sqrt(P*P+M*M); + Int_t iq = int(Q); + SetBeam( E, M, iq, dE ); + + return 0; + } + ClassImp(THcRunParameters) diff --git a/src/THcRunParameters.h b/src/THcRunParameters.h new file mode 100644 index 0000000..a9f1193 --- /dev/null +++ b/src/THcRunParameters.h @@ -0,0 +1,22 @@ +#ifndef ROOT_THcRunParameters +#define ROOT_THcRunParameters + +////////////////////////////////////////////////////////////////////////// +// +// THaRunParameters +// +////////////////////////////////////////////////////////////////////////// + +#include "THaRunParameters.h" + +class THcRunParameters : public THaRunParameters { +public: + THcRunParameters(); + virtual ~THcRunParameters(); + + virtual Int_t ReadDatabase( const TDatime& date); + + ClassDef(THcRunParameters,0) +}; + +#endif -- GitLab