EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairWriteoutBuffer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairWriteoutBuffer.h
1 
24 #ifndef FairWriteoutBuffer_H_
25 #define FairWriteoutBuffer_H_
26 
27 
28 
29 #include "TObject.h"
30 #include "TString.h"
31 //#include "FairWriteoutBufferAbsBasis.h"
32 #include "FairTimeStamp.h"
33 #include <map>
34 
35 class FairLogger;
36 
38 {
39  public:
41  fTreeSave(false), fActivateBuffering(kFALSE), fVerbose(0) {};
42  FairWriteoutBuffer(TString branchName, TString className, TString folderName, Bool_t persistance);
43  virtual ~FairWriteoutBuffer() {};
44 
45  virtual void SaveDataToTree(Bool_t val = kTRUE) {fTreeSave = val;}
46  virtual void ActivateBuffering(Bool_t val = kTRUE) {fActivateBuffering=val;}
47 
50  virtual void FillNewData(FairTimeStamp* data, double startTime, double activeTime);
51 
52  virtual Int_t GetNData() {return fDeadTime_map.size();}
53  virtual std::vector<FairTimeStamp*> GetRemoveOldData(double time);
54  virtual std::vector<FairTimeStamp*> GetAllData();
55 
56 
57  virtual void SetVerbose(Int_t val) {fVerbose = val;}
58 
59  virtual void DeleteOldData() {
60  TClonesArray* myArray = FairRootManager::Instance()->GetTClonesArray(fBranchName);
61  myArray->Delete();
62  }
63 
64  virtual void WriteOutData(double time);
65  virtual void WriteOutAllData();
66 
67  protected:
68 
69  virtual void AddNewDataToTClonesArray(FairTimeStamp* data) = 0;
70  virtual double FindTimeForData(FairTimeStamp* data) = 0;
71  virtual void FillDataMap(FairTimeStamp* data, double activeTime) = 0;
72  virtual void EraseDataFromDataMap(FairTimeStamp* data) = 0;
73 
76  virtual std::vector<std::pair<double, FairTimeStamp*> > Modify(std::pair<double, FairTimeStamp*> oldData, std::pair<double, FairTimeStamp*> newData) {
77  std::vector<std::pair<double, FairTimeStamp*> > result;
78  result.push_back(oldData);
79  return result;
80  }
81 
82 
83  virtual void WriteOutDataDeadTimeMap(double time);
84  virtual void MoveDataFromStartTimeMapToDeadTimeMap(double time);
85  virtual void FillDataToDeadTimeMap(FairTimeStamp* data, double activeTime);
86 
87  virtual void PrintData(FairTimeStamp* data) {std::cout << data->GetTimeStamp();};
88  virtual void PrintDeadTimeMap();
89  virtual void PrintStartTimeMap();
90 
91  std::multimap<double, std::pair<double, FairTimeStamp*> > fStartTime_map;
92  std::multimap<double, FairTimeStamp*> fDeadTime_map;
93 
94  TString fBranchName;
95  TString fClassName;
96  Bool_t fTreeSave;
98  Int_t fVerbose;
101 };
102 
103 #endif /* FairWriteoutBuffer_H_ */