GRSISort
Created by P.C. Bender
Developement Team: P.C. Bender, R. Dunlop, V. Bildstein
An extension of the ROOT analysis Framework
TGRSIint Class Reference

TGRSIint is a class that acts as an interpreter for GRSISort. The idea is that TGRSIint will read in cal, info, mid and root files and open them appropriately (order) and do the correct thing with them. It also applies the command line options. Finally, TGRSIint allows us to take over the interpreter to do some GRSI things.

Definition at line 39 of file TGRSIint.h.

Public Member Functions

 ~TGRSIint () override
 
void DelayedProcessLine_Action ()
 
bool HandleTermInput () override
 
TRawFileOpenRawFile (const std::string &filename)
 
TFile * OpenRootFile (const std::string &filename, Option_t *opt="read")
 
void PrintHelp (bool)
 
void PrintLogo (bool) override
 
Long_t ProcessLine (const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr) override
 
void RunMacroFile (const std::string &filename)
 
int TabCompletionHook (char *, int *, std::ostream &) override
 
void Terminate (Int_t status=0) override
 

Static Public Member Functions

static TEnv * GetEnv ()
 
static TGRSIintinstance (int argc=0, char **argv=nullptr, void *options=nullptr, int numOptions=-1, bool noLogo=false, const char *appClassName="grsisort")
 

Static Public Attributes

static TGRSIintfTGRSIint = nullptr
 

Private Member Functions

 TGRSIint (int argc, char **argv, void *options=nullptr, int numOptions=0, bool noLogo=false, const char *appClassName="grsisort")
 
void ApplyOptions ()
 
Long_t DelayedProcessLine (std::string command)
 
void DrawLogo ()
 
void LoadExtraClasses ()
 
void LoadGROOTGraphics ()
 
void LoopUntilDone ()
 
void SetupPipeline ()
 

Private Attributes

bool fAllowedToTerminate
 
bool fIsTabComplete
 
TTimer * fKeepAliveTimer
 
std::string fNewFragmentFile
 
std::vector< TRawFile * > fRawFiles
 
int fRawFilesOpened
 
int fRootFilesOpened
 
std::thread::id main_thread_id
 

Static Private Attributes

static TEnv * fGRSIEnv = nullptr
 

#include <TGRSIint.h>

+ Inheritance diagram for TGRSIint:
+ Collaboration diagram for TGRSIint:

Constructor & Destructor Documentation

◆ TGRSIint()

TGRSIint::TGRSIint ( int  argc,
char **  argv,
void *  options = nullptr,
int  numOptions = 0,
bool  noLogo = false,
const char *  appClassName = "grsisort" 
)
private

Singleton constructor

Definition at line 64 of file TGRSIint.cxx.

References pygui.grut-view::argv, fGRSIEnv, TGRSIOptions::Get(), PrintLogo(), and TGRSIOptions::ShouldExit().

Referenced by instance().

◆ ~TGRSIint()

TGRSIint::~TGRSIint ( )
override

Default dtor.

Definition at line 190 of file TGRSIint.cxx.

Member Function Documentation

◆ ApplyOptions()

◆ DelayedProcessLine()

◆ DelayedProcessLine_Action()

◆ DrawLogo()

void TGRSIint::DrawLogo ( )
private

Draws the logo. Can be suppressed with -l

Definition at line 698 of file TGRSIint.cxx.

References PopupLogo(), and WaitLogo().

Referenced by PrintLogo().

◆ GetEnv()

static TEnv* TGRSIint::GetEnv ( )
inlinestatic

Definition at line 65 of file TGRSIint.h.

References fGRSIEnv.

◆ HandleTermInput()

bool TGRSIint::HandleTermInput ( )
override

Handles terminal input via TRint

Definition at line 195 of file TGRSIint.cxx.

◆ instance()

TGRSIint * TGRSIint::instance ( int  argc = 0,
char **  argv = nullptr,
void *  options = nullptr,
int  numOptions = -1,
bool  noLogo = false,
const char *  appClassName = "grsisort" 
)
static

Singleton constructor instance

Definition at line 54 of file TGRSIint.cxx.

References ApplyOptions(), pygui.grut-view::argv, fTGRSIint, and TGRSIint().

Referenced by main(), TGRSIInterruptHandler::Notify(), TFragHistLoop::OpenFile(), and TAnalysisHistLoop::OpenFile().

◆ LoadExtraClasses()

void TGRSIint::LoadExtraClasses ( )
private

◆ LoadGROOTGraphics()

void TGRSIint::LoadGROOTGraphics ( )
private

Loads root graphics in unless -b is used for batch mode.

Definition at line 705 of file TGRSIint.cxx.

Referenced by ApplyOptions().

◆ LoopUntilDone()

