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 AliDAQ::AliDAQ(const AliDAQ& source) :
122 // Nothing to be done
125 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
127 // Assignment operator
128 // Nothing to be done
132 Int_t AliDAQ::DetectorID(const char *detectorName)
134 // Return the detector index
135 // corresponding to a given
137 TString detStr = detectorName;
140 for(iDet = 0; iDet < kNDetectors; iDet++) {
141 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
144 if (iDet == kNDetectors) {
145 AliErrorClass(Form("Invalid detector name: %s !",detectorName));
151 const char *AliDAQ::DetectorName(Int_t detectorID)
153 // Returns the name of particular
154 // detector identified by its index
155 if (detectorID < 0 || detectorID >= kNDetectors) {
156 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
159 return fgkDetectorName[detectorID];
162 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
164 // Returns the DDL ID offset
165 // for a given detector
166 Int_t detectorID = DetectorID(detectorName);
170 return DdlIDOffset(detectorID);
173 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
175 // Returns the DDL ID offset
176 // for a given detector identified
178 if (detectorID < 0 || detectorID >= kNDetectors) {
179 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
182 // HLT has a DDL offset = 30
183 if (detectorID == (kNDetectors-1)) return (kHLTId << 8);
185 return (detectorID << 8);
188 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID,Int_t &ddlIndex)
190 // Returns the detector name for
193 Int_t detectorID = DetectorIDFromDdlID(ddlID,ddlIndex);
197 return DetectorName(detectorID);
200 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID,Int_t &ddlIndex)
202 // Returns the detector ID and
203 // the ddl index within the
204 // detector range for
205 // a given input DDL ID
206 Int_t detectorID = ddlID >> 8;
209 if (detectorID == kHLTId) detectorID = kNDetectors-1;
211 if (detectorID < 0 || detectorID >= kNDetectors) {
212 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
215 ddlIndex = ddlID & 0xFF;
216 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
217 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
218 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
225 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
227 // Returns the DDL ID starting from
228 // the detector name and the DDL
229 // index inside the detector
230 Int_t detectorID = DetectorID(detectorName);
234 return DdlID(detectorID,ddlIndex);
237 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
239 // Returns the DDL ID starting from
240 // the detector ID and the DDL
241 // index inside the detector
242 Int_t ddlID = DdlIDOffset(detectorID);
246 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
247 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
248 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
256 const char *AliDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
258 // Returns the DDL file name
259 // (used in the simulation) starting from
260 // the detector name and the DDL
261 // index inside the detector
262 Int_t detectorID = DetectorID(detectorName);
266 return DdlFileName(detectorID,ddlIndex);
269 const char *AliDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
271 // Returns the DDL file name
272 // (used in the simulation) starting from
273 // the detector ID and the DDL
274 // index inside the detector
275 Int_t ddlID = DdlIDOffset(detectorID);
279 if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
280 AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
281 ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
286 static TString fileName;
288 fileName = DetectorName(detectorID);
292 return fileName.Data();
295 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
297 // Returns the number of DDLs for
299 Int_t detectorID = DetectorID(detectorName);
303 return NumberOfDdls(detectorID);
306 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
308 // Returns the number of DDLs for
310 if (detectorID < 0 || detectorID >= kNDetectors) {
311 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
315 return fgkNumberOfDdls[detectorID];
318 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
320 // Returns the number of DDLs for
322 Int_t detectorID = DetectorID(detectorName);
326 return NumberOfLdcs(detectorID);
329 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
331 // Returns the number of DDLs for
333 if (detectorID < 0 || detectorID >= kNDetectors) {
334 AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
338 return fgkNumberOfLdcs[detectorID];
341 void AliDAQ::PrintConfig()
343 // Print the DAQ configuration
344 // for all the detectors
345 printf("====================================================================\n"
346 "| ALICE Data Acquisition Configuration |\n"
347 "====================================================================\n"
348 "| Detector ID | Detector Name | DDL Offset | # of DDLs | # of LDCs |\n"
349 "====================================================================\n");
350 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
351 printf("|%11d |%13s |%10d |%9d |%9.1f |\n",
352 iDet,DetectorName(iDet),DdlIDOffset(iDet),NumberOfDdls(iDet),NumberOfLdcs(iDet));
354 printf("====================================================================\n");