]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 2007-2009, 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 | /* $Id:$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides storage container ITS SSD module callibration data | |
21 | /// used by DA. | |
22 | /// | |
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include "AliITSNoiseSSD.h" | |
26 | #include "AliITSPedestalSSD.h" | |
27 | #include "AliITSBadChannelsSSD.h" | |
28 | #include "AliITSModuleDaSSD.h" | |
29 | #include "TString.h" | |
30 | #include "AliLog.h" | |
31 | ||
32 | ClassImp(AliITSModuleDaSSD) | |
33 | ||
34 | ||
35 | const Int_t AliITSModuleDaSSD::fgkStripsPerModule = 1536; // Number of strips per SSD module | |
36 | const Int_t AliITSModuleDaSSD::fgkPNStripsPerModule = 768; // Number of N/P strips per SSD module | |
37 | const Int_t AliITSModuleDaSSD::fgkStripsPerChip = 128; // Number of strips per chip HAL25 | |
38 | const UChar_t AliITSModuleDaSSD::fgkMaxAdNumber = 9; // MAx SSD FEROM AD number | |
39 | const UChar_t AliITSModuleDaSSD::fgkMaxAdcNumber = 13; // MAx SSD FEROM ADC number | |
40 | const Int_t AliITSModuleDaSSD::fgkChipsPerModule = 12; // Number of HAL25 chips per SSD module | |
41 | ||
42 | ||
43 | ||
44 | using namespace std; | |
45 | ||
46 | //______________________________________________________________________________ | |
47 | AliITSModuleDaSSD::AliITSModuleDaSSD() : | |
48 | fEquipId(0), | |
49 | fEquipType(0), | |
50 | fDdlId(0), | |
51 | fAd(0), | |
52 | fAdc(0), | |
53 | fModuleId(0), | |
54 | fNumberOfStrips(0), | |
55 | fStrips(NULL), | |
56 | fNumberOfChips(0), | |
57 | fCm(NULL), | |
58 | fEventsNumber(0) | |
59 | { | |
60 | // Default constructor | |
61 | } | |
62 | ||
63 | ||
64 | //______________________________________________________________________________ | |
65 | AliITSModuleDaSSD::AliITSModuleDaSSD(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t moduleID) : | |
66 | fEquipId(0), | |
67 | fEquipType(0), | |
68 | fDdlId(ddlID), | |
69 | fAd(ad), | |
70 | fAdc(adc), | |
71 | fModuleId(moduleID), | |
72 | fNumberOfStrips(0), | |
73 | fStrips(NULL), | |
74 | fNumberOfChips(0), | |
75 | fCm(NULL), | |
76 | fEventsNumber(0) | |
77 | { | |
78 | // Constructor, set module id data | |
79 | } | |
80 | ||
81 | ||
82 | ||
83 | //______________________________________________________________________________ | |
84 | AliITSModuleDaSSD::AliITSModuleDaSSD(const Int_t numberofstrips) : | |
85 | fEquipId(0), | |
86 | fEquipType(0), | |
87 | fDdlId(0), | |
88 | fAd(0), | |
89 | fAdc(0), | |
90 | fModuleId(0), | |
91 | fNumberOfStrips(0), | |
92 | fStrips(NULL), | |
93 | fNumberOfChips(0), | |
94 | fCm(NULL), | |
95 | fEventsNumber(0) | |
96 | { | |
97 | // Constructor, allocates memory for AliITSChannelDaSSD* | |
98 | if (numberofstrips != fgkStripsPerModule) | |
99 | AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule)); | |
100 | fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips]; | |
101 | if (fStrips) { | |
102 | fNumberOfStrips = numberofstrips; | |
103 | for (Int_t i = 0; i < numberofstrips; i++) fStrips[i]= NULL; | |
104 | } else { | |
105 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips)); | |
106 | fNumberOfStrips = 0; | |
107 | fStrips = NULL; | |
108 | } | |
109 | } | |
110 | ||
111 | ||
112 | //______________________________________________________________________________ | |
113 | AliITSModuleDaSSD::AliITSModuleDaSSD(const Int_t numberofstrips, const Long_t eventsnumber) : | |
114 | fEquipId(0), | |
115 | fEquipType(0), | |
116 | fDdlId(0), | |
117 | fAd(0), | |
118 | fAdc(0), | |
119 | fModuleId(0), | |
120 | fNumberOfStrips(0), | |
121 | fStrips(NULL), | |
122 | fNumberOfChips(0), | |
123 | fCm(NULL), | |
124 | fEventsNumber(0) | |
125 | { | |
126 | // Constructor, allocates memory for AliITSChannelDaSSD* and events data | |
127 | if (numberofstrips != fgkStripsPerModule) | |
128 | AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule)); | |
129 | fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips]; | |
130 | if (fStrips) { | |
131 | fNumberOfStrips = numberofstrips; | |
132 | memset(fStrips, 0, numberofstrips * sizeof(AliITSChannelDaSSD*)); | |
133 | for (Int_t i = 0; i < fNumberOfStrips; i++) { | |
134 | fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber); | |
135 | if (!fStrips[i]) AliError(Form("AliITSModuleDaSSD: Error allocating memory for AliITSChannelDaSSD %i-th object", i)); | |
136 | } | |
137 | } else { | |
138 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips)); | |
139 | fNumberOfStrips = 0; | |
140 | fStrips = NULL; | |
141 | } | |
142 | } | |
143 | ||
144 | ||
145 | ||
146 | //______________________________________________________________________________ | |
147 | AliITSModuleDaSSD::AliITSModuleDaSSD(const AliITSModuleDaSSD& module) : | |
148 | TObject(module), | |
149 | fEquipId(module.fEquipId), | |
150 | fEquipType(module.fEquipType), | |
151 | fDdlId(module.fDdlId), | |
152 | fAd(module.fAd), | |
153 | fAdc(module.fAdc), | |
154 | fModuleId(module.fModuleId), | |
155 | fNumberOfStrips(module.fNumberOfStrips), | |
156 | fStrips(NULL), | |
157 | fNumberOfChips(module.fNumberOfChips), | |
158 | fCm(NULL), | |
159 | fEventsNumber(module.fEventsNumber) | |
160 | { | |
161 | // copy constructor | |
162 | if ((module.fNumberOfStrips > 0) && (module.fStrips)) { | |
163 | fStrips = new (nothrow) AliITSChannelDaSSD* [module.fNumberOfStrips]; | |
164 | if (fStrips) { | |
165 | for (Int_t strind = 0; strind < module.fNumberOfStrips; strind++) { | |
166 | if (module.fStrips[strind]) { | |
167 | fStrips[strind] = new AliITSChannelDaSSD(*(module.fStrips[strind])); | |
168 | if (!fStrips[strind]) { | |
169 | AliError("AliITSModuleDaSSD: Error copy constructor"); | |
170 | for (Int_t i = (strind - 1); i >= 0; i--) delete fStrips[strind]; | |
171 | delete [] fStrips; | |
172 | fStrips = NULL; | |
173 | break; | |
174 | } | |
175 | } else fStrips[strind] = NULL; | |
176 | } | |
177 | } else { | |
178 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", module.fNumberOfStrips)); | |
179 | fNumberOfStrips = 0; | |
180 | fStrips = NULL; | |
181 | } | |
182 | } | |
183 | if (module.fCm) { | |
184 | fCm = new (nothrow) TArrayF [module.fNumberOfChips]; | |
185 | if (fCm) { | |
186 | for (Int_t chind = 0; chind < module.fNumberOfChips; chind++) fCm[chind] = module.fCm[chind]; | |
187 | } else { | |
188 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayF objects!", module.fNumberOfChips)); | |
189 | fNumberOfChips = 0; | |
190 | fCm = NULL; | |
191 | } | |
192 | } | |
193 | } | |
194 | ||
195 | ||
196 | ||
197 | //______________________________________________________________________________ | |
198 | AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& module) | |
199 | { | |
200 | // assignment operator | |
201 | if (this == &module) return *this; | |
202 | if (fStrips) { | |
203 | for (Long_t i = 0; i < fNumberOfStrips; i++) if (fStrips[i]) delete fStrips[i]; | |
204 | delete [] fStrips; | |
205 | } | |
206 | fEquipId = module.fEquipId; | |
207 | fEquipType = module.fEquipType; | |
208 | fDdlId = module.fDdlId; | |
209 | fAd = module.fAd; | |
210 | fAdc = module.fAdc; | |
211 | fModuleId = module.fModuleId; | |
212 | fNumberOfStrips = module.fNumberOfStrips; | |
213 | fStrips = NULL; | |
214 | fNumberOfChips = module.fNumberOfChips; | |
215 | fCm = NULL; | |
216 | fEventsNumber = module.fEventsNumber; | |
217 | if ((module.fNumberOfStrips > 0) && (module.fStrips)) { | |
218 | fStrips = new (nothrow) AliITSChannelDaSSD* [module.fNumberOfStrips]; | |
219 | if (fStrips) { | |
220 | for (Int_t strind = 0; strind < module.fNumberOfStrips; strind++) { | |
221 | if (module.fStrips[strind]) { | |
222 | fStrips[strind] = new AliITSChannelDaSSD(*(module.fStrips[strind])); | |
223 | if (!fStrips[strind]) { | |
224 | AliError("AliITSModuleDaSSD: Error copy constructor"); | |
225 | for (Int_t i = (strind - 1); i >= 0; i--) delete fStrips[strind]; | |
226 | delete [] fStrips; | |
227 | fStrips = NULL; | |
228 | break; | |
229 | } | |
230 | } else fStrips[strind] = NULL; | |
231 | } | |
232 | } else { | |
233 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", module.fNumberOfStrips)); | |
234 | fNumberOfStrips = 0; | |
235 | fStrips = NULL; | |
236 | } | |
237 | } | |
238 | if (fCm) delete [] fCm; | |
239 | if (module.fCm) { | |
240 | fCm = new (nothrow) TArrayF [module.fNumberOfChips]; | |
241 | if (fCm) { | |
242 | for (Int_t chind = 0; chind < module.fNumberOfChips; chind++) fCm[chind] = module.fCm[chind]; | |
243 | } else { | |
244 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayF objects!", module.fNumberOfChips)); | |
245 | fNumberOfChips = 0; | |
246 | fCm = NULL; | |
247 | } | |
248 | } | |
249 | return *this; | |
250 | } | |
251 | ||
252 | ||
253 | ||
254 | //______________________________________________________________________________ | |
255 | AliITSModuleDaSSD::~AliITSModuleDaSSD() | |
256 | { | |
257 | // Destructor | |
258 | if (fStrips) | |
259 | { | |
260 | for (Long_t i = 0; i < fNumberOfStrips; i++) | |
261 | { | |
262 | if (fStrips[i]) delete fStrips[i]; | |
263 | } | |
264 | delete [] fStrips; | |
265 | } | |
266 | if (fCm) delete [] fCm; | |
267 | } | |
268 | ||
269 | ||
270 | ||
271 | //______________________________________________________________________________ | |
272 | Bool_t AliITSModuleDaSSD::SetNumberOfStrips(const Int_t numberofstrips) | |
273 | { | |
274 | // Allocates memory for AliITSChannelDaSSD* | |
275 | if (fStrips) { | |
276 | for (Int_t i = 0; i < fNumberOfStrips; i++) if (fStrips[i]) delete fStrips[i]; | |
277 | delete [] fStrips; | |
278 | fStrips = NULL; | |
279 | } | |
280 | if (numberofstrips <= 0) {fNumberOfStrips = 0; return kTRUE; } | |
281 | if (numberofstrips != fgkStripsPerModule) | |
282 | AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule)); | |
283 | fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips]; | |
284 | if (fStrips) { | |
285 | fNumberOfStrips = numberofstrips; | |
286 | memset(fStrips, 0, sizeof(AliITSChannelDaSSD*) * numberofstrips); | |
287 | return kTRUE; | |
288 | } else { | |
289 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips)); | |
290 | fNumberOfStrips = 0; | |
291 | fStrips = NULL; | |
292 | return kFALSE; | |
293 | } | |
294 | } | |
295 | ||
296 | ||
297 | //______________________________________________________________________________ | |
298 | Bool_t AliITSModuleDaSSD::SetNumberOfChips(const Int_t nchips) | |
299 | { | |
300 | // Allocate nchips TArrayF objects to save Common Mode | |
301 | DeleteCM(); | |
302 | if (nchips <= 0) {fNumberOfChips = 0; return kTRUE; } | |
303 | if (nchips != fgkChipsPerModule) | |
304 | AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i HAL25 chips", fgkChipsPerModule)); | |
305 | fCm = new (nothrow) TArrayF [nchips]; | |
306 | if (fCm) { | |
307 | fNumberOfChips = nchips; | |
308 | return kTRUE; | |
309 | } else { | |
310 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayF objects!", nchips)); | |
311 | fNumberOfChips = 0; | |
312 | fCm = NULL; | |
313 | return kFALSE; | |
314 | } | |
315 | } | |
316 | ||
317 | ||
318 | //______________________________________________________________________________ | |
319 | Bool_t AliITSModuleDaSSD::SetModuleIdData (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Short_t moduleID) | |
320 | { | |
321 | // SetModuleIdData | |
322 | if (ad > fgkMaxAdNumber) { | |
323 | AliWarning(Form("AliITSModuleDaSSD: Wrong AD number: %i", ad)); | |
324 | return kFALSE; | |
325 | } | |
326 | if (adc > fgkMaxAdcNumber || ForbiddenAdcNumber(adc)) { | |
327 | AliWarning(Form("AliITSModuleDaSSD: Wrong ADC number: %i", adc)); | |
328 | return kFALSE; | |
329 | } | |
330 | fDdlId = ddlID; | |
331 | fAd = ad; | |
332 | fAdc = adc; | |
333 | fModuleId = moduleID; | |
334 | return kTRUE; | |
335 | } | |
336 | ||
337 | ||
338 | //______________________________________________________________________________ | |
339 | void AliITSModuleDaSSD::SetModuleFEEId (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) | |
340 | { | |
341 | // Set id data of FEE connected to the Module | |
342 | fDdlId = ddlID; | |
343 | fAd = ad; | |
344 | fAdc = adc; | |
345 | } | |
346 | ||
347 | ||
348 | //______________________________________________________________________________ | |
349 | void AliITSModuleDaSSD::SetModuleRorcId (const Int_t equipid, const Int_t equiptype) | |
350 | { | |
351 | // Set data to access FEROM registres via DDL | |
352 | fEquipId = equipid; | |
353 | fEquipType = equiptype; | |
354 | } | |
355 | ||
356 | ||
357 | //______________________________________________________________________________ | |
358 | Bool_t AliITSModuleDaSSD::SetEventsNumber(const Long_t eventsnumber) | |
359 | { | |
360 | // Allocate the memory for the events data | |
361 | Int_t i; | |
362 | if (!fStrips) return kFALSE; | |
363 | for (i = 0; i < fNumberOfStrips; i++) { | |
364 | if (fStrips[i]) | |
365 | if (!fStrips[i]->SetEvenetsNumber(eventsnumber)) { | |
366 | for (Int_t j = 0; j < i; j++) fStrips[j]->DeleteSignal(); | |
367 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for i% events for module %i, strip %i", | |
368 | eventsnumber, (Int_t)fModuleId, i)); | |
369 | return kFALSE; | |
370 | } | |
371 | else | |
372 | if (!(fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber))) { | |
373 | for (Int_t j = 0; j < i; j++) delete fStrips[j]; | |
374 | delete [] fStrips; | |
375 | fNumberOfStrips = 0; | |
376 | fStrips = NULL; | |
377 | AliError(Form("AliITSModuleDaSSD: Error allocating memory for strip %i of module %i!", (Int_t)fModuleId, i)); | |
378 | return kFALSE; | |
379 | } | |
380 | } | |
381 | return kTRUE; | |
382 | } | |
383 | ||
384 | ||
385 | ||
386 | //______________________________________________________________________________ | |
387 | Bool_t AliITSModuleDaSSD::SetCM (const Float_t cm, const Int_t chipn, const Int_t evn) | |
388 | { | |
389 | // Set value of CM for a given chip and event | |
390 | if ((!fCm) || (chipn >= fNumberOfChips)) return kFALSE; | |
391 | if (evn >= fCm[chipn].GetSize()) return kFALSE; | |
392 | else fCm[chipn][evn] = cm; | |
393 | return kTRUE; | |
394 | } | |
395 | ||
396 | ||
397 | ||
398 | //______________________________________________________________________________ | |
399 | Float_t AliITSModuleDaSSD::GetCM(const Int_t chipn, const Long_t evn) const | |
400 | { | |
401 | // Get value of CM for a given chip and event | |
402 | if ((!fCm) || (chipn >= fNumberOfChips)) return 0.0f; | |
403 | if (evn >= fCm[chipn].GetSize()) return 0.0f; | |
404 | else return fCm[chipn][evn]; | |
405 | } | |
406 | ||
407 | ||
408 | ||
409 | //______________________________________________________________________________ | |
410 | AliITSNoiseSSD* AliITSModuleDaSSD::GetCalibrationNoise() const | |
411 | { | |
412 | // Creates the AliITSNoiseSSD objects with callibration data | |
413 | AliITSNoiseSSD *mc; | |
414 | Float_t noise; | |
415 | if (!fStrips) return NULL; | |
416 | mc = new AliITSNoiseSSD(); | |
417 | mc->SetMod(fModuleId); | |
418 | mc->SetNNoiseP(fgkPNStripsPerModule); | |
419 | mc->SetNNoiseN(fgkPNStripsPerModule); | |
420 | for (Int_t i = 0; i < fNumberOfStrips; i++) { | |
421 | if (!fStrips[i]) noise = AliITSChannelDaSSD::GetUndefinedValue(); | |
422 | else noise = fStrips[i]->GetNoiseCM(); | |
423 | if (i < fgkPNStripsPerModule) | |
424 | mc->AddNoiseP(i, noise); | |
425 | else mc->AddNoiseN((AliITSChannelDaSSD::GetMaxStripIdConst() - i), noise); | |
426 | } | |
427 | return mc; | |
428 | } | |
429 | ||
430 | ||
431 | ||
432 | //______________________________________________________________________________ | |
433 | AliITSPedestalSSD* AliITSModuleDaSSD::GetCalibrationPedestal() const | |
434 | { | |
435 | // Creates the AliITSPedestalSSD objects with callibration data | |
436 | AliITSPedestalSSD *mc; | |
437 | Float_t ped; | |
438 | if (!fStrips) return NULL; | |
439 | mc = new AliITSPedestalSSD(); | |
440 | mc->SetMod(fModuleId); | |
441 | mc->SetNPedestalP(fgkPNStripsPerModule); | |
442 | mc->SetNPedestalN(fgkPNStripsPerModule); | |
443 | for (Int_t i = 0; i < fNumberOfStrips; i++) { | |
444 | if (!fStrips[i]) ped = AliITSChannelDaSSD::GetUndefinedValue(); | |
445 | else ped = fStrips[i]->GetPedestal(); | |
446 | if (i < fgkPNStripsPerModule) | |
447 | mc->AddPedestalP(i, ped); | |
448 | else mc->AddPedestalN((AliITSChannelDaSSD::GetMaxStripIdConst() - i), ped); | |
449 | } | |
450 | return mc; | |
451 | } | |
452 | ||
453 | ||
454 | ||
455 | //______________________________________________________________________________ | |
456 | AliITSBadChannelsSSD* AliITSModuleDaSSD::GetCalibrationBadChannels() const | |
457 | { | |
458 | // Creates the AliITSBadChannelsSSD objects with callibration data | |
459 | AliITSBadChannelsSSD *mc; | |
460 | Int_t *chlist, nch = 0, nchn = 0, nchp = 0; | |
461 | if (!fStrips) return NULL; | |
462 | chlist = new Int_t [GetStripsPerModuleConst()]; | |
463 | for (Int_t i = 0; i < fNumberOfStrips; i++) { | |
464 | if (!fStrips[i]) { chlist[nch++] = i; if (i < fgkPNStripsPerModule) nchp++; else nchn++; continue;} | |
465 | if (fStrips[i]->GetNoiseCM() == AliITSChannelDaSSD::GetUndefinedValue()) | |
466 | { chlist[nch++] = i; if (i < fgkPNStripsPerModule) nchp++; else nchn++; } | |
467 | } | |
468 | mc = new AliITSBadChannelsSSD(); | |
469 | mc->SetMod(fModuleId); | |
470 | if (!nch) return mc; | |
471 | mc->SetNBadPChannelsList(nchp); | |
472 | mc->SetNBadNChannelsList(nchn); | |
473 | for (Int_t i = 0; i < nch; i++) { | |
474 | if (chlist[i] < fgkPNStripsPerModule) mc->AddBadPChannel(chlist[i], i); | |
475 | else mc->AddBadNChannel((AliITSChannelDaSSD::GetMaxStripIdConst() - chlist[i]), (i-nchp)); | |
476 | } | |
477 | return mc; | |
478 | } |