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