Adding processing of Data Quality Flag coming from LHC Data File.
[u/mrichter/AliRoot.git] / STEER / STEER / AliGRPObject.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 // **********************
19 // Class containing the GRP data that have to be stored in the OCDB.
20 // Data come either from DAQ logbook or from DCS DB.
21 // Processing of the data can also be performed here.
22 // **********************
23
24 #include <TMap.h>
25 #include <TObject.h>
26 #include <TObjString.h>
27
28 #include "AliGRPObject.h"
29 #include "AliDCSSensor.h"
30 #include "AliLog.h"
31
32 ClassImp(AliGRPObject)
33
34 const Double_t kCavernCut = 1.0;           // tolerable difference between cavern pressure sensors
35 const Double_t kSurfaceDifference = 4.5;   //  offset between surface and cavern pressure sensors
36         
37 const Float_t AliGRPObject::fgkInvalidFloat = 1E-33; // value to identify invalid data - float
38 const TString AliGRPObject::fgkInvalidString = "";  // value to identify invalid data - string
39 const Char_t AliGRPObject::fgkInvalidChar = -1;         // value to identify invalid data - uchar
40 const Int_t AliGRPObject::fgkInvalidInt = -1;  // value to identify invalid data - uint
41 const Int_t AliGRPObject::fgkInvalidUInt = 0;  // value to identify invalid data - uint
42 const Int_t AliGRPObject::fgknDCSDPHallProbes = 40;   // number of dcs dps
43 const char* AliGRPObject::fgkDCSDataPointsHallProbes[AliGRPObject::fgknDCSDPHallProbes] = {
44                    "L3_BSF17_H1",
45                    "L3_BSF17_H2",
46                    "L3_BSF17_H3",
47                    "L3_BSF17_Temperature",
48                    "L3_BSF4_H1",
49                    "L3_BSF4_H2",
50                    "L3_BSF4_H3",
51                    "L3_BSF4_Temperature",
52                    "L3_BKF17_H1",
53                    "L3_BKF17_H2",
54                    "L3_BKF17_H3",
55                    "L3_BKF17_Temperature",
56                    "L3_BKF4_H1",
57                    "L3_BKF4_H2",
58                    "L3_BKF4_H3",
59                    "L3_BKF4_Temperature",
60                    "L3_BSF13_H1",
61                    "L3_BSF13_H2",
62                    "L3_BSF13_H3",
63                    "L3_BSF13_Temperature",
64                    "L3_BSF8_H1",
65                    "L3_BSF8_H2",
66                    "L3_BSF8_H3",
67                    "L3_BSF8_Temperature",
68                    "L3_BKF13_H1",
69                    "L3_BKF13_H2",
70                    "L3_BKF13_H3",
71                    "L3_BKF13_Temperature",
72                    "L3_BKF8_H1",
73                    "L3_BKF8_H2",
74                    "L3_BKF8_H3",
75                    "L3_BKF8_Temperature",
76                    "Dipole_Inside_H1",
77                    "Dipole_Inside_H2",
78                    "Dipole_Inside_H3",
79                    "Dipole_Inside_Temperature",
80                    "Dipole_Outside_H1",
81                    "Dipole_Outside_H2",
82                    "Dipole_Outside_H3",
83                    "Dipole_Outside_Temperature",
84                  };
85
86 //-----------------------------------------------------------------------------
87 AliGRPObject::AliGRPObject():
88         TObject(),
89         fPoints(5),
90         fDimension(0),
91         fTimeStart((time_t)fgkInvalidFloat),
92         fTimeEnd((time_t)fgkInvalidFloat),
93         fBeamEnergy(fgkInvalidFloat),
94         fBeamType(fgkInvalidString),
95         fNumberOfDetectors(fgkInvalidChar),
96         fDetectorMask(fgkInvalidUInt),
97         fLHCPeriod(fgkInvalidString),
98         fRunType(fgkInvalidString),
99         fLHCState(fgkInvalidString),
100         fL3Polarity(fgkInvalidChar),
101         fDipolePolarity(fgkInvalidChar),
102         fL3Current(new Float_t[fPoints]),
103         fDipoleCurrent(new Float_t[fPoints]),
104         fCavernTemperature(new Float_t[fPoints]),
105         fCavernAtmosPressure(0x0),
106         fCavernAtmosPressure2(0x0),
107         fSurfaceAtmosPressure(0x0),
108         fHallProbes(0x0),
109         fMachineMode(fgkInvalidString),
110         fLHCStateArray(0x0),
111         fMachineModeArray(0x0),
112         fQATrigClasses(0x0),
113         fQACloningRequest(0x0),
114         fMaxTimeLHCValidity(0),
115         fNFalseDataQualityFlag(0),
116         fFalseDataQualityFlag(0x0)
117 {
118
119         //
120         // AliGRPObject default ctor
121         //
122
123         fDimension = fgknDCSDPHallProbes*fPoints;
124         fHallProbes = new Float_t[fDimension];
125
126         for (Int_t nhp=0; nhp< fDimension; nhp++){ // setting to zero values for non working HP 
127                 if ((nhp >= 0 && nhp <= 1*fPoints-1) || // L3_BSF17_H1
128                     (nhp >= 1*fPoints && nhp <= 2*fPoints-1) || // L3_BSF17_H2
129                     (nhp >= 2*fPoints && nhp <= 3*fPoints-1) || // L3_BSF17_H3
130                     (nhp >= 3*fPoints && nhp <= 4*fPoints-1) || // L3_BSF17_Temperature
131                     (nhp >= 6*fPoints && nhp <= 7*fPoints-1) ) { // L3_BSF4_H3
132                         fHallProbes[nhp] = 0; // setting to zero values for non working HP 
133                         AliDebug(2,Form("setting hp[%d] to zero = %f", 
134 nhp, fHallProbes[nhp]));
135                 }
136                 else {
137                         fHallProbes[nhp] = fgkInvalidFloat;
138                 }
139         }
140
141
142         for (Int_t i = 0; i < fPoints; i++){
143
144                 fL3Current[i] = fgkInvalidFloat;
145                 fDipoleCurrent[i] = fgkInvalidFloat;
146                 fCavernTemperature[i] = fgkInvalidFloat;
147         }
148
149         for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
150                 fSeparateBeamType[ibeamType] = fgkInvalidString;
151         }
152 }
153
154 //-----------------------------------------------------------------------------
155
156 AliGRPObject::AliGRPObject(const AliGRPObject &obj):
157         TObject(obj),
158         fPoints(obj.fPoints),
159         fDimension(obj.fDimension),
160         fTimeStart(obj.fTimeStart),
161         fTimeEnd(obj.fTimeEnd),
162         fBeamEnergy(obj.fBeamEnergy),
163         fBeamType(obj.fBeamType),
164         fNumberOfDetectors(obj.fNumberOfDetectors),
165         fDetectorMask(obj.fDetectorMask),
166         fLHCPeriod(obj.fLHCPeriod),
167         fRunType(obj.fRunType),
168         fLHCState(obj.fLHCState),
169         fL3Polarity(obj.fL3Polarity),
170         fDipolePolarity(obj.fDipolePolarity),
171         fL3Current(new Float_t[fPoints]),
172         fDipoleCurrent(new Float_t[fPoints]),
173         fCavernTemperature(new Float_t[fPoints]),
174         fCavernAtmosPressure(obj.fCavernAtmosPressure),
175         fCavernAtmosPressure2(obj.fCavernAtmosPressure2),
176         fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),
177         fHallProbes(0x0),
178         fMachineMode(obj.fMachineMode),
179         fLHCStateArray(obj.fLHCStateArray),
180         fMachineModeArray(obj.fMachineModeArray),
181         fQATrigClasses(obj.fQATrigClasses),
182         fQACloningRequest(obj.fQACloningRequest),
183         fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity),
184         fNFalseDataQualityFlag(obj.fNFalseDataQualityFlag),
185         fFalseDataQualityFlag(obj.fFalseDataQualityFlag)
186
187
188 {
189
190         //
191         // AliGRPObject copy ctor
192         //
193
194         fHallProbes = new Float_t[fDimension]; 
195
196         for (Int_t nhp=0; nhp< fDimension; nhp++){
197                 fHallProbes[nhp] = obj.fHallProbes[nhp];
198         }
199
200         for (Int_t i = 0; i < fPoints; i++){
201
202                 fL3Current[i] = obj.fL3Current[i];
203                 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
204                 fCavernTemperature[i] = obj.fCavernTemperature[i];
205         }
206
207         for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
208                 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
209         }
210 }
211
212 //-----------------------------------------------------------------------------
213
214 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj) 
215 {
216
217         //
218         // AliGRPObject assignment operator
219         //
220
221         if (&obj == this) return *this; 
222
223         TObject::operator=(obj);
224         this->fTimeStart = obj.GetTimeStart();
225         this->fTimeEnd = obj.GetTimeEnd();
226         this->fBeamEnergy = obj.GetBeamEnergy();
227         this->fBeamType = obj.GetBeamType();
228         this->fNumberOfDetectors = obj.GetNumberOfDetectors();
229         this->fDetectorMask = obj.GetDetectorMask();
230         this->fLHCPeriod = obj.GetLHCPeriod();
231         this->fRunType = obj.GetRunType();
232         this->fLHCState = obj.GetLHCState();
233         this->fL3Polarity = obj.GetL3Polarity();
234         this->fDipolePolarity = obj.GetDipolePolarity();
235         this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();
236         this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();
237         this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();
238         this->fPoints = obj.GetPoints();
239         this->fDimension = obj.GetDimension();
240
241         this->fL3Current = new Float_t[fPoints];
242         this->fDipoleCurrent = new Float_t[fPoints];
243         this->fCavernTemperature = new Float_t[fPoints];
244         
245         if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension]; 
246         for (Int_t nhp=0; nhp< fDimension; nhp++){
247                 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);
248
249         }
250         for (Int_t i = 0; i < fPoints; i++){
251
252                 this->fL3Current[i] = obj.GetL3Current((Stats)i);
253                 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
254                 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
255         }
256
257         this->fMachineMode = obj.fMachineMode;
258         this->fLHCStateArray = obj.fLHCStateArray;
259         this->fMachineModeArray = obj.fMachineModeArray;
260         this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
261
262         this->fQATrigClasses = obj.fQATrigClasses;
263         this->fQACloningRequest = obj.fQACloningRequest;
264
265         for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
266                 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
267         }
268
269         this->fNFalseDataQualityFlag = obj.fNFalseDataQualityFlag;
270         this->fFalseDataQualityFlag = obj.fFalseDataQualityFlag;
271
272         return *this;
273 }
274
275 //-----------------------------------------------------------------------------
276
277 AliGRPObject::~AliGRPObject() {
278
279         //
280         // dtor
281         //
282
283         
284         delete [] fHallProbes;
285         delete [] fL3Current;
286         delete [] fDipoleCurrent;
287         delete [] fCavernTemperature;
288
289         if (fCavernAtmosPressure){
290                 delete fCavernAtmosPressure;
291                 fCavernAtmosPressure = 0x0;
292         }
293         if (fCavernAtmosPressure2){
294                 delete fCavernAtmosPressure2;
295                 fCavernAtmosPressure2 = 0x0;
296         }
297         if (fSurfaceAtmosPressure){
298                 delete fSurfaceAtmosPressure;
299                 fSurfaceAtmosPressure = 0x0;
300         }
301         if (fLHCStateArray){
302                 delete fLHCStateArray;
303                 fLHCStateArray = 0x0;
304         }
305         if (fMachineModeArray){
306                 delete fMachineModeArray;
307                 fMachineModeArray = 0x0;
308         }
309         if (fQATrigClasses) {
310           delete fQATrigClasses;
311           fQATrigClasses = 0x0;
312         }
313         if (fQACloningRequest) {
314           delete fQACloningRequest;
315           fQACloningRequest = 0x0;
316         }
317         if (fFalseDataQualityFlag){
318                 delete fFalseDataQualityFlag;
319                 fFalseDataQualityFlag = 0x0;
320         }
321 }
322
323 //-----------------------------------------------------------------------------
324 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
325
326         //
327         // method to return array of statistical
328         // variables for Hall Probe hp
329         //
330
331         Float_t* array = new Float_t[fPoints];
332         Int_t shift = fPoints*(Int_t)hp; 
333         for (Int_t i=0;i<fPoints; i++){
334
335                 array[i] = fHallProbes[shift+i];
336
337         }
338
339         return array;
340 }
341 //-------------------------------------------------------------------------------
342
343 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
344
345         //
346         // method to set hall probe hp 
347         // from a given array
348         //
349
350         Int_t shift = fPoints*hp;
351         for (Int_t i = 0; i< fPoints; i++){
352
353                 fHallProbes[i+shift] =  hall_probe[i];
354         }
355         return;
356 }
357
358 //-------------------------------------------------------------------------------
359
360 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
361
362         //
363         // method to set the values of the GRP parameters 
364         // reading them from the old format of the GRP 
365         // object, i.e. a TMap
366         //
367
368         if (mapGRP->GetValue("fAliceStartTime")){
369                 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
370         }
371         else {
372                 AliError(Form("No fAliceStartTime value found in GRP map!"));
373         }
374         if (mapGRP->GetValue("fAliceStopTime")){
375                 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
376         }
377         
378         else { 
379                 AliError(Form("No fAliceStopTime value found in GRP map!"));
380         }
381
382         if(mapGRP->GetValue("fAliceBeamEnergy")){
383           double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();
384           if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2;   // old format was storig sqrt(s)
385           SetBeamEnergy(be);
386         }
387         else { 
388                 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
389         }
390         if(mapGRP->GetValue("fAliceBeamType")){
391                 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
392         }
393         else { 
394                 AliError(Form("No fAliceBeamType value found in GRP map!"));
395         }
396         if(mapGRP->GetValue("fNumberOfDetectors")){
397                 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi()); 
398         }
399         else { 
400                 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
401         }
402         if(mapGRP->GetValue("fDetectorMask")){
403                 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());  
404         }
405         else { 
406                 AliError(Form("No fDetectorMask value found in GRP map!"));
407         }
408         if(mapGRP->GetValue("fLHCPeriod")){
409                 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
410         }
411         else { 
412                 AliError(Form("No fLHCPeriod value found in GRP map!"));
413         }
414         if(mapGRP->GetValue("fRunType")){
415                 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
416         }
417         else { 
418                 AliError(Form("No fRunType value found in GRP map!"));
419         }
420         if(mapGRP->GetValue("fLHCState")){
421                 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
422         }
423         else { 
424                 AliError(Form("No fLHCState value found in GRP map!"));
425         }
426         if(mapGRP->GetValue("fLHCluminosity")){
427                 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
428         }       
429         else { 
430                 AliError(Form("No fLHCLuminosity value found in GRP map!"));
431         }
432         if(mapGRP->GetValue("fBeamIntensity")){
433                 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
434         }       
435         else { 
436                 AliError(Form("No fBeamIntensity value found in GRP map!"));
437         }
438         if(mapGRP->GetValue("fL3Polarity")){
439                 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
440         }       
441         else { 
442                 AliError(Form("No fL3Polarity value found in GRP map!"));
443         }
444         if(mapGRP->GetValue("fDipolePolarity")){
445                 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());  
446         }       
447         else { 
448                 AliError(Form("No fDipolePolarity value found in GRP map!"));
449         }
450         if(mapGRP->GetValue("fL3Current")){
451                 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));
452                 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);
453         }       
454         else { 
455                 AliError(Form("No fL3Current value found in GRP map!"));
456         }
457         if(mapGRP->GetValue("fDipoleCurrent")){
458                 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));
459                 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);
460         }       
461         else { 
462                 AliError(Form("No fDipoleCurrent value found in GRP map!"));
463         }
464         if(mapGRP->GetValue("fCavernTemperature")){
465                 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));
466                 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);
467         }       
468         else { 
469                 AliError(Form("No fCavernTemperature value found in GRP map!"));
470         }
471         if(mapGRP->GetValue("fCavernAtmosPressure")){
472                 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
473         }       
474         else { 
475                 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
476         }
477         if(mapGRP->GetValue("fP2Pressure")){
478                 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
479         }
480         else { 
481                 AliError(Form("No fP2Pressure value found in GRP map!"));
482         }
483         
484         return;
485
486 }
487 //-------------------------------------------------------------------------------
488
489 Float_t AliGRPObject::GetBeamEnergy() const {
490
491         //
492         // Getting the energy
493         // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
494         //
495
496         Float_t energy = fBeamEnergy;
497         if (fBeamType=="A-A"){
498                 energy = energy*82./208;
499         }
500         return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
501 }
502
503 //-------------------------------------------------------------------------------
504
505 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const { 
506 //
507 //  Return current pressure value from 'best' cavern sensor
508 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
509 //     use sensor most compatible with surface sensor
510
511   return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
512              fSurfaceAtmosPressure,time,inside);
513                                 
514 }
515
516 //-------------------------------------------------------------------------------
517
518 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1, 
519                       AliDCSSensor* cavern2, AliDCSSensor* surface, 
520                       const TTimeStamp& time, Bool_t& inside)  {
521 //
522 //  Return current pressure value from 'best' cavern sensor
523 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
524 //     use sensor most compatible with surface sensor
525
526      
527     Double_t valueSensor2 = cavern2->Eval(time,inside);
528     Double_t valueSensor1 = cavern1->Eval(time,inside);
529     if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
530         return valueSensor2;
531     } else { 
532         Double_t valueSurface = surface->Eval(time,inside);
533         Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
534         Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
535         if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
536             return valueSensor1;
537         } else {
538             return valueSensor2;
539         }
540      }
541 }
542
543 //-------------------------------------------------------------------------------
544
545 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1, 
546              AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
547
548 //
549 //  Return pointer to 'best' cavern sensor
550 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
551 //     use sensor most compatible with surface sensor
552 //    Pressure measuread at time specified by TTimestamp
553
554
555     Bool_t inside; 
556     Double_t valueSensor2 = cavern2->Eval(time,inside);
557     Double_t valueSensor1 = cavern1->Eval(time,inside);
558     if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
559         return cavern2;
560     } else { 
561         Double_t valueSurface = surface->Eval(time,inside);
562         Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
563         Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
564         if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
565             return cavern1;
566         } else {
567             return cavern2;
568         }
569      }
570 }
571
572 //-------------------------------------------------------------------------------
573
574 AliDCSSensor*   AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
575 //
576 //  Return pointer to 'best' cavern sensor
577 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
578 //     use sensor most compatible with surface sensor
579 //    Pressure measuread at time specified by TTimestamp
580
581
582    return GetBestCavernAtmosPressure(fCavernAtmosPressure,
583         fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
584
585 }
586     
587 //-------------------------------------------------------------------------------
588
589 AliDCSSensor*   AliGRPObject::GetBestCavernAtmosPressure() const {
590 //
591 //  Return pointer to 'best' cavern sensor
592 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
593 //     use sensor most compatible with surface sensor
594 //    Pressure measuread at start-of-run
595
596    return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));
597 }
598
599 //-------------------------------------------------------------------------------
600 void AliGRPObject::SetFalseDataQualityFlagPeriods(Double_t* falses){
601         
602         //
603         // setting the starts (even positions in the array) and ends (odd positions in the array)
604         // of the periods when the Data Quality Flag was set to FALSE
605         //
606         
607         fFalseDataQualityFlag = new TArrayD(fNFalseDataQualityFlag*2,falses);
608 }
609
610 //-------------------------------------------------------------------------------
611 Double_t AliGRPObject::GetStartFalseDataQualityFlag(Int_t iperiod) const {
612         
613         // 
614         // returning the start timestamp of the FALSE period "iperiod"
615         //
616         
617         if (iperiod < fNFalseDataQualityFlag){
618                 return fFalseDataQualityFlag->At(iperiod*2);
619         }
620         else{
621                 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
622         }
623         return -1.;
624 }
625
626 //-------------------------------------------------------------------------------
627 Double_t AliGRPObject::GetEndFalseDataQualityFlag(Int_t iperiod) const {
628         
629         // 
630         // returning the end timestamp of the FALSE period "iperiod"
631         //
632         
633         if (iperiod < fNFalseDataQualityFlag){
634                 return fFalseDataQualityFlag->At(iperiod*2+1);
635         }
636         else{
637                 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
638         }
639         return -1.;
640 }