#include "TROOT.h"
#include "TClass.h"
#include "TError.h"
#include "TSystem.h"
#include "TString.h"
#include "TRegexp.h"
#include "THaInterface.h"
#include "TInterpreter.h"
#include "THaVarList.h"
#include "THaCutList.h"
#include "THaCodaDecoder.h"
#include "THaGlobals.h"
#include "THaAnalyzer.h"
#include "ha_compiledata.h"
#include "TTree.h"
using namespace std;
THaVarList* gHaVars = NULL;
THaCutList* gHaCuts = NULL;
TList* gHaApps = NULL;
TList* gHaScalers = NULL;
TList* gHaPhysics = NULL;
THaRunBase* gHaRun = NULL;
TClass* gHaDecoder = NULL;
THaDB* gHaDB = NULL;
THaInterface* THaInterface::fgAint = NULL;
static TString fgTZ;
THaInterface::THaInterface( const char* appClassName, int* argc, char** argv,
void* options, int numOptions, Bool_t noLogo ) :
TRint( appClassName, argc, argv, options, numOptions, kTRUE )
{
if( fgAint ) {
Error("THaInterface", "only one instance of THaInterface allowed");
MakeZombie();
return;
}
if( !noLogo )
PrintLogo();
SetPrompt("analyzer [%d] ");
gHaVars = new THaVarList;
gHaCuts = new THaCutList( gHaVars );
gHaApps = new TList;
gHaScalers = new TList;
gHaPhysics = new TList;
gHaDecoder = THaCodaDecoder::Class();
TTree::SetMaxTreeSize(1500000000);
TString s = gSystem->Getenv("ANALYZER");
if( s.IsNull() ) {
s = HA_INCLUDEPATH;
} else {
TString p = s+"/include";
void* dp = gSystem->OpenDirectory(p);
if( dp ) {
gSystem->FreeDirectory(dp);
s = p;
} else
s = s+"/src " + s+"/hana_decode " + s+"/hana_scaler";
}
TRegexp re("[^ ]+");
TString ss = s(re);
while( !ss.IsNull() ) {
void* dp = gSystem->OpenDirectory(ss);
if( dp ) {
gInterpreter->AddIncludePath(ss);
gSystem->FreeDirectory(dp);
}
s.Remove(0,s.Index(re)+ss.Length());
ss = s(re);
}
fgTZ = gSystem->Getenv("TZ");
gSystem->Setenv("TZ","US/Eastern");
fgAint = this;
}
THaInterface::~THaInterface()
{
if( fgAint == this ) {
gSystem->Setenv("TZ",fgTZ.Data());
delete THaAnalyzer::GetInstance();
delete gHaPhysics; gHaPhysics=0;
delete gHaScalers; gHaScalers=0;
delete gHaApps; gHaApps=0;
delete gHaVars; gHaVars=0;
delete gHaCuts; gHaCuts=0;
fgAint = NULL;
}
}
#if ROOT_VERSION_CODE < ROOT_VERSION(5,18,0)
void THaInterface::PrintLogo()
#else
void THaInterface::PrintLogo( Bool_t lite )
#endif
{
Int_t iday,imonth,iyear,mille;
static const char* months[] = {"Jan","Feb","Mar","Apr","May",
"Jun","Jul","Aug","Sep","Oct",
"Nov","Dec"};
const char* root_version = gROOT->GetVersion();
Int_t idatqq = gROOT->GetVersionDate();
iday = idatqq%100;
imonth = (idatqq/100)%100;
iyear = (idatqq/10000);
if ( iyear < 90 )
mille = 2000 + iyear;
else if ( iyear < 1900 )
mille = 1900 + iyear;
else
mille = iyear;
char* root_date = Form("%s %d %4d",months[imonth-1],iday,mille);
const char* halla_version = HA_VERSION;
#if ROOT_VERSION_CODE >= ROOT_VERSION(5,18,0)
if( !lite ) {
#endif
Printf(" ************************************************");
Printf(" * *");
Printf(" * W E L C O M E to the *");
Printf(" * H A L L A C++ A N A L Y Z E R *");
Printf(" * *");
Printf(" * Release %10s %18s *",halla_version,__DATE__);
Printf(" * Based on ROOT %8s %20s *",root_version,root_date);
Printf(" * *");
Printf(" * For information visit *");
Printf(" * http://hallaweb.jlab.org/root/ *");
Printf(" * *");
Printf(" ************************************************");
#if ROOT_VERSION_CODE >= ROOT_VERSION(5,18,0)
}
#endif
#ifdef R__UNIX
#endif
gInterpreter->PrintIntro();
}
TClass* THaInterface::GetDecoder()
{
return gHaDecoder;
}
TClass* THaInterface::SetDecoder( TClass* c )
{
if( !c ) {
::Error("THaInterface::SetDecoder", "argument is NULL");
return NULL;
}
if( !c->InheritsFrom("THaEvData")) {
::Error("THaInterface::SetDecoder",
"decoder class must inherit from THaEvData");
return NULL;
}
gHaDecoder = c;
return gHaDecoder;
}
ClassImp(THaInterface)
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.