GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TPipeline.h
Go to the documentation of this file.
1 #ifndef _TPIPELINE_H_
2 #define _TPIPELINE_H_
3 
4 #include <string>
5 #include <vector>
6 
7 #include "TDirectory.h"
8 
9 #include "StoppableThread.h"
10 #include "ThreadsafeQueue.h"
11 #include "TRawEvent.h"
12 #include "TRawEventSource.h"
13 #include "TUnpackedEvent.h"
14 
15 class TDataLoop;
16 class TUnpackLoop;
17 class TRootInputLoop;
18 class THistogramLoop;
19 class TWriteLoop;
20 class TTerminalLoop;
21 
22 class TPipeline {
23 public:
24  TPipeline();
25  virtual ~TPipeline();
26 
27  bool CanStart(bool print_reason = false);
28 
29  void Start();
30  void Pause();
31  void Resume();
32  void Stop();
33  void Join();
34  std::string Status();
35  void Write();
36 
37 
38  TDirectory* GetDirectory();
42  void ClearHistograms();
43  void ReplaceRawDataFile(std::string filename);
44 
46  void SetHistogramLibrary(std::string filename);
47  std::string GetHistogramLibrary() const;
48 
49  void SetReplaceVariable(const char* name, double value);
50  void RemoveVariable(const char* name);
51  TList* GetVariables();
52 
53  bool InLearningPhase();
54 
59  void AddRawDataFile(std::string filename);
60 
62  void SetOutputRootFile(std::string filename);
63 
65  void SetIsOnline(bool is_online);
66 
68  void SetTimeOrdering(bool time_order);
69 
71  void AddInputRootFile(std::string filename);
72 
74  void SetInputRing(std::string ringname);
75 
76  bool IsFinished();
77 
78 private:
79  TPipeline(const TPipeline&) { }
81 
82  bool AllQueuesEmpty();
83 
84  int Initialize();
85 
86  void SetupRawReadLoop();
87  void SetupRootReadLoop();
88  void SetupOutputFile();
89  void SetupHistogramLoop();
90  void SetupOutputLoop();
91  TRawEventSource* OpenSingleFile(const std::string& filename);
92 
93  TFile* output_file;
94  TDirectory* output_directory;
95 
96  // Output of the TDataLoop. Unused if reading from a root file.
98 
99  // Output of the TUnpackLoop, or the TRootInputLoop, depending on settings
101 
102  // Output of the THistogramLoop
104 
105  std::vector<StoppableThread*> pipeline;
112 
113  // The setup parameters
114  std::vector<std::string> input_raw_files;
115  std::vector<std::string> input_root_files;
116  std::string input_ring;
117 
118  std::string histogram_library;
119  std::string output_root_file;
120  bool is_online;
121 
124 
125  ClassDef(TPipeline, 0);
126 };
127 
128 #endif /* _TPIPELINE_H_ */