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
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// -------------------------------------------------------------------------
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}
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 3: // intended fall-through
272 case 2: // intended fall-through
273 case 1: // intended fall-through
274 case 0: {
275 // CBM modules
276 BuildChannelsUidMapCbm(uCh, uGbtx);
277 break;
278 }
279 case 11: {
280 // STAR eTOF modules
281 BuildChannelsUidMapStar(uCh, uGbtx);
282 break;
283 }
284 case 5: {
286 BuildChannelsUidMapBmon(uCh, uGbtx);
287 break;
288 }
289 case 99: {
292 break;
293 }
294 case 78: {
295 // cern-20-gap + ceramic module
296 BuildChannelsUidMapCern(uCh, uGbtx);
297 }
298 [[fallthrough]]; // fall through is intended
299 case 8: // ceramics
300 {
301 BuildChannelsUidMapCera(uCh, uGbtx);
302 break;
303 }
304 case 4: // intended fallthrough
305 [[fallthrough]];
306 case 7: [[fallthrough]];
307 case 9: // Star2 boxes
308 {
309 if ((fiGdpbIdArray[uGdpb] & 0xF000) == 0xB000) {
310 BuildChannelsUidMapStar2A(uCh, uGbtx);
311 }
312 else {
313 BuildChannelsUidMapStar2(uCh, uGbtx);
314 }
315 break;
316 }
317 case 6: // Buc box
318 {
319 if ((fiGdpbIdArray[uGdpb] & 0xF000) == 0xB000) {
320 BuildChannelsUidMapStar2A(uCh, uGbtx);
321 }
322 else {
323 BuildChannelsUidMapBuc(uCh, uGbtx);
324 }
325 break;
326 }
327 case 66: // Buc box
328 {
329 BuildChannelsUidMapBuc(uCh, uGbtx);
330 break;
331 }
332 case 69: {
334 BuildChannelsUidMapBuc(uCh, uGbtx);
336 uCh -= 80; // PAL, 2022/03/17: ?!?
337 BuildChannelsUidMapStar2(uCh, uGbtx);
338 uCh -= 80; // PAL, 2022/03/17: ?!?
339 break;
340 }
341 case -1: {
342 LOG(info) << " Found unused GBTX link at uCh = " << uCh;
343 uCh += 160;
344 break;
345 }
346 default: {
347 LOG(error) << "Invalid Tof Type specifier for GBTx " << std::setw(2) << uGbtx << ": " << fiRpcType[uGbtx];
348 }
349 } // switch (fiRpcType[uGbtx])
350 if ((uCh - uCh0) != fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4 / nbRobPerComp) {
351 LOG(fatal) << "Tof mapping error for Gbtx " << uGbtx << ", diff = " << uCh - uCh0 << ", expected "
353 << " with nbRobPerFlim = " << nbRobPerComp;
354 }
355 } // for (UInt_t uGbtx = 0; uGbtx < uNrOfGbtx; ++uGbtx)
356}
357// -------------------------------------------------------------------------
358void CbmMcbm2018TofPar::BuildChannelsUidMapCbm(UInt_t& uCh, UInt_t uGbtx)
359{
360 LOG(info) << " Map mTof box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
361 if (fiRpcSide[uGbtx] < 4) { // mTof modules
362 LOG(debug) << " Map mTof box " << fiModuleId[uGbtx] << " at GBTX - uCh = " << uCh;
363 const Int_t RpcMap[5] = {4, 2, 0, 3, 1};
364 const Int_t RpcMapInv[5] = {0, 2, 4, 1, 3};
365 for (Int_t iRpc = 0; iRpc < fiNrOfRpc[uGbtx]; iRpc++) {
366 Int_t iStrMax = 32;
367 UInt_t uChNext = 1;
368 Int_t iRpcMap = -1;
369 if (fiRpcSide[uGbtx] < 2) {
370 iRpcMap = RpcMap[iRpc];
371 }
372 else {
373 iRpcMap = RpcMapInv[iRpc];
374 }
375 for (Int_t iStr = 0; iStr < iStrMax; iStr++) {
376 Int_t iStrMap = iStr;
377
378 if (fiRpcSide[uGbtx] % 2 == 0) {
379 iStrMap = 31 - iStr;
380 }
381 if (fiModuleId[uGbtx] > -1)
382 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, fiRpcSide[uGbtx] % 2,
383 fiRpcType[uGbtx]);
384 else
385 fviRpcChUId[uCh] = 0;
386 // LOG(debug)<<Form("Map Ch %d to Address 0x%08x",uCh,fviRpcChUId[uCh]);
387 uCh += uChNext;
388 } // for (Int_t iStr = 0; iStr < iStrMax; iStr++)
389 } // for (Int_t iRpc = 0; iRpc < fiNrOfRpc[uGbtx]; iRpc++)
390 } // if (fiRpcSide[uGbtx] < 2)
391}
392// -------------------------------------------------------------------------
393void CbmMcbm2018TofPar::BuildChannelsUidMapStar(UInt_t& uCh, UInt_t uGbtx)
394{
395 if (fiRpcSide[uGbtx] < 2) {
396 // mTof modules
397 LOG(info) << "Start eTOF module side " << fiRpcSide[uGbtx] << " at " << uCh;
398 const Int_t RpcMap[3] = {0, 1, 2};
399 for (Int_t iRpc = 0; iRpc < fiNrOfRpc[uGbtx]; iRpc++) {
400 Int_t iStrMax = 32;
401 Int_t uChNext = 1;
402
403 for (Int_t iStr = 0; iStr < iStrMax; iStr++) {
404 Int_t iStrMap = iStr;
405 Int_t iRpcMap = RpcMap[iRpc];
406
407 if (fiRpcSide[uGbtx] == 0) iStrMap = 31 - iStr;
408 if (fiModuleId[uGbtx] > -1)
409 fviRpcChUId[uCh] =
410 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, fiRpcSide[uGbtx], fiRpcType[uGbtx]);
411 else
412 fviRpcChUId[uCh] = 0;
413 // LOG(debug)<<Form("Map Ch %d to Address 0x%08x",uCh,fviRpcChUId[uCh]);
414 uCh += uChNext;
415 }
416 }
417 }
418 uCh += 64;
419}
420// -------------------------------------------------------------------------
421void CbmMcbm2018TofPar::BuildChannelsUidMapBmon(UInt_t& uCh, UInt_t uGbtx)
422{
423 LOG(info) << " Map diamond at GBTX " << uGbtx << " - uCh = " << uCh;
424 for (UInt_t uFee = 0; uFee < kuNbFeePerGbtx; ++uFee) {
425 for (UInt_t uFeeCh = 0; uFeeCh < kuNbChannelsPerFee; ++uFeeCh) {
427 if (0 == uFee && 1 == fiNrOfRpc[uGbtx]) {
428 switch (uCh % 8) {
429 case 0:
430 case 2:
431 case 4: {
436 UInt_t uChannelBmon = uFeeCh / 8 + 4 * fiRpcSide[uGbtx];
437 fiRpcType[uGbtx] = 5; //for compatibility with TOF convention
438 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], 0, uChannelBmon, 0, fiRpcType[uGbtx]);
439 LOG(info) << Form("Bmon channel: %u from GBTx %2u Fee %2u "
440 "Channel %2u, indx %d address %08x",
441 uChannelBmon, uGbtx, uFeeCh, uCh, uCh, fviRpcChUId[uCh]);
442 break;
443 } // Valid Bmon channel
444 default: {
445 fviRpcChUId[uCh] = 0;
446 } // Invalid Bmon channel
447 } // switch( uCh % 4 )
448 } // if( 0 == uFee )
449
450 uCh++;
451 } // for( UInt_t uCh = 0; uCh < kuNbFeePerGbtx; ++uCh )
452 } // for( UInt_t uFee = 0; uFee < kuNbChannelsPerFee; ++uFee )
453}
454// -------------------------------------------------------------------------
456{
457 LOG(info) << " Map 2022 diamond " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
458 for (UInt_t uGet4 = 0; uGet4 < kuNbGet4PerGbtx; ++uGet4) {
459 for (UInt_t uGet4Ch = 0; uGet4Ch < kuNbChannelsPerGet4; ++uGet4Ch) {
461 if (-1 < fiModuleId[uGbtx] && uGet4 < 32 && 0 == uGet4 % 4 && 0 == uGet4Ch) {
464 UInt_t uChannelBmon = (uGet4 / 8 + 4 * (uGbtx / 2)) % 16;
466 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], 0, uChannelBmon, fiRpcSide[uGbtx], 5);
467 LOG(info) << Form(" Bmon channel: %u side %u from GBTx %2u, "
468 "indx %d address %08x",
469 uChannelBmon, fiRpcSide[uGbtx], uGbtx, uCh, fviRpcChUId[uCh]);
470 } // Valid Bmon channel
471 else {
472 fviRpcChUId[uCh] = 0;
473 } // Invalid Bmon channel
474 uCh++;
475 } // for( UInt_t uCh = 0; uCh < kuNbFeePerGbtx; ++uCh )
476 } // for( UInt_t uFee = 0; uFee < kuNbChannelsPerFee; ++uFee )
477}
478// -------------------------------------------------------------------------
479void CbmMcbm2018TofPar::BuildChannelsUidMapCern(UInt_t& uCh, UInt_t /*uGbtx*/)
480{
481 LOG(info) << " Map CERN 20 gap at GBTX - uCh = " << uCh;
482 // clang-format off
483 const Int_t StrMap[32] = {0, 1, 2, 3, 4, 31, 5, 6, 7, 30, 8,
484 9, 10, 29, 11, 12, 13, 14, 28, 15, 16, 17,
485 18, 27, 26, 25, 24, 23, 22, 21, 20, 19};
486 // clang-format on
487 Int_t iModuleId = 0;
488 Int_t iModuleType = 7;
489 Int_t iRpcMap = 0;
490 for (Int_t iFeet = 0; iFeet < 2; iFeet++) {
491 for (Int_t iStr = 0; iStr < 32; iStr++) {
492 Int_t iStrMap = 31 - 12 - StrMap[iStr];
493 Int_t iSideMap = iFeet;
494 if (iStrMap < 20)
495 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(iModuleId, iRpcMap, iStrMap, iSideMap, iModuleType);
496 else
497 fviRpcChUId[uCh] = 0;
498 uCh++;
499 }
500 }
501 LOG(info) << " Map end CERN 20 gap at GBTX - uCh = " << uCh;
502}
503// -------------------------------------------------------------------------
504void CbmMcbm2018TofPar::BuildChannelsUidMapCera(UInt_t& uCh, UInt_t /*uGbtx*/)
505{
506 Int_t iModuleId = 0;
507 Int_t iModuleType = 8;
508 for (Int_t iRpc = 0; iRpc < 8; iRpc++) {
509 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(iModuleId, 7 - iRpc, 0, 0, iModuleType);
510 uCh++;
511 }
512 uCh += (24 + 4 * 32); //for 2024 FSD
513 //uCh += (24 + 2 * 32);
514 LOG(info) << " Map end ceramics box at GBTX - uCh = " << uCh;
515}
516// -------------------------------------------------------------------------
517void CbmMcbm2018TofPar::BuildChannelsUidMapStar2(UInt_t& uCh, UInt_t uGbtx)
518{
519 LOG(info) << " Map Star2 box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
520 const Int_t iRpc[5] = {1, -1, 1, 0, 0};
521 const Int_t iSide[5] = {1, -1, 0, 1, 0};
522 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
523 for (Int_t iStr = 0; iStr < 32; iStr++) {
524 Int_t iStrMap = iStr;
525 Int_t iRpcMap = iRpc[iFeet];
526 Int_t iSideMap = iSide[iFeet];
527 if (iSideMap == 0) iStrMap = 31 - iStr;
528 switch (fiRpcSide[uGbtx]) {
529 case 0:; break;
530 case 1:;
531 iRpcMap = 1 - iRpcMap; // swap counters
532 break;
533 case 2:
534 switch (iFeet) {
535 case 1:
536 iRpcMap = iRpc[4];
537 iSideMap = iSide[4];
538 iStrMap = 31 - iStrMap;
539 break;
540 case 4:
541 iRpcMap = iRpc[1];
542 iSideMap = iSide[1];
543 break;
544 default:;
545 }
546 break;
547 case 3: // direct beam 20210524
548 switch (iFeet) {
549 case 0:
550 iRpcMap = 0;
551 iSideMap = 0;
552 iStrMap = iStr;
553 break;
554 case 1:
555 iRpcMap = 0;
556 iSideMap = 1;
557 iStrMap = 31 - iStr;
558 break;
559 default: iSideMap = -1;
560 }
561 break;
562 }
563 if (iSideMap > -1)
564 fviRpcChUId[uCh] =
565 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
566 else
567 fviRpcChUId[uCh] = 0;
568 uCh++;
569 }
570 }
571}
572// -------------------------------------------------------------------------
573void CbmMcbm2018TofPar::BuildChannelsUidMapStar2A(UInt_t& uCh, UInt_t uGbtx)
574{
575 LOG(info) << " Map Star2A box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh << " for type "
576 << fiRpcType[uGbtx] << ", side " << fiRpcSide[uGbtx];
577 if (fiRpcSide[uGbtx] < 3) {
578 Int_t NrFeet = 2;
579 if (fiRpcSide[uGbtx] < 2) NrFeet = 1;
580 Int_t iFeet = 0;
581 for (; iFeet < NrFeet; iFeet++) {
582 for (Int_t iStr = 0; iStr < 32; iStr++) {
583 Int_t iStrMap = iStr;
584 Int_t iRpcMap = fiNrOfRpc[uGbtx];
585 Int_t iSideMap = fiRpcSide[uGbtx];
586 if (fiRpcSide[uGbtx] == 2) {
587 if (iFeet == 0)
588 iSideMap = 0;
589 else
590 iSideMap = 1;
591 }
592
593 if (fiRpcType[uGbtx] != 6)
594 if (iSideMap == 0) iStrMap = 31 - iStr;
595
596 if (iSideMap > -1)
597 fviRpcChUId[uCh] =
598 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
599 else
600 fviRpcChUId[uCh] = 0;
601
602 uCh++;
603 }
604 }
605 while (iFeet < 2) {
606 for (Int_t iStr = 0; iStr < 32; iStr++) {
607 fviRpcChUId[uCh] = 0;
608 uCh++;
609 }
610 iFeet++;
611 }
612 }
613 else {
614 if (fiRpcSide[uGbtx] == 3) {
615 int iSideMap = -1;
616 int iStrMap = -1;
617 int iRpcMap = -1;
618 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
619 for (Int_t iStr = 0; iStr < 32; iStr++) {
620 switch (iFeet) {
621 case 0: iSideMap = -1; break;
622 case 1:
623 iRpcMap = 0;
624 iStrMap = iStr;
625 iSideMap = 0;
626 break;
627 case 2:
628 iRpcMap = 0;
629 iStrMap = iStr;
630 iSideMap = 1;
631 break;
632 case 3:
633 iRpcMap = 1;
634 iStrMap = iStr;
635 iSideMap = 0;
636 break;
637 case 4:
638 iRpcMap = 1;
639 iStrMap = iStr;
640 iSideMap = 1;
641 break;
642 }
643 if (iSideMap > -1)
644 fviRpcChUId[uCh] =
645 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
646 else
647 fviRpcChUId[uCh] = 0;
648 uCh++;
649 }
650 }
651 }
652 else if (fiRpcSide[uGbtx] == 4) {
653 int iSideMap = -1;
654 int iStrMap = -1;
655 int iRpcMap = -1;
656 const int ConOff[8] = {0, 2, 4, 6, 7, 1, 3, 5}; //Get4 after Gbtx
657 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
658 for (Int_t iStr = 0; iStr < 32; iStr++) {
659 switch (iFeet) {
660 case 0: iSideMap = -1; break;
661 case 1:
662 iRpcMap = 0;
663 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
664 iSideMap = 0;
665 break;
666 case 2:
667 iRpcMap = 0;
668 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
669 iSideMap = 1;
670 break;
671 case 3:
672 iRpcMap = 1;
673 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
674 iSideMap = 1;
675 break;
676 case 4:
677 iRpcMap = 1;
678 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
679 iSideMap = 0;
680 break;
681 }
682 if (iSideMap > -1)
683 fviRpcChUId[uCh] =
684 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
685 else
686 fviRpcChUId[uCh] = 0;
687 uCh++;
688 }
689 }
690 }
691 else if (fiRpcSide[uGbtx] == 5) {
692 int iSideMap = -1;
693 int iStrMap = -1;
694 int iRpcMap = -1;
695 const int ConOff[8] = {0, 2, 4, 6, 7, 1, 3, 5}; //Get4 after Gbtx
696 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
697 for (Int_t iStr = 0; iStr < 32; iStr++) {
698 switch (iFeet) {
699 case 0: iSideMap = -1; break;
700 case 1:
701 iRpcMap = 0;
702 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
703 iStrMap = 31 - iStrMap;
704 iSideMap = 1;
705 break;
706 case 2:
707 iRpcMap = 0;
708 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
709 iStrMap = 31 - iStrMap;
710 iSideMap = 0;
711 break;
712 case 3:
713 iRpcMap = 1;
714 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
715 iStrMap = 31 - iStrMap;
716 iSideMap = 0;
717 break;
718 case 4:
719 iRpcMap = 1;
720 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
721 iStrMap = 31 - iStrMap;
722 iSideMap = 1;
723 break;
724 }
725 if (iSideMap > -1)
726 fviRpcChUId[uCh] =
727 CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]);
728 else
729 fviRpcChUId[uCh] = 0;
730 uCh++;
731 }
732 }
733 }
734 }
735}
736
737void CbmMcbm2018TofPar::BuildChannelsUidMapBuc(UInt_t& uCh, UInt_t uGbtx)
738{
739 LOG(info) << " Map Buc box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh;
740
741 Int_t iModuleIdMap = fiModuleId[uGbtx];
742 const Int_t iRpc[5] = {0, -1, 0, 1, 1};
743 const Int_t iSide[5] = {1, -1, 0, 1, 0};
744 for (Int_t iFeet = 0; iFeet < 5; iFeet++) {
745 for (Int_t iStr = 0; iStr < 32; iStr++) {
746 Int_t iStrMap = iStr;
747 Int_t iRpcMap = iRpc[iFeet];
748 Int_t iSideMap = iSide[iFeet];
749 switch (fiRpcSide[uGbtx]) {
750 case 0:; break;
751 case 1: // HD cosmic 2019, Buc2018, v18n
752 iStrMap = 31 - iStr;
753 iRpcMap = 1 - iRpcMap;
754 break;
755 case 2: // v18m_cosmicHD
756 // iStrMap=31-iStr;
757 iSideMap = 1 - iSideMap;
758 break;
759 case 3: {
760 /*
761 iStrMap = 31 - iStr;
762 iRpcMap = 1 - iRpcMap;
763 iSideMap = 1 - iSideMap;
764 */
765 //const int ConOff[8]={0,5,1,6,2,7,3,4}; //Get44 on connector
766 const int ConOff[8] = {0, 2, 4, 6, 7, 1, 3, 5}; //Get4 after Gbtx
767 switch (iFeet) {
768 case 0: iSideMap = -1; break;
769 case 1:
770 iRpcMap = 0;
771 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
772 iSideMap = 0;
773 break;
774 case 2:
775 iRpcMap = 0;
776 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
777 iSideMap = 1;
778 break;
779 case 3:
780 iRpcMap = 1;
781 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
782 iSideMap = 1;
783 break;
784 case 4:
785 iRpcMap = 1;
786 iStrMap = 3 - iStr % 4 + 4 * ConOff[iStr / 4];
787 iSideMap = 0;
788 break;
789 }
790 } break;
791 case 4: // HD cosmic 2019, Buc2018, v18o
792 iRpcMap = 1 - iRpcMap;
793 break;
794 case 5: // Buc2025, mCBM
795 iRpcMap = 1 - iRpcMap;
796 //iStrMap = 31 - iStr;
797 iSideMap = 1 - iSideMap;
798 break;
799 case 55: // HD cosmic 2020, Buc2018, v20a
800 iStrMap = 31 - iStr;
801 break;
802 case 6: //BUC special
803 {
804 switch (fiModuleId[uGbtx]) {
805 case 0: iRpcMap = 0; break;
806 case 1: iRpcMap = 1; break;
807 }
808 if (iFeet % 2 == 1)
809 iModuleIdMap = 1;
810 else
811 iModuleIdMap = 0;
812
813 switch (iFeet) {
814 case 0:
815 case 3: iSideMap = 0; break;
816 case 1:
817 case 2: iSideMap = 1; break;
818 }
819 break;
820 }
821 case 8: {
822 // Special case for two channels in 2022
823 // Fallthrough to 7 for all other channels
824 if (2 == iFeet) {
825 if (7 == iStr) {
827 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(0, 0, 0, 0, 8);
828 uCh++;
829 continue;
830 }
831 else if (23 == iStr) {
833 fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(1, 0, 0, 0, 8);
834 uCh++;
835 continue;
836 }
837 }
838 }
839 [[fallthrough]];
840 case 7: {
841 // clang-format off
842 /*
843 const Int_t iChMap[160]={
844 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,
845 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,
846 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,
847 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,
848 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
849 };
850 */
851 const Int_t iChMap[160]={
852 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,
853 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,
854 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,
855 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,
856 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
857 };
858 // clang-format on
859 Int_t iInd = iFeet * 32 + iStr;
860 Int_t i = 0;
861 for (; i < 160; i++) {
862 if (iInd == iChMap[i]) break;
863 }
864 iStrMap = i % 32;
865 Int_t iFeetInd = (i - iStrMap) / 32;
866 switch (iFeetInd) {
867 case 0: {
868 iRpcMap = 0;
869 iSideMap = 1;
870 break;
871 }
872 case 1: {
873 iRpcMap = 1;
874 iSideMap = 1;
875 break;
876 }
877 case 2: {
878 iRpcMap = 1;
879 iSideMap = 0;
880 break;
881 }
882 case 3: {
883 iRpcMap = 0;
884 iSideMap = 0;
885 break;
886 }
887 case 4: {
888 iSideMap = -1;
889 break;
890 }
891 }
892 iModuleIdMap = fiModuleId[uGbtx];
893 LOG(debug) << "Buc of GBTX " << uGbtx << " Ch " << uCh
894 << Form(", Feet %1d, Str %2d, Ind %3d, i %3d, FeetInd %1d, Rpc %1d, Side %1d, Str %2d ", iFeet,
895 iStr, iInd, i, iFeetInd, iRpcMap, iSideMap, iStrMap);
896 break;
897 }
898 default: {
899 break;
900 }
901 } // switch (fiRpcSide[uGbtx])
902 if (iSideMap > -1)
903 fviRpcChUId[uCh] =
904 CbmTofAddress::GetUniqueAddress(iModuleIdMap, iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx] % 10);
905 else
906 fviRpcChUId[uCh] = 0;
907
908 uCh++;
909 } // for (Int_t iStr = 0; iStr < 32; iStr++)
910 } // for (Int_t iFeet = 0; iFeet < 5; iFeet++)
911}
912// -------------------------------------------------------------------------
913
914
ClassImp(CbmConverterManager)
int Int_t
bool Bool_t
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