CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018TofPar.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Florian Uhlig [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMcbm2018TofPar source file -----
7// ----- Created 09/09/18 by P.-A. Loizeau -----
8// -------------------------------------------------------------------------
9
10#include "CbmMcbm2018TofPar.h"
11
12#include "CbmTofAddress.h"
13#include "CbmTofDetectorId_v14a.h" // in cbmdata/tof
14#include "FairDetParIo.h"
15#include "FairParIo.h"
16#include "FairParamList.h"
17#include "TString.h"
18#include "gDpbMessv100.h"
19
20#include <Logger.h>
21
22#include <iomanip>
23
24// ----- Standard constructor ------------------------------------------
25CbmMcbm2018TofPar::CbmMcbm2018TofPar(const char* name, const char* title, const char* context)
26 : FairParGenericSet(name, title, context)
27 , fvdPadiThrCodeToValue(GetNrOfPadiThrCodes(), 0.0)
28 , fiNrOfGdpb(-1)
29 , fiGdpbIdArray()
30 , fiNrOfFeesPerGdpb(-1)
31 , fiNrOfGet4PerFee(-1)
32 , fiNrOfChannelsPerGet4(-1)
33 , fiNrOfGbtx(-1)
34 , fiNrOfModule(-1)
35 , fiNrOfRpc()
36 , fiRpcType()
37 , fiRpcSide()
38 , fiModuleId()
39 , fiNbMsTot(0)
40 , fiNbMsOverlap(0)
41 , fdSizeMsInNs(0.0)
42 , fdStarTriggerDeadtime()
43 , fdStarTriggerDelay()
44 , fdStarTriggerWinSize()
45 , fdTsDeadtimePeriod(0.0)
46{
47 detName = "Tof";
48
50 for (UInt_t uPadiPoint = 0; uPadiPoint < kuNbThrMeasPoints; ++uPadiPoint) {
51 fvdPadiThrCodeToValue[kuThrMeasCode[uPadiPoint]] = kdThrMeasVal[uPadiPoint];
52
54 if (uPadiPoint + 1 < kuNbThrMeasPoints) {
55 UInt_t uNbSteps = kuThrMeasCode[uPadiPoint + 1] - kuThrMeasCode[uPadiPoint];
56 Double_t dValStep = (kdThrMeasVal[uPadiPoint + 1] - kdThrMeasVal[uPadiPoint]) / uNbSteps;
57 UInt_t uCode = kuThrMeasCode[uPadiPoint];
58 for (UInt_t uStep = 1; uStep < uNbSteps; ++uStep) {
59 uCode++;
60 fvdPadiThrCodeToValue[uCode] = kdThrMeasVal[uPadiPoint] + dValStep * uStep;
61 } // for( UInt_t uStep = 1; uStep < uNbSteps; ++uStep)
62 } // if( uPadiPoint + 1 < kuNbThrMeasPoints )
63 } // for( UInt_t uPadiPoint = 0; uPadiPoint < kuNbThrMeasPoints; ++uPadiPoint )
64}
65// -------------------------------------------------------------------------
66
67
68// ----- Destructor ----------------------------------------------------
70// -------------------------------------------------------------------------
71
72
73// ----- Public method clear -------------------------------------------
75{
76 status = kFALSE;
77 resetInputVersions();
78}
79// -------------------------------------------------------------------------
80
81// -------------------------------------------------------------------------
82
83void CbmMcbm2018TofPar::putParams(FairParamList* l)
84{
85 if (!l) return;
86 l->add("McbmTof2024", fbMcbmTof2024);
87 l->add("NrOfGdpbs", fiNrOfGdpb);
88 l->add("GdpbIdArray", fiGdpbIdArray);
89 l->add("NrOfFeesPerGdpb", fiNrOfFeesPerGdpb);
90 l->add("NrOfGet4PerFee", fiNrOfGet4PerFee);
91 l->add("NrOfChannelsPerGet4", fiNrOfChannelsPerGet4);
92 l->add("NrOfGbtx", fiNrOfGbtx);
93 l->add("NrOfModule", fiNrOfModule);
94 l->add("NrOfRpcs", fiNrOfRpc);
95 l->add("RpcType", fiRpcType);
96 l->add("RpcSide", fiRpcSide);
97 l->add("ModuleId", fiModuleId);
98 l->add("NbMsTot", fiNbMsTot);
99 l->add("NbMsOverlap", fiNbMsOverlap);
100 l->add("SizeMsInNs", fdSizeMsInNs);
101 l->add("StarTriggerDeadtime", fdStarTriggerDeadtime);
102 l->add("StarTriggerDelay", fdStarTriggerDelay);
103 l->add("StarTriggerWinSize", fdStarTriggerWinSize);
104 l->add("TsDeadtimePeriod", fdTsDeadtimePeriod);
105}
106
107//------------------------------------------------------
108
109Bool_t CbmMcbm2018TofPar::getParams(FairParamList* l)
110{
111
112 if (!l) return kFALSE;
113
115 l->fill("McbmTof2024", &fbMcbmTof2024);
116 if (fbMcbmTof2024) {
117 LOG(info) << "CbmMcbm2018TofPar::getParams => Using mTOF 2024 mapping checks!";
118 }
119
120 if (!l->fill("NrOfGdpbs", &fiNrOfGdpb)) return kFALSE;
121
123 if (!l->fill("GdpbIdArray", &fiGdpbIdArray)) return kFALSE;
124
125 if (!l->fill("NrOfFeesPerGdpb", &fiNrOfFeesPerGdpb)) return kFALSE;
126 if (!l->fill("NrOfGet4PerFee", &fiNrOfGet4PerFee)) return kFALSE;
127 if (!l->fill("NrOfChannelsPerGet4", &fiNrOfChannelsPerGet4)) return kFALSE;
128
129 if (!l->fill("NrOfGbtx", &fiNrOfGbtx)) return kFALSE;
130
131 if (!l->fill("NrOfModule", &fiNrOfModule)) return kFALSE;
132
134 if (!l->fill("NrOfRpc", &fiNrOfRpc)) return kFALSE;
135
137 if (!l->fill("RpcType", &fiRpcType)) return kFALSE;
138
140 if (!l->fill("RpcSide", &fiRpcSide)) return kFALSE;
141
143 if (!l->fill("ModuleId", &fiModuleId)) return kFALSE;
144
145 if (!l->fill("NbMsTot", &fiNbMsTot)) return kFALSE;
146 if (!l->fill("NbMsOverlap", &fiNbMsOverlap)) return kFALSE;
147 if (!l->fill("SizeMsInNs", &fdSizeMsInNs)) return kFALSE;
148
152 if (!l->fill("StarTriggerDeadtime", &fdStarTriggerDeadtime)) return kFALSE;
153 if (!l->fill("StarTriggerDelay", &fdStarTriggerDelay)) return kFALSE;
154 if (!l->fill("StarTriggerWinSize", &fdStarTriggerWinSize)) return kFALSE;
155 if (!l->fill("TsDeadtimePeriod", &fdTsDeadtimePeriod)) return kFALSE;
156
157 LOG(info) << "Build TOF Channels UId Map:";
159
160 return kTRUE;
161}
162// -------------------------------------------------------------------------
163Int_t CbmMcbm2018TofPar::Get4ChanToPadiChan(UInt_t uChannelInFee)
164{
165 if (uChannelInFee < kuNbChannelsPerFee)
166 return kuGet4topadi[uChannelInFee];
167 else {
168 LOG(fatal) << "CbmMcbm2018TofPar::Get4ChanToPadiChan => Index out of bound, " << uChannelInFee << " vs "
169 << static_cast<uint32_t>(kuNbChannelsPerFee) << ", returning crazy value!";
170 return -1;
171 } // else of if( uChannelInFee < kuNbChannelsPerFee )
172}
173Int_t CbmMcbm2018TofPar::PadiChanToGet4Chan(UInt_t uChannelInFee)
174{
175 if (uChannelInFee < kuNbChannelsPerFee)
176 return kuPaditoget4[uChannelInFee];
177 else {
178 LOG(fatal) << "CbmMcbm2018TofPar::PadiChanToGet4Chan => Index out of bound, " << uChannelInFee << " vs "
179 << static_cast<uint32_t>(kuNbChannelsPerFee) << ", returning crazy value!";
180 return -1;
181 } // else of if( uChannelInFee < kuNbChannelsPerFee )
182}
183// -------------------------------------------------------------------------
185{
186 if (gdpbv100::kuChipIdMergedEpoch == uElink) {
187 return uElink;
188 }
189 else if (uElink < kuNbGet4PerGdpb) {
190 return kuElinkToGet4[uElink % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElink / kuNbGet4PerGbtx);
191 }
192 else {
193 LOG(fatal) << "CbmMcbm2018TofPar::ElinkIdxToGet4Idx => Index out of bound, " << uElink << " vs "
194 << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!";
195 return -1;
196 } // else of if( uElink < kuNbGet4PerGbtx )
197}
199{
200 if (gdpbv100::kuChipIdMergedEpoch == uGet4) {
201 return uGet4;
202 }
203 else if (uGet4 < kuNbGet4PerGdpb) {
204 return kuGet4ToElink[uGet4 % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uGet4 / kuNbGet4PerGbtx);
205 }
206 else {
207 LOG(fatal) << "CbmMcbm2018TofPar::Get4IdxToElinkIdx => Index out of bound, " << uGet4 << " vs "
208 << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!";
209 return -1;
210 } // else of if( uElink < kuNbGet4PerGbtx )
211}
213{
214 if (gdpbv100::kuChipIdMergedEpoch == uElink) {
215 return uElink;
216 }
217 else if (uElink < kuNbGet4PerGdpb) {
218 return kuElinkToGet4A[uElink % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElink / kuNbGet4PerGbtx);
219 }
220 else {
221 LOG(fatal) << "CbmMcbm2018TofPar::ElinkIdxToGet4IdxA => Index out of bound, " << uElink << " vs "
222 << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!";
223 return -1;
224 } // else of if( uElink < kuNbGet4PerGbtx )
225}
227{
228 if (gdpbv100::kuChipIdMergedEpoch == uGet4) {
229 return uGet4;
230 }
231 else if (uGet4 < kuNbGet4PerGdpb) {
233 }
234 else {
235 LOG(fatal) << "CbmMcbm2018TofPar::Get4IdxToElinkIdxA => Index out of bound, " << uGet4 << " vs "
236 << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!";
237 return -1;
238 } // else of if( uElink < kuNbGet4PerGbtx )
239}
240// -------------------------------------------------------------------------
242{
243 if (uCode < GetNrOfPadiThrCodes())
244 return fvdPadiThrCodeToValue[uCode];
245 else {
246 LOG(error) << "CbmStar2019TofPar::GetPadiThresholdVal => Code out of bound, " << uCode << " vs "
247 << GetNrOfPadiThrCodes() << ", returning crazy value!";
248 return 1e9;
249 } // else of if( uCode < GetNrOfPadiThrCodes() )
250}
251// -------------------------------------------------------------------------
253{
254 UInt_t uNrOfGbtx = fiNrOfGbtx;
255 UInt_t uNrOfGet4 = fiNrOfGdpb * fiNrOfFeesPerGdpb * fiNrOfGet4PerFee;
256 UInt_t uNrOfChannels = uNrOfGet4 * fiNrOfChannelsPerGet4;
257 fviRpcChUId.resize(uNrOfChannels);
258
259 UInt_t nbRobPerComp = 2; // number of Gbtx per Gdpb (flim) for the final channel count check
260 if (fbMcbmTof2024) {
261 // Hack for 2024 TOF mapping
262 nbRobPerComp = 1;
263 }
264
265 UInt_t uCh = 0;
266 for (UInt_t uGbtx = 0; uGbtx < uNrOfGbtx; ++uGbtx) {
267 uint32_t uCh0 = uCh;
268 uint32_t uGdpb = uCh0 / (fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4);
269 LOG(info) << "Map at ch " << uCh << ", Gdpb " << uGdpb << ", Id " << std::hex << fiGdpbIdArray[uGdpb] << std::dec;
270 switch (fiRpcType[uGbtx]) {
271 case 2: // intended fall-through
272 case 0: {
273 // CBM modules
274 BuildChannelsUidMapCbm(uCh, uGbtx);
275 break;
276 }
277 case 1: {
278 // STAR eTOF modules
279 BuildChannelsUidMapStar(uCh, uGbtx);
280 break;
281 }
282 case 5: {
284 BuildChannelsUidMapBmon(uCh, uGbtx);
285 break;
286 }
287 case 99: {
290 break;
291 }
292 case 78: {
293 // cern-20-gap + ceramic module
294 BuildChannelsUidMapCern(uCh, uGbtx);
295 }
296 [[fallthrough]]; // fall through is intended
297 case 8: // ceramics
298 {
299 BuildChannelsUidMapCera(uCh, uGbtx);
300 break;
301 }
302 case 4: // intended fallthrough
303 [[fallthrough]];
304 case 7: [[fallthrough]];
305 case 9: // Star2 boxes
306 {
307 if ((fiGdpbIdArray[uGdpb] & 0xF000) == 0xB000) {
308 BuildChannelsUidMapStar2A(uCh, uGbtx);
309 }
310 else {
311 BuildChannelsUidMapStar2(uCh, uGbtx);
312 }
313 break;
314 }
315 case 6: // Buc box
316 {
317 if ((fiGdpbIdArray[uGdpb] & 0xF000) == 0xB000) {
318 BuildChannelsUidMapStar2A(uCh, uGbtx);
319 }
320 else {
321 BuildChannelsUidMapBuc(uCh, uGbtx);
322 }
323 break;
324 }
325 case 66: // Buc box
326 {
327 BuildChannelsUidMapBuc(uCh, uGbtx);
328 break;
329 }
330 case 69: {
332 BuildChannelsUidMapBuc(uCh, uGbtx);
334 uCh -= 80; // PAL, 2022/03/17: ?!?
335 BuildChannelsUidMapStar2(uCh, uGbtx);
336 uCh -= 80; // PAL, 2022/03/17: ?!?
337 break;
338 }
339 case -1: {
340 LOG(info) << " Found unused GBTX link at uCh = " << uCh;
341 uCh += 160;
342 break;
343 }
344 default: {
345 LOG(error) << "Invalid Tof Type specifier for GBTx " << std::setw(2) << uGbtx << ": " << fiRpcType[uGbtx];
346 }
347 } // switch (fiRpcType[uGbtx])
348 if ((uCh - uCh0) != fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4 / nbRobPerComp) {
349 LOG(fatal) << "Tof mapping error for Gbtx " << uGbtx << ", diff = " << uCh - uCh0 << ", expected "
351 << " with nbRobPerFlim = " << nbRobPerComp;
352 }
353 } // for (UInt_t uGbtx = 0; uGbtx < uNrOfGbtx; ++uGbtx)
354}
355// -------------------------------------------------------------------------
356void CbmMcbm2018TofPar::BuildChannelsUidMapCbm(UInt_t& uCh, UInt_t uGbtx)
357{
358 LOG(info) << " Map mTof box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
359 if (fiRpcSide[uGbtx] < 4) { // mTof modules
360 LOG(debug) << " Map mTof box " << fiModuleId[uGbtx] << " at GBTX - uCh = " << uCh;
361 const Int_t RpcMap[5] = {4, 2, 0, 3, 1};
362 const Int_t RpcMapInv[5] = {0, 2, 4, 1, 3};
363 for (Int_t iRpc = 0; iRpc < fiNrOfRpc[uGbtx]; iRpc++) {
364 Int_t iStrMax = 32;
365 UInt_t uChNext = 1;
366 Int_t iRpcMap = -1;
367 if (fiRpcSide[uGbtx] < 2) {
368 iRpcMap = RpcMap[iRpc];
369 }
370 else {
371 iRpcMap = RpcMapInv[iRpc];
372 }
373 for (Int_t iStr = 0; iStr < iStrMax; iStr++) {
374 Int_t iStrMap = iStr;
375
376 if (fiRpcSide[uGbtx] % 2 == 0) {
377 iStrMap = 31 - iStr;
378 }
379 if (fiModuleId[uGbtx] > -1)
380 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, fiRpcSide[uGbtx] % 2,
381 fiRpcType[uGbtx]);
382 else
383 fviRpcChUId[uCh] = 0;
384 // LOG(debug)<<Form("Map Ch %d to Address 0x%08x",uCh,fviRpcChUId[uCh]);
385 uCh += uChNext;
386 } // for (Int_t iStr = 0; iStr < iStrMax; iStr++)
387 } // for (Int_t iRpc = 0; iRpc < fiNrOfRpc[uGbtx]; iRpc++)
388 } // if (fiRpcSide[uGbtx] < 2)
389}
390// -------------------------------------------------------------------------
391void CbmMcbm2018TofPar::BuildChannelsUidMapStar(UInt_t& uCh, UInt_t uGbtx)
392{
393 if (fiRpcSide[uGbtx] < 2) {
394 // mTof modules
395 LOG(info) << "Start eTOF module side " << fiRpcSide[uGbtx] << " at " << uCh;
396 const Int_t RpcMap[3] = {0, 1, 2};
397 for (Int_t iRpc = 0; iRpc < fiNrOfRpc[uGbtx]; iRpc++) {
398 Int_t iStrMax = 32;
399 Int_t uChNext = 1;
400
401 for (Int_t iStr = 0; iStr < iStrMax; iStr++) {
402 Int_t iStrMap = iStr;
403 Int_t iRpcMap = RpcMap[iRpc];
404
405 if (fiRpcSide[uGbtx] == 0) iStrMap = 31 - iStr;
406 if (fiModuleId[uGbtx] > -1)
407 fviRpcChUId[uCh] =
408 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, fiRpcSide[uGbtx], fiRpcType[uGbtx]);
409 else
410 fviRpcChUId[uCh] = 0;
411 // LOG(debug)<<Form("Map Ch %d to Address 0x%08x",uCh,fviRpcChUId[uCh]);
412 uCh += uChNext;
413 }
414 }
415 }
416 uCh += 64;
417}
418// -------------------------------------------------------------------------
419void CbmMcbm2018TofPar::BuildChannelsUidMapBmon(UInt_t& uCh, UInt_t uGbtx)
420{
421 LOG(info) << " Map diamond at GBTX - uCh = " << uCh;
422 for (UInt_t uFee = 0; uFee < kuNbFeePerGbtx; ++uFee) {
423 for (UInt_t uFeeCh = 0; uFeeCh < kuNbChannelsPerFee; ++uFeeCh) {
425 if (0 == uFee && 1 == fiNrOfRpc[uGbtx]) {
426 switch (uCh % 8) {
427 case 0:
428 case 2:
429 case 4: {
434 UInt_t uChannelBmon = uFeeCh / 8 + 4 * fiRpcSide[uGbtx];
435 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], 0, uChannelBmon, 0, fiRpcType[uGbtx]);
436 LOG(info) << Form("Bmon channel: %u from GBTx %2u Fee %2u "
437 "Channel %2u, indx %d address %08x",
438 uChannelBmon, uGbtx, uFeeCh, uCh, uCh, fviRpcChUId[uCh]);
439 break;
440 } // Valid Bmon channel
441 default: {
442 fviRpcChUId[uCh] = 0;
443 } // Invalid Bmon channel
444 } // switch( uCh % 4 )
445 } // if( 0 == uFee )
446
447 uCh++;
448 } // for( UInt_t uCh = 0; uCh < kuNbFeePerGbtx; ++uCh )
449 } // for( UInt_t uFee = 0; uFee < kuNbChannelsPerFee; ++uFee )
450}
451// -------------------------------------------------------------------------
453{
454 LOG(info) << " Map 2022 diamond " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
455 for (UInt_t uGet4 = 0; uGet4 < kuNbGet4PerGbtx; ++uGet4) {
456 for (UInt_t uGet4Ch = 0; uGet4Ch < kuNbChannelsPerGet4; ++uGet4Ch) {
458 if (-1 < fiModuleId[uGbtx] && uGet4 < 32 && 0 == uGet4 % 4 && 0 == uGet4Ch) {
461 UInt_t uChannelBmon = (uGet4 / 8 + 4 * (uGbtx / 2)) % 16;
463 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], 0, uChannelBmon, fiRpcSide[uGbtx], 5);
464 LOG(info) << Form(" Bmon channel: %u side %u from GBTx %2u, "
465 "indx %d address %08x",
466 uChannelBmon, fiRpcSide[uGbtx], uGbtx, uCh, fviRpcChUId[uCh]);
467 } // Valid Bmon channel
468 else {
469 fviRpcChUId[uCh] = 0;
470 } // Invalid Bmon channel
471 uCh++;
472 } // for( UInt_t uCh = 0; uCh < kuNbFeePerGbtx; ++uCh )
473 } // for( UInt_t uFee = 0; uFee < kuNbChannelsPerFee; ++uFee )
474}
475// -------------------------------------------------------------------------
476void CbmMcbm2018TofPar::BuildChannelsUidMapCern(UInt_t& uCh, UInt_t /*uGbtx*/)
477{
478 LOG(info) << " Map CERN 20 gap at GBTX - uCh = " << uCh;
479 // clang-format off
480 const Int_t StrMap[32] = {0, 1, 2, 3, 4, 31, 5, 6, 7, 30, 8,
481 9, 10, 29, 11, 12, 13, 14, 28, 15, 16, 17,
482 18, 27, 26, 25, 24, 23, 22, 21, 20, 19};
483 // clang-format on
484 Int_t iModuleId = 0;
485 Int_t iModuleType = 7;
486 Int_t iRpcMap = 0;
487 for (Int_t iFeet = 0; iFeet < 2; iFeet++) {
488 for (Int_t iStr = 0; iStr < 32; iStr++) {
489 Int_t iStrMap = 31 - 12 - StrMap[iStr];
490 Int_t iSideMap = iFeet;
491 if (iStrMap < 20)
492 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(iModuleId, iRpcMap, iStrMap, iSideMap, iModuleType);
493 else
494 fviRpcChUId[uCh] = 0;
495 uCh++;
496 }
497 }
498 LOG(info) << " Map end CERN 20 gap at GBTX - uCh = " << uCh;
499}
500// -------------------------------------------------------------------------
501void CbmMcbm2018TofPar::BuildChannelsUidMapCera(UInt_t& uCh, UInt_t /*uGbtx*/)
502{
503 Int_t iModuleId = 0;
504 Int_t iModuleType = 8;
505 for (Int_t iRpc = 0; iRpc < 8; iRpc++) {
506 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(iModuleId, 7 - iRpc, 0, 0, iModuleType);
507 uCh++;
508 }
509 uCh += (24 + 2 * 32);
510 LOG(info) << " Map end ceramics box at GBTX - uCh = " << uCh;
511}
512// -------------------------------------------------------------------------
513void CbmMcbm2018TofPar::BuildChannelsUidMapStar2(UInt_t& uCh, UInt_t uGbtx)
514{
515 LOG(info) << " Map Star2 box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
516 const Int_t iRpc[5] = {1, -1, 1, 0, 0};
517 const Int_t iSide[5] = {1, -1, 0, 1, 0};
518 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
519 for (Int_t iStr = 0; iStr < 32; iStr++) {
520 Int_t iStrMap = iStr;
521 Int_t iRpcMap = iRpc[iFeet];
522 Int_t iSideMap = iSide[iFeet];
523 if (iSideMap == 0) iStrMap = 31 - iStr;
524 switch (fiRpcSide[uGbtx]) {
525 case 0:; break;
526 case 1:;
527 iRpcMap = 1 - iRpcMap; // swap counters
528 break;
529 case 2:
530 switch (iFeet) {
531 case 1:
532 iRpcMap = iRpc[4];
533 iSideMap = iSide[4];
534 iStrMap = 31 - iStrMap;
535 break;
536 case 4:
537 iRpcMap = iRpc[1];
538 iSideMap = iSide[1];
539 break;
540 default:;
541 }
542 break;
543 case 3: // direct beam 20210524
544 switch (iFeet) {
545 case 0:
546 iRpcMap = 0;
547 iSideMap = 0;
548 iStrMap = iStr;
549 break;
550 case 1:
551 iRpcMap = 0;
552 iSideMap = 1;
553 iStrMap = 31 - iStr;
554 break;
555 default: iSideMap = -1;
556 }
557 break;
558 }
559 if (iSideMap > -1)
560 fviRpcChUId[uCh] =
561 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
562 else
563 fviRpcChUId[uCh] = 0;
564 uCh++;
565 }
566 }
567}
568// -------------------------------------------------------------------------
569void CbmMcbm2018TofPar::BuildChannelsUidMapStar2A(UInt_t& uCh, UInt_t uGbtx)
570{
571 LOG(info) << " Map Star2A box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh << " for type "
572 << fiRpcType[uGbtx] << ", side " << fiRpcSide[uGbtx];
573 if (fiRpcSide[uGbtx] < 3) {
574 Int_t NrFeet = 2;
575 if (fiRpcSide[uGbtx] < 2) NrFeet = 1;
576 Int_t iFeet = 0;
577 for (; iFeet < NrFeet; iFeet++) {
578 for (Int_t iStr = 0; iStr < 32; iStr++) {
579 Int_t iStrMap = iStr;
580 Int_t iRpcMap = fiNrOfRpc[uGbtx];
581 Int_t iSideMap = fiRpcSide[uGbtx];
582 if (fiRpcSide[uGbtx] == 2) {
583 if (iFeet == 0)
584 iSideMap = 0;
585 else
586 iSideMap = 1;
587 }
588
589 if (fiRpcType[uGbtx] != 6)
590 if (iSideMap == 0) iStrMap = 31 - iStr;
591
592 if (iSideMap > -1)
593 fviRpcChUId[uCh] =
594 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
595 else
596 fviRpcChUId[uCh] = 0;
597
598 uCh++;
599 }
600 }
601 while (iFeet < 2) {
602 for (Int_t iStr = 0; iStr < 32; iStr++) {
603 fviRpcChUId[uCh] = 0;
604 uCh++;
605 }
606 iFeet++;
607 }
608 }
609 else {
610 if (fiRpcSide[uGbtx] == 3) {
611 int iSideMap = -1;
612 int iStrMap = -1;
613 int iRpcMap = -1;
614 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
615 for (Int_t iStr = 0; iStr < 32; iStr++) {
616 switch (iFeet) {
617 case 0: iSideMap = -1; break;
618 case 1:
619 iRpcMap = 0;
620 iStrMap = iStr;
621 iSideMap = 0;
622 break;
623 case 2:
624 iRpcMap = 0;
625 iStrMap = iStr;
626 iSideMap = 1;
627 break;
628 case 3:
629 iRpcMap = 1;
630 iStrMap = iStr;
631 iSideMap = 0;
632 break;
633 case 4:
634 iRpcMap = 1;
635 iStrMap = iStr;
636 iSideMap = 1;
637 break;
638 }
639 if (iSideMap > -1)
640 fviRpcChUId[uCh] =
641 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
642 else
643 fviRpcChUId[uCh] = 0;
644 uCh++;
645 }
646 }
647 }
648 else if (fiRpcSide[uGbtx] == 4) {
649 int iSideMap = -1;
650 int iStrMap = -1;
651 int iRpcMap = -1;
652 const int ConOff[8] = {0, 2, 4, 6, 7, 1, 3, 5}; //Get4 after Gbtx
653 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
654 for (Int_t iStr = 0; iStr < 32; iStr++) {
655 switch (iFeet) {
656 case 0: iSideMap = -1; break;
657 case 1:
658 iRpcMap = 0;
659 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
660 iSideMap = 0;
661 break;
662 case 2:
663 iRpcMap = 0;
664 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
665 iSideMap = 1;
666 break;
667 case 3:
668 iRpcMap = 1;
669 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
670 iSideMap = 1;
671 break;
672 case 4:
673 iRpcMap = 1;
674 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
675 iSideMap = 0;
676 break;
677 }
678 if (iSideMap > -1)
679 fviRpcChUId[uCh] =
680 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
681 else
682 fviRpcChUId[uCh] = 0;
683 uCh++;
684 }
685 }
686 }
687 }
688}
689
690// -------------------------------------------------------------------------
691void CbmMcbm2018TofPar::BuildChannelsUidMapBuc(UInt_t& uCh, UInt_t uGbtx)
692{
693 LOG(info) << " Map Buc box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
694
695 Int_t iModuleIdMap = fiModuleId[uGbtx];
696 const Int_t iRpc[5] = {0, -1, 0, 1, 1};
697 const Int_t iSide[5] = {1, -1, 0, 1, 0};
698 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
699 for (Int_t iStr = 0; iStr < 32; iStr++) {
700 Int_t iStrMap = iStr;
701 Int_t iRpcMap = iRpc[iFeet];
702 Int_t iSideMap = iSide[iFeet];
703 switch (fiRpcSide[uGbtx]) {
704 case 0:; break;
705 case 1: // HD cosmic 2019, Buc2018, v18n
706 iStrMap = 31 - iStr;
707 iRpcMap = 1 - iRpcMap;
708 break;
709 case 2: // v18m_cosmicHD
710 // iStrMap=31-iStr;
711 iSideMap = 1 - iSideMap;
712 break;
713 case 3: {
714 /*
715 iStrMap = 31 - iStr;
716 iRpcMap = 1 - iRpcMap;
717 iSideMap = 1 - iSideMap;
718 */
719 //const int ConOff[8]={0,5,1,6,2,7,3,4}; //Get44 on connector
720 const int ConOff[8] = {0, 2, 4, 6, 7, 1, 3, 5}; //Get4 after Gbtx
721 switch (iFeet) {
722 case 0: iSideMap = -1; break;
723 case 1:
724 iRpcMap = 0;
725 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
726 iSideMap = 0;
727 break;
728 case 2:
729 iRpcMap = 0;
730 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
731 iSideMap = 1;
732 break;
733 case 3:
734 iRpcMap = 1;
735 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
736 iSideMap = 1;
737 break;
738 case 4:
739 iRpcMap = 1;
740 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
741 iSideMap = 0;
742 break;
743 }
744 } break;
745 case 4: // HD cosmic 2019, Buc2018, v18o
746 iRpcMap = 1 - iRpcMap;
747 break;
748 case 5: // HD cosmic 2020, Buc2018, v20a
749 iStrMap = 31 - iStr;
750 break;
751 case 6: //BUC special
752 {
753 switch (fiModuleId[uGbtx]) {
754 case 0: iRpcMap = 0; break;
755 case 1: iRpcMap = 1; break;
756 }
757 if (iFeet % 2 == 1)
758 iModuleIdMap = 1;
759 else
760 iModuleIdMap = 0;
761
762 switch (iFeet) {
763 case 0:
764 case 3: iSideMap = 0; break;
765 case 1:
766 case 2: iSideMap = 1; break;
767 }
768 break;
769 }
770 case 8: {
771 // Special case for two channels in 2022
772 // Fallthrough to 7 for all other channels
773 if (2 == iFeet) {
774 if (7 == iStr) {
776 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(0, 0, 0, 0, 8);
777 uCh++;
778 continue;
779 }
780 else if (23 == iStr) {
782 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(1, 0, 0, 0, 8);
783 uCh++;
784 continue;
785 }
786 }
787 }
788 [[fallthrough]];
789 case 7: {
790 // clang-format off
791 /*
792 const Int_t iChMap[160]={
793 127, 126, 125, 124, 12, 13, 14, 15, 7, 6, 5, 4, 28, 29, 30, 31, 123, 122, 121, 120, 8, 9, 10, 11, 107, 106, 105, 104, 108, 109, 110, 111,
794 39, 38, 37, 36, 52, 53, 54, 55, 63, 62, 61, 60, 128, 129, 130, 131, 43, 42, 41, 40, 148, 149, 150, 151, 59, 58, 57, 56, 132, 133, 134, 135,
795 139, 138, 137, 136, 140, 141, 142, 143, 99, 98, 97, 96, 64, 65, 66, 67, 103, 102, 101, 100, 84, 85, 86, 87, 155, 154, 153, 152, 68, 69, 70, 71,
796 159, 158, 157, 156, 144, 145, 146, 147, 47, 46, 45, 44, 76, 77, 78, 79, 51, 50, 49, 48, 20, 21, 22, 23, 35, 34, 33, 32, 116, 117, 118, 119,
797 75, 74, 73, 72, 92, 93, 94, 95, 19, 18, 17, 16, 80, 81, 82, 83, 115, 114, 113, 112, 24, 25, 26, 27, 91, 90, 89, 88, 0, 1, 2, 3
798 };
799 */
800 const Int_t iChMap[160]={
801 124, 125, 126, 127, 12, 13, 14, 15, 4, 5, 6, 7, 28, 29, 30, 31, 120, 121, 122, 123, 8, 9, 10, 11, 104, 105, 106, 107, 108, 109, 110, 111,
802 36, 37, 38, 39, 52, 53, 54, 55, 60, 61, 62, 63, 128, 129, 130, 131, 40, 41, 42, 43, 148, 149, 150, 151, 56, 57, 58, 59, 132, 133, 134, 135,
803 136, 137, 138, 139, 140, 141, 142, 143, 96, 97, 98, 99, 64, 65, 66, 67, 100, 101, 102, 103, 84, 85, 86, 87, 152, 153, 154, 155, 68, 69, 70, 71,
804 156, 157, 158, 159, 144, 145, 146, 147, 44, 45, 46, 47, 76, 77, 78, 79, 48, 49, 50, 51, 20, 21, 22, 23, 32, 33, 34, 35, 116, 117, 118, 119,
805 75, 74, 73, 72, 92, 93, 94, 95, 16, 17, 18, 19, 80, 81, 82, 83, 115, 114, 113, 112, 24, 25, 26, 27, 88, 89, 90, 91, 0, 1, 2, 3
806 };
807 // clang-format on
808 Int_t iInd = iFeet * 32 + iStr;
809 Int_t i = 0;
810 for (; i < 160; i++) {
811 if (iInd == iChMap[i]) break;
812 }
813 iStrMap = i % 32;
814 Int_t iFeetInd = (i - iStrMap) / 32;
815 switch (iFeetInd) {
816 case 0: {
817 iRpcMap = 0;
818 iSideMap = 1;
819 break;
820 }
821 case 1: {
822 iRpcMap = 1;
823 iSideMap = 1;
824 break;
825 }
826 case 2: {
827 iRpcMap = 1;
828 iSideMap = 0;
829 break;
830 }
831 case 3: {
832 iRpcMap = 0;
833 iSideMap = 0;
834 break;
835 }
836 case 4: {
837 iSideMap = -1;
838 break;
839 }
840 }
841 iModuleIdMap = fiModuleId[uGbtx];
842 LOG(debug) << "Buc of GBTX " << uGbtx << " Ch " << uCh
843 << Form(", Feet %1d, Str %2d, Ind %3d, i %3d, FeetInd %1d, Rpc %1d, Side %1d, Str %2d ", iFeet,
844 iStr, iInd, i, iFeetInd, iRpcMap, iSideMap, iStrMap);
845 break;
846 }
847 default: {
848 break;
849 }
850 } // switch (fiRpcSide[uGbtx])
851 if (iSideMap > -1)
852 fviRpcChUId[uCh] =
853 CbmTofAddress::GetUniqueAddress(iModuleIdMap, iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx] % 10);
854 else
855 fviRpcChUId[uCh] = 0;
856
857 uCh++;
858 } // for (Int_t iStr = 0; iStr < 32; iStr++)
859 } // for (Int_t iFeet = 0; iFeet < 5; iFeet++)
860}
861// -------------------------------------------------------------------------
862
863
ClassImp(CbmConverterManager)
const UInt_t kuPaditoget4[kuNbChannelsPerFee]
Map from GET4 channel to PADI channel.
void BuildChannelsUidMapCera(UInt_t &uCh, UInt_t uGbtx)
static const uint32_t kuNbGet4PerGbtx
void BuildChannelsUidMapBuc(UInt_t &uCh, UInt_t uGbtx)
Int_t Get4IdxToElinkIdxA(UInt_t uGet4)
void putParams(FairParamList *)
void BuildChannelsUidMapBmon_2022(UInt_t &uCh, UInt_t uGbtx)
static const uint32_t kuNbGet4PerGdpb
CbmMcbm2018TofPar(const char *name="CbmMcbm2018TofPar", const char *title="Tof unpacker parameters", const char *context="Default")
std::vector< Int_t > fviRpcChUId
const UInt_t kuElinkToGet4[kuNbGet4PerGbtx]
Map from PADI channel to GET4 channel.
void BuildChannelsUidMapBmon(UInt_t &uCh, UInt_t uGbtx)
const UInt_t kuThrMeasCode[kuNbThrMeasPoints]
Int_t Get4IdxToElinkIdx(UInt_t uGet4)
Bool_t getParams(FairParamList *)
const UInt_t kuGet4ToElink[kuNbGet4PerGbtx]
const UInt_t kuElinkToGet4A[kuNbGet4PerGbtx]
void BuildChannelsUidMapStar2A(UInt_t &uCh, UInt_t uGbtx)
const UInt_t kuGet4ToElinkA[kuNbGet4PerGbtx]
void BuildChannelsUidMapStar(UInt_t &uCh, UInt_t uGbtx)
Double_t GetPadiThresholdVal(UInt_t uCode)
std::vector< Double_t > fvdPadiThrCodeToValue
const Double_t kdThrMeasVal[kuNbThrMeasPoints]
void BuildChannelsUidMapCbm(UInt_t &uCh, UInt_t uGbtx)
static const uint32_t kuNbThrMeasPoints
Int_t Get4ChanToPadiChan(UInt_t uChannelInFee)
void BuildChannelsUidMapCern(UInt_t &uCh, UInt_t uGbtx)
static const uint32_t kuNbFeePerGbtx
Int_t PadiChanToGet4Chan(UInt_t uChannelInFee)
void BuildChannelsUidMapStar2(UInt_t &uCh, UInt_t uGbtx)
static const uint32_t kuNbChannelsPerFee
Int_t ElinkIdxToGet4Idx(UInt_t uElink)
static constexpr UInt_t GetNrOfPadiThrCodes()
Int_t ElinkIdxToGet4IdxA(UInt_t uElink)
const UInt_t kuGet4topadi[kuNbChannelsPerFee]
Mapping in Readout chain PCBs.
static const uint32_t kuNbChannelsPerGet4
Readout chain.
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
const uint32_t kuChipIdMergedEpoch