GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TWriteLoop.h
Go to the documentation of this file.
1 #ifndef _TWRITELOOP_H_
2 #define _TWRITELOOP_H_
3 
4 #include <atomic>
5 #include <map>
6 #include <vector>
7 
8 #include "TClass.h"
9 #include "TDirectory.h"
10 #include "TTree.h"
11 
12 #include "StoppableThread.h"
13 #include "ThreadsafeQueue.h"
14 #include "TUnpackedEvent.h"
15 
16 class TWriteLoop : public StoppableThread {
17 public:
19  virtual ~TWriteLoop();
20 
21  void SetLearningPhaseLength(int length) { learning_phase_length = length; }
22  int GetLearningPhaseLength(int length) const { return learning_phase_length; }
23 
24  void Write();
25 
27 
28 protected:
29  bool Iteration();
30 
31 private:
32  void HandleEvent(TUnpackedEvent* event);
33  void LearningPhase(TUnpackedEvent* event);
34  void EndLearningPhase();
35  void WriteEvent(TUnpackedEvent* event);
36 
38  TTree* event_tree;
39  //TTree* scaler_tree;
40 
41  std::map<TClass*, TDetector**> det_map;
42  std::vector<TUnpackedEvent*> learning_queue;
43  std::atomic_bool in_learning_phase;
45 
46  TDirectory& output_dir;
47 };
48 
49 
50 #endif /* _TWRITELOOP_H_ */