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 ///////////////////////////////////////////////////////////////////////////////
28 #include <Riostream.h>
29 #include "AliITSHandleDaSSD.h"
35 #include "TObjArray.h"
37 #include "AliITSNoiseSSD.h"
38 #include "AliITSPedestalSSD.h"
39 #include "AliITSBadChannelsSSD.h"
40 #include "AliITSRawStreamSSD.h"
41 #include "AliRawReaderDate.h"
42 #include "AliITSRawStreamSSD.h"
43 #include "AliITSChannelDaSSD.h"
46 ClassImp(AliITSHandleDaSSD)
51 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModules = 1698; // Number of SSD modules in ITS
52 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerDdl = 108; // Number of SSD modules in DDL
53 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerSlot = 12; // Number of SSD modules in Slot
54 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDSlotsPerDDL = 9; // Number of SSD slots per DDL
55 const Int_t AliITSHandleDaSSD::fgkNumberOfSSDDDLs = 16; // Number of SSD modules in Slot
56 const Float_t AliITSHandleDaSSD::fgkPedestalThresholdFactor = 3.0; // Defalt value for fPedestalThresholdFactor
57 const Float_t AliITSHandleDaSSD::fgkCmThresholdFactor = 3.0; // Defalt value for fCmThresholdFactor
59 const UInt_t AliITSHandleDaSSD::fgkZsBitMask = 0x0000003F; // Bit mask for FEROM ZS
60 const UInt_t AliITSHandleDaSSD::fgkOffSetBitMask = 0x000003FF; // Bit mask for FEROM Offset correction
61 const UInt_t AliITSHandleDaSSD::fgkBadChannelMask = 0x00000001; // Mask to suppress the channel from the bad channel list
62 const Int_t AliITSHandleDaSSD::fgkAdcPerDBlock = 6; // FEROM configuration file constant
64 //______________________________________________________________________________
65 AliITSHandleDaSSD::AliITSHandleDaSSD() :
66 fRawDataFileName(NULL),
73 fStaticBadChannelsMap(NULL),
77 fPedestalThresholdFactor(fgkPedestalThresholdFactor),
78 fCmThresholdFactor(fgkCmThresholdFactor),
80 fOffsetDefault(INT_MAX),
83 // Default constructor
87 //______________________________________________________________________________
88 AliITSHandleDaSSD::AliITSHandleDaSSD(Char_t *rdfname) :
89 fRawDataFileName(NULL),
96 fStaticBadChannelsMap(NULL),
100 fPedestalThresholdFactor(fgkPedestalThresholdFactor) ,
101 fCmThresholdFactor(fgkCmThresholdFactor),
103 fOffsetDefault(INT_MAX),
106 if (!Init(rdfname)) AliError("AliITSHandleDaSSD::AliITSHandleDaSSD() initialization error!");
110 //______________________________________________________________________________
111 AliITSHandleDaSSD::AliITSHandleDaSSD(const AliITSHandleDaSSD& ssdadldc) :
113 fRawDataFileName(ssdadldc.fRawDataFileName),
114 fNumberOfModules(ssdadldc.fNumberOfModules),
116 fModIndProcessed(ssdadldc.fModIndProcessed),
117 fModIndRead(ssdadldc.fModIndRead),
119 fNumberOfEvents(ssdadldc.fNumberOfEvents),
120 fStaticBadChannelsMap(ssdadldc.fStaticBadChannelsMap),
121 fDDLModuleMap(ssdadldc.fDDLModuleMap),
122 fLdcId(ssdadldc.fLdcId),
123 fRunId(ssdadldc.fRunId),
124 fPedestalThresholdFactor(ssdadldc.fPedestalThresholdFactor),
125 fCmThresholdFactor(ssdadldc.fCmThresholdFactor),
126 fZsDefault(ssdadldc.fZsDefault),
127 fOffsetDefault(ssdadldc.fOffsetDefault),
128 fZsFactor(ssdadldc.fZsFactor)
131 if ((ssdadldc.fNumberOfModules > 0) && (ssdadldc.fModules)) {
132 fModules = new (nothrow) AliITSModuleDaSSD* [ssdadldc.fNumberOfModules];
134 for (Int_t modind = 0; modind < ssdadldc.fNumberOfModules; modind++) {
135 if (ssdadldc.fModules[modind]) {
136 fModules[modind] = new AliITSModuleDaSSD(*(ssdadldc.fModules[modind]));
137 if (!fModules[modind]) {
138 AliError("AliITSHandleDaSSD: Error copy constructor");
139 for (Int_t i = (modind - 1); i >= 0; i--) delete fModules[modind];
144 } else fModules[modind] = NULL;
147 AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", ssdadldc.fNumberOfModules));
148 fNumberOfModules = 0;
155 //______________________________________________________________________________
156 AliITSHandleDaSSD& AliITSHandleDaSSD::operator = (const AliITSHandleDaSSD& ssdadldc)
158 // assignment operator
159 if (this == &ssdadldc) return *this;
161 for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i];
165 if (fModIndex) { delete [] fModIndex; fModIndex = NULL; }
166 if ((ssdadldc.fNumberOfModules > 0) && (ssdadldc.fModules)) {
167 fModules = new (nothrow) AliITSModuleDaSSD* [ssdadldc.fNumberOfModules];
169 for (Int_t modind = 0; modind < ssdadldc.fNumberOfModules; modind++) {
170 if (ssdadldc.fModules[modind]) {
171 fModules[modind] = new AliITSModuleDaSSD(*(ssdadldc.fModules[modind]));
172 if (!fModules[modind]) {
173 AliError("AliITSHandleDaSSD: Error assignment operator");
174 for (Int_t i = (modind - 1); i >= 0; i--) delete fModules[modind];
179 } else fModules[modind] = NULL;
182 AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", ssdadldc.fNumberOfModules));
183 fNumberOfModules = 0;
191 //______________________________________________________________________________
192 AliITSHandleDaSSD::~AliITSHandleDaSSD()
194 // Default destructor
197 for (Int_t i = 0; i < fNumberOfModules; i++)
199 if (fModules[i]) delete fModules[i];
203 if (fModIndex) delete [] fModIndex;
204 if (fStaticBadChannelsMap) { fStaticBadChannelsMap->Delete(); delete fStaticBadChannelsMap; }
205 if (fDDLModuleMap) delete [] fDDLModuleMap;
210 //______________________________________________________________________________
211 void AliITSHandleDaSSD::Reset()
213 // Delete array of AliITSModuleDaSSD* objects.
215 for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i];
219 if (fModIndex) { delete [] fModIndex; fModIndex = NULL; }
221 if (fStaticBadChannelsMap) {
222 fStaticBadChannelsMap->Delete();
223 delete fStaticBadChannelsMap;
224 fStaticBadChannelsMap = NULL;
226 if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL; }
228 fRawDataFileName = NULL;
229 fModIndProcessed = fModIndRead = 0;
232 fPedestalThresholdFactor = fgkPedestalThresholdFactor;
233 fCmThresholdFactor = fgkCmThresholdFactor;
238 //______________________________________________________________________________
239 Bool_t AliITSHandleDaSSD::Init(Char_t *rdfname)
241 // Read raw data file and set initial and configuration parameters
242 Long_t physeventind = 0, strn = 0, nofstripsev, nofstrips = 0;
243 Int_t nofeqipmentev, nofeqipment = 0, eqn = 0;
244 AliRawReaderDate *rawreaderdate = NULL;
245 UChar_t *data = NULL;
246 Long_t datasize = 0, eqbelsize = 1;
248 rawreaderdate = new AliRawReaderDate(rdfname, 0);
249 if (!(rawreaderdate->GetAttributes() || rawreaderdate->GetEventId())) {
250 AliError(Form("AliITSHandleDaSSD: Error reading raw data file %s by RawReaderDate", rdfname));
254 if (rawreaderdate->NextEvent()) {
255 fRunId = rawreaderdate->GetRunNumber();
256 rawreaderdate->RewindEvents();
257 } else { MakeZombie(); return kFALSE; }
258 if (fModules) Reset();
259 rawreaderdate->Select("ITSSSD");
261 while (rawreaderdate->NextEvent()) {
262 if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue;
265 while (rawreaderdate->ReadNextData(data)) {
266 fLdcId = rawreaderdate->GetLDCId();
268 datasize = rawreaderdate->GetDataSize();
269 eqbelsize = rawreaderdate->GetEquipmentElementSize();
270 if ( datasize % eqbelsize ) {
271 AliError(Form("AliITSHandleDaSSD: Error Init(%s): event data size %i is not an integer of equipment data size %i",
272 rdfname, datasize, eqbelsize));
276 nofstripsev += (Int_t) (datasize / eqbelsize);
278 if (physeventind++) {
279 if (nofstrips != nofstripsev) AliWarning(Form("AliITSHandleDaSSD: number of strips varies from event to event, ev = %i, %i",
280 physeventind, nofstripsev));
281 if (nofeqipment != nofeqipmentev) AliWarning("AliITSHandleDaSSD: number of DDLs varies from event to event");
283 nofstrips = nofstripsev;
284 nofeqipment = nofeqipmentev;
285 if (strn < nofstrips) strn = nofstrips;
286 if (eqn < nofeqipment) eqn = nofeqipment;
288 delete rawreaderdate;
289 if ((physeventind > 0) && (strn > 0))
291 fNumberOfEvents = physeventind;
292 fRawDataFileName = rdfname;
293 fModIndex = new (nothrow) Int_t [fgkNumberOfSSDModulesPerDdl * eqn];
295 for (Int_t i = 0; i < fgkNumberOfSSDModulesPerDdl * eqn; i++) fModIndex[i] = -1;
296 else AliWarning(Form("AliITSHandleDaSSD: Error Init(%s): Index array for %i modules was not created",
297 rdfname, fgkNumberOfSSDModulesPerDdl * eqn));
298 if (SetNumberOfModules(fgkNumberOfSSDModulesPerDdl * eqn)) {
299 TString str = TString::Format("Max number of equipment: %i, max number of channels: %i\n", eqn, strn);
300 DumpInitData(str.Data());
310 //______________________________________________________________________________
311 AliITSModuleDaSSD* AliITSHandleDaSSD::GetModule (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
313 // Retrieve AliITSModuleDaSSD object from the array
314 if (!fModules) return NULL;
315 for (Int_t i = 0; i < fNumberOfModules; i++) {
317 if ( (fModules[i]->GetDdlId() == ddlID)
318 && (fModules[i]->GetAD() == ad)
319 && (fModules[i]->GetADC() == adc))
327 Int_t AliITSHandleDaSSD::GetModuleIndex (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
329 // Retrieve the position of AliITSModuleDaSSD object in the array
330 if (!fModules) return -1;
331 for (Int_t i = 0; i < fNumberOfModules; i++) {
333 if ( (fModules[i]->GetDdlId() == ddlID)
334 && (fModules[i]->GetAD() == ad)
335 && (fModules[i]->GetADC() == adc))
344 //______________________________________________________________________________
345 AliITSChannelDaSSD* AliITSHandleDaSSD::GetStrip (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t stripID) const
347 // Retrieve AliITSChannalDaSSD object from the array
348 for (Int_t modind = 0; modind < fNumberOfModules; modind++) {
349 if ( (fModules[modind]->GetDdlId() == ddlID)
350 && (fModules[modind]->GetAD() == ad)
351 && (fModules[modind]->GetADC() == adc) )
353 return fModules[modind]->GetStrip(stripID);
356 AliError(Form("AliITSHandleDaSSD: Error GetStrip (%i, %i, %i, %i), strip not found, returns NULL!",
357 ddlID, ad, adc, stripID));
363 //______________________________________________________________________________
364 Bool_t AliITSHandleDaSSD::SetModule(AliITSModuleDaSSD *const module, const Int_t index)
366 // Assign array element with AliITSModuleDaSSD object
367 if ((index < fNumberOfModules) && (index >= 0))
369 if (fModules[index]) delete fModules[index];
370 fModules[index] = module;
378 //______________________________________________________________________________
379 Bool_t AliITSHandleDaSSD::SetNumberOfModules (const Int_t numberofmodules)
381 // Allocates memory for AliITSModuleDaSSD objects
382 if (numberofmodules > fgkNumberOfSSDModules)
383 AliWarning(Form("AliITSHandleDaSSD: the number of modules %i you use exceeds the maximum %i for ALICE ITS SSD",
384 numberofmodules, fgkNumberOfSSDModules));
386 for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) delete fModules[i];
390 fModules = new (nothrow) AliITSModuleDaSSD* [numberofmodules];
392 fNumberOfModules = numberofmodules;
393 memset(fModules, 0, sizeof(AliITSModuleDaSSD*) * numberofmodules);
396 AliError(Form("AliITSHandleDaSSD: Error allocating memory for %i AliITSModulesDaSSD* objects!", numberofmodules));
397 fNumberOfModules = 0;
405 //______________________________________________________________________________
406 Bool_t AliITSHandleDaSSD::ReadStaticBadChannelsMap(const Char_t *filename)
408 // Reads Static Bad Channels Map from the file
411 AliWarning("No file name is specified for Static Bad Channels Map!");
414 bcfile = new TFile(filename, "READ");
415 if (bcfile->IsZombie()) {
416 AliWarning(Form("Error reading file %s with Static Bad Channels Map!", filename));
419 bcfile->GetObject("BadChannels;1", fStaticBadChannelsMap);
420 if (!fStaticBadChannelsMap) {
421 AliWarning("Error fStaticBadChannelsMap == NULL!");
433 Bool_t AliITSHandleDaSSD::ReadDDLModuleMap(const Char_t *filename)
435 // Reads the SSD DDL Map from the file
437 AliRawReaderDate *rwr = NULL;
438 AliITSRawStreamSSD *rsm = NULL;
440 if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL;}
441 fDDLModuleMap = new (nothrow) Int_t [fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl];
442 if (!fDDLModuleMap) {
443 AliWarning("Error allocation memory for DDL Map!");
447 AliWarning("No file name is specified for SSD DDL Map, using the one from AliITSRawStreamSSD!");
448 rwr = new AliRawReaderDate(event);
449 rsm = new AliITSRawStreamSSD(rwr);
450 rsm->Setv11HybridDDLMapping();
451 for (Int_t ddli = 0; ddli < fgkNumberOfSSDDDLs; ddli++)
452 for (Int_t mi = 0; mi < fgkNumberOfSSDModulesPerDdl; mi++)
453 fDDLModuleMap[(ddli * fgkNumberOfSSDModulesPerDdl + mi)] = rsm->GetModuleNumber(ddli, mi);
458 ddlmfile.open(filename, ios::in);
459 if (!ddlmfile.is_open()) {
460 AliWarning(Form("Error reading file %s with SSD DDL Map!", filename));
461 if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL;}
465 while((!ddlmfile.eof()) && (ind < (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl))) {
466 ddlmfile >> fDDLModuleMap[ind++];
467 if (ddlmfile.fail()) AliError(Form("Error extracting number from the DDL map file %s, ind: ", filename, ind));
469 if (ind != (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl))
470 AliWarning(Form("Only %i (< %i) entries were read from DDL Map!", ind, (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl)));
477 //______________________________________________________________________________
478 Int_t AliITSHandleDaSSD::ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber)
480 // Reads raw data from file
481 if (!Init(fileName)){
482 AliError("AliITSHandleDaSSD: Error ReadCalibrationDataFile");
485 fNumberOfEvents = eventsnumber;
486 return ReadModuleRawData (fNumberOfModules);
491 //______________________________________________________________________________
492 Int_t AliITSHandleDaSSD::ReadModuleRawData (const Int_t modulesnumber)
494 // Reads raw data from file
495 AliRawReader *rawreaderdate = NULL;
496 AliITSRawStreamSSD *stream = NULL;
497 AliITSModuleDaSSD *module;
498 AliITSChannelDaSSD *strip;
500 Int_t nofeqipmentev, equipid, prequipid;
502 if (!(rawreaderdate = new AliRawReaderDate(fRawDataFileName, 0))) return 0;
504 AliError("AliITSHandleDaSSD: Error ReadModuleRawData: no structure was allocated for data");
507 if (!fDDLModuleMap) if (!ReadDDLModuleMap()) AliWarning("DDL map is not defined, ModuleID will be set to 0!");
508 stream = new AliITSRawStreamSSD(rawreaderdate);
509 stream->Setv11HybridDDLMapping();
511 while (rawreaderdate->NextEvent()) {
512 if ((rawreaderdate->GetType() != PHYSICS_EVENT) && (rawreaderdate->GetType() != CALIBRATION_EVENT)) continue;
515 while (stream->Next()) {
516 equipid = rawreaderdate->GetEquipmentId();
517 if ((equipid != prequipid) && (prequipid >= 0)) nofeqipmentev += 1;
519 Int_t equiptype = rawreaderdate->GetEquipmentType();
520 UChar_t ddlID = (UChar_t)rawreaderdate->GetDDLID();
521 UChar_t ad = stream->GetAD();
522 UChar_t adc = stream->GetADC();
523 UShort_t stripID = stream->GetSideFlag() ? AliITSChannelDaSSD::GetMaxStripIdConst() - stream->GetStrip() : stream->GetStrip();
524 Short_t signal = stream->GetSignal();
526 Int_t indpos = (nofeqipmentev * fgkNumberOfSSDModulesPerDdl)
527 + ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2));
528 Int_t modpos = fModIndex[indpos];
529 if (((modpos > 0) && (modpos < fModIndRead)) || ((modpos < 0) && (modind == modulesnumber))) continue;
530 if ((modpos < 0) && (modind < modulesnumber)) {
531 module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst());
533 if (fDDLModuleMap) mddli = RetrieveModuleId(ddlID, ad, adc);
535 if (!module->SetModuleIdData (ddlID, ad, adc, mddli)) return 0;
536 module->SetModuleRorcId (equipid, equiptype);
537 module->SetCMFeromEventsNumber(fNumberOfEvents);
538 modpos = fModIndRead + modind;
540 fModules[modpos] = module;
541 fModIndex[indpos] = modpos;
543 if (stripID < AliITSModuleDaSSD::GetStripsPerModuleConst()) {
544 if (!(strip = fModules[modpos]->GetStrip(stripID))) {
545 strip = new AliITSChannelDaSSD(stripID, fNumberOfEvents);
546 fModules[modpos]->SetStrip(strip, stripID);
548 strip->SetSignal(eventind, signal);
549 } else fModules[modpos]->SetCMFerom(signal, (stripID - AliITSModuleDaSSD::GetStripsPerModuleConst()), eventind);
551 if (++eventind > fNumberOfEvents) break;
554 delete rawreaderdate;
555 if (modind) cout << "The memory was allocated for " << modind << " modules." << endl;
556 fModIndRead += modind;
557 if (modind < modulesnumber) RelocateModules();
563 //______________________________________________________________________________
564 Bool_t AliITSHandleDaSSD::RelocateModules()
566 // Relocate memory for AliITSModuleDaSSD object array
568 AliITSModuleDaSSD **marray = NULL;
569 for (Int_t modind = 0; modind < fNumberOfModules; modind++)
570 if (fModules[modind]) nm += 1;
571 if (nm == fNumberOfModules) return kTRUE;
572 marray = new (nothrow) AliITSModuleDaSSD* [nm];
574 AliError(Form("AliITSHandleDaSSD: Error relocating memory for %i AliITSModuleDaSSD* objects!", nm));
578 for (Int_t modind = 0; modind < fNumberOfModules; modind++)
579 if (fModules[modind]) marray[nm++] = fModules[modind];
582 fNumberOfModules = fModIndRead = nm;
588 //______________________________________________________________________________
589 Bool_t AliITSHandleDaSSD::AddFeromCm(AliITSModuleDaSSD *const module)
590 // Restore the original signal value adding CM calculated and subtracted in ferom
592 AliITSChannelDaSSD *strip;
593 Short_t *signal, *cmferom;
595 if (!module) return kFALSE;
596 for (Int_t chipind = 0; chipind < AliITSModuleDaSSD::GetChipsPerModuleConst(); chipind++) {
597 if (!(cmferom = module->GetCMFerom(chipind))) {
598 AliWarning(Form("AliITSHandleDaSSD: There is no Ferom CM values for chip %i, module %i!", chipind, module->GetModuleId()));
601 for (Int_t strind = (chipind * AliITSModuleDaSSD::GetStripsPerChip());
602 strind < ((chipind + 1) * AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
603 if (!(strip = module->GetStrip(strind))) continue;
604 if (!(signal = strip->GetSignal())) continue;
605 // if (strip->GetEventsNumber() != module->GetEventsNumber()) return kFALSE;
607 for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
608 if (SignalOutOfRange(signal[ev]) || SignalOutOfRange(cmferom[ev])) ovev += 1;
610 Short_t signal1 = signal[ev] + cmferom[ev];
611 strip->SetSignal(ev, signal1);
621 //______________________________________________________________________________
622 Bool_t AliITSHandleDaSSD::CalculatePedestal(AliITSModuleDaSSD *const module)
624 // Calculates Pedestal
625 AliITSChannelDaSSD *strip;
626 Float_t pedestal, noise;
629 if (!module) return kFALSE;
630 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
631 if (!(strip = module->GetStrip(strind))) continue;
632 if (!(signal = strip->GetSignal())) {
633 AliError(Form("AliITSHandleDaSSD: Error CalculatePedestal(): there are no events data for module[%i] strip[%i]->GetSignal()",
634 module->GetModuleId(), strind));
637 //************* pedestal first pass ****************
640 for (ev = 0; ev < strip->GetEventsNumber(); ev++)
641 if (SignalOutOfRange(signal[ev])) ovev += 1;
642 else pedestal = ((ev - ovev)) ? pedestal + (signal[ev] - pedestal) / static_cast<Float_t>(ev - ovev + 1) : signal[ev];
643 if (ev == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue();
644 strip->SetPedestal(pedestal);
645 //************* noise *******************************
646 Double_t nsum = 0.0L;
648 for (ev = 0; ev < strip->GetEventsNumber(); ev++) {
649 if (SignalOutOfRange(signal[ev])) ovev += 1;
650 else nsum += pow((signal[ev] - strip->GetPedestal()), 2);
652 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Float_t)(n));
653 else noise = AliITSChannelDaSSD::GetUndefinedValue();
654 strip->SetNoise(noise);
655 //************* pedestal second pass ****************
658 for (ev = 0; ev < strip->GetEventsNumber(); ev++)
659 if ( SignalOutOfRange(signal[ev])
660 || TMath::Abs(signal[ev] - strip->GetPedestal()) > (fPedestalThresholdFactor * strip->GetNoise())) ovev += 1;
661 else pedestal = ((ev - ovev)) ? pedestal + (signal[ev] - pedestal) / static_cast<Float_t>(ev - ovev + 1) : signal[ev];
662 if (ev == ovev) pedestal = AliITSChannelDaSSD::GetUndefinedValue();
663 strip->SetPedestal(pedestal);
664 strip->SetOverflowNumber(ovev);
670 //______________________________________________________________________________
671 Bool_t AliITSHandleDaSSD::CalculateNoise(AliITSModuleDaSSD *const module)
674 AliITSChannelDaSSD *strip;
678 if (!module) return kFALSE;
679 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
680 if (!(strip = module->GetStrip(strind))) continue;
681 if (!(signal = strip->GetSignal())) {
682 strip->SetNoise(AliITSChannelDaSSD::GetUndefinedValue());
683 AliError(Form("AliITSHandleDaSSD: Error CalculateNoise(): there are no events data for module[%i] strip[%i]->GetSignal()",
684 module->GetModuleId(), strind));
687 Double_t nsum = 0.0L;
689 for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
690 if (SignalOutOfRange(signal[ev])) ovev += 1;
691 else nsum += pow((signal[ev] - strip->GetPedestal()), 2);
693 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Float_t)(n));
694 else noise = AliITSChannelDaSSD::GetUndefinedValue();
695 strip->SetNoise(noise);
702 //______________________________________________________________________________
703 Bool_t AliITSHandleDaSSD::CalculateNoiseCM(AliITSModuleDaSSD *const module)
705 // Calculates Noise with CM correction
706 AliITSChannelDaSSD *strip = NULL;
710 if (!CalculateCM(module)) {
711 AliError("Error: AliITSHandleDaSSD::CalculateCM() returned kFALSE");
714 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
715 if (!(strip = module->GetStrip(strind))) continue; //return kFALSE;
716 if (!(signal = strip->GetSignal())) {
717 strip->SetNoiseCM(AliITSChannelDaSSD::GetUndefinedValue());
718 AliError(Form("SSDDAModule: Error CalculateNoiseWithoutCM(): there are no events data for module[%i] strip[%i]->GetSignal()",
719 module->GetModuleId(), strind));
720 continue; //return kFALSE;
722 Int_t chipind = strind / AliITSModuleDaSSD::GetStripsPerChip();
723 Double_t nsum = 0.0L;
725 for (Long_t ev = 0; ev < strip->GetEventsNumber(); ev++) {
726 if (SignalOutOfRange(signal[ev])) ovev += 1;
727 else nsum += pow((signal[ev] - strip->GetPedestal() - module->GetCM(chipind, ev)), 2);
729 if ((n = strip->GetEventsNumber() - ovev - 1) > 0) noise = sqrt(nsum / (Float_t)(n));
730 else noise = AliITSChannelDaSSD::GetUndefinedValue();
731 strip->SetNoiseCM(noise);
738 //______________________________________________________________________________
739 Bool_t AliITSHandleDaSSD::CalculateCM(AliITSModuleDaSSD *const module)
742 AliITSChannelDaSSD *strip = NULL;
746 module->SetNumberOfChips(AliITSModuleDaSSD::GetChipsPerModuleConst());
747 for (Int_t chipind = 0; chipind < module->GetNumberOfChips(); chipind++) {
748 stripind = chipind * module->GetStripsPerChip();
749 module->GetCM()[chipind].Set(fNumberOfEvents);
750 module->GetCM()[chipind].Reset(0.0f);
751 for (Long_t ev = 0; ev < fNumberOfEvents; ev++) {
752 // calculate firs approximation of CM.
755 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
756 if (!(strip = module->GetStrip(strind))) continue; //return kFALSE;
757 if (!(signal = strip->GetSignal())) {
758 AliError(Form("AliITSHandleDaSSD: Error CalculateCM: there are no events data for module[%i] strip[%i]->GetSignal()",
759 module->GetModuleId(), strind));
762 if ((signal[ev] >= AliITSChannelDaSSD::GetOverflowConst()) ||
763 (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1;
764 else cm0 += (signal[ev] - strip->GetPedestal());
766 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cm0 /= (Float_t)(n);
767 else { module->SetCM(0.0f, chipind, ev); continue; }
768 // calculate avarage (cm - (signal - pedestal)) over the chip
769 Double_t cmsigma = 0.0L;
771 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
772 if (!(strip = module->GetStrip(strind))) continue;
773 if (!(signal = strip->GetSignal())) {
774 AliError(Form("AliITSHandleDaSSD: Error CalculateCM: there are no events data for module[%i] strip[%i]->GetSignal()\n",
775 module->GetModuleId(), strind));
778 if ((signal[ev] >= AliITSChannelDaSSD::GetOverflowConst()) ||
779 (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())) ovstr += 1;
780 else cmsigma += pow((cm0 - (signal[ev] - strip->GetPedestal())), 2);
782 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsigma = sqrt(cmsigma / (Float_t)(n));
783 else { module->SetCM(0.0f, chipind, ev); continue; }
784 // calculate cm with threshold
785 Double_t cmsum = 0.0L;
787 for (Int_t strind = stripind; strind < (stripind + AliITSModuleDaSSD::GetStripsPerChip()); strind++) {
788 if (!(strip = module->GetStrip(strind))) continue;
789 signal = strip->GetSignal();
790 if ( (signal[ev] >= AliITSChannelDaSSD::GetOverflowConst())
791 || (strip->GetPedestal() == AliITSChannelDaSSD::GetUndefinedValue())
792 || (TMath::Abs(cm0 - (signal[ev] - strip->GetPedestal())) > (fCmThresholdFactor * cmsigma)) ) ovstr += 1;
793 else cmsum += (signal[ev] - strip->GetPedestal());
795 if ((n = AliITSModuleDaSSD::GetStripsPerChip() - ovstr)) cmsum /= (Float_t)(n);
797 if (!module->SetCM(cmsum, chipind, ev));
804 //______________________________________________________________________________
805 Bool_t AliITSHandleDaSSD::ProcessRawData(const Int_t nmread)
807 // Performs calculation of calibration parameters (pedestal, noise, ...)
809 if (nmread <= 0) return kFALSE;
810 if (!fModules) return kFALSE;
811 while ((nm = ReadModuleRawData(nmread)) > 0) {
812 cout << "Processing next " << nm << " modules;" << endl;
813 for (Int_t modind = fModIndProcessed; modind < fModIndRead; modind++) {
814 if (!fModules[modind]) {
815 AliError(Form("AliITSHandleDaSSD: Error ProcessRawData(): No AliITSModuleDaSSD object with index %i is allocated in AliITSHandleDaSSD\n",
819 AddFeromCm(fModules[modind]);
820 CalculatePedestal(fModules[modind]);
821 CalculateNoise(fModules[modind]);
822 CalculateNoiseCM(fModules[modind]);
827 fModIndProcessed = fModIndRead;
828 cout << fModIndProcessed << " - done" << endl;
834 //______________________________________________________________________________
835 Short_t AliITSHandleDaSSD::RetrieveModuleId(const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
837 // Retrieve ModuleId from the DDL map which is defined in AliITSRawStreamSSD class
838 if (!fDDLModuleMap) return 0;
839 Int_t mddli = ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2));
840 if ((ddlID < fgkNumberOfSSDDDLs) && (mddli < fgkNumberOfSSDModulesPerDdl)) {
841 mddli = fDDLModuleMap[ddlID * fgkNumberOfSSDModulesPerDdl + mddli];
844 AliWarning(Form("Module index = %d or ddlID = %d is out of range 0 is rturned", ddlID, mddli));
847 if (mddli > SHRT_MAX) return SHRT_MAX;
848 else return (Short_t)mddli;
853 //______________________________________________________________________________
854 TObjArray* AliITSHandleDaSSD::GetCalibrationSSDLDC() const
856 // Fill in the array for OCDB
858 TObject *modcalibobj;
859 if (!fModules) return NULL;
860 ldcc = new TObjArray(fNumberOfModules, 0);
861 for (Int_t i = 0; i < fNumberOfModules; i++) {
866 modcalibobj = dynamic_cast<TObject*>(fModules[i]->GetCalibrationNoise());
867 ldcc->AddAt(modcalibobj, i);
874 //______________________________________________________________________________
875 Bool_t AliITSHandleDaSSD::SaveCalibrationSSDLDC(Char_t*& dafname) const
877 // Save Calibration data locally
878 TObjArray *ldcn, *ldcp, *ldcbc;
879 TObject *modobjn, *modobjp, *modobjbc;
881 TString dadatafilename("");
882 if (!fModules) return kFALSE;
883 ldcn = new TObjArray(fNumberOfModules, 0);
884 ldcn->SetName("Noise");
885 ldcp = new TObjArray(fNumberOfModules, 0);
886 ldcp->SetName("Pedestal");
887 ldcbc = new TObjArray(fNumberOfModules, 0);
888 ldcbc->SetName("BadChannels");
889 for (Int_t i = 0; i < fNumberOfModules; i++) {
894 modobjn = dynamic_cast<TObject*>(fModules[i]->GetCalibrationNoise());
895 modobjp = dynamic_cast<TObject*>(fModules[i]->GetCalibrationPedestal());
896 modobjbc = dynamic_cast<TObject*>(fModules[i]->GetCalibrationBadChannels());
897 ldcn->AddAt(modobjn, i);
898 ldcp->AddAt(modobjp, i);
899 ldcbc->AddAt(modobjbc, i);
904 if (dafname) dadatafilename.Form("%s/", dafname);
905 dadatafilename += TString::Format("ITSSSDda_%i.root", fLdcId);
906 tmpfname = new Char_t[dadatafilename.Length()+1];
907 dafname = strcpy(tmpfname, dadatafilename.Data());
908 TFile *fileRun = new TFile (dadatafilename.Data(),"RECREATE");
909 if (fileRun->IsZombie()) {
910 AliError(Form("AliITSHandleDaSSD: SaveCalibrationSSDLDC() error open file %s", dadatafilename.Data()));
918 fileRun->WriteTObject(ldcn);
919 fileRun->WriteTObject(ldcp);
920 if (fStaticBadChannelsMap) fileRun->WriteTObject(fStaticBadChannelsMap);
921 else fileRun->WriteTObject(ldcbc);
933 //______________________________________________________________________________
934 Bool_t AliITSHandleDaSSD::DumpModInfo(const Float_t meannosethreshold) const
936 // Dump calibration parameters
937 AliITSModuleDaSSD *mod;
938 AliITSChannelDaSSD *strip;
940 cout << "SSDDALDC::DumpModInfo(): Error, no modules are allocated!" << endl;
943 cout << "Modules with MeanNoise > " << meannosethreshold << endl;
944 for (Int_t i = 0; i < fNumberOfModules; i++) {
945 if (!(mod = fModules[i])) continue;
946 Float_t maxnoise = 0.0f, meannoise = 0.0f, maxped = 0.0f;
947 Int_t maxstrind = 0, novfstr = 0;
948 for (Int_t strind = 0; strind < mod->GetNumberOfStrips(); strind++) {
949 if (!(strip = mod->GetStrip(strind))) {novfstr++; continue; }
950 if (strip->GetNoiseCM() >= AliITSChannelDaSSD::GetUndefinedValue() ) {novfstr++; continue; }
951 if (maxnoise < strip->GetNoiseCM()) {
952 maxnoise = strip->GetNoiseCM();
955 meannoise = (strind - novfstr) ? meannoise + (strip->GetNoiseCM() - meannoise) / static_cast<Float_t>(strind - novfstr + 1)
956 : strip->GetNoiseCM();
957 if (TMath::Abs(maxped) < TMath::Abs(strip->GetPedestal())) maxped = strip->GetPedestal();
959 if (meannoise > meannosethreshold)
960 cout << "Mod: " << i << "; DDl: " << (int)mod->GetDdlId() << "; AD: " << (int)mod->GetAD()
961 << "; ADC: " << (int)mod->GetADC() << "; MaxPed = " << maxped
962 << "; MeanNoise = " << meannoise
963 << "; NOfStrips = " << (mod->GetNumberOfStrips() - novfstr) << endl;
970 //______________________________________________________________________________
971 Bool_t AliITSHandleDaSSD::PrintModCalibrationData(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Char_t *fname) const
973 // Print Module calibration data whether in file on in cout
974 AliITSChannelDaSSD *strip;
977 if (!fname) { outputfile = &cout; }
979 datafile.open(fname, ios::out);
980 if (datafile.fail()) return kFALSE;
981 outputfile = dynamic_cast<ostream*>(&datafile);
983 *outputfile << "DDL = " << (int)ddlID << "; AD = " << (int)ad << "; ADC = " << (int)adc << endl;
984 for (Int_t strind = 0; strind < AliITSModuleDaSSD::GetStripsPerModuleConst(); strind++) {
985 if ( (strip = GetStrip(ddlID, ad, adc, strind)) ) {
986 *outputfile << "Str = " << strind << "; ped = " << strip->GetPedestal()
987 << "; noise = " << strip->GetNoiseCM() << endl;
991 if (datafile.is_open()) datafile.close();
997 //______________________________________________________________________________
998 void AliITSHandleDaSSD::DumpInitData(const Char_t *str) const
1000 // Print general information retrieved from raw data file
1001 cout << "Raw data file: " << fRawDataFileName << endl
1002 << "LDC: " << (Int_t)fLdcId << "; RunId: " << fRunId << endl
1003 << "Number of physics events: " << fNumberOfEvents << endl
1008 //______________________________________________________________________________
1009 Bool_t AliITSHandleDaSSD::AllocateSimulatedModules(const Int_t copymodind)
1011 // Used to allocate simulated modules to test the performance
1012 AliITSModuleDaSSD *module;
1013 UChar_t ad, adc, ddlID;
1014 ad = adc = ddlID = 0;
1015 if (!(fModules[copymodind])) return kFALSE;
1016 for (Int_t modind = 0; modind < fNumberOfModules; modind++) {
1017 if (!fModules[modind]) {
1018 module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst());
1019 if ((adc < 5) || ((adc > 7) && (adc < 13)) ) adc += 1;
1020 else if (adc == 5) adc = 8;
1021 else if (adc == 13) {
1023 if (ad < 8) ad += 1;
1029 if (!module->SetModuleIdData (ddlID, ad, adc, modind)) return kFALSE;
1030 fModules[modind] = module;
1031 for (Int_t strind = 0; strind < module->GetNumberOfStrips(); strind++) {
1032 AliITSChannelDaSSD *cstrip = fModules[copymodind]->GetStrip(strind);
1033 Long_t eventsnumber = cstrip->GetEventsNumber();
1034 AliITSChannelDaSSD *strip = new AliITSChannelDaSSD(strind, eventsnumber);
1035 for (Long_t evind = 0; evind < eventsnumber; evind++) {
1036 Short_t sign = *cstrip->GetSignal(evind);
1037 if (!strip->SetSignal(evind, sign)) AliError(Form("AliITSHandleDaSSD: Copy events error! mod = %i, str = %i", modind, strind));
1039 module->SetStrip(strip, strind);
1043 ddlID = fModules[modind]->GetDdlId();
1044 ad = fModules[modind]->GetAD();
1045 adc = fModules[modind]->GetADC();
1048 for (UShort_t modind = 0; modind < fNumberOfModules; modind++) fModules[modind]->SetModuleId(modind + 1080);
1054 //___________________________________________________________________________________________
1055 Bool_t AliITSHandleDaSSD::AdDataPresent(const Int_t ddl, const Int_t ad) const
1057 // Check if there are calibration data for given ddl and slot
1058 for (Int_t modind = 0; modind < fNumberOfModules; modind++)
1059 if ((GetModule(modind)->GetAD() == ad) && (GetModule(modind)->GetDdlId() == ddl)) return kTRUE;
1065 //___________________________________________________________________________________________
1066 Bool_t AliITSHandleDaSSD::SaveEqSlotCalibrationData(const Int_t ddl, const Int_t ad, const Char_t *fname) const
1067 // Saves calibration files for selected equipment (DDL)
1070 Int_t zsml, offsetml;
1071 ULong_t zsth, offset, zsoffset;
1073 AliError("File name must be specified!");
1076 if (!AdDataPresent(ddl, ad)) {
1077 AliError(Form("Error SaveEqSlotCalibrationData(ddl = %i, ad = %i) no data present", ddl, ad));
1080 feefile.open(fname, ios::out);
1081 if (!feefile.is_open()) {
1082 AliError(Form("Can not open the file %s for output!", fname));
1085 for (zsml = 0; fgkZsBitMask >> zsml; zsml++);
1086 for (offsetml = 0; fgkOffSetBitMask >> offsetml; offsetml++);
1087 for (Int_t strind = 0; strind < AliITSModuleDaSSD::GetStripsPerModuleConst(); strind++) {
1088 for (Int_t adcb = 0; adcb < fgkAdcPerDBlock; adcb++) {
1090 for (Int_t j = 0; j < 2; j++) {
1091 Int_t adc = adcb + j * 8;
1092 zsth = ZsThreshold(ddl, ad, adc, strind);
1093 offset = OffsetValue(ddl, ad, adc, strind);
1094 zsoffset = zsoffset | (((zsth << offsetml) | offset) << ((j == 0) ? (offsetml + zsml) : 0));
1096 feefile << "0x" << ConvBase(static_cast<unsigned long>(zsoffset), 16) << endl;
1104 //______________________________________________________________________________
1105 Int_t AliITSHandleDaSSD::ChannelIsBad(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1107 // Check if the channel is bad
1108 // AliITSBadChannelsSSD *badch = NULL;
1109 // TArrayI bcharray;
1112 if (fStaticBadChannelsMap && fDDLModuleMap) {
1113 modn = RetrieveModuleId(ddl, ad, adc);
1116 if (modn < 0) return -1;
1118 while ((modind < fStaticBadChannelsMap->GetEntriesFast() && (!badch))) {
1119 AliITSBadChannelsSSD *bc = static_cast<AliITSBadChannelsSSD*>(fStaticBadChannelsMap->At(modind++));
1120 if ((bc->GetMod()) == modn) badch = bc;
1123 if (strn < AliITSModuleDaSSD::GetPNStripsPerModule()) {
1124 bcharray = badch->GetBadPChannelsList();
1127 bcharray = badch->GetBadNChannelsList();
1128 strsiden = AliITSChannelDaSSD::GetMaxStripIdConst() - strn;
1130 if (bcharray.GetSize() < AliITSModuleDaSSD::GetPNStripsPerModule()) {
1131 AliWarning(Form("No entry found in bad channels list TArrayI for ddl/ad/adc/str: %i/%i/%i/%i", ddl, ad, adc, strn));
1134 return (bcharray[strsiden] & fgkBadChannelMask);
1136 AliWarning(Form("No entry found in bad channels list for ddl = %i, ad = %i, adc = %i", ddl, ad, adc));
1140 AliError("Error ether bad channels list or DDLMap is not initialized or both, return 0!");
1149 //______________________________________________________________________________
1150 ULong_t AliITSHandleDaSSD::OffsetValue(const AliITSChannelDaSSD *strip,
1151 const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1153 // Calculate the offset value to be upload to FEROM
1155 if (fOffsetDefault < INT_MAX) pedint = fOffsetDefault;
1156 else pedint = TMath::Nint(strip->GetPedestal());
1157 if (pedint > static_cast<Int_t>((fgkOffSetBitMask >> 1))) {
1158 if (!ChannelIsBad(ddl, ad, adc, strn))
1159 AliError(Form("Offset %i, channel(ddl/ad/adc/strip) %i/%i/%i/%i can not be represented with mask %i, Offset = %i",
1160 pedint, ddl, ad, adc, strn, ConvBase(fgkOffSetBitMask, 16).c_str(), fgkOffSetBitMask));
1161 return fgkOffSetBitMask;
1163 if ((-pedint) > static_cast<Int_t>(((fgkOffSetBitMask + 1) >> 1))) {
1164 if (!ChannelIsBad(ddl, ad, adc, strn))
1165 AliError(Form("Offset %i, channel(ddl/ad/adc/strip) %i/%i/%i/%i can not be represented with mask %i, Offset = %i",
1166 pedint, ddl, ad, adc, strn, ConvBase(fgkOffSetBitMask, 16).c_str(), (fgkOffSetBitMask & (~fgkOffSetBitMask >> 1))));
1167 return fgkOffSetBitMask & (~fgkOffSetBitMask >> 1);
1169 return fgkOffSetBitMask & (pedint >= 0 ? pedint : pedint + fgkOffSetBitMask + 1);
1174 //______________________________________________________________________________
1175 ULong_t AliITSHandleDaSSD::OffsetValue(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1177 // Calculate the offset value to be upload to FEROM
1178 AliITSChannelDaSSD *strip = NULL;
1179 AliITSModuleDaSSD *module = NULL;
1180 if ((module = GetModule(ddl, ad, adc))) {
1181 if ((strip = module->GetStrip(strn))) return OffsetValue(strip, ddl, ad, adc, strn);
1183 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, strip = %i, 0 is used!", ddl, ad, adc, strn));
1187 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, 0 is used!", ddl, ad, adc));
1194 //______________________________________________________________________________
1195 ULong_t AliITSHandleDaSSD::ZsThreshold(AliITSChannelDaSSD *strip) const
1197 // Calculate the value of zero suppression threshold to be upload to FEROM
1199 if (fZsDefault < 0) zs = TMath::Nint(fZsFactor * strip->GetNoiseCM());
1200 else zs = fZsDefault;
1201 return (zs < fgkZsBitMask) ? (zs & fgkZsBitMask) : fgkZsBitMask;
1205 //______________________________________________________________________________
1206 ULong_t AliITSHandleDaSSD::ZsThreshold(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const
1208 // Calculate the value of zero suppression threshold to be upload to FEROM, account bad channels list
1209 AliITSChannelDaSSD *strip = NULL;
1210 AliITSModuleDaSSD *module = NULL;
1211 if ((ChannelIsBad(ddl, ad, adc, strn))) return fgkZsBitMask;
1212 if ((module = GetModule(ddl, ad, adc))) {
1213 if ((strip = module->GetStrip(strn))) return ZsThreshold(strip);
1215 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, strip = %i, 0 is used!", ddl, ad, adc, strn));
1219 AliWarning(Form("There is no calibration data for ddl = %i, ad = %i, adc = %i, 0 is used!", ddl, ad, adc));
1225 //______________________________________________________________________________
1226 string AliITSHandleDaSSD::ConvBase(const unsigned long value, const long base) const
1228 // Converts the unsigned long number into that in another base
1229 string digits = "0123456789ABCDEF";
1231 unsigned long v = value;
1232 if((base < 2) || (base > 16)) {
1233 result = "Error: base out of range.";
1238 result = digits[v % base] + result;
1242 while((v) || (i<8));