]>
Commit | Line | Data |
---|---|---|
42650ece | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ////////////////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // The AliDAQ class is responsible for handling all the information about // | |
19 | // Data Acquisition configuration. It defines the detector indexing, // | |
20 | // the number of DDLs and LDCs per detector. // | |
21 | // The number of LDCs per detector is used only in the simulation in order // | |
22 | // to define the configuration of the dateStream application. Therefore the // | |
23 | // numbers in the corresponding array can be changed without affecting the // | |
24 | // rest of the aliroot code. // | |
25 | // The equipment ID (DDL ID) is an integer (32-bit) number defined as: // | |
26 | // Equipment ID = (detectorID << 8) + DDLIndex // | |
27 | // where the detectorID is given by fgkDetectorName array and DDLIndex is // | |
28 | // the index of the corresponding DDL inside the detector partition. // | |
29 | // Due to DAQ/HLT limitations, the ddl indexes should be consequtive, or // | |
30 | // at least without big gaps in between. // | |
31 | // The sub-detector code use only this class in the simulation and reading // | |
32 | // of the raw data. // | |
33 | // // | |
34 | // cvetan.cheshkov@cern.ch 2006/06/09 // | |
35 | // // | |
36 | ////////////////////////////////////////////////////////////////////////////// | |
37 | ||
38 | #include <TClass.h> | |
39 | #include <TString.h> | |
40 | ||
41 | #include "AliDAQ.h" | |
42 | #include "AliLog.h" | |
43 | ||
44 | ClassImp(AliDAQ) | |
45 | ||
46 | const char* AliDAQ::fgkDetectorName[AliDAQ::kNDetectors] = { | |
47 | "ITSSPD", | |
48 | "ITSSDD", | |
49 | "ITSSSD", | |
50 | "TPC", | |
51 | "TRD", | |
52 | "TOF", | |
ababa197 | 53 | "HMPID", |
42650ece | 54 | "PHOS", |
55 | "CPV", | |
56 | "PMD", | |
57 | "MUONTRK", | |
58 | "MUONTRG", | |
59 | "FMD", | |
ababa197 | 60 | "T0", |
42650ece | 61 | "VZERO", // Name to be changed to V0 ? |
62 | "ZDC", | |
b384f8a4 | 63 | "ACORDE", |
42650ece | 64 | "TRG", |
65 | "EMCAL", | |
7034c7a7 | 66 | "DAQ_TEST", |
42650ece | 67 | "HLT" |
68 | }; | |
69 | ||
70 | Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = { | |
71 | 20, | |
72 | 24, | |
73 | 16, | |
74 | 216, | |
75 | 18, | |
76 | 72, | |
77 | 20, | |
78 | 20, | |
79 | 10, | |
80 | 6, | |
81 | 20, | |
82 | 2, | |
83 | 3, | |
84 | 1, | |
85 | 1, | |
86 | 1, | |
87 | 1, | |
88 | 1, | |
89 | 24, | |
7034c7a7 | 90 | 1, |
42650ece | 91 | 10 |
92 | }; | |
93 | ||
94 | Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = { | |
42650ece | 95 | 4, |
96 | 4, | |
97 | 4, | |
0d45e170 | 98 | 36, |
42650ece | 99 | 3, |
100 | 12, | |
101 | 4, | |
102 | 4, | |
103 | 2, | |
104 | 1, | |
105 | 4, | |
106 | 1, | |
107 | 1, | |
108 | 0.5, | |
109 | 0.5, | |
110 | 1, | |
111 | 1, | |
112 | 1, | |
0d45e170 | 113 | 4, |
7034c7a7 | 114 | 1, |
0d45e170 | 115 | 5 |
42650ece | 116 | }; |
117 | ||
118 | AliDAQ::AliDAQ(const AliDAQ& source) : | |
119 | TObject(source) | |
120 | { | |
121 | // Copy constructor | |
122 | // Nothing to be done | |
123 | } | |
124 | ||
125 | AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */) | |
126 | { | |
127 | // Assignment operator | |
128 | // Nothing to be done | |
129 | return *this; | |
130 | } | |
131 | ||
132 | Int_t AliDAQ::DetectorID(const char *detectorName) | |
133 | { | |
134 | // Return the detector index | |
135 | // corresponding to a given | |
136 | // detector name | |
137 | TString detStr = detectorName; | |
138 | ||
139 | Int_t iDet; | |
140 | for(iDet = 0; iDet < kNDetectors; iDet++) { | |
141 | if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0) | |
142 | break; | |
143 | } | |
144 | if (iDet == kNDetectors) { | |
145 | AliErrorClass(Form("Invalid detector name: %s !",detectorName)); | |
146 | return -1; | |
147 | } | |
148 | return iDet; | |
149 | } | |
150 | ||
151 | const char *AliDAQ::DetectorName(Int_t detectorID) | |
152 | { | |
153 | // Returns the name of particular | |
154 | // detector identified by its index | |
155 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
156 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
157 | return ""; | |
158 | } | |
159 | return fgkDetectorName[detectorID]; | |
160 | } | |
161 | ||
162 | Int_t AliDAQ::DdlIDOffset(const char *detectorName) | |
163 | { | |
164 | // Returns the DDL ID offset | |
165 | // for a given detector | |
166 | Int_t detectorID = DetectorID(detectorName); | |
167 | if (detectorID < 0) | |
168 | return -1; | |
169 | ||
170 | return DdlIDOffset(detectorID); | |
171 | } | |
172 | ||
173 | Int_t AliDAQ::DdlIDOffset(Int_t detectorID) | |
174 | { | |
175 | // Returns the DDL ID offset | |
176 | // for a given detector identified | |
177 | // by its index | |
178 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
179 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
180 | return -1; | |
181 | } | |
7034c7a7 | 182 | // HLT has a DDL offset = 30 |
183 | if (detectorID == (kNDetectors-1)) return (kHLTId << 8); | |
184 | ||
42650ece | 185 | return (detectorID << 8); |
186 | } | |
187 | ||
362c9d61 | 188 | const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex) |
42650ece | 189 | { |
190 | // Returns the detector name for | |
191 | // a given DDL ID | |
362c9d61 | 192 | ddlIndex = -1; |
193 | Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex); | |
42650ece | 194 | if (detectorID < 0) |
195 | return ""; | |
196 | ||
197 | return DetectorName(detectorID); | |
198 | } | |
199 | ||
362c9d61 | 200 | Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex) |
42650ece | 201 | { |
362c9d61 | 202 | // Returns the detector ID and |
203 | // the ddl index within the | |
204 | // detector range for | |
205 | // a given input DDL ID | |
42650ece | 206 | Int_t detectorID = ddlID >> 8; |
7034c7a7 | 207 | |
208 | // HLT | |
209 | if (detectorID == kHLTId) detectorID = kNDetectors-1; | |
210 | ||
42650ece | 211 | if (detectorID < 0 || detectorID >= kNDetectors) { |
212 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
213 | return -1; | |
214 | } | |
362c9d61 | 215 | ddlIndex = ddlID & 0xFF; |
42650ece | 216 | if (ddlIndex >= fgkNumberOfDdls[detectorID]) { |
217 | AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d", | |
218 | ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID)); | |
362c9d61 | 219 | ddlIndex = -1; |
42650ece | 220 | return -1; |
221 | } | |
222 | return detectorID; | |
223 | } | |
224 | ||
225 | Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex) | |
226 | { | |
227 | // Returns the DDL ID starting from | |
228 | // the detector name and the DDL | |
229 | // index inside the detector | |
230 | Int_t detectorID = DetectorID(detectorName); | |
231 | if (detectorID < 0) | |
232 | return -1; | |
233 | ||
234 | return DdlID(detectorID,ddlIndex); | |
235 | } | |
236 | ||
237 | Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex) | |
238 | { | |
239 | // Returns the DDL ID starting from | |
240 | // the detector ID and the DDL | |
241 | // index inside the detector | |
242 | Int_t ddlID = DdlIDOffset(detectorID); | |
243 | if (ddlID < 0) | |
244 | return -1; | |
245 | ||
246 | if (ddlIndex >= fgkNumberOfDdls[detectorID]) { | |
247 | AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d", | |
248 | ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID)); | |
249 | return -1; | |
250 | } | |
251 | ||
252 | ddlID += ddlIndex; | |
253 | return ddlID; | |
254 | } | |
255 | ||
cddbd913 | 256 | const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex) |
257 | { | |
258 | // Returns the DDL file name | |
259 | // (used in the simulation) starting from | |
260 | // the detector name and the DDL | |
261 | // index inside the detector | |
262 | Int_t detectorID = DetectorID(detectorName); | |
263 | if (detectorID < 0) | |
264 | return ""; | |
265 | ||
266 | return DdlFileName(detectorID,ddlIndex); | |
267 | } | |
268 | ||
269 | const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex) | |
270 | { | |
271 | // Returns the DDL file name | |
272 | // (used in the simulation) starting from | |
273 | // the detector ID and the DDL | |
274 | // index inside the detector | |
275 | Int_t ddlID = DdlIDOffset(detectorID); | |
276 | if (ddlID < 0) | |
277 | return ""; | |
278 | ||
279 | if (ddlIndex >= fgkNumberOfDdls[detectorID]) { | |
280 | AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d", | |
281 | ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID)); | |
282 | return ""; | |
283 | } | |
284 | ||
285 | ddlID += ddlIndex; | |
4c95e64c | 286 | static TString fileName; |
287 | ||
288 | fileName = DetectorName(detectorID); | |
cddbd913 | 289 | fileName += "_"; |
290 | fileName += ddlID; | |
291 | fileName += ".ddl"; | |
292 | return fileName.Data(); | |
293 | } | |
294 | ||
42650ece | 295 | Int_t AliDAQ::NumberOfDdls(const char *detectorName) |
296 | { | |
297 | // Returns the number of DDLs for | |
298 | // a given detector | |
299 | Int_t detectorID = DetectorID(detectorName); | |
300 | if (detectorID < 0) | |
301 | return -1; | |
302 | ||
303 | return NumberOfDdls(detectorID); | |
304 | } | |
305 | ||
306 | Int_t AliDAQ::NumberOfDdls(Int_t detectorID) | |
307 | { | |
308 | // Returns the number of DDLs for | |
309 | // a given detector | |
310 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
311 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
312 | return -1; | |
313 | } | |
314 | ||
315 | return fgkNumberOfDdls[detectorID]; | |
316 | } | |
317 | ||
318 | Float_t AliDAQ::NumberOfLdcs(const char *detectorName) | |
319 | { | |
320 | // Returns the number of DDLs for | |
321 | // a given detector | |
322 | Int_t detectorID = DetectorID(detectorName); | |
323 | if (detectorID < 0) | |
324 | return -1; | |
325 | ||
326 | return NumberOfLdcs(detectorID); | |
327 | } | |
328 | ||
329 | Float_t AliDAQ::NumberOfLdcs(Int_t detectorID) | |
330 | { | |
331 | // Returns the number of DDLs for | |
332 | // a given detector | |
333 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
334 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
335 | return -1; | |
336 | } | |
337 | ||
338 | return fgkNumberOfLdcs[detectorID]; | |
339 | } | |
0d45e170 | 340 | |
341 | void AliDAQ::PrintConfig() | |
342 | { | |
343 | // Print the DAQ configuration | |
344 | // for all the detectors | |
345 | printf("====================================================================\n" | |
346 | "| ALICE Data Acquisition Configuration |\n" | |
347 | "====================================================================\n" | |
348 | "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs |\n" | |
349 | "====================================================================\n"); | |
350 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { | |
351 | printf("|%11d |%13s |%10d |%9d |%9.1f |\n", | |
352 | iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet)); | |
353 | } | |
354 | printf("====================================================================\n"); | |
355 | ||
356 | } |