Skip to content

Commit 9241e5f

Browse files
committed
add support for FairShip stripped down root files not conform with standard FairRoot format
1 parent 5fe0508 commit 9241e5f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

base/source/FairFileSource.cxx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
//
1616
#include "FairFileSource.h"
17+
#include "FairRootManager.h" // for FairRootManager
1718
#include "TString.h"
1819
#include "FairFileHeader.h"
1920
#include "FairLogger.h"
@@ -139,14 +140,25 @@ Bool_t FairFileSource::Init()
139140
// with a different branch structure but the same tree name. ROOT
140141
// probably only checks if the name of the tree is the same.
141142
TList* list= dynamic_cast <TList*> (fRootFile->Get("BranchList"));
142-
if(list==0)fLogger->Fatal(MESSAGE_ORIGIN, "No Branch list in input file");
143+
if(list==0){
144+
// special FairShip case of stripped down root file, create list instead of doing core dump
145+
list = new TList();
146+
TTree* sTree = dynamic_cast <TTree*> (fRootFile->Get("cbmsim"));
147+
for(Int_t i =0; i< sTree->GetListOfBranches()->GetEntries(); i++) {
148+
TObjString* Obj = new TObjString( sTree->GetListOfBranches()->At(i)->GetName() );
149+
list->Add( Obj );
150+
}
151+
FairRootManager* fManager = FairRootManager::Instance();
152+
fManager->SetBranchNameList(list);
153+
}
154+
if(list==0){ fLogger->Fatal(MESSAGE_ORIGIN, "No Branch list in input file"); };
143155
TString chainName = fInputTitle;
144156
TString ObjName;
145157
fInputLevel.push_back(chainName);
146158
fCheckInputBranches[chainName] = new std::list<TString>;
147159
if(list) {
148160
TObjString* Obj=0;
149-
fLogger->Info(MESSAGE_ORIGIN, "Enteries in the list %i", list->GetEntries());
161+
fLogger->Info(MESSAGE_ORIGIN, "Entries in the list %i", list->GetEntries());
150162
for(Int_t i =0; i< list->GetEntries(); i++) {
151163
Obj=dynamic_cast <TObjString*> (list->At(i));
152164
if(Obj!=0){

base/steer/FairRootManager.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,11 @@ TObject* FairRootManager::ActivateBranch(const char* BrName)
12771277
break;
12781278
}
12791279
}
1280-
1280+
if(!fObj2[fNObj]) {
1281+
// special FairShip case of stripped down root file
1282+
fRootFileSource->GetInChain()->SetBranchStatus(BrName,1);
1283+
fRootFileSource->GetInChain()->SetBranchAddress(BrName,&fObj2[fNObj]);
1284+
}
12811285
if(!fObj2[fNObj]) {
12821286
/** if we do not find an object corresponding to the branch in the folder structure
12831287
* then we have no idea about what type of object is this and we cannot set the branch address

0 commit comments

Comments
 (0)