]>
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", | |
53 | "RICH", // Name to be changed to HMPID | |
54 | "PHOS", | |
55 | "CPV", | |
56 | "PMD", | |
57 | "MUONTRK", | |
58 | "MUONTRG", | |
59 | "FMD", | |
60 | "START", // Name to be changed to T0 | |
61 | "VZERO", // Name to be changed to V0 ? | |
62 | "ZDC", | |
63 | "CRT", // Name to be changed to ACCORDE | |
64 | "TRG", | |
65 | "EMCAL", | |
66 | "HLT" | |
67 | }; | |
68 | ||
69 | Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = { | |
70 | 20, | |
71 | 24, | |
72 | 16, | |
73 | 216, | |
74 | 18, | |
75 | 72, | |
76 | 20, | |
77 | 20, | |
78 | 10, | |
79 | 6, | |
80 | 20, | |
81 | 2, | |
82 | 3, | |
83 | 1, | |
84 | 1, | |
85 | 1, | |
86 | 1, | |
87 | 1, | |
88 | 24, | |
89 | 10 | |
90 | }; | |
91 | ||
92 | Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = { | |
42650ece | 93 | 4, |
94 | 4, | |
95 | 4, | |
0d45e170 | 96 | 36, |
42650ece | 97 | 3, |
98 | 12, | |
99 | 4, | |
100 | 4, | |
101 | 2, | |
102 | 1, | |
103 | 4, | |
104 | 1, | |
105 | 1, | |
106 | 0.5, | |
107 | 0.5, | |
108 | 1, | |
109 | 1, | |
110 | 1, | |
0d45e170 | 111 | 4, |
112 | 5 | |
42650ece | 113 | }; |
114 | ||
115 | AliDAQ::AliDAQ(const AliDAQ& source) : | |
116 | TObject(source) | |
117 | { | |
118 | // Copy constructor | |
119 | // Nothing to be done | |
120 | } | |
121 | ||
122 | AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */) | |
123 | { | |
124 | // Assignment operator | |
125 | // Nothing to be done | |
126 | return *this; | |
127 | } | |
128 | ||
129 | Int_t AliDAQ::DetectorID(const char *detectorName) | |
130 | { | |
131 | // Return the detector index | |
132 | // corresponding to a given | |
133 | // detector name | |
134 | TString detStr = detectorName; | |
135 | ||
136 | Int_t iDet; | |
137 | for(iDet = 0; iDet < kNDetectors; iDet++) { | |
138 | if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0) | |
139 | break; | |
140 | } | |
141 | if (iDet == kNDetectors) { | |
142 | AliErrorClass(Form("Invalid detector name: %s !",detectorName)); | |
143 | return -1; | |
144 | } | |
145 | return iDet; | |
146 | } | |
147 | ||
148 | const char *AliDAQ::DetectorName(Int_t detectorID) | |
149 | { | |
150 | // Returns the name of particular | |
151 | // detector identified by its index | |
152 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
153 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
154 | return ""; | |
155 | } | |
156 | return fgkDetectorName[detectorID]; | |
157 | } | |
158 | ||
159 | Int_t AliDAQ::DdlIDOffset(const char *detectorName) | |
160 | { | |
161 | // Returns the DDL ID offset | |
162 | // for a given detector | |
163 | Int_t detectorID = DetectorID(detectorName); | |
164 | if (detectorID < 0) | |
165 | return -1; | |
166 | ||
167 | return DdlIDOffset(detectorID); | |
168 | } | |
169 | ||
170 | Int_t AliDAQ::DdlIDOffset(Int_t detectorID) | |
171 | { | |
172 | // Returns the DDL ID offset | |
173 | // for a given detector identified | |
174 | // by its index | |
175 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
176 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
177 | return -1; | |
178 | } | |
179 | return (detectorID << 8); | |
180 | } | |
181 | ||
362c9d61 | 182 | const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex) |
42650ece | 183 | { |
184 | // Returns the detector name for | |
185 | // a given DDL ID | |
362c9d61 | 186 | ddlIndex = -1; |
187 | Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex); | |
42650ece | 188 | if (detectorID < 0) |
189 | return ""; | |
190 | ||
191 | return DetectorName(detectorID); | |
192 | } | |
193 | ||
362c9d61 | 194 | Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex) |
42650ece | 195 | { |
362c9d61 | 196 | // Returns the detector ID and |
197 | // the ddl index within the | |
198 | // detector range for | |
199 | // a given input DDL ID | |
42650ece | 200 | Int_t detectorID = ddlID >> 8; |
201 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
202 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
203 | return -1; | |
204 | } | |
362c9d61 | 205 | ddlIndex = ddlID & 0xFF; |
42650ece | 206 | if (ddlIndex >= fgkNumberOfDdls[detectorID]) { |
207 | AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d", | |
208 | ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID)); | |
362c9d61 | 209 | ddlIndex = -1; |
42650ece | 210 | return -1; |
211 | } | |
212 | return detectorID; | |
213 | } | |
214 | ||
215 | Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex) | |
216 | { | |
217 | // Returns the DDL ID starting from | |
218 | // the detector name and the DDL | |
219 | // index inside the detector | |
220 | Int_t detectorID = DetectorID(detectorName); | |
221 | if (detectorID < 0) | |
222 | return -1; | |
223 | ||
224 | return DdlID(detectorID,ddlIndex); | |
225 | } | |
226 | ||
227 | Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex) | |
228 | { | |
229 | // Returns the DDL ID starting from | |
230 | // the detector ID and the DDL | |
231 | // index inside the detector | |
232 | Int_t ddlID = DdlIDOffset(detectorID); | |
233 | if (ddlID < 0) | |
234 | return -1; | |
235 | ||
236 | if (ddlIndex >= fgkNumberOfDdls[detectorID]) { | |
237 | AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d", | |
238 | ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID)); | |
239 | return -1; | |
240 | } | |
241 | ||
242 | ddlID += ddlIndex; | |
243 | return ddlID; | |
244 | } | |
245 | ||
cddbd913 | 246 | const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex) |
247 | { | |
248 | // Returns the DDL file name | |
249 | // (used in the simulation) starting from | |
250 | // the detector name and the DDL | |
251 | // index inside the detector | |
252 | Int_t detectorID = DetectorID(detectorName); | |
253 | if (detectorID < 0) | |
254 | return ""; | |
255 | ||
256 | return DdlFileName(detectorID,ddlIndex); | |
257 | } | |
258 | ||
259 | const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex) | |
260 | { | |
261 | // Returns the DDL file name | |
262 | // (used in the simulation) starting from | |
263 | // the detector ID and the DDL | |
264 | // index inside the detector | |
265 | Int_t ddlID = DdlIDOffset(detectorID); | |
266 | if (ddlID < 0) | |
267 | return ""; | |
268 | ||
269 | if (ddlIndex >= fgkNumberOfDdls[detectorID]) { | |
270 | AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d", | |
271 | ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID)); | |
272 | return ""; | |
273 | } | |
274 | ||
275 | ddlID += ddlIndex; | |
276 | TString fileName = DetectorName(detectorID); | |
277 | fileName += "_"; | |
278 | fileName += ddlID; | |
279 | fileName += ".ddl"; | |
280 | return fileName.Data(); | |
281 | } | |
282 | ||
42650ece | 283 | Int_t AliDAQ::NumberOfDdls(const char *detectorName) |
284 | { | |
285 | // Returns the number of DDLs for | |
286 | // a given detector | |
287 | Int_t detectorID = DetectorID(detectorName); | |
288 | if (detectorID < 0) | |
289 | return -1; | |
290 | ||
291 | return NumberOfDdls(detectorID); | |
292 | } | |
293 | ||
294 | Int_t AliDAQ::NumberOfDdls(Int_t detectorID) | |
295 | { | |
296 | // Returns the number of DDLs for | |
297 | // a given detector | |
298 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
299 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
300 | return -1; | |
301 | } | |
302 | ||
303 | return fgkNumberOfDdls[detectorID]; | |
304 | } | |
305 | ||
306 | Float_t AliDAQ::NumberOfLdcs(const char *detectorName) | |
307 | { | |
308 | // Returns the number of DDLs for | |
309 | // a given detector | |
310 | Int_t detectorID = DetectorID(detectorName); | |
311 | if (detectorID < 0) | |
312 | return -1; | |
313 | ||
314 | return NumberOfLdcs(detectorID); | |
315 | } | |
316 | ||
317 | Float_t AliDAQ::NumberOfLdcs(Int_t detectorID) | |
318 | { | |
319 | // Returns the number of DDLs for | |
320 | // a given detector | |
321 | if (detectorID < 0 || detectorID >= kNDetectors) { | |
322 | AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1)); | |
323 | return -1; | |
324 | } | |
325 | ||
326 | return fgkNumberOfLdcs[detectorID]; | |
327 | } | |
0d45e170 | 328 | |
329 | void AliDAQ::PrintConfig() | |
330 | { | |
331 | // Print the DAQ configuration | |
332 | // for all the detectors | |
333 | printf("====================================================================\n" | |
334 | "| ALICE Data Acquisition Configuration |\n" | |
335 | "====================================================================\n" | |
336 | "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs |\n" | |
337 | "====================================================================\n"); | |
338 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { | |
339 | printf("|%11d |%13s |%10d |%9d |%9.1f |\n", | |
340 | iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet)); | |
341 | } | |
342 | printf("====================================================================\n"); | |
343 | ||
344 | } |