CbmRoot
Loading...
Searching...
No Matches
RootManager.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025-2025 Warsaw University of Technology, Warsaw
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Daniel Wielanek [committer] */
4#include "RootManager.h"
5
6#include <FairRootManager.h>
7
8#include <RtypesCore.h>
9#include <TCollection.h>
10#include <TFile.h>
11#include <TList.h>
12#include <TObjString.h>
13
14#include <Hal/InputDataInfo.h>
15
16namespace Hal
17{
18 namespace Fair
19 {
21 : Hal::IOManager(new Hal::InputDataInfo(FairRootManager::Instance()->GetInFile()->GetName()))
22 {
23 fFairManager = FairRootManager::Instance();
24 if (fFairManager->GetInFile()) {
25 fDataInfo->OverwriteSourceName(fFairManager->GetInFile()->GetName());
26 }
27 }
28
29 TObject* RootManager::GetObject(const char* BrName) { return fFairManager->GetObject(BrName); }
30
31 TFile* RootManager::GetInFile() { return fFairManager->GetInFile(); }
32
33 void RootManager::UpdateBranches() { fFairManager->UpdateBranches(); }
34
35 void RootManager::SetInChain(TChain* tempChain, Int_t ident) { fFairManager->SetInChain(tempChain, ident); }
36
37 void RootManager::RegisterInternal(const char* name, const char* folderName, TNamed* obj, Bool_t toFile)
38 {
39 fFairManager->Register(name, folderName, obj, toFile);
40 }
41
42 void RootManager::RegisterInternal(const char* name, const char* Foldername, TCollection* obj, Bool_t toFile)
43 {
44 fFairManager->Register(name, Foldername, obj, toFile);
45 }
46
48 {
49 fFairManager = FairRootManager::Instance();
50 TList* l = fFairManager->GetBranchNameList();
51 for (int i = 0; i < l->GetEntries(); i++) {
52 TString name = ((TObjString*) l->At(i))->GetString();
53 Int_t stat = fFairManager->CheckBranch(name);
54 TObject* obj = fFairManager->GetObject(name);
55 switch (stat) {
56 case 0: // not exist
57 break;
58 case 1: // in file
59 AddBranch(name, obj, BranchInfo::EFlag::kInActive);
60 break;
61 case 2: // memory
62 AddBranch(name, obj, BranchInfo::EFlag::kVirtual);
63 break;
64 }
65 }
66 }
67
69 {
70 if (fFairManager == nullptr) {
71 fFairManager = FairRootManager::Instance();
72 if (fFairManager->GetInFile()) {
73 fDataInfo->OverwriteSourceName(fFairManager->GetInFile()->GetName());
74 }
75 }
77 return kTRUE;
78 }
79
81 {
82 if (!fFairManager) return;
83 auto file = fFairManager->GetOutFile();
84 if (file) file->cd();
85 }
86
87 } // namespace Fair
88} // namespace Hal
int Int_t
bool Bool_t
FairRootManager * fFairManager
Definition RootManager.h:24
virtual void RegisterInternal(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)
void SetInChain(TChain *tempChain, Int_t ident=-1)
TObject * GetObject(const char *BrName)
virtual Bool_t InitInternal()
virtual void RefreshBranchList()