]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHandleDaSSD.h
Updated online raw data QA for the SSD - occupancy calculation per module (Panos)
[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 "AliITSModuleDaSSD.h"
12
13 ///////////////////////////////////////////////////////////////////////////////
14 ///
15 /// This class provides ITS SSD data handling
16 /// used by DA. 
17 //  Author: Oleksandr Borysov
18 //  Date: 19/05/2008
19 ///////////////////////////////////////////////////////////////////////////////
20
21 using namespace std;
22
23 class TObjArray;
24
25 class AliITSHandleDaSSD : public TObject {
26   public :
27     AliITSHandleDaSSD();
28     explicit AliITSHandleDaSSD(Char_t *rdfname);
29     AliITSHandleDaSSD(const AliITSHandleDaSSD& ssdadldc);
30     AliITSHandleDaSSD& operator = (const AliITSHandleDaSSD& ssdadldc);
31     virtual ~AliITSHandleDaSSD();
32
33     virtual Bool_t Init(Char_t *rdfname);
34     Bool_t  SetRawFileName (Char_t *rdfname) {return Init(rdfname); }
35
36     void    SetZsDefaul(Int_t zs)        { fZsDefault = zs;       }
37     void    SetOffsetDefault(Int_t offs) { fOffsetDefault = offs; }
38     void    SetZsFactor(Float_t zsf)     { fZsFactor = zsf;       }
39     void    SetPedestalThresholdFactor(Float_t pthf) { fPedestalThresholdFactor = pthf; }
40     void    SetCmThresholdFactor(Float_t cmthf)      { fCmThresholdFactor = cmthf;      }
41
42     Int_t   GetZsDefault() const     { return fZsDefault;     }
43     Int_t   GetOffsetDefault() const { return fOffsetDefault; }
44     Float_t GetZsFactor() const      { return fZsFactor;      }
45     Float_t GetPedestalThresholdFactor() const { return fPedestalThresholdFactor; }
46     Float_t GetCmThresholdFactor() const       { return fCmThresholdFactor;       }
47     
48     Int_t              GetNumberOfModules() const { return fNumberOfModules; }
49     UInt_t             GetLdcId() const { return fLdcId; }
50     UInt_t             GetRunId() const { return fRunId; }
51     AliITSModuleDaSSD* GetModule (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
52     AliITSModuleDaSSD* GetModule (const Int_t index) const 
53                                {if ((fModules) && (index < fNumberOfModules)) return fModules[index]; else return NULL;}
54     Int_t GetModuleIndex (const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
55     AliITSChannelDaSSD* GetStrip (const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const UShort_t stripID) const;
56     TObjArray*  GetCalibrationSSDLDC()  const;
57     Bool_t      SaveCalibrationSSDLDC(Char_t*& dafname) const;
58     
59     void    SetModIndProcessed(Int_t mi) {fModIndProcessed = mi;}
60     void    SetModIndRead (Int_t mr)  {fModIndRead = mr;}
61     Bool_t  SetNumberOfModules (const Int_t numberofmodules);
62     Bool_t  SetModule(AliITSModuleDaSSD *const module, const Int_t index); 
63     virtual Bool_t  ReadStaticBadChannelsMap(const Char_t *filename = NULL);  
64     virtual Bool_t  ReadDDLModuleMap(const Char_t *filename = NULL);  
65     Int_t   ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber);
66     Int_t   ReadModuleRawData (const Int_t modulesnumber);  
67
68     virtual Bool_t  CalculatePedestal(AliITSModuleDaSSD *const module);
69     virtual Bool_t  CalculateNoise(AliITSModuleDaSSD *const module);
70     virtual Bool_t  CalculateNoiseCM(AliITSModuleDaSSD *const module);
71     virtual Bool_t  CalculateCM(AliITSModuleDaSSD *const module);
72     virtual Bool_t  AddFeromCm(AliITSModuleDaSSD *const module);
73     virtual Bool_t  ProcessRawData(const Int_t nmread = fgkNumberOfSSDModulesPerDdl);
74     virtual Bool_t  RelocateModules();
75     virtual Bool_t  AllocateSimulatedModules(const Int_t copymodind = 0);
76
77     Bool_t  AdDataPresent(const Int_t ddl, const Int_t ad) const;
78     Int_t   DdlToEquipmentId (Int_t ddl) const { return (512 + ddl); }
79     Int_t   ChannelIsBad(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
80     Bool_t  SaveEqSlotCalibrationData(const Int_t ddl, const Int_t ad, const Char_t *fname) const;
81     ULong_t OffsetValue(const AliITSChannelDaSSD *strip, const UChar_t ddl = 0, const UChar_t ad = 0, 
82                                  const UChar_t adc = 0, const Int_t strn = -1) const;
83     ULong_t OffsetValue(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
84     ULong_t ZsThreshold(AliITSChannelDaSSD *strip) const;
85     ULong_t ZsThreshold(const UChar_t ddl, const UChar_t ad, const UChar_t adc, const Int_t strn) const;
86     
87     virtual void    Reset();
88     virtual Short_t RetrieveModuleId(const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const;
89     Bool_t  DumpModInfo(const Float_t meannosethreshold) const;
90     Bool_t  PrintModCalibrationData(const UChar_t ddlID, const UChar_t ad, const UChar_t adc, const Char_t *fname = NULL) const;
91     void    DumpInitData(const Char_t *str = "") const;
92     void    DeleteSignalAll() { if (fModules) for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) fModules[i]->DeleteSignal();}
93     void    DeleteSignal() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteSignal();}
94     void    DeleteCMAll() { if (fModules) for (Int_t i = 0; i < fNumberOfModules; i++) if (fModules[i]) fModules[i]->DeleteCM();}
95     void    DeleteCM() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteCM();}
96     void    DeleteCMFerom() { if (fModules) for (Int_t i = fModIndProcessed; i < fModIndRead; i++) if (fModules[i]) fModules[i]->DeleteCMFerom ();}
97
98     static Int_t GetNumberOfSSDModulesConst() { return fgkNumberOfSSDModules; }
99
100   protected :
101
102     static const Int_t    fgkNumberOfSSDModules ;        // Number of SSD modules in ITS
103     static const Int_t    fgkNumberOfSSDModulesPerDdl;   // Number of SSD modules in DDL
104     static const Int_t    fgkNumberOfSSDModulesPerSlot;  // Number of SSD modules in Slot
105     static const Int_t    fgkNumberOfSSDDDLs;            // Number of DDLs in SSD
106     static const Int_t    fgkNumberOfSSDSlotsPerDDL;     // Number of SSD slots per DDL
107     static const Float_t  fgkPedestalThresholdFactor;    // Defalt value for fPedestalThresholdFactor 
108     static const Float_t  fgkCmThresholdFactor;          // Defalt value for fCmThresholdFactor 
109    
110     static const UInt_t   fgkZsBitMask ;           // Bit mask for FEROM ZS
111     static const UInt_t   fgkOffSetBitMask;        // Bit mask for FEROM Offset correction
112     static const UInt_t   fgkBadChannelMask;       // Mask to suppress the channel from the bad channel list
113     static const Int_t    fgkAdcPerDBlock;         // FEROM configuration file constant
114      
115     Char_t              *fRawDataFileName;       // Name of the file with raw data
116     Int_t                fNumberOfModules;       // number of AliITSModuleDaSSD to allocate
117     AliITSModuleDaSSD  **fModules;               //[fNumberOfModules] array of pointer on AliITSModuleDaSSD objects (1698 SSD  Modules)
118     Int_t                fModIndProcessed;       //! index of the last module in fModules array with processed data
119     Int_t                fModIndRead;            //! index of the last module in fModules array with adc data present (read)
120     Int_t               *fModIndex;              //! index array for fModules
121     Long_t               fNumberOfEvents;        // Number of physics or calibration events in raw data file fRawDataFileName
122
123     TObjArray           *fStaticBadChannelsMap;  // Static bad channels map read from the file
124     Int_t               *fDDLModuleMap;          //! DDL map  
125     
126     UInt_t               fLdcId;                 //  LDC number, read from header
127     UInt_t               fRunId;                 //  Run number, read from header
128
129     Float_t         fPedestalThresholdFactor;        // configuration parameter: ThresholdFactor for pedestal calculation 
130     Float_t         fCmThresholdFactor;              // configuration parameter: ThresholdFactor for CM calculation 
131     Int_t           fZsDefault;                      // default value for ZS threshold
132     Int_t           fOffsetDefault;                  // default value for offset correction
133     Float_t         fZsFactor;                       // zs factor 3.0
134
135   protected :
136     Bool_t   SignalOutOfRange (const Short_t signal) const { return (signal >= AliITSChannelDaSSD::GetOverflowConst()); }
137     string   ConvBase(const unsigned long value, const long base) const;
138
139     ClassDef(AliITSHandleDaSSD, 5)
140
141 };
142
143 #endif
144