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