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 ?
70 Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
94 Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
118 const char* AliDAQ::fgkOfflineModuleName[AliDAQ::kNDetectors] = {
142 const char* AliDAQ::fgkOnlineName[AliDAQ::kNDetectors] = {
166 AliDAQ::AliDAQ(const AliDAQ& source) :
170 // Nothing to be done
173 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
175 // Assignment operator
176 // Nothing to be done
180 Int_t AliDAQ::DetectorID(const char *detectorName)
182 // Return the detector index
183 // corresponding to a given
185 TString detStr = detectorName;
188 for(iDet = 0; iDet < kNDetectors; iDet++) {
189 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
192 if (iDet == kNDetectors) {
193 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
199 const char *AliDAQ::DetectorName(Int_t detectorID)
201 // Returns the name of particular
202 // detector identified by its index
203 if (detectorID < 0 || detectorID >= kNDetectors) {
204 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
207 return fgkDetectorName[detectorID];
210 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
212 // Returns the DDL ID offset
213 // for a given detector
214 Int_t detectorID = DetectorID(detectorName);
218 return DdlIDOffset(detectorID);
221 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
223 // Returns the DDL ID offset
224 // for a given detector identified
226 if (detectorID < 0 || detectorID >= kNDetectors) {
227 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
230 // HLT has a DDL offset = 30
231 if (detectorID == (kNDetectors-1)) return (kHLTId << 8);
233 return (detectorID << 8);
236 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex)
238 // Returns the detector name for
241 Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex);
245 return DetectorName(detectorID);
248 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex)
250 // Returns the detector ID and
251 // the ddl index within the
252 // detector range for
253 // a given input DDL ID
254 Int_t detectorID = ddlID >> 8;
257 if (detectorID == kHLTId) detectorID = kNDetectors-1;
259 if (detectorID < 0 || detectorID >= kNDetectors) {
260 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
263 ddlIndex = ddlID & 0xFF;
264 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
265 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
266 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
273 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
275 // Returns the DDL ID starting from
276 // the detector name and the DDL
277 // index inside the detector
278 Int_t detectorID = DetectorID(detectorName);
282 return DdlID(detectorID,ddlIndex);
285 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
287 // Returns the DDL ID starting from
288 // the detector ID and the DDL
289 // index inside the detector
290 Int_t ddlID = DdlIDOffset(detectorID);
294 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
295 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
296 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
304 const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
306 // Returns the DDL file name
307 // (used in the simulation) starting from
308 // the detector name and the DDL
309 // index inside the detector
310 Int_t detectorID = DetectorID(detectorName);
314 return DdlFileName(detectorID,ddlIndex);
317 const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
319 // Returns the DDL file name
320 // (used in the simulation) starting from
321 // the detector ID and the DDL
322 // index inside the detector
323 Int_t ddlID = DdlIDOffset(detectorID);
327 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
328 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
329 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
334 static TString fileName;
336 fileName = DetectorName(detectorID);
340 return fileName.Data();
343 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
345 // Returns the number of DDLs for
347 Int_t detectorID = DetectorID(detectorName);
351 return NumberOfDdls(detectorID);
354 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
356 // Returns the number of DDLs for
358 if (detectorID < 0 || detectorID >= kNDetectors) {
359 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
363 return fgkNumberOfDdls[detectorID];
366 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
368 // Returns the number of DDLs for
370 Int_t detectorID = DetectorID(detectorName);
374 return NumberOfLdcs(detectorID);
377 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
379 // Returns the number of DDLs for
381 if (detectorID < 0 || detectorID >= kNDetectors) {
382 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
386 return fgkNumberOfLdcs[detectorID];
389 void AliDAQ::PrintConfig()
391 // Print the DAQ configuration
392 // for all the detectors
393 printf("===================================================================================================\n"
394 "| ALICE Data Acquisition Configuration |\n"
395 "===================================================================================================\n"
396 "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs | Online Name | AliRoot Module |\n"
397 "===================================================================================================\n");
398 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
399 printf("|%11d |%13s |%10d |%9d |%9.1f |%11s |%14s |\n",
400 iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet),
401 OnlineName(iDet),OfflineModuleName(iDet));
403 printf("===================================================================================================\n");
407 const char *AliDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
409 // Returns a string with the list of
410 // active detectors. The input is the
411 // trigger pattern word contained in
412 // the raw-data event header.
414 static TString detList;
416 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
417 if ((detectorPattern >> iDet) & 0x1) {
418 detList += fgkDetectorName[iDet];
423 // Always remember HLT
424 if ((detectorPattern >> kHLTId) & 0x1) detList += fgkDetectorName[kNDetectors-1];
426 return detList.Data();
429 UInt_t AliDAQ::DetectorPattern(const char *detectorList)
431 // Returns a 32-bit word containing the
432 // the detector pattern corresponding to a given
435 TString detList = detectorList;
436 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
437 TString det = fgkDetectorName[iDet];
438 if((detList.CompareTo(det) == 0) ||
439 detList.BeginsWith(det) ||
440 detList.EndsWith(det) ||
441 detList.Contains( " "+det+" " )) pattern |= (1 << iDet) ;
445 TString hltDet = fgkDetectorName[kNDetectors-1];
446 if((detList.CompareTo(hltDet) == 0) ||
447 detList.BeginsWith(hltDet) ||
448 detList.EndsWith(hltDet) ||
449 detList.Contains( " "+hltDet+" " )) pattern |= (1 << kHLTId) ;
454 UInt_t AliDAQ::DetectorPatternOffline(const char *detectorList)
456 // Returns a 32-bit word containing the
457 // the detector pattern corresponding to a given
458 // list of detectors.
459 // The list of detectors must follow offline module
462 TString detList = detectorList;
463 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
464 TString det = fgkOfflineModuleName[iDet];
465 if((detList.CompareTo(det) == 0) ||
466 detList.BeginsWith(det) ||
467 detList.EndsWith(det) ||
468 detList.Contains( " "+det+" " )) pattern |= (1 << iDet) ;
472 TString hltDet = fgkOfflineModuleName[kNDetectors-1];
473 if((detList.CompareTo(hltDet) == 0) ||
474 detList.BeginsWith(hltDet) ||
475 detList.EndsWith(hltDet) ||
476 detList.Contains( " "+hltDet+" " )) pattern |= (1 << kHLTId) ;
481 const char *AliDAQ::OfflineModuleName(const char *detectorName)
483 // Returns the name of the offline module
484 // for a given detector (online naming convention)
485 Int_t detectorID = DetectorID(detectorName);
489 return OfflineModuleName(detectorID);
492 const char *AliDAQ::OfflineModuleName(Int_t detectorID)
494 // Returns the name of the offline module
495 // for a given detector (online naming convention)
496 if (detectorID < 0 || detectorID >= kNDetectors) {
497 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
501 return fgkOfflineModuleName[detectorID];
504 const char *AliDAQ::OnlineName(const char *detectorName)
506 // Returns the name of the online detector name (3 characters)
507 // for a given detector
508 Int_t detectorID = DetectorID(detectorName);
512 return OnlineName(detectorID);
515 const char *AliDAQ::OnlineName(Int_t detectorID)
517 // Returns the name of the online detector name (3 characters)
518 // for a given detector
519 if (detectorID < 0 || detectorID >= kNDetectors) {
520 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
524 return fgkOnlineName[detectorID];