]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEERBase/AliDAQ.cxx
- introduction of gain scenarios (e.g. OROC only - for homogeneous gain in 11h)
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliDAQ.cxx
CommitLineData
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
44ClassImp(AliDAQ)
45
46const 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",
e921939b 66 "DAQ_TEST",
44f26f0f 67 "MFT",
e921939b 68 "HLT"
42650ece 69};
70
71Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
72 20,
73 24,
74 16,
75 216,
76 18,
77 72,
78 20,
79 20,
80 10,
81 6,
82 20,
83 2,
84 3,
85 1,
86 1,
87 1,
88 1,
89 1,
69c3f03a 90 46,
7034c7a7 91 1,
44f26f0f 92 10,
36689079 93 28
42650ece 94};
95
96Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
42650ece 97 4,
98 4,
99 4,
0d45e170 100 36,
42650ece 101 3,
102 12,
103 4,
104 4,
105 2,
106 1,
d54ecd4e 107 5,
42650ece 108 1,
109 1,
110 0.5,
111 0.5,
112 1,
113 1,
114 1,
69c3f03a 115 8,
7034c7a7 116 1,
44f26f0f 117 1,
36689079 118 7
42650ece 119};
120
7e88424f 121const char* AliDAQ::fgkOfflineModuleName[AliDAQ::kNDetectors] = {
122 "ITS",
123 "ITS",
124 "ITS",
125 "TPC",
126 "TRD",
127 "TOF",
128 "HMPID",
129 "PHOS",
130 "CPV",
131 "PMD",
132 "MUON",
133 "MUON",
134 "FMD",
135 "T0",
136 "VZERO",
137 "ZDC",
138 "ACORDE",
139 "CTP",
140 "EMCAL",
e921939b 141 "",
44f26f0f 142 "MFT",
e921939b 143 "HLT"
7e88424f 144};
145
146const char* AliDAQ::fgkOnlineName[AliDAQ::kNDetectors] = {
147 "SPD",
148 "SDD",
149 "SSD",
150 "TPC",
151 "TRD",
152 "TOF",
153 "HMP",
154 "PHS",
155 "CPV",
156 "PMD",
157 "MCH",
158 "MTR",
159 "FMD",
160 "T00",
161 "V00",
162 "ZDC",
163 "ACO",
164 "TRI",
165 "EMC",
e921939b 166 "TST",
44f26f0f 167 "MFT",
e921939b 168 "HLT"
7e88424f 169};
170
42650ece 171AliDAQ::AliDAQ(const AliDAQ& source) :
172 TObject(source)
173{
174 // Copy constructor
175 // Nothing to be done
176}
177
178AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
179{
180 // Assignment operator
181 // Nothing to be done
182 return *this;
183}
184
185Int_t AliDAQ::DetectorID(const char *detectorName)
186{
187 // Return the detector index
188 // corresponding to a given
189 // detector name
190 TString detStr = detectorName;
191
192 Int_t iDet;
193 for(iDet = 0; iDet < kNDetectors; iDet++) {
194 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
195 break;
196 }
197 if (iDet == kNDetectors) {
198 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
199 return -1;
200 }
201 return iDet;
202}
203
204const char *AliDAQ::DetectorName(Int_t detectorID)
205{
206 // Returns the name of particular
207 // detector identified by its index
208 if (detectorID < 0 || detectorID >= kNDetectors) {
209 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
210 return "";
211 }
212 return fgkDetectorName[detectorID];
213}
214
215Int_t AliDAQ::DdlIDOffset(const char *detectorName)
216{
217 // Returns the DDL ID offset
218 // for a given detector
219 Int_t detectorID = DetectorID(detectorName);
220 if (detectorID < 0)
221 return -1;
222
223 return DdlIDOffset(detectorID);
224}
225
226Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
227{
228 // Returns the DDL ID offset
229 // for a given detector identified
230 // by its index
231 if (detectorID < 0 || detectorID >= kNDetectors) {
232 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
233 return -1;
234 }
7034c7a7 235 // HLT has a DDL offset = 30
236 if (detectorID == (kNDetectors-1)) return (kHLTId << 8);
237
42650ece 238 return (detectorID << 8);
239}
240
362c9d61 241const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex)
42650ece 242{
243 // Returns the detector name for
244 // a given DDL ID
362c9d61 245 ddlIndex = -1;
246 Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex);
42650ece 247 if (detectorID < 0)
248 return "";
249
250 return DetectorName(detectorID);
251}
252
362c9d61 253Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex)
42650ece 254{
362c9d61 255 // Returns the detector ID and
256 // the ddl index within the
257 // detector range for
258 // a given input DDL ID
42650ece 259 Int_t detectorID = ddlID >> 8;
7034c7a7 260
261 // HLT
262 if (detectorID == kHLTId) detectorID = kNDetectors-1;
263
42650ece 264 if (detectorID < 0 || detectorID >= kNDetectors) {
265 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
266 return -1;
267 }
362c9d61 268 ddlIndex = ddlID & 0xFF;
42650ece 269 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
270 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
271 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
362c9d61 272 ddlIndex = -1;
42650ece 273 return -1;
274 }
275 return detectorID;
276}
277
278Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
279{
280 // Returns the DDL ID starting from
281 // the detector name and the DDL
282 // index inside the detector
283 Int_t detectorID = DetectorID(detectorName);
284 if (detectorID < 0)
285 return -1;
286
287 return DdlID(detectorID,ddlIndex);
288}
289
290Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
291{
292 // Returns the DDL ID starting from
293 // the detector ID and the DDL
294 // index inside the detector
295 Int_t ddlID = DdlIDOffset(detectorID);
296 if (ddlID < 0)
297 return -1;
298
299 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
300 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
301 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
302 return -1;
303 }
304
305 ddlID += ddlIndex;
306 return ddlID;
307}
308
cddbd913 309const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
310{
311 // Returns the DDL file name
312 // (used in the simulation) starting from
313 // the detector name and the DDL
314 // index inside the detector
315 Int_t detectorID = DetectorID(detectorName);
316 if (detectorID < 0)
317 return "";
318
319 return DdlFileName(detectorID,ddlIndex);
320}
321
322const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
323{
324 // Returns the DDL file name
325 // (used in the simulation) starting from
326 // the detector ID and the DDL
327 // index inside the detector
328 Int_t ddlID = DdlIDOffset(detectorID);
329 if (ddlID < 0)
330 return "";
331
332 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
333 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
334 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
335 return "";
336 }
337
338 ddlID += ddlIndex;
4c95e64c 339 static TString fileName;
340
341 fileName = DetectorName(detectorID);
cddbd913 342 fileName += "_";
343 fileName += ddlID;
344 fileName += ".ddl";
345 return fileName.Data();
346}
347
42650ece 348Int_t AliDAQ::NumberOfDdls(const char *detectorName)
349{
350 // Returns the number of DDLs for
351 // a given detector
352 Int_t detectorID = DetectorID(detectorName);
353 if (detectorID < 0)
354 return -1;
355
356 return NumberOfDdls(detectorID);
357}
358
359Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
360{
361 // Returns the number of DDLs for
362 // a given detector
363 if (detectorID < 0 || detectorID >= kNDetectors) {
364 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
365 return -1;
366 }
367
368 return fgkNumberOfDdls[detectorID];
369}
370
371Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
372{
373 // Returns the number of DDLs for
374 // a given detector
375 Int_t detectorID = DetectorID(detectorName);
376 if (detectorID < 0)
377 return -1;
378
379 return NumberOfLdcs(detectorID);
380}
381
382Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
383{
384 // Returns the number of DDLs for
385 // a given detector
386 if (detectorID < 0 || detectorID >= kNDetectors) {
387 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
388 return -1;
389 }
390
391 return fgkNumberOfLdcs[detectorID];
392}
0d45e170 393
394void AliDAQ::PrintConfig()
395{
396 // Print the DAQ configuration
397 // for all the detectors
7e88424f 398 printf("===================================================================================================\n"
399 "| ALICE Data Acquisition Configuration |\n"
400 "===================================================================================================\n"
401 "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs | Online Name | AliRoot Module |\n"
402 "===================================================================================================\n");
0d45e170 403 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
7e88424f 404 printf("|%11d |%13s |%10d |%9d |%9.1f |%11s |%14s |\n",
405 iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet),
406 OnlineName(iDet),OfflineModuleName(iDet));
0d45e170 407 }
7e88424f 408 printf("===================================================================================================\n");
0d45e170 409
410}
1d3b4f15 411
7e88424f 412const char *AliDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
1d3b4f15 413{
414 // Returns a string with the list of
415 // active detectors. The input is the
416 // trigger pattern word contained in
417 // the raw-data event header.
418
419 static TString detList;
420 detList = "";
421 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
422 if ((detectorPattern >> iDet) & 0x1) {
423 detList += fgkDetectorName[iDet];
424 detList += " ";
425 }
426 }
427
428 // Always remember HLT
429 if ((detectorPattern >> kHLTId) & 0x1) detList += fgkDetectorName[kNDetectors-1];
430
431 return detList.Data();
432}
433
7e88424f 434UInt_t AliDAQ::DetectorPattern(const char *detectorList)
435{
436 // Returns a 32-bit word containing the
437 // the detector pattern corresponding to a given
438 // list of detectors
439 UInt_t pattern = 0;
440 TString detList = detectorList;
441 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
442 TString det = fgkDetectorName[iDet];
443 if((detList.CompareTo(det) == 0) ||
444 detList.BeginsWith(det) ||
445 detList.EndsWith(det) ||
446 detList.Contains( " "+det+" " )) pattern |= (1 << iDet) ;
447 }
448
449 // HLT
450 TString hltDet = fgkDetectorName[kNDetectors-1];
451 if((detList.CompareTo(hltDet) == 0) ||
452 detList.BeginsWith(hltDet) ||
453 detList.EndsWith(hltDet) ||
454 detList.Contains( " "+hltDet+" " )) pattern |= (1 << kHLTId) ;
455
456 return pattern;
457}
458
7b649c02 459UInt_t AliDAQ::DetectorPatternOffline(const char *detectorList)
460{
461 // Returns a 32-bit word containing the
462 // the detector pattern corresponding to a given
463 // list of detectors.
464 // The list of detectors must follow offline module
465 // name convention.
466 UInt_t pattern = 0;
467 TString detList = detectorList;
468 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
469 TString det = fgkOfflineModuleName[iDet];
470 if((detList.CompareTo(det) == 0) ||
471 detList.BeginsWith(det) ||
472 detList.EndsWith(det) ||
473 detList.Contains( " "+det+" " )) pattern |= (1 << iDet) ;
474 }
475
476 // HLT
477 TString hltDet = fgkOfflineModuleName[kNDetectors-1];
478 if((detList.CompareTo(hltDet) == 0) ||
479 detList.BeginsWith(hltDet) ||
480 detList.EndsWith(hltDet) ||
481 detList.Contains( " "+hltDet+" " )) pattern |= (1 << kHLTId) ;
482
483 return pattern;
484}
485
7e88424f 486const char *AliDAQ::OfflineModuleName(const char *detectorName)
487{
488 // Returns the name of the offline module
489 // for a given detector (online naming convention)
490 Int_t detectorID = DetectorID(detectorName);
491 if (detectorID < 0)
492 return "";
493
494 return OfflineModuleName(detectorID);
495}
496
497const char *AliDAQ::OfflineModuleName(Int_t detectorID)
498{
499 // Returns the name of the offline module
500 // for a given detector (online naming convention)
501 if (detectorID < 0 || detectorID >= kNDetectors) {
502 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
503 return "";
504 }
505
506 return fgkOfflineModuleName[detectorID];
507}
508
509const char *AliDAQ::OnlineName(const char *detectorName)
510{
511 // Returns the name of the online detector name (3 characters)
512 // for a given detector
513 Int_t detectorID = DetectorID(detectorName);
514 if (detectorID < 0)
515 return "";
516
517 return OnlineName(detectorID);
518}
519
520const char *AliDAQ::OnlineName(Int_t detectorID)
521{
522 // Returns the name of the online detector name (3 characters)
523 // for a given detector
524 if (detectorID < 0 || detectorID >= kNDetectors) {
525 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
526 return "";
527 }
528
529 return fgkOnlineName[detectorID];
530}
531