CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MuchPar.cxx
Go to the documentation of this file.
1/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Ajit Kumar, Florian Uhlig [committer] */
4
6
7#include "FairDetParIo.h"
8#include "FairParIo.h"
9#include "FairParamList.h"
10#include <Logger.h>
11
12#include "TMath.h"
13#include "TString.h"
14
15using namespace std;
16
17// ----- Standard constructor ------------------------------------------
18CbmMcbm2018MuchPar::CbmMcbm2018MuchPar(const char* name, const char* title, const char* context)
19 : FairParGenericSet(name, title, context)
20 , fuNrOfDpbs(0)
21 , fiDbpIdArray()
22 , fiCrobActiveFlag()
23 , fuFebsInGemA(0)
24 , fuFebsInGemB(0)
25 , fuFebsInRpc(0)
26 , fnFebsIdsArrayGemA()
27 , fnFebsIdsArrayGemB()
28 , fnFebsIdsArrayRpc()
29 , fChannelsToPadXA()
30 , fChannelsToPadYA()
31 , fChannelsToPadXB()
32 , fChannelsToPadYB()
33 , fChannelsToPadXRpc()
34 , fChannelsToPadYRpc()
35 , fRealX()
36 , fRealPadSize()
37{
38 detName = "Much";
39}
40// -------------------------------------------------------------------------
41
42
43// ----- Destructor ----------------------------------------------------
45// -------------------------------------------------------------------------
46
47
48// ----- Public method clear -------------------------------------------
50{
51 status = kFALSE;
52 resetInputVersions();
53}
54// -------------------------------------------------------------------------
55
56// -------------------------------------------------------------------------
57
58void CbmMcbm2018MuchPar::putParams(FairParamList* l)
59{
60 if (!l) return;
61
62 l->add("NrOfDpbs", fuNrOfDpbs);
63 l->add("DbpIdArray", fiDbpIdArray);
64 l->add("CrobActiveFlag", fiCrobActiveFlag);
65 l->add("NrOfFebsInGemA", fuFebsInGemA);
66 l->add("nFebsIdsArrayA", fnFebsIdsArrayGemA);
67 l->add("NrOfFebsInGemB", fuFebsInGemB);
68 l->add("nFebsIdsArrayB", fnFebsIdsArrayGemB);
69 l->add("NrOfFebsInRpc", fuFebsInRpc);
70 l->add("nFebsIdsArrayRpc", fnFebsIdsArrayRpc);
71 l->add("ChannelsToPadXA", fChannelsToPadXA);
72 l->add("ChannelsToPadYA", fChannelsToPadYA);
73 l->add("ChannelsToPadXB", fChannelsToPadXB);
74 l->add("ChannelsToPadYB", fChannelsToPadYB);
75 l->add("ChannelsToPadXRpc", fChannelsToPadXRpc);
76 l->add("ChannelsToPadYRpc", fChannelsToPadYRpc);
77 l->add("RealX", fRealX);
78 l->add("PadSize", fRealPadSize);
79}
80
81// -------------------------------------------------------------------------
82
83Bool_t CbmMcbm2018MuchPar::getParams(FairParamList* l)
84{
85
86 if (!l) return kFALSE;
87
88 if (!l->fill("NrOfDpbs", &fuNrOfDpbs)) return kFALSE;
89
91 if (!l->fill("DbpIdArray", &fiDbpIdArray)) return kFALSE;
92
94 if (!l->fill("CrobActiveFlag", &fiCrobActiveFlag)) return kFALSE;
95
96 if (!l->fill("NrOfFebsInGemA", &fuFebsInGemA)) return kFALSE;
97
99 if (!l->fill("nFebsIdsArrayA", &fnFebsIdsArrayGemA)) return kFALSE;
100
101 if (!l->fill("NrOfFebsInGemB", &fuFebsInGemB)) return kFALSE;
102
104 if (!l->fill("nFebsIdsArrayB", &fnFebsIdsArrayGemB)) return kFALSE;
105
106 if (!l->fill("NrOfFebsInRpc", &fuFebsInRpc)) return kFALSE;
107
109 if (!l->fill("nFebsIdsArrayRpc", &fnFebsIdsArrayRpc)) return kFALSE;
110
112 if (!l->fill("ChannelsToPadXA", &fChannelsToPadXA)) return kFALSE;
113
115 if (!l->fill("ChannelsToPadYA", &fChannelsToPadYA)) return kFALSE;
116
118 if (!l->fill("ChannelsToPadXB", &fChannelsToPadXB)) return kFALSE;
119
121 if (!l->fill("ChannelsToPadYB", &fChannelsToPadYB)) return kFALSE;
122
124 if (!l->fill("ChannelsToPadXRpc", &fChannelsToPadXRpc)) return kFALSE;
125
127 if (!l->fill("ChannelsToPadYRpc", &fChannelsToPadYRpc)) return kFALSE;
128
129 fRealX.Set(2232); // Number of Sectors in one GEM Module
130 if (!l->fill("RealX", &fRealX)) return kFALSE;
131
132 fRealPadSize.Set(2232); // Number of Sectors in one GEM Module
133 if (!l->fill("PadSize", &fRealPadSize)) return kFALSE;
134
135 return kTRUE;
136}
137// -------------------------------------------------------------------------
139{
140 //LOG(info) <<" uElink "<<uElink<<" kuNbElinksPerCrob "<<kuNbElinksPerCrob;
141 if (uElink < kuNbElinksPerCrob) return kiCrobMapElinkFebIdx[uElink];
142 else {
143 LOG(warning) << "CbmMcbm2018MuchPar::ElinkIdxToFebIdx => Index out of bound, "
144 << "returning crazy value!";
145 return -1;
146 } // else of if( uElink < kuNbElinksPerCrob )
147}
148// -------------------------------------------------------------------------
150{
151 if (uElink < kuNbElinksPerCrob) return kuCrobMapElinkFebMuch[uElink];
152 else {
153 LOG(warning) << "CbmMcbm2018MuchPar::ElinkIdxToAsicIdxFebMuch => Index out of bound, "
154 << "returning crazy value!";
155 return 0xFFFF;
156 } // else of if( uElink < kuNbElinksPerCrob )
157}
158// -------------------------------------------------------------------------
159UInt_t CbmMcbm2018MuchPar::GetDpbId(UInt_t uDpbIdx)
160{
161 if (uDpbIdx < fuNrOfDpbs) return fiDbpIdArray[uDpbIdx];
162 else {
163 LOG(warning) << "CbmMcbm2018MuchPar::GetDpbId => Index out of bound, "
164 << "returning crazy value!";
165 return 0xFFFFFFFF;
166 } // else of if( uDpbIdx < fuNrOfDpbs )
167}
168Bool_t CbmMcbm2018MuchPar::IsCrobActive(UInt_t uDpbIdx, UInt_t uCrobIdx)
169{
170 if (uDpbIdx < fuNrOfDpbs) {
171 if (uCrobIdx < kuNbCrobsPerDpb) return 0 < fiCrobActiveFlag[uDpbIdx * kuNbCrobsPerDpb + uCrobIdx] ? kTRUE : kFALSE;
172 else {
173 LOG(warning) << "CbmMcbm2018MuchPar::IsCrobActive => Crob Index out of bound, "
174 << "returning default inactive!";
175 return kFALSE;
176 } // else of if( uCrobIdx < kuNbCrobsPerDpb )
177 } // if( uDpbIdx < fuNrOfDpbs )
178 else {
179 LOG(warning) << "CbmMcbm2018MuchPar::IsCrobActive => Dpb Index out of bound, "
180 << "returning default inactive!";
181 return kFALSE;
182 } // else of if( uDpbIdx < fuNrOfDpbs )
183}
184Bool_t CbmMcbm2018MuchPar::IsFebActive(UInt_t uFebInSystIdx)
185{
186
187 if (uFebInSystIdx < GetNrOfFebs()) {
189 return kTRUE;
190 } // if( uFebInSystIdx < GetNrOfFebs() )
191 else {
192 LOG(warning) << "CbmMcbm2018MuchPar::IsFebActive => Feb Index out of bound, "
193 << "returning default inactive!";
194 return kFALSE;
195 } // else of if( uFebInSystIdx < GetNrOfFebs() )
196}
197Bool_t CbmMcbm2018MuchPar::IsFebActive(UInt_t uDpbIdx, UInt_t uCrobIdx, UInt_t uFebIdx)
198{
199 if (uDpbIdx < fuNrOfDpbs) {
200 if (uCrobIdx < kuNbCrobsPerDpb) {
201 if (uFebIdx < kuNbFebsPerCrob) {
202 UInt_t uIdx = (uDpbIdx * kuNbCrobsPerDpb + uCrobIdx) * kuNbFebsPerCrob + uFebIdx;
203 return IsFebActive(uIdx);
204 } // if( uFebIdx < kuNbFebsPerCrob )
205 else {
206 LOG(warning) << "CbmMcbm2018MuchPar::IsFebActive => Feb Index out of bound, "
207 << "returning default inactive!";
208 return kFALSE;
209 } // else of if( uFebIdx < kuNbCrobsPerDpb )
210 } // if( uCrobIdx < kuNbCrobsPerDpb )
211 else {
212 LOG(warning) << "CbmMcbm2018MuchPar::IsFebActive => Crob Index out of bound, "
213 << "returning default inactive!";
214 return kFALSE;
215 } // else of if( uCrobIdx < kuNbCrobsPerDpb )
216 } // if( uDpbIdx < fuNrOfDpbs )
217 else {
218 LOG(warning) << "CbmMcbm2018MuchPar::IsFebActive => Dpb Index out of bound, "
219 << "returning default inactive!";
220 return kFALSE;
221 } // else of if( uDpbIdx < fuNrOfDpbs )
222}
223Short_t CbmMcbm2018MuchPar::GetPadXA(UShort_t febid, UShort_t channelid)
224{
225 if (fChannelsToPadXA.GetSize() <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
226 LOG(debug) << "CbmMcbm2018MuchPar::GetPadXA => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid)
227 << " VS " << fChannelsToPadXA.GetSize() << " (" << febid << " and " << channelid << ")";
228 return -2;
229 } // if( fChannelsToPadXA.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
230
231
232 return fChannelsToPadXA[(febid * kuNbChanPerAsic) + channelid];
233}
234Short_t CbmMcbm2018MuchPar::GetPadYA(UShort_t febid, UShort_t channelid)
235{
236 if (fChannelsToPadXA.GetSize() <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
237 LOG(debug) << "CbmMcbm2018MuchPar::GetPadYA => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid)
238 << " VS " << fChannelsToPadYA.GetSize() << " (" << febid << " and " << channelid << ")";
239 return -2;
240 } // if( fChannelsToPadXA.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
241
242 return fChannelsToPadYA[(febid * kuNbChanPerAsic) + channelid];
243}
244
245Short_t CbmMcbm2018MuchPar::GetPadXB(UShort_t febid, UShort_t channelid)
246{
247 if (fChannelsToPadXB.GetSize() <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
248 LOG(debug) << "CbmMcbm2018MuchPar::GetPadXB => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid)
249 << " VS " << fChannelsToPadXB.GetSize() << " (" << febid << " and " << channelid << ")";
250 return -2;
251 } // if( fChannelsToPadXB.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
252
253
254 return fChannelsToPadXB[(febid * kuNbChanPerAsic) + channelid];
255}
256Short_t CbmMcbm2018MuchPar::GetPadYB(UShort_t febid, UShort_t channelid)
257{
258 if (fChannelsToPadXB.GetSize() <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
259 LOG(debug) << "CbmMcbm2018MuchPar::GetPadYB => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid)
260 << " VS " << fChannelsToPadYB.GetSize() << " (" << febid << " and " << channelid << ")";
261 return -2;
262 } // if( fChannelsToPadXB.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
263
264 return fChannelsToPadYB[(febid * kuNbChanPerAsic) + channelid];
265}
266
267
268Short_t CbmMcbm2018MuchPar::GetPadXRpc(UShort_t febid, UShort_t channelid)
269{
270 if (fChannelsToPadXRpc.GetSize() <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
271 LOG(debug) << "CbmMcbm2018MuchPar::GetPadXRpc => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid)
272 << " VS " << fChannelsToPadXRpc.GetSize() << " (" << febid << " and " << channelid << ")";
273 return -2;
274 } // if( fChannelsToPadXB.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
275
276
277 return fChannelsToPadXRpc[(febid * kuNbChanPerAsic) + channelid];
278}
279Short_t CbmMcbm2018MuchPar::GetPadYRpc(UShort_t febid, UShort_t channelid)
280{
281 if (fChannelsToPadXRpc.GetSize() <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
282 LOG(debug) << "CbmMcbm2018MuchPar::GetPadYRpc => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid)
283 << " VS " << fChannelsToPadYRpc.GetSize() << " (" << febid << " and " << channelid << ")";
284 return -2;
285 } // if( fChannelsToPadXB.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
286
287 return fChannelsToPadYRpc[(febid * kuNbChanPerAsic) + channelid];
288}
289
290
291UInt_t CbmMcbm2018MuchPar::GetFebId(UInt_t uAsicIdx)
292{
293 //22022022:- Not enabled GEM2 (GemB) Working for GemA and RPC under one CRI
294 //LOG(info)<<" fnFebsIdsArrayGemA.GetSize() "<<fnFebsIdsArrayGemA.GetSize()<<" fnFebsIdsArrayGemB.GetSize()"<<fnFebsIdsArrayGemB.GetSize();
295 if (uAsicIdx >= GetNrOfFebsInGemA()) {
296 if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInRpc()) return fnFebsIdsArrayRpc[uAsicIdx % GetNrOfFebsInGemA()];
297 else {
298 LOG(error) << "CbmMcbm2018MuchPar::GetFebId => Index out of bounds: " << uAsicIdx << " VS " << GetNrOfFebsInGemA()
299 << " and " << GetNrOfFebsInRpc() << " => Returning crazy value!!!";
300 return 10000 * (GetNrOfFebsInGemA() + GetNrOfFebsInRpc());
301 } // else of if( ( uAsicIdx % GetNrOfFebsInGemA() ) < GetNrOfFebsInGemB() )
302 } // if(uAsicIdx >= GetNrOfFebsInGemA())
303 else
304 return fnFebsIdsArrayGemA[uAsicIdx];
305
306 //uncomment below when GemB also visible with another CRI
307 /*
308 if (uAsicIdx >= GetNrOfFebsInGemA()) {
309 if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInGemB())
310 return fnFebsIdsArrayGemB[uAsicIdx % GetNrOfFebsInGemA()];
311 else {
312 // LOG(error) << "CbmMcbm2018MuchPar::GetFebId => Index out of bounds: " << uAsicIdx << " VS " << GetNrOfFebsInGemA()
313 // << " and " << GetNrOfFebsInGemB() << " => Returning crazy value!!!";
314 return 10000 * (GetNrOfFebsInGemA() + GetNrOfFebsInGemB());
315 } // else of if( ( uAsicIdx % GetNrOfFebsInGemA() ) < GetNrOfFebsInGemB() )
316 } // if(uAsicIdx >= GetNrOfFebsInGemA())
317 else
318 return fnFebsIdsArrayGemA[uAsicIdx];
319 */
320}
321
322UInt_t CbmMcbm2018MuchPar::GetModule(UInt_t uAsicIdx)
323{
324 if (uAsicIdx >= GetNrOfFebsInGemA()) {
325 //if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInGemB()) return 1;
326 if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInRpc()) return 1;
327 else
328 return 2;
329 } // if(uAsicIdx >= GetNrOfFebsInGemA())
330 else
331 return 0;
332}
333
334Double_t CbmMcbm2018MuchPar::GetRealX(Int_t SectorIndex)
335{
336
337 //LOG(info)<<" fChannelsToPadX.GetSize() "<<fChannelsToPadX.GetSize();
338 if (SectorIndex < 0 || SectorIndex <= 97) {
339 LOG(debug) << "CbmMcbm2018MuchPar::GetRealX => Index out of bounds: ";
340 return -2;
341 } // if( fChannelsToPadY.GetSize () <= (febid*kuNbChanPerAsic)+channelid )
342
343 return fRealX[SectorIndex];
344}
345
346Double_t CbmMcbm2018MuchPar::GetRealPadSize(Int_t SectorIndex)
347{
348
349 //LOG(info)<<" fChannelsToPadX.GetSize() "<<fChannelsToPadX.GetSize();
350 if (SectorIndex < 0 || SectorIndex <= 97) {
351 LOG(debug) << "CbmMcbm2018MuchPar::GetRealX => Index out of bounds: ";
352 return -2;
353 } // if( fChannelsToPadY.GetSize () <= (febid*kuNbChanPerAsic)+channelid )
354
355 return fRealPadSize[SectorIndex];
356}
357
358Double_t CbmMcbm2018MuchPar::GetRealX(Int_t Channel, Int_t Sector)
359{
360 Int_t PadIndex = Channel + 97 * Sector;
361 if (Channel < 0 || Sector < 0) return -2;
362 if (fRealX.GetSize() <= PadIndex) {
363 LOG(info) << "CbmMcbm2018MuchPar::GetRealX => Index out of bounds: " << Channel << " " << Sector << " " << PadIndex;
364 return -1;
365 } // if( fRealX.Size() <= PadIndex )
366
367 return fRealX[PadIndex];
368}
369Double_t CbmMcbm2018MuchPar::GetRealPadSize(Int_t Channel, Int_t Sector)
370{
371 Int_t PadIndex = Channel + 97 * Sector;
372 if (Channel < 0 || Sector < 0) return -2;
373 if (fRealPadSize.GetSize() <= PadIndex) {
374 LOG(info) << "CbmMcbm2018MuchPar::GetRealPadSize => Index out of bounds: " << Channel << " " << Sector << " "
375 << PadIndex;
376 return -1;
377 } // if( fRealPadSize.Size() <= PadIndex )
378
379 return fRealPadSize[PadIndex];
380}
381
ClassImp(CbmConverterManager)
Int_t ElinkIdxToFebIdx(UInt_t uElink)
void putParams(FairParamList *)
CbmMcbm2018MuchPar(const char *name="CbmMcbm2018MuchPar", const char *title="Much parameters", const char *context="Default")
Double_t GetRealPadSize(Int_t)
static const UInt_t kuNbElinksPerCrob
Short_t GetPadXA(UShort_t febid, UShort_t channelid)
const Int_t kiCrobMapElinkFebIdx[kuNbElinksPerCrob]
Map from eLink index to ASIC index within CROB ( 0 to kuNbFebsPerCrob * kuNbAsicPerFeb )
Short_t GetPadXB(UShort_t febid, UShort_t channelid)
UInt_t ElinkIdxToAsicIdxFebMuch(UInt_t uElink)
UInt_t fuNrOfDpbs
Map from eLink index to ASIC index within CROB ( 0 to kuNbFebsPerCrob * kuNbAsicPerFeb )
static const UInt_t kuNbCrobsPerDpb
Constants.
UInt_t GetDpbId(UInt_t uDpbIdx)
Short_t GetPadXRpc(UShort_t febid, UShort_t channelid)
Short_t GetPadYRpc(UShort_t febid, UShort_t channelid)
Short_t GetPadYB(UShort_t febid, UShort_t channelid)
Short_t GetPadYA(UShort_t febid, UShort_t channelid)
static const UInt_t kuNbFebsPerCrob
Bool_t IsCrobActive(UInt_t uDpbIdx, UInt_t uCrobIdx)
Bool_t IsFebActive(UInt_t uFebInSystIdx)
static const UInt_t kuNbChanPerAsic
Bool_t getParams(FairParamList *)
const UInt_t kuCrobMapElinkFebMuch[kuNbElinksPerCrob]
Hash for CbmL1LinkKey.