#include "THaRunParameters.h"
#include "THaAnalysisObject.h"
#include "TDatime.h"
#include "TError.h"
#include "TMath.h"
#include "THaEvData.h"
#include <iostream>
using namespace std;
THaRunParameters::THaRunParameters() :
fBeamE(0), fBeamP(0), fBeamM(0), fBeamQ(0), fBeamdE(0), fBeamPol(0),
fTgtM(0), fTgtPol(0), fIsPol(kFALSE)
{
fPrescale.Set(THaEvData::MAX_PSFACT);
for( int i=0; i<fPrescale.GetSize(); i++)
fPrescale[i] = -1;
}
THaRunParameters::THaRunParameters( const THaRunParameters& rhs ) :
TObject(rhs),
fBeamName(rhs.fBeamName), fBeamE(rhs.fBeamE), fBeamP(rhs.fBeamP),
fBeamM(rhs.fBeamM), fBeamQ(rhs.fBeamQ), fBeamdE(rhs.fBeamdE),
fBeamPol(rhs.fBeamPol),
fTgtName(rhs.fTgtName), fTgtM(rhs.fTgtM), fTgtPol(rhs.fTgtPol),
fIsPol(rhs.fIsPol),
fRunName(rhs.fRunName), fPrescale(rhs.fPrescale)
{
}
THaRunParameters& THaRunParameters::operator=(const THaRunParameters& rhs)
{
if (this != &rhs) {
fBeamName = rhs.fBeamName;
fBeamE = rhs.fBeamE;
fBeamP = rhs.fBeamP;
fBeamM = rhs.fBeamM;
fBeamQ = rhs.fBeamQ;
fBeamdE = rhs.fBeamdE;
fBeamPol = rhs.fBeamPol;
fTgtName = rhs.fTgtName;
fTgtM = rhs.fTgtM;
fTgtPol = rhs.fTgtPol;
fIsPol = rhs.fIsPol;
fRunName = rhs.fRunName;
fPrescale = rhs.fPrescale;
}
return *this;
}
THaRunParameters::~THaRunParameters()
{
}
void THaRunParameters::Clear( Option_t* )
{
fBeamName = fTgtName = fRunName = "";
fBeamE = fBeamP = fBeamM = fBeamdE = fBeamPol = fTgtM = fTgtPol = 0;
fBeamQ = 0;
fIsPol = kFALSE;
fPrescale.Reset();
}
void THaRunParameters::Print( Option_t* ) const
{
cout << "Run parameters: " << fRunName << endl;
cout << " Beam: " << fBeamName <<endl;
cout << " Energy = " << fBeamE << " +/- " << fBeamdE << " GeV\n";
cout << " Momentum = " << fBeamP << " GeV/c\n";
cout << " Mass/Charge = " << fBeamM << "/" << fBeamQ << " GeV/c^2\n";
if( fIsPol ) {
cout << " Polarization= " << 100.*fBeamPol << "%\n";
}
cout << " Target: " << fTgtName << endl;
cout << " Mass: = " << fTgtM << " GeV/c^2\n";
if( fIsPol ) {
cout << " Polarization= " << 100.*fTgtPol << "%\n";
}
cout << " DAQ:\n";
Int_t np = fPrescale.GetSize();
if( np > 0 ){
cout << " Prescale factors: (1-"<<np<<")\n ";
for( int i=0; i<np; i++ ) {
#if ROOT_VERSION_CODE >= ROOT_VERSION(3,3,0)
cout << fPrescale[i];
#else
cout << const_cast<THaRunParameters*>(this)->fPrescale[i];
#endif
if( i != np-1 )
cout << "/";
}
cout << endl;
}
}
Int_t THaRunParameters::ReadDatabase( const TDatime& date )
{
#define OPEN THaAnalysisObject::OpenFile
#define READ THaAnalysisObject::LoadDBvalue
FILE* f = OPEN( "run", date, "THaRunParameters::ReadDatabase", "r", 1 );
if( !f )
return -1;
Int_t iq, st;
Double_t E, M = 0.511e-3, Q = -1.0, dE = 0.0;
if( (st = READ( f, date, "ebeam", E )) ) {
Error( "ReadDatabase", "Beam energy missing in run database. "
"Run parameter initialization failed." );
return st;
}
READ( f, date, "mbeam", M );
READ( f, date, "qbeam", Q );
READ( f, date, "dEbeam", dE );
iq = int(Q);
SetBeam( E, M, iq, dE );
fclose(f);
return 0;
}
void THaRunParameters::SetBeam( Double_t E, Double_t M, Int_t Q, Double_t dE )
{
fBeamE = E;
fBeamM = M;
fBeamQ = Q;
fBeamP = (E>M) ? TMath::Sqrt(E*E-M*M) : 0.0;
if( fBeamP == 0.0 )
Warning( "SetBeam()", "Beam momentum = 0 ??");
fBeamdE = dE;
}
void THaRunParameters::SetPolarizations( Double_t pb, Double_t pt )
{
fBeamPol = pb;
fTgtPol = pt;
fIsPol = (TMath::Abs(pb*pt) > 1e-8);
}
ClassImp(THaRunParameters)
Last change: Sat Nov 7 21:26:50 2009
Last generated: 2009-11-07 21:26
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.