1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 /// This class provides ITS SSD data handling
22 // Author: Oleksandr Borysov
24 ///////////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
30 #include "AliITSHandleDaSSD.h"
38 #include "AliITSNoiseSSDv2.h"
39 #include "AliITSPedestalSSDv2.h"
40 #include "AliITSBadChannelsSSDv2.h"
41 #include "AliITSRawStreamSSD.h"
42 #include "AliRawReaderDate.h"
43 #include "AliITSRawStreamSSD.h"
44 #include "AliITSChannelDaSSD.h"
47 ClassImp(AliITSHandleDaSSD)
52 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModules = 1698; // Number of SSD modules in ITS
53 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerDdl = 108; // Number of SSD modules in DDL
54 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerSlot = 12; // Number of SSD modules in Slot
55 const Short_t AliITSHandleDaSSD::fgkMinSSDModuleId = 500; // Initial SSD modules number
56 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDSlotsPerDDL = 9; // Number of SSD slots per DDL
57 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDDDLs = 16; // Number of SSD modules in Slot
58 const Float_t AliITSHandleDaSSD::fgkPedestalThresholdFactor = 3.0; // Defalt value for fPedestalThresholdFactor
59 const Float_t AliITSHandleDaSSD::fgkCmThresholdFactor = 3.0; // Defalt value for fCmThresholdFactor
61 const UInt_t AliITSHandleDaSSD::fgkZsBitMask = 0x0000003F; // Bit mask for FEROM ZS
62 const UInt_t AliITSHandleDaSSD::fgkOffSetBitMask = 0x000003FF; // Bit mask for FEROM Offset correction
63 const UInt_t AliITSHandleDaSSD::fgkBadChannelMask = 0x00000001; // Mask to suppress the channel from the bad channel list
64 const Int_t AliITSHandleDaSSD::fgkAdcPerDBlock = 6; // FEROM configuration file constant
66 //______________________________________________________________________________
67 AliITSHandleDaSSD::AliITSHandleDaSSD() :
68 fRawDataFileName(NULL),
76 fBadChannelsList(NULL),
82 fPedestalThresholdFactor(fgkPedestalThresholdFactor),
83 fCmThresholdFactor(fgkCmThresholdFactor),
85 fOffsetDefault(INT_MAX),
90 // Default constructor
94 //______________________________________________________________________________
95 AliITSHandleDaSSD::AliITSHandleDaSSD(Char_t *rdfname) :
96 fRawDataFileName(NULL),
104 fBadChannelsList(NULL),
110 fPedestalThresholdFactor(fgkPedestalThresholdFactor) ,
111 fCmThresholdFactor(fgkCmThresholdFactor),
113 fOffsetDefault(INT_MAX),
118 if (!Init(rdfname)) AliError("AliITSHandleDaSSD::AliITSHandleDaSSD() initialization error!");
122 //______________________________________________________________________________
123 AliITSHandleDaSSD::AliITSHandleDaSSD(const AliITSHandleDaSSD& ssdadldc) :
125 fRawDataFileName(ssdadldc.fRawDataFileName),
126 fNumberOfModules(ssdadldc.fNumberOfModules),
128 fModIndProcessed(ssdadldc.fModIndProcessed),
129 fModIndRead(ssdadldc.fModIndRead),
132 fNumberOfEvents(ssdadldc.fNumberOfEvents),
133 fBadChannelsList(NULL),
135 fALaddersOff(ssdadldc.fALaddersOff),
136 fCLaddersOff(ssdadldc.fCLaddersOff),
137 fLdcId(ssdadldc.fLdcId),
138 fRunId(ssdadldc.fRunId),
139 fPedestalThresholdFactor(ssdadldc.fPedestalThresholdFactor),
140 fCmThresholdFactor(ssdadldc.fCmThresholdFactor),
141 fZsDefault(ssdadldc.fZsDefault),
142 fOffsetDefault(ssdadldc.fOffsetDefault),
143 fZsMinimum(ssdadldc.fZsMinimum),
144 fMergeBCLists(ssdadldc.fMergeBCLists),
145 fZsFactor(ssdadldc.fZsFactor)
148 if ((ssdadldc.fNumberOfModules > 0) && (ssdadldc.fModules)) {
149 fModules = new (nothrow) AliITSModuleDaSSD* [ssdadldc.fNumberOfModules];
151 for (Int_t modind = 0; modind < ssdadldc.fNumberOfModules; modind++) {
152 if (ssdadldc.fModules[modind]) {
153 fModules[modind] = new AliITSModuleDaSSD(*(ssdadldc.fModules[modind]));
154 if (!fModules[modind]) {
155 AliError("AliITSHandleDaSSD: Error copy constructor");
156 for (Int_t i = (modind - 1); i >= 0; i--) delete fModules[modind];
161 } else fModules[modind] = NULL;
164 AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", ssdadldc.fNumberOfModules));
165 fNumberOfModules = 0;
169 if (ssdadldc.fBadChannelsList) AliWarning("fBadChannelsList is not copied by copy constructor, use other methods to init it!");
170 if (ssdadldc.fDDLModuleMap) AliWarning("fDDLModuleMap is not copied by copy constructor, use other methods to init it!");
174 //______________________________________________________________________________
175 AliITSHandleDaSSD& AliITSHandleDaSSD::operator = (const AliITSHandleDaSSD& ssdadldc)
177 // assignment operator
178 if (this == &ssdadldc) return *this;
179 TObject::operator=(ssdadldc);
181 for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i];
185 if (fModIndex) { delete [] fModIndex; fModIndex = NULL; }
186 if ((ssdadldc.fNumberOfModules > 0) && (ssdadldc.fModules)) {
187 fModules = new (nothrow) AliITSModuleDaSSD* [ssdadldc.fNumberOfModules];
189 for (Int_t modind = 0; modind < ssdadldc.fNumberOfModules; modind++) {
190 if (ssdadldc.fModules[modind]) {
191 fModules[modind] = new AliITSModuleDaSSD(*(ssdadldc.fModules[modind]));
192 if (!fModules[modind]) {
193 AliError("AliITSHandleDaSSD: Error assignment operator");
194 for (Int_t i = (modind - 1); i >= 0; i--) delete fModules[modind];
199 } else fModules[modind] = NULL;
202 AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", ssdadldc.fNumberOfModules));
203 fNumberOfModules = 0;
207 fRawDataFileName = NULL;
208 fModIndProcessed = 0;
211 fEqIndex = ssdadldc.fEqIndex;
212 fNumberOfEvents = ssdadldc.fNumberOfEvents;
213 fLdcId = ssdadldc.fLdcId;
214 fRunId = ssdadldc.fRunId;
215 fPedestalThresholdFactor = ssdadldc.fPedestalThresholdFactor;
216 fCmThresholdFactor = ssdadldc.fCmThresholdFactor;
217 fZsDefault = ssdadldc.fZsDefault;
218 fOffsetDefault = ssdadldc.fOffsetDefault;
219 fZsMinimum = ssdadldc.fZsMinimum;
220 fMergeBCLists = ssdadldc.fMergeBCLists;
221 fZsFactor = ssdadldc.fZsFactor;
222 fALaddersOff = ssdadldc.fALaddersOff;
223 fCLaddersOff = ssdadldc.fCLaddersOff;
224 fBadChannelsList = NULL;
225 fDDLModuleMap = NULL;
227 if (ssdadldc.fBadChannelsList) AliWarning("fBadChannelsList is not copied by assignment operator, use other methods to init it!");
228 if (ssdadldc.fDDLModuleMap) AliWarning("fDDLModuleMap is not copied by assignment operator, use other methods to init it!");
233 //______________________________________________________________________________
234 AliITSHandleDaSSD::~AliITSHandleDaSSD()
236 // Default destructor
239 for (Int_t i = 0; i < fNumberOfModules; i++)
241 if (fModules[i]) delete fModules[i];
245 if (fModIndex) delete [] fModIndex;
246 if (fBadChannelsList) delete fBadChannelsList;
247 if (fDDLModuleMap) delete [] fDDLModuleMap;
252 //______________________________________________________________________________
253 void AliITSHandleDaSSD::Reset()
255 // Delete array of AliITSModuleDaSSD* objects.
257 for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i];
261 if (fModIndex) { delete [] fModIndex; fModIndex = NULL; }
263 if (fBadChannelsList) {
264 delete fBadChannelsList;
265 fBadChannelsList = NULL;
267 if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL; }
271 fRawDataFileName = NULL;
272 fModIndProcessed = fModIndRead = 0;
275 fPedestalThresholdFactor = fgkPedestalThresholdFactor;
276 fCmThresholdFactor = fgkCmThresholdFactor;
281 //______________________________________________________________________________
282 Bool_t AliITSHandleDaSSD::Init(Char_t *rdfname)
284 // Read raw data file and set initial and configuration parameters
285 Long_t physeventind = 0, strn = 0, nofstripsev, nofstrips = 0;
286 Int_t nofeqipmentev, nofeqipment = 0, eqn = 0;
287 AliRawReaderDate *rawreaderdate = NULL;
288 UChar_t *data = NULL;
289 Long_t datasize = 0, eqbelsize = 1;
291 rawreaderdate = new AliRawReaderDate(rdfname, 0);
292 if (!(rawreaderdate->GetAttributes() || rawreaderdate->GetEventId())) {
293 AliError(Form("AliITSHandleDaSSD: Error reading raw data file %s by RawReaderDate", rdfname));
297 if (rawreaderdate->NextEvent()) {
298 fRunId = rawreaderdate->GetRunNumber();
299 rawreaderdate->RewindEvents();
300 } else { MakeZombie(); return kFALSE; }
301 if (fModules) Reset();
302 //rawreaderdate->SelectEvents(-1);
303 rawreaderdate->Select("ITSSSD");
305 while (rawreaderdate->NextEvent()) {
306 if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue;
309 while (rawreaderdate->ReadNextData(data)) {
310 fLdcId = rawreaderdate->GetLDCId();
312 datasize = rawreaderdate->GetDataSize();
313 eqbelsize = rawreaderdate->GetEquipmentElementSize();
314 if ( datasize % eqbelsize ) {
315 AliError(Form("AliITSHandleDaSSD: Error Init(%s): event data size %ld is not an integer of equipment data size %ld",
316 rdfname, datasize, eqbelsize));
320 nofstripsev += (Int_t) (datasize / eqbelsize);
322 if (physeventind++) {
323 if (nofstrips != nofstripsev) AliWarning(Form("AliITSHandleDaSSD: number of strips varies from event to event, ev = %ld, %ld",
324 physeventind, nofstripsev));
325 if (nofeqipment != nofeqipmentev) AliWarning("AliITSHandleDaSSD: number of DDLs varies from event to event");
327 nofstrips = nofstripsev;
328 nofeqipment = nofeqipmentev;
329 if (strn < nofstrips) strn = nofstrips;
330 if (eqn < nofeqipment) eqn = nofeqipment;
332 delete rawreaderdate;
333 if ((physeventind > 0) && (strn > 0))
335 fNumberOfEvents = physeventind;
336 fRawDataFileName = rdfname;
339 fModIndex = new (nothrow) Int_t [fgkNumberOfSSDModulesPerDdl * eqn];
341 for (Int_t i = 0; i < fgkNumberOfSSDModulesPerDdl * eqn; i++) fModIndex[i] = -1;
342 else AliWarning(Form("AliITSHandleDaSSD: Error Init(%s): Index array for %i modules was not created",
343 rdfname, fgkNumberOfSSDModulesPerDdl * eqn));
344 if (SetNumberOfModules(fgkNumberOfSSDModulesPerDdl * eqn)) {
345 TString str = TString::Format("Max number of equipment: %d, max number of channels: %ld\n", eqn, strn);
346 DumpInitData(str.Data());
356 //______________________________________________________________________________
357 AliITSModuleDaSSD* AliITSHandleDaSSD::GetModule (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
359 // Retrieve AliITSModuleDaSSD object from the array
360 if (!fModules) return NULL;
361 for (Int_t i = 0; i < fNumberOfModules; i++) {
363 if ( (fModules[i]->GetDdlId() == ddlID)
364 && (fModules[i]->GetAD() == ad)
365 && (fModules[i]->GetADC() == adc))
373 Int_t AliITSHandleDaSSD::GetModuleIndex (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
375 // Retrieve the position of AliITSModuleDaSSD object in the array
376 if (!fModules) return -1;
377 for (Int_t i = 0; i < fNumberOfModules; i++) {
379 if ( (fModules[i]->GetDdlId() == ddlID)
380 && (fModules[i]->GetAD() == ad)
381 && (fModules[i]->GetADC() == adc))
390 //______________________________________________________________________________
391 AliITSChannelDaSSD* AliITSHandleDaSSD::GetStrip (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t stripID) const
393 // Retrieve AliITSChannalDaSSD object from the array
394 for (Int_t modind = 0; modind < fNumberOfModules; modind++) {
395 if ( (fModules[modind]->GetDdlId() == ddlID)
396 && (fModules[modind]->GetAD() == ad)
397 && (fModules[modind]->GetADC() == adc) )
399 return fModules[modind]->GetStrip(stripID);
402 AliError(Form("AliITSHandleDaSSD: Error GetStrip (%i, %i, %i, %i), strip not found, returns NULL!",
403 ddlID, ad, adc, stripID));
409 //______________________________________________________________________________
410 Bool_t AliITSHandleDaSSD::SetModule(AliITSModuleDaSSD *const module, const Int_t index)
412 // Assign array element with AliITSModuleDaSSD object
413 if ((index < fNumberOfModules) && (index >= 0))
415 if (fModules[index]) delete fModules[index];
416 fModules[index] = module;
424 //______________________________________________________________________________
425 Bool_t AliITSHandleDaSSD::SetNumberOfModules (const Int_t numberofmodules)
427 // Allocates memory for AliITSModuleDaSSD objects
428 if (numberofmodules > fgkNumberOfSSDModules)
429 AliWarning(Form("AliITSHandleDaSSD: the number of modules %i you use exceeds the maximum %i for ALICE ITS SSD",
430 numberofmodules, fgkNumberOfSSDModules));
432 for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i];
436 fModules = new (nothrow) AliITSModuleDaSSD* [numberofmodules];
438 fNumberOfModules = numberofmodules;
439 memset(fModules, 0, sizeof(AliITSModuleDaSSD*) * numberofmodules);
442 AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", numberofmodules));
443 fNumberOfModules = 0;
451 //______________________________________________________________________________
452 Bool_t AliITSHandleDaSSD::ReadStaticBadChannelsMap(const Char_t *filename)
454 // Reads Static Bad Channels Map from the file
457 AliWarning("No file name is specified for Static Bad Channels Map!");
460 bcfile = new TFile(filename, "READ");
461 if (bcfile->IsZombie()) {
462 AliWarning(Form("Error reading file %s with Static Bad Channels Map!", filename));
465 bcfile->GetObject("AliITSBadChannelsSSDv2;1", fBadChannelsList);
466 if (!fBadChannelsList) {
467 AliWarning("Error fBadChannelsList == NULL!");
479 Bool_t AliITSHandleDaSSD::ReadDDLModuleMap(const Char_t *filename)
481 // Reads the SSD DDL Map from the file
483 AliRawReaderDate *rwr = NULL;
484 AliITSRawStreamSSD *rsm = NULL;
486 if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL;}
487 fDDLModuleMap = new (nothrow) Int_t [fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl];
488 if (!fDDLModuleMap) {
489 AliWarning("Error allocation memory for DDL Map!");
493 AliWarning("No file name is specified for SSD DDL Map, using the one from AliITSRawStreamSSD!");
494 rwr = new AliRawReaderDate(event);
495 rsm = new AliITSRawStreamSSD(rwr);
496 rsm->Setv11HybridDDLMapping();
497 for (Int_t ddli = 0; ddli < fgkNumberOfSSDDDLs; ddli++)
498 for (Int_t mi = 0; mi < fgkNumberOfSSDModulesPerDdl; mi++)
499 fDDLModuleMap[(ddli * fgkNumberOfSSDModulesPerDdl + mi)] = rsm->GetModuleNumber(ddli, mi);
504 ddlmfile.open(filename, ios::in);
505 if (!ddlmfile.is_open()) {
506 AliWarning(Form("Error reading file %s with SSD DDL Map!", filename));
507 if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL;}
511 while((!ddlmfile.eof()) && (ind < (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl))) {
512 ddlmfile >> fDDLModuleMap[ind++];
513 if (ddlmfile.fail()) AliError(Form("Error extracting number from the DDL map file %s, ind: %d ", filename, ind));
515 if (ind != (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl))
516 AliWarning(Form("Only %i (< %i) entries were read from DDL Map!", ind, (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl)));
523 //______________________________________________________________________________
524 Int_t AliITSHandleDaSSD::ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber)
526 // Reads raw data from file
527 if (!Init(fileName)){
528 AliError("AliITSHandleDaSSD: Error ReadCalibrationDataFile");
531 fNumberOfEvents = eventsnumber;
532 return ReadModuleRawData (fNumberOfModules);
537 //______________________________________________________________________________
538 Int_t AliITSHandleDaSSD::ReadModuleRawData (const Int_t modulesnumber)
540 // Reads raw data from file
541 AliRawReader *rawreaderdate = NULL;
542 AliITSRawStreamSSD *stream = NULL;
543 AliITSModuleDaSSD *module;
544 AliITSChannelDaSSD *strip;
546 Int_t nofeqipment, eqind;
547 Short_t equipid, prequipid;
549 if (!(rawreaderdate = new AliRawReaderDate(fRawDataFileName, 0))) return 0;
551 AliError("AliITSHandleDaSSD: Error ReadModuleRawData: no structure was allocated for data");
554 if (!fDDLModuleMap) if (!ReadDDLModuleMap()) AliWarning("DDL map is not defined, ModuleID will be set to 0!");
555 stream = new AliITSRawStreamSSD(rawreaderdate);
556 stream->Setv11HybridDDLMapping();
557 //rawreaderdate->SelectEvents(-1);
558 rawreaderdate->Select("ITSSSD");
561 while (rawreaderdate->NextEvent()) {
562 if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue;
565 while (stream->Next()) {
566 equipid = rawreaderdate->GetEquipmentId();
567 if ((equipid != prequipid)) {
568 if ((eqind = GetEqIndex(equipid)) < 0) { fEqIndex.AddAt(equipid, nofeqipment); eqind = nofeqipment++; }
571 Int_t equiptype = rawreaderdate->GetEquipmentType();
572 UChar_t ddlID = (UChar_t)rawreaderdate->GetDDLID();
573 UChar_t ad = stream->GetAD();
574 UChar_t adc = stream->GetADC();
575 UShort_t stripID = stream->GetSideFlag() ? AliITSChannelDaSSD::GetMaxStripIdConst() - stream->GetStrip() : stream->GetStrip();
576 Short_t signal = stream->GetSignal();
578 Int_t indpos = (eqind * fgkNumberOfSSDModulesPerDdl)
579 + ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2));
580 Int_t modpos = fModIndex[indpos];
581 if (((modpos > 0) && (modpos < fModIndRead)) || ((modpos < 0) && (modind == modulesnumber))) continue;
582 if ((modpos < 0) && (modind < modulesnumber)) {
583 module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst());
585 if (fDDLModuleMap) mddli = RetrieveModuleId(ddlID, ad, adc);
587 if (!module->SetModuleIdData (ddlID, ad, adc, mddli)) return 0;
588 module->SetModuleRorcId (equipid, equiptype);
589 modpos = fModIndRead + modind;
591 fModules[modpos] = module;
592 fModIndex[indpos] = modpos;
594 if (stripID < AliITSModuleDaSSD::GetStripsPerModuleConst()) {
595 if (!(strip = fModules[modpos]->GetStrip(stripID))) {
596 strip = new AliITSChannelDaSSD(stripID, fNumberOfEvents);
597 fModules[modpos]->SetStrip(strip, stripID);
599 strip->SetSignal(eventind, signal);
601 if (!(fModules[modpos]->GetCMFerom())) {
602 fModules[modpos]->AllocateCMFeromArray();
603 fModules[modpos]->SetCMFeromEventsNumber(fNumberOfEvents);
605 fModules[modpos]->SetCMFerom(signal, (stripID - AliITSModuleDaSSD::GetStripsPerModuleConst()), eventind);
608 if (++eventind > fNumberOfEvents) break;
611 delete rawreaderdate;
612 if (modind) cout << "The memory was allocated for " << modind << " modules." << endl;
613 fModIndRead += modind;
614 if (modind < modulesnumber) RelocateModules();
620 //______________________________________________________________________________
621 Bool_t AliITSHandleDaSSD::RelocateModules()
623 // Relocate memory for AliITSModuleDaSSD object array
625 AliITSModuleDaSSD **marray = NULL;
626 for (Int_t modind = 0; modind < fNumberOfModules; modind++)
627 if (fModules[modind]) nm += 1;
628 if (nm == fNumberOfModules) return kTRUE;
629 marray = new (nothrow) AliITSModuleDaSSD* [nm];
631 AliError(Form("AliITSHandleDaSSD: Error relocating memory for %i AliITSModuleDaSSD* objects!", nm));
635 for (Int_t modind = 0; modind < fNumberOfModules; modind++)
636 if (fModules[modind]) marray[nm++] = fModules[modind];
639 fNumberOfModules = fModIndRead = nm;
645 //______________________________________________________________________________
646 Bool_t AliITSHandleDaSSD::AddFeromCm(const AliITSModuleDaSSD *const module)
648 // Restore the original signal value adding CM calculated and subtracted in ferom
649 AliITSChannelDaSSD *strip;
650 Short_t *signal, *cmferom;
652 if (!module) return kFALSE;
653 if (!module->GetCMFerom()) return kTRUE;
654 for (Int_t chipind = 0; chipind < AliITSModuleDaSSD::GetChipsPerModuleConst(); chipind++) {
655 if (!(cmferom = module->GetCMFerom(chipind))) {
656 AliWarning(Form("AliITSHandleDaSSD: There is no Ferom CM values for chip %i, module %i!", chipind, module->GetModuleId()));
659 for (Int_t strind = (chipind * AliITSModuleDaSSD::GetStripsPerChip());
660 strind < ((chipind + 1) * AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
661 if (!(strip = module->GetStrip(strind))) continue;
662 if (!(signal = strip->GetSignal())) continue;
663 // if (strip->GetEventsNumber() != module->GetEventsNumber()) return kFALSE;
665 for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
666 if (SignalOutOfRange(signal[ev]) || SignalOutOfRange(cmferom[ev])) ovev += 1;
668 Short_t signal1 = signal[ev] + cmferom[ev];
669 strip->SetSignal(ev, signal1);
679 //______________________________________________________________________________
680 Bool_t AliITSHandleDaSSD::CalculatePedestal(const AliITSModuleDaSSD *const module)
682 // Calculates Pedestal
683 AliITSChannelDaSSD *strip;
684 Double_t pedestal, noise;
687 if (!module) return kFALSE;
688 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
689 if (!(strip = module->GetStrip(strind))) continue;
690 if (!(signal = strip->GetSignal())) {
691 AliError(Form("AliITSHandleDaSSD: Error CalculatePedestal(): there are no events data for module[%i] strip[%i]->GetSignal()",
692 module->GetModuleId(), strind));
695 //************* pedestal first pass ****************
698 for (ev = 0; ev < strip->GetEventsNumber(); ev++)
699 if (SignalOutOfRange(signal[ev])) ovev += 1;
700 else pedestal = ((ev - ovev)) ? pedestal + (signal[ev] - pedestal) / static_cast<Double_t>(ev - ovev + 1) : signal[ev];
701 if (ev == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue();
702 strip->SetPedestal(static_cast<Float_t>(pedestal));
703 //************* noise *******************************
704 Double_t nsum = 0.0L;
706 for (ev = 0; ev < strip->GetEventsNumber(); ev++) {
707 if (SignalOutOfRange(signal[ev])) ovev += 1;
708 else nsum += pow((signal[ev] - strip->GetPedestal()), 2);
710 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Double_t)(n));
711 else noise = AliITSChannelDaSSD::GetUndefinedValue();
712 strip->SetNoise(static_cast<Float_t>(noise));
713 //************* pedestal second pass ****************
716 for (ev = 0; ev < strip->GetEventsNumber(); ev++)
717 if ( SignalOutOfRange(signal[ev])
718 || TMath::Abs(signal[ev] - strip->GetPedestal()) > (fPedestalThresholdFactor * strip->GetNoise())) ovev += 1;
719 else pedestal = ((ev - ovev)) ? pedestal + (signal[ev] - pedestal) / static_cast<Double_t>(ev - ovev + 1) : signal[ev];
720 if (ev == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue();
721 strip->SetPedestal(static_cast<Float_t>(pedestal));
722 strip->SetOverflowNumber(ovev);
728 //______________________________________________________________________________
729 Bool_t AliITSHandleDaSSD::CalculateNoise(const AliITSModuleDaSSD *const module)
732 AliITSChannelDaSSD *strip;
736 if (!module) return kFALSE;
737 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
738 if (!(strip = module->GetStrip(strind))) continue;
739 if (!(signal = strip->GetSignal())) {
740 strip->SetNoise(AliITSChannelDaSSD::GetUndefinedValue());
741 AliError(Form("AliITSHandleDaSSD: Error CalculateNoise(): there are no events data for module[%i] strip[%i]->GetSignal()",
742 module->GetModuleId(), strind));
745 Double_t nsum = 0.0L;
747 for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
748 if (SignalOutOfRange(signal[ev])) ovev += 1;
749 else nsum += pow((signal[ev] - strip->GetPedestal()), 2);
751 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = static_cast<Float_t>(sqrt(nsum / (Float_t)(n)));
752 else noise = AliITSChannelDaSSD::GetUndefinedValue();
753 strip->SetNoise(noise);
760 //______________________________________________________________________________
761 Bool_t AliITSHandleDaSSD::CalculateNoiseCM(AliITSModuleDaSSD *const module)
763 // Calculates Noise with CM correction
764 AliITSChannelDaSSD *strip = NULL;
768 if (!CalculateCM(module)) {
769 AliError("Error: AliITSHandleDaSSD::CalculateCM() returned kFALSE");
772 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
773 if (!(strip = module->GetStrip(strind))) continue; //return kFALSE;
774 if (!(signal = strip->GetSignal())) {
775 strip->SetNoiseCM(AliITSChannelDaSSD::GetUndefinedValue());
776 AliError(Form("AliITSHandleDaSSD: Error CalculateNoiseCM(): there are no events data for module[%i] strip[%i]->GetSignal()",
777 module->GetModuleId(), strind));
778 continue; //return kFALSE;
780 Int_t chipind = strind / AliITSModuleDaSSD::GetStripsPerChip();
781 Double_t nsum = 0.0L;
783 for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
784 if (SignalOutOfRange(signal[ev])) ovev += 1;
785 else nsum += pow((signal[ev] - strip->GetPedestal() - module->GetCM(chipind, ev)), 2);
787 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = static_cast<Float_t>(sqrt(nsum / (Double_t)(n)));
788 else noise = AliITSChannelDaSSD::GetUndefinedValue();
789 strip->SetNoiseCM(noise);
796 //______________________________________________________________________________
797 Bool_t AliITSHandleDaSSD::CalculateCM(AliITSModuleDaSSD *const module)
800 AliITSChannelDaSSD *strip = NULL;
804 module->SetNumberOfChips(AliITSModuleDaSSD::GetChipsPerModuleConst());
805 for (Int_t chipind = 0; chipind < module->GetNumberOfChips(); chipind++) {
806 stripind = chipind * module->GetStripsPerChip();
807 module->GetCM()[chipind].Set(fNumberOfEvents);
808 module->GetCM()[chipind].Reset(0.0f);
809 for (Long_t ev = 0; ev < fNumberOfEvents; ev++) {
810 // calculate firs approximation of CM.
813 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
814 if (!(strip = module->GetStrip(strind))) continue; //return kFALSE;
815 if (!(signal = strip->GetSignal())) {
816 AliError(Form("AliITSHandleDaSSD: Error CalculateCM: there are no events data for module[%i] strip[%i]->GetSignal()",
817 module->GetModuleId(), strind));
820 if ((SignalOutOfRange(signal[ev])) || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1;
821 else cm0 += (signal[ev] - strip->GetPedestal());
823 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cm0 /= (Float_t)(n);
824 else { module->SetCM(0.0f, chipind, ev); continue; }
825 // calculate avarage (cm - (signal - pedestal)) over the chip
826 Double_t cmsigma = 0.0L;
828 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
829 if (!(strip = module->GetStrip(strind))) continue;
830 if (!(signal = strip->GetSignal())) {
831 AliError(Form("AliITSHandleDaSSD: Error CalculateCM: there are no events data for module[%i] strip[%i]->GetSignal()\n",
832 module->GetModuleId(), strind));
835 if ((SignalOutOfRange(signal[ev])) || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1;
836 else cmsigma += pow((cm0 - (signal[ev] - strip->GetPedestal())), 2);
838 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsigma = sqrt(cmsigma / (Float_t)(n));
839 else { module->SetCM(0.0f, chipind, ev); continue; }
840 // calculate cm with threshold
841 Double_t cmsum = 0.0L;
843 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
844 if (!(strip = module->GetStrip(strind))) continue;
845 signal = strip->GetSignal();
846 if ( (SignalOutOfRange(signal[ev])) || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())
847 || (TMath::Abs(cm0 - (signal[ev] - strip->GetPedestal())) > (fCmThresholdFactor * cmsigma)) ) ovstr += 1;
848 else cmsum += (signal[ev] - strip->GetPedestal());
850 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsum /= (Float_t)(n);
852 if (!(module->SetCM(cmsum, chipind, ev)))
853 AliError(Form("AliITSHandleDaSSD: Error, module->SetCM(...) returned kFALSE module:chip:event : [%d]:[%d]:[%ld]\n",
854 module->GetModuleId(), chipind, ev));
861 //______________________________________________________________________________
862 Bool_t AliITSHandleDaSSD::ProcessRawData(const Int_t nmread, const Bool_t usewelford)
864 // Performs calculation of calibration parameters (pedestal, noise, ...)
866 if (nmread <= 0) return kFALSE;
867 if (!fModules) return kFALSE;
868 while ((nm = ReadModuleRawData(nmread)) > 0) {
869 cout << "Processing next " << nm << " modules;" << endl;
870 for (Int_t modind = fModIndProcessed; modind < fModIndRead; modind++) {
871 if (!fModules[modind]) {
872 AliError(Form("AliITSHandleDaSSD: Error ProcessRawData(): No AliITSModuleDaSSD object with index %i is allocated in AliITSHandleDaSSD\n",
876 AddFeromCm(fModules[modind]);
878 CalculatePedNoiseW(fModules[modind]);
879 CalculateNoiseCMW(fModules[modind]);
881 CalculatePedestal(fModules[modind]);
882 CalculateNoise(fModules[modind]);
883 CalculateNoiseCM(fModules[modind]);
889 fModIndProcessed = fModIndRead;
890 cout << fModIndProcessed << " - done" << endl;
891 if (nm < nmread ) break;
897 //______________________________________________________________________________
898 Short_t AliITSHandleDaSSD::RetrieveModuleId(const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
900 // Retrieve ModuleId from the DDL map which is defined in AliITSRawStreamSSD class
901 if (!fDDLModuleMap) {
902 AliError("Error DDLMap is not initialized, return 0!");
905 Int_t mddli = ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2));
906 if ((ddlID < fgkNumberOfSSDDDLs) && (mddli < fgkNumberOfSSDModulesPerDdl)) {
907 mddli = fDDLModuleMap[ddlID * fgkNumberOfSSDModulesPerDdl + mddli];
910 AliWarning(Form("Module index = %d or ddlID = %d is out of range 0 is rturned", ddlID, mddli));
913 if (mddli > SHRT_MAX) return SHRT_MAX;
914 else return (Short_t)mddli;
919 //______________________________________________________________________________
920 AliITSNoiseSSDv2* AliITSHandleDaSSD::GetCalibrationOCDBNoise() const
922 // Fill in the array for OCDB
923 AliITSNoiseSSDv2 *ldcn = NULL;
924 AliITSModuleDaSSD *module = NULL;
925 AliITSChannelDaSSD *strip = NULL;
926 if (!fModules) return NULL;
927 ldcn = new AliITSNoiseSSDv2;
929 AliError("Error allocation mamory for AliITSBadChannelsSSDv2 object, return NULL!");
932 for (Int_t i = 0; i < fNumberOfModules; i++) {
933 if (!(module = fModules[i])) continue;
934 if (module->GetModuleId() < fgkMinSSDModuleId) continue;
935 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
936 if (!(strip = module->GetStrip(strind))) continue;
937 Short_t modid = module->GetModuleId() - fgkMinSSDModuleId;
938 if (strip->GetStripId() < AliITSModuleDaSSD::GetPNStripsPerModule() )
939 ldcn->AddNoiseP(modid, strip->GetStripId(), strip->GetNoiseCM());
941 ldcn->AddNoiseN(modid, (AliITSChannelDaSSD::GetMaxStripIdConst() - strip->GetStripId()), strip->GetNoiseCM());
948 //______________________________________________________________________________
949 AliITSBadChannelsSSDv2* AliITSHandleDaSSD::GetCalibrationBadChannels() const
951 // Fill in the TObjArray with the list of bad channels
952 AliITSBadChannelsSSDv2 *ldcbc = NULL;
953 AliITSModuleDaSSD *module = NULL;
954 AliITSChannelDaSSD *strip = NULL;
955 if (!fModules) return NULL;
956 ldcbc = new AliITSBadChannelsSSDv2;
958 AliError("Error allocation mamory for AliITSBadChannelsSSDv2 object, return NULL!");
961 for (Int_t i = 0; i < fNumberOfModules; i++) {
962 if (!(module = fModules[i])) continue;
963 if (module->GetModuleId() < fgkMinSSDModuleId) continue;
964 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
965 if (!(strip = module->GetStrip(strind))) continue;
966 Short_t modid = module->GetModuleId() - fgkMinSSDModuleId;
967 if (strip->GetStripId() < AliITSModuleDaSSD::GetPNStripsPerModule() )
968 ldcbc->AddBadChannelP(modid, strip->GetStripId(), EvaluateIfChannelIsBad(module, strip->GetStripId()));
970 ldcbc->AddBadChannelN(modid, (AliITSChannelDaSSD::GetMaxStripIdConst() - strip->GetStripId()),
971 EvaluateIfChannelIsBad(module, strip->GetStripId()));
979 //______________________________________________________________________________
980 Bool_t AliITSHandleDaSSD::SaveCalibrationSSDLDC(Char_t*& dafname)
982 // Save Calibration data locally
983 AliITSBadChannelsSSDv2 *ldcbc = NULL;
984 AliITSPedestalSSDv2 *ldcp = NULL;
985 AliITSNoiseSSDv2 *ldcn = NULL;
986 AliITSModuleDaSSD *module = NULL;
987 AliITSChannelDaSSD *strip = NULL;
989 TString dadatafilename("");
990 if (!fModules) return kFALSE;
991 ldcn = new AliITSNoiseSSDv2;
992 ldcp = new AliITSPedestalSSDv2;
993 ldcbc = new AliITSBadChannelsSSDv2;
994 if ((!ldcn) || (!ldcp) || (!ldcp)) {
995 AliError("Error allocation mamory for calibration objects, return kFALSE!");
998 for (Int_t i = 0; i < fNumberOfModules; i++) {
999 if (!(module = fModules[i])) continue;
1000 if (module->GetModuleId() < fgkMinSSDModuleId) continue;
1001 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
1002 if (!(strip = module->GetStrip(strind))) continue;
1003 Short_t modid = module->GetModuleId() - fgkMinSSDModuleId;
1004 if (strip->GetStripId() < AliITSModuleDaSSD::GetPNStripsPerModule() ) {
1005 ldcn->AddNoiseP(modid, strip->GetStripId(), strip->GetNoiseCM());
1006 ldcp->AddPedestalP(modid, strip->GetStripId(), strip->GetPedestal());
1007 ldcbc->AddBadChannelP(modid, strip->GetStripId(), EvaluateIfChannelIsBad(module, strip->GetStripId()));
1009 ldcn->AddNoiseN(modid, (AliITSChannelDaSSD::GetMaxStripIdConst() - strip->GetStripId()), strip->GetNoiseCM());
1010 ldcp->AddPedestalN(modid, (AliITSChannelDaSSD::GetMaxStripIdConst() - strip->GetStripId()), strip->GetPedestal());
1011 ldcbc->AddBadChannelN(modid, (AliITSChannelDaSSD::GetMaxStripIdConst() - strip->GetStripId()),
1012 EvaluateIfChannelIsBad(module, strip->GetStripId()));
1016 if (dafname) dadatafilename.Form("%s/", dafname);
1017 dadatafilename += TString::Format("ITSSSDda_%i.root", fLdcId);
1018 tmpfname = new Char_t[dadatafilename.Length()+1];
1019 Int_t sz = dadatafilename.Sizeof();
1020 dafname = strncpy(tmpfname, dadatafilename.Data(),sz);
1021 TFile *fileRun = new TFile (dadatafilename.Data(),"RECREATE");
1022 if (fileRun->IsZombie()) {
1023 AliError(Form("AliITSHandleDaSSD: SaveCalibrationSSDLDC() error open file %s", dadatafilename.Data()));
1031 fileRun->WriteTObject(ldcn);
1032 fileRun->WriteTObject(ldcp);
1033 if (fBadChannelsList)
1034 if (fMergeBCLists) {
1035 MergeBadChannels(ldcbc);
1036 fileRun->WriteTObject(ldcbc);
1037 } else fileRun->WriteTObject(fBadChannelsList);
1038 else fileRun->WriteTObject(ldcbc);
1048 //______________________________________________________________________________
1049 Int_t AliITSHandleDaSSD::MergeBadChannels(AliITSBadChannelsSSDv2*& bcl) const
1051 // Merges the statick bad channels list with bad channels got upon calibration
1052 AliITSModuleDaSSD *module = 0;
1053 Int_t nmpch = 0, nmnch = 0, ngpch = 0, ngnch = 0;
1054 if (!fBadChannelsList || !bcl) {
1055 AliWarning("Either fBadChannelsList == NULL or bad_channels_list == NULL, there is nothing to merge!");
1058 for (Int_t modind = 0; modind < GetNumberOfModules(); modind++) {
1059 if (!(module = fModules[modind])) continue;
1060 if (module->GetModuleId() < fgkMinSSDModuleId) continue;
1061 Short_t modid = module->GetModuleId() - fgkMinSSDModuleId;
1062 for (Int_t strind = 0; strind < AliITSModuleDaSSD::GetPNStripsPerModule(); strind++) {
1063 if ( (!(fBadChannelsList->GetBadChannelP(modid, strind) & fgkBadChannelMask))
1064 && (bcl->GetBadChannelP(modid, strind) & fgkBadChannelMask) )
1066 if ( (!(fBadChannelsList->GetBadChannelN(modid, strind) & fgkBadChannelMask))
1067 && (bcl->GetBadChannelN(modid, strind) & fgkBadChannelMask) )
1069 if ( (!(bcl->GetBadChannelP(modid, strind) & fgkBadChannelMask))
1070 && (fBadChannelsList->GetBadChannelP(modid, strind) & fgkBadChannelMask) ) {
1071 bcl->AddBadChannelP(modid, strind, fBadChannelsList->GetBadChannelP(modid, strind));
1074 if ( (!(bcl->GetBadChannelN(modid, strind) & fgkBadChannelMask))
1075 && (fBadChannelsList->GetBadChannelN(modid, strind) & fgkBadChannelMask) ) {
1076 bcl->AddBadChannelN(modid, strind, fBadChannelsList->GetBadChannelN(modid, strind));
1081 AliInfo(Form("Static bad, dynamic good: P%d, N%d", nmpch, nmnch));
1082 AliInfo(Form("Static good, dynamic bad: P%d, N%d", ngpch, ngnch));
1083 return (nmnch + nmpch);
1088 //______________________________________________________________________________
1089 Bool_t AliITSHandleDaSSD::DumpModInfo(const Float_t meannosethreshold) const
1091 // Dump calibration parameters
1092 AliITSModuleDaSSD *mod;
1093 AliITSChannelDaSSD *strip;
1095 cout << "SSDDALDC::DumpModInfo(): Error, no modules are allocated!" << endl;
1098 cout << "Modules with MeanNoise > " << meannosethreshold << endl;
1099 for (Int_t i = 0; i < fNumberOfModules; i++) {
1100 if (!(mod = fModules[i])) continue;
1101 Double_t maxnoise = 0.0L, meannoise = 0.0L, meanovf = 0.0L;
1102 Float_t maxped = 0.0f;
1103 Int_t maxstrind = 0, novfstr = 0, maxovf = 0;
1104 for (Int_t strind = 0; strind < mod->GetNumberOfStrips(); strind++) {
1105 if (!(strip = mod->GetStrip(strind))) {novfstr++; continue; }
1106 if (strip->GetNoiseCM() >= AliITSChannelDaSSD::GetUndefinedValue() ) {novfstr++; continue; }
1107 if (maxnoise < strip->GetNoiseCM()) {
1108 maxnoise = strip->GetNoiseCM();
1111 meannoise = (strind - novfstr) ? meannoise + (strip->GetNoiseCM() - meannoise) / static_cast<Double_t>(strind - novfstr + 1)
1112 : strip->GetNoiseCM();
1113 if (TMath::Abs(maxped) < TMath::Abs(strip->GetPedestal())) maxped = strip->GetPedestal();
1114 meanovf = (strind - novfstr) ? meanovf + (strip->GetOverflowNumber() - meanovf) / static_cast<Double_t>(strind - novfstr + 1)
1115 : strip->GetOverflowNumber();
1116 if (strip->GetOverflowNumber() > maxovf) maxovf = strip->GetOverflowNumber();
1118 if (meannoise > meannosethreshold)
1119 cout << "Mod: " << i << "; DDl: " << (int)mod->GetDdlId() << "; AD: " << (int)mod->GetAD()
1120 << "; ADC: " << (int)mod->GetADC() << "; MaxPed = " << maxped
1121 << "; MeanNoise = " << meannoise
1122 << "; NOfStrips = " << (mod->GetNumberOfStrips() - novfstr) << endl;
1123 if (maxovf > 10) cout << "Max number of events with overflow : " << maxovf << "; mean : " << meanovf << endl;
1130 //______________________________________________________________________________
1131 Bool_t AliITSHandleDaSSD::PrintModCalibrationData(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Char_t *fname) const
1133 // Print Module calibration data whether in file or in cout
1134 AliITSChannelDaSSD *strip;
1136 ostream *outputfile;
1137 if (!fname) { outputfile = &cout; }
1139 datafile.open(fname, ios::out);
1140 if (datafile.fail()) return kFALSE;
1141 outputfile = dynamic_cast<ostream*>(&datafile);
1143 *outputfile << "DDL = " << (int)ddlID << "; AD = " << (int)ad << "; ADC = " << (int)adc << endl;
1144 for (Int_t strind = 0; strind < AliITSModuleDaSSD::GetStripsPerModuleConst(); strind++) {
1145 if ( (strip = GetStrip(ddlID, ad, adc, strind)) ) {
1146 *outputfile << "Str = " << strind << "; ped = " << strip->GetPedestal()
1147 << "; noise = " << strip->GetNoiseCM() << endl;
1151 if (datafile.is_open()) datafile.close();
1157 //______________________________________________________________________________
1158 void AliITSHandleDaSSD::DumpInitData(const Char_t *str) const
1160 // Print general information retrieved from raw data file
1161 cout << "Raw data file: " << fRawDataFileName << endl
1162 << "LDC: " << (Int_t)fLdcId << "; RunId: " << fRunId << endl
1163 << "Number of physics events: " << fNumberOfEvents << endl
1168 //______________________________________________________________________________
1169 Bool_t AliITSHandleDaSSD::AllocateSimulatedModules(const Int_t copymodind)
1171 // Used to allocate simulated modules to test the performance
1172 AliITSModuleDaSSD *module;
1173 UChar_t ad, adc, ddlID;
1174 ad = adc = ddlID = 0;
1175 if (!(fModules[copymodind])) return kFALSE;
1176 for (Int_t modind = 0; modind < fNumberOfModules; modind++) {
1177 if (!fModules[modind]) {
1178 module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst());
1179 if ((adc < 5) || ((adc > 7) && (adc < 13)) ) adc += 1;
1180 else if (adc == 5) adc = 8;
1181 else if (adc == 13) {
1183 if (ad < 8) ad += 1;
1189 if (!module->SetModuleIdData (ddlID, ad, adc, modind)) return kFALSE;
1190 fModules[modind] = module;
1191 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
1192 AliITSChannelDaSSD *cstrip = fModules[copymodind]->GetStrip(strind);
1193 if(!cstrip)return kFALSE;
1194 Long_t eventsnumber = cstrip->GetEventsNumber();
1195 AliITSChannelDaSSD *strip = new AliITSChannelDaSSD(strind, eventsnumber);
1196 for (Long_t evind = 0; evind < eventsnumber; evind++) {
1197 Short_t sign = cstrip->GetSignal(evind);
1198 if (!strip->SetSignal(evind, sign)) AliError(Form("AliITSHandleDaSSD: Copy events error! mod = %i, str = %i", modind, strind));
1200 module->SetStrip(strip, strind);
1204 ddlID = fModules[modind]->GetDdlId();
1205 ad = fModules[modind]->GetAD();
1206 adc = fModules[modind]->GetADC();
1209 for (UShort_t modind = 0; modind < fNumberOfModules; modind++) fModules[modind]->SetModuleId(modind + 1080);
1215 //___________________________________________________________________________________________
1216 Bool_t AliITSHandleDaSSD::AdDataPresent(const Int_t ddl, const Int_t ad) const
1218 // Check if there are calibration data for given ddl and slot
1219 for (Int_t modind = 0; modind < fNumberOfModules; modind++)
1220 if ((GetModule(modind)->GetAD() == ad) && (GetModule(modind)->GetDdlId() == ddl)) return kTRUE;
1226 //___________________________________________________________________________________________
1227 Bool_t AliITSHandleDaSSD::SaveEqSlotCalibrationData(const Int_t ddl, const Int_t ad, const Char_t *fname) const
1229 // Saves calibration files for selected equipment (DDL)
1231 Int_t zsml, offsetml;
1232 ULong_t zsth, offset, zsoffset;
1234 AliError("File name must be specified!");
1237 if (!AdDataPresent(ddl, ad)) {
1238 AliError(Form("Error SaveEqSlotCalibrationData(ddl = %i, ad = %i) no data present", ddl, ad));
1241 feefile.open(fname, ios::out);
1242 if (!feefile.is_open()) {
1243 AliError(Form("Can not open the file %s for output!", fname));
1246 for (zsml = 0; fgkZsBitMask >> zsml; zsml++) ;
1247 for (offsetml = 0; fgkOffSetBitMask >> offsetml; offsetml++) ;
1248 for (Int_t strind = 0; strind < AliITSModuleDaSSD::GetStripsPerModuleConst(); strind++) {
1249 for (Int_t adcb = 0; adcb < fgkAdcPerDBlock; adcb++) {
1251 for (Int_t j = 0; j < 2; j++) {
1252 Int_t adc = adcb + j * 8;
1253 zsth = ZsThreshold(ddl, ad, adc, strind);
1254 offset = OffsetValue(ddl, ad, adc, strind);
1255 zsoffset = zsoffset | (((zsth << offsetml) | offset) << ((j == 0) ? (offsetml + zsml) : 0));
1257 feefile << "0x" << ConvBase(static_cast<unsigned long>(zsoffset), 16) << endl;
1265 //______________________________________________________________________________
1266 Int_t AliITSHandleDaSSD::ChannelIsBad(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1268 // Check if the channel is bad
1269 AliITSModuleDaSSD *module = NULL;
1271 if (fBadChannelsList && fDDLModuleMap) {
1272 modn = RetrieveModuleId(ddl, ad, adc);
1273 if (modn < 0) return -1;
1274 if (modn < fgkMinSSDModuleId) {
1275 AliWarning(Form("Module ddl/ad/adc: %d/%d/%d has number %d which is wrong for SSD module %d", ddl, ad, adc, strn, modn));
1278 Short_t modid = modn - fgkMinSSDModuleId;
1279 if (strn < AliITSModuleDaSSD::GetPNStripsPerModule())
1280 return (fBadChannelsList->GetBadChannelP(modid, strn) & fgkBadChannelMask);
1281 else return (fBadChannelsList->GetBadChannelN(modid, (AliITSChannelDaSSD::GetMaxStripIdConst() - strn)) & fgkBadChannelMask);
1283 AliError("Error ether bad channels list or DDLMap is not initialized or both, EvaluateIfChannelIsBad(module, strip) is used!");
1284 if ((module = GetModule(ddl, ad, adc))) {
1285 return (EvaluateIfChannelIsBad(module, strn) & fgkBadChannelMask);
1287 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, 0 is used!", ddl, ad, adc));
1296 //______________________________________________________________________________
1297 Int_t AliITSHandleDaSSD::LadderIsOff(const UChar_t ddl, const UChar_t ad, const UChar_t adc) const
1299 //Checks if the module with given ddl, ad, adc is on the ladder which is in the list of ladders which are off
1300 const Int_t nm5 = 500;
1301 const Int_t nm6 = 1248;
1302 const Int_t nml5a = 12;
1303 const Int_t nml5c = 10;
1304 const Int_t nml6a = 12;
1305 const Int_t nml6c = 13;
1306 Int_t modn, ladder, layer, side;
1307 AliITSModuleDaSSD *module;
1308 if (!(module = GetModule(ddl, ad, adc))) return 0;
1309 if ((modn = module->GetModuleId()) <= 0) modn = RetrieveModuleId(ddl, ad, adc);
1310 if (modn <= 0) return 0;
1311 layer = modn >= nm6 ? 1 : 0; // 6 : 5
1312 ladder = (modn - (layer ? nm6 : nm5)) / (layer ? (nml6a + nml6c) : (nml5a + nml5c));
1313 if ( ((modn - (layer ? nm6 : nm5)) % (layer ? (nml6a + nml6c) : (nml5a + nml5c))) < (layer ? nml6a : nml5a))
1316 ladder += (layer ? 600 : 500);
1319 if (fCLaddersOff.GetSize()) {
1320 for(Int_t i = 0; i < fCLaddersOff.GetSize(); i++)
1321 if (fCLaddersOff.At(i) == ladder) return fCLaddersOff.At(i);
1325 if (fALaddersOff.GetSize()) {
1326 for(Int_t i = 0; i < fALaddersOff.GetSize(); i++)
1327 if (fALaddersOff.At(i) == ladder) return fALaddersOff.At(i);
1335 //______________________________________________________________________________
1336 ULong_t AliITSHandleDaSSD::OffsetValue(const AliITSChannelDaSSD *strip,
1337 const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1339 // Calculate the offset value to be upload to FEROM
1341 if (fOffsetDefault < INT_MAX) pedint = fOffsetDefault;
1342 else pedint = TMath::Nint(strip->GetPedestal());
1343 if (pedint > static_cast<Int_t>((fgkOffSetBitMask >> 1))) {
1344 if (!ChannelIsBad(ddl, ad, adc, strn) && !((fMergeBCLists) && (EvaluateIfChannelIsBad(GetModule(ddl, ad, adc), strn))))
1345 AliError(Form("Offset %i, channel(ddl/ad/adc/strip) %i/%i/%i/%i can not be represented with mask 0x%s, Offset = %i",
1346 pedint, ddl, ad, adc, strn, ConvBase(fgkOffSetBitMask, 16).c_str(), (fgkOffSetBitMask >> 1)));
1347 return (fgkOffSetBitMask >> 1);
1349 if ((-pedint) > static_cast<Int_t>(((fgkOffSetBitMask + 1) >> 1))) {
1350 if (!ChannelIsBad(ddl, ad, adc, strn) && !((fMergeBCLists) && (EvaluateIfChannelIsBad(GetModule(ddl, ad, adc), strn))))
1351 AliError(Form("Offset %i, channel(ddl/ad/adc/strip) %i/%i/%i/%i can not be represented with mask 0x%s, Offset = %i",
1352 pedint, ddl, ad, adc, strn, ConvBase(fgkOffSetBitMask, 16).c_str(),
1353 ((fgkOffSetBitMask & (~fgkOffSetBitMask >> 1)) - fgkOffSetBitMask - 1)));
1354 return fgkOffSetBitMask & (~fgkOffSetBitMask >> 1);
1356 return fgkOffSetBitMask & (pedint >= 0 ? pedint : pedint + fgkOffSetBitMask + 1);
1361 //______________________________________________________________________________
1362 ULong_t AliITSHandleDaSSD::OffsetValue(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1364 // Calculate the offset value to be upload to FEROM
1365 AliITSChannelDaSSD *strip = NULL;
1366 AliITSModuleDaSSD *module = NULL;
1367 if ((module = GetModule(ddl, ad, adc))) {
1368 if ((strip = module->GetStrip(strn))) return OffsetValue(strip, ddl, ad, adc, strn);
1370 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, strip = %i, 0 is used!", ddl, ad, adc, strn));
1374 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, 0 is used!", ddl, ad, adc));
1381 //______________________________________________________________________________
1382 ULong_t AliITSHandleDaSSD::ZsThreshold(const AliITSChannelDaSSD *strip) const
1384 // Calculate the value of zero suppression threshold to be upload to FEROM
1386 if (fZsDefault < 0) {
1387 zs = TMath::Nint(fZsFactor * strip->GetNoiseCM());
1388 if (zs < static_cast<ULong_t>(fZsMinimum)) zs = static_cast<ULong_t>(fZsMinimum);
1390 else zs = fZsDefault;
1391 return (zs < fgkZsBitMask) ? (zs & fgkZsBitMask) : fgkZsBitMask;
1395 //______________________________________________________________________________
1396 ULong_t AliITSHandleDaSSD::ZsThreshold(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1398 // Calculate the value of zero suppression threshold to be upload to FEROM, account bad channels list
1399 AliITSChannelDaSSD *strip = NULL;
1400 AliITSModuleDaSSD *module = NULL;
1401 if (ChannelIsBad(ddl, ad, adc, strn)) return fgkZsBitMask;
1402 if (LadderIsOff(ddl, ad, adc)) return fgkZsBitMask;
1403 if (fZsDefault > 0) if (static_cast<ULong_t>(fZsDefault) >= fgkZsBitMask) return fgkZsBitMask;
1404 if ((module = GetModule(ddl, ad, adc))) {
1405 if (fMergeBCLists) if (EvaluateIfChannelIsBad(module, strn)) return fgkZsBitMask;
1406 if ((strip = module->GetStrip(strn))) return ZsThreshold(strip);
1408 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, strip = %i, 0 is used!", ddl, ad, adc, strn));
1412 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, 0 is used!", ddl, ad, adc));
1418 //______________________________________________________________________________
1419 string AliITSHandleDaSSD::ConvBase(const unsigned long value, const long base) const
1421 // Converts the unsigned long number into that in another base
1422 string digits = "0123456789ABCDEF";
1424 unsigned long v = value;
1425 if((base < 2) || (base > 16)) {
1426 result = "Error: base out of range.";
1431 result = digits[v % base] + result;
1435 while((v) || (i<8));
1442 //______________________________________________________________________________
1443 Int_t AliITSHandleDaSSD::CheckOffChips() const
1445 // Check if the chip, module are off
1446 AliITSChannelDaSSD *strip;
1448 Int_t strnd, chipnd, modnd, stroff, chipoff, modoff;
1449 offthreshold = TMath::Nint(fZsMinimum/fZsFactor);
1451 for (Int_t mi = 0; mi < fNumberOfModules; mi++) {
1452 if (!fModules[mi]) { modnd++; continue; }
1453 if (fModules[mi]->GetModuleId() < 0) continue;
1454 if (LadderIsOff(fModules[mi]->GetDdlId(), fModules[mi]->GetAD(), fModules[mi]->GetADC()) ) continue;
1455 chipoff = chipnd = 0;
1456 for (Int_t chipind = 0; chipind < AliITSModuleDaSSD::GetChipsPerModuleConst(); chipind++) {
1458 Int_t stripind = chipind * AliITSModuleDaSSD::GetStripsPerChip();
1459 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
1460 if (!(strip = fModules[mi]->GetStrip(strind))) { strnd++; continue; }
1461 if (strip->GetNoiseCM() < offthreshold ) stroff++;
1463 if (strnd == AliITSModuleDaSSD::GetStripsPerChip()) chipnd++;
1464 else if (stroff == AliITSModuleDaSSD::GetStripsPerChip()) chipoff++;
1465 else if ((stroff + strnd) == AliITSModuleDaSSD::GetStripsPerChip()) chipoff++;
1467 if ((!chipoff) && (!chipnd)) continue;
1468 if (chipnd == AliITSModuleDaSSD::GetChipsPerModuleConst()) {
1469 AliInfo(Form("Module: (ddl/ad/adc) %i/%i/%i seems to be off and it is not on the ladders which are off!",
1470 fModules[mi]->GetDdlId(), fModules[mi]->GetAD(), fModules[mi]->GetADC()));
1473 if (chipoff == AliITSModuleDaSSD::GetChipsPerModuleConst()) {
1474 AliInfo(Form("Module (ddl/ad/adc): %i/%i/%i seems to be off and it is not on the ladders which are off!",
1475 fModules[mi]->GetDdlId(), fModules[mi]->GetAD(), fModules[mi]->GetADC()));
1478 else if ((chipoff + chipnd) == AliITSModuleDaSSD::GetChipsPerModuleConst()) {
1479 AliInfo(Form("Module: (ddl/ad/adc): %i/%i/%i seems to be off and it is not on the ladders which are off!",
1480 fModules[mi]->GetDdlId(), fModules[mi]->GetAD(), fModules[mi]->GetADC()));
1484 AliInfo(Form("Module: (ddl/ad/adc): %i/%i/%i has %i chips which are off!",
1485 fModules[mi]->GetDdlId(), fModules[mi]->GetAD(), fModules[mi]->GetADC(), chipoff));
1489 return (modoff + modnd);
1493 //______________________________________________________________________________
1494 Bool_t AliITSHandleDaSSD::CalculatePedNoiseW(const AliITSModuleDaSSD *const module)
1496 // Calculates Pedestal and Noise using Welford algorithm
1497 AliITSChannelDaSSD *strip;
1498 Double_t pedestal, noise, p0, s0;
1501 if (!module) return kFALSE;
1502 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
1503 if (!(strip = module->GetStrip(strind))) continue;
1504 if (!(signal = strip->GetSignal())) {
1505 AliError(Form("AliITSHandleDaSSD: Error CalculatePedestal(): there are no events data for module[%i] strip[%i]->GetSignal()",
1506 module->GetModuleId(), strind));
1509 //************* pedestal and noise first pass ****************
1510 pedestal = p0 = noise = 0.0L;
1512 for (Int_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
1513 if (SignalOutOfRange(signal[ev])) ovev += 1;
1516 pedestal = p0 = signal[ev];
1519 p0 = pedestal + (signal[ev] - pedestal) / static_cast<Double_t>(ev - ovev + 1);
1520 s0 = noise + (signal[ev] - pedestal) * (signal[ev] - p0);
1525 if (strip->GetEventsNumber() == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue();
1526 strip->SetPedestal(static_cast<Float_t>(pedestal));
1527 if ((n = strip->GetEventsNumber() - ovev - 1) > 0)
1528 strip->SetNoise( static_cast<Float_t>(sqrt(noise / static_cast<Double_t>(n))) );
1530 strip->SetNoise(AliITSChannelDaSSD::GetUndefinedValue());
1533 //************* Second pass excluds event with |p - s|>f*noise *****************
1534 pedestal = p0 = noise = 0.0L;
1536 for (Int_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
1537 if ( SignalOutOfRange(signal[ev])
1538 || TMath::Abs(signal[ev] - strip->GetPedestal()) > (fPedestalThresholdFactor * strip->GetNoise())) ovev += 1;
1541 pedestal = p0 = signal[ev];
1544 p0 = pedestal + (signal[ev] - pedestal) / static_cast<Double_t>(ev - ovev + 1);
1545 s0 = noise + (signal[ev] - pedestal) * (signal[ev] - p0);
1550 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(noise / static_cast<Double_t>(n));
1551 else noise = AliITSChannelDaSSD::GetUndefinedValue();
1552 strip->SetNoise(static_cast<Float_t>(noise));
1553 if (strip->GetEventsNumber() == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue();
1554 strip->SetPedestal(static_cast<Float_t>(pedestal));
1555 strip->SetOverflowNumber(ovev);
1561 //______________________________________________________________________________
1562 Bool_t AliITSHandleDaSSD::CalculateCMW(AliITSModuleDaSSD *const module)
1564 // Calculates CM using Welford algorithm
1565 AliITSChannelDaSSD *strip = NULL;
1569 Double_t cm0, cm1, cmsigma, cms1;
1570 module->SetNumberOfChips(AliITSModuleDaSSD::GetChipsPerModuleConst());
1571 for (Int_t chipind = 0; chipind < module->GetNumberOfChips(); chipind++) {
1572 stripind = chipind * module->GetStripsPerChip();
1573 module->GetCM()[chipind].Set(fNumberOfEvents);
1574 module->GetCM()[chipind].Reset(0.0f);
1575 for (Long_t ev = 0; ev < fNumberOfEvents; ev++) {
1576 // calculate firs approximation of CM and SigmaCM.
1577 cm0 = cm1 = cmsigma = 0.0L;
1579 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
1580 if (!(strip = module->GetStrip(strind))) { ovstr += 1; continue; } //return kFALSE;
1581 if (!(signal = strip->GetSignal())) { ovstr += 1; continue; } //return kFALSE;
1582 if ((SignalOutOfRange(signal[ev])) || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1;
1584 if (!(strind - stripind - ovstr)) {
1585 cm0 = cm1 = signal[ev] - strip->GetPedestal();
1588 cm1 = cm0 + (signal[ev] - strip->GetPedestal() - cm0) / static_cast<Double_t>(strind - stripind - ovstr + 1);
1589 cms1 = cmsigma + (signal[ev] - strip->GetPedestal() - cm0) * (signal[ev] - strip->GetPedestal() - cm1);
1594 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr - 1) > 0) cmsigma = sqrt(cmsigma / static_cast<Double_t>(n));
1596 AliWarning(Form("AliITSHandleDaSSD: Too little number of strips have a signal for module:chip:event : [%d]:[%d]:[%ld]\n",
1597 module->GetModuleId(), chipind, ev));
1598 if (!(module->SetCM(0.0f, chipind, ev)))
1599 AliError(Form("AliITSHandleDaSSD: Error, module->SetCM(...) returned kFALSE module:chip:event : [%d]:[%d]:[%ld]\n",
1600 module->GetModuleId(), chipind, ev));
1603 // calculate cm with threshold
1604 Double_t cmsum = 0.0L;
1606 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
1607 if (!(strip = module->GetStrip(strind))) { ovstr += 1; continue; }
1608 if (!(signal = strip->GetSignal())) { ovstr += 1; continue; }
1609 if ( (SignalOutOfRange(signal[ev])) || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())
1610 || (TMath::Abs(cm0 - (signal[ev] - strip->GetPedestal())) > (fCmThresholdFactor * cmsigma)) ) ovstr += 1;
1611 else cmsum += (signal[ev] - strip->GetPedestal());
1613 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsum /= (Double_t)(n);
1615 if (!(module->SetCM(static_cast<Float_t>(cmsum), chipind, ev)))
1616 AliError(Form("AliITSHandleDaSSD: Error, module->SetCM(...) returned kFALSE module:chip:event : [%d]:[%d]:[%ld]\n",
1617 module->GetModuleId(), chipind, ev));
1624 //______________________________________________________________________________
1625 Bool_t AliITSHandleDaSSD::CalculateNoiseCMW(AliITSModuleDaSSD *const module)
1627 // Calculates Noise with CM correction
1628 AliITSChannelDaSSD *strip = NULL;
1631 if (!CalculateCMW(module)) {
1632 AliError("Error: AliITSHandleDaSSD::CalculateCMW() returned kFALSE");
1635 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
1636 if (!(strip = module->GetStrip(strind))) continue; //return kFALSE;
1637 if (!(signal = strip->GetSignal())) {
1638 strip->SetNoiseCM(AliITSChannelDaSSD::GetUndefinedValue());
1639 AliError(Form("AliITSHandleDaSSD: Error CalculateNoiseCMW(): there are no events data for module[%i] strip[%i]->GetSignal()",
1640 module->GetModuleId(), strind));
1641 continue; //return kFALSE;
1643 //** To get exactly the same set of events as for pedestal and noise calculation **
1644 Double_t pedestal, noise, p0, s0;
1645 pedestal = p0 = noise = 0.0L;
1647 for (Int_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
1648 if (SignalOutOfRange(signal[ev])) ovev += 1;
1651 pedestal = p0 = signal[ev];
1654 p0 = pedestal + (signal[ev] - pedestal) / static_cast<Double_t>(ev - ovev + 1);
1655 s0 = noise + (signal[ev] - pedestal) * (signal[ev] - p0);
1660 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(noise / static_cast<Double_t>(n));
1662 strip->SetNoiseCM(AliITSChannelDaSSD::GetUndefinedValue());
1665 //** Calculation of CM corrected noise **
1666 Int_t chipind = strind / AliITSModuleDaSSD::GetStripsPerChip();
1667 Double_t nsum = 0.0L;
1669 for (Int_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
1670 if ( SignalOutOfRange(signal[ev])
1671 || TMath::Abs(signal[ev] - pedestal) > (fPedestalThresholdFactor * noise)) ovev += 1;
1672 else nsum += pow((signal[ev] - strip->GetPedestal() - module->GetCM(chipind, ev)), 2);
1674 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / static_cast<Double_t>(n));
1675 else noise = AliITSChannelDaSSD::GetUndefinedValue();
1676 strip->SetNoiseCM(static_cast<Float_t>(noise));
1683 //______________________________________________________________________________
1684 UChar_t AliITSHandleDaSSD::EvaluateIfChannelIsBad(const AliITSModuleDaSSD *const module, const Int_t stripn) const
1686 //Applies the bad channel creteria and set the appropriate flags for returned value
1687 AliITSChannelDaSSD *strip = 0;
1689 if (fZsDefault >= 0) { if (static_cast<ULong_t>(fZsDefault) >= fgkZsBitMask) bcflags |= 3; }
1690 else if (static_cast<ULong_t>(fZsMinimum) >= fgkZsBitMask) bcflags |= 3;
1691 if (LadderIsOff(module->GetDdlId(), module->GetAD(), module->GetADC()) ) bcflags |= 3;
1693 if (!(strip = module->GetStrip(stripn))) bcflags |= 3;
1695 if (strip->GetNoiseCM() == AliITSChannelDaSSD::GetUndefinedValue()) bcflags |= 8;
1696 if (static_cast<ULong_t>(TMath::Nint(fZsFactor * strip->GetNoiseCM())) >= fgkZsBitMask) bcflags |= 8;
1697 if (strip->GetNoiseCM() < 1) bcflags |= 16;
1698 if (strip->GetPedestal() > ((fgkOffSetBitMask >> 1) - 1)) bcflags |= 4;
1699 else if ((-(strip->GetPedestal())) > (fgkOffSetBitMask >> 1)) bcflags |= 4;
1700 if (bcflags) bcflags |= 3;