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