]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSModuleDaSSD.cxx
Eff C++ warning removal (Marian)
[u/mrichter/AliRoot.git] / ITS / AliITSModuleDaSSD.cxx
CommitLineData
223dda26 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
2e2c6def 16/* $Id:$ */
223dda26 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"
2e2c6def 26#include "AliITSPedestalSSD.h"
27#include "AliITSBadChannelsSSD.h"
f67db810 28#include "AliITSModuleDaSSD.h"
c4d90345 29#include "TString.h"
30#include "AliLog.h"
f67db810 31
32ClassImp(AliITSModuleDaSSD)
33
c4d90345 34
35const Int_t AliITSModuleDaSSD::fgkStripsPerModule = 1536; // Number of strips per SSD module
36const Int_t AliITSModuleDaSSD::fgkPNStripsPerModule = 768; // Number of N/P strips per SSD module
37const Int_t AliITSModuleDaSSD::fgkStripsPerChip = 128; // Number of strips per chip HAL25
38const UChar_t AliITSModuleDaSSD::fgkMaxAdNumber = 9; // MAx SSD FEROM AD number
39const UChar_t AliITSModuleDaSSD::fgkMaxAdcNumber = 13; // MAx SSD FEROM ADC number
40const Int_t AliITSModuleDaSSD::fgkChipsPerModule = 12; // Number of HAL25 chips per SSD module
41
42
43
f67db810 44using namespace std;
45
c4d90345 46//______________________________________________________________________________
f67db810 47AliITSModuleDaSSD::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),
c4d90345 56 fNumberOfChips(0),
57 fCm(NULL),
f67db810 58 fEventsNumber(0)
59{
223dda26 60// Default constructor
f67db810 61}
62
63
c4d90345 64//______________________________________________________________________________
f67db810 65AliITSModuleDaSSD::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),
c4d90345 74 fNumberOfChips(0),
75 fCm(NULL),
f67db810 76 fEventsNumber(0)
77{
223dda26 78// Constructor, set module id data
f67db810 79}
80
81
82
c4d90345 83//______________________________________________________________________________
f67db810 84AliITSModuleDaSSD::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),
c4d90345 93 fNumberOfChips(0),
94 fCm(NULL),
f67db810 95 fEventsNumber(0)
96{
223dda26 97// Constructor, allocates memory for AliITSChannelDaSSD*
f67db810 98 if (numberofstrips != fgkStripsPerModule)
c4d90345 99 AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule));
223dda26 100 fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips];
101 if (fStrips) {
f67db810 102 fNumberOfStrips = numberofstrips;
103 for (Int_t i = 0; i < numberofstrips; i++) fStrips[i]= NULL;
223dda26 104 } else {
c4d90345 105 AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips));
f67db810 106 fNumberOfStrips = 0;
107 fStrips = NULL;
223dda26 108 }
f67db810 109}
110
111
c4d90345 112//______________________________________________________________________________
f67db810 113AliITSModuleDaSSD::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),
c4d90345 122 fNumberOfChips(0),
123 fCm(NULL),
f67db810 124 fEventsNumber(0)
125{
223dda26 126// Constructor, allocates memory for AliITSChannelDaSSD* and events data
f67db810 127 if (numberofstrips != fgkStripsPerModule)
c4d90345 128 AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule));
223dda26 129 fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips];
130 if (fStrips) {
f67db810 131 fNumberOfStrips = numberofstrips;
223dda26 132 memset(fStrips, 0, numberofstrips * sizeof(AliITSChannelDaSSD*));
133 for (Int_t i = 0; i < fNumberOfStrips; i++) {
134 fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber);
c4d90345 135 if (!fStrips[i]) AliError(Form("AliITSModuleDaSSD: Error allocating memory for AliITSChannelDaSSD %i-th object", i));
223dda26 136 }
137 } else {
c4d90345 138 AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips));
f67db810 139 fNumberOfStrips = 0;
140 fStrips = NULL;
f67db810 141 }
142}
143
144
145
c4d90345 146//______________________________________________________________________________
f67db810 147AliITSModuleDaSSD::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),
a69c8ba0 156 fStrips(NULL),
c4d90345 157 fNumberOfChips(module.fNumberOfChips),
a69c8ba0 158 fCm(NULL),
f67db810 159 fEventsNumber(module.fEventsNumber)
160{
223dda26 161// copy constructor
a69c8ba0 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 }
f67db810 193}
194
195
196
c4d90345 197//______________________________________________________________________________
f67db810 198AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& module)
199{
200// assignment operator
a69c8ba0 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 }
f67db810 249 return *this;
250}
251
252
253
c4d90345 254//______________________________________________________________________________
f67db810 255AliITSModuleDaSSD::~AliITSModuleDaSSD()
256{
223dda26 257// Destructor
f67db810 258 if (fStrips)
259 {
260 for (Long_t i = 0; i < fNumberOfStrips; i++)
261 {
262 if (fStrips[i]) delete fStrips[i];
f67db810 263 }
264 delete [] fStrips;
265 }
c4d90345 266 if (fCm) delete [] fCm;
267}
268
269
270
271//______________________________________________________________________________
272Bool_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 }
f67db810 294}
295
296
c4d90345 297//______________________________________________________________________________
298Bool_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
f67db810 317
c4d90345 318//______________________________________________________________________________
319Bool_t AliITSModuleDaSSD::SetModuleIdData (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Short_t moduleID)
f67db810 320{
223dda26 321// SetModuleIdData
f67db810 322 if (ad > fgkMaxAdNumber) {
c4d90345 323 AliWarning(Form("AliITSModuleDaSSD: Wrong AD number: %i", ad));
f67db810 324 return kFALSE;
325 }
326 if (adc > fgkMaxAdcNumber || ForbiddenAdcNumber(adc)) {
c4d90345 327 AliWarning(Form("AliITSModuleDaSSD: Wrong ADC number: %i", adc));
f67db810 328 return kFALSE;
329 }
330 fDdlId = ddlID;
331 fAd = ad;
332 fAdc = adc;
333 fModuleId = moduleID;
334 return kTRUE;
335}
336
337
c4d90345 338//______________________________________________________________________________
f67db810 339void AliITSModuleDaSSD::SetModuleFEEId (const UChar_t ddlID, const UChar_t ad, const UChar_t adc)
340{
223dda26 341// Set id data of FEE connected to the Module
f67db810 342 fDdlId = ddlID;
343 fAd = ad;
344 fAdc = adc;
345}
346
347
c4d90345 348//______________________________________________________________________________
f67db810 349void AliITSModuleDaSSD::SetModuleRorcId (const Int_t equipid, const Int_t equiptype)
350{
223dda26 351// Set data to access FEROM registres via DDL
f67db810 352 fEquipId = equipid;
353 fEquipType = equiptype;
354}
355
356
c4d90345 357//______________________________________________________________________________
f67db810 358Bool_t AliITSModuleDaSSD::SetEventsNumber(const Long_t eventsnumber)
359{
00e18e8f 360// Allocate the memory for the events data
f67db810 361 Int_t i;
362 if (!fStrips) return kFALSE;
00e18e8f 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();
c4d90345 367 AliError(Form("AliITSModuleDaSSD: Error allocating memory for i% events for module %i, strip %i",
368 eventsnumber, (Int_t)fModuleId, i));
00e18e8f 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;
c4d90345 377 AliError(Form("AliITSModuleDaSSD: Error allocating memory for strip %i of module %i!", (Int_t)fModuleId, i));
00e18e8f 378 return kFALSE;
379 }
380 }
f67db810 381 return kTRUE;
382}
383
384
385
c4d90345 386//______________________________________________________________________________
387Bool_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//______________________________________________________________________________
399Float_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//______________________________________________________________________________
2e2c6def 410AliITSNoiseSSD* AliITSModuleDaSSD::GetCalibrationNoise() const
f67db810 411{
223dda26 412// Creates the AliITSNoiseSSD objects with callibration data
f67db810 413 AliITSNoiseSSD *mc;
c4d90345 414 Float_t noise;
f67db810 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++) {
c4d90345 421 if (!fStrips[i]) noise = AliITSChannelDaSSD::GetUndefinedValue();
422 else noise = fStrips[i]->GetNoiseCM();
f67db810 423 if (i < fgkPNStripsPerModule)
c4d90345 424 mc->AddNoiseP(i, noise);
425 else mc->AddNoiseN((AliITSChannelDaSSD::GetMaxStripIdConst() - i), noise);
f67db810 426 }
427 return mc;
428}
2e2c6def 429
430
431
432//______________________________________________________________________________
433AliITSPedestalSSD* 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//______________________________________________________________________________
456AliITSBadChannelsSSD* 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}