- fixing warnings/coverity
[u/mrichter/AliRoot.git] / ITS / AliITSHandleDaSSD.h
CommitLineData
f67db810 1#ifndef ALIITSHANDLEDASSD_H
2#define ALIITSHANDLEDASSD_H
3
223dda26 4/* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6/* */
371588bb 7/* $Id$ */
f67db810 8
be4f467e 9#include <string>
223dda26 10#include "TObject.h"
61a57d07 11#include "TArrayS.h"
f67db810 12#include "AliITSModuleDaSSD.h"
88128115 13#include "AliITSBadChannelsSSDv2.h"
14#include "AliITSNoiseSSDv2.h"
f67db810 15
223dda26 16///////////////////////////////////////////////////////////////////////////////
17///
18/// This class provides ITS SSD data handling
19/// used by DA.
2e2c6def 20// Author: Oleksandr Borysov
d86972f6 21// Date: 09/02/2010
223dda26 22///////////////////////////////////////////////////////////////////////////////
23
be4f467e 24using namespace std;
25
f67db810 26class AliITSHandleDaSSD : public TObject {
27 public :
28 AliITSHandleDaSSD();
c4d90345 29 explicit AliITSHandleDaSSD(Char_t *rdfname);
f67db810 30 AliITSHandleDaSSD(const AliITSHandleDaSSD& ssdadldc);
31 AliITSHandleDaSSD& operator = (const AliITSHandleDaSSD& ssdadldc);
32 virtual ~AliITSHandleDaSSD();
33
be4f467e 34 virtual Bool_t Init(Char_t *rdfname);
c4d90345 35 Bool_t SetRawFileName (Char_t *rdfname) {return Init(rdfname); }
f67db810 36
61a57d07 37 void SetZsDefaul(const Int_t zs) { fZsDefault = zs; }
38 void SetOffsetDefault(const Int_t offs) { fOffsetDefault = offs; }
d86972f6 39 void SetZsMinimum(const Int_t zsm) { if (zsm >= 0) if (static_cast<UInt_t>(zsm) <= fgkZsBitMask) fZsMinimum = zsm; }
61a57d07 40 void SetMergeBCFlag(const Byte_t mbcf) { fMergeBCLists = mbcf; }
41 void SetZsFactor(const Float_t zsf) { fZsFactor = zsf; }
42 void SetPedestalThresholdFactor(const Float_t pthf) { fPedestalThresholdFactor = pthf; }
43 void SetCmThresholdFactor(const Float_t cmthf) { fCmThresholdFactor = cmthf; }
44 void SetALaddersOff(const Int_t n, const Short_t *allist) { fALaddersOff.Set(n, allist); }
45 void SetCLaddersOff(const Int_t n, const Short_t *cllist) { fCLaddersOff.Set(n, cllist); }
46 void SetLaddersOff(const Int_t na, const Short_t *allist, const Int_t nc, const Short_t *cllist)
47 { SetALaddersOff(na, allist); SetCLaddersOff(nc, cllist); }
48
49 Int_t GetNumberOfEvents() const { return fNumberOfEvents; }
50 Int_t GetZsDefault() const { return fZsDefault; }
51 Int_t GetOffsetDefault() const { return fOffsetDefault; }
52 Float_t GetZsFactor() const { return fZsFactor; }
53 Int_t GetZsMinimum() const { return fZsMinimum; }
54 Bool_t GetMergeBCFlag() const { return static_cast<Bool_t>(fMergeBCLists); }
be4f467e 55 Float_t GetPedestalThresholdFactor() const { return fPedestalThresholdFactor; }
56 Float_t GetCmThresholdFactor() const { return fCmThresholdFactor; }
61a57d07 57 TArrayS GetALaddersOff () const { return fALaddersOff; }
58 TArrayS GetCLaddersOff () const { return fCLaddersOff; }
59 Int_t GetEqIndex(const Short_t eq) const { for(Int_t i = 0; i < fEqIndex.GetSize(); i++) if (eq == fEqIndex.At(i)) return i; return -1; }
60
c4d90345 61 Int_t GetNumberOfModules() const { return fNumberOfModules; }
62 UInt_t GetLdcId() const { return fLdcId; }
63 UInt_t GetRunId() const { return fRunId; }
f67db810 64 AliITSModuleDaSSD* GetModule (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
65 AliITSModuleDaSSD* GetModule (const Int_t index) const
66 {if ((fModules) && (index < fNumberOfModules)) return fModules[index]; else return NULL;}
c4d90345 67 Int_t GetModuleIndex (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
61a57d07 68 AliITSChannelDaSSD* GetStrip (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t stripID) const;
88128115 69 AliITSNoiseSSDv2* GetCalibrationOCDBNoise() const;
70 AliITSBadChannelsSSDv2* GetCalibrationBadChannels() const;
61a57d07 71 Bool_t SaveCalibrationSSDLDC(Char_t*& dafname);
88128115 72 Int_t MergeBadChannels(AliITSBadChannelsSSDv2*& bcl) const;
f67db810 73
c4d90345 74 void SetModIndProcessed(Int_t mi) {fModIndProcessed = mi;}
75 void SetModIndRead (Int_t mr) {fModIndRead = mr;}
f67db810 76 Bool_t SetNumberOfModules (const Int_t numberofmodules);
77 Bool_t SetModule(AliITSModuleDaSSD *const module, const Int_t index);
6e7691a5 78 virtual Bool_t ReadStaticBadChannelsMap(const Char_t *filename = NULL);
79 virtual Bool_t ReadDDLModuleMap(const Char_t *filename = NULL);
371588bb 80 Int_t ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber);
61a57d07 81 virtual Int_t ReadModuleRawData (const Int_t modulesnumber);
c4d90345 82
83 virtual Bool_t CalculatePedestal(AliITSModuleDaSSD *const module);
a69c8ba0 84 virtual Bool_t CalculateNoise(AliITSModuleDaSSD *const module);
c4d90345 85 virtual Bool_t CalculateNoiseCM(AliITSModuleDaSSD *const module);
86 virtual Bool_t CalculateCM(AliITSModuleDaSSD *const module);
d86972f6 87 virtual Bool_t CalculatePedNoiseW(AliITSModuleDaSSD *const module);
88 virtual Bool_t CalculateCMW(AliITSModuleDaSSD *const module);
89 virtual Bool_t CalculateNoiseCMW(AliITSModuleDaSSD *const module);
371588bb 90 virtual Bool_t AddFeromCm(AliITSModuleDaSSD *const module);
d86972f6 91 virtual Bool_t ProcessRawData(const Int_t nmread = fgkNumberOfSSDModulesPerDdl, const Bool_t usewelford = kTRUE);
c4d90345 92 virtual Bool_t RelocateModules();
93 virtual Bool_t AllocateSimulatedModules(const Int_t copymodind = 0);
be4f467e 94
95 Bool_t AdDataPresent(const Int_t ddl, const Int_t ad) const;
96 Int_t DdlToEquipmentId (Int_t ddl) const { return (512 + ddl); }
97 Int_t ChannelIsBad(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
d86972f6 98 UChar_t EvaluateIfChannelIsBad(const AliITSModuleDaSSD *const module, const Int_t stripn) const;
61a57d07 99 Int_t LadderIsOff(const UChar_t ddl, const UChar_t ad, const UChar_t adc) const;
be4f467e 100 Bool_t SaveEqSlotCalibrationData(const Int_t ddl, const Int_t ad, const Char_t *fname) const;
101 ULong_t OffsetValue(const AliITSChannelDaSSD *strip, const UChar_t ddl = 0, const UChar_t ad = 0,
102 const UChar_t adc = 0, const Int_t strn = -1) const;
103 ULong_t OffsetValue(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
104 ULong_t ZsThreshold(AliITSChannelDaSSD *strip) const;
105 ULong_t ZsThreshold(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
106
c4d90345 107 virtual void Reset();
108 virtual Short_t RetrieveModuleId(const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
109 Bool_t DumpModInfo(const Float_t meannosethreshold) const;
110 Bool_t PrintModCalibrationData(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Char_t *fname = NULL) const;
61a57d07 111 Int_t CheckOffChips() const;
c4d90345 112 void DumpInitData(const Char_t *str = "") const;
113 void DeleteSignalAll() { if (fModules) for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) fModules[i]->DeleteSignal();}
114 void DeleteSignal() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteSignal();}
a69c8ba0 115 void DeleteCMAll() { if (fModules) for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) fModules[i]->DeleteCM();}
116 void DeleteCM() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteCM();}
371588bb 117 void DeleteCMFerom() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteCMFerom ();}
f67db810 118
119 static Int_t GetNumberOfSSDModulesConst() { return fgkNumberOfSSDModules; }
120
121 protected :
be4f467e 122
c4d90345 123 static const Int_t fgkNumberOfSSDModules ; // Number of SSD modules in ITS
2e2c6def 124 static const Int_t fgkNumberOfSSDModulesPerDdl; // Number of SSD modules in DDL
125 static const Int_t fgkNumberOfSSDModulesPerSlot; // Number of SSD modules in Slot
61a57d07 126 static const Short_t fgkMinSSDModuleId; // Initial SSD modules number
6e7691a5 127 static const Int_t fgkNumberOfSSDDDLs; // Number of DDLs in SSD
be4f467e 128 static const Int_t fgkNumberOfSSDSlotsPerDDL; // Number of SSD slots per DDL
c4d90345 129 static const Float_t fgkPedestalThresholdFactor; // Defalt value for fPedestalThresholdFactor
130 static const Float_t fgkCmThresholdFactor; // Defalt value for fCmThresholdFactor
be4f467e 131
132 static const UInt_t fgkZsBitMask ; // Bit mask for FEROM ZS
133 static const UInt_t fgkOffSetBitMask; // Bit mask for FEROM Offset correction
134 static const UInt_t fgkBadChannelMask; // Mask to suppress the channel from the bad channel list
135 static const Int_t fgkAdcPerDBlock; // FEROM configuration file constant
136
61a57d07 137 Char_t *fRawDataFileName; // Name of the file with raw data
138 Int_t fNumberOfModules; // number of AliITSModuleDaSSD to allocate
139 AliITSModuleDaSSD **fModules; //[fNumberOfModules] array of pointer on AliITSModuleDaSSD objects (1698 SSD Modules)
140 Int_t fModIndProcessed; //! index of the last module in fModules array with processed data
141 Int_t fModIndRead; //! index of the last module in fModules array with adc data present (read)
142 Int_t *fModIndex; //! index array for fModules
143 TArrayS fEqIndex; //! index array of equipmnts (DDLs).
144 Long_t fNumberOfEvents; // Number of physics or calibration events in raw data file fRawDataFileName
145
88128115 146 AliITSBadChannelsSSDv2 *fBadChannelsList; //! List of bad channels: static or created on base of calculated noise and pedestal
61a57d07 147 Int_t *fDDLModuleMap; //! DDL map
148 TArrayS fALaddersOff; //! Lisst of ladders of side A that are off and should be suppressed
149 TArrayS fCLaddersOff; //! Lisst of ladders of side C that are off and should be suppressed
c4d90345 150
61a57d07 151 UInt_t fLdcId; // LDC number, read from header
152 UInt_t fRunId; // Run number, read from header
f67db810 153
be4f467e 154 Float_t fPedestalThresholdFactor; // configuration parameter: ThresholdFactor for pedestal calculation
155 Float_t fCmThresholdFactor; // configuration parameter: ThresholdFactor for CM calculation
156 Int_t fZsDefault; // default value for ZS threshold
157 Int_t fOffsetDefault; // default value for offset correction
61a57d07 158 Int_t fZsMinimum; // minimum value for ZS threshold
159 Byte_t fMergeBCLists; // Flag, if it is not zero the static bad channels list is merged with dynamic one
be4f467e 160 Float_t fZsFactor; // zs factor 3.0
61a57d07 161
be4f467e 162 protected :
61a57d07 163 Bool_t SignalOutOfRange (const Short_t signal) const { return ((signal >= AliITSChannelDaSSD::GetOverflowConst()) ||
164 (signal <= AliITSChannelDaSSD::GetUnderflowConst())); }
be4f467e 165 string ConvBase(const unsigned long value, const long base) const;
f67db810 166
d86972f6 167 ClassDef(AliITSHandleDaSSD, 8)
f67db810 168
169};
170
171#endif
d86972f6 172