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