GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TXXXStore.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "TXXXStore.h"
15
16#include "TFile.h"
17#include "TTree.h"
18#include "TROOT.h"
19#include "TBranch.h"
20
21#include "TGo4Log.h"
22#include "TGo4Status.h"
24#include "TGo4EventElement.h"
25#include "TXXXEvent.h"
26
27
29 TGo4EventStore("User custom store")
30{
31 GO4TRACE((15,"TXXXStore::TXXXStore()", __LINE__, __FILE__));
32 // public default ctor for streamer
33}
34
36 TGo4EventStore("User custom store")
37{
38 GO4TRACE((15,"TXXXStore::TXXXStore(TGo4UserStoreParameter* par)", __LINE__, __FILE__));
39
40 if (!par) {
41 TGo4Log::Error("TGo4UserStoreParameter is not specified in TXXXStore constructor");
42 return;
43 }
44
45 SetName(par->GetName());
46
47 TString fname = par->GetName();
48 if (!fname.Contains(".root")) fname.Append(".root");
49
50 fxFile = TFile::Open(fname.Data(), "RECREATE");
51 TGo4Log::Info("TXXXStore: Open file %s RECREATE", fname.Data());
52
53 fxTree = new TTree("Custom", "Custom go4 store");
54 fxTree->Write();
55}
56
58{
59 if (fxFile && fxTree) {
60 fxFile = fxTree->GetCurrentFile(); // for file split after 1.8 Gb!
61 fxFile->cd();
62 fxTree->Write(nullptr, TObject::kOverwrite);
63 delete fxFile; // closes File, fxTree is removed from memory then
64 fxFile = nullptr;
65 fxTree = nullptr;
66 }
67}
68
70{
71 GO4TRACE((12,"TXXXStore::Store(TGo4EventElement *)", __LINE__, __FILE__));
72
73 TXXXEvent *custom = dynamic_cast<TXXXEvent *>(event); // address of next event into event pointer
74 if (!custom) return 1; // error
75
76 if(!fbBranchExists) {
77 fxEvent = custom;
78 fxTree->Branch("Crate1", fxEvent->fCrate1, "Create1[8]/F");
79 fxTree->Branch("Crate2", fxEvent->fCrate2, "Create2[8]/F");
80 fbBranchExists = kTRUE;
81 } else if (fxEvent != custom) {
82 TGo4Log::Info("TXXXStore: Event pointer changed");
83 return 1; // error, should never happen
84 }
85
86 fxTree->Fill();
87 return 0;
88}
#define GO4TRACE(X)
Definition TGo4Log.h:25
The abstract base class for the data elements of which the unpacked events (or detector structure dat...
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
Definition TGo4Log.cxx:294
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
Definition TGo4Log.cxx:320
TTree * fxTree
file
Definition TXXXStore.h:53
TFile * fxFile
Definition TXXXStore.h:52
virtual ~TXXXStore()
Definition TXXXStore.cxx:57
TXXXEvent * fxEvent
tree
Definition TXXXStore.h:54
Bool_t fbBranchExists
current event
Definition TXXXStore.h:55
Int_t Store(TGo4EventElement *event) override
Stores eventelement event into the storage implementation.
Definition TXXXStore.cxx:69