]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHandleDaSSD.h
1) Added classes for digitization
[u/mrichter/AliRoot.git] / ITS / AliITSHandleDaSSD.h
1 #ifndef ALIITSHANDLEDASSD_H
2 #define ALIITSHANDLEDASSD_H
3
4 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6 /*                                                                        */
7 /* $Id$ */
8
9 #include <string>
10 #include "TObject.h"
11 #include "TArrayS.h"
12 #include "AliITSModuleDaSSD.h"
13
14 ///////////////////////////////////////////////////////////////////////////////
15 ///
16 /// This class provides ITS SSD data handling
17 /// used by DA. 
18 //  Author: Oleksandr Borysov
19 //  Date: 09/02/2010
20 ///////////////////////////////////////////////////////////////////////////////
21
22 using namespace std;
23
24 class AliITSBadChannelsSSDv2;
25 class AliITSNoiseSSDv2;
26
27 class AliITSHandleDaSSD : public TObject {
28   public :
29     AliITSHandleDaSSD();
30     explicit AliITSHandleDaSSD(Char_t *rdfname);
31     AliITSHandleDaSSD(const AliITSHandleDaSSD& ssdadldc);
32     AliITSHandleDaSSD& operator = (const AliITSHandleDaSSD& ssdadldc);
33     virtual ~AliITSHandleDaSSD();
34
35     virtual Bool_t Init(Char_t *rdfname);
36     Bool_t  SetRawFileName (Char_t *rdfname) {return Init(rdfname); }
37
38     void    SetZsDefaul(const Int_t zs)        { fZsDefault = zs;       }
39     void    SetOffsetDefault(const Int_t offs) { fOffsetDefault = offs; }
40     void    SetZsMinimum(const Int_t zsm)      { if (zsm >= 0) if (static_cast<UInt_t>(zsm) <= fgkZsBitMask) fZsMinimum = zsm; }
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); }
56     Float_t GetPedestalThresholdFactor() const { return fPedestalThresholdFactor; }
57     Float_t GetCmThresholdFactor() const       { return fCmThresholdFactor;       }
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         
62     Int_t              GetNumberOfModules() const { return fNumberOfModules; }
63     UInt_t             GetLdcId() const { return fLdcId; }
64     UInt_t             GetRunId() const { return fRunId; }
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;}
68     Int_t GetModuleIndex (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
69     AliITSChannelDaSSD*    GetStrip (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t stripID) const;
70     AliITSNoiseSSDv2*        GetCalibrationOCDBNoise()  const;
71     AliITSBadChannelsSSDv2*  GetCalibrationBadChannels() const;
72     Bool_t      SaveCalibrationSSDLDC(Char_t*& dafname);
73     Int_t       MergeBadChannels(AliITSBadChannelsSSDv2*& bcl) const;    
74     
75     void    SetModIndProcessed(Int_t mi) {fModIndProcessed = mi;}
76     void    SetModIndRead (Int_t mr)  {fModIndRead = mr;}
77     Bool_t  SetNumberOfModules (const Int_t numberofmodules);
78     Bool_t  SetModule(AliITSModuleDaSSD *const module, const Int_t index); 
79     virtual Bool_t  ReadStaticBadChannelsMap(const Char_t *filename = NULL);  
80     virtual Bool_t  ReadDDLModuleMap(const Char_t *filename = NULL);  
81     Int_t   ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber);
82     virtual Int_t   ReadModuleRawData (const Int_t modulesnumber);  
83
84     virtual Bool_t  CalculatePedestal(const AliITSModuleDaSSD *const module);
85     virtual Bool_t  CalculateNoise(const AliITSModuleDaSSD *const module);
86     virtual Bool_t  CalculateNoiseCM(AliITSModuleDaSSD *const module);
87     virtual Bool_t  CalculateCM(AliITSModuleDaSSD *const module);
88     virtual Bool_t  CalculatePedNoiseW(const AliITSModuleDaSSD *const module);
89     virtual Bool_t  CalculateCMW(AliITSModuleDaSSD *const module);
90     virtual Bool_t  CalculateNoiseCMW(AliITSModuleDaSSD *const module);
91     virtual Bool_t  AddFeromCm(const AliITSModuleDaSSD *const module);
92     virtual Bool_t  ProcessRawData(const Int_t nmread = fgkNumberOfSSDModulesPerDdl,  const Bool_t usewelford = kTRUE);
93     virtual Bool_t  RelocateModules();
94     virtual Bool_t  AllocateSimulatedModules(const Int_t copymodind = 0);
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;
99     UChar_t EvaluateIfChannelIsBad(const AliITSModuleDaSSD *const module, const Int_t stripn) const;
100     Int_t   LadderIsOff(const UChar_t ddl, const UChar_t ad, const UChar_t adc) const;
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;
105     ULong_t ZsThreshold(const AliITSChannelDaSSD *strip) const;
106     ULong_t ZsThreshold(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
107     
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;
112     Int_t   CheckOffChips() const;
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();}
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();}
118     void    DeleteCMFerom() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteCMFerom ();}
119
120     static Int_t GetNumberOfSSDModulesConst() { return fgkNumberOfSSDModules; }
121
122   protected :
123
124     static const Int_t    fgkNumberOfSSDModules ;        // Number of SSD modules in ITS
125     static const Int_t    fgkNumberOfSSDModulesPerDdl;   // Number of SSD modules in DDL
126     static const Int_t    fgkNumberOfSSDModulesPerSlot;  // Number of SSD modules in Slot
127     static const Short_t  fgkMinSSDModuleId;             // Initial SSD modules number
128     static const Int_t    fgkNumberOfSSDDDLs;            // Number of DDLs in SSD
129     static const Int_t    fgkNumberOfSSDSlotsPerDDL;     // Number of SSD slots per DDL
130     static const Float_t  fgkPedestalThresholdFactor;    // Defalt value for fPedestalThresholdFactor 
131     static const Float_t  fgkCmThresholdFactor;          // Defalt value for fCmThresholdFactor 
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      
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
147     AliITSBadChannelsSSDv2 *fBadChannelsList;       //! List of bad channels: static or created on base of calculated noise and pedestal
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
151     
152     UInt_t                fLdcId;                 //  LDC number, read from header
153     UInt_t                fRunId;                 //  Run number, read from header
154
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
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
161     Float_t         fZsFactor;                       // zs factor 3.0
162     
163   protected :
164     Bool_t   SignalOutOfRange (const Short_t signal) const { return ((signal >= AliITSChannelDaSSD::GetOverflowConst()) || 
165                                                                      (signal <= AliITSChannelDaSSD::GetUnderflowConst())); }
166     string   ConvBase(const unsigned long value, const long base) const;
167
168     ClassDef(AliITSHandleDaSSD, 8)
169
170 };
171
172 #endif