CbmRoot
CbmMcbm2018RichPar.cxx
Go to the documentation of this file.
1 
8 #include "CbmMcbm2018RichPar.h"
9 
10 // FairRoot
11 #include "FairLogger.h"
12 #include "FairParamList.h"
13 
14 // C/C++
15 #include <iomanip>
16 
17 //#include "FairLogger.h" //TODO delete
18 
20  const char* title,
21  const char* context)
22  : FairParGenericSet(name, title, context) {
23  detName = "RICH";
24 }
25 
27 
28 void CbmMcbm2018RichPar::putParams(FairParamList* l) {
29  if (!l) return;
30 
31  l->add("TRBaddresses", fTRBaddresses);
32  l->add("ToTshifts", fToTshifts);
33 }
34 
35 Bool_t CbmMcbm2018RichPar::getParams(FairParamList* l) {
36  if (!l) return kFALSE;
37 
38  if (!l->fill("TRBaddresses", &fTRBaddresses)) return kFALSE;
39  if (!l->fill("ToTshifts", &fToTshifts)) return kFALSE;
40 
41  // Create a map from the list imported from the par file
42  Int_t siz = fTRBaddresses.GetSize();
43  for (Int_t i = 0; i < siz; i++) {
44  fTRBaddrMap.insert(std::pair<Int_t, Int_t>(fTRBaddresses[i], i));
45  }
46 
47  // Create a map from the lists imported from the par file
48  for (Int_t i = 0; i < siz; i++) {
49  for (Int_t ch = 0; ch <= 32; ch++) {
50  fToTshiftMap.insert(
51  std::pair<Int_t, Double_t>(i * 33 + ch, fToTshifts[i * 33 + ch]));
52  }
53  }
54 
55  return kTRUE;
56 }
57 
58 Int_t CbmMcbm2018RichPar::GetAddressIdx(Int_t addr) const {
59  //TODO catch exception only for map
60  try {
61  Int_t idx = fTRBaddrMap.at(addr);
62  return idx;
63  } catch (...) {
64  LOG(warning)
65  << "CbmMcbm2018RichPar::GetAddressIdx => Unknown TRB address 0x"
66  << std::hex << std::setw(4) << addr << ", probably corrupted data!";
67  return -1;
68  }
69 }
70 
71 Int_t CbmMcbm2018RichPar::GetAddress(Int_t ind) const {
72  if (ind < 0 || ind >= fTRBaddresses.GetSize()) return -1;
73  return fTRBaddresses[ind];
74 }
75 
CbmMcbm2018RichPar::GetAddress
Int_t GetAddress(Int_t ind) const
Definition: CbmMcbm2018RichPar.cxx:71
CbmMcbm2018RichPar.h
CbmMcbm2018RichPar::~CbmMcbm2018RichPar
virtual ~CbmMcbm2018RichPar()
Definition: CbmMcbm2018RichPar.cxx:26
CbmMcbm2018RichPar::CbmMcbm2018RichPar
CbmMcbm2018RichPar(const char *name="CbmMcbm2018RichPar", const char *title="RICH unpacker parameters", const char *context="Default")
Definition: CbmMcbm2018RichPar.cxx:19
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmMcbm2018RichPar
Definition: CbmMcbm2018RichPar.h:13
CbmMcbm2018RichPar::getParams
virtual Bool_t getParams(FairParamList *)
Definition: CbmMcbm2018RichPar.cxx:35
CbmMcbm2018RichPar::GetAddressIdx
Int_t GetAddressIdx(Int_t addr) const
Definition: CbmMcbm2018RichPar.cxx:58
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMcbm2018RichPar::putParams
virtual void putParams(FairParamList *)
Definition: CbmMcbm2018RichPar.cxx:28
CbmMcbm2018RichPar::fTRBaddresses
TArrayI fTRBaddresses
Definition: CbmMcbm2018RichPar.h:54
CbmMcbm2018RichPar::fTRBaddrMap
std::map< Int_t, Int_t > fTRBaddrMap
Definition: CbmMcbm2018RichPar.h:70
CbmMcbm2018RichPar::fToTshiftMap
std::map< Int_t, Double_t > fToTshiftMap
Definition: CbmMcbm2018RichPar.h:75
CbmMcbm2018RichPar::fToTshifts
TArrayD fToTshifts
Definition: CbmMcbm2018RichPar.h:64