void TGRSIint::LoopUntilDone ( )
private

Outputs the thread status until all of the threads are complete.

Definition at line 167 of file TGRSIint.cxx.

References StoppableThread::AllThreadProgress(), StoppableThread::AllThreadStatus(), StoppableThread::AnyThreadRunning(), fAllowedToTerminate, and TGRSIOptions::Get().

Referenced by ApplyOptions(), and Terminate().

◆ OpenRawFile()

TRawFile * TGRSIint::OpenRawFile ( const std::string &  filename)

Opens Raw input file and stores them in _raw if successfuly opened.

Definition at line 385 of file TGRSIint.cxx.

References BLUE, TParserLibrary::CreateRawFile(), file_exists(), fRawFiles, fRawFilesOpened, TSingleton< TParserLibrary >::Get(), ProcessLine(), and RESET_COLOR.

Referenced by ApplyOptions().

◆ OpenRootFile()

TFile * TGRSIint::OpenRootFile ( const std::string &  filename,
Option_t *  opt = "read" 
)

Opens root files provided on the command line. Also tells you where these files are stored (ie _file0). If these files are analysis or fragment trees, they are automatically chained into chains called gFragment and gAnalysis. Once this is complete, the TChannels, GValues and RunInfo are also read in.

Definition at line 305 of file TGRSIint.cxx.

References AddFileToGUI(), BLUE, fRootFilesOpened, gAnalysis, gFragment, TRunInfo::ReadInfoFromFile(), and RESET_COLOR.

Referenced by ApplyOptions(), TFragHistLoop::OpenFile(), and TAnalysisHistLoop::OpenFile().

◆ PrintHelp()

void TGRSIint::PrintHelp ( bool  print)

Prints the help. Not sure this is used anymore.

Definition at line 716 of file TGRSIint.cxx.

References BG_WHITE, DRED, and RESET_COLOR.

◆ PrintLogo()

void TGRSIint::PrintLogo ( bool  print)
override

Prints the GRSISort logo to terminal

Definition at line 277 of file TGRSIint.cxx.

References DrawLogo(), GRSI_RELEASE, and ProgramName().

Referenced by TGRSIint().

◆ ProcessLine()

Long_t TGRSIint::ProcessLine ( const char *  line,
Bool_t  sync = kFALSE,
Int_t *  error = nullptr 
)
override

This takes over the native root command line. There are two main reasons for this

  1. To keep the command line thread-safe.
  2. To block TCanvas from opening, and to instead use our GCanvas.

Definition at line 242 of file TGRSIint.cxx.

References DelayedProcessLine(), fIsTabComplete, and main_thread_id.

Referenced by DelayedProcessLine_Action(), OpenRawFile(), and RunMacroFile().

◆ RunMacroFile()

void TGRSIint::RunMacroFile ( const std::string &  filename)

Runs a macro file. This happens when a .C file is provided on the command line

Definition at line 672 of file TGRSIint.cxx.

References file_exists(), and ProcessLine().

Referenced by ApplyOptions().

◆ SetupPipeline()

void TGRSIint::SetupPipeline ( )
private

Finds all of the files input as well as flags provided and makes all of the decisions about what to sort and what order to open everything up in. This also creates the output files. Starts the threads and gets the sorting going. This is really the brains of the command line sorting routine.

Definition at line 408 of file TGRSIint.cxx.

