]>
Commit | Line | Data |
---|---|---|
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" |
27 | ||
28 | ClassImp(AliITSModuleDaSSD) | |
29 | ||
30 | using namespace std; | |
31 | ||
32 | AliITSModuleDaSSD::AliITSModuleDaSSD() : | |
33 | fEquipId(0), | |
34 | fEquipType(0), | |
35 | fDdlId(0), | |
36 | fAd(0), | |
37 | fAdc(0), | |
38 | fModuleId(0), | |
39 | fNumberOfStrips(0), | |
40 | fStrips(NULL), | |
41 | fEventsNumber(0) | |
42 | { | |
223dda26 | 43 | // Default constructor |
f67db810 | 44 | } |
45 | ||
46 | ||
47 | AliITSModuleDaSSD::AliITSModuleDaSSD(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t moduleID) : | |
48 | fEquipId(0), | |
49 | fEquipType(0), | |
50 | fDdlId(ddlID), | |
51 | fAd(ad), | |
52 | fAdc(adc), | |
53 | fModuleId(moduleID), | |
54 | fNumberOfStrips(0), | |
55 | fStrips(NULL), | |
56 | fEventsNumber(0) | |
57 | { | |
223dda26 | 58 | // Constructor, set module id data |
f67db810 | 59 | } |
60 | ||
61 | ||
62 | ||
63 | AliITSModuleDaSSD::AliITSModuleDaSSD(const Int_t numberofstrips) : | |
64 | fEquipId(0), | |
65 | fEquipType(0), | |
66 | fDdlId(0), | |
67 | fAd(0), | |
68 | fAdc(0), | |
69 | fModuleId(0), | |
70 | fNumberOfStrips(0), | |
71 | fStrips(NULL), | |
72 | fEventsNumber(0) | |
73 | { | |
223dda26 | 74 | // Constructor, allocates memory for AliITSChannelDaSSD* |
f67db810 | 75 | if (numberofstrips != fgkStripsPerModule) |
223dda26 | 76 | Warning("AliITSModuleDaSSD", "ALICE ITS SSD Module contains %i strips", fgkStripsPerModule); |
77 | fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips]; | |
78 | if (fStrips) { | |
f67db810 | 79 | fNumberOfStrips = numberofstrips; |
80 | for (Int_t i = 0; i < numberofstrips; i++) fStrips[i]= NULL; | |
223dda26 | 81 | } else { |
82 | Error("AliITSModuleDaSSD", "Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips); | |
f67db810 | 83 | fNumberOfStrips = 0; |
84 | fStrips = NULL; | |
223dda26 | 85 | } |
f67db810 | 86 | } |
87 | ||
88 | ||
89 | AliITSModuleDaSSD::AliITSModuleDaSSD(const Int_t numberofstrips, const Long_t eventsnumber) : | |
90 | fEquipId(0), | |
91 | fEquipType(0), | |
92 | fDdlId(0), | |
93 | fAd(0), | |
94 | fAdc(0), | |
95 | fModuleId(0), | |
96 | fNumberOfStrips(0), | |
97 | fStrips(NULL), | |
98 | fEventsNumber(0) | |
99 | { | |
223dda26 | 100 | // Constructor, allocates memory for AliITSChannelDaSSD* and events data |
f67db810 | 101 | if (numberofstrips != fgkStripsPerModule) |
223dda26 | 102 | Warning("AliITSModuleDaSSD", "ALICE ITS SSD Module contains %i strips", fgkStripsPerModule); |
103 | fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips]; | |
104 | if (fStrips) { | |
f67db810 | 105 | fNumberOfStrips = numberofstrips; |
223dda26 | 106 | memset(fStrips, 0, numberofstrips * sizeof(AliITSChannelDaSSD*)); |
107 | for (Int_t i = 0; i < fNumberOfStrips; i++) { | |
108 | fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber); | |
109 | if (!fStrips[i]) Error("AliITSModuleDaSSD", "Error allocating memory for AliITSChannelDaSSD %i-th object", i); | |
110 | } | |
111 | } else { | |
112 | Error("AliITSModuleDaSSD", "Error allocating memory for %i AliITSChannelDaSSD* objects!", numberofstrips); | |
f67db810 | 113 | fNumberOfStrips = 0; |
114 | fStrips = NULL; | |
f67db810 | 115 | } |
116 | } | |
117 | ||
118 | ||
119 | ||
120 | AliITSModuleDaSSD::AliITSModuleDaSSD(const AliITSModuleDaSSD& module) : | |
121 | TObject(module), | |
122 | fEquipId(module.fEquipId), | |
123 | fEquipType(module.fEquipType), | |
124 | fDdlId(module.fDdlId), | |
125 | fAd(module.fAd), | |
126 | fAdc(module.fAdc), | |
127 | fModuleId(module.fModuleId), | |
128 | fNumberOfStrips(module.fNumberOfStrips), | |
129 | fStrips(module.fStrips), | |
130 | fEventsNumber(module.fEventsNumber) | |
131 | { | |
223dda26 | 132 | // copy constructor |
f67db810 | 133 | |
134 | Fatal("AliITSModuleDaSSD", "copy constructor not implemented"); | |
135 | } | |
136 | ||
137 | ||
138 | ||
139 | AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& module) | |
140 | { | |
141 | // assignment operator | |
142 | ||
143 | Fatal("AliITSModuleDaSSD: operator =", "assignment operator not implemented"); | |
144 | return *this; | |
145 | } | |
146 | ||
147 | ||
148 | ||
149 | AliITSModuleDaSSD::~AliITSModuleDaSSD() | |
150 | { | |
223dda26 | 151 | // Destructor |
f67db810 | 152 | if (fStrips) |
153 | { | |
154 | for (Long_t i = 0; i < fNumberOfStrips; i++) | |
155 | { | |
156 | if (fStrips[i]) delete fStrips[i]; | |
f67db810 | 157 | } |
158 | delete [] fStrips; | |
159 | } | |
160 | } | |
161 | ||
162 | ||
163 | ||
164 | Bool_t AliITSModuleDaSSD::SetModuleIdData (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t moduleID) | |
165 | { | |
223dda26 | 166 | // SetModuleIdData |
f67db810 | 167 | if (ad > fgkMaxAdNumber) { |
168 | Warning("AliITSModuleDaSSD", "Wrong AD number: %i", ad); | |
169 | return kFALSE; | |
170 | } | |
171 | if (adc > fgkMaxAdcNumber || ForbiddenAdcNumber(adc)) { | |
172 | Warning("AliITSModuleDaSSD", "Wrong ADC number: %i", adc); | |
173 | return kFALSE; | |
174 | } | |
175 | fDdlId = ddlID; | |
176 | fAd = ad; | |
177 | fAdc = adc; | |
178 | fModuleId = moduleID; | |
179 | return kTRUE; | |
180 | } | |
181 | ||
182 | ||
183 | ||
184 | void AliITSModuleDaSSD::SetModuleFEEId (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) | |
185 | { | |
223dda26 | 186 | // Set id data of FEE connected to the Module |
f67db810 | 187 | fDdlId = ddlID; |
188 | fAd = ad; | |
189 | fAdc = adc; | |
190 | } | |
191 | ||
192 | ||
193 | void AliITSModuleDaSSD::SetModuleRorcId (const Int_t equipid, const Int_t equiptype) | |
194 | { | |
223dda26 | 195 | // Set data to access FEROM registres via DDL |
f67db810 | 196 | fEquipId = equipid; |
197 | fEquipType = equiptype; | |
198 | } | |
199 | ||
200 | ||
201 | Bool_t AliITSModuleDaSSD::SetEventsNumber(const Long_t eventsnumber) | |
202 | { | |
223dda26 | 203 | // Allocate the memory for the enents data |
f67db810 | 204 | Int_t i; |
205 | if (!fStrips) return kFALSE; | |
206 | try { | |
207 | for (i = 0; i < fNumberOfStrips; i++) { | |
208 | if (fStrips[i]) fStrips[i]->SetEvenetsNumber(eventsnumber); | |
209 | else fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber); | |
210 | } | |
211 | } | |
212 | catch (bad_alloc&) { | |
223dda26 | 213 | Error("AliITSModuleDaSSD", "Error allocating memory for %i-th AliITSChannelDaSSD objects!", i); |
f67db810 | 214 | for (Int_t j = 0; j < i; j++) delete fStrips[j]; |
215 | delete [] fStrips; | |
216 | fNumberOfStrips = 0; | |
217 | fStrips = NULL; | |
218 | return kFALSE; | |
219 | } | |
220 | return kTRUE; | |
221 | } | |
222 | ||
223 | ||
224 | ||
225 | AliITSNoiseSSD* AliITSModuleDaSSD::GetCalibrationSSDModule() const | |
226 | { | |
223dda26 | 227 | // Creates the AliITSNoiseSSD objects with callibration data |
f67db810 | 228 | AliITSNoiseSSD *mc; |
229 | if (!fStrips) return NULL; | |
230 | mc = new AliITSNoiseSSD(); | |
231 | mc->SetMod(fModuleId); | |
232 | mc->SetNNoiseP(fgkPNStripsPerModule); | |
233 | mc->SetNNoiseN(fgkPNStripsPerModule); | |
234 | for (Int_t i = 0; i < fNumberOfStrips; i++) { | |
235 | if (!fStrips[i]) { | |
236 | delete mc; | |
237 | return NULL; | |
238 | } | |
239 | if (i < fgkPNStripsPerModule) | |
240 | mc->AddNoiseP(i, fStrips[i]->GetNoise()); | |
241 | else mc->AddNoiseN((i - fgkPNStripsPerModule), fStrips[i]->GetNoise()); | |
242 | } | |
243 | return mc; | |
244 | } |