/** @file CbmDigiManager.h ** @author Volker Friese ** @since 8 May 2007 **/ #ifndef CBMDIGIMANAGER_H #define CBMDIGIMANAGER_H 1 #include #include "TString.h" #include "FairLogger.h" #include "FairTask.h" #include "CbmDefs.h" #include "CbmDigiBranchBase.h" /** @brief CbmDigiManager ** @author Volker Friese ** @since 08.05.07 ** @date 5 June 2019 ** ** Interface class to provide access to CbmDigis. ** The storage model (STL vector or TClonesArray) is abstracted from. **/ class CbmDigiManager { public: /** Destructor **/ virtual ~CbmDigiManager(); /** @brief Get a digi object ** @param index Index of digi in its container ** @return Pointer to constant digi object ** ** Requirement to the template type Digi is that its pointer can be ** cast to CbmDigi* and that it has a static method GetSystem(). **/ template const Digi* Get(Int_t index) { assert( fIsInitialised ); Int_t system = Digi::GetSystem(); if ( fBranches[system] ) { return static_cast(fBranches[system]->GetDigi(index)); } return nullptr; } /** @brief Get a match object ** @param index Index of digi/match in their container ** @return Pointer to constant match object **/ const CbmMatch* GetMatch(ECbmModuleId systemId, Int_t index) { assert( fIsInitialised ); if ( fBranches[systemId] ) { return fBranches[systemId]->GetDigiMatch(index); } return nullptr; } /** Number of digis for a given system ** @param System identifier (ECbmModuleId) ** @return Number of digis for system **/ static Int_t GetNofDigis(ECbmModuleId system); /** @brief Initialisation ** @return kSUCCESS is successful ** ** The input tree is checked for digi branches. **/ InitStatus Init(); /** @brief Presence of a digi branch ** @return kTRUE if digi branch is present **/ static Bool_t IsPresent(ECbmModuleId systemId) { if ( systemId < kNofSystems ) { if ( fBranches[systemId]) return kTRUE; } return kFALSE; } /** @brief Presence of a digi match branch ** @return kTRUE if digi match branch is present **/ static Bool_t IsMatchPresent(ECbmModuleId systemId) { if ( systemId < kNofSystems ) { if ( fBranches[systemId]) return fBranches[systemId]->HasMatches(); } return kFALSE; } /** @brief Static instance **/ static CbmDigiManager* Instance() { if ( ! fgInstance ) fgInstance = new CbmDigiManager(); return fgInstance; } private: static std::vector fBranches; //! static CbmDigiManager* fgInstance; //! static Bool_t fIsInitialised; /** Default constructor **/ CbmDigiManager(); /** Copy constructor forbidden **/ CbmDigiManager(const CbmDigiManager&) = delete; /** Assignment operator forbidden **/ CbmDigiManager& operator=(const CbmDigiManager&) = delete; /** @brief Name of branches ** @param system System identifier (ECbmModuleId) ** @return Name of the digi branch (hard-coded). Empty for unknown system. **/ TString BranchName(Int_t system) const; /** @brief Set a digi branch **/ template void SetBranch(); ClassDef(CbmDigiManager,2); }; #endif /* CBMDIGIMANAGER_H */