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