CbmRoot
CbmMcbm2018MuchPar.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMcbm2018MuchPar source file -----
3 // ----- Created 25/07/17 by P.-A. Loizeau ----
4 // ----- Modified 07/12/18 Ajit Kumar -----
5 // -------------------------------------------------------------------------
6 
7 #include "CbmMcbm2018MuchPar.h"
8 
9 #include "FairDetParIo.h"
10 #include "FairLogger.h"
11 #include "FairParIo.h"
12 #include "FairParamList.h"
13 
14 #include "TMath.h"
15 #include "TString.h"
16 
17 using namespace std;
18 
19 // ----- Standard constructor ------------------------------------------
21  const char* title,
22  const char* context)
23  : FairParGenericSet(name, title, context)
24  , fuNrOfDpbs(0)
25  , fiDbpIdArray()
26  , fiCrobActiveFlag()
27  , fuFebsInGemA(0)
28  , fuFebsInGemB(0)
29  , fnFebsIdsArrayGemA()
30  , fnFebsIdsArrayGemB()
31  , fChannelsToPadXA()
32  , fChannelsToPadYA()
33  , fChannelsToPadXB()
34  , fChannelsToPadYB()
35  , fRealX()
36  , fRealPadSize() {
37  detName = "Much";
38 }
39 // -------------------------------------------------------------------------
40 
41 
42 // ----- Destructor ----------------------------------------------------
44 // -------------------------------------------------------------------------
45 
46 
47 // ----- Public method clear -------------------------------------------
49  status = kFALSE;
50  resetInputVersions();
51 }
52 // -------------------------------------------------------------------------
53 
54 // -------------------------------------------------------------------------
55 
56 void CbmMcbm2018MuchPar::putParams(FairParamList* l) {
57  if (!l) return;
58 
59  l->add("NrOfDpbs", fuNrOfDpbs);
60  l->add("DbpIdArray", fiDbpIdArray);
61  l->add("CrobActiveFlag", fiCrobActiveFlag);
62  l->add("NrOfFebsInGemA", fuFebsInGemA);
63  l->add("nFebsIdsArrayA", fnFebsIdsArrayGemA);
64  l->add("NrOfFebsInGemB", fuFebsInGemB);
65  l->add("nFebsIdsArrayB", fnFebsIdsArrayGemB);
66  l->add("ChannelsToPadXA", fChannelsToPadXA);
67  l->add("ChannelsToPadYA", fChannelsToPadYA);
68  l->add("ChannelsToPadXB", fChannelsToPadXB);
69  l->add("ChannelsToPadYB", fChannelsToPadYB);
70  l->add("RealX", fRealX);
71  l->add("PadSize", fRealPadSize);
72 }
73 
74 // -------------------------------------------------------------------------
75 
76 Bool_t CbmMcbm2018MuchPar::getParams(FairParamList* l) {
77 
78  if (!l) return kFALSE;
79 
80  if (!l->fill("NrOfDpbs", &fuNrOfDpbs)) return kFALSE;
81 
83  if (!l->fill("DbpIdArray", &fiDbpIdArray)) return kFALSE;
84 
86  if (!l->fill("CrobActiveFlag", &fiCrobActiveFlag)) return kFALSE;
87 
88  if (!l->fill("NrOfFebsInGemA", &fuFebsInGemA)) return kFALSE;
89 
91  if (!l->fill("nFebsIdsArrayA", &fnFebsIdsArrayGemA)) return kFALSE;
92 
93  if (!l->fill("NrOfFebsInGemB", &fuFebsInGemB)) return kFALSE;
94 
96  if (!l->fill("nFebsIdsArrayB", &fnFebsIdsArrayGemB)) return kFALSE;
97 
99  if (!l->fill("ChannelsToPadXA", &fChannelsToPadXA)) return kFALSE;
100 
102  if (!l->fill("ChannelsToPadYA", &fChannelsToPadYA)) return kFALSE;
103 
105  if (!l->fill("ChannelsToPadXB", &fChannelsToPadXB)) return kFALSE;
106 
108  if (!l->fill("ChannelsToPadYB", &fChannelsToPadYB)) return kFALSE;
109 
110  fRealX.Set(2232); // Number of Sectors in one GEM Module
111  if (!l->fill("RealX", &fRealX)) return kFALSE;
112 
113  fRealPadSize.Set(2232); // Number of Sectors in one GEM Module
114  if (!l->fill("PadSize", &fRealPadSize)) return kFALSE;
115 
116  return kTRUE;
117 }
118 // -------------------------------------------------------------------------
120  //LOG(info) <<" uElink "<<uElink<<" kuNbElinksPerCrob "<<kuNbElinksPerCrob;
121  if (uElink < kuNbElinksPerCrob)
122  return kiCrobMapElinkFebIdx[uElink];
123  else {
124  LOG(warning)
125  << "CbmMcbm2018MuchPar::ElinkIdxToFebIdx => Index out of bound, "
126  << "returning crazy value!";
127  return -1;
128  } // else of if( uElink < kuNbElinksPerCrob )
129 }
130 // -------------------------------------------------------------------------
132  if (uElink < kuNbElinksPerCrob)
133  return kuCrobMapElinkFebMuch[uElink];
134  else {
135  LOG(warning)
136  << "CbmMcbm2018MuchPar::ElinkIdxToAsicIdxFebMuch => Index out of bound, "
137  << "returning crazy value!";
138  return 0xFFFF;
139  } // else of if( uElink < kuNbElinksPerCrob )
140 }
141 // -------------------------------------------------------------------------
142 UInt_t CbmMcbm2018MuchPar::GetDpbId(UInt_t uDpbIdx) {
143  if (uDpbIdx < fuNrOfDpbs)
144  return fiDbpIdArray[uDpbIdx];
145  else {
146  LOG(warning) << "CbmMcbm2018MuchPar::GetDpbId => Index out of bound, "
147  << "returning crazy value!";
148  return 0xFFFFFFFF;
149  } // else of if( uDpbIdx < fuNrOfDpbs )
150 }
151 Bool_t CbmMcbm2018MuchPar::IsCrobActive(UInt_t uDpbIdx, UInt_t uCrobIdx) {
152  if (uDpbIdx < fuNrOfDpbs) {
153  if (uCrobIdx < kuNbCrobsPerDpb)
154  return 0 < fiCrobActiveFlag[uDpbIdx * kuNbCrobsPerDpb + uCrobIdx]
155  ? kTRUE
156  : kFALSE;
157  else {
158  LOG(warning)
159  << "CbmMcbm2018MuchPar::IsCrobActive => Crob Index out of bound, "
160  << "returning default inactive!";
161  return kFALSE;
162  } // else of if( uCrobIdx < kuNbCrobsPerDpb )
163  } // if( uDpbIdx < fuNrOfDpbs )
164  else {
165  LOG(warning)
166  << "CbmMcbm2018MuchPar::IsCrobActive => Dpb Index out of bound, "
167  << "returning default inactive!";
168  return kFALSE;
169  } // else of if( uDpbIdx < fuNrOfDpbs )
170 }
171 Bool_t CbmMcbm2018MuchPar::IsFebActive(UInt_t uFebInSystIdx) {
172 
173  if (uFebInSystIdx < GetNrOfFebs()) {
175  return kTRUE;
176  } // if( uFebInSystIdx < GetNrOfFebs() )
177  else {
178  LOG(warning)
179  << "CbmMcbm2018MuchPar::IsFebActive => Feb Index out of bound, "
180  << "returning default inactive!";
181  return kFALSE;
182  } // else of if( uFebInSystIdx < GetNrOfFebs() )
183 }
184 Bool_t CbmMcbm2018MuchPar::IsFebActive(UInt_t uDpbIdx,
185  UInt_t uCrobIdx,
186  UInt_t uFebIdx) {
187  if (uDpbIdx < fuNrOfDpbs) {
188  if (uCrobIdx < kuNbCrobsPerDpb) {
189  if (uFebIdx < kuNbFebsPerCrob) {
190  UInt_t uIdx =
191  (uDpbIdx * kuNbCrobsPerDpb + uCrobIdx) * kuNbFebsPerCrob + uFebIdx;
192  return IsFebActive(uIdx);
193  } // if( uFebIdx < kuNbFebsPerCrob )
194  else {
195  LOG(warning)
196  << "CbmMcbm2018MuchPar::IsFebActive => Feb Index out of bound, "
197  << "returning default inactive!";
198  return kFALSE;
199  } // else of if( uFebIdx < kuNbCrobsPerDpb )
200  } // if( uCrobIdx < kuNbCrobsPerDpb )
201  else {
202  LOG(warning)
203  << "CbmMcbm2018MuchPar::IsFebActive => Crob Index out of bound, "
204  << "returning default inactive!";
205  return kFALSE;
206  } // else of if( uCrobIdx < kuNbCrobsPerDpb )
207  } // if( uDpbIdx < fuNrOfDpbs )
208  else {
209  LOG(warning)
210  << "CbmMcbm2018MuchPar::IsFebActive => Dpb Index out of bound, "
211  << "returning default inactive!";
212  return kFALSE;
213  } // else of if( uDpbIdx < fuNrOfDpbs )
214 }
215 Short_t CbmMcbm2018MuchPar::GetPadXA(UShort_t febid, UShort_t channelid) {
216  if (fChannelsToPadXA.GetSize()
217  <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
218  LOG(debug) << "CbmMcbm2018MuchPar::GetPadXA => Index out of bounds: "
219  << ((febid * kuNbChanPerAsic) + channelid) << " VS "
220  << fChannelsToPadXA.GetSize() << " (" << febid << " and "
221  << channelid << ")";
222  return -2;
223  } // if( fChannelsToPadXA.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
224 
225 
226  return fChannelsToPadXA[(febid * kuNbChanPerAsic) + channelid];
227 }
228 Short_t CbmMcbm2018MuchPar::GetPadYA(UShort_t febid, UShort_t channelid) {
229  if (fChannelsToPadXA.GetSize()
230  <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
231  LOG(debug) << "CbmMcbm2018MuchPar::GetPadYA => Index out of bounds: "
232  << ((febid * kuNbChanPerAsic) + channelid) << " VS "
233  << fChannelsToPadYA.GetSize() << " (" << febid << " and "
234  << channelid << ")";
235  return -2;
236  } // if( fChannelsToPadXA.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
237 
238  return fChannelsToPadYA[(febid * kuNbChanPerAsic) + channelid];
239 }
240 
241 Short_t CbmMcbm2018MuchPar::GetPadXB(UShort_t febid, UShort_t channelid) {
242  if (fChannelsToPadXB.GetSize()
243  <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
244  LOG(debug) << "CbmMcbm2018MuchPar::GetPadXB => Index out of bounds: "
245  << ((febid * kuNbChanPerAsic) + channelid) << " VS "
246  << fChannelsToPadXB.GetSize() << " (" << febid << " and "
247  << channelid << ")";
248  return -2;
249  } // if( fChannelsToPadXB.GetSize () <= static_cast< Int_t >( (febid*kuNbChanPerAsic)+channelid ) )
250 
251 
252  return fChannelsToPadXB[(febid * kuNbChanPerAsic) + channelid];
253 }
254 Short_t CbmMcbm2018MuchPar::GetPadYB(UShort_t febid, UShort_t channelid) {
255  if (fChannelsToPadXB.GetSize()
256  <= static_cast<Int_t>((febid * kuNbChanPerAsic) + channelid)) {
257  LOG(debug) << "CbmMcbm2018MuchPar::GetPadYB => Index out of bounds: "
258  << ((febid * kuNbChanPerAsic) + channelid) << " VS "
259  << fChannelsToPadYB.GetSize() << " (" << febid << " and "
260  << 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 UInt_t CbmMcbm2018MuchPar::GetFebId(UInt_t uAsicIdx) {
268  //LOG(info)<<" fnFebsIdsArrayGemA.GetSize() "<<fnFebsIdsArrayGemA.GetSize()<<" fnFebsIdsArrayGemB.GetSize()"<<fnFebsIdsArrayGemB.GetSize();
269  if (uAsicIdx >= GetNrOfFebsInGemA()) {
270  if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInGemB())
271  return fnFebsIdsArrayGemB[uAsicIdx % GetNrOfFebsInGemA()];
272  else {
273  LOG(error) << "CbmMcbm2018MuchPar::GetFebId => Index out of bounds: "
274  << uAsicIdx << " VS " << GetNrOfFebsInGemA() << " and "
275  << GetNrOfFebsInGemB() << " => Returning crazy value!!!";
276  return 10000 * (GetNrOfFebsInGemA() + GetNrOfFebsInGemB());
277  } // else of if( ( uAsicIdx % GetNrOfFebsInGemA() ) < GetNrOfFebsInGemB() )
278  } // if(uAsicIdx >= GetNrOfFebsInGemA())
279  else
280  return fnFebsIdsArrayGemA[uAsicIdx];
281 }
282 
283 UInt_t CbmMcbm2018MuchPar::GetModule(UInt_t uAsicIdx) {
284  if (uAsicIdx >= GetNrOfFebsInGemA()) {
285  if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInGemB())
286  return 1;
287  else
288  return 2;
289  } // if(uAsicIdx >= GetNrOfFebsInGemA())
290  else
291  return 0;
292 }
293 
294 Double_t CbmMcbm2018MuchPar::GetRealX(Int_t SectorIndex) {
295 
296  //LOG(info)<<" fChannelsToPadX.GetSize() "<<fChannelsToPadX.GetSize();
297  if (SectorIndex < 0 || SectorIndex <= 97) {
298  LOG(debug) << "CbmMcbm2018MuchPar::GetRealX => Index out of bounds: ";
299  return -2;
300  } // if( fChannelsToPadY.GetSize () <= (febid*kuNbChanPerAsic)+channelid )
301 
302  return fRealX[SectorIndex];
303 }
304 
305 Double_t CbmMcbm2018MuchPar::GetRealPadSize(Int_t SectorIndex) {
306 
307  //LOG(info)<<" fChannelsToPadX.GetSize() "<<fChannelsToPadX.GetSize();
308  if (SectorIndex < 0 || SectorIndex <= 97) {
309  LOG(debug) << "CbmMcbm2018MuchPar::GetRealX => Index out of bounds: ";
310  return -2;
311  } // if( fChannelsToPadY.GetSize () <= (febid*kuNbChanPerAsic)+channelid )
312 
313  return fRealPadSize[SectorIndex];
314 }
315 
316 Double_t CbmMcbm2018MuchPar::GetRealX(Int_t Channel, Int_t Sector) {
317  Int_t PadIndex = Channel + 97 * Sector;
318  if (Channel < 0 || Sector < 0) return -2;
319  if (fRealX.GetSize() <= PadIndex) {
320  LOG(info) << "CbmMcbm2018MuchPar::GetRealX => Index out of bounds: "
321  << Channel << " " << Sector << " " << PadIndex;
322  return -1;
323  } // if( fRealX.Size() <= PadIndex )
324 
325  return fRealX[PadIndex];
326 }
327 Double_t CbmMcbm2018MuchPar::GetRealPadSize(Int_t Channel, Int_t Sector) {
328  Int_t PadIndex = Channel + 97 * Sector;
329  if (Channel < 0 || Sector < 0) return -2;
330  if (fRealPadSize.GetSize() <= PadIndex) {
331  LOG(info) << "CbmMcbm2018MuchPar::GetRealPadSize => Index out of bounds: "
332  << Channel << " " << Sector << " " << PadIndex;
333  return -1;
334  } // if( fRealPadSize.Size() <= PadIndex )
335 
336  return fRealPadSize[PadIndex];
337 }
338 
CbmMcbm2018MuchPar::fChannelsToPadYA
TArrayI fChannelsToPadYA
Definition: CbmMcbm2018MuchPar.h:164
CbmMcbm2018MuchPar::IsCrobActive
Bool_t IsCrobActive(UInt_t uDpbIdx, UInt_t uCrobIdx)
Definition: CbmMcbm2018MuchPar.cxx:151
CbmMcbm2018MuchPar::GetNrOfFebsInGemB
UInt_t GetNrOfFebsInGemB()
Definition: CbmMcbm2018MuchPar.h:75
CbmMcbm2018MuchPar::kuNbCrobsPerDpb
static const UInt_t kuNbCrobsPerDpb
Constants.
Definition: CbmMcbm2018MuchPar.h:98
CbmMcbm2018MuchPar::fChannelsToPadXA
TArrayI fChannelsToPadXA
Definition: CbmMcbm2018MuchPar.h:162
CbmMcbm2018MuchPar.h
CbmMcbm2018MuchPar::GetDpbId
UInt_t GetDpbId(UInt_t uDpbIdx)
Definition: CbmMcbm2018MuchPar.cxx:142
CbmMcbm2018MuchPar::fiCrobActiveFlag
TArrayI fiCrobActiveFlag
Definition: CbmMcbm2018MuchPar.h:154
CbmMcbm2018MuchPar::GetRealPadSize
Double_t GetRealPadSize(Int_t)
Definition: CbmMcbm2018MuchPar.cxx:305
CbmMcbm2018MuchPar::GetNrOfFebsInGemA
UInt_t GetNrOfFebsInGemA()
Definition: CbmMcbm2018MuchPar.h:74
CbmMcbm2018MuchPar::kuNbElinksPerCrob
static const UInt_t kuNbElinksPerCrob
Definition: CbmMcbm2018MuchPar.h:99
CbmMcbm2018MuchPar::fuFebsInGemB
UInt_t fuFebsInGemB
Definition: CbmMcbm2018MuchPar.h:156
CbmMcbm2018MuchPar::CbmMcbm2018MuchPar
CbmMcbm2018MuchPar(const char *name="CbmMcbm2018MuchPar", const char *title="Much parameters", const char *context="Default")
Definition: CbmMcbm2018MuchPar.cxx:20
CbmMcbm2018MuchPar::ElinkIdxToAsicIdxFebMuch
UInt_t ElinkIdxToAsicIdxFebMuch(UInt_t uElink)
Definition: CbmMcbm2018MuchPar.cxx:131
CbmMcbm2018MuchPar::GetPadYA
Short_t GetPadYA(UShort_t febid, UShort_t channelid)
Definition: CbmMcbm2018MuchPar.cxx:228
CbmMcbm2018MuchPar::IsFebActive
Bool_t IsFebActive(UInt_t uFebInSystIdx)
Definition: CbmMcbm2018MuchPar.cxx:171
CbmMcbm2018MuchPar::fRealPadSize
TArrayD fRealPadSize
Definition: CbmMcbm2018MuchPar.h:172
CbmMcbm2018MuchPar::putParams
void putParams(FairParamList *)
Definition: CbmMcbm2018MuchPar.cxx:56
CbmMcbm2018MuchPar::GetRealX
Double_t GetRealX(Int_t)
Definition: CbmMcbm2018MuchPar.cxx:294
CbmMcbm2018MuchPar::fRealX
TArrayD fRealX
Definition: CbmMcbm2018MuchPar.h:170
CbmMcbm2018MuchPar::fChannelsToPadYB
TArrayI fChannelsToPadYB
Definition: CbmMcbm2018MuchPar.h:168
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMcbm2018MuchPar::kuNbFebsPerCrob
static const UInt_t kuNbFebsPerCrob
Definition: CbmMcbm2018MuchPar.h:101
CbmMcbm2018MuchPar::fnFebsIdsArrayGemA
TArrayI fnFebsIdsArrayGemA
Definition: CbmMcbm2018MuchPar.h:158
CbmMcbm2018MuchPar::~CbmMcbm2018MuchPar
virtual ~CbmMcbm2018MuchPar()
Definition: CbmMcbm2018MuchPar.cxx:43
CbmMcbm2018MuchPar::GetPadXB
Short_t GetPadXB(UShort_t febid, UShort_t channelid)
Definition: CbmMcbm2018MuchPar.cxx:241
CbmMcbm2018MuchPar
Definition: CbmMcbm2018MuchPar.h:19
CbmMcbm2018MuchPar::fnFebsIdsArrayGemB
TArrayI fnFebsIdsArrayGemB
Definition: CbmMcbm2018MuchPar.h:160
CbmMcbm2018MuchPar::GetNrOfFebs
UInt_t GetNrOfFebs()
Definition: CbmMcbm2018MuchPar.h:71
CbmMcbm2018MuchPar::GetPadYB
Short_t GetPadYB(UShort_t febid, UShort_t channelid)
Definition: CbmMcbm2018MuchPar.cxx:254
CbmMcbm2018MuchPar::getParams
Bool_t getParams(FairParamList *)
Definition: CbmMcbm2018MuchPar.cxx:76
CbmMcbm2018MuchPar::kuCrobMapElinkFebMuch
const UInt_t kuCrobMapElinkFebMuch[kuNbElinksPerCrob]
Definition: CbmMcbm2018MuchPar.h:120
CbmMcbm2018MuchPar::ElinkIdxToFebIdx
Int_t ElinkIdxToFebIdx(UInt_t uElink)
Definition: CbmMcbm2018MuchPar.cxx:119
CbmMcbm2018MuchPar::GetModule
UInt_t GetModule(UInt_t)
Definition: CbmMcbm2018MuchPar.cxx:283
CbmMcbm2018MuchPar::clear
virtual void clear()
Definition: CbmMcbm2018MuchPar.cxx:48
CbmMcbm2018MuchPar::fuNrOfDpbs
UInt_t fuNrOfDpbs
Map from eLink index to ASIC index within CROB ( 0 to kuNbFebsPerCrob * kuNbAsicPerFeb )
Definition: CbmMcbm2018MuchPar.h:150
CbmMcbm2018MuchPar::fuFebsInGemA
UInt_t fuFebsInGemA
Definition: CbmMcbm2018MuchPar.h:155
CbmMcbm2018MuchPar::kiCrobMapElinkFebIdx
const Int_t kiCrobMapElinkFebIdx[kuNbElinksPerCrob]
Map from eLink index to ASIC index within CROB ( 0 to kuNbFebsPerCrob * kuNbAsicPerFeb )
Definition: CbmMcbm2018MuchPar.h:140
CbmMcbm2018MuchPar::fiDbpIdArray
TArrayI fiDbpIdArray
Definition: CbmMcbm2018MuchPar.h:152
CbmMcbm2018MuchPar::kuNbChanPerAsic
static const UInt_t kuNbChanPerAsic
Definition: CbmMcbm2018MuchPar.h:105
CbmMcbm2018MuchPar::GetFebId
UInt_t GetFebId(UInt_t)
Definition: CbmMcbm2018MuchPar.cxx:267
CbmMcbm2018MuchPar::GetPadXA
Short_t GetPadXA(UShort_t febid, UShort_t channelid)
Definition: CbmMcbm2018MuchPar.cxx:215
CbmMcbm2018MuchPar::fChannelsToPadXB
TArrayI fChannelsToPadXB
Definition: CbmMcbm2018MuchPar.h:166