]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliGRPObject.cxx
Avoiding generating errors due to missing non-working Data points - following discuss...
[u/mrichter/AliRoot.git] / STEER / AliGRPObject.cxx
1 /**************************************************************************\r
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3  *                                                                        *\r
4  * Author: The ALICE Off-line Project.                                    *\r
5  * Contributors are mentioned in the code where appropriate.              *\r
6  *                                                                        *\r
7  * Permission to use, copy, modify and distribute this software and its   *\r
8  * documentation strictly for non-commercial purposes is hereby granted   *\r
9  * without fee, provided that the above copyright notice appears in all   *\r
10  * copies and that both the copyright notice and this permission notice   *\r
11  * appear in the supporting documentation. The authors make no claims     *\r
12  * about the suitability of this software for any purpose. It is          *\r
13  * provided "as is" without express or implied warranty.                  *\r
14  **************************************************************************/\r
15 \r
16 /* $Id$ */\r
17 \r
18 // **********************\r
19 // Class containing the GRP data that have to be stored in the OCDB.\r
20 // Data come either from DAQ logbook or from DCS DB.\r
21 // Processing of the data can also be performed here.\r
22 // **********************\r
23 \r
24 #include <TMap.h>\r
25 #include <TObject.h>\r
26 #include <TObjString.h>\r
27 \r
28 #include "AliGRPObject.h"\r
29 #include "AliDCSSensor.h"\r
30 #include "AliLog.h"\r
31 \r
32 ClassImp(AliGRPObject)\r
33         \r
34 const Float_t AliGRPObject::fgkInvalidFloat = 1E-33; // value to identify invalid data - float\r
35 const TString AliGRPObject::fgkInvalidString = "";  // value to identify invalid data - string\r
36 const Char_t AliGRPObject::fgkInvalidChar = -1;         // value to identify invalid data - uchar\r
37 const Int_t AliGRPObject::fgkInvalidInt = -1;  // value to identify invalid data - uint\r
38 const Int_t AliGRPObject::fgkInvalidUInt = 0;  // value to identify invalid data - uint\r
39 const Int_t AliGRPObject::fgknDCSDPHallProbes = 40;   // number of dcs dps\r
40 const char* AliGRPObject::fgkDCSDataPointsHallProbes[AliGRPObject::fgknDCSDPHallProbes] = {\r
41                    "L3_BSF17_H1",\r
42                    "L3_BSF17_H2",\r
43                    "L3_BSF17_H3",\r
44                    "L3_BSF17_Temperature",\r
45                    "L3_BSF4_H1",\r
46                    "L3_BSF4_H2",\r
47                    "L3_BSF4_H3",\r
48                    "L3_BSF4_Temperature",\r
49                    "L3_BKF17_H1",\r
50                    "L3_BKF17_H2",\r
51                    "L3_BKF17_H3",\r
52                    "L3_BKF17_Temperature",\r
53                    "L3_BKF4_H1",\r
54                    "L3_BKF4_H2",\r
55                    "L3_BKF4_H3",\r
56                    "L3_BKF4_Temperature",\r
57                    "L3_BSF13_H1",\r
58                    "L3_BSF13_H2",\r
59                    "L3_BSF13_H3",\r
60                    "L3_BSF13_Temperature",\r
61                    "L3_BSF8_H1",\r
62                    "L3_BSF8_H2",\r
63                    "L3_BSF8_H3",\r
64                    "L3_BSF8_Temperature",\r
65                    "L3_BKF13_H1",\r
66                    "L3_BKF13_H2",\r
67                    "L3_BKF13_H3",\r
68                    "L3_BKF13_Temperature",\r
69                    "L3_BKF8_H1",\r
70                    "L3_BKF8_H2",\r
71                    "L3_BKF8_H3",\r
72                    "L3_BKF8_Temperature",\r
73                    "Dipole_Inside_H1",\r
74                    "Dipole_Inside_H2",\r
75                    "Dipole_Inside_H3",\r
76                    "Dipole_Inside_Temperature",\r
77                    "Dipole_Outside_H1",\r
78                    "Dipole_Outside_H2",\r
79                    "Dipole_Outside_H3",\r
80                    "Dipole_Outside_Temperature",\r
81                  };\r
82 \r
83 //-----------------------------------------------------------------------------\r
84 AliGRPObject::AliGRPObject():\r
85         TObject(),\r
86         fPoints(5),\r
87         fDimension(0),\r
88         fTimeStart((time_t)fgkInvalidFloat),\r
89         fTimeEnd((time_t)fgkInvalidFloat),\r
90         fBeamEnergy(fgkInvalidFloat),\r
91         fBeamType(fgkInvalidString),\r
92         fNumberOfDetectors(fgkInvalidChar),\r
93         fDetectorMask(fgkInvalidUInt),\r
94         fLHCPeriod(fgkInvalidString),\r
95         fRunType(fgkInvalidString),\r
96         fLHCState(fgkInvalidString),\r
97         fL3Polarity(fgkInvalidChar),\r
98         fDipolePolarity(fgkInvalidChar),\r
99         fL3Current(new Float_t[fPoints]),\r
100         fDipoleCurrent(new Float_t[fPoints]),\r
101         fCavernTemperature(new Float_t[fPoints]),\r
102         fCavernAtmosPressure(0x0),\r
103         fCavernAtmosPressure2(0x0),\r
104         fSurfaceAtmosPressure(0x0),\r
105         fHallProbes(0x0),\r
106         fMachineMode(fgkInvalidString),\r
107         fLHCStateArray(0x0),\r
108         fMachineModeArray(0x0),\r
109         fMaxTimeLHCValidity(0)\r
110 {\r
111 \r
112         //\r
113         // AliGRPObject default ctor\r
114         //\r
115 \r
116         fDimension = fgknDCSDPHallProbes*fPoints;\r
117         fHallProbes = new Float_t[fDimension];\r
118 \r
119         for (Int_t nhp=0; nhp< fDimension; nhp++){ // setting to zero values for non working HP \r
120                 if ((nhp >= 0 && nhp <= 1*fPoints-1) || // L3_BSF17_H1\r
121                     (nhp >= 1*fPoints && nhp <= 2*fPoints-1) || // L3_BSF17_H2\r
122                     (nhp >= 2*fPoints && nhp <= 3*fPoints-1) || // L3_BSF17_H3\r
123                     (nhp >= 3*fPoints && nhp <= 4*fPoints-1) || // L3_BSF17_Temperature\r
124                     (nhp >= 6*fPoints && nhp <= 7*fPoints-1) ) { // L3_BSF4_H3\r
125                         fHallProbes[nhp] = 0; // setting to zero values for non working HP \r
126                         AliDebug(2,"setting hp[%d] to zero = %f", nhp, fHallProbes[nhp]);\r
127                 }\r
128                 else {\r
129                         fHallProbes[nhp] = fgkInvalidFloat;\r
130                 }\r
131         }\r
132 \r
133 \r
134         for (Int_t i = 0; i < fPoints; i++){\r
135 \r
136                 fL3Current[i] = fgkInvalidFloat;\r
137                 fDipoleCurrent[i] = fgkInvalidFloat;\r
138                 fCavernTemperature[i] = fgkInvalidFloat;\r
139         }\r
140 }\r
141 \r
142 //-----------------------------------------------------------------------------\r
143 \r
144 AliGRPObject::AliGRPObject(const AliGRPObject &obj):\r
145         TObject(obj),\r
146         fPoints(obj.fPoints),\r
147         fDimension(obj.fDimension),\r
148         fTimeStart(obj.fTimeStart),\r
149         fTimeEnd(obj.fTimeEnd),\r
150         fBeamEnergy(obj.fBeamEnergy),\r
151         fBeamType(obj.fBeamType),\r
152         fNumberOfDetectors(obj.fNumberOfDetectors),\r
153         fDetectorMask(obj.fDetectorMask),\r
154         fLHCPeriod(obj.fLHCPeriod),\r
155         fRunType(obj.fRunType),\r
156         fLHCState(obj.fLHCState),\r
157         fL3Polarity(obj.fL3Polarity),\r
158         fDipolePolarity(obj.fDipolePolarity),\r
159         fL3Current(new Float_t[fPoints]),\r
160         fDipoleCurrent(new Float_t[fPoints]),\r
161         fCavernTemperature(new Float_t[fPoints]),\r
162         fCavernAtmosPressure(obj.fCavernAtmosPressure),\r
163         fCavernAtmosPressure2(obj.fCavernAtmosPressure2),\r
164         fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),\r
165         fHallProbes(0x0),\r
166         fMachineMode(obj.fMachineMode),\r
167         fLHCStateArray(obj.fLHCStateArray),\r
168         fMachineModeArray(obj.fMachineModeArray),\r
169         fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity)\r
170 \r
171 {\r
172 \r
173         //\r
174         // AliGRPObject copy ctor\r
175         //\r
176 \r
177         fHallProbes = new Float_t[fDimension]; \r
178 \r
179         for (Int_t nhp=0; nhp< fDimension; nhp++){\r
180                 fHallProbes[nhp] = obj.fHallProbes[nhp];\r
181         }\r
182 \r
183         for (Int_t i = 0; i < fPoints; i++){\r
184 \r
185                 fL3Current[i] = obj.fL3Current[i];\r
186                 fDipoleCurrent[i] = obj.fDipoleCurrent[i];\r
187                 fCavernTemperature[i] = obj.fCavernTemperature[i];\r
188         }\r
189 }\r
190 \r
191 //-----------------------------------------------------------------------------\r
192 \r
193 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj) \r
194 {\r
195 \r
196         //\r
197         // AliGRPObject assignment operator\r
198         //\r
199 \r
200         if (&obj == this) return *this; \r
201 \r
202         TObject::operator=(obj);\r
203         this->fTimeStart = obj.GetTimeStart();\r
204         this->fTimeEnd = obj.GetTimeEnd();\r
205         this->fBeamEnergy = obj.GetBeamEnergy();\r
206         this->fBeamType = obj.GetBeamType();\r
207         this->fNumberOfDetectors = obj.GetNumberOfDetectors();\r
208         this->fDetectorMask = obj.GetDetectorMask();\r
209         this->fLHCPeriod = obj.GetLHCPeriod();\r
210         this->fRunType = obj.GetRunType();\r
211         this->fLHCState = obj.GetLHCState();\r
212         this->fL3Polarity = obj.GetL3Polarity();\r
213         this->fDipolePolarity = obj.GetDipolePolarity();\r
214         this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();\r
215         this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();\r
216         this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();\r
217         this->fPoints = obj.GetPoints();\r
218         this->fDimension = obj.GetDimension();\r
219 \r
220         this->fL3Current = new Float_t[fPoints];\r
221         this->fDipoleCurrent = new Float_t[fPoints];\r
222         this->fCavernTemperature = new Float_t[fPoints];\r
223         \r
224         if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension]; \r
225         for (Int_t nhp=0; nhp< fDimension; nhp++){\r
226                 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);\r
227 \r
228         }\r
229         for (Int_t i = 0; i < fPoints; i++){\r
230 \r
231                 this->fL3Current[i] = obj.GetL3Current((Stats)i);\r
232                 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);\r
233                 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);\r
234         }\r
235 \r
236         this->fMachineMode = obj.fMachineMode;\r
237         this->fLHCStateArray = obj.fLHCStateArray;\r
238         this->fMachineModeArray = obj.fMachineModeArray;\r
239         this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;\r
240         return *this;\r
241 }\r
242 \r
243 //-----------------------------------------------------------------------------\r
244 \r
245 AliGRPObject::~AliGRPObject() {\r
246 \r
247         //\r
248         // dtor\r
249         //\r
250 \r
251         \r
252         delete [] fHallProbes;\r
253         delete [] fL3Current;\r
254         delete [] fDipoleCurrent;\r
255         delete [] fCavernTemperature;\r
256 \r
257         if (fCavernAtmosPressure){\r
258                 delete fCavernAtmosPressure;\r
259                 fCavernAtmosPressure = 0x0;\r
260         }\r
261         if (fCavernAtmosPressure2){\r
262                 delete fCavernAtmosPressure2;\r
263                 fCavernAtmosPressure2 = 0x0;\r
264         }\r
265         if (fSurfaceAtmosPressure){\r
266                 delete fSurfaceAtmosPressure;\r
267                 fSurfaceAtmosPressure = 0x0;\r
268         }\r
269         if (fLHCStateArray){\r
270                 delete fLHCStateArray;\r
271                 fLHCStateArray = 0x0;\r
272         }\r
273         if (fMachineModeArray){\r
274                 delete fMachineModeArray;\r
275                 fMachineModeArray = 0x0;\r
276         }\r
277 }\r
278 \r
279 //-----------------------------------------------------------------------------\r
280 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {\r
281 \r
282         //\r
283         // method to return array of statistical\r
284         // variables for Hall Probe hp\r
285         //\r
286 \r
287         Float_t* array = new Float_t[fPoints];\r
288         Int_t shift = fPoints*(Int_t)hp; \r
289         for (Int_t i=0;i<fPoints; i++){\r
290 \r
291                 array[i] = fHallProbes[shift+i];\r
292 \r
293         }\r
294 \r
295         return array;\r
296 }\r
297 //-------------------------------------------------------------------------------\r
298 \r
299 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){\r
300 \r
301         //\r
302         // method to set hall probe hp \r
303         // from a given array\r
304         //\r
305 \r
306         Int_t shift = fPoints*hp;\r
307         for (Int_t i = 0; i< fPoints; i++){\r
308 \r
309                 fHallProbes[i+shift] =  hall_probe[i];\r
310         }\r
311         return;\r
312 }\r
313 \r
314 //-------------------------------------------------------------------------------\r
315 \r
316 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){\r
317 \r
318         //\r
319         // method to set the values of the GRP parameters \r
320         // reading them from the old format of the GRP \r
321         // object, i.e. a TMap\r
322         //\r
323 \r
324         if (mapGRP->GetValue("fAliceStartTime")){\r
325                 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());\r
326         }\r
327         else {\r
328                 AliError(Form("No fAliceStartTime value found in GRP map!"));\r
329         }\r
330         if (mapGRP->GetValue("fAliceStopTime")){\r
331                 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());\r
332         }\r
333         \r
334         else { \r
335                 AliError(Form("No fAliceStopTime value found in GRP map!"));\r
336         }\r
337 \r
338         if(mapGRP->GetValue("fAliceBeamEnergy")){\r
339           double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();\r
340           if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2;   // old format was storig sqrt(s)\r
341           SetBeamEnergy(be);\r
342         }\r
343         else { \r
344                 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));\r
345         }\r
346         if(mapGRP->GetValue("fAliceBeamType")){\r
347                 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());\r
348         }\r
349         else { \r
350                 AliError(Form("No fAliceBeamType value found in GRP map!"));\r
351         }\r
352         if(mapGRP->GetValue("fNumberOfDetectors")){\r
353                 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi()); \r
354         }\r
355         else { \r
356                 AliError(Form("No fNumberOfDetectors value found in GRP map!"));\r
357         }\r
358         if(mapGRP->GetValue("fDetectorMask")){\r
359                 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());  \r
360         }\r
361         else { \r
362                 AliError(Form("No fDetectorMask value found in GRP map!"));\r
363         }\r
364         if(mapGRP->GetValue("fLHCPeriod")){\r
365                 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());\r
366         }\r
367         else { \r
368                 AliError(Form("No fLHCPeriod value found in GRP map!"));\r
369         }\r
370         if(mapGRP->GetValue("fRunType")){\r
371                 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());\r
372         }\r
373         else { \r
374                 AliError(Form("No fRunType value found in GRP map!"));\r
375         }\r
376         if(mapGRP->GetValue("fLHCState")){\r
377                 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());\r
378         }\r
379         else { \r
380                 AliError(Form("No fLHCState value found in GRP map!"));\r
381         }\r
382         if(mapGRP->GetValue("fLHCluminosity")){\r
383                 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));\r
384         }       \r
385         else { \r
386                 AliError(Form("No fLHCLuminosity value found in GRP map!"));\r
387         }\r
388         if(mapGRP->GetValue("fBeamIntensity")){\r
389                 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));\r
390         }       \r
391         else { \r
392                 AliError(Form("No fBeamIntensity value found in GRP map!"));\r
393         }\r
394         if(mapGRP->GetValue("fL3Polarity")){\r
395                 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());\r
396         }       \r
397         else { \r
398                 AliError(Form("No fL3Polarity value found in GRP map!"));\r
399         }\r
400         if(mapGRP->GetValue("fDipolePolarity")){\r
401                 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());  \r
402         }       \r
403         else { \r
404                 AliError(Form("No fDipolePolarity value found in GRP map!"));\r
405         }\r
406         if(mapGRP->GetValue("fL3Current")){\r
407                 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));\r
408                 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);\r
409         }       \r
410         else { \r
411                 AliError(Form("No fL3Current value found in GRP map!"));\r
412         }\r
413         if(mapGRP->GetValue("fDipoleCurrent")){\r
414                 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));\r
415                 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);\r
416         }       \r
417         else { \r
418                 AliError(Form("No fDipoleCurrent value found in GRP map!"));\r
419         }\r
420         if(mapGRP->GetValue("fCavernTemperature")){\r
421                 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));\r
422                 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);\r
423         }       \r
424         else { \r
425                 AliError(Form("No fCavernTemperature value found in GRP map!"));\r
426         }\r
427         if(mapGRP->GetValue("fCavernAtmosPressure")){\r
428                 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));\r
429         }       \r
430         else { \r
431                 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));\r
432         }\r
433         if(mapGRP->GetValue("fP2Pressure")){\r
434                 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));\r
435         }\r
436         else { \r
437                 AliError(Form("No fP2Pressure value found in GRP map!"));\r
438         }\r
439         \r
440         return;\r
441 \r
442 }\r