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] = {
74 Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
102 Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
130 const char* AliDAQ::fgkOfflineModuleName[AliDAQ::kNDetectors] = {
158 const char* AliDAQ::fgkOnlineName[AliDAQ::kNDetectors] = {
186 AliDAQ::AliDAQ(const AliDAQ& source) :
190 // Nothing to be done
193 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
195 // Assignment operator
196 // Nothing to be done
200 Int_t AliDAQ::DetectorID(const char *detectorName)
202 // Return the detector index
203 // corresponding to a given
205 TString detStr = detectorName;
208 for(iDet = 0; iDet < kNDetectors; iDet++) {
209 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
212 if (iDet == kNDetectors) {
213 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
219 const char *AliDAQ::DetectorName(Int_t detectorID)
221 // Returns the name of particular
222 // detector identified by its index
223 if (detectorID < 0 || detectorID >= kNDetectors) {
224 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
227 return fgkDetectorName[detectorID];
230 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
232 // Returns the DDL ID offset
233 // for a given detector
234 Int_t detectorID = DetectorID(detectorName);
238 return DdlIDOffset(detectorID);
241 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
243 // Returns the DDL ID offset
244 // for a given detector identified
246 if (detectorID < 0 || detectorID >= kNDetectors) {
247 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
250 // HLT has a DDL offset = 30
251 if (detectorID == (kNDetectors-1)) return (kHLTId << 8);
253 return (detectorID << 8);
256 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex)
258 // Returns the detector name for
261 Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex);
265 return DetectorName(detectorID);
268 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex)
270 // Returns the detector ID and
271 // the ddl index within the
272 // detector range for
273 // a given input DDL ID
274 Int_t detectorID = ddlID >> 8;
277 if (detectorID == kHLTId) detectorID = kNDetectors-1;
279 if (detectorID < 0 || detectorID >= kNDetectors) {
280 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
283 ddlIndex = ddlID & 0xFF;
284 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
285 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
286 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
293 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
295 // Returns the DDL ID starting from
296 // the detector name and the DDL
297 // index inside the detector
298 Int_t detectorID = DetectorID(detectorName);
302 return DdlID(detectorID,ddlIndex);
305 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
307 // Returns the DDL ID starting from
308 // the detector ID and the DDL
309 // index inside the detector
310 Int_t ddlID = DdlIDOffset(detectorID);
314 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
315 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
316 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
324 const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
326 // Returns the DDL file name
327 // (used in the simulation) starting from
328 // the detector name and the DDL
329 // index inside the detector
330 Int_t detectorID = DetectorID(detectorName);
334 return DdlFileName(detectorID,ddlIndex);
337 const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
339 // Returns the DDL file name
340 // (used in the simulation) starting from
341 // the detector ID and the DDL
342 // index inside the detector
343 Int_t ddlID = DdlIDOffset(detectorID);
347 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
348 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
349 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
354 static TString fileName;
356 fileName = DetectorName(detectorID);
360 return fileName.Data();
363 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
365 // Returns the number of DDLs for
367 Int_t detectorID = DetectorID(detectorName);
371 return NumberOfDdls(detectorID);
374 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
376 // Returns the number of DDLs for
378 if (detectorID < 0 || detectorID >= kNDetectors) {
379 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
383 return fgkNumberOfDdls[detectorID];
386 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
388 // Returns the number of DDLs for
390 Int_t detectorID = DetectorID(detectorName);
394 return NumberOfLdcs(detectorID);
397 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
399 // Returns the number of DDLs for
401 if (detectorID < 0 || detectorID >= kNDetectors) {
402 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
406 return fgkNumberOfLdcs[detectorID];
409 void AliDAQ::PrintConfig()
411 // Print the DAQ configuration
412 // for all the detectors
413 printf("===================================================================================================\n"
414 "| ALICE Data Acquisition Configuration |\n"
415 "===================================================================================================\n"
416 "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs | Online Name | AliRoot Module |\n"
417 "===================================================================================================\n");
418 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
419 printf("|%11d |%13s |%10d |%9d |%9.1f |%11s |%14s |\n",
420 iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet),
421 OnlineName(iDet),OfflineModuleName(iDet));
423 printf("===================================================================================================\n");
427 const char *AliDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
429 // Returns a string with the list of
430 // active detectors. The input is the
431 // trigger pattern word contained in
432 // the raw-data event header.
434 static TString detList;
436 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
437 if ((detectorPattern >> iDet) & 0x1) {
438 detList += fgkDetectorName[iDet];
443 // Always remember HLT
444 if ((detectorPattern >> kHLTId) & 0x1) detList += fgkDetectorName[kNDetectors-1];
446 return detList.Data();
449 UInt_t AliDAQ::DetectorPattern(const char *detectorList)
451 // Returns a 32-bit word containing the
452 // the detector pattern corresponding to a given
455 TString detList = detectorList;
456 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
457 TString det = fgkDetectorName[iDet];
458 if((detList.CompareTo(det) == 0) ||
459 detList.BeginsWith(det) ||
460 detList.EndsWith(det) ||
461 detList.Contains( " "+det+" " )) pattern |= (1 << iDet) ;
465 TString hltDet = fgkDetectorName[kNDetectors-1];
466 if((detList.CompareTo(hltDet) == 0) ||
467 detList.BeginsWith(hltDet) ||
468 detList.EndsWith(hltDet) ||
469 detList.Contains( " "+hltDet+" " )) pattern |= (1 << kHLTId) ;
474 UInt_t AliDAQ::DetectorPatternOffline(const char *detectorList)
476 // Returns a 32-bit word containing the
477 // the detector pattern corresponding to a given
478 // list of detectors.
479 // The list of detectors must follow offline module
482 TString detList = detectorList;
483 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
484 TString det = fgkOfflineModuleName[iDet];
485 if((detList.CompareTo(det) == 0) ||
486 detList.BeginsWith(det) ||
487 detList.EndsWith(det) ||
488 detList.Contains( " "+det+" " )) pattern |= (1 << iDet) ;
492 TString hltDet = fgkOfflineModuleName[kNDetectors-1];
493 if((detList.CompareTo(hltDet) == 0) ||
494 detList.BeginsWith(hltDet) ||
495 detList.EndsWith(hltDet) ||
496 detList.Contains( " "+hltDet+" " )) pattern |= (1 << kHLTId) ;
501 const char *AliDAQ::OfflineModuleName(const char *detectorName)
503 // Returns the name of the offline module
504 // for a given detector (online naming convention)
505 Int_t detectorID = DetectorID(detectorName);
509 return OfflineModuleName(detectorID);
512 const char *AliDAQ::OfflineModuleName(Int_t detectorID)
514 // Returns the name of the offline module
515 // for a given detector (online naming convention)
516 if (detectorID < 0 || detectorID >= kNDetectors) {
517 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
521 return fgkOfflineModuleName[detectorID];
524 const char *AliDAQ::OnlineName(const char *detectorName)
526 // Returns the name of the online detector name (3 characters)
527 // for a given detector
528 Int_t detectorID = DetectorID(detectorName);
532 return OnlineName(detectorID);
535 const char *AliDAQ::OnlineName(Int_t detectorID)
537 // Returns the name of the online detector name (3 characters)
538 // for a given detector
539 if (detectorID < 0 || detectorID >= kNDetectors) {
540 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
544 return fgkOnlineName[detectorID];