]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSModuleDaSSD.cxx
plitting of drift speed (updated at every physics run) from other calibration paramet...
[u/mrichter/AliRoot.git] / ITS / AliITSModuleDaSSD.cxx
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 "AliITSModuleDaSSD.h"
27 #include "TString.h"
28 #include "AliLog.h"
29
30 ClassImp(AliITSModuleDaSSD)
31
32
33 const Int_t   AliITSModuleDaSSD::fgkStripsPerModule   = 1536;   // Number of strips per SSD module
34 const Int_t   AliITSModuleDaSSD::fgkPNStripsPerModule = 768;    // Number of N/P strips per SSD module
35 const Int_t   AliITSModuleDaSSD::fgkStripsPerChip     = 128;    // Number of strips per chip HAL25
36 const UChar_t AliITSModuleDaSSD::fgkMaxAdNumber       = 9;      // MAx SSD FEROM AD number
37 const UChar_t AliITSModuleDaSSD::fgkMaxAdcNumber      = 13;     // MAx SSD FEROM ADC number
38 const Int_t   AliITSModuleDaSSD::fgkChipsPerModule    = 12;     // Number of HAL25 chips per SSD module
39
40
41
42 using namespace std;
43
44 //______________________________________________________________________________
45 AliITSModuleDaSSD::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),
54   fNumberOfChips(0),
55   fCm(NULL),
56   fEventsNumber(0)
57 {
58 // Default constructor
59 }
60
61
62 //______________________________________________________________________________
63 AliITSModuleDaSSD::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),
72   fNumberOfChips(0),
73   fCm(NULL),
74   fEventsNumber(0)
75 {
76 // Constructor, set module id data
77 }
78
79
80
81 //______________________________________________________________________________
82 AliITSModuleDaSSD::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),
91   fNumberOfChips(0),
92   fCm(NULL),
93   fEventsNumber(0)
94 {
95 // Constructor, allocates memory for AliITSChannelDaSSD*
96   if (numberofstrips != fgkStripsPerModule) 
97     AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule));
98   fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips];
99   if (fStrips) {
100      fNumberOfStrips = numberofstrips;
101      for (Int_t i = 0; i < numberofstrips; i++) fStrips[i]= NULL;
102   } else {
103      AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips));
104      fNumberOfStrips = 0;
105      fStrips = NULL;
106   }  
107 }
108
109
110 //______________________________________________________________________________
111 AliITSModuleDaSSD::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),
120   fNumberOfChips(0),
121   fCm(NULL),
122   fEventsNumber(0)
123 {
124 // Constructor, allocates memory for AliITSChannelDaSSD* and events data
125   if (numberofstrips != fgkStripsPerModule) 
126     AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule));
127   fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips];
128   if (fStrips) {
129      fNumberOfStrips = numberofstrips;
130      memset(fStrips, 0, numberofstrips * sizeof(AliITSChannelDaSSD*));
131      for (Int_t i = 0; i < fNumberOfStrips; i++) {
132        fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber);
133        if (!fStrips[i]) AliError(Form("AliITSModuleDaSSD: Error allocating memory for AliITSChannelDaSSD %i-th object", i));
134      }
135   } else {
136      AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips));
137      fNumberOfStrips = 0;
138      fStrips = NULL;
139   }  
140 }
141
142
143
144 //______________________________________________________________________________
145 AliITSModuleDaSSD::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),
154   fStrips(module.fStrips),
155   fNumberOfChips(module.fNumberOfChips),
156   fCm(module.fCm),
157   fEventsNumber(module.fEventsNumber)
158 {
159 // copy constructor
160
161   AliFatal("AliITSModuleDaSSD, copy constructor not implemented");
162 }
163
164
165
166 //______________________________________________________________________________
167 AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& module)
168 {
169 // assignment operator
170
171   AliFatal("AliITSModuleDaSSD: operator =, assignment operator not implemented");
172   return *this;
173 }
174     
175
176     
177 //______________________________________________________________________________
178 AliITSModuleDaSSD::~AliITSModuleDaSSD()
179 {
180 // Destructor
181   if (fStrips)
182   {
183     for (Long_t i = 0; i < fNumberOfStrips; i++)
184     { 
185       if (fStrips[i]) delete fStrips[i];
186     }
187     delete [] fStrips;
188   } 
189   if (fCm) delete [] fCm;
190 }
191
192
193
194 //______________________________________________________________________________
195 Bool_t AliITSModuleDaSSD::SetNumberOfStrips(const Int_t numberofstrips)
196 {
197 // Allocates memory for AliITSChannelDaSSD*
198   if (fStrips) {
199     for (Int_t i = 0; i < fNumberOfStrips; i++) if (fStrips[i]) delete fStrips[i];
200     delete [] fStrips;
201     fStrips = NULL;
202   }  
203   if (numberofstrips <= 0) {fNumberOfStrips = 0; return kTRUE; } 
204   if (numberofstrips != fgkStripsPerModule) 
205     AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule));
206   fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips];
207   if (fStrips) {
208      fNumberOfStrips = numberofstrips;
209      memset(fStrips, 0, sizeof(AliITSChannelDaSSD*) * numberofstrips);
210      return kTRUE;
211   } else {
212      AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips));
213      fNumberOfStrips = 0;
214      fStrips = NULL;
215      return kFALSE;
216   }  
217 }
218
219
220 //______________________________________________________________________________
221 Bool_t AliITSModuleDaSSD::SetNumberOfChips(const Int_t nchips)
222 {
223 // Allocate nchips TArrayF objects to save Common Mode
224   DeleteCM();
225   if (nchips <= 0) {fNumberOfChips = 0; return kTRUE; } 
226   if (nchips != fgkChipsPerModule) 
227     AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i HAL25 chips", fgkChipsPerModule));
228   fCm = new (nothrow) TArrayF [nchips];
229   if (fCm) {
230      fNumberOfChips = nchips;
231      return kTRUE;
232   } else {
233      AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayF objects!", nchips));
234      fNumberOfChips = 0;
235      fCm = NULL;
236      return kFALSE;
237   }  
238 }
239
240   
241 //______________________________________________________________________________
242 Bool_t AliITSModuleDaSSD::SetModuleIdData (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Short_t moduleID)
243 {
244 // SetModuleIdData
245   if (ad > fgkMaxAdNumber) {
246     AliWarning(Form("AliITSModuleDaSSD: Wrong AD number: %i", ad));
247     return kFALSE;
248   }  
249   if (adc > fgkMaxAdcNumber || ForbiddenAdcNumber(adc)) {
250     AliWarning(Form("AliITSModuleDaSSD: Wrong ADC number: %i", adc));
251     return kFALSE;
252   }  
253   fDdlId = ddlID;
254   fAd = ad;
255   fAdc = adc;
256   fModuleId = moduleID;
257   return kTRUE;
258 }
259
260
261 //______________________________________________________________________________
262 void AliITSModuleDaSSD::SetModuleFEEId (const UChar_t ddlID, const UChar_t ad, const UChar_t adc)
263 {
264 // Set id data of FEE connected to the Module
265   fDdlId = ddlID;
266   fAd = ad;
267   fAdc = adc;
268 }
269
270
271 //______________________________________________________________________________
272 void AliITSModuleDaSSD::SetModuleRorcId (const Int_t equipid, const Int_t equiptype)
273 {
274 // Set data to access FEROM registres via DDL
275   fEquipId = equipid; 
276   fEquipType = equiptype;
277 }
278
279
280 //______________________________________________________________________________
281 Bool_t AliITSModuleDaSSD::SetEventsNumber(const Long_t eventsnumber)
282 {
283 // Allocate the memory for the events data
284   Int_t i;
285   if (!fStrips) return kFALSE;
286   for (i = 0; i < fNumberOfStrips; i++) {
287     if (fStrips[i])  
288       if (!fStrips[i]->SetEvenetsNumber(eventsnumber)) {
289         for (Int_t j = 0; j < i; j++) fStrips[j]->DeleteSignal();
290         AliError(Form("AliITSModuleDaSSD: Error allocating memory for i% events for module %i, strip %i", 
291                                     eventsnumber, (Int_t)fModuleId, i));
292         return kFALSE;
293       }
294     else 
295       if (!(fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber))) {
296         for (Int_t j = 0; j < i; j++) delete fStrips[j];
297         delete [] fStrips;
298         fNumberOfStrips = 0;
299         fStrips = NULL;
300         AliError(Form("AliITSModuleDaSSD: Error allocating memory for strip %i of module %i!", (Int_t)fModuleId, i));
301         return kFALSE;
302       }
303   } 
304   return kTRUE;
305 }
306
307
308
309 //______________________________________________________________________________
310 Bool_t AliITSModuleDaSSD::SetCM (const Float_t cm, const Int_t chipn, const Int_t evn)
311
312 // Set value of CM for a given chip and event 
313   if ((!fCm) || (chipn >= fNumberOfChips)) return kFALSE;
314   if (evn >= fCm[chipn].GetSize()) return kFALSE;
315   else fCm[chipn][evn] = cm;
316   return kTRUE;
317 }
318
319
320
321 //______________________________________________________________________________
322 Float_t  AliITSModuleDaSSD::GetCM(const Int_t chipn, const Long_t evn)   const 
323
324 // Get value of CM for a given chip and event 
325   if ((!fCm) || (chipn >= fNumberOfChips)) return 0.0f;
326   if (evn >= fCm[chipn].GetSize()) return 0.0f;
327   else return fCm[chipn][evn];
328 }
329
330
331
332 //______________________________________________________________________________
333 AliITSNoiseSSD* AliITSModuleDaSSD::GetCalibrationSSDModule() const
334 {
335 // Creates the AliITSNoiseSSD objects with callibration data
336   AliITSNoiseSSD  *mc;
337   Float_t          noise;
338   if (!fStrips) return NULL;
339   mc = new AliITSNoiseSSD();
340   mc->SetMod(fModuleId);
341   mc->SetNNoiseP(fgkPNStripsPerModule);
342   mc->SetNNoiseN(fgkPNStripsPerModule);
343   for (Int_t i = 0; i < fNumberOfStrips; i++) {
344     if (!fStrips[i]) noise = AliITSChannelDaSSD::GetUndefinedValue();
345     else  noise = fStrips[i]->GetNoiseCM();
346     if (i < fgkPNStripsPerModule)
347           mc->AddNoiseP(i, noise);
348     else  mc->AddNoiseN((AliITSChannelDaSSD::GetMaxStripIdConst() - i), noise);                     
349   }
350   return mc;
351 }