]>
Commit | Line | Data |
---|---|---|
1605abc6 | 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 | * author: Roberto Preghenella (R+), Roberto.Preghenella@bo.infn.it | |
18 | */ | |
19 | ||
20 | ////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // // | |
23 | // This class provides the TOF FEE reader. // | |
24 | // // | |
25 | // // | |
26 | ////////////////////////////////////////////////////////////////////// | |
27 | ||
5b086af5 | 28 | #include <TSystem.h> |
1605abc6 | 29 | #include "AliTOFFEEReader.h" |
30 | #include "AliTOFFEEConfig.h" | |
31 | #include "AliTOFRawStream.h" | |
39dff6a4 | 32 | #include "AliTOFGeometry.h" |
1605abc6 | 33 | #include "AliLog.h" |
34 | #include <fstream> | |
35 | ||
36 | ClassImp(AliTOFFEEReader) | |
37 | ||
38 | //_______________________________________________________________ | |
39 | ||
40 | AliTOFFEEReader::AliTOFFEEReader() : | |
41 | TObject(), | |
42 | fFEEConfig(new AliTOFFEEConfig()), | |
43 | fChannelEnabled() | |
44 | { | |
45 | /* | |
46 | * | |
47 | * default constructor | |
48 | * | |
49 | */ | |
50 | ||
51 | } | |
52 | ||
53 | //_______________________________________________________________ | |
54 | ||
55 | AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) : | |
56 | TObject(source), | |
57 | fFEEConfig(new AliTOFFEEConfig()) | |
58 | { | |
59 | /* | |
60 | * | |
61 | * copy constructor | |
62 | * | |
63 | */ | |
64 | ||
65 | memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig)); | |
66 | } | |
67 | ||
68 | //_______________________________________________________________ | |
69 | ||
70 | AliTOFFEEReader & | |
71 | AliTOFFEEReader::operator=(const AliTOFFEEReader &source) | |
72 | { | |
73 | /* | |
74 | * | |
75 | * operator = | |
76 | * | |
77 | */ | |
78 | ||
79 | TObject::operator=(source); | |
80 | memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig)); | |
81 | return *this; | |
82 | } | |
83 | ||
84 | //_______________________________________________________________ | |
85 | ||
86 | AliTOFFEEReader::~AliTOFFEEReader() | |
87 | { | |
88 | /* | |
89 | * | |
90 | * default destructor | |
91 | * | |
92 | */ | |
93 | ||
94 | delete fFEEConfig; | |
95 | } | |
96 | ||
97 | //_______________________________________________________________ | |
98 | ||
99 | void | |
100 | AliTOFFEEReader::ResetChannelEnabledArray() | |
101 | { | |
102 | /* | |
103 | * | |
104 | * reset channel enabled array | |
105 | * | |
106 | */ | |
107 | ||
108 | for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) | |
109 | fChannelEnabled[iIndex] = kFALSE; | |
110 | } | |
111 | ||
112 | //_______________________________________________________________ | |
113 | ||
114 | void | |
39dff6a4 | 115 | AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const |
1605abc6 | 116 | { |
117 | /* | |
118 | * | |
119 | * load FEE config | |
120 | * | |
121 | */ | |
122 | ||
5b086af5 | 123 | Char_t *expandedFileName = gSystem->ExpandPathName(FileName); |
1605abc6 | 124 | std::ifstream is; |
5b086af5 | 125 | is.open(expandedFileName, std::ios::binary); |
1605abc6 | 126 | is.read((Char_t *)fFEEConfig, sizeof(AliTOFFEEConfig)); |
127 | is.close(); | |
128 | } | |
129 | ||
130 | //_______________________________________________________________ | |
131 | ||
132 | Int_t | |
133 | AliTOFFEEReader::ParseFEEConfig() | |
134 | { | |
135 | /* | |
136 | * | |
137 | * parse FEE config | |
138 | * | |
139 | * loops over all FEE channels, checks whether they are enabled | |
140 | * and sets channel enabled | |
141 | * | |
142 | */ | |
143 | ||
144 | AliInfo("parsing TOF FEE config") | |
145 | ||
146 | AliTOFRawStream rawStream; | |
147 | Int_t nEnabled = 0; | |
148 | Int_t volume[5], index; | |
149 | Int_t temp; | |
150 | ||
151 | ResetChannelEnabledArray(); | |
152 | ||
153 | /* loop over all FEE channels */ | |
154 | for (Int_t iDDL = 0; iDDL < GetNumberOfDDLs(); iDDL++) | |
155 | for (Int_t iTRM = 0; iTRM < GetNumberOfTRMs(); iTRM++) | |
156 | for (Int_t iChain = 0; iChain < GetNumberOfChains(); iChain++) | |
157 | for (Int_t iTDC = 0; iTDC < GetNumberOfTDCs(); iTDC++) | |
158 | for (Int_t iChannel = 0; iChannel < GetNumberOfChannels(); iChannel++) | |
159 | /* check whether FEE channel is enabled */ | |
160 | if (IsChannelEnabled(iDDL, iTRM + 3, iChain, iTDC, iChannel)) { | |
161 | /* convert FEE channel indexes into detector indexes */ | |
162 | rawStream.EquipmentId2VolumeId(iDDL, iTRM + 3, iChain, iTDC, iChannel, volume); | |
163 | /* swap padx and padz to fit AliTOFGeometry::GetIndex behaviour */ | |
164 | temp = volume[4]; volume[4] = volume[3]; volume[3] = temp; | |
165 | /* convert detector indexes into calibration index */ | |
166 | index = AliTOFGeometry::GetIndex(volume); | |
167 | /* check calibration index */ | |
168 | if (index != -1 && index < GetNumberOfIndexes()) { | |
169 | /* set calibration channel enabled */ | |
170 | fChannelEnabled[index] = kTRUE; | |
171 | nEnabled++; | |
172 | } | |
173 | } | |
174 | return nEnabled; | |
175 | } | |
176 | ||
177 | //_______________________________________________________________ | |
178 | ||
179 | Bool_t | |
39dff6a4 | 180 | AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const |
1605abc6 | 181 | { |
182 | /* | |
183 | * | |
184 | * is channel enabled | |
185 | * | |
186 | * checks whether a FEE channel is enabled using the | |
187 | * TOF FEE config object. | |
188 | * | |
189 | */ | |
190 | ||
191 | AliTOFFEEConfig *feeConfig; | |
192 | AliTOFCrateConfig *crateConfig; | |
193 | AliTOFTRMConfig *trmConfig; | |
194 | Int_t maskPB, maskTDC; | |
195 | ||
196 | /* get and check fee config */ | |
197 | if (!(feeConfig = GetFEEConfig())) | |
198 | return kFALSE; | |
199 | ||
200 | /* get and check crate config */ | |
201 | if (!(crateConfig = feeConfig->GetCrateConfig(iDDL))) | |
202 | return kFALSE; | |
203 | ||
204 | /* get and check TRM config */ | |
205 | if (!(trmConfig = crateConfig->GetTRMConfig(iTRM - 3))) | |
206 | return kFALSE; | |
207 | ||
208 | /* check DRM enabled */ | |
209 | if (!crateConfig->IsDRMEnabled()) | |
210 | return kFALSE; | |
211 | ||
212 | /* check TRM enabled */ | |
213 | if (!crateConfig->IsTRMEnabled(iTRM - 3)) | |
214 | return kFALSE; | |
215 | ||
216 | /* switch chain */ | |
217 | switch (iChain) { | |
218 | /* chain A */ | |
219 | case 0: | |
220 | /* check chain enabled */ | |
221 | if (trmConfig->GetChainAFlag() != 1) | |
222 | return kFALSE; | |
223 | /* switch TDC */ | |
224 | switch (iTDC) { | |
225 | case 0: case 1: case 2: | |
226 | maskPB = trmConfig->GetMaskPB0(); | |
227 | break; | |
228 | case 3: case 4: case 5: | |
229 | maskPB = trmConfig->GetMaskPB1(); | |
230 | break; | |
231 | case 6: case 7: case 8: | |
232 | maskPB = trmConfig->GetMaskPB2(); | |
233 | break; | |
234 | case 9: case 10: case 11: | |
235 | maskPB = trmConfig->GetMaskPB3(); | |
236 | break; | |
237 | case 12: case 13: case 14: | |
238 | maskPB = trmConfig->GetMaskPB4(); | |
239 | break; | |
240 | default: | |
241 | return kFALSE; | |
242 | break; | |
243 | } /* switch TDC */ | |
244 | break; /* chain A */ | |
245 | /* chain B */ | |
246 | case 1: | |
247 | /* check chain enabled */ | |
248 | if (trmConfig->GetChainBFlag() != 1) | |
249 | return kFALSE; | |
250 | /* switch TDC */ | |
251 | switch (iTDC) { | |
252 | case 0: case 1: case 2: | |
253 | maskPB = trmConfig->GetMaskPB5(); | |
254 | break; | |
255 | case 3: case 4: case 5: | |
256 | maskPB = trmConfig->GetMaskPB6(); | |
257 | break; | |
258 | case 6: case 7: case 8: | |
259 | maskPB = trmConfig->GetMaskPB7(); | |
260 | break; | |
261 | case 9: case 10: case 11: | |
262 | maskPB = trmConfig->GetMaskPB8(); | |
263 | break; | |
264 | case 12: case 13: case 14: | |
265 | maskPB = trmConfig->GetMaskPB9(); | |
266 | break; | |
267 | default: | |
268 | return kFALSE; | |
269 | break; | |
270 | } /* switch TDC */ | |
271 | break; /* chain B */ | |
272 | default: | |
273 | return kFALSE; | |
274 | break; | |
275 | } /* switch chain */ | |
276 | ||
277 | /* check channel enabled */ | |
278 | maskTDC = (maskPB & (0xFF << ((iTDC % 3) * 8))) >> ((iTDC % 3) * 8); | |
279 | if (maskTDC & (0x1 << iChannel)) | |
280 | return kTRUE; | |
281 | else | |
282 | return kFALSE; | |
283 | ||
284 | } | |
285 | ||
286 | ||
287 | void | |
288 | AliTOFFEEReader::DumpFEEConfig() | |
289 | { | |
290 | /* | |
291 | * | |
292 | * dump FEE config | |
293 | * | |
294 | */ | |
295 | ||
296 | AliTOFFEEConfig *feeConfig = GetFEEConfig(); | |
297 | AliTOFCrateConfig *crateConfig; | |
298 | AliTOFDRMConfig *drmConfig; | |
299 | AliTOFLTMConfig *ltmConfig; | |
300 | AliTOFTRMConfig *trmConfig; | |
301 | ||
302 | AliInfo("-------------------------------------"); | |
303 | AliInfo("dumping TOF FEE config"); | |
304 | AliInfo("-------------------------------------"); | |
305 | AliInfo(Form("version: %d", feeConfig->GetVersion())); | |
306 | AliInfo(Form("dump time: %d", feeConfig->GetDumpTime())); | |
307 | AliInfo(Form("run number: %d", feeConfig->GetRunNumber())); | |
308 | AliInfo(Form("run type: %d", feeConfig->GetRunType())); | |
309 | AliInfo("-------------------------------------"); | |
310 | ||
311 | /* loop over crates */ | |
312 | for (Int_t iCrate = 0; iCrate < AliTOFFEEConfig::GetNumberOfCrates(); iCrate++) { | |
313 | crateConfig = feeConfig->GetCrateConfig(iCrate); | |
314 | ||
315 | /* check crate config */ | |
316 | if (!crateConfig) | |
317 | continue; | |
318 | ||
319 | /* check DRM enabled */ | |
320 | if (!crateConfig->IsDRMEnabled()) | |
321 | continue; | |
322 | ||
323 | AliInfo(Form("crate id: %02d", iCrate)); | |
324 | ||
325 | /* dump DRM config */ | |
326 | drmConfig = crateConfig->GetDRMConfig(); | |
327 | AliInfo(Form("DRM is enabled: drmId=%d, slotMask=%03x", drmConfig->GetDRMId(), drmConfig->GetSlotMask())); | |
328 | ||
329 | /* dump LTM config if enabled */ | |
330 | if (crateConfig->IsLTMEnabled()) { | |
331 | ltmConfig = crateConfig->GetLTMConfig(); | |
332 | AliInfo(Form("LTM is enabled: threshold=%d", ltmConfig->GetThreshold())); | |
333 | } | |
334 | ||
335 | /* dump CPDM config if enabled */ | |
336 | if (crateConfig->IsCPDMEnabled()) { | |
337 | AliInfo(Form("CPDM is enabled")); | |
338 | } | |
339 | ||
340 | /* loop over TRMs */ | |
341 | for (Int_t iTRM = 0; iTRM < AliTOFCrateConfig::GetNumberOfTRMs(); iTRM++) { | |
342 | ||
343 | trmConfig = crateConfig->GetTRMConfig(iTRM); | |
344 | ||
345 | /* check TRM config */ | |
346 | if (!trmConfig) | |
347 | continue; | |
348 | ||
349 | /* check TRM enabled */ | |
350 | if (!crateConfig->IsTRMEnabled(iTRM)) | |
351 | continue; | |
352 | ||
353 | /* dump TRM config */ | |
354 | AliInfo(Form("TRM%02d is enabled: matchWin=%d, latWin=%d, packFlag=%d", iTRM + 3, trmConfig->GetMatchingWindow(), trmConfig->GetLatencyWindow(), trmConfig->GetPackingFlag())); | |
355 | ||
356 | /* check TRM chain A flag */ | |
357 | if (trmConfig->GetChainAFlag() == 1) { | |
358 | AliInfo(Form("TRM%02d chainA is enabled: PB0=%06X, PB1=%06X, PB2=%06X, PB3=%06X, PB4=%06X", iTRM + 3, trmConfig->GetMaskPB0(), trmConfig->GetMaskPB1(), trmConfig->GetMaskPB2(), trmConfig->GetMaskPB3(), trmConfig->GetMaskPB4())); | |
359 | } | |
360 | ||
361 | /* check TRM chain B flag */ | |
362 | if (trmConfig->GetChainBFlag() == 1) { | |
363 | AliInfo(Form("TRM%02d chainB is enabled: PB5=%06X, PB6=%06X, PB7=%06X, PB8=%06X, PB9=%06X", iTRM + 3, trmConfig->GetMaskPB5(), trmConfig->GetMaskPB6(), trmConfig->GetMaskPB7(), trmConfig->GetMaskPB8(), trmConfig->GetMaskPB9())); | |
364 | } | |
365 | ||
366 | ||
367 | ||
368 | } /* loop over TRMs */ | |
369 | AliInfo("-------------------------------------"); | |
370 | } /* loop over crates */ | |
371 | } | |
372 |