]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliDAQ.cxx
New class AliDAQ is introduced in order to handle the detector numbering and DAQ...
[u/mrichter/AliRoot.git] / RAW / AliDAQ.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 //////////////////////////////////////////////////////////////////////////////
17 //                                                                          //
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.                                                         //
33 //                                                                          //
34 // cvetan.cheshkov@cern.ch  2006/06/09                                      //
35 //                                                                          //
36 //////////////////////////////////////////////////////////////////////////////
37
38 #include <TClass.h>
39 #include <TString.h>
40
41 #include "AliDAQ.h"
42 #include "AliLog.h"
43
44 ClassImp(AliDAQ)
45
46 const char* AliDAQ::fgkDetectorName[AliDAQ::kNDetectors] = {
47   "ITSSPD",
48   "ITSSDD",
49   "ITSSSD",
50   "TPC",
51   "TRD",
52   "TOF",
53   "RICH",  // Name to be changed to HMPID
54   "PHOS",
55   "CPV",
56   "PMD",
57   "MUONTRK",
58   "MUONTRG",
59   "FMD",
60   "START", // Name to be changed to T0
61   "VZERO", // Name to be changed to V0 ?
62   "ZDC",
63   "CRT",   // Name to be changed to ACCORDE
64   "TRG",
65   "EMCAL",
66   "HLT"
67 };
68
69 Int_t AliDAQ::fgkNumberOfDdls[AliDAQ::kNDetectors] = {
70   20,
71   24,
72   16,
73   216,
74   18,
75   72,
76   20,
77   20,
78   10,
79   6,
80   20,
81   2,
82   3,
83   1,
84   1,
85   1,
86   1,
87   1,
88   24,
89   10
90 };
91
92 Float_t AliDAQ::fgkNumberOfLdcs[AliDAQ::kNDetectors] = {
93   36,
94   4,
95   4,
96   4,
97   3,
98   12,
99   4,
100   4,
101   2,
102   1,
103   4,
104   1,
105   1,
106   0.5,
107   0.5,
108   1,
109   1,
110   1,
111   4
112 };
113
114 AliDAQ::AliDAQ(const AliDAQ& source) :
115   TObject(source)
116 {
117   // Copy constructor
118   // Nothing to be done
119 }
120
121 AliDAQ& AliDAQ::operator = (const AliDAQ& /* source */)
122 {
123   // Assignment operator
124   // Nothing to be done
125   return *this;
126 }
127
128 Int_t AliDAQ::DetectorID(const char *detectorName)
129 {
130   // Return the detector index
131   // corresponding to a given
132   // detector name
133   TString detStr = detectorName;
134
135   Int_t iDet;
136   for(iDet = 0; iDet < kNDetectors; iDet++) {
137     if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
138       break;
139   }
140   if (iDet == kNDetectors) {
141     AliErrorClass(Form("Invalid detector name: %s !",detectorName));
142     return -1;
143   }
144   return iDet;
145 }
146
147 const char *AliDAQ::DetectorName(Int_t detectorID)
148 {
149   // Returns the name of particular
150   // detector identified by its index
151   if (detectorID < 0 || detectorID >= kNDetectors) {
152     AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
153     return "";
154   }
155   return fgkDetectorName[detectorID];
156 }
157
158 Int_t AliDAQ::DdlIDOffset(const char *detectorName)
159 {
160   // Returns the DDL ID offset
161   // for a given detector
162   Int_t detectorID = DetectorID(detectorName);
163   if (detectorID < 0)
164     return -1;
165   
166   return DdlIDOffset(detectorID);
167 }
168
169 Int_t AliDAQ::DdlIDOffset(Int_t detectorID)
170 {
171   // Returns the DDL ID offset
172   // for a given detector identified
173   // by its index
174   if (detectorID < 0 || detectorID >= kNDetectors) {
175     AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
176     return -1;
177   }
178   return (detectorID << 8);
179 }
180
181 const char *AliDAQ::DetectorNameFromDdlID(Int_t ddlID)
182 {
183   // Returns the detector name for
184   // a given DDL ID
185   Int_t detectorID = DetectorIDFromDdlID(ddlID);
186   if (detectorID < 0)
187     return "";
188
189   return DetectorName(detectorID);
190 }
191
192 Int_t AliDAQ::DetectorIDFromDdlID(Int_t ddlID)
193 {
194   // Returns the detector ID for
195   // a given DDL ID
196   Int_t detectorID = ddlID >> 8;
197   if (detectorID < 0 || detectorID >= kNDetectors) {
198     AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
199     return -1;
200   }
201   Int_t ddlIndex = ddlID & 0xFF;
202   if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
203     AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
204                        ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
205     return -1;
206   }
207   return detectorID;
208 }
209
210 Int_t AliDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
211 {
212   // Returns the DDL ID starting from
213   // the detector name and the DDL
214   // index inside the detector
215   Int_t detectorID = DetectorID(detectorName);
216   if (detectorID < 0)
217     return -1;
218
219   return DdlID(detectorID,ddlIndex);
220 }
221
222 Int_t AliDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
223 {
224   // Returns the DDL ID starting from
225   // the detector ID and the DDL
226   // index inside the detector
227   Int_t ddlID = DdlIDOffset(detectorID);
228   if (ddlID < 0)
229     return -1;
230   
231   if (ddlIndex >= fgkNumberOfDdls[detectorID]) {
232     AliErrorClass(Form("Invalid DDL index %d (%d -> %d) for detector %d",
233                        ddlIndex,0,fgkNumberOfDdls[detectorID],detectorID));
234     return -1;
235   }
236
237   ddlID += ddlIndex;
238   return ddlID;
239 }
240
241 Int_t AliDAQ::NumberOfDdls(const char *detectorName)
242 {
243   // Returns the number of DDLs for
244   // a given detector
245   Int_t detectorID = DetectorID(detectorName);
246   if (detectorID < 0)
247     return -1;
248
249   return NumberOfDdls(detectorID);
250 }
251
252 Int_t AliDAQ::NumberOfDdls(Int_t detectorID)
253 {
254   // Returns the number of DDLs for
255   // a given detector
256   if (detectorID < 0 || detectorID >= kNDetectors) {
257     AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
258     return -1;
259   }
260
261   return fgkNumberOfDdls[detectorID];
262 }
263
264 Float_t AliDAQ::NumberOfLdcs(const char *detectorName)
265 {
266   // Returns the number of DDLs for
267   // a given detector
268   Int_t detectorID = DetectorID(detectorName);
269   if (detectorID < 0)
270     return -1;
271
272   return NumberOfLdcs(detectorID);
273 }
274
275 Float_t AliDAQ::NumberOfLdcs(Int_t detectorID)
276 {
277   // Returns the number of DDLs for
278   // a given detector
279   if (detectorID < 0 || detectorID >= kNDetectors) {
280     AliErrorClass(Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1));
281     return -1;
282   }
283
284   return fgkNumberOfLdcs[detectorID];
285 }