CbmRoot
Loading...
Searching...
No Matches
CbmTrdParSpadic.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer], Pascal Raisig */
4
5#include "CbmTrdParSpadic.h"
6
7#include "CbmTrdDefs.h" // for eModuleTypes1D, eCbmTrdModuleType...
8
9#include <FairParamList.h> // for FairParamList
10#include <Logger.h> // for Logger, LOG
11
12#include <TArrayI.h> // for TArrayI
13#include <TString.h> // for Form
14
15#include <vector> // for vector
16
17Double_t CbmTrdParSpadic::fgSizeX = 6.0;
18Double_t CbmTrdParSpadic::fgSizeY = 3.0;
19Double_t CbmTrdParSpadic::fgSizeZ = 0.5;
20
21//___________________________________________________________________
22CbmTrdParSpadic::CbmTrdParSpadic(Int_t address, Int_t FebGrouping, Double_t x, Double_t y, Double_t z, size_t compId)
23 : CbmTrdParAsic(address, FebGrouping, x, y, z, compId)
24{
27}
28
29// ---- LoadParams ----------------------------------------------------
30void CbmTrdParSpadic::LoadParams(FairParamList* inList)
31{
32
33 // inList->print();
34
35 Int_t criId(-1);
36 Int_t crobId(-1);
37 Int_t crobNr(-1);
38 Int_t eLinkId(-1);
39 TArrayI channelAddresses(NSPADICCH);
40
41 Bool_t loadOk = kTRUE;
42
43 loadOk &= inList->fill(Form("%d-criId", fAddress), &criId);
44 loadOk &= inList->fill(Form("%d-crobId", fAddress), &crobId);
45 loadOk &= inList->fill(Form("%d-crobNr", fAddress), &crobNr);
46 loadOk &= inList->fill(Form("%d-eLinkId", fAddress), &eLinkId);
47 loadOk &= inList->fill(Form("%d-eLinkId", fAddress), &eLinkId);
48 loadOk &= inList->fill(Form("%d-channelAddresses", fAddress), &channelAddresses);
49 Int_t iAsicChannel(0);
50 for (auto& channelIt : fChannelAddresses) {
51 channelIt = channelAddresses[iAsicChannel];
52 iAsicChannel++;
53 }
54 loadOk &= !fChannelAddresses.empty();
55
56 if (!loadOk) {
57 LOG(error) << GetName() << Form("Params could not be correctly loaded for asic %d", fAddress);
58 fComponentId = 100098;
59 }
60 else {
61 fComponentId = CreateComponentId(criId, crobId, crobNr, eLinkId);
62 LOG(debug4) << GetName() << "Params correctly loaded for asic " << fAddress << " with componentId " << fComponentId;
63 }
64}
65
66// ---- CreateComponentId ---------------------------------------------
67size_t CbmTrdParSpadic::CreateComponentId(Int_t criId, Int_t crobId, Int_t nThCrobOnModule, Int_t eLinkId)
68{
69 size_t compId = criId * ECbmTrdComponentIdDecoding::kCriIdPosition
71 + nThCrobOnModule * ECbmTrdComponentIdDecoding::kCrobNrPosition + eLinkId;
72 return compId;
73}
74
75// ---- GetCriId ----------------------------------------------------
77
78// ---- GetCriId ----------------------------------------------------
79std::uint16_t CbmTrdParSpadic::GetCriId(size_t componentId)
80{
81 uint16_t returnId = (componentId / (ECbmTrdComponentIdDecoding::kCriIdPosition));
82 return returnId;
83}
84
85// ---- GetCrobId ----------------------------------------------------
87
88// ---- GetCrobId ----------------------------------------------------
89std::uint8_t CbmTrdParSpadic::GetCrobId(size_t componentId)
90{
91 std::uint8_t returnId(-1);
93 return returnId;
94}
95
96// ---- GetCrobNumber ----------------------------------------------------
98
99// ---- GetCrobNumber ----------------------------------------------------
100std::uint8_t CbmTrdParSpadic::GetCrobNumber(size_t componentId)
101{
102 std::uint8_t returnId(-1);
104 return returnId;
105}
106
107// ---- GetElinkId ----------------------------------------------------
108std::uint8_t CbmTrdParSpadic::GetElinkId(Int_t channelId) { return GetElinkId(fComponentId, channelId); }
109
110// ---- GetElinkId ----------------------------------------------------
111std::uint8_t CbmTrdParSpadic::GetElinkId(size_t componentId, Int_t channelId)
112{
113 std::uint8_t eLinkId(-1);
114
115 if (channelId > (NSPADICCH - 1)) // check for maximum number of spadic channels
116 {
117 LOG(error) << Form("CbmTrdParSpadic::GetElinkId(%d) - Incorrect channelId "
118 "(out of range %d > %d",
119 channelId, channelId, (NSPADICCH));
120 return eLinkId;
121 }
122
123 // eLinkId = channelId < 15 ? ((((componentId % ECbmTrdComponentIdDecoding::kCriIdPosition)
124 // % ECbmTrdComponentIdDecoding::kCrobIdPosition))
125 // % ECbmTrdComponentIdDecoding::kCrobNrPosition)
126 // :
127 // ((((componentId % ECbmTrdComponentIdDecoding::kCriIdPosition)
128 // % ECbmTrdComponentIdDecoding::kCrobIdPosition))
129 // % ECbmTrdComponentIdDecoding::kCrobNrPosition) + 1;
130 eLinkId = channelId < 15 ? (componentId % ECbmTrdComponentIdDecoding::kCrobNrPosition)
132 return eLinkId;
133}
134
135// ---- GetNasicsOnModule ----------------------------------------------------
136using namespace cbm::trd;
138{
139 switch (moduleType) {
140 case (Int_t) eModuleTypes1D::kHighChDensitySmallR: return 80; break;
141 case (Int_t) eModuleTypes1D::kLowChDensitySmallR: return 20; break;
142 case (Int_t) eModuleTypes1D::kHighChDensityLargeR: return 108; break;
143 case (Int_t) eModuleTypes1D::kLowChDensityLargeR: return 36; break;
144 case (Int_t) eModuleTypes1D::kMcbmModule:
145 return 24; // 24 is the maximum on a kMcbmModule it can also be less
146 break;
147 default: return 1; break;
148 }
149}
150
151// ---- GetNasicsPerCrob ----------------------------------------------------
153{
154 Int_t nAsicsPerCrob = GetNasicsOnModule(moduleType);
155 switch (moduleType) {
156 case (Int_t) eModuleTypes1D::kHighChDensitySmallR: nAsicsPerCrob /= 4; break;
157 case (Int_t) eModuleTypes1D::kLowChDensitySmallR: nAsicsPerCrob /= 1; break;
158 case (Int_t) eModuleTypes1D::kHighChDensityLargeR: nAsicsPerCrob /= 6; break;
159 case (Int_t) eModuleTypes1D::kLowChDensityLargeR: nAsicsPerCrob /= 2; break;
160 case (Int_t) eModuleTypes1D::kMcbmModule:
161 nAsicsPerCrob /= 1; // 24 is the maximum on a kMcbmModule it can also be less
162 break;
163 default: nAsicsPerCrob /= -1; break;
164 }
165 return nAsicsPerCrob;
166}
167
168// ---- GetAsicChAddress ----
169Int_t CbmTrdParSpadic::GetAsicChAddress(const Int_t asicChannel)
170{
172
173 Int_t address = -1;
174 // Channel mapping based on channels 0-15 on the odd eLink and 16-31 on the even eLink, check setting in the unpacker for your dataset
175
176 address = fVecSpadicChannels.at(asicChannel);
177 return address;
178}
179
180// ---- FillAsicChannelToElinkMap ----
181void CbmTrdParSpadic::FillAsicChannelToElinkMap(std::map<UInt_t, UInt_t>* map)
182{
183
184 // Only emplace pairs in an empty map.
185 if (map->size() > 0) return;
186
187 // This assumes that we have 2 elinks per SPADIC and that positions 00..15 in fVecSpadicChannels corresponds to the first elink while 16..31 corresponds to the second
188 UInt_t nthAsicElink = 0;
189 UInt_t rawchannel = 0;
190 for (size_t ichannel = 0; ichannel < fVecSpadicChannels.size(); ichannel++) {
191 rawchannel = fVecSpadicChannels[ichannel];
192 if (rawchannel >= NSPADICCH / 2) nthAsicElink = 1;
193 else
194 nthAsicElink = 0;
195 auto channelpair = std::pair<UInt_t, UInt_t>(ichannel, nthAsicElink);
196 map->emplace(channelpair);
197 }
198}
199
200// ---- GetElinkNr ----
201UInt_t CbmTrdParSpadic::GetElinkNr(Int_t moduleChannel, UInt_t nChannelsPerRow)
202{
204 UInt_t row = moduleChannel / nChannelsPerRow;
205 UInt_t column = moduleChannel % nChannelsPerRow;
206 UInt_t nelinksPerRow = nChannelsPerRow / (NSPADICCH / 2);
207
208 // each SPADIC has its channels distributed over 2 rows. Hence, we have (nspadics per row) * 2 elinks per row
209 // row 0 and 1, 2 and 3, ... use the same elinks
210 UInt_t nthelink = (column / (NSPADICCH / 2)) * 2 + (row / 2) * nelinksPerRow;
211
212 // up to now we do not know if we have the first or second elink on the asic. Hence, we get the channel number in the asic coordinates and check the asicChannel to elink map, wether it is on the first (0) or second (1) elink. And add the result.
213 UInt_t asicRow = row % 2;
214 UInt_t asicChannel = column % (NSPADICCH / 2) + (NSPADICCH / 2) * asicRow;
215 nthelink += fMapAsicChannelToElink.find(asicChannel)->second;
216
217 return nthelink;
218}
219
ClassImp(CbmConverterManager)
#define NSPADICCH
Definition of ASIC parameters.
std::vector< Int_t > fChannelAddresses
addresses of individual output channels
size_t fComponentId
Hardware component Id used for addressing For the digit decoding see ECbmTrdComponentIdDecoding....
Int_t fAddress
unique ASIC ID
Definition of SPADIC parameters.
static size_t CreateComponentId(Int_t criId, Int_t crobId, Int_t nThCrobOnModule, Int_t eLinkId)
Create the componentId from a given criId, crobId, eLinkId and the nThCrobOnModule count,...
const std::vector< UInt_t > fVecSpadicChannels
CbmTrdParSpadic(Int_t address=0, Int_t FebGrouping=-1, Double_t x=0, Double_t y=0, Double_t z=0, size_t compId=0)
void FillAsicChannelToElinkMap(std::map< UInt_t, UInt_t > *map)
Write the eLink to asicChannel mapping to the passed map.
static Double_t fgSizeZ
SPADIC half size in z [cm].
std::uint8_t GetCrobId()
static Double_t fgSizeX
SPADIC half size in x [cm].
std::uint16_t GetCriId()
std::uint8_t GetCrobNumber()
static Int_t GetNasicsPerCrob(Int_t moduleType)
Returns the number of asics per Crob on a given moduleType defined in eCbmTrdModuleTypes.
virtual void LoadParams(FairParamList *inList)
Loads the specific params for the spadic placed at fAddress, e.g. channel calibration parameters.
UInt_t GetElinkNr(Int_t moduleChannel, UInt_t nChannelsPerRow)
Return the number of the elink (counting started in channel order from bottom left to right) correlat...
static Int_t GetNasicsOnModule(Int_t moduleType)
Returns the number of asics on a given moduleType defined in eCbmTrdModuleTypes.
Int_t GetAsicChAddress(const Int_t asicChannel)
Returns the nth asic Channel in asic coordinates in single asic padplane coordinates....
static Double_t fgSizeY
SPADIC half size in y [cm].
static std::uint8_t GetElinkId(size_t componentId, Int_t channelId)
eLinkId for the given asicAddress and channelId (in the asic coordinates, i.e. 00....
std::map< UInt_t, UInt_t > fMapAsicChannelToElink