CbmRoot
Loading...
Searching...
No Matches
CbmTrdParModAsic.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Alexandru Bercuci [committer] */
4
5#include "CbmTrdParModAsic.h"
6
7#include "CbmTrdDigi.h" // for eCbmTrdAsicType
8#include "CbmTrdParAsic.h" // for CbmTrdParAsic
9#include "CbmTrdParFasp.h" // for CbmTrdParFasp, NFASPCH, CbmTrdParFasp...
10#include "CbmTrdParMod.h" // for CbmTrdParMod
11#include "CbmTrdParSpadic.h" // for CbmTrdParSpadic, NSPADICCH
12
13#include <FairParamList.h> // for FairParamList
14#include <Logger.h> // for Logger, LOG
15
16#include <TArrayI.h> // for TArrayI
17#include <TGenericClassInfo.h> // for TGenericClassInfo
18#include <TObjArray.h>
19#include <TObjString.h>
20#include <TString.h> // for Form
21#include <TSystem.h>
22
23#include <utility> // for pair
24
25#include <stdint.h> // for size_t
26#include <stdio.h> // for printf
27#include <string.h> // for strcmp
28
29using std::map;
30//_______________________________________________________________________________
31CbmTrdParModAsic::CbmTrdParModAsic(const char* name, const char* title)
32 : CbmTrdParMod(name, title)
33 , fType(8)
34 , fCrobAdd()
35 , fModPar()
36{
37}
38
39//_______________________________________________________________________________
41{
42 for (auto asic : fModPar)
43 delete asic.second;
44 fModPar.clear();
45}
46
47//_______________________________________________________________________________
49 const CbmTrdParFaspChannel*& rect) const
50{
51 if (pad < 0 || pad >= NFASPMOD * NFASPCH) return false;
52 for (int ich(0), ch(pad << 1); ich < 2; ich++, ch++) {
53 int faspAddress = GetAsicAddress(ch);
54 const CbmTrdParFasp* p = static_cast<const CbmTrdParFasp*>(GetAsicPar(faspAddress));
55 if (!p) {
56 LOG(debug) << GetName() << "::GetFaspChannelPar : Could not find FASP params for address=" << faspAddress
57 << " @ pad=" << pad;
58 continue;
59 }
60 if (ich) rect = p->GetChannel(pad, ich);
61 else
62 tilt = p->GetChannel(pad, ich);
63 }
64 return true;
65}
66
67//_______________________________________________________________________________
68Int_t CbmTrdParModAsic::GetAsicAddress(Int_t chAddress) const
69{
74 for (auto asic : fModPar) {
75 if (asic.second->QueryChannel(chAddress) >= 0) return asic.first;
76 }
77 return -1;
78}
79
80//_______________________________________________________________________________
81void CbmTrdParModAsic::GetAsicAddresses(std::vector<Int_t>* a) const
82{
86 for (auto asic : fModPar)
87 a->push_back(asic.first);
88}
89
90//_______________________________________________________________________________
92{
93 if (fModPar.find(address) == fModPar.end()) return nullptr;
94 return fModPar.at(address);
95}
96
97//_______________________________________________________________________________
99{
100 if (fModPar.find(address) == fModPar.end()) return nullptr;
101 return fModPar[address];
102}
103
104//_______________________________________________________________________________
106{
107 switch (fType) {
108 case 1: return 80;
109 case 3: return 20;
110 case 5: return 180;
111 case 7: return 36;
112 case 8: return 24;
113 case 9: return 180;
114 default:
115 LOG(warn) << GetName() << "::GetNofAsics : The chamber type " << fType << " has no mapping to ASICs. Skip.";
116 }
117 return 0;
118}
119
120//_______________________________________________________________________________
122{
123 switch (fType) {
124 case 1:
125 case 3:
126 case 5:
127 case 7:
130 default:
131 LOG(warn) << GetName() << "::GetAsicType : The chamber type " << fType << " has no mapping to ASICs. Skip.";
132 }
134}
135
136//_______________________________________________________________________________
137int CbmTrdParModAsic::HasEqId(uint16_t eq, uint8_t& lnk) const
138{
139 int idx(0);
140 for (auto add : fCrobAdd) {
141 if ((add & 0xffff) == eq) {
142 lnk = 0;
143 return idx;
144 }
145 else if (((add >> 16) & 0xffff) == eq) {
146 lnk = 1;
147 return idx;
148 }
149 idx++;
150 }
151 return -1;
152}
153
154//_______________________________________________________________________________
155void CbmTrdParModAsic::Print(Option_t* opt) const
156{
157 printf(" %s Asics[%d] Crobs[%lu]\n", GetName(), GetNofAsics(), fCrobAdd.size());
158 printf(" ");
159 for (auto eqid : fCrobAdd)
160 printf(" %d", eqid);
161 printf("\n");
162 if (strcmp(opt, "all") == 0) {
163 for (auto asic : fModPar)
164 asic.second->Print(opt);
165 }
166}
167
168//_______________________________________________________________________________
170{
171 int address = p->GetAddress();
172 if (fModPar.find(address) != fModPar.end()) {
173 if (address % 1000 == 999) return;
174 LOG(warn) << GetName() << "::SetAsicPar : The ASIC @ " << address << " already initialized. Skip.";
175 return;
176 }
177 fModPar[address] = p;
178}
179
180//_______________________________________________________________________________
182{
183 switch (fType) {
184 case 1:
185 case 3:
186 case 5:
187 case 7:
188 case 8: fCrobAdd.push_back(addresses[0]); break;
189 case 9:
190 for (int i(0); i < NCROBMOD; i++)
191 fCrobAdd.push_back(addresses[i]);
192 break;
193 default:
194 LOG(warn) << GetName() << "::SetCrobAddresses : The chamber type " << fType << " has no mapping to CROBs. Skip.";
195 }
196}
197
198
ClassImp(CbmConverterManager)
Definition of ASIC parameters.
virtual Int_t GetAddress() const
Definition of FASP channel calibration container.
Definition of FASP parameters.
const CbmTrdParFaspChannel * GetChannel(Int_t pad_address, UChar_t pair) const
Query the calibration for one FASP RO channel.
Describe TRD module ASIC settings (electronic gain, delays, etc)
virtual void GetAsicAddresses(std::vector< Int_t > *a) const
Query the ASICs in the module for their DAQ address. It applies to the list of ASICs....
virtual void SetCrobAddresses(int *addresses)
Initialize the CROB addresses as they are used in the DAQ.
uint8_t fType
type of chamber for current module
std::map< int, CbmTrdParAsic * > fModPar
list of ASIC params for module
virtual int GetNofAsics() const
Returns the DEFAULT number of ASICs for the current module.
CbmTrdParModAsic(const char *name="CbmTrdParModAsic", const char *title="Generic list of ASICs for TRD modules")
virtual CbmTrdDigi::eCbmTrdAsicType GetAsicType() const
Query the type of ASICs in the list.
virtual void clear()
Reset all parameters.
virtual Int_t GetAsicAddress(Int_t chAddress) const
Look for the ASIC which operates on a specific channel It applies to the list of ASICs.
virtual const CbmTrdParAsic * GetAsicPar(Int_t address) const
Look for the ASIC parameters of a given DAQ id It applies to the list of ASICs.
bool GetFaspChannelPar(int pad, const CbmTrdParFaspChannel *&tilt, const CbmTrdParFaspChannel *&rect) const
Access the calibration objects describing the two FASP channels allocated to a pad....
virtual int HasEqId(uint16_t eqid, uint8_t &lnk) const
Query the existence of an equipment (CROB) by HW id on the current module params.
virtual void Print(Option_t *opt="") const
std::vector< int32_t > fCrobAdd
ordered list of Crobs for current module
virtual void SetAsicPar(CbmTrdParAsic *p)
Initialize the ASIC parameters for DAQ id It applies to the list of ASICs.
Definition of generic parameters for one TRD module.
#define NCROBMOD
#define NFASPCH
#define NFASPMOD