1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////////////
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. //
34 // cvetan.cheshkov@cern.ch 2006/06/09 //
36 //////////////////////////////////////////////////////////////////////////////
46 const char* AliDAQ::fgkDetectorName[AliDAQ::kNDetectors] = {
61 "VZERO", // Name to be changed to V0 ?
72 Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
98 Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
124 const char* AliDAQ::fgkOfflineModuleName[AliDAQ::kNDetectors] = {
150 const char* AliDAQ::fgkOnlineName[AliDAQ::kNDetectors] = {
176 AliDAQ::AliDAQ(const AliDAQ& source) :
180 // Nothing to be done
183 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
185 // Assignment operator
186 // Nothing to be done
190 Int_t AliDAQ::DetectorID(const char *detectorName)
192 // Return the detector index
193 // corresponding to a given
195 TString detStr = detectorName;
198 for(iDet = 0; iDet < kNDetectors; iDet++) {
199 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
202 if (iDet == kNDetectors) {
203 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
209 const char *AliDAQ::DetectorName(Int_t detectorID)
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));
217 return fgkDetectorName[detectorID];
220 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
222 // Returns the DDL ID offset
223 // for a given detector
224 Int_t detectorID = DetectorID(detectorName);
228 return DdlIDOffset(detectorID);
231 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
233 // Returns the DDL ID offset
234 // for a given detector identified
236 if (detectorID < 0 || detectorID >= kNDetectors) {
237 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
240 // HLT has a DDL offset = 30
241 if (detectorID == (kNDetectors-1)) return (kHLTId << 8);
243 return (detectorID << 8);
246 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex)
248 // Returns the detector name for
251 Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex);
255 return DetectorName(detectorID);
258 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex)
260 // Returns the detector ID and
261 // the ddl index within the
262 // detector range for
263 // a given input DDL ID
264 Int_t detectorID = ddlID >> 8;
267 if (detectorID == kHLTId) detectorID = kNDetectors-1;
269 if (detectorID < 0 || detectorID >= kNDetectors) {
270 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
273 ddlIndex = ddlID & 0xFF;
274 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
275 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
276 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
283 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
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);
292 return DdlID(detectorID,ddlIndex);
295 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
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);
304 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
305 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
306 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
314 const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
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);
324 return DdlFileName(detectorID,ddlIndex);
327 const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
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);
337 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
338 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
339 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
344 static TString fileName;
346 fileName = DetectorName(detectorID);
350 return fileName.Data();
353 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
355 // Returns the number of DDLs for
357 Int_t detectorID = DetectorID(detectorName);
361 return NumberOfDdls(detectorID);
364 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
366 // Returns the number of DDLs for
368 if (detectorID < 0 || detectorID >= kNDetectors) {
369 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
373 return fgkNumberOfDdls[detectorID];
376 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
378 // Returns the number of DDLs for
380 Int_t detectorID = DetectorID(detectorName);
384 return NumberOfLdcs(detectorID);
387 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
389 // Returns the number of DDLs for
391 if (detectorID < 0 || detectorID >= kNDetectors) {
392 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
396 return fgkNumberOfLdcs[detectorID];
399 void AliDAQ::PrintConfig()
401 // Print the DAQ configuration
402 // for all the detectors
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");
408 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
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));
413 printf("===================================================================================================\n");
417 const char *AliDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
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.
424 static TString detList;
426 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
427 if ((detectorPattern >> iDet) & 0x1) {
428 detList += fgkDetectorName[iDet];
433 // Always remember HLT
434 if ((detectorPattern >> kHLTId) & 0x1) detList += fgkDetectorName[kNDetectors-1];
436 return detList.Data();
439 UInt_t AliDAQ::DetectorPattern(const char *detectorList)
441 // Returns a 32-bit word containing the
442 // the detector pattern corresponding to a given
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) ;
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) ;
464 UInt_t AliDAQ::DetectorPatternOffline(const char *detectorList)
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
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) ;
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) ;
491 const char *AliDAQ::OfflineModuleName(const char *detectorName)
493 // Returns the name of the offline module
494 // for a given detector (online naming convention)
495 Int_t detectorID = DetectorID(detectorName);
499 return OfflineModuleName(detectorID);
502 const char *AliDAQ::OfflineModuleName(Int_t detectorID)
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));
511 return fgkOfflineModuleName[detectorID];
514 const char *AliDAQ::OnlineName(const char *detectorName)
516 // Returns the name of the online detector name (3 characters)
517 // for a given detector
518 Int_t detectorID = DetectorID(detectorName);
522 return OnlineName(detectorID);
525 const char *AliDAQ::OnlineName(Int_t detectorID)
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));
534 return fgkOnlineName[detectorID];