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 ?
71 Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
96 Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
121 const char* AliDAQ::fgkOfflineModuleName[AliDAQ::kNDetectors] = {
146 const char* AliDAQ::fgkOnlineName[AliDAQ::kNDetectors] = {
171 AliDAQ::AliDAQ(const AliDAQ& source) :
175 // Nothing to be done
178 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
180 // Assignment operator
181 // Nothing to be done
185 Int_t AliDAQ::DetectorID(const char *detectorName)
187 // Return the detector index
188 // corresponding to a given
190 TString detStr = detectorName;
193 for(iDet = 0; iDet < kNDetectors; iDet++) {
194 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
197 if (iDet == kNDetectors) {
198 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
204 const char *AliDAQ::DetectorName(Int_t detectorID)
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));
212 return fgkDetectorName[detectorID];
215 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
217 // Returns the DDL ID offset
218 // for a given detector
219 Int_t detectorID = DetectorID(detectorName);
223 return DdlIDOffset(detectorID);
226 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
228 // Returns the DDL ID offset
229 // for a given detector identified
231 if (detectorID < 0 || detectorID >= kNDetectors) {
232 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
235 // HLT has a DDL offset = 30
236 if (detectorID == (kNDetectors-1)) return (kHLTId << 8);
238 return (detectorID << 8);
241 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex)
243 // Returns the detector name for
246 Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex);
250 return DetectorName(detectorID);
253 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex)
255 // Returns the detector ID and
256 // the ddl index within the
257 // detector range for
258 // a given input DDL ID
259 Int_t detectorID = ddlID >> 8;
262 if (detectorID == kHLTId) detectorID = kNDetectors-1;
264 if (detectorID < 0 || detectorID >= kNDetectors) {
265 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
268 ddlIndex = ddlID & 0xFF;
269 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
270 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
271 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
278 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
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);
287 return DdlID(detectorID,ddlIndex);
290 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
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);
299 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
300 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
301 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
309 const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
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);
319 return DdlFileName(detectorID,ddlIndex);
322 const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
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);
332 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
333 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
334 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
339 static TString fileName;
341 fileName = DetectorName(detectorID);
345 return fileName.Data();
348 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
350 // Returns the number of DDLs for
352 Int_t detectorID = DetectorID(detectorName);
356 return NumberOfDdls(detectorID);
359 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
361 // Returns the number of DDLs for
363 if (detectorID < 0 || detectorID >= kNDetectors) {
364 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
368 return fgkNumberOfDdls[detectorID];
371 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
373 // Returns the number of DDLs for
375 Int_t detectorID = DetectorID(detectorName);
379 return NumberOfLdcs(detectorID);
382 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
384 // Returns the number of DDLs for
386 if (detectorID < 0 || detectorID >= kNDetectors) {
387 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
391 return fgkNumberOfLdcs[detectorID];
394 void AliDAQ::PrintConfig()
396 // Print the DAQ configuration
397 // for all the detectors
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");
403 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
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));
408 printf("===================================================================================================\n");
412 const char *AliDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
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.
419 static TString detList;
421 for(Int_t iDet = 0; iDet < (kNDetectors-1); iDet++) {
422 if ((detectorPattern >> iDet) & 0x1) {
423 detList += fgkDetectorName[iDet];
428 // Always remember HLT
429 if ((detectorPattern >> kHLTId) & 0x1) detList += fgkDetectorName[kNDetectors-1];
431 return detList.Data();
434 UInt_t AliDAQ::DetectorPattern(const char *detectorList)
436 // Returns a 32-bit word containing the
437 // the detector pattern corresponding to a given
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) ;
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) ;
459 UInt_t AliDAQ::DetectorPatternOffline(const char *detectorList)
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
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) ;
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) ;
486 const char *AliDAQ::OfflineModuleName(const char *detectorName)
488 // Returns the name of the offline module
489 // for a given detector (online naming convention)
490 Int_t detectorID = DetectorID(detectorName);
494 return OfflineModuleName(detectorID);
497 const char *AliDAQ::OfflineModuleName(Int_t detectorID)
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));
506 return fgkOfflineModuleName[detectorID];
509 const char *AliDAQ::OnlineName(const char *detectorName)
511 // Returns the name of the online detector name (3 characters)
512 // for a given detector
513 Int_t detectorID = DetectorID(detectorName);
517 return OnlineName(detectorID);
520 const char *AliDAQ::OnlineName(Int_t detectorID)
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));
529 return fgkOnlineName[detectorID];