EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmModuleList.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmModuleList.cxx
1 
6 #include "FairLogger.h"
7 
8 #include "CbmModuleList.h"
9 
10 
11 
12 // ----- Initialisation of the list of modules -------------------------
13 map<Int_t, TString> CbmModuleList::DefineModules() {
14  map<Int_t, TString> data;
15 
16  data[kRef] = "ref";
17  data[kMvd] = "mvd";
18  data[kSts] = "sts";
19  data[kRich] = "rich";
20  data[kMuch] = "much";
21  data[kTrd] = "trd";
22  data[kTof] = "tof";
23  data[kEcal] = "ecal";
24  data[kPsd] = "psd";
25  data[kDummy] = "dummy";
26  data[kMagnet] = "magnet";
27  data[kTarget] = "target";
28  data[kPipe] = "pipe";
29 
30  return data;
31 }
32 // -------------------------------------------------------------------------
33 
34 
35 
36 // ----- Initialise static map -------------------------- ----------------
37 // This is done by using the copy constructor of std::map, calling the
38 // method DefineModules, which actually fills the static map.
40 // -------------------------------------------------------------------------
41 
42 
43 
44 // ------ Get module Id from module name ---------------------------------
45 Int_t CbmModuleList::GetModuleId(const char* moduleName) {
46 
47  map<Int_t, TString>::iterator it = fModules.begin();
48  while ( it != fModules.end() ) {
49  if ( ! (it->second).CompareTo(moduleName, TString::kIgnoreCase) )
50  return it->first;
51  it++;
52  }
53  return -1;
54 
55 }
56 // -------------------------------------------------------------------------
57 
58 
59 
60 // ------ Get module name from module Id --------------------------------
61 TString CbmModuleList::GetModuleName(Int_t moduleId) {
62  if ( fModules.find(moduleId) == fModules.end() ) {
63  LOG(ERROR) << "Illegal module Id " << moduleId << FairLogger::endl;
64  return "";
65  }
66  return fModules.find(moduleId)->second;
67 }
68 // -------------------------------------------------------------------------
69 
70 
71 
72