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 "TSysEvtHandler.h"
29#include "TRint.h"
30#include "TEnv.h"
31#include "TFile.h"
32#include "TChain.h"
33
34#include "TRawFile.h"
35
36extern TChain* gFragment;
37extern TChain* gAnalysis;
38
39class TGRSIint : public TRint {
40private:
41 TGRSIint(int argc, char** argv, void* options = nullptr, int numOptions = 0, bool noLogo = false,
42 const char* appClassName = "grsisort");
43
44 static TEnv* fGRSIEnv; ///< GRSI environment
45
46public:
47 static TGRSIint* fTGRSIint; ///< Static pointer (singleton)
48 static TGRSIint* instance(int argc = 0, char** argv = nullptr, void* options = nullptr, int numOptions = -1,
49 bool noLogo = false, const char* appClassName = "grsisort");
50
51 TGRSIint(const TGRSIint&) = delete;
52 TGRSIint(TGRSIint&&) noexcept = delete;
53 TGRSIint& operator=(const TGRSIint&) = delete;
54 TGRSIint& operator=(TGRSIint&&) noexcept = delete;
55 ~TGRSIint() = default;
56
57 static void PrintHelp(bool);
58 void PrintLogo(bool) override;
59 bool HandleTermInput() override;
60 int TabCompletionHook(char*, int*, std::ostream&) override;
61
62 TFile* OpenRootFile(const std::string& filename, Option_t* opt = "read");
63 TRawFile* OpenRawFile(const std::string& filename);
64 void RunMacroFile(const std::string& filename);
65
66 void Terminate(Int_t status = 0) override;
67
68 static TEnv* GetEnv() { return fGRSIEnv; }
69
70 Long_t ProcessLine(const char* line, Bool_t sync = kFALSE, Int_t* error = nullptr) override;
71
73
74private:
75 void SetupPipeline();
76 void LoopUntilDone();
77 void ApplyOptions();
78 static void LoadGROOTGraphics();
80
81 Long_t DelayedProcessLine(std::string command);
82
83 TTimer* fKeepAliveTimer; ///< Time of process
84#ifndef __CINT__
85 std::thread::id main_thread_id; ///< Main sorting thread id
86#endif
87
88 bool fIsTabComplete; ///< Flag for tab completion hook
89 bool fAllowedToTerminate; ///< Flag for shutting down GRSISort
90 int fRootFilesOpened; ///< Number of ROOT files opened
91 int fRawFilesOpened; ///< Number of Raw Files opened
92 std::string fNewFragmentFile; ///< New fragment file name
93
94 std::vector<TRawFile*> fRawFiles; ///< List of Raw files opened
95
96 int fFakeArgc{0}; ///< this is used as a fake argc to pass to the TRint constructor
97
98 /// \cond CLASSIMP
99 ClassDefOverride(TGRSIint, 0) // NOLINT(readability-else-after-return)
100 /// \endcond
101};
102
103//////////////////////////////////////////////////
104///
105/// \class TGRSIInterruptHandler
106///
107/// Handles interruptions such as ctrl-c
108///
109///////////////////////////////////////////////////
110
111class TGRSIInterruptHandler : public TSignalHandler {
112public:
113 TGRSIInterruptHandler() : TSignalHandler(kSigInterrupt, false) {}
114 bool Notify() override;
115};
116/*! @} */
117#endif
bool Notify() override
Definition TGRSIint.cxx:739
void SetupPipeline()
Definition TGRSIint.cxx:407
TRawFile * OpenRawFile(const std::string &filename)
Definition TGRSIint.cxx:379
int TabCompletionHook(char *, int *, std::ostream &) override
Definition TGRSIint.cxx:236
static void PrintHelp(bool)
Definition TGRSIint.cxx:730
int fRawFilesOpened
Number of Raw Files opened.
Definition TGRSIint.h:91
static TEnv * GetEnv()
Definition TGRSIint.h:68
Long_t DelayedProcessLine(std::string command)
Definition TGRSIint.cxx:788
std::thread::id main_thread_id
Main sorting thread id.
Definition TGRSIint.h:85
TGRSIint(int argc, char **argv, void *options=nullptr, int numOptions=0, bool noLogo=false, const char *appClassName="grsisort")
Definition TGRSIint.cxx:62
static TGRSIint * fTGRSIint
Static pointer (singleton)
Definition TGRSIint.h:47
TFile * OpenRootFile(const std::string &filename, Option_t *opt="read")
Definition TGRSIint.cxx:307
TTimer * fKeepAliveTimer
Time of process.
Definition TGRSIint.h:83
TGRSIint(const TGRSIint &)=delete
std::vector< TRawFile * > fRawFiles
List of Raw files opened.
Definition TGRSIint.h:94
static void LoadGROOTGraphics()
Definition TGRSIint.cxx:719
void DelayedProcessLine_Action()
Definition TGRSIint.cxx:805
void LoadExtraClasses()
std::string fNewFragmentFile
New fragment file name.
Definition TGRSIint.h:92
void RunMacroFile(const std::string &filename)
Definition TGRSIint.cxx:693
bool fAllowedToTerminate
Flag for shutting down GRSISort.
Definition TGRSIint.h:89
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:52
TGRSIint(TGRSIint &&) noexcept=delete
bool fIsTabComplete
Flag for tab completion hook.
Definition TGRSIint.h:88
int fRootFilesOpened
Number of ROOT files opened.
Definition TGRSIint.h:90
void LoopUntilDone()
Definition TGRSIint.cxx:163
static TEnv * fGRSIEnv
GRSI environment.
Definition TGRSIint.h:44
void PrintLogo(bool) override
Definition TGRSIint.cxx:282
Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr) override
Definition TGRSIint.cxx:245
int fFakeArgc
this is used as a fake argc to pass to the TRint constructor
Definition TGRSIint.h:96
void Terminate(Int_t status=0) override
Definition TGRSIint.cxx:192
void ApplyOptions()
Definition TGRSIint.cxx:89
bool HandleTermInput() override
Definition TGRSIint.cxx:186
Reader for raw files.
Definition TRawFile.h:31
TChain * gAnalysis
Definition TGRSIint.cxx:50
TChain * gFragment
Definition TGRSIint.cxx:49