CbmRoot
CbmDigiManager.h
Go to the documentation of this file.
1 
7 #ifndef CBMDIGIMANAGER_H
8 #define CBMDIGIMANAGER_H 1
9 
10 #include <Rtypes.h> // for THashConsistencyHolder, Cla...
11 #include <RtypesCore.h> // for UInt_t, Bool_t, Int_t, kTRUE
12 
13 #include <FairLogger.h> // for LOG
14 #include <FairTask.h> // for InitStatus
15 
16 #include <boost/any.hpp> // for any_cast, bad_any_cast (ptr...
17 #include <boost/exception/exception.hpp> // for clone_impl, error_info_inje...
18 
19 #include <assert.h> // for assert
20 #include <iosfwd> // for string
21 #include <map> // for map, map<>::mapped_type
22 #include <vector> // for vector
23 
24 #include "CbmDefs.h" // for ECbmModuleId
25 #include "CbmDigiBranchBase.h" // for CbmDigiBranchBase
26 
27 class CbmMatch;
28 
38 
39 public:
41  virtual ~CbmDigiManager();
42 
43 
51  template<class Digi>
52  const Digi* Get(Int_t index) const {
53  assert(fIsInitialised);
54  ECbmModuleId system = Digi::GetSystem();
55  if (fBranches.find(system) == fBranches.end()) return nullptr;
56  try {
57  return boost::any_cast<const Digi*>(fBranches[system]->GetDigi(index));
58  } catch (
59  const boost::exception_detail::clone_impl<
60  boost::exception_detail::error_info_injector<boost::bad_any_cast>>&) {
61  LOG(fatal)
62  << "Failed boost any_cast in Digimanager::Get for a digi of type "
63  << Digi::GetClassName();
64  } // catch only boost::bad_any_cast which can be triggered by CbmMuchDigi/CbmMuchBeamTimeDigi
65  return nullptr;
66  }
67 
68 
74  const CbmMatch* GetMatch(ECbmModuleId systemId, UInt_t index) const;
75 
76 
81  static Int_t GetNofDigis(ECbmModuleId systemId);
82 
83 
89  InitStatus Init();
90 
91 
94  if (!fgInstance) fgInstance = new CbmDigiManager();
95  return fgInstance;
96  }
97 
98 
103  static Bool_t IsPresent(ECbmModuleId systemId);
104 
105 
110  static Bool_t IsMatchPresent(ECbmModuleId systemId);
111 
112 
120  void SetBranchName(ECbmModuleId system, const char* name) {
121  fBranchNames[system] = std::string(name);
122  }
123 
124 
130  void UseMuchBeamTimeDigi(Bool_t choice = kTRUE) {
131  fUseMuchBeamTimeDigi = choice;
132  }
133 
134 
135 private:
136  static std::map<ECbmModuleId, CbmDigiBranchBase*> fBranches;
138  static Bool_t fIsInitialised;
139  std::map<ECbmModuleId, std::string> fBranchNames {};
140  static Bool_t fUseMuchBeamTimeDigi;
141 
142 
144  CbmDigiManager();
145 
146 
148  CbmDigiManager(const CbmDigiManager&) = delete;
149 
150 
153 
154 
156  template<class Digi>
157  void SetBranch();
158 
159 
161 };
162 
163 
164 #endif /* CBMDIGIMANAGER_H */
CbmMatch
Definition: CbmMatch.h:22
CbmDigiManager::fBranches
static std::map< ECbmModuleId, CbmDigiBranchBase * > fBranches
Definition: CbmDigiManager.h:136
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmDigiManager::CbmDigiManager
CbmDigiManager()
Definition: CbmDigiManager.cxx:40
CbmDigiManager::~CbmDigiManager
virtual ~CbmDigiManager()
Definition: CbmDigiManager.cxx:45
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmDigiManager::GetNofDigis
static Int_t GetNofDigis(ECbmModuleId systemId)
Definition: CbmDigiManager.cxx:62
CbmDigiManager::UseMuchBeamTimeDigi
void UseMuchBeamTimeDigi(Bool_t choice=kTRUE)
Use CbmMuchBeamTimeDigi instead of CbmMuchDigi for MUCH.
Definition: CbmDigiManager.h:130
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmDigiManager::fIsInitialised
static Bool_t fIsInitialised
Definition: CbmDigiManager.h:138
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmDigiManager::IsMatchPresent
static Bool_t IsMatchPresent(ECbmModuleId systemId)
Presence of a digi match branch.
Definition: CbmDigiManager.cxx:104
CbmDigiManager::operator=
CbmDigiManager & operator=(const CbmDigiManager &)=delete
CbmDigiManager::ClassDef
ClassDef(CbmDigiManager, 5)
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmDigiManager::fgInstance
static CbmDigiManager * fgInstance
Definition: CbmDigiManager.h:137
CbmDigiManager::GetMatch
const CbmMatch * GetMatch(ECbmModuleId systemId, UInt_t index) const
Get a match object.
Definition: CbmDigiManager.cxx:54
CbmDigiManager::CbmDigiManager
CbmDigiManager(const CbmDigiManager &)=delete
CbmDigiBranchBase.h
CbmDigiManager::fBranchNames
std::map< ECbmModuleId, std::string > fBranchNames
Definition: CbmDigiManager.h:139
CbmDigiManager
CbmDigiManager.
Definition: CbmDigiManager.h:37
CbmDigiManager::fUseMuchBeamTimeDigi
static Bool_t fUseMuchBeamTimeDigi
Definition: CbmDigiManager.h:140
CbmDigiManager::SetBranch
void SetBranch()
Set a digi branch.
Definition: CbmDigiManager.cxx:121
CbmDigiManager::SetBranchName
void SetBranchName(ECbmModuleId system, const char *name)
Set the digi branch name for a system.
Definition: CbmDigiManager.h:120
CbmDefs.h