#include "THaHelicity.h"
#include "THaEvData.h"
#include "VarDef.h"
#include <iostream>
#include <cstring>
using namespace std;
THaHelicity::THaHelicity( const char* name, const char* description,
THaApparatus* app ) :
THaADCHelicity(name, description, app), fG0_Hel(kUnknown),
fGoodHel(false), fGoodHel2(false)
{
}
THaHelicity::THaHelicity()
{
}
THaHelicity::~THaHelicity()
{
DefineVariables( kDelete );
}
Int_t THaHelicity::DefineVariables( EMode mode )
{
if( mode == kDefine && fIsSetup ) return kOK;
THaADCHelicity::DefineVariables( mode );
const RVarDef var[] = {
{ "qrt", "QRT from ROC", "fQrt" },
{ "gate", "Helicity Gate from ROC", "fGate" },
{ "pread", "Present G0 reading", "fPresentReading" },
{ "timestamp", "Timestamp from ROC", "fTimestamp" },
{ "validtime", "Timestamp is valid", "fValidTime" },
{ "g0_hel", "G0 helicity reading", "fG0_Hel" },
{ "goodhel", "ADC and G0 helicities agree", "fGoodHel" },
{ "goodhel2", "ADC and G0 helicities agree unless one unknown",
"fGoodHel2" },
{ 0 }
};
return DefineVarsFromList( var, mode );
}
Int_t THaHelicity::ReadDatabase( const TDatime& date )
{
Int_t st = THaADCHelicity::ReadDatabase( date );
if( st != kOK )
return st;
st = THaG0HelicityReader::ReadDatabase( GetDBFileName(), GetPrefix(),
date, fG0Debug );
if( st != kOK )
return st;
FILE* file = OpenFile( date );
if( !file ) return kFileError;
DBRequest req[] = {
{ "verbose", &fDebug, kInt, 0, 1, -2 },
{ 0 }
};
st = LoadDB( file, date, req, GetPrefix() );
fclose(file);
if( st )
return kInitError;
return kOK;
}
void THaHelicity::Clear( Option_t* opt )
{
THaADCHelicity::Clear(opt);
THaG0HelicityReader::Clear(opt);
fG0_Hel = kUnknown;
fGoodHel2 = fGoodHel = false;
}
Int_t THaHelicity::Decode( const THaEvData& evdata )
{
Int_t st = THaADCHelicity::Decode( evdata );
if( st < 0 )
return st;
st = ReadData( evdata );
if( st < 0 )
return st;
if( fGate )
fG0_Hel = ( fPresentReading ) ? kPlus : kMinus;
fGoodHel = (fADC_Hel == fG0_Hel);
fGoodHel2 = (fGoodHel ||
(fADC_Hel == kUnknown && fG0_Hel != kUnknown) ||
(fG0_Hel == kUnknown && fADC_Hel != kUnknown) );
if( (!fGoodHel && fDebug >= 2) || (!fGoodHel2 && fDebug >= 1) ) {
Warning( Here("Decode"), "ADC and G0 helicities disagree: %d %d at "
"evno = %d", fADC_Hel, fG0_Hel, evdata.GetEvNum() );
}
return kOK;
}
ClassImp(THaHelicity)
Last change: Sat Nov 7 21:26:48 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.