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 DrawLogo();
79 static void LoadGROOTGraphics();
81
82 Long_t DelayedProcessLine(std::string command);
83
84 TTimer* fKeepAliveTimer; ///< Time of process
85#ifndef __CINT__
86 std::thread::id main_thread_id; ///< Main sorting thread id
87#endif
88
89 bool fIsTabComplete; ///< Flag for tab completion hook
90 bool fAllowedToTerminate; ///< Flag for shutting down GRSISort
91 int fRootFilesOpened; ///< Number of ROOT files opened
92 int fRawFilesOpened; ///< Number of Raw Files opened
93 std::string fNewFragmentFile; ///< New fragment file name
94
95 std::vector<TRawFile*> fRawFiles; ///< List of Raw files opened
96
97 int fFakeArgc{0}; ///< this is used as a fake argc to pass to the TRint constructor
98
99 /// \cond CLASSIMP
100 ClassDefOverride(TGRSIint, 0) // NOLINT(readability-else-after-return)
101 /// \endcond
102};
103
104//////////////////////////////////////////////////
105///
106/// \class TGRSIInterruptHandler
107///
108/// Handles interruptions such as ctrl-c
109///
110///////////////////////////////////////////////////
111
112class TGRSIInterruptHandler : public TSignalHandler {
113public:
114 TGRSIInterruptHandler() : TSignalHandler(kSigInterrupt, false) {}
115 bool Notify() override;
116};
117/*! @} */
118#endif
bool Notify() override
Definition TGRSIint.cxx:752
void SetupPipeline()
Definition TGRSIint.cxx:413
TRawFile * OpenRawFile(const std::string &filename)
Definition TGRSIint.cxx:385
int TabCompletionHook(char *, int *, std::ostream &) override
Definition TGRSIint.cxx:239
static void PrintHelp(bool)
Definition TGRSIint.cxx:743
int fRawFilesOpened
Number of Raw Files opened.
Definition TGRSIint.h:92
static TEnv * GetEnv()
Definition TGRSIint.h:68
Long_t DelayedProcessLine(std::string command)
Definition TGRSIint.cxx:801
std::thread::id main_thread_id
Main sorting thread id.
Definition TGRSIint.h:86
TGRSIint(int argc, char **argv, void *options=nullptr, int numOptions=0, bool noLogo=false, const char *appClassName="grsisort")
Definition TGRSIint.cxx:65
static TGRSIint * fTGRSIint
Static pointer (singleton)
Definition TGRSIint.h:47
TFile * OpenRootFile(const std::string &filename, Option_t *opt="read")
Definition TGRSIint.cxx:313
TTimer * fKeepAliveTimer
Time of process.
Definition TGRSIint.h:84
TGRSIint(const TGRSIint &)=delete
static void DrawLogo()
Definition TGRSIint.cxx:725
std::vector< TRawFile * > fRawFiles
List of Raw files opened.
Definition TGRSIint.h:95
static void LoadGROOTGraphics()
Definition TGRSIint.cxx:732
void DelayedProcessLine_Action()
Definition TGRSIint.cxx:818
void LoadExtraClasses()
std::string fNewFragmentFile
New fragment file name.
Definition TGRSIint.h:93
void RunMacroFile(const std::string &filename)
Definition TGRSIint.cxx:699
bool fAllowedToTerminate
Flag for shutting down GRSISort.
Definition TGRSIint.h:90
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:55
TGRSIint(TGRSIint &&) noexcept=delete
bool fIsTabComplete
Flag for tab completion hook.
Definition TGRSIint.h:89
int fRootFilesOpened
Number of ROOT files opened.
Definition TGRSIint.h:91
void LoopUntilDone()
Definition TGRSIint.cxx:166
static TEnv * fGRSIEnv
GRSI environment.
Definition TGRSIint.h:44
void PrintLogo(bool) override
Definition TGRSIint.cxx:285
Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr) override
Definition TGRSIint.cxx:248
int fFakeArgc
this is used as a fake argc to pass to the TRint constructor
Definition TGRSIint.h:97
void Terminate(Int_t status=0) override
Definition TGRSIint.cxx:195
void ApplyOptions()
Definition TGRSIint.cxx:92
bool HandleTermInput() override
Definition TGRSIint.cxx:189
Reader for raw files.
Definition TRawFile.h:31
TChain * gAnalysis
Definition TGRSIint.cxx:53
TChain * gFragment
Definition TGRSIint.cxx:52