GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGRSIint.h
Go to the documentation of this file.
1#ifndef TGRSIINT_H
2#define TGRSIINT_H
3
4/** \addtogroup Sorting
5 * @{
6 */
7
8//////////////////////////////////////////////////
9///
10/// \class TGRSIint
11///
12/// TGRSIint is a class that acts as an interpreter for GRSISort. The
13/// idea is that TGRSIint will read in cal, info, mid and root files
14/// and open them appropriately (order) and do the correct thing with
15/// them. It also applies the command line options. Finally, TGRSIint
16/// allows us to take over the interpreter to do some GRSI things.
17///
18///
19///////////////////////////////////////////////////
20
21#ifndef __CINT__
22#include <thread>
23#endif
24
25#include <cstdio>
26#include <string>
27
28#include "TSystem.h"
29#include "TSysEvtHandler.h"
30#include "TRint.h"
31#include "TList.h"
32#include "TEnv.h"
33#include "TFile.h"
34#include "TChain.h"
35#include "TStopwatch.h"
36
37#include "Globals.h"
38#include "TRawFile.h"
39
40extern TChain* gFragment;
41extern TChain* gAnalysis;
42
43class TGRSIint : public TRint {
44private:
45 TGRSIint(int argc, char** argv, void* options = nullptr, int numOptions = 0, bool noLogo = false,
46 const char* appClassName = "grsisort");
47
48 static TEnv* fGRSIEnv; ///< GRSI environment
49
50public:
51 static TGRSIint* fTGRSIint; ///< Static pointer (singleton)
52 static TGRSIint* instance(int argc = 0, char** argv = nullptr, void* options = nullptr, int numOptions = -1,
53 bool noLogo = false, const char* appClassName = "grsisort");
54
55 TGRSIint(const TGRSIint&) = delete;
56 TGRSIint(TGRSIint&&) noexcept = delete;
57 TGRSIint& operator=(const TGRSIint&) = delete;
58 TGRSIint& operator=(TGRSIint&&) noexcept = delete;
59 ~TGRSIint() = default;
60
61 static void PrintHelp(bool);
62 void PrintLogo(bool) override;
63 bool HandleTermInput() override;
64 int TabCompletionHook(char*, int*, std::ostream&) override;
65
66 TFile* OpenRootFile(const std::string& filename, Option_t* opt = "read");
67 TRawFile* OpenRawFile(const std::string& filename);
68 void RunMacroFile(const std::string& filename);
69
70 void Terminate(Int_t status = 0) override;
71
72 static TEnv* GetEnv() { return fGRSIEnv; }
73
74 Long_t ProcessLine(const char* line, Bool_t sync = kFALSE, Int_t* error = nullptr) override;
75
77
78private:
79 void SetupPipeline();
80 void LoopUntilDone();
81 void ApplyOptions();
82 static void DrawLogo();
83 static void LoadGROOTGraphics();
85
86 Long_t DelayedProcessLine(std::string command);
87
88 TTimer* fKeepAliveTimer; ///< Time of process
89#ifndef __CINT__
90 std::thread::id main_thread_id; ///< Main sorting thread id
91#endif
92
93 bool fIsTabComplete; ///< Flag for tab completion hook
94 bool fAllowedToTerminate; ///< Flag for shutting down GRSISort
95 int fRootFilesOpened; ///< Number of ROOT files opened
96 int fRawFilesOpened; ///< Number of Raw Files opened
97 std::string fNewFragmentFile; ///< New fragment file name
98
99 std::vector<TRawFile*> fRawFiles; ///< List of Raw files opened
100
101 /// \cond CLASSIMP
102 ClassDefOverride(TGRSIint, 0) // NOLINT(readability-else-after-return)
103 /// \endcond
104};
105
106//////////////////////////////////////////////////
107///
108/// \class TGRSIInterruptHandler
109///
110/// Handles interruptions such as ctrl-c
111///
112///////////////////////////////////////////////////
113
114class TGRSIInterruptHandler : public TSignalHandler {
115public:
116 TGRSIInterruptHandler() : TSignalHandler(kSigInterrupt, false) {}
117 bool Notify() override;
118};
119/*! @} */
120#endif
bool Notify() override
Definition TGRSIint.cxx:724
void SetupPipeline()
Definition TGRSIint.cxx:399
TRawFile * OpenRawFile(const std::string &filename)
Definition TGRSIint.cxx:371
int TabCompletionHook(char *, int *, std::ostream &) override
Definition TGRSIint.cxx:225
static void PrintHelp(bool)
Definition TGRSIint.cxx:715
int fRawFilesOpened
Number of Raw Files opened.
Definition TGRSIint.h:96
static TEnv * GetEnv()
Definition TGRSIint.h:72
Long_t DelayedProcessLine(std::string command)
Definition TGRSIint.cxx:773
std::thread::id main_thread_id
Main sorting thread id.
Definition TGRSIint.h:90
TGRSIint(int argc, char **argv, void *options=nullptr, int numOptions=0, bool noLogo=false, const char *appClassName="grsisort")
Definition TGRSIint.cxx:63
static TGRSIint * fTGRSIint
Static pointer (singleton)
Definition TGRSIint.h:51
TFile * OpenRootFile(const std::string &filename, Option_t *opt="read")
Definition TGRSIint.cxx:299
TTimer * fKeepAliveTimer
Time of process.
Definition TGRSIint.h:88
TGRSIint(const TGRSIint &)=delete
static void DrawLogo()
Definition TGRSIint.cxx:697
std::vector< TRawFile * > fRawFiles
List of Raw files opened.
Definition TGRSIint.h:99
static void LoadGROOTGraphics()
Definition TGRSIint.cxx:704
void DelayedProcessLine_Action()
Definition TGRSIint.cxx:790
void LoadExtraClasses()
std::string fNewFragmentFile
New fragment file name.
Definition TGRSIint.h:97
void RunMacroFile(const std::string &filename)
Definition TGRSIint.cxx:671
bool fAllowedToTerminate
Flag for shutting down GRSISort.
Definition TGRSIint.h:94
static TGRSIint * instance(int argc=0, char **argv=nullptr, void *options=nullptr, int numOptions=-1, bool noLogo=false, const char *appClassName="grsisort")
Definition TGRSIint.cxx:53
TGRSIint(TGRSIint &&) noexcept=delete
bool fIsTabComplete
Flag for tab completion hook.
Definition TGRSIint.h:93
int fRootFilesOpened
Number of ROOT files opened.
Definition TGRSIint.h:95
void LoopUntilDone()
Definition TGRSIint.cxx:164
static TEnv * fGRSIEnv
GRSI environment.
Definition TGRSIint.h:48
void PrintLogo(bool) override
Definition TGRSIint.cxx:271
Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr) override
Definition TGRSIint.cxx:234
void Terminate(Int_t status=0) override
Definition TGRSIint.cxx:193
void ApplyOptions()
Definition TGRSIint.cxx:90
bool HandleTermInput() override
Definition TGRSIint.cxx:187
Reader for raw files.
Definition TRawFile.h:31
TChain * gAnalysis
Definition TGRSIint.cxx:51
TChain * gFragment
Definition TGRSIint.cxx:50