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] = {
53 "RICH", // Name to be changed to HMPID
60 "START", // Name to be changed to T0
61 "VZERO", // Name to be changed to V0 ?
63 "CRT", // Name to be changed to ACCORDE
69 Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
92 Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
115 AliDAQ::AliDAQ(const AliDAQ& source) :
119 // Nothing to be done
122 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
124 // Assignment operator
125 // Nothing to be done
129 Int_t AliDAQ::DetectorID(const char *detectorName)
131 // Return the detector index
132 // corresponding to a given
134 TString detStr = detectorName;
137 for(iDet = 0; iDet < kNDetectors; iDet++) {
138 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
141 if (iDet == kNDetectors) {
142 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
148 const char *AliDAQ::DetectorName(Int_t detectorID)
150 // Returns the name of particular
151 // detector identified by its index
152 if (detectorID < 0 || detectorID >= kNDetectors) {
153 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
156 return fgkDetectorName[detectorID];
159 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
161 // Returns the DDL ID offset
162 // for a given detector
163 Int_t detectorID = DetectorID(detectorName);
167 return DdlIDOffset(detectorID);
170 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
172 // Returns the DDL ID offset
173 // for a given detector identified
175 if (detectorID < 0 || detectorID >= kNDetectors) {
176 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
179 return (detectorID << 8);
182 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID)
184 // Returns the detector name for
186 Int_t detectorID = DetectorIDFromDdlID(ddlID);
190 return DetectorName(detectorID);
193 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID)
195 // Returns the detector ID for
197 Int_t detectorID = ddlID >> 8;
198 if (detectorID < 0 || detectorID >= kNDetectors) {
199 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
202 Int_t ddlIndex = ddlID & 0xFF;
203 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
204 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
205 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
211 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
213 // Returns the DDL ID starting from
214 // the detector name and the DDL
215 // index inside the detector
216 Int_t detectorID = DetectorID(detectorName);
220 return DdlID(detectorID,ddlIndex);
223 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
225 // Returns the DDL ID starting from
226 // the detector ID and the DDL
227 // index inside the detector
228 Int_t ddlID = DdlIDOffset(detectorID);
232 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
233 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
234 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
242 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
244 // Returns the number of DDLs for
246 Int_t detectorID = DetectorID(detectorName);
250 return NumberOfDdls(detectorID);
253 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
255 // Returns the number of DDLs for
257 if (detectorID < 0 || detectorID >= kNDetectors) {
258 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
262 return fgkNumberOfDdls[detectorID];
265 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
267 // Returns the number of DDLs for
269 Int_t detectorID = DetectorID(detectorName);
273 return NumberOfLdcs(detectorID);
276 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
278 // Returns the number of DDLs for
280 if (detectorID < 0 || detectorID >= kNDetectors) {
281 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
285 return fgkNumberOfLdcs[detectorID];
288 void AliDAQ::PrintConfig()
290 // Print the DAQ configuration
291 // for all the detectors
292 printf("====================================================================\n"
293 "| ALICE Data Acquisition Configuration |\n"
294 "====================================================================\n"
295 "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs |\n"
296 "====================================================================\n");
297 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
298 printf("|%11d |%13s |%10d |%9d |%9.1f |\n",
299 iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet));
301 printf("====================================================================\n");