References TUnpackingLoop::AddGoodOutputQueue(), TFragmentChainLoop::AddOutputQueue(), TDetBuildingLoop::AddOutputQueue(), TGRSIOptions::AnalysisHistogramLib(), TGRSIOptions::AnalysisOptions(), TFragWriteLoop::BadInputQueue(), TUnpackingLoop::BadOutputQueue(), TDetectorInformation::BuildMode(), TAnalysisOptions::BuildWindow(), TGRSIOptions::CalInputFiles(), TGRSIOptions::CloseAfterSort(), StoppableThread::ColumnWidth(), DRED, TGRSIOptions::ExternalRunInfo(), file_exists(), fNewFragmentFile, TGRSIOptions::FragmentHistogramLib(), fRawFiles, gAnalysis, TFragHistLoop::Get(), TAnalysisHistLoop::Get(), TAnalysisWriteLoop::Get(), TFragWriteLoop::Get(), TGRSIOptions::Get(), TEventBuildingLoop::Get(), TUnpackingLoop::Get(), TFragmentChainLoop::Get(), TSingleton< TRunInfo >::Get(), TDataLoop::Get(), TDetBuildingLoop::Get(), TRunInfo::GetDetectorInformation(), GetRunNumber(), GetSubRunNumber(), gFragment, TGRSIOptions::InputFiles(), TFragHistLoop::InputQueue(), TAnalysisHistLoop::InputQueue(), TAnalysisWriteLoop::InputQueue(), TFragWriteLoop::InputQueue(), TEventBuildingLoop::InputQueue(), TUnpackingLoop::InputQueue(), TDetBuildingLoop::InputQueue(), TEventBuildingLoop::kDefault, TGRSIOptions::MakeAnalysisTree(), TGRSIOptions::MakeHistos(), TAnalysisWriteLoop::OutOfOrderQueue(), TEventBuildingLoop::OutOfOrderQueue(), TGRSIOptions::OutputAnalysisFile(), TGRSIOptions::OutputAnalysisHistogramFile(), TGRSIOptions::OutputFragmentFile(), TGRSIOptions::OutputFragmentHistogramFile(), TEventBuildingLoop::OutputQueue(), TDataLoop::OutputQueue(), TAnalysisOptions::Print(), TChannel::ReadCalFile(), TRunInfo::ReadInfoFile(), GValue::ReadValFile(), RESET_COLOR, StoppableThread::ResumeAll(), TFragWriteLoop::ScalerInputQueue(), TUnpackingLoop::ScalerOutputQueue(), TDetectorInformation::Set(), TFragHistLoop::SetOutputFilename(), TAnalysisHistLoop::SetOutputFilename(), TRunInfo::SetRunInfo(), TFragmentChainLoop::SetSelfStopping(), TDataLoop::SetSelfStopping(), TEventBuildingLoop::SetSortDepth(), TGRSIOptions::SortDepth(), TGRSIOptions::SortRaw(), StoppableThread::StatusWidth(), TGRSIOptions::ValInputFiles(), and TGRSIOptions::WriteFragmentTree().

Referenced by ApplyOptions().

◆ TabCompletionHook()

Int_t TGRSIint::TabCompletionHook ( char *  buf,
int *  pLoc,
std::ostream &  out 
)
override

Tries to do a tab completion. Returns false if unsuccsessful

Definition at line 233 of file TGRSIint.cxx.

References fIsTabComplete.

◆ Terminate()

void TGRSIint::Terminate ( Int_t  status = 0)
override

Kills all of the threads if the process is allowed to terminate. This sends an error to TSortingDiagnostics if an analysis tree is being created

Definition at line 201 of file TGRSIint.cxx.

References fAllowedToTerminate, TGRSIOptions::Get(), TSingleton< TSortingDiagnostics >::Get(), LoopUntilDone(), TSortingDiagnostics::Print(), StoppableThread::SendStop(), and StoppableThread::StopAll().

Referenced by ApplyOptions(), and TGRSIInterruptHandler::Notify().

Member Data Documentation

◆ fAllowedToTerminate

bool TGRSIint::fAllowedToTerminate
private

Flag for shutting down GRSISort.

Definition at line 90 of file TGRSIint.h.

Referenced by LoopUntilDone(), and Terminate().

◆ fGRSIEnv

TEnv * TGRSIint::fGRSIEnv = nullptr
staticprivate

GRSI environment.

Definition at line 44 of file TGRSIint.h.

Referenced by GetEnv(), and TGRSIint().

◆ fIsTabComplete

bool TGRSIint::fIsTabComplete
private

Flag for tab completion hook.

Definition at line 89 of file TGRSIint.h.

Referenced by ProcessLine(), and TabCompletionHook().

◆ fKeepAliveTimer

TTimer* TGRSIint::fKeepAliveTimer
private

Time of process.

Definition at line 83 of file TGRSIint.h.

◆ fNewFragmentFile

std::string TGRSIint::fNewFragmentFile
private

New fragment file name.

Definition at line 93 of file TGRSIint.h.

Referenced by SetupPipeline().

◆ fRawFiles

std::vector<TRawFile*> TGRSIint::fRawFiles
private

List of Raw files opened.

Definition at line 95 of file TGRSIint.h.

Referenced by OpenRawFile(), and SetupPipeline().

◆ fRawFilesOpened

int TGRSIint::fRawFilesOpened
private

Number of Raw Files opened.

Definition at line 92 of file TGRSIint.h.

Referenced by OpenRawFile().

◆ fRootFilesOpened

int TGRSIint::fRootFilesOpened
private

Number of ROOT files opened.

Definition at line 91 of file TGRSIint.h.

Referenced by OpenRootFile().

◆ fTGRSIint

TGRSIint * TGRSIint::fTGRSIint = nullptr
static

Static pointer (singleton)

Definition at line 47 of file TGRSIint.h.

Referenced by instance().

◆ main_thread_id

std::thread::id TGRSIint::main_thread_id
private

Main sorting thread id.

Definition at line 85 of file TGRSIint.h.

Referenced by ProcessLine().