CbmRoot
CbmTrdParSpadic.cxx
Go to the documentation of this file.
1 #include "CbmTrdParSpadic.h"
2 
3 #include "CbmTrdDefs.h" // for eCbmTrdModuleTypes, eCbmTrdModuleType...
4 
5 #include <FairLogger.h> // for Logger, LOG
6 #include <FairParamList.h> // for FairParamList
7 
8 #include <TArrayI.h> // for TArrayI
9 #include <TString.h> // for Form
10 
11 #include <vector> // for vector
12 
13 Double_t CbmTrdParSpadic::fgSizeX = 6.0;
14 Double_t CbmTrdParSpadic::fgSizeY = 3.0;
15 Double_t CbmTrdParSpadic::fgSizeZ = 0.5;
16 
17 //___________________________________________________________________
19  Int_t FebGrouping,
20  Double_t x,
21  Double_t y,
22  Double_t z,
23  std::uint64_t compId)
24  : CbmTrdParAsic(address, FebGrouping, x, y, z, compId) {
26 }
27 
28 // ---- LoadParams ----------------------------------------------------
29 void CbmTrdParSpadic::LoadParams(FairParamList* inList) {
30 
31  // inList->print();
32 
33  Int_t criId(-1);
34  Int_t crobId(-1);
35  Int_t crobNr(-1);
36  Int_t eLinkId(-1);
37  TArrayI channelAddresses(NSPADICCH);
38 
39  Bool_t loadOk = kTRUE;
40 
41  loadOk &= inList->fill(Form("%d-criId", fAddress), &criId);
42  loadOk &= inList->fill(Form("%d-crobId", fAddress), &crobId);
43  loadOk &= inList->fill(Form("%d-crobNr", fAddress), &crobNr);
44  loadOk &= inList->fill(Form("%d-eLinkId", fAddress), &eLinkId);
45  loadOk &= inList->fill(Form("%d-eLinkId", fAddress), &eLinkId);
46  loadOk &=
47  inList->fill(Form("%d-channelAddresses", fAddress), &channelAddresses);
48  Int_t iAsicChannel(0);
49  for (auto& channelIt : fChannelAddresses) {
50  channelIt = channelAddresses[iAsicChannel];
51  iAsicChannel++;
52  }
53  loadOk &= !fChannelAddresses.empty();
54 
55  if (!loadOk) {
56  LOG(error) << GetName()
57  << Form("Params could not be correctly loaded for asic %d",
58  fAddress);
59  fComponentId = 100098;
60  } else {
61  fComponentId = CreateComponentId(criId, crobId, crobNr, eLinkId);
62  LOG(debug4) << GetName() << "Params correctly loaded for asic " << fAddress
63  << " with componentId " << fComponentId;
64  }
65 }
66 
67 // ---- CreateComponentId ---------------------------------------------
68 std::uint64_t CbmTrdParSpadic::CreateComponentId(Int_t criId,
69  Int_t crobId,
70  Int_t nThCrobOnModule,
71  Int_t eLinkId) {
72  std::uint64_t compId =
73  criId * ECbmTrdComponentIdDecoding::kCriIdPosition
74  + crobId * ECbmTrdComponentIdDecoding::kCrobIdPosition
75  + nThCrobOnModule * ECbmTrdComponentIdDecoding::kCrobNrPosition + eLinkId;
76  return compId;
77 }
78 
79 // ---- GetCriId ----------------------------------------------------
80 std::uint16_t CbmTrdParSpadic::GetCriId() { return GetCriId(fComponentId); }
81 
82 // ---- GetCriId ----------------------------------------------------
83 std::uint16_t CbmTrdParSpadic::GetCriId(std::uint64_t componentId) {
84  uint16_t returnId =
85  (componentId / (ECbmTrdComponentIdDecoding::kCriIdPosition));
86  return returnId;
87 }
88 
89 // ---- GetCrobId ----------------------------------------------------
91 
92 // ---- GetCrobId ----------------------------------------------------
93 std::uint8_t CbmTrdParSpadic::GetCrobId(std::uint64_t componentId) {
94  std::uint8_t returnId(-1);
95  returnId = ((componentId % ECbmTrdComponentIdDecoding::kCriIdPosition)
96  / ECbmTrdComponentIdDecoding::kCrobIdPosition);
97  return returnId;
98 }
99 
100 // ---- GetCrobNumber ----------------------------------------------------
102  return GetCrobNumber(fComponentId);
103 }
104 
105 // ---- GetCrobNumber ----------------------------------------------------
106 std::uint8_t CbmTrdParSpadic::GetCrobNumber(std::uint64_t componentId) {
107  std::uint8_t returnId(-1);
108  returnId = (componentId % ECbmTrdComponentIdDecoding::kCrobIdPosition
109  / ECbmTrdComponentIdDecoding::kCrobNrPosition);
110  return returnId;
111 }
112 
113 // ---- GetElinkId ----------------------------------------------------
114 std::uint8_t CbmTrdParSpadic::GetElinkId(Int_t channelId) {
115  return GetElinkId(fComponentId, channelId);
116 }
117 
118 // ---- GetElinkId ----------------------------------------------------
119 std::uint8_t CbmTrdParSpadic::GetElinkId(std::uint64_t componentId,
120  Int_t channelId) {
121  std::uint8_t eLinkId(-1);
122 
123  if (channelId
124  > (NSPADICCH - 1)) // check for maximum number of spadic channels
125  {
126  LOG(error) << Form("CbmTrdParSpadic::GetElinkId(%d) - Incorrect channelId "
127  "(out of range %d > %d",
128  channelId,
129  channelId,
130  (NSPADICCH));
131  return eLinkId;
132  }
133 
134  // eLinkId = channelId < 15 ? ((((componentId % ECbmTrdComponentIdDecoding::kCriIdPosition)
135  // % ECbmTrdComponentIdDecoding::kCrobIdPosition))
136  // % ECbmTrdComponentIdDecoding::kCrobNrPosition)
137  // :
138  // ((((componentId % ECbmTrdComponentIdDecoding::kCriIdPosition)
139  // % ECbmTrdComponentIdDecoding::kCrobIdPosition))
140  // % ECbmTrdComponentIdDecoding::kCrobNrPosition) + 1;
141  eLinkId = channelId < 15
142  ? (componentId % ECbmTrdComponentIdDecoding::kCrobNrPosition)
143  : (componentId % ECbmTrdComponentIdDecoding::kCrobNrPosition) + 1;
144  return eLinkId;
145 }
146 
147 // ---- GetNasicsOnModule ----------------------------------------------------
148 Int_t CbmTrdParSpadic::GetNasicsOnModule(Int_t moduleType) {
149  switch (moduleType) {
150  case (Int_t) eCbmTrdModuleTypes::kHighChDensitySmallR: return 80; break;
151  case (Int_t) eCbmTrdModuleTypes::kLowChDensitySmallR: return 20; break;
152  case (Int_t) eCbmTrdModuleTypes::kHighChDensityLargeR: return 108; break;
153  case (Int_t) eCbmTrdModuleTypes::kLowChDensityLargeR: return 36; break;
154  case (Int_t) eCbmTrdModuleTypes::kMcbmModule:
155  return 24; // 24 is the maximum on a kMcbmModule it can also be less
156  break;
157  default: return 1; break;
158  }
159 }
160 
161 // ---- GetNasicsPerCrob ----------------------------------------------------
162 Int_t CbmTrdParSpadic::GetNasicsPerCrob(Int_t moduleType) {
163  Int_t nAsicsPerCrob = GetNasicsOnModule(moduleType);
164  switch (moduleType) {
166  nAsicsPerCrob /= 4;
167  break;
169  nAsicsPerCrob /= 1;
170  break;
172  nAsicsPerCrob /= 6;
173  break;
175  nAsicsPerCrob /= 2;
176  break;
177  case (Int_t) eCbmTrdModuleTypes::kMcbmModule:
178  nAsicsPerCrob /=
179  1; // 24 is the maximum on a kMcbmModule it can also be less
180  break;
181  default: nAsicsPerCrob /= -1; break;
182  }
183  return nAsicsPerCrob;
184 }
185 
186 // ---- GetAsicChAddress ----
187 Int_t CbmTrdParSpadic::GetAsicChAddress(const Int_t asicChannel) {
189 
190  Int_t address = -1;
191  // 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
192 
193  address = fVecSpadicChannels.at(asicChannel);
194  return address;
195 }
196 
CbmTrdParSpadic::GetNasicsOnModule
static Int_t GetNasicsOnModule(Int_t moduleType)
Returns the number of asics on a given moduleType defined in eCbmTrdModuleTypes.
Definition: CbmTrdParSpadic.cxx:148
CbmTrdParAsic::fComponentId
std::uint64_t fComponentId
For the digit decoding see ECbmTrdComponentIdDecoding. nTh cRob on the module counted from top to bot...
Definition: CbmTrdParAsic.h:75
CbmTrdParSpadic::LoadParams
virtual void LoadParams(FairParamList *inList)
Loads the specific params for the spadic placed at fAddress, e.g. channel calibration parameters.
Definition: CbmTrdParSpadic.cxx:29
CbmTrdParAsic
Definition of ASIC parameters.
Definition: CbmTrdParAsic.h:15
eCbmTrdModuleTypes::kLowChDensitySmallR
@ kLowChDensitySmallR
CbmTrdParSpadic::GetCriId
std::uint16_t GetCriId()
Definition: CbmTrdParSpadic.cxx:80
CbmTrdParSpadic::GetElinkId
static std::uint8_t GetElinkId(std::uint64_t componentId, Int_t channelId)
eLinkId for the given asicAddress and channelId (in the asic coordinates, i.e. 00....
Definition: CbmTrdParSpadic.cxx:119
CbmTrdParSpadic::CreateComponentId
static std::uint64_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,...
Definition: CbmTrdParSpadic.cxx:68
eCbmTrdModuleTypes::kLowChDensityLargeR
@ kLowChDensityLargeR
CbmTrdParSpadic::GetNasicsPerCrob
static Int_t GetNasicsPerCrob(Int_t moduleType)
Returns the number of asics per Crob on a given moduleType defined in eCbmTrdModuleTypes.
Definition: CbmTrdParSpadic.cxx:162
CbmTrdParSpadic::GetAsicChAddress
Int_t GetAsicChAddress(const Int_t asicChannel)
Returns the nth asic Channel in asic coordinates in single asic padplane coordinates....
Definition: CbmTrdParSpadic.cxx:187
CbmTrdParSpadic.h
CbmTrdParSpadic::fgSizeY
static Double_t fgSizeY
SPADIC half size in y [cm].
Definition: CbmTrdParSpadic.h:78
CbmTrdParSpadic::fgSizeX
static Double_t fgSizeX
SPADIC half size in x [cm].
Definition: CbmTrdParSpadic.h:77
CbmTrdParSpadic::CbmTrdParSpadic
CbmTrdParSpadic(Int_t address=0, Int_t FebGrouping=-1, Double_t x=0, Double_t y=0, Double_t z=0, std::uint64_t compId=0)
Definition: CbmTrdParSpadic.cxx:18
CbmTrdParAsic::fChannelAddresses
std::vector< Int_t > fChannelAddresses
addresses of individual output channels
Definition: CbmTrdParAsic.h:77
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTrdParSpadic::fVecSpadicChannels
const std::vector< Int_t > fVecSpadicChannels
Definition: CbmTrdParSpadic.h:81
CbmTrdParSpadic::fgSizeZ
static Double_t fgSizeZ
SPADIC half size in z [cm].
Definition: CbmTrdParSpadic.h:79
NSPADICCH
#define NSPADICCH
Definition: CbmTrdParSpadic.h:4
CbmTrdDefs.h
eCbmTrdModuleTypes::kMcbmModule
@ kMcbmModule
eCbmTrdModuleTypes::kHighChDensityLargeR
@ kHighChDensityLargeR
CbmTrdParAsic::fAddress
Int_t fAddress
unique ASIC ID
Definition: CbmTrdParAsic.h:69
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
eCbmTrdModuleTypes::kHighChDensitySmallR
@ kHighChDensitySmallR
CbmTrdParSpadic::GetCrobId
std::uint8_t GetCrobId()
Definition: CbmTrdParSpadic.cxx:90
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTrdParSpadic
Definition of SPADIC parameters.
Definition: CbmTrdParSpadic.h:16
CbmTrdParSpadic::GetCrobNumber
std::uint8_t GetCrobNumber()
Definition: CbmTrdParSpadic.cxx:101