8 #ifndef FAIR_ROOT_MANAGER_H
9 #define FAIR_ROOT_MANAGER_H
23 #include <type_traits>
125 TClonesArray*
GetData(TString branchName,
127 Double_t startParameter,
129 Double_t stopParameter);
132 fTSBufferMap[branchName] = functionalBuffer;
160 void Register(
const char* name,
const char* Foldername, TNamed* obj, Bool_t toFile);
166 void Register(
const char* name,
const char* Foldername, TCollection* obj, Bool_t toFile);
170 void RegisterAny(
const char* name, T*& obj, Bool_t toFile);
178 TClonesArray*
Register(TString branchName, TString className, TString folderName, Bool_t toFile);
204 Int_t
Write(
const char* name = 0, Int_t option = 0, Int_t bufsize = 0);
248 return fSourceChain->GetTree();
254 return fSourceChain->GetFile();
260 return fSourceChain->GetFile();
263 void SetInChain(TChain* tempChain, Int_t ident = -1);
289 struct TypeAddressPair
291 TypeAddressPair(
const std::type_info& oi,
const std::type_info& pi,
void* a)
293 , persistenttypeinfo(pi)
296 const std::type_info& origtypeinfo;
297 const std::type_info& persistenttypeinfo;
308 TObject* ActivateBranch(
const char* BrName);
311 void AddMemoryBranch(
const char*, TObject*);
314 void AddMemoryBranchAny(
const char* name, T** obj);
316 T GetMemoryBranchAny(
const char* name)
const;
319 void RegisterImpl(
const char* name,
const char* Foldername, T* obj, Bool_t toFile);
327 Int_t CheckBranchSt(
const char* BrName);
330 TObject* GetMemoryBranch(
const char*);
336 void EmitMemoryBranchWrongTypeWarning(
const char* brname,
const char* typen1,
const char* typen2)
const;
343 TFolder* fRootFolder;
345 Double_t fCurrentTime;
353 std::map<TString, TObject*> fMap;
358 std::map<std::string, std::unique_ptr<TypeAddressPair const>> fAnyBranchMap;
359 std::vector<std::string> fPersistentBranchesAny;
365 TList* fBranchNameList;
367 std::vector<std::string> fReqBrNames;
370 Int_t fMCTrackBranchId;
373 TList* fTimeBasedBranchNameList;
375 std::map<TString, TClonesArray*> fActiveContainer;
377 std::map<TString, FairTSBufferFunctional*> fTSBufferMap;
378 std::map<TString, FairWriteoutBuffer*> fWriteoutBufferMap;
379 std::map<Int_t, TBranch*> fInputBranchMap;
383 Bool_t fBranchPerMap;
385 std::map<TString, Int_t> fBrPerMap;
387 std::map<TString, Int_t>::iterator fBrPerMapIter;
390 UInt_t fCurrentEntryNo;
392 UInt_t fTimeforEntryNo;
393 Bool_t fFillLastData;
396 TObjArray* fListFolder;
400 TChain* fSourceChain;
401 std::map<UInt_t, TChain*> fSignalChainList;
407 Bool_t fUseFairLinks;
410 TObjArray* fListOfBranchesFromInput;
412 TIterator* fListOfBranchesFromInputIter;
414 TRefArray* fListOfNonTimebasedBranches;
416 TIterator* fListOfNonTimebasedBranchesIter;
420 static Int_t fgCounter;
429 void FairRootManager::AddMemoryBranchAny(
const char* brname, T** obj)
431 if (fAnyBranchMap.find(brname) == fAnyBranchMap.end()) {
432 auto& ot =
typeid(T*);
433 auto& pt =
typeid(T);
434 fAnyBranchMap[brname] = std::unique_ptr<TypeAddressPair const>(
new TypeAddressPair(ot, pt, (
void*)obj));
440 T FairRootManager::GetMemoryBranchAny(
const char* brname)
const
442 static_assert(std::is_pointer<T>::value,
"Return type of GetMemoryBranchAny has to be a pointer");
443 using P =
typename std::remove_pointer<T>::type;
444 auto iter = fAnyBranchMap.find(brname);
445 if (iter != fAnyBranchMap.end()) {
447 if (
typeid(P).hash_code() != iter->second->origtypeinfo.hash_code()) {
448 EmitMemoryBranchWrongTypeWarning(brname,
typeid(P).name(), iter->second->origtypeinfo.name());
451 return static_cast<T
>(iter->second->ptraddr);
461 AddMemoryBranchAny<T>(brname, &obj);
463 auto& ot =
typeid(T*);
464 auto& pt =
typeid(T);
468 LOG(fatal) <<
"The sink does not exist to store persistent branches.";
475 template<
typename TPtr>
478 static_assert(std::is_pointer<TPtr>::value,
"Return type of GetObjectAs has to be a pointer");
479 using X =
typename std::remove_pointer<TPtr>::type;
480 static_assert(std::is_const<X>::value,
"Return type of GetObjectAs has to be pointer to const class");
481 using T =
typename std::remove_const<X>::type;
485 T** obj = GetMemoryBranchAny<T**>(brname);
508 AddMemoryBranchAny<T>(brname, addr);
511 fReqBrNames.emplace_back(brname);
524 #endif // FAIR_ROOT_MANAGER_H
static char * GetTreeName()
virtual Bool_t ActivateObjectAny(void **, const std::type_info &, const char *)
void CreateGeometryFile(const char *geofile)
Int_t CheckMaxEventNo(Int_t EvtEnd=0)
void SetBranchNameList(TList *list)
virtual void RegisterAny(const char *brname, const std::type_info &oi, const std::type_info &pi, void *obj)=0
TObject * GetCloneOfLinkData(const FairLink link)
Int_t ReadEvent(Int_t i=0)
virtual void FillEventHeader(FairEventHeader *feh)
TClonesArray * GetCloneOfTClonesArray(const FairLink link)
FairWriteoutBuffer * RegisterWriteoutBuffer(TString branchName, FairWriteoutBuffer *buffer)
const std::vector< std::string > & GetReqBranchNames() const
T InitObjectAs(const char *BrName)
Int_t AddBranchToList(const char *name)
void InitTSBuffer(TString branchName, BinaryFunctor *function)
void TerminateAllTSBuffer()
void WriteFileHeader(FairFileHeader *f)
Bool_t AllDataProcessed()
void SetEntryNr(Int_t val)
void SetFinishRun(Bool_t val=kTRUE)
static FairRootManager * Instance()
void SetSink(FairSink *tempSink)
TObject * GetObject(const char *BrName)
Int_t ReadNonTimeBasedEventFromBranches(Int_t i=0)
TClonesArray * GetData(TString branchName, BinaryFunctor *function, Double_t parameter)
Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
TList * GetBranchNameList()
void SetInChain(TChain *tempChain, Int_t ident=-1)
TClonesArray * GetTClonesArray(TString branchName)
FairTSBufferFunctional * GetTSBuffer(TString branchName)
void SetTimeBasedBranchNameList(TList *list)
TChain * GetSignalChainNo(UInt_t i)
Int_t GetMCTrackBranchId() const
void StoreAllWriteoutBufferData()
void SetLastFill(Bool_t val=kTRUE)
Bool_t GetUseFairLinks() const
void SetListOfFolders(TObjArray *ta)
void RegisterInputObject(const char *name, TObject *obj)
Int_t GetInstanceId() const
TString GetBranchName(Int_t id)
void TerminateTSBuffer(TString branchName)
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
TClonesArray * GetEmptyTClonesArray(TString branchName)
Bool_t ReadNextEvent(Double_t dt)
static char * GetFolderName()
void SetSource(FairSource *tempSource)
void UpdateFileName(TString &fileName)
void UpdateListOfTimebasedBranches()
const TFile * GetRootFile()
Int_t CheckBranch(const char *BrName)
void DeleteOldWriteoutBufferData()
Base class for all functors which are used in the FairTSBufferFunctional.
A container class to store digi data during events.
void StoreWriteoutBufferData(Double_t eventTime)
void ReadBranchEvent(const char *BrName)
void RegisterTSBuffer(TString branchName, FairTSBufferFunctional *functionalBuffer)
A class to access time ordered data in a root branch.
void RegisterAny(const char *name, T *&obj, Bool_t toFile)
Int_t GetBranchId(TString const &BrName)
void FillEventHeader(FairEventHeader *feh)
virtual ~FairRootManager()
bool CreatePersistentBranchesAny()
void SetUseFairLinks(Bool_t val)