BmnRoot
Loading...
Searching...
No Matches
BmnModuleList.cxx
Go to the documentation of this file.
1
7#include "BmnModuleList.h"
8
9#include "FairLogger.h"
10
11#include <boost/algorithm/string.hpp>
12
13using std::map;
14
15// ----- Initialisation of the list of modules -------------------------
16map<Int_t, TString> BmnModuleList::DefineModules() {
17 map<Int_t, TString> data;
18
19 data[kREF] = "ref";
20 data[kMVD] = "mvd";
21 data[kSSD] = "ssd";
22 data[kTOF] = "tof";
23 data[kECAL] = "ecal";
24
25 return data;
26}
27// -------------------------------------------------------------------------
28
29
30
31// ----- Initialise static map -------------------------- ----------------
32// This is done by using the copy constructor of std::map, calling the
33// method DefineModules, which actually fills the static map.
34map<Int_t, TString> BmnModuleList::fModules(BmnModuleList::DefineModules());
35// -------------------------------------------------------------------------
36
37
38
39// ------ Get module Id from module name ---------------------------------
40Int_t BmnModuleList::GetModuleId(const char* moduleName) {
41
42 map<Int_t, TString>::iterator it = fModules.begin();
43 while ( it != fModules.end() ) {
44 if ( ! (it->second).CompareTo(moduleName, TString::kIgnoreCase) )
45 return it->first;
46 it++;
47 }
48 return -1;
49
50}
51// -------------------------------------------------------------------------
52
53
54
55// ------ Get module name from module Id --------------------------------
56TString BmnModuleList::GetModuleName(Int_t moduleId) {
57 if ( fModules.find(moduleId) == fModules.end() ) {
58 LOG(error) << "Module List: Illegal module Id " << moduleId;
59 return "";
60 }
61 return fModules.find(moduleId)->second;
62}
63// -------------------------------------------------------------------------
64
65
66
67// ------ Get module name in capitals from module Id -------------------
68TString BmnModuleList::GetModuleNameCaps(Int_t moduleId) {
69 TString name = GetModuleName(moduleId);
70 name.ToUpper();
71 return name;
72}
73// -------------------------------------------------------------------------
74
75
@ kTOF
@ kREF
@ kSSD
@ kECAL
static Int_t GetModuleId(const char *moduleName)
static TString GetModuleNameCaps(Int_t moduleId)
static TString GetModuleName(Int_t moduleId)