CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018RichPar.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
12#include "CbmMcbm2018RichPar.h"
13
14// FairRoot
15#include "FairParamList.h"
16#include <Logger.h>
17
18// C/C++
19#include <iomanip>
20
21//#include <Logger.h> //TODO delete
22
23CbmMcbm2018RichPar::CbmMcbm2018RichPar(const char* name, const char* title, const char* context)
24 : FairParGenericSet(name, title, context)
25{
26 detName = "RICH";
27}
28
30
31void CbmMcbm2018RichPar::putParams(FairParamList* l)
32{
33 if (!l) return;
34
35 l->add("TRBaddresses", fTRBaddresses);
36 l->add("ToTshifts", fToTshifts);
37}
38
39Bool_t CbmMcbm2018RichPar::getParams(FairParamList* l)
40{
41 if (!l) return kFALSE;
42
43 if (!l->fill("TRBaddresses", &fTRBaddresses)) return kFALSE;
44 if (!l->fill("ToTshifts", &fToTshifts)) return kFALSE;
45
47
48 return kTRUE;
49}
50
52{
53 // Create a map from the list imported from the par file
54 Int_t siz = fTRBaddresses.GetSize();
55 for (Int_t i = 0; i < siz; i++) {
56 fTRBaddrMap.insert(std::pair<Int_t, Int_t>(fTRBaddresses[i], i));
57 LOG(debug) << "Inserting in RICH TRB map: 0x" << std::hex << std::setw(4) << fTRBaddresses[i] << std::dec << " "
58 << i;
59 }
60
61 // Create a vector from the lists imported from the par file
62 // Continuous indices => no need for map with deep calls
63 for (Int_t i = 0; i < siz; i++) {
64 for (Int_t ch = 0; ch <= 32; ch++) {
65 fToTshiftMap.push_back(fToTshifts[i * 33 + ch]);
66 }
67 }
68}
69
70Int_t CbmMcbm2018RichPar::GetAddressIdx(Int_t addr, bool bVerbose) const
71{
72 auto it = fTRBaddrMap.find(addr);
73 if (fTRBaddrMap.end() == it) {
74 if (bVerbose) {
75 LOG(warning) << "CbmMcbm2018RichPar::GetAddressIdx => Unknown TRB address 0x" << std::hex << std::setw(4) << addr
76 << std::dec << ", probably corrupted data!";
77 LOG(warning) << "Nb available TRB addresses: " << GetNaddresses();
78
79 Print();
80 }
81
82 return -1;
83 }
84 else {
85 return it->second;
86 }
87}
88
89Int_t CbmMcbm2018RichPar::GetAddress(Int_t ind) const
90{
91 if (ind < 0 || ind >= fTRBaddresses.GetSize()) return -1;
92 return fTRBaddresses[ind];
93}
94
95Double_t CbmMcbm2018RichPar::GetToTshift2(Int_t tdcIdx, Int_t ch) const
96{
97 if (-1 == tdcIdx) {
98 LOG(fatal) << "CbmMcbm2018RichPar::GetToTshift2 => Invalid TDC index, "
99 << "check your data or your parameters!";
100 }
101 return fToTshiftMap[tdcIdx * 33 + ch];
102}
103
104void CbmMcbm2018RichPar::Print(Option_t*) const
105{
106 LOG(info) << "Nb available TRB addresses: " << GetNaddresses();
107
108 TString sPrintout = "";
109 for (Int_t iTrb = 0; iTrb < GetNaddresses(); ++iTrb) {
110 if (0 == iTrb % 8) sPrintout += "\n";
111 sPrintout += Form(" 0x%04x", GetAddress(iTrb));
112 } // for( Int_t iTrb = 0; iTrb < GetNaddresses; ++iTrb)
113 LOG(info) << "Available TRB addresses: " << sPrintout;
114
115 sPrintout = "";
116 for (auto it = fTRBaddrMap.begin(); it != fTRBaddrMap.end(); ++it) {
117 sPrintout += Form(" 0x%04x", it->first);
118 } // for( UInt_t i = 0; i < uNrOfChannels; ++i)
119 LOG(info) << "TRB addresses in map: " << std::endl << sPrintout;
120}
121
ClassImp(CbmConverterManager)
Double_t GetToTshift2(Int_t tdcIdx, Int_t ch) const
Int_t GetNaddresses(void) const
Int_t GetAddress(Int_t ind) const
virtual void putParams(FairParamList *)
Int_t GetAddressIdx(Int_t addr, bool bVerbose=true) const
std::map< Int_t, Int_t > fTRBaddrMap
void Print(Option_t *option="") const
virtual Bool_t getParams(FairParamList *)
std::vector< Double_t > fToTshiftMap
CbmMcbm2018RichPar(const char *name="CbmMcbm2018RichPar", const char *title="RICH unpacker parameters", const char *context="Default")