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