Merge branch 'master' into TPCdev
[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         fBeamTypeFromLHC(fgkInvalidString)
118 {
119
120         //
121         // AliGRPObject default ctor
122         //
123
124         fDimension = fgknDCSDPHallProbes*fPoints;
125         fHallProbes = new Float_t[fDimension];
126
127         for (Int_t nhp=0; nhp< fDimension; nhp++){ // setting to zero values for non working HP 
128                 if ((nhp >= 0 && nhp <= 1*fPoints-1) || // L3_BSF17_H1
129                     (nhp >= 1*fPoints && nhp <= 2*fPoints-1) || // L3_BSF17_H2
130                     (nhp >= 2*fPoints && nhp <= 3*fPoints-1) || // L3_BSF17_H3
131                     (nhp >= 3*fPoints && nhp <= 4*fPoints-1) || // L3_BSF17_Temperature
132                     (nhp >= 6*fPoints && nhp <= 7*fPoints-1) ) { // L3_BSF4_H3
133                         fHallProbes[nhp] = 0; // setting to zero values for non working HP 
134                         AliDebug(2,Form("setting hp[%d] to zero = %f", 
135 nhp, fHallProbes[nhp]));
136                 }
137                 else {
138                         fHallProbes[nhp] = fgkInvalidFloat;
139                 }
140         }
141
142
143         for (Int_t i = 0; i < fPoints; i++){
144
145                 fL3Current[i] = fgkInvalidFloat;
146                 fDipoleCurrent[i] = fgkInvalidFloat;
147                 fCavernTemperature[i] = fgkInvalidFloat;
148         }
149
150         for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
151                 fSeparateBeamType[ibeamType] = fgkInvalidString;
152         }
153 }
154
155 //-----------------------------------------------------------------------------
156
157 AliGRPObject::AliGRPObject(const AliGRPObject &obj):
158         TObject(obj),
159         fPoints(obj.fPoints),
160         fDimension(obj.fDimension),
161         fTimeStart(obj.fTimeStart),
162         fTimeEnd(obj.fTimeEnd),
163         fBeamEnergy(obj.fBeamEnergy),
164         fBeamType(obj.fBeamType),
165         fNumberOfDetectors(obj.fNumberOfDetectors),
166         fDetectorMask(obj.fDetectorMask),
167         fLHCPeriod(obj.fLHCPeriod),
168         fRunType(obj.fRunType),
169         fLHCState(obj.fLHCState),
170         fL3Polarity(obj.fL3Polarity),
171         fDipolePolarity(obj.fDipolePolarity),
172         fL3Current(new Float_t[fPoints]),
173         fDipoleCurrent(new Float_t[fPoints]),
174         fCavernTemperature(new Float_t[fPoints]),
175         fCavernAtmosPressure(obj.fCavernAtmosPressure),
176         fCavernAtmosPressure2(obj.fCavernAtmosPressure2),
177         fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),
178         fHallProbes(0x0),
179         fMachineMode(obj.fMachineMode),
180         fLHCStateArray(obj.fLHCStateArray),
181         fMachineModeArray(obj.fMachineModeArray),
182         fQATrigClasses(obj.fQATrigClasses),
183         fQACloningRequest(obj.fQACloningRequest),
184         fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity),
185         fNFalseDataQualityFlag(obj.fNFalseDataQualityFlag),
186         fFalseDataQualityFlag(obj.fFalseDataQualityFlag),
187         fBeamTypeFromLHC(obj.fBeamTypeFromLHC)
188
189
190 {
191
192         //
193         // AliGRPObject copy ctor
194         //
195
196         fHallProbes = new Float_t[fDimension]; 
197
198         for (Int_t nhp=0; nhp< fDimension; nhp++){
199                 fHallProbes[nhp] = obj.fHallProbes[nhp];
200         }
201
202         for (Int_t i = 0; i < fPoints; i++){
203
204                 fL3Current[i] = obj.fL3Current[i];
205                 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
206                 fCavernTemperature[i] = obj.fCavernTemperature[i];
207         }
208
209         for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
210                 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
211         }
212 }
213
214 //-----------------------------------------------------------------------------
215
216 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj) 
217 {
218
219         //
220         // AliGRPObject assignment operator
221         //
222
223         if (&obj == this) return *this; 
224
225         TObject::operator=(obj);
226         this->fTimeStart = obj.GetTimeStart();
227         this->fTimeEnd = obj.GetTimeEnd();
228         this->fBeamEnergy = obj.GetBeamEnergy();
229         this->fBeamType = obj.GetBeamType();
230         this->fNumberOfDetectors = obj.GetNumberOfDetectors();
231         this->fDetectorMask = obj.GetDetectorMask();
232         this->fLHCPeriod = obj.GetLHCPeriod();
233         this->fRunType = obj.GetRunType();
234         this->fLHCState = obj.GetLHCState();
235         this->fL3Polarity = obj.GetL3Polarity();
236         this->fDipolePolarity = obj.GetDipolePolarity();
237         this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();
238         this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();
239         this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();
240         this->fPoints = obj.GetPoints();
241         this->fDimension = obj.GetDimension();
242
243         this->fL3Current = new Float_t[fPoints];
244         this->fDipoleCurrent = new Float_t[fPoints];
245         this->fCavernTemperature = new Float_t[fPoints];
246         
247         if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension]; 
248         for (Int_t nhp=0; nhp< fDimension; nhp++){
249                 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);
250
251         }
252         for (Int_t i = 0; i < fPoints; i++){
253
254                 this->fL3Current[i] = obj.GetL3Current((Stats)i);
255                 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
256                 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
257         }
258
259         this->fMachineMode = obj.fMachineMode;
260         this->fLHCStateArray = obj.fLHCStateArray;
261         this->fMachineModeArray = obj.fMachineModeArray;
262         this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
263
264         this->fQATrigClasses = obj.fQATrigClasses;
265         this->fQACloningRequest = obj.fQACloningRequest;
266
267         for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
268                 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
269         }
270
271         this->fNFalseDataQualityFlag = obj.fNFalseDataQualityFlag;
272         this->fFalseDataQualityFlag = obj.fFalseDataQualityFlag;
273         this->fBeamTypeFromLHC = obj.fBeamTypeFromLHC;
274
275         return *this;
276 }
277
278 //-----------------------------------------------------------------------------
279
280 AliGRPObject::~AliGRPObject() {
281
282         //
283         // dtor
284         //
285
286         
287         delete [] fHallProbes;
288         delete [] fL3Current;
289         delete [] fDipoleCurrent;
290         delete [] fCavernTemperature;
291
292         if (fCavernAtmosPressure){
293                 delete fCavernAtmosPressure;
294                 fCavernAtmosPressure = 0x0;
295         }
296         if (fCavernAtmosPressure2){
297                 delete fCavernAtmosPressure2;
298                 fCavernAtmosPressure2 = 0x0;
299         }
300         if (fSurfaceAtmosPressure){
301                 delete fSurfaceAtmosPressure;
302                 fSurfaceAtmosPressure = 0x0;
303         }
304         if (fLHCStateArray){
305                 delete fLHCStateArray;
306                 fLHCStateArray = 0x0;
307         }
308         if (fMachineModeArray){
309                 delete fMachineModeArray;
310                 fMachineModeArray = 0x0;
311         }
312         if (fQATrigClasses) {
313           delete fQATrigClasses;
314           fQATrigClasses = 0x0;
315         }
316         if (fQACloningRequest) {
317           delete fQACloningRequest;
318           fQACloningRequest = 0x0;
319         }
320         if (fFalseDataQualityFlag){
321                 delete fFalseDataQualityFlag;
322                 fFalseDataQualityFlag = 0x0;
323         }
324 }
325
326 //-----------------------------------------------------------------------------
327 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
328
329         //
330         // method to return array of statistical
331         // variables for Hall Probe hp
332         //
333
334         Float_t* array = new Float_t[fPoints];
335         Int_t shift = fPoints*(Int_t)hp; 
336         for (Int_t i=0;i<fPoints; i++){
337
338                 array[i] = fHallProbes[shift+i];
339
340         }
341
342         return array;
343 }
344 //-------------------------------------------------------------------------------
345
346 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
347
348         //
349         // method to set hall probe hp 
350         // from a given array
351         //
352
353         Int_t shift = fPoints*hp;
354         for (Int_t i = 0; i< fPoints; i++){
355
356                 fHallProbes[i+shift] =  hall_probe[i];
357         }
358         return;
359 }
360
361 //-------------------------------------------------------------------------------
362
363 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
364
365         //
366         // method to set the values of the GRP parameters 
367         // reading them from the old format of the GRP 
368         // object, i.e. a TMap
369         //
370
371         if (mapGRP->GetValue("fAliceStartTime")){
372                 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
373         }
374         else {
375                 AliError(Form("No fAliceStartTime value found in GRP map!"));
376         }
377         if (mapGRP->GetValue("fAliceStopTime")){
378                 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
379         }
380         
381         else { 
382                 AliError(Form("No fAliceStopTime value found in GRP map!"));
383         }
384
385         if(mapGRP->GetValue("fAliceBeamEnergy")){
386           double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();
387           if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2;   // old format was storig sqrt(s)
388           SetBeamEnergy(be);
389         }
390         else { 
391                 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
392         }
393         if(mapGRP->GetValue("fAliceBeamType")){
394                 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
395         }
396         else { 
397                 AliError(Form("No fAliceBeamType value found in GRP map!"));
398         }
399         if(mapGRP->GetValue("fNumberOfDetectors")){
400                 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi()); 
401                 AliDebug(1, Form("fNumberOfDetectors = %d", fNumberOfDetectors));
402         }
403         else { 
404                 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
405         }
406         if(mapGRP->GetValue("fDetectorMask")){
407                 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());  
408                 AliDebug(1, Form("fDetectorMask = %d",fDetectorMask));
409         }
410         else { 
411                 AliError(Form("No fDetectorMask value found in GRP map!"));
412         }
413         if(mapGRP->GetValue("fLHCPeriod")){
414                 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
415         }
416         else { 
417                 AliError(Form("No fLHCPeriod value found in GRP map!"));
418         }
419         if(mapGRP->GetValue("fRunType")){
420                 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
421         }
422         else { 
423                 AliError(Form("No fRunType value found in GRP map!"));
424         }
425         if(mapGRP->GetValue("fLHCState")){
426                 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
427         }
428         else { 
429                 AliError(Form("No fLHCState value found in GRP map!"));
430         }
431         if(mapGRP->GetValue("fLHCluminosity")){
432                 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
433         }       
434         else { 
435                 AliError(Form("No fLHCLuminosity value found in GRP map!"));
436         }
437         if(mapGRP->GetValue("fBeamIntensity")){
438                 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
439         }       
440         else { 
441                 AliError(Form("No fBeamIntensity value found in GRP map!"));
442         }
443         if(mapGRP->GetValue("fL3Polarity")){
444                 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
445         }       
446         else { 
447                 AliError(Form("No fL3Polarity value found in GRP map!"));
448         }
449         if(mapGRP->GetValue("fDipolePolarity")){
450                 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());  
451         }       
452         else { 
453                 AliError(Form("No fDipolePolarity value found in GRP map!"));
454         }
455         if(mapGRP->GetValue("fL3Current")){
456                 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));
457                 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);
458         }       
459         else { 
460                 AliError(Form("No fL3Current value found in GRP map!"));
461         }
462         if(mapGRP->GetValue("fDipoleCurrent")){
463                 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));
464                 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);
465         }       
466         else { 
467                 AliError(Form("No fDipoleCurrent value found in GRP map!"));
468         }
469         if(mapGRP->GetValue("fCavernTemperature")){
470                 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));
471                 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);
472         }       
473         else { 
474                 AliError(Form("No fCavernTemperature value found in GRP map!"));
475         }
476         if(mapGRP->GetValue("fCavernAtmosPressure")){
477                 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
478         }       
479         else { 
480                 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
481         }
482         if(mapGRP->GetValue("fP2Pressure")){
483                 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
484         }
485         else { 
486                 AliError(Form("No fP2Pressure value found in GRP map!"));
487         }
488         
489         return;
490
491 }
492 //-------------------------------------------------------------------------------
493
494 Float_t AliGRPObject::GetBeamEnergy() const {
495
496         //
497         // Getting the energy
498         // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
499         //
500
501         Float_t energy = fBeamEnergy;
502         if (fBeamType=="A-A"){
503                 energy = energy*82./208;
504         }
505         return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
506 }
507
508 //-------------------------------------------------------------------------------
509
510 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const { 
511 //
512 //  Return current pressure value from 'best' cavern sensor
513 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
514 //     use sensor most compatible with surface sensor
515
516   return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
517              fSurfaceAtmosPressure,time,inside);
518                                 
519 }
520
521 //-------------------------------------------------------------------------------
522
523 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1, 
524                       AliDCSSensor* cavern2, AliDCSSensor* surface, 
525                       const TTimeStamp& time, Bool_t& inside)  {
526 //
527 //  Return current pressure value from 'best' cavern sensor
528 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
529 //     use sensor most compatible with surface sensor
530
531      
532     Double_t valueSensor2 = cavern2->Eval(time,inside);
533     Double_t valueSensor1 = cavern1->Eval(time,inside);
534     if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
535         return valueSensor2;
536     } else { 
537         Double_t valueSurface = surface->Eval(time,inside);
538         Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
539         Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
540         if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
541             return valueSensor1;
542         } else {
543             return valueSensor2;
544         }
545      }
546 }
547
548 //-------------------------------------------------------------------------------
549
550 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1, 
551              AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
552
553 //
554 //  Return pointer to 'best' cavern sensor
555 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
556 //     use sensor most compatible with surface sensor
557 //    Pressure measuread at time specified by TTimestamp
558
559
560     Bool_t inside; 
561     Double_t valueSensor2 = cavern2->Eval(time,inside);
562     Double_t valueSensor1 = cavern1->Eval(time,inside);
563     if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
564         return cavern2;
565     } else { 
566         Double_t valueSurface = surface->Eval(time,inside);
567         Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
568         Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
569         if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
570             return cavern1;
571         } else {
572             return cavern2;
573         }
574      }
575 }
576
577 //-------------------------------------------------------------------------------
578
579 AliDCSSensor*   AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
580 //
581 //  Return pointer to 'best' cavern sensor
582 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
583 //     use sensor most compatible with surface sensor
584 //    Pressure measuread at time specified by TTimestamp
585
586
587    return GetBestCavernAtmosPressure(fCavernAtmosPressure,
588         fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
589
590 }
591     
592 //-------------------------------------------------------------------------------
593
594 AliDCSSensor*   AliGRPObject::GetBestCavernAtmosPressure() const {
595 //
596 //  Return pointer to 'best' cavern sensor
597 //    (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
598 //     use sensor most compatible with surface sensor
599 //    Pressure measuread at start-of-run
600
601    return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));
602 }
603
604 //-------------------------------------------------------------------------------
605 void AliGRPObject::SetFalseDataQualityFlagPeriods(Double_t* falses){
606         
607         //
608         // setting the starts (even positions in the array) and ends (odd positions in the array)
609         // of the periods when the Data Quality Flag was set to FALSE
610         //
611         
612         fFalseDataQualityFlag = new TArrayD(fNFalseDataQualityFlag*2,falses);
613 }
614
615 //-------------------------------------------------------------------------------
616 Double_t AliGRPObject::GetStartFalseDataQualityFlag(Int_t iperiod) const {
617         
618         // 
619         // returning the start timestamp of the FALSE period "iperiod"
620         //
621         
622         if (iperiod < fNFalseDataQualityFlag){
623                 return fFalseDataQualityFlag->At(iperiod*2);
624         }
625         else{
626                 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
627         }
628         return -1.;
629 }
630
631 //-------------------------------------------------------------------------------
632 Double_t AliGRPObject::GetEndFalseDataQualityFlag(Int_t iperiod) const {
633         
634         // 
635         // returning the end timestamp of the FALSE period "iperiod"
636         //
637         
638         if (iperiod < fNFalseDataQualityFlag){
639                 return fFalseDataQualityFlag->At(iperiod*2+1);
640         }
641         else{
642                 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
643         }
644         return -1.;
645 }