FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRootFileSink.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -----------------------------------------------------------------------------
9 // ----- -----
10 // ----- FairRootFileSink -----
11 // ----- Created 22.12.2017 by R. Karabowicz -----
12 // ----- -----
13 // -----------------------------------------------------------------------------
14 
15 #ifndef __FAIRROOT__FairRootFileSink__
16 #define __FAIRROOT__FairRootFileSink__
17 
18 #include "FairSink.h"
19 
20 #include <Rtypes.h>
21 #include <TFile.h>
22 #include <TString.h>
23 #include <typeinfo>
24 
25 class FairEventHeader;
26 class FairFileHeader;
27 class TBranch;
28 class TObjArray;
29 class TObject;
30 class TTree;
31 class TFolder;
32 
33 class FairRootFileSink : public FairSink
34 {
35  public:
36  FairRootFileSink(TFile* f, const char* Title = "OutputRootFile");
37  FairRootFileSink(const TString* RootFileName, const char* Title = "OutputRootFile");
38  FairRootFileSink(const TString RootFileName, const char* Title = "OutputRootFile");
39  // FairRootFileSink(const FairRootFileSink& file);
40  virtual ~FairRootFileSink();
41 
42  virtual Bool_t InitSink();
43  virtual void Close();
44  virtual void Reset();
45 
46  virtual Sink_Type GetSinkType() { return kFILESINK; }
47 
48  virtual void FillEventHeader(FairEventHeader* feh);
49 
50  virtual TFile* OpenRootFile(TString fileName = "");
51  TFile* GetRootFile() { return fRootFile; }
52  virtual TString GetFileName() { return (fRootFile ? fRootFile->GetName() : ""); }
53 
54  virtual void SetOutTree(TTree* fTree) { fOutTree = fTree; }
55  TTree* GetOutTree() { return fOutTree; }
56 
57  virtual void Fill();
58 
59  virtual Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0);
60 
61  virtual void RegisterImpl(const char*, const char*, void*);
62  virtual void RegisterAny(const char* brname, const std::type_info& oi, const std::type_info& pi, void* obj);
63 
64  virtual void WriteFolder();
65  virtual bool CreatePersistentBranchesAny();
66 
67  virtual void WriteObject(TObject* f, const char*, Int_t option = 0);
68  virtual void WriteGeometry();
69 
70  virtual FairSink* CloneSink();
71 
72  private:
74  TString fOutputTitle;
76  TFile* fRootFile;
78  TTree* fOutTree;
80  TObjArray* fListFolder;
81 
82  TFolder* fCbmout;
84  Bool_t fIsInitialized;
85 
87  FairRootFileSink operator=(const FairRootFileSink&);
88 
89  void TruncateBranchNames();
90  void TruncateBranchNames(TBranch* b, TString ffn);
91  // bool CreatePersistentBranchesAny();
92 
94  FairFileHeader* fFileHeader;
95 
96  ClassDef(FairRootFileSink, 1);
97 };
98 
99 #endif /* defined(__FAIRROOT__FairRootFileSink__) */
FairRootFileSink(TFile *f, const char *Title="OutputRootFile")
Sink_Type
Definition: FairSink.h:29
virtual void Fill()
virtual void FillEventHeader(FairEventHeader *feh)
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
virtual ~FairRootFileSink()
virtual void RegisterAny(const char *brname, const std::type_info &oi, const std::type_info &pi, void *obj)
virtual bool CreatePersistentBranchesAny()
virtual void WriteGeometry()
virtual void SetOutTree(TTree *fTree)
virtual Sink_Type GetSinkType()
virtual void Reset()
virtual TString GetFileName()
virtual void RegisterImpl(const char *, const char *, void *)
virtual FairSink * CloneSink()
virtual void WriteFolder()
virtual void Close()
virtual Bool_t InitSink()
virtual void WriteObject(TObject *f, const char *, Int_t option=0)
virtual TFile * OpenRootFile(TString fileName="")