Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
DbgIOManager.cxx
1/*
2 * DbgIOManager.cxx
3 *
4 * Created on: 28 maj 2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "DbgIOManager.h"
10
11#include "Cout.h"
12#include "InputDataInfo.h"
13
14#include <TBranch.h>
15#include <TFile.h>
16#include <TList.h>
17#include <TObjString.h>
18#include <TSystem.h>
19#include <TTree.h>
20
21namespace HalDbg {
22
23 IOManager::IOManager(TString name, Int_t entries) :
24 Hal::IOManager(new Hal::InputDataInfo(name)),
25 fInFileName(name),
26 fOutTreeName("HalTree"),
27 fEntries(entries),
28 fInFile(nullptr),
29 fOutFile(nullptr),
30 fOutTree(nullptr) {}
31
32 Bool_t IOManager::InitInternal() {
33 Hal::Cout::PrintInfo(fInFileName, Hal::EInfo::kLowWarning);
34 fInFile = new TFile(fInFileName, "recreate");
35 fOutFile = new TFile(fOutFileName, "recreate");
36 fOutTree = new TTree(fOutTreeName, fOutTreeName);
37 Hal::Cout::PrintInfo(Form("CREATING TREE %s", fOutTreeName.Data()), Hal::EInfo::kError);
38 return kTRUE;
39 }
40
41 Int_t IOManager::GetEntries() const { return fEntries; }
42
43 IOManager::~IOManager() {
44 if (fInFile) delete fInFile;
45 if (fOutFile) delete fOutFile;
46 gSystem->Exec(Form("rm %s", fInFileName.Data()));
47 }
48
49 TFile* IOManager::GetInFile() { return fInFile; }
50
51 void IOManager::RegisterInternal(const char* name, const char* /*folderName*/, TNamed* obj, Bool_t toFile) {
52 if (toFile) { fOutTree->Branch(name, obj); }
53 }
54
55 void IOManager::RegisterInternal(const char* name, const char* /*Foldername*/, TCollection* obj, Bool_t toFile) {
56 if (toFile) { fOutTree->Branch(name, obj); }
57 }
58
59 void IOManager::SetInChain(TChain* /*tempChain*/, Int_t /*ident*/) {}
60
61 Int_t IOManager::GetEntry(Int_t i, Int_t /*flag*/) {
62 if (i < fEntries) return 1;
63 return -1;
64 }
65
66 void IOManager::FillTree() { fOutTree->Fill(); }
67
68 void IOManager::CloseManager() {
69 fOutTree->Write();
70 fOutFile->Close();
71 }
72
73} // namespace HalDbg
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370