]>
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 | ||
8bcdc40d | 16 | /* $Id$ */ |
223dda26 | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides ITS SSD data handling | |
21 | /// used by DA. | |
2e2c6def | 22 | // Author: Oleksandr Borysov |
371588bb | 23 | // Date: 20/04/2008 |
223dda26 | 24 | /////////////////////////////////////////////////////////////////////////////// |
25 | ||
26 | #include <Riostream.h> | |
f67db810 | 27 | #include "AliITSHandleDaSSD.h" |
223dda26 | 28 | #include <math.h> |
c4d90345 | 29 | #include <limits.h> |
223dda26 | 30 | #include "event.h" |
31 | #include "TFile.h" | |
c4d90345 | 32 | #include "TString.h" |
223dda26 | 33 | #include "TObjArray.h" |
c4d90345 | 34 | #include "AliLog.h" |
223dda26 | 35 | #include "AliITSNoiseSSD.h" |
2e2c6def | 36 | #include "AliITSPedestalSSD.h" |
37 | #include "AliITSBadChannelsSSD.h" | |
c4d90345 | 38 | #include "AliITSRawStreamSSD.h" |
223dda26 | 39 | #include "AliRawReaderDate.h" |
371588bb | 40 | #include "AliITSRawStreamSSD.h" |
223dda26 | 41 | #include "AliITSChannelDaSSD.h" |
f67db810 | 42 | |
43 | ||
44 | ClassImp(AliITSHandleDaSSD) | |
45 | ||
46 | using namespace std; | |
47 | ||
48 | ||
c4d90345 | 49 | const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModules = 1698; // Number of SSD modules in ITS |
2e2c6def | 50 | const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerDdl = 108; // Number of SSD modules in DDL |
51 | const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerSlot = 12; // Number of SSD modules in Slot | |
c4d90345 | 52 | const Float_t AliITSHandleDaSSD::fgkPedestalThresholdFactor = 3.0; // Defalt value for fPedestalThresholdFactor |
53 | const Float_t AliITSHandleDaSSD::fgkCmThresholdFactor = 3.0; // Defalt value for fCmThresholdFactor | |
54 | ||
55 | //______________________________________________________________________________ | |
f67db810 | 56 | AliITSHandleDaSSD::AliITSHandleDaSSD() : |
c4d90345 | 57 | fRawDataFileName(NULL), |
f67db810 | 58 | fNumberOfModules(0), |
59 | fModules(NULL), | |
c4d90345 | 60 | fModIndProcessed(0), |
61 | fModIndRead(0), | |
2e2c6def | 62 | fModIndex(NULL), |
c4d90345 | 63 | fNumberOfEvents(0), |
f67db810 | 64 | fLdcId(0), |
c4d90345 | 65 | fRunId(0), |
66 | fPedestalThresholdFactor(fgkPedestalThresholdFactor), | |
67 | fCmThresholdFactor(fgkCmThresholdFactor) | |
f67db810 | 68 | { |
223dda26 | 69 | // Default constructor |
f67db810 | 70 | } |
71 | ||
72 | ||
c4d90345 | 73 | //______________________________________________________________________________ |
74 | AliITSHandleDaSSD::AliITSHandleDaSSD(Char_t *rdfname) : | |
75 | fRawDataFileName(NULL), | |
f67db810 | 76 | fNumberOfModules(0), |
77 | fModules(NULL), | |
c4d90345 | 78 | fModIndProcessed(0), |
79 | fModIndRead(0), | |
2e2c6def | 80 | fModIndex(NULL), |
c4d90345 | 81 | fNumberOfEvents(0), |
f67db810 | 82 | fLdcId(0), |
c4d90345 | 83 | fRunId(0), |
84 | fPedestalThresholdFactor(fgkPedestalThresholdFactor) , | |
85 | fCmThresholdFactor(fgkCmThresholdFactor) | |
f67db810 | 86 | { |
c4d90345 | 87 | if (!Init(rdfname)) AliError("AliITSHandleDaSSD::AliITSHandleDaSSD() initialization error!"); |
f67db810 | 88 | } |
89 | ||
90 | ||
c4d90345 | 91 | //______________________________________________________________________________ |
f67db810 | 92 | AliITSHandleDaSSD::AliITSHandleDaSSD(const AliITSHandleDaSSD& ssdadldc) : |
93 | TObject(ssdadldc), | |
c4d90345 | 94 | fRawDataFileName(ssdadldc.fRawDataFileName), |
f67db810 | 95 | fNumberOfModules(ssdadldc.fNumberOfModules), |
a69c8ba0 | 96 | fModules(NULL), |
c4d90345 | 97 | fModIndProcessed(ssdadldc.fModIndProcessed), |
98 | fModIndRead(ssdadldc.fModIndRead), | |
2e2c6def | 99 | fModIndex(NULL), |
c4d90345 | 100 | fNumberOfEvents(ssdadldc.fNumberOfEvents), |
f67db810 | 101 | fLdcId(ssdadldc.fLdcId), |
c4d90345 | 102 | fRunId(ssdadldc.fRunId), |
103 | fPedestalThresholdFactor(ssdadldc.fPedestalThresholdFactor), | |
104 | fCmThresholdFactor(ssdadldc.fCmThresholdFactor) | |
f67db810 | 105 | { |
106 | // copy constructor | |
a69c8ba0 | 107 | if ((ssdadldc.fNumberOfModules > 0) && (ssdadldc.fModules)) { |
108 | fModules = new (nothrow) AliITSModuleDaSSD* [ssdadldc.fNumberOfModules]; | |
109 | if (fModules) { | |
110 | for (Int_t modind = 0; modind < ssdadldc.fNumberOfModules; modind++) { | |
111 | if (ssdadldc.fModules[modind]) { | |
112 | fModules[modind] = new AliITSModuleDaSSD(*(ssdadldc.fModules[modind])); | |
113 | if (!fModules[modind]) { | |
114 | AliError("AliITSHandleDaSSD: Error copy constructor"); | |
115 | for (Int_t i = (modind - 1); i >= 0; i--) delete fModules[modind]; | |
116 | delete [] fModules; | |
117 | fModules = NULL; | |
118 | break; | |
119 | } | |
120 | } else fModules[modind] = NULL; | |
121 | } | |
122 | } else { | |
123 | AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", ssdadldc.fNumberOfModules)); | |
124 | fNumberOfModules = 0; | |
125 | fModules = NULL; | |
126 | } | |
127 | } | |
f67db810 | 128 | } |
129 | ||
130 | ||
c4d90345 | 131 | //______________________________________________________________________________ |
f67db810 | 132 | AliITSHandleDaSSD& AliITSHandleDaSSD::operator = (const AliITSHandleDaSSD& ssdadldc) |
133 | { | |
134 | // assignment operator | |
a69c8ba0 | 135 | if (this == &ssdadldc) return *this; |
136 | if (fModules) { | |
137 | for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i]; | |
138 | delete [] fModules; | |
139 | fModules = NULL; | |
140 | } | |
2e2c6def | 141 | if (fModIndex) { delete [] fModIndex; fModIndex = NULL; } |
a69c8ba0 | 142 | if ((ssdadldc.fNumberOfModules > 0) && (ssdadldc.fModules)) { |
143 | fModules = new (nothrow) AliITSModuleDaSSD* [ssdadldc.fNumberOfModules]; | |
144 | if (fModules) { | |
145 | for (Int_t modind = 0; modind < ssdadldc.fNumberOfModules; modind++) { | |
146 | if (ssdadldc.fModules[modind]) { | |
147 | fModules[modind] = new AliITSModuleDaSSD(*(ssdadldc.fModules[modind])); | |
148 | if (!fModules[modind]) { | |
149 | AliError("AliITSHandleDaSSD: Error assignment operator"); | |
150 | for (Int_t i = (modind - 1); i >= 0; i--) delete fModules[modind]; | |
151 | delete [] fModules; | |
152 | fModules = NULL; | |
153 | break; | |
154 | } | |
155 | } else fModules[modind] = NULL; | |
156 | } | |
157 | } else { | |
158 | AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", ssdadldc.fNumberOfModules)); | |
159 | fNumberOfModules = 0; | |
160 | fModules = NULL; | |
161 | } | |
162 | } | |
f67db810 | 163 | return *this; |
164 | } | |
165 | ||
166 | ||
c4d90345 | 167 | //______________________________________________________________________________ |
f67db810 | 168 | AliITSHandleDaSSD::~AliITSHandleDaSSD() |
223dda26 | 169 | { |
170 | // Default destructor | |
f67db810 | 171 | if (fModules) |
172 | { | |
173 | for (Int_t i = 0; i < fNumberOfModules; i++) | |
174 | { | |
175 | if (fModules[i]) delete fModules[i]; | |
176 | } | |
177 | delete [] fModules; | |
178 | } | |
2e2c6def | 179 | if (fModIndex) delete [] fModIndex; |
f67db810 | 180 | } |
181 | ||
182 | ||
183 | ||
c4d90345 | 184 | //______________________________________________________________________________ |
185 | void AliITSHandleDaSSD::Reset() | |
186 | { | |
187 | // Delete array of AliITSModuleDaSSD* objects. | |
188 | if (fModules) { | |
189 | for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i]; | |
190 | delete [] fModules; | |
191 | fModules = NULL; | |
2e2c6def | 192 | } |
193 | if (fModIndex) { delete [] fModIndex; fModIndex = NULL; } | |
c4d90345 | 194 | fRawDataFileName = NULL; |
195 | fModIndProcessed = fModIndRead = 0; | |
196 | fNumberOfEvents = 0; | |
197 | fLdcId = fRunId = 0; | |
198 | fPedestalThresholdFactor = fgkPedestalThresholdFactor; | |
199 | fCmThresholdFactor = fgkCmThresholdFactor; | |
200 | } | |
201 | ||
202 | ||
203 | ||
204 | //______________________________________________________________________________ | |
205 | Bool_t AliITSHandleDaSSD::Init(Char_t *rdfname, const Char_t *configfname) | |
206 | { | |
207 | // Read raw data file and set initial and configuration parameters | |
208 | Long_t physeventind = 0, strn = 0, nofstripsev, nofstrips = 0; | |
209 | Int_t nofeqipmentev, nofeqipment = 0, eqn = 0; | |
210 | AliRawReaderDate *rawreaderdate = NULL; | |
211 | UChar_t *data = NULL; | |
212 | Long_t datasize = 0, eqbelsize = 1; | |
213 | ||
214 | if (configfname) ReadConfigurationFile(configfname); | |
215 | rawreaderdate = new AliRawReaderDate(rdfname, 0); | |
216 | if (!(rawreaderdate->GetAttributes() || rawreaderdate->GetEventId())) { | |
217 | AliError(Form("AliITSHandleDaSSD: Error reading raw data file %s by RawReaderDate", rdfname)); | |
218 | MakeZombie(); | |
219 | return kFALSE; | |
371588bb | 220 | } |
c4d90345 | 221 | if (rawreaderdate->NextEvent()) { |
c4d90345 | 222 | fRunId = rawreaderdate->GetRunNumber(); |
223 | rawreaderdate->RewindEvents(); | |
224 | } else { MakeZombie(); return kFALSE; } | |
225 | if (fModules) Reset(); | |
226 | rawreaderdate->SelectEvents(-1); | |
371588bb | 227 | rawreaderdate->Select("ITSSSD"); |
c4d90345 | 228 | nofstrips = 0; |
229 | while (rawreaderdate->NextEvent()) { | |
230 | if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue; | |
231 | nofstripsev = 0; | |
232 | nofeqipmentev = 0; | |
233 | while (rawreaderdate->ReadNextData(data)) { | |
2e2c6def | 234 | fLdcId = rawreaderdate->GetLDCId(); |
c4d90345 | 235 | nofeqipmentev += 1; |
236 | datasize = rawreaderdate->GetDataSize(); | |
237 | eqbelsize = rawreaderdate->GetEquipmentElementSize(); | |
371588bb | 238 | if ( datasize % eqbelsize ) { |
c4d90345 | 239 | AliError(Form("AliITSHandleDaSSD: Error Init(%s): event data size %i is not an integer of equipment data size %i", |
240 | rdfname, datasize, eqbelsize)); | |
241 | MakeZombie(); | |
242 | return kFALSE; | |
243 | } | |
371588bb | 244 | nofstripsev += (Int_t) (datasize / eqbelsize); |
c4d90345 | 245 | } |
246 | if (physeventind++) { | |
371588bb | 247 | if (nofstrips != nofstripsev) AliWarning(Form("AliITSHandleDaSSD: number of strips varies from event to event, ev = %i, %i", |
248 | physeventind, nofstripsev)); | |
249 | if (nofeqipment != nofeqipmentev) AliWarning("AliITSHandleDaSSD: number of DDLs varies from event to event"); | |
c4d90345 | 250 | } |
251 | nofstrips = nofstripsev; | |
252 | nofeqipment = nofeqipmentev; | |
371588bb | 253 | if (strn < nofstrips) strn = nofstrips; |
c4d90345 | 254 | if (eqn < nofeqipment) eqn = nofeqipment; |
255 | } | |
256 | delete rawreaderdate; | |
257 | if ((physeventind > 0) && (strn > 0)) | |
258 | { | |
259 | fNumberOfEvents = physeventind; | |
260 | fRawDataFileName = rdfname; | |
2e2c6def | 261 | fModIndex = new (nothrow) Int_t [fgkNumberOfSSDModulesPerDdl * eqn]; |
262 | if (fModIndex) | |
263 | for (Int_t i = 0; i < fgkNumberOfSSDModulesPerDdl * eqn; i++) fModIndex[i] = -1; | |
264 | else AliWarning(Form("AliITSHandleDaSSD: Error Init(%s): Index array for %i modules was not created", | |
265 | rdfname, fgkNumberOfSSDModulesPerDdl * eqn)); | |
371588bb | 266 | if (SetNumberOfModules(fgkNumberOfSSDModulesPerDdl * eqn)) { |
a69c8ba0 | 267 | TString str = TString::Format("Max number of equipment: %i, max number of channels: %i\n", eqn, strn); |
c4d90345 | 268 | DumpInitData(str.Data()); |
269 | return kTRUE; | |
270 | } | |
271 | } | |
272 | MakeZombie(); | |
273 | return kFALSE; | |
274 | } | |
275 | ||
276 | ||
277 | //______________________________________________________________________________ | |
8bcdc40d | 278 | Bool_t AliITSHandleDaSSD::ReadConfigurationFile(const Char_t * /* configfname */) |
c4d90345 | 279 | const { |
280 | // Dowload configuration parameters from configuration file or database | |
281 | return kFALSE; | |
282 | } | |
283 | ||
284 | ||
285 | ||
286 | //______________________________________________________________________________ | |
f67db810 | 287 | AliITSModuleDaSSD* AliITSHandleDaSSD::GetModule (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const |
288 | { | |
223dda26 | 289 | // Retrieve AliITSModuleDaSSD object from the array |
f67db810 | 290 | if (!fModules) return NULL; |
291 | for (Int_t i = 0; i < fNumberOfModules; i++) { | |
292 | if (fModules[i]) { | |
293 | if ( (fModules[i]->GetDdlId() == ddlID) | |
294 | && (fModules[i]->GetAD() == ad) | |
295 | && (fModules[i]->GetADC() == adc)) | |
296 | return fModules[i]; | |
297 | } | |
298 | } | |
299 | return NULL; | |
300 | } | |
301 | ||
302 | ||
c4d90345 | 303 | Int_t AliITSHandleDaSSD::GetModuleIndex (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const |
304 | { | |
305 | // Retrieve the position of AliITSModuleDaSSD object in the array | |
306 | if (!fModules) return -1; | |
307 | for (Int_t i = 0; i < fNumberOfModules; i++) { | |
308 | if (fModules[i]) { | |
309 | if ( (fModules[i]->GetDdlId() == ddlID) | |
310 | && (fModules[i]->GetAD() == ad) | |
311 | && (fModules[i]->GetADC() == adc)) | |
312 | return i; | |
313 | } | |
314 | } | |
315 | return -1; | |
316 | } | |
317 | ||
318 | ||
f67db810 | 319 | |
c4d90345 | 320 | //______________________________________________________________________________ |
f67db810 | 321 | AliITSChannelDaSSD* AliITSHandleDaSSD::GetStrip (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t stripID) const |
322 | { | |
223dda26 | 323 | // Retrieve AliITSChannalDaSSD object from the array |
f67db810 | 324 | for (Int_t modind = 0; modind < fNumberOfModules; modind++) { |
325 | if ( (fModules[modind]->GetDdlId() == ddlID) | |
326 | && (fModules[modind]->GetAD() == ad) | |
327 | && (fModules[modind]->GetADC() == adc) ) | |
328 | { | |
329 | return fModules[modind]->GetStrip(stripID); | |
330 | } | |
331 | } | |
c4d90345 | 332 | AliError(Form("AliITSHandleDaSSD: Error GetStrip (%i, %i, %i, %i), strip not found, returns NULL!", |
333 | ddlID, ad, adc, stripID)); | |
f67db810 | 334 | return NULL; |
335 | } | |
336 | ||
337 | ||
338 | ||
c4d90345 | 339 | //______________________________________________________________________________ |
f67db810 | 340 | Bool_t AliITSHandleDaSSD::SetModule(AliITSModuleDaSSD *const module, const Int_t index) |
341 | { | |
223dda26 | 342 | // Assign array element with AliITSModuleDaSSD object |
f67db810 | 343 | if ((index < fNumberOfModules) && (index >= 0)) |
344 | { | |
345 | if (fModules[index]) delete fModules[index]; | |
346 | fModules[index] = module; | |
347 | return kTRUE; | |
348 | } | |
349 | else return kFALSE; | |
350 | } | |
351 | ||
352 | ||
c4d90345 | 353 | |
354 | //______________________________________________________________________________ | |
f67db810 | 355 | Bool_t AliITSHandleDaSSD::SetNumberOfModules (const Int_t numberofmodules) |
356 | { | |
223dda26 | 357 | // Allocates memory for AliITSModuleDaSSD objects |
358 | if (numberofmodules > fgkNumberOfSSDModules) | |
c4d90345 | 359 | AliWarning(Form("AliITSHandleDaSSD: the number of modules %i you use exceeds the maximum %i for ALICE ITS SSD", |
360 | numberofmodules, fgkNumberOfSSDModules)); | |
361 | if (fModules) { | |
362 | for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i]; | |
363 | delete [] fModules; | |
364 | fModules = NULL; | |
365 | } | |
223dda26 | 366 | fModules = new (nothrow) AliITSModuleDaSSD* [numberofmodules]; |
367 | if (fModules) { | |
368 | fNumberOfModules = numberofmodules; | |
369 | memset(fModules, 0, sizeof(AliITSModuleDaSSD*) * numberofmodules); | |
370 | return kTRUE; | |
371 | } else { | |
c4d90345 | 372 | AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", numberofmodules)); |
f67db810 | 373 | fNumberOfModules = 0; |
374 | fModules = NULL; | |
223dda26 | 375 | } |
f67db810 | 376 | return kFALSE; |
377 | } | |
378 | ||
379 | ||
c4d90345 | 380 | |
381 | //______________________________________________________________________________ | |
371588bb | 382 | Int_t AliITSHandleDaSSD::ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber) |
f67db810 | 383 | { |
223dda26 | 384 | // Reads raw data from file |
c4d90345 | 385 | if (!Init(fileName)){ |
386 | AliError("AliITSHandleDaSSD: Error ReadCalibrationDataFile"); | |
f67db810 | 387 | return kFALSE; |
388 | } | |
371588bb | 389 | fNumberOfEvents = eventsnumber; |
390 | return ReadModuleRawData (fNumberOfModules); | |
f67db810 | 391 | } |
392 | ||
393 | ||
c4d90345 | 394 | |
395 | //______________________________________________________________________________ | |
396 | Int_t AliITSHandleDaSSD::ReadModuleRawData (const Int_t modulesnumber) | |
397 | { | |
398 | // Reads raw data from file | |
371588bb | 399 | AliRawReader *rawreaderdate = NULL; |
400 | AliITSRawStreamSSD *stream = NULL; | |
c4d90345 | 401 | AliITSModuleDaSSD *module; |
402 | AliITSChannelDaSSD *strip; | |
371588bb | 403 | Long_t eventind = 0; |
404 | Int_t nofeqipmentev, equipid, prequipid; | |
c4d90345 | 405 | UShort_t modind; |
c4d90345 | 406 | if (!(rawreaderdate = new AliRawReaderDate(fRawDataFileName, 0))) return 0; |
407 | if (!fModules) { | |
408 | AliError("AliITSHandleDaSSD: Error ReadModuleRawData: no structure was allocated for data"); | |
409 | return 0; | |
410 | } | |
371588bb | 411 | stream = new AliITSRawStreamSSD(rawreaderdate); |
412 | stream->Setv11HybridDDLMapping(); | |
c4d90345 | 413 | rawreaderdate->SelectEvents(-1); |
414 | modind = 0; | |
415 | while (rawreaderdate->NextEvent()) { | |
416 | if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue; | |
2e2c6def | 417 | nofeqipmentev = 0; |
371588bb | 418 | prequipid = -1; |
419 | while (stream->Next()) { | |
420 | equipid = rawreaderdate->GetEquipmentId(); | |
421 | if ((equipid != prequipid) && (prequipid >= 0)) nofeqipmentev += 1; | |
422 | prequipid = equipid; | |
423 | Int_t equiptype = rawreaderdate->GetEquipmentType(); | |
424 | UChar_t ddlID = (UChar_t)rawreaderdate->GetDDLID(); | |
425 | UChar_t ad = stream->GetAD(); | |
426 | UChar_t adc = stream->GetADC(); | |
427 | UShort_t stripID = stream->GetSideFlag() ? AliITSChannelDaSSD::GetMaxStripIdConst() - stream->GetStrip() : stream->GetStrip(); | |
428 | Short_t signal = stream->GetSignal(); | |
429 | ||
430 | Int_t indpos = (nofeqipmentev * fgkNumberOfSSDModulesPerDdl) | |
431 | + ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2)); | |
432 | Int_t modpos = fModIndex[indpos]; | |
433 | if (((modpos > 0) && (modpos < fModIndRead)) || ((modpos < 0) && (modind == modulesnumber))) continue; | |
434 | if ((modpos < 0) && (modind < modulesnumber)) { | |
435 | module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst()); | |
436 | Int_t mddli = ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2)); | |
437 | if ((ddlID < AliITSRawStreamSSD::kDDLsNumber) && (mddli < AliITSRawStreamSSD::kModulesPerDDL)) { | |
438 | mddli = stream->GetModuleNumber(ddlID, mddli); | |
439 | } | |
440 | else { | |
441 | AliWarning(Form("Module index = %d or ddlID = %d is out of range -1 is rturned", ddlID, mddli)); | |
442 | mddli = 0; | |
443 | } | |
444 | if (!module->SetModuleIdData (ddlID, ad, adc, mddli)) return 0; | |
445 | // if (!module->SetModuleIdData (ddlID, ad, adc, RetrieveModuleId(ddlID, ad, adc))) return 0; | |
446 | module->SetModuleRorcId (equipid, equiptype); | |
447 | module->SetCMFeromEventsNumber(fNumberOfEvents); | |
448 | modpos = fModIndRead + modind; | |
449 | modind += 1; | |
450 | fModules[modpos] = module; | |
451 | fModIndex[indpos] = modpos; | |
452 | } | |
453 | if (stripID < AliITSModuleDaSSD::GetStripsPerModuleConst()) { | |
c4d90345 | 454 | if (!(strip = fModules[modpos]->GetStrip(stripID))) { |
455 | strip = new AliITSChannelDaSSD(stripID, fNumberOfEvents); | |
456 | fModules[modpos]->SetStrip(strip, stripID); | |
457 | } | |
458 | strip->SetSignal(eventind, signal); | |
371588bb | 459 | } else fModules[modpos]->SetCMFerom(signal, (stripID - AliITSModuleDaSSD::GetStripsPerModuleConst()), eventind); |
c4d90345 | 460 | } |
461 | if (++eventind > fNumberOfEvents) break; | |
462 | } | |
371588bb | 463 | delete stream; |
c4d90345 | 464 | delete rawreaderdate; |
465 | if (modind) cout << "The memory was allocated for " << modind << " modules." << endl; | |
466 | fModIndRead += modind; | |
467 | if (modind < modulesnumber) RelocateModules(); | |
468 | return modind; | |
469 | } | |
470 | ||
471 | ||
472 | ||
473 | //______________________________________________________________________________ | |
f67db810 | 474 | Bool_t AliITSHandleDaSSD::RelocateModules() |
223dda26 | 475 | { |
476 | // Relocate memory for AliITSModuleDaSSD object array | |
f67db810 | 477 | Int_t nm = 0; |
223dda26 | 478 | AliITSModuleDaSSD **marray = NULL; |
f67db810 | 479 | for (Int_t modind = 0; modind < fNumberOfModules; modind++) |
480 | if (fModules[modind]) nm += 1; | |
481 | if (nm == fNumberOfModules) return kTRUE; | |
223dda26 | 482 | marray = new (nothrow) AliITSModuleDaSSD* [nm]; |
483 | if (!marray) { | |
c4d90345 | 484 | AliError(Form("AliITSHandleDaSSD: Error relocating memory for %i AliITSModuleDaSSD* objects!", nm)); |
f67db810 | 485 | return kFALSE; |
486 | } | |
487 | nm = 0; | |
488 | for (Int_t modind = 0; modind < fNumberOfModules; modind++) | |
489 | if (fModules[modind]) marray[nm++] = fModules[modind]; | |
490 | delete [] fModules; | |
491 | fModules = marray; | |
c4d90345 | 492 | fNumberOfModules = fModIndRead = nm; |
f67db810 | 493 | return kTRUE; |
494 | } | |
495 | ||
496 | ||
c4d90345 | 497 | |
371588bb | 498 | //______________________________________________________________________________ |
499 | Bool_t AliITSHandleDaSSD::AddFeromCm(AliITSModuleDaSSD *const module) | |
500 | // Restore the original signal value adding CM calculated and subtracted in ferom | |
501 | { | |
502 | AliITSChannelDaSSD *strip; | |
503 | Short_t *signal, *cmferom; | |
504 | ||
505 | if (!module) return kFALSE; | |
506 | for (Int_t chipind = 0; chipind < AliITSModuleDaSSD::GetChipsPerModuleConst(); chipind++) { | |
507 | if (!(cmferom = module->GetCMFerom(chipind))) { | |
508 | AliWarning(Form("AliITSHandleDaSSD: There is no Ferom CM values for chip %i, module %i!", chipind, module->GetModuleId())); | |
509 | continue; | |
510 | } | |
511 | for (Int_t strind = (chipind * AliITSModuleDaSSD::GetStripsPerChip()); | |
512 | strind < ((chipind + 1) * AliITSModuleDaSSD::GetStripsPerChip()); strind++) { | |
513 | if (!(strip = module->GetStrip(strind))) continue; | |
514 | if (!(signal = strip->GetSignal())) continue; | |
515 | // if (strip->GetEventsNumber() != module->GetEventsNumber()) return kFALSE; | |
516 | Long_t ovev = 0; | |
517 | for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) { | |
518 | if (SignalOutOfRange(signal[ev]) || SignalOutOfRange(cmferom[ev])) ovev += 1; | |
519 | else { | |
520 | Short_t signal1 = signal[ev] + cmferom[ev]; | |
521 | strip->SetSignal(ev, signal1); | |
522 | } | |
523 | } | |
524 | } | |
525 | } | |
526 | return kTRUE; | |
527 | } | |
528 | ||
529 | ||
530 | ||
c4d90345 | 531 | //______________________________________________________________________________ |
532 | Bool_t AliITSHandleDaSSD::CalculatePedestal(AliITSModuleDaSSD *const module) | |
f67db810 | 533 | { |
223dda26 | 534 | // Calculates Pedestal |
f67db810 | 535 | AliITSChannelDaSSD *strip; |
c4d90345 | 536 | Float_t pedestal, noise; |
537 | Short_t *signal; | |
538 | Long_t ovev, ev, n; | |
539 | if (!module) return kFALSE; | |
540 | for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) { | |
541 | if (!(strip = module->GetStrip(strind))) continue; | |
542 | if (!(signal = strip->GetSignal())) { | |
543 | AliError(Form("AliITSHandleDaSSD: Error CalculatePedestal(): there are no events data for module[%i] strip[%i]->GetSignal()", | |
544 | module->GetModuleId(), strind)); | |
545 | continue; | |
f67db810 | 546 | } |
c4d90345 | 547 | //************* pedestal first pass **************** |
548 | pedestal = 0.0f; | |
549 | ovev = 0l; | |
550 | for (ev = 0; ev < strip->GetEventsNumber(); ev++) | |
551 | if (SignalOutOfRange(signal[ev])) ovev += 1; | |
552 | else pedestal = ((ev - ovev)) ? pedestal + (signal[ev] - pedestal) / static_cast<Float_t>(ev - ovev + 1) : signal[ev]; | |
553 | if (ev == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue(); | |
554 | strip->SetPedestal(pedestal); | |
555 | //************* noise ******************************* | |
556 | Double_t nsum = 0.0L; | |
557 | ovev = 0l; | |
558 | for (ev = 0; ev < strip->GetEventsNumber(); ev++) { | |
559 | if (SignalOutOfRange(signal[ev])) ovev += 1; | |
560 | else nsum += pow((signal[ev] - strip->GetPedestal()), 2); | |
561 | } | |
562 | if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Float_t)(n)); | |
563 | else noise = AliITSChannelDaSSD::GetUndefinedValue(); | |
564 | strip->SetNoise(noise); | |
565 | //************* pedestal second pass **************** | |
566 | pedestal = 0.0f; | |
567 | ovev = 0l; | |
568 | for (ev = 0; ev < strip->GetEventsNumber(); ev++) | |
569 | if ( SignalOutOfRange(signal[ev]) | |
570 | || TMath::Abs(signal[ev] - strip->GetPedestal()) > (fPedestalThresholdFactor * strip->GetNoise())) ovev += 1; | |
571 | else pedestal = ((ev - ovev)) ? pedestal + (signal[ev] - pedestal) / static_cast<Float_t>(ev - ovev + 1) : signal[ev]; | |
572 | if (ev == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue(); | |
573 | strip->SetPedestal(pedestal); | |
574 | strip->SetOverflowNumber(ovev); | |
f67db810 | 575 | } |
576 | return kTRUE; | |
577 | } | |
578 | ||
579 | ||
c4d90345 | 580 | //______________________________________________________________________________ |
a69c8ba0 | 581 | Bool_t AliITSHandleDaSSD::CalculateNoise(AliITSModuleDaSSD *const module) |
f67db810 | 582 | { |
223dda26 | 583 | // Calculates Noise |
f67db810 | 584 | AliITSChannelDaSSD *strip; |
585 | Short_t *signal; | |
586 | Float_t noise; | |
587 | Long_t ovev, n; | |
c4d90345 | 588 | if (!module) return kFALSE; |
589 | for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) { | |
590 | if (!(strip = module->GetStrip(strind))) continue; | |
591 | if (!(signal = strip->GetSignal())) { | |
592 | strip->SetNoise(AliITSChannelDaSSD::GetUndefinedValue()); | |
593 | AliError(Form("AliITSHandleDaSSD: Error CalculateNoise(): there are no events data for module[%i] strip[%i]->GetSignal()", | |
594 | module->GetModuleId(), strind)); | |
595 | continue; | |
f67db810 | 596 | } |
c4d90345 | 597 | Double_t nsum = 0.0L; |
598 | ovev = 0l; | |
599 | for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) { | |
600 | if (SignalOutOfRange(signal[ev])) ovev += 1; | |
601 | else nsum += pow((signal[ev] - strip->GetPedestal()), 2); | |
602 | } | |
603 | if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Float_t)(n)); | |
604 | else noise = AliITSChannelDaSSD::GetUndefinedValue(); | |
605 | strip->SetNoise(noise); | |
f67db810 | 606 | } |
607 | return kTRUE; | |
608 | } | |
609 | ||
610 | ||
611 | ||
c4d90345 | 612 | //______________________________________________________________________________ |
613 | Bool_t AliITSHandleDaSSD::CalculateNoiseCM(AliITSModuleDaSSD *const module) | |
f67db810 | 614 | { |
c4d90345 | 615 | // Calculates Noise with CM correction |
616 | AliITSChannelDaSSD *strip = NULL; | |
617 | Short_t *signal; | |
618 | Float_t noise; | |
619 | Long_t ovev, n; | |
620 | if (!CalculateCM(module)) { | |
621 | AliError("Error: AliITSHandleDaSSD::CalculateCM() returned kFALSE"); | |
622 | return kFALSE; | |
623 | } | |
624 | for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) { | |
625 | if (!(strip = module->GetStrip(strind))) continue; //return kFALSE; | |
626 | if (!(signal = strip->GetSignal())) { | |
627 | strip->SetNoiseCM(AliITSChannelDaSSD::GetUndefinedValue()); | |
628 | AliError(Form("SSDDAModule: Error CalculateNoiseWithoutCM(): there are no events data for module[%i] strip[%i]->GetSignal()", | |
629 | module->GetModuleId(), strind)); | |
2e2c6def | 630 | continue; //return kFALSE; |
f67db810 | 631 | } |
c4d90345 | 632 | Int_t chipind = strind / AliITSModuleDaSSD::GetStripsPerChip(); |
633 | Double_t nsum = 0.0L; | |
634 | ovev = 0l; | |
635 | for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) { | |
636 | if (SignalOutOfRange(signal[ev])) ovev += 1; | |
637 | else nsum += pow((signal[ev] - strip->GetPedestal() - module->GetCM(chipind, ev)), 2); | |
638 | } | |
639 | if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Float_t)(n)); | |
640 | else noise = AliITSChannelDaSSD::GetUndefinedValue(); | |
641 | strip->SetNoiseCM(noise); | |
642 | } | |
2e2c6def | 643 | return kTRUE; |
f67db810 | 644 | } |
645 | ||
646 | ||
647 | ||
c4d90345 | 648 | //______________________________________________________________________________ |
649 | Bool_t AliITSHandleDaSSD::CalculateCM(AliITSModuleDaSSD *const module) | |
f67db810 | 650 | { |
c4d90345 | 651 | // Calculates CM |
f67db810 | 652 | AliITSChannelDaSSD *strip = NULL; |
c4d90345 | 653 | Short_t *signal; |
654 | Long_t ovstr, n; | |
655 | Int_t stripind; | |
656 | module->SetNumberOfChips(AliITSModuleDaSSD::GetChipsPerModuleConst()); | |
657 | for (Int_t chipind = 0; chipind < module->GetNumberOfChips(); chipind++) { | |
658 | stripind = chipind * module->GetStripsPerChip(); | |
371588bb | 659 | module->GetCM()[chipind].Set(fNumberOfEvents); |
660 | module->GetCM()[chipind].Reset(0.0f); | |
c4d90345 | 661 | for (Long_t ev = 0; ev < fNumberOfEvents; ev++) { |
662 | // calculate firs approximation of CM. | |
663 | Double_t cm0 = 0.0L; | |
664 | ovstr = 0l; | |
665 | for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) { | |
666 | if (!(strip = module->GetStrip(strind))) continue; //return kFALSE; | |
667 | if (!(signal = strip->GetSignal())) { | |
668 | AliError(Form("AliITSHandleDaSSD: Error CalculateCM: there are no events data for module[%i] strip[%i]->GetSignal()", | |
669 | module->GetModuleId(), strind)); | |
670 | return kFALSE; | |
671 | } | |
672 | if ((signal[ev] >= AliITSChannelDaSSD::GetOverflowConst()) || | |
673 | (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1; | |
674 | else cm0 += (signal[ev] - strip->GetPedestal()); | |
f67db810 | 675 | } |
c4d90345 | 676 | if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cm0 /= (Float_t)(n); |
677 | else { module->SetCM(0.0f, chipind, ev); continue; } | |
678 | // calculate avarage (cm - (signal - pedestal)) over the chip | |
679 | Double_t cmsigma = 0.0L; | |
680 | ovstr = 0l; | |
681 | for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) { | |
682 | if (!(strip = module->GetStrip(strind))) continue; | |
683 | if (!(signal = strip->GetSignal())) { | |
684 | AliError(Form("AliITSHandleDaSSD: Error CalculateCM: there are no events data for module[%i] strip[%i]->GetSignal()\n", | |
685 | module->GetModuleId(), strind)); | |
686 | return kFALSE; | |
f67db810 | 687 | } |
c4d90345 | 688 | if ((signal[ev] >= AliITSChannelDaSSD::GetOverflowConst()) || |
689 | (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1; | |
690 | else cmsigma += pow((cm0 - (signal[ev] - strip->GetPedestal())), 2); | |
f67db810 | 691 | } |
c4d90345 | 692 | if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsigma = sqrt(cmsigma / (Float_t)(n)); |
693 | else { module->SetCM(0.0f, chipind, ev); continue; } | |
694 | // calculate cm with threshold | |
695 | Double_t cmsum = 0.0L; | |
696 | ovstr = 0l; | |
697 | for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) { | |
698 | if (!(strip = module->GetStrip(strind))) continue; | |
699 | signal = strip->GetSignal(); | |
700 | if ( (signal[ev] >= AliITSChannelDaSSD::GetOverflowConst()) | |
701 | || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue()) | |
702 | || (TMath::Abs(cm0 - (signal[ev] - strip->GetPedestal())) > (fCmThresholdFactor * cmsigma)) ) ovstr += 1; | |
703 | else cmsum += (signal[ev] - strip->GetPedestal()); | |
704 | } | |
705 | if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsum /= (Float_t)(n); | |
706 | else cmsum = 0.0L; | |
707 | if (!module->SetCM(cmsum, chipind, ev)); | |
708 | } | |
709 | } | |
710 | return kTRUE; | |
711 | } | |
712 | ||
713 | ||
714 | //______________________________________________________________________________ | |
715 | Bool_t AliITSHandleDaSSD::ProcessRawData(const Int_t nmread) | |
716 | { | |
717 | // Performs calculation of calibration parameters (pedestal, noise, ...) | |
718 | Int_t nm = 0; | |
719 | if (nmread <= 0) return kFALSE; | |
720 | if (!fModules) return kFALSE; | |
721 | while ((nm = ReadModuleRawData(nmread)) > 0) { | |
722 | cout << "Processing next " << nm << " modules;" << endl; | |
723 | for (Int_t modind = fModIndProcessed; modind < fModIndRead; modind++) { | |
724 | if (!fModules[modind]) { | |
725 | AliError(Form("AliITSHandleDaSSD: Error ProcessRawData(): No AliITSModuleDaSSD object with index %i is allocated in AliITSHandleDaSSD\n", | |
726 | modind)); | |
727 | return kFALSE; | |
f67db810 | 728 | } |
371588bb | 729 | AddFeromCm(fModules[modind]); |
c4d90345 | 730 | CalculatePedestal(fModules[modind]); |
731 | CalculateNoise(fModules[modind]); | |
732 | CalculateNoiseCM(fModules[modind]); | |
f67db810 | 733 | } |
c4d90345 | 734 | DeleteSignal(); |
371588bb | 735 | DeleteCM(); |
736 | DeleteCMFerom(); | |
c4d90345 | 737 | fModIndProcessed = fModIndRead; |
738 | cout << fModIndProcessed << " - done" << endl; | |
739 | } | |
740 | return kTRUE; | |
f67db810 | 741 | } |
742 | ||
743 | ||
c4d90345 | 744 | //______________________________________________________________________________ |
745 | Short_t AliITSHandleDaSSD::RetrieveModuleId(const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const | |
746 | { | |
747 | // Retrieve ModuleId from the DDL map which is defined in AliITSRawStreamSSD class | |
371588bb | 748 | |
c4d90345 | 749 | Int_t mddli = (ad - 1) * 12 + ((adc<6) ? adc : (adc-2)); |
750 | if ((ddlID < AliITSRawStreamSSD::kDDLsNumber) && (mddli < AliITSRawStreamSSD::kModulesPerDDL)) { | |
751 | mddli = AliITSRawStreamSSD::GetModuleNumber(ddlID, mddli); | |
752 | if (mddli > SHRT_MAX) return SHRT_MAX; | |
753 | else return (Short_t)mddli; | |
754 | } | |
755 | else { | |
756 | AliWarning(Form("Module index = %d or ddlID = %d is out of range -1 is rturned", ddlID, mddli)); | |
757 | return -1; | |
758 | } | |
759 | } | |
760 | ||
f67db810 | 761 | |
c4d90345 | 762 | |
763 | //______________________________________________________________________________ | |
f67db810 | 764 | TObjArray* AliITSHandleDaSSD::GetCalibrationSSDLDC() const |
223dda26 | 765 | { |
766 | // Fill in the array for OCDB | |
f67db810 | 767 | TObjArray *ldcc; |
c4d90345 | 768 | TObject *modcalibobj; |
f67db810 | 769 | if (!fModules) return NULL; |
770 | ldcc = new TObjArray(fNumberOfModules, 0); | |
771 | for (Int_t i = 0; i < fNumberOfModules; i++) { | |
772 | if (!fModules[i]) { | |
773 | delete ldcc; | |
774 | return NULL; | |
775 | } | |
2e2c6def | 776 | modcalibobj = dynamic_cast<TObject*>(fModules[i]->GetCalibrationNoise()); |
c4d90345 | 777 | ldcc->AddAt(modcalibobj, i); |
f67db810 | 778 | } |
779 | ldcc->Compress(); | |
780 | return ldcc; | |
781 | } | |
782 | ||
783 | ||
c4d90345 | 784 | //______________________________________________________________________________ |
785 | Bool_t AliITSHandleDaSSD::SaveCalibrationSSDLDC(Char_t*& dafname) const | |
f67db810 | 786 | { |
223dda26 | 787 | // Save Calibration data locally |
2e2c6def | 788 | TObjArray *ldcn, *ldcp, *ldcbc; |
789 | TObject *modobjn, *modobjp, *modobjbc; | |
c4d90345 | 790 | Char_t *tmpfname; |
791 | TString dadatafilename(""); | |
f67db810 | 792 | if (!fModules) return kFALSE; |
2e2c6def | 793 | ldcn = new TObjArray(fNumberOfModules, 0); |
794 | ldcn->SetName("Noise"); | |
795 | ldcp = new TObjArray(fNumberOfModules, 0); | |
796 | ldcp->SetName("Pedestal"); | |
797 | ldcbc = new TObjArray(fNumberOfModules, 0); | |
798 | ldcbc->SetName("BadChannels"); | |
f67db810 | 799 | for (Int_t i = 0; i < fNumberOfModules; i++) { |
800 | if (!fModules[i]) { | |
2e2c6def | 801 | delete ldcn; |
f67db810 | 802 | return kFALSE; |
803 | } | |
2e2c6def | 804 | modobjn = dynamic_cast<TObject*>(fModules[i]->GetCalibrationNoise()); |
805 | modobjp = dynamic_cast<TObject*>(fModules[i]->GetCalibrationPedestal()); | |
806 | modobjbc = dynamic_cast<TObject*>(fModules[i]->GetCalibrationBadChannels()); | |
807 | ldcn->AddAt(modobjn, i); | |
808 | ldcp->AddAt(modobjp, i); | |
809 | ldcbc->AddAt(modobjbc, i); | |
f67db810 | 810 | } |
2e2c6def | 811 | ldcn->Compress(); |
812 | ldcp->Compress(); | |
813 | ldcbc->Compress(); | |
a69c8ba0 | 814 | if (dafname) dadatafilename.Form("%s/", dafname); |
371588bb | 815 | dadatafilename += TString::Format("ITSSSDda_%i.root", fLdcId); |
a69c8ba0 | 816 | tmpfname = new Char_t[dadatafilename.Length()+1]; |
c4d90345 | 817 | dafname = strcpy(tmpfname, dadatafilename.Data()); |
818 | TFile *fileRun = new TFile (dadatafilename.Data(),"RECREATE"); | |
f67db810 | 819 | if (fileRun->IsZombie()) { |
c4d90345 | 820 | AliError(Form("AliITSHandleDaSSD: SaveCalibrationSSDLDC() error open file %s", dadatafilename.Data())); |
2e2c6def | 821 | ldcn->Delete(); |
f67db810 | 822 | delete fileRun; |
2e2c6def | 823 | delete ldcn; |
824 | delete ldcp; | |
825 | delete ldcbc; | |
f67db810 | 826 | return kFALSE; |
827 | } | |
2e2c6def | 828 | fileRun->WriteTObject(ldcn); |
829 | fileRun->WriteTObject(ldcp); | |
830 | fileRun->WriteTObject(ldcbc); | |
f67db810 | 831 | fileRun->Close(); |
2e2c6def | 832 | ldcn->Delete(); |
f67db810 | 833 | delete fileRun; |
2e2c6def | 834 | delete ldcn; |
835 | delete ldcp; | |
836 | delete ldcbc; | |
c4d90345 | 837 | return kTRUE; |
838 | } | |
839 | ||
840 | ||
841 | ||
842 | //______________________________________________________________________________ | |
843 | Bool_t AliITSHandleDaSSD::DumpModInfo(const Float_t meannosethreshold) const | |
844 | { | |
845 | // Dump calibration parameters | |
846 | AliITSModuleDaSSD *mod; | |
847 | AliITSChannelDaSSD *strip; | |
848 | if (!fModules) { | |
849 | cout << "SSDDALDC::DumpModInfo(): Error, no modules are allocated!" << endl; | |
850 | return kFALSE; | |
851 | } | |
852 | cout << "Modules with MeanNoise > " << meannosethreshold << endl; | |
853 | for (Int_t i = 0; i < fNumberOfModules; i++) { | |
854 | if (!(mod = fModules[i])) continue; | |
371588bb | 855 | Float_t maxnoise = 0.0f, meannoise = 0.0f, maxped = 0.0f; |
c4d90345 | 856 | Int_t maxstrind = 0, novfstr = 0; |
857 | for (Int_t strind = 0; strind < mod->GetNumberOfStrips(); strind++) { | |
858 | if (!(strip = mod->GetStrip(strind))) {novfstr++; continue; } | |
859 | if (strip->GetNoiseCM() >= AliITSChannelDaSSD::GetUndefinedValue() ) {novfstr++; continue; } | |
860 | if (maxnoise < strip->GetNoiseCM()) { | |
861 | maxnoise = strip->GetNoiseCM(); | |
862 | maxstrind = strind; | |
863 | } | |
864 | meannoise = (strind - novfstr) ? meannoise + (strip->GetNoiseCM() - meannoise) / static_cast<Float_t>(strind - novfstr + 1) | |
865 | : strip->GetNoiseCM(); | |
371588bb | 866 | if (TMath::Abs(maxped) < TMath::Abs(strip->GetPedestal())) maxped = strip->GetPedestal(); |
c4d90345 | 867 | } |
868 | if (meannoise > meannosethreshold) | |
869 | cout << "Mod: " << i << "; DDl: " << (int)mod->GetDdlId() << "; AD: " << (int)mod->GetAD() | |
371588bb | 870 | << "; ADC: " << (int)mod->GetADC() << "; MaxPed = " << maxped |
871 | << "; MeanNoise = " << meannoise | |
c4d90345 | 872 | << "; NOfStrips = " << (mod->GetNumberOfStrips() - novfstr) << endl; |
873 | } | |
874 | return kTRUE; | |
875 | } | |
876 | ||
877 | ||
878 | ||
879 | //______________________________________________________________________________ | |
880 | Bool_t AliITSHandleDaSSD::PrintModCalibrationData(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Char_t *fname) const | |
881 | { | |
882 | // Print Module calibration data whether in file on in cout | |
883 | AliITSChannelDaSSD *strip; | |
884 | ofstream datafile; | |
885 | ostream *outputfile; | |
886 | if (!fname) { outputfile = &cout; } | |
887 | else { | |
888 | datafile.open(fname, ios::out); | |
889 | if (datafile.fail()) return kFALSE; | |
890 | outputfile = dynamic_cast<ostream*>(&datafile); | |
891 | } | |
892 | *outputfile << "DDL = " << (int)ddlID << "; AD = " << (int)ad << "; ADC = " << (int)adc << endl; | |
893 | for (Int_t strind = 0; strind < AliITSModuleDaSSD::GetStripsPerModuleConst(); strind++) { | |
8bcdc40d | 894 | if ( (strip = GetStrip(ddlID, ad, adc, strind)) ) { |
c4d90345 | 895 | *outputfile << "Str = " << strind << "; ped = " << strip->GetPedestal() |
896 | << "; noise = " << strip->GetNoiseCM() << endl; | |
897 | } | |
898 | else continue; | |
899 | } | |
900 | if (datafile.is_open()) datafile.close(); | |
901 | return kTRUE; | |
902 | } | |
903 | ||
904 | ||
905 | ||
371588bb | 906 | //______________________________________________________________________________ |
c4d90345 | 907 | void AliITSHandleDaSSD::DumpInitData(const Char_t *str) const |
908 | { | |
371588bb | 909 | // Print general information retrieved from raw data file |
c4d90345 | 910 | cout << "Raw data file: " << fRawDataFileName << endl |
911 | << "LDC: " << (Int_t)fLdcId << "; RunId: " << fRunId << endl | |
912 | << "Number of physics events: " << fNumberOfEvents << endl | |
913 | << str; | |
914 | } | |
915 | ||
916 | ||
917 | //______________________________________________________________________________ | |
918 | Bool_t AliITSHandleDaSSD::AllocateSimulatedModules(const Int_t copymodind) | |
919 | { | |
920 | // Used to allocate simulated modules to test the performance | |
921 | AliITSModuleDaSSD *module; | |
922 | UChar_t ad, adc, ddlID; | |
923 | ad = adc = ddlID = 0; | |
924 | if (!(fModules[copymodind])) return kFALSE; | |
925 | for (Int_t modind = 0; modind < fNumberOfModules; modind++) { | |
926 | if (!fModules[modind]) { | |
927 | module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst()); | |
928 | if ((adc < 5) || ((adc > 7) && (adc < 13)) ) adc += 1; | |
929 | else if (adc == 5) adc = 8; | |
930 | else if (adc == 13) { | |
931 | adc = 0; | |
932 | if (ad < 8) ad += 1; | |
933 | else { | |
934 | ad = 0; | |
935 | ddlID +=1; | |
936 | } | |
937 | } | |
938 | if (!module->SetModuleIdData (ddlID, ad, adc, modind)) return kFALSE; | |
939 | fModules[modind] = module; | |
940 | for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) { | |
941 | AliITSChannelDaSSD *cstrip = fModules[copymodind]->GetStrip(strind); | |
942 | Long_t eventsnumber = cstrip->GetEventsNumber(); | |
943 | AliITSChannelDaSSD *strip = new AliITSChannelDaSSD(strind, eventsnumber); | |
944 | for (Long_t evind = 0; evind < eventsnumber; evind++) { | |
945 | Short_t sign = *cstrip->GetSignal(evind); | |
946 | if (!strip->SetSignal(evind, sign)) AliError(Form("AliITSHandleDaSSD: Copy events error! mod = %i, str = %i", modind, strind)); | |
947 | } | |
948 | module->SetStrip(strip, strind); | |
949 | } | |
950 | } | |
951 | else { | |
952 | ddlID = fModules[modind]->GetDdlId(); | |
953 | ad = fModules[modind]->GetAD(); | |
954 | adc = fModules[modind]->GetADC(); | |
955 | } | |
956 | } | |
957 | for (UShort_t modind = 0; modind < fNumberOfModules; modind++) fModules[modind]->SetModuleId(modind + 1080); | |
f67db810 | 958 | return kTRUE; |
959 | } | |
371588bb | 960 |