prevent running if CDB snapshot setting failed
[u/mrichter/AliRoot.git] / STEER / STEER / AliGRPObject.h
1 #ifndef ALIGRPOBJECT_H
2 #define ALIGRPOBJECT_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //
10 // AliGRPObject
11 // class to store the information
12 // coming from the GRP preprocessor
13 // 
14
15 #include <time.h>
16 #include <TString.h>
17 #include <TTimeStamp.h>
18 #include <TArrayD.h>
19
20 class TMap;
21
22 class AliDCSSensor;
23 class AliSplineFit;
24 class AliLog;
25
26 class AliGRPObject : public TObject {
27  public:
28
29         enum Stats {kMean = 0, kTruncMean = 1, kMedian = 2, kSDMean = 3, kSDMedian = 4};
30         
31         enum StatusBits {kPolConvLHC = BIT(14), kUniformBMap = BIT(15),kConvSqrtSHalfGeV = BIT(16)};
32
33         enum DP_HallProbes { 
34                  khpL3bsf17H1= 0 , khpL3bsf17H2, khpL3bsf17H3, khpL3bsf17Temperature, 
35                  khpL3bsf4H1, khpL3bsf4H2, khpL3bsf4H3, khpL3bsf4Temperature, 
36                  khpL3bkf17H1, khpL3bkf17H2, khpL3bkf17H3, khpL3bkf17Temperature, 
37                  khpL3bkf4H1, khpL3bkf4H2, khpL3bkf4H3, khpL3bkf4Temperature, 
38                  khpL3bsf13H1, khpL3bsf13H2, khpL3bsf13H3, khpL3bsf13Temperature,
39                  khpL3bsf8H1, khpL3bsf8H2, khpL3bsf8H3, khpL3bsfy8Temperature,
40                  khpL3bkf13H1, khpL3bkf13H2, khpL3bkf13H3, khpL3bkf13Temperature,
41                  khpL3bkf8H1, khpL3bkf8H2, khpL3bkf8H3, khpL3bkf8Temperature,
42                  khpDipoleInsideH1, khpDipoleInsideH2, khpDipoleInsideH3, khpDipoleInsideTemperature,
43                  khpDipoleOutsideH1, khpDipoleOutsideH2, khpDipoleOutsideH3, khpDipoleOutsideTemperature};
44
45
46         AliGRPObject();
47         AliGRPObject(const AliGRPObject & obj);
48         AliGRPObject& operator=(const AliGRPObject & obj);
49         ~AliGRPObject();
50
51         // getters
52         Bool_t    IsBeamEnergyIsSqrtSHalfGeV() const {return TestBit(kConvSqrtSHalfGeV);}
53         Bool_t    IsPolarityConventionLHC() const {return TestBit(kPolConvLHC);}
54         Bool_t    IsUniformBMap() const {return TestBit(kUniformBMap);}
55         time_t    GetTimeStart() const {return fTimeStart;}
56         time_t    GetTimeEnd() const {return fTimeEnd;}
57         Float_t   GetBeamEnergy() const;
58         TString   GetBeamType() const {return fBeamType;}
59         Char_t    GetNumberOfDetectors() const {return fNumberOfDetectors;}
60         UInt_t    GetDetectorMask() const {return fDetectorMask;}
61         TString   GetLHCPeriod() const {return fLHCPeriod;}
62         TString   GetRunType() const {return fRunType;}
63         TString   GetLHCState() const {return fLHCState;}
64         TString   GetMachineMode() const {return fMachineMode;}
65         TObjArray*   GetLHCStateArray() const {return fLHCStateArray;}
66         TObjArray*   GetMachineModeArray() const {return fMachineModeArray;}
67         Char_t    GetL3Polarity() const {return fL3Polarity;}
68         Char_t    GetDipolePolarity() const {return fDipolePolarity;}
69         Float_t*  GetL3Current() const {return fL3Current;}
70         Float_t   GetL3Current(Stats stat) const {return fL3Current[stat];}
71         Float_t*  GetDipoleCurrent() const {return fDipoleCurrent;}
72         Float_t   GetDipoleCurrent(Stats stat) const {return fDipoleCurrent[stat];}
73         Float_t*  GetCavernTemperature() const {return fCavernTemperature;}
74         Float_t   GetCavernTemperature(Stats stat) const {return fCavernTemperature[stat];}
75         AliDCSSensor*   GetCavernAtmosPressure() const {return fCavernAtmosPressure;}
76         AliDCSSensor*   GetCavernAtmosPressure2() const {return fCavernAtmosPressure2;}
77         AliDCSSensor*   GetSurfaceAtmosPressure() const {return fSurfaceAtmosPressure;}
78         AliDCSSensor*   GetBestCavernAtmosPressure() const ;
79         AliDCSSensor*   GetBestCavernAtmosPressure(const TTimeStamp& time) const;
80         static AliDCSSensor* GetBestCavernAtmosPressure(AliDCSSensor* cavern1, 
81                            AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time);
82
83
84         Float_t*  GetHallProbesArray(DP_HallProbes hp) const;
85         Float_t   GetHallProbes(Int_t hp) const {return fHallProbes[hp];}
86         Float_t   GetHallProbes(DP_HallProbes hp, Stats stat) const {return fHallProbes[hp*fPoints+stat];}
87
88         Int_t    GetPoints() const {return fPoints;}
89         Int_t    GetDimension() const {return fDimension;}
90
91         Double_t GetMaxTimeLHCValidity() const {return fMaxTimeLHCValidity;}
92         //
93         TObjArray* GetQATrigClasses()    const {return (TObjArray*)fQATrigClasses;}
94         TObjArray* GetQACloningRequest() const {return (TObjArray*)fQACloningRequest;}
95         //
96         // setters
97         void SetBeamEnergyIsSqrtSHalfGeV(Bool_t v=kTRUE) {SetBit(kConvSqrtSHalfGeV,v);}
98         void SetPolarityConventionLHC(Bool_t v=kTRUE) {return SetBit(kPolConvLHC,v);}
99         void SetUniformBMap(Bool_t v=kTRUE) {return SetBit(kUniformBMap,v);}
100         void SetTimeStart(time_t timeStart)  {fTimeStart = timeStart;}
101         void SetTimeEnd(time_t timeEnd)  {fTimeEnd = timeEnd;}
102         void SetBeamEnergy(Float_t beamEnergy)  {fBeamEnergy = beamEnergy;}
103         void SetBeamType(TString beamType)  {fBeamType = beamType;}
104         void SetNumberOfDetectors(Char_t numberOfDetectors)  {fNumberOfDetectors = numberOfDetectors;}
105         void SetDetectorMask(UInt_t detectorMask)  {fDetectorMask = detectorMask;}
106         void SetLHCPeriod(TString lhcPeriod)  {fLHCPeriod = lhcPeriod;}
107         void SetRunType(TString runType)  {fRunType = runType;}
108         void SetLHCState(TString lhcState)  {fLHCState = lhcState;}
109         void SetMachineMode(TString machineMode)  {fMachineMode = machineMode;}
110         void SetLHCStateArray(TObjArray* lhcStateArray)  {fLHCStateArray = lhcStateArray;}
111         void SetMachineModeArray(TObjArray* machineModeArray)  {fMachineModeArray = machineModeArray;}
112         void SetL3Polarity(Char_t l3Polarity)  {fL3Polarity = l3Polarity;}
113         void SetDipolePolarity(Char_t dipolePolarity)  {fDipolePolarity = dipolePolarity;}
114         void SetL3Current(const Float_t* l3Current)  {
115                 for (Int_t i = 0;i<fPoints;i++) fL3Current[i] = l3Current[i];
116         }
117         void SetL3Current(Float_t l3Current, Stats stat)  {fL3Current[stat] = l3Current;}
118         void SetDipoleCurrent(const Float_t* dipoleCurrent) {
119                 for (Int_t i = 0;i<fPoints;i++) fDipoleCurrent[i] = dipoleCurrent[i];
120         }
121         void SetDipoleCurrent(Float_t dipoleCurrent, Stats stat)  {fDipoleCurrent[stat] = dipoleCurrent;}
122         void SetCavernTemperature(const Float_t* cavernTemperature)  {
123                 for (Int_t i = 0;i<fPoints;i++) fCavernTemperature[i] = cavernTemperature[i];
124         }
125         void SetCavernTemperature(Float_t cavernTemperature, Stats stat)  {fCavernTemperature[stat] = cavernTemperature;}
126         void SetCavernAtmosPressure(AliDCSSensor* const cavernAtmosPressure)  {fCavernAtmosPressure = cavernAtmosPressure;}
127         void SetCavernAtmosPressure2(AliDCSSensor* const cavernAtmosPressure)  {fCavernAtmosPressure2 = cavernAtmosPressure;}
128         void SetSurfaceAtmosPressure(AliDCSSensor* const surfacePressure)  {fSurfaceAtmosPressure = surfacePressure;}
129
130         void SetHallProbes(DP_HallProbes hp, Float_t hall_probe, Stats stat)  {fHallProbes[hp*fPoints+stat] = hall_probe;}
131         void SetHallProbes(const Float_t* hall_probe){
132                 for (Int_t i = 0; i< fDimension; i++) fHallProbes[i] =  hall_probe[i];}
133
134         void SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe);  
135         void SetPoints(Int_t points) {fPoints = points;}
136         void SetDimension(Int_t dimension) {fDimension = dimension;}
137         void SetMaxTimeLHCValidity(Double_t maxTimeLHCValidity) {fMaxTimeLHCValidity = maxTimeLHCValidity;}
138         //
139         void SetQATrigClasses(TObjArray* arr)    {fQATrigClasses = arr;}
140         void SetQACloningRequest(TObjArray* arr) {fQACloningRequest = arr;}
141         //
142         // getters for "invalid" flags
143
144         static Float_t GetInvalidFloat() {return fgkInvalidFloat;}
145         static TString GetInvalidString() {return fgkInvalidString;}
146         static Int_t GetInvalidInt() {return fgkInvalidInt;}
147         static Int_t GetInvalidUInt() {return fgkInvalidUInt;}
148         static Char_t GetInvalidChar() {return fgkInvalidChar;}
149         static Int_t GetNumberOfHP() {return fgknDCSDPHallProbes;}
150         static const char* GetHPDP(Int_t indexHP) {return fgkDCSDataPointsHallProbes[indexHP];}
151
152         Double_t EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const;
153         static Double_t EvalCavernPressure(AliDCSSensor* cavern1, 
154                       AliDCSSensor* cavern2, AliDCSSensor* surface, 
155                       const TTimeStamp& time, Bool_t& inside);
156
157         // to read old GRP object in TMap format
158
159         void ReadValuesFromMap(const TMap* map);        
160
161         void SetSingleBeamType(Int_t ibeamType, TString beamType)  {fSeparateBeamType[ibeamType] = beamType;}
162         TString   GetSingleBeamType(Int_t ibeamType) const {return fSeparateBeamType[ibeamType];}
163
164         void SetNFalseDataQualityFlag(Int_t nFalses) {fNFalseDataQualityFlag = nFalses;}
165         Int_t GetNFalseDataQualityFlag() const {return fNFalseDataQualityFlag;}
166
167         void SetFalseDataQualityFlagPeriods(Double_t* falses);
168         TArrayD* GetFalseDataQualityFlagPeriods() const {return fFalseDataQualityFlag;}
169
170         Double_t GetStartFalseDataQualityFlag(Int_t iperiod) const;
171         Double_t GetEndFalseDataQualityFlag(Int_t iperiod) const;
172
173         void SetBeamTypeFromLHC(TString beamTypeFromLHC)  {fBeamTypeFromLHC = beamTypeFromLHC;}
174         TString   GetBeamTypeFromLHC() const {return fBeamTypeFromLHC;}
175
176  private:
177
178         static const Float_t fgkInvalidFloat;   // value to identify invalid data - float
179         static const TString fgkInvalidString;  // value to identify invalid data - string
180         static const Char_t fgkInvalidChar;     // value to identify invalid data - char
181         static const Int_t fgkInvalidInt;       // value to identify invalid data - int
182         static const Int_t fgkInvalidUInt;       // value to identify invalid data - uint
183         static const Int_t   fgknDCSDPHallProbes;               //! number of dcs dps
184         static const char*   fgkDCSDataPointsHallProbes[];      //! names of dcs dps
185
186         Int_t fPoints;                    // number of statistical quantities to be stored
187         Int_t fDimension;                 // dimension of Hall Probes array
188
189         time_t   fTimeStart;              // DAQ_time_start entry from DAQ logbook
190         time_t   fTimeEnd;                // DAQ_time_end entry from DAQ logbook
191         Float_t  fBeamEnergy;             // beamEnergy entry from DAQ logbook
192         TString  fBeamType;               // beamType entry from DAQ logbook
193         Char_t   fNumberOfDetectors;      // numberOfDetectors entry from DAQ logbook
194         UInt_t   fDetectorMask;           // detectorMask entry from DAQ logbook
195         TString  fLHCPeriod;              // LHCperiod entry from DAQ logbook 
196         TString  fRunType;                // RunType entry from DAQ logbook 
197         TString  fLHCState;               // LHCState entry from DCS DB
198         Char_t    fL3Polarity;            // L3Polarity entry from DCS DB
199         Char_t    fDipolePolarity;        // DipolePolarity entry from DCS DB                                     
200         Float_t*  fL3Current;             // [fPoints]
201                                           // L3Current entry from DCS DB
202         Float_t*  fDipoleCurrent;         // [fPoints]
203                                           // DipoleCurrent entry from DCS DB
204         Float_t*  fCavernTemperature;     // [fPoints]
205                                           // CavernTemperature entry from DCS DB
206         AliDCSSensor*  fCavernAtmosPressure;    // CavernAtmosPressure entry from DCS DB
207         AliDCSSensor*  fCavernAtmosPressure2;    // CavernAtmosPressure2 entry from DCS DB
208         AliDCSSensor*  fSurfaceAtmosPressure;   // SurfaceAtmosPressure entry from DCS DB
209
210         // Hall Probes
211
212         Float_t* fHallProbes;       //[fDimension] 
213                                     // array containg the values for the Hall Probes
214
215         TString  fMachineMode;      // Machine Mode from LHC
216         TObjArray* fLHCStateArray;     // Array of values for the LHC State
217         TObjArray* fMachineModeArray;  // Array of values for the LHC State
218         TObjArray* fQATrigClasses;     // RS: Array of trigger class to watch in QA
219         TObjArray* fQACloningRequest;  // RS: Array of cloning requests for QA histos
220         Double_t fMaxTimeLHCValidity;    // time until which the LHC Data Machine Mode and Beam Mode didn't change 
221         TString  fSeparateBeamType[2];   // separate beam Types from LHC
222         Int_t fNFalseDataQualityFlag;    // number of times the data quality flag turned to FALSE
223         TArrayD* fFalseDataQualityFlag;  // array of starts (even positions) and ends (odd poistions) of the periods
224                                          // when the data quality flag was FALSE
225         TString fBeamTypeFromLHC;        // string containing the information about the beam types AS SENT BY LHC (in the form "beam1-beam2")
226         
227         ClassDef(AliGRPObject,10)
228
229 };
230
231 #endif