]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliGRPObject.cxx
Adding support for CINT7, CMSH7, CMUL7, CMUU7, CEMC7 triggers
[u/mrichter/AliRoot.git] / STEER / AliGRPObject.cxx
CommitLineData
29d11b68 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
32ClassImp(AliGRPObject)
de67dd6b 33
34const Double_t kCavernCut = 1.0; // tolerable difference between cavern pressure sensors
35const Double_t kSurfaceDifference = 4.5; // offset between surface and cavern pressure sensors
29d11b68 36
37const Float_t AliGRPObject::fgkInvalidFloat = 1E-33; // value to identify invalid data - float
38const TString AliGRPObject::fgkInvalidString = ""; // value to identify invalid data - string
39const Char_t AliGRPObject::fgkInvalidChar = -1; // value to identify invalid data - uchar
40const Int_t AliGRPObject::fgkInvalidInt = -1; // value to identify invalid data - uint
41const Int_t AliGRPObject::fgkInvalidUInt = 0; // value to identify invalid data - uint
42const Int_t AliGRPObject::fgknDCSDPHallProbes = 40; // number of dcs dps
43const 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//-----------------------------------------------------------------------------
87AliGRPObject::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 fMaxTimeLHCValidity(0)
113{
114
115 //
116 // AliGRPObject default ctor
117 //
118
119 fDimension = fgknDCSDPHallProbes*fPoints;
120 fHallProbes = new Float_t[fDimension];
121
122 for (Int_t nhp=0; nhp< fDimension; nhp++){ // setting to zero values for non working HP
123 if ((nhp >= 0 && nhp <= 1*fPoints-1) || // L3_BSF17_H1
124 (nhp >= 1*fPoints && nhp <= 2*fPoints-1) || // L3_BSF17_H2
125 (nhp >= 2*fPoints && nhp <= 3*fPoints-1) || // L3_BSF17_H3
126 (nhp >= 3*fPoints && nhp <= 4*fPoints-1) || // L3_BSF17_Temperature
127 (nhp >= 6*fPoints && nhp <= 7*fPoints-1) ) { // L3_BSF4_H3
128 fHallProbes[nhp] = 0; // setting to zero values for non working HP
129 AliDebug(2,Form("setting hp[%d] to zero = %f",
130nhp, fHallProbes[nhp]));
131 }
132 else {
133 fHallProbes[nhp] = fgkInvalidFloat;
134 }
135 }
136
137
138 for (Int_t i = 0; i < fPoints; i++){
139
140 fL3Current[i] = fgkInvalidFloat;
141 fDipoleCurrent[i] = fgkInvalidFloat;
142 fCavernTemperature[i] = fgkInvalidFloat;
143 }
53b0ec45 144
145 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
146 fSeparateBeamType[ibeamType] = fgkInvalidString;
147 }
29d11b68 148}
149
150//-----------------------------------------------------------------------------
151
152AliGRPObject::AliGRPObject(const AliGRPObject &obj):
153 TObject(obj),
154 fPoints(obj.fPoints),
155 fDimension(obj.fDimension),
156 fTimeStart(obj.fTimeStart),
157 fTimeEnd(obj.fTimeEnd),
158 fBeamEnergy(obj.fBeamEnergy),
159 fBeamType(obj.fBeamType),
160 fNumberOfDetectors(obj.fNumberOfDetectors),
161 fDetectorMask(obj.fDetectorMask),
162 fLHCPeriod(obj.fLHCPeriod),
163 fRunType(obj.fRunType),
164 fLHCState(obj.fLHCState),
165 fL3Polarity(obj.fL3Polarity),
166 fDipolePolarity(obj.fDipolePolarity),
167 fL3Current(new Float_t[fPoints]),
168 fDipoleCurrent(new Float_t[fPoints]),
169 fCavernTemperature(new Float_t[fPoints]),
170 fCavernAtmosPressure(obj.fCavernAtmosPressure),
171 fCavernAtmosPressure2(obj.fCavernAtmosPressure2),
172 fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),
173 fHallProbes(0x0),
174 fMachineMode(obj.fMachineMode),
175 fLHCStateArray(obj.fLHCStateArray),
176 fMachineModeArray(obj.fMachineModeArray),
177 fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity)
178
179{
180
181 //
182 // AliGRPObject copy ctor
183 //
184
185 fHallProbes = new Float_t[fDimension];
186
187 for (Int_t nhp=0; nhp< fDimension; nhp++){
188 fHallProbes[nhp] = obj.fHallProbes[nhp];
189 }
190
191 for (Int_t i = 0; i < fPoints; i++){
192
193 fL3Current[i] = obj.fL3Current[i];
194 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
195 fCavernTemperature[i] = obj.fCavernTemperature[i];
196 }
53b0ec45 197
198 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
199 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
200 }
29d11b68 201}
202
203//-----------------------------------------------------------------------------
204
205AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
206{
207
208 //
209 // AliGRPObject assignment operator
210 //
211
212 if (&obj == this) return *this;
213
214 TObject::operator=(obj);
215 this->fTimeStart = obj.GetTimeStart();
216 this->fTimeEnd = obj.GetTimeEnd();
217 this->fBeamEnergy = obj.GetBeamEnergy();
218 this->fBeamType = obj.GetBeamType();
219 this->fNumberOfDetectors = obj.GetNumberOfDetectors();
220 this->fDetectorMask = obj.GetDetectorMask();
221 this->fLHCPeriod = obj.GetLHCPeriod();
222 this->fRunType = obj.GetRunType();
223 this->fLHCState = obj.GetLHCState();
224 this->fL3Polarity = obj.GetL3Polarity();
225 this->fDipolePolarity = obj.GetDipolePolarity();
226 this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();
227 this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();
228 this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();
229 this->fPoints = obj.GetPoints();
230 this->fDimension = obj.GetDimension();
231
232 this->fL3Current = new Float_t[fPoints];
233 this->fDipoleCurrent = new Float_t[fPoints];
234 this->fCavernTemperature = new Float_t[fPoints];
235
236 if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension];
237 for (Int_t nhp=0; nhp< fDimension; nhp++){
238 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);
239
240 }
241 for (Int_t i = 0; i < fPoints; i++){
242
243 this->fL3Current[i] = obj.GetL3Current((Stats)i);
244 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
245 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
246 }
247
248 this->fMachineMode = obj.fMachineMode;
249 this->fLHCStateArray = obj.fLHCStateArray;
250 this->fMachineModeArray = obj.fMachineModeArray;
251 this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
53b0ec45 252
253 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
254 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
255 }
256
29d11b68 257 return *this;
258}
259
260//-----------------------------------------------------------------------------
261
262AliGRPObject::~AliGRPObject() {
263
264 //
265 // dtor
266 //
267
268
269 delete [] fHallProbes;
270 delete [] fL3Current;
271 delete [] fDipoleCurrent;
272 delete [] fCavernTemperature;
273
274 if (fCavernAtmosPressure){
275 delete fCavernAtmosPressure;
276 fCavernAtmosPressure = 0x0;
277 }
278 if (fCavernAtmosPressure2){
279 delete fCavernAtmosPressure2;
280 fCavernAtmosPressure2 = 0x0;
281 }
282 if (fSurfaceAtmosPressure){
283 delete fSurfaceAtmosPressure;
284 fSurfaceAtmosPressure = 0x0;
285 }
286 if (fLHCStateArray){
287 delete fLHCStateArray;
288 fLHCStateArray = 0x0;
289 }
290 if (fMachineModeArray){
291 delete fMachineModeArray;
292 fMachineModeArray = 0x0;
293 }
294}
295
296//-----------------------------------------------------------------------------
297Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
298
299 //
300 // method to return array of statistical
301 // variables for Hall Probe hp
302 //
303
304 Float_t* array = new Float_t[fPoints];
305 Int_t shift = fPoints*(Int_t)hp;
306 for (Int_t i=0;i<fPoints; i++){
307
308 array[i] = fHallProbes[shift+i];
309
310 }
311
312 return array;
313}
314//-------------------------------------------------------------------------------
315
316void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
317
318 //
319 // method to set hall probe hp
320 // from a given array
321 //
322
323 Int_t shift = fPoints*hp;
324 for (Int_t i = 0; i< fPoints; i++){
325
326 fHallProbes[i+shift] = hall_probe[i];
327 }
328 return;
329}
330
331//-------------------------------------------------------------------------------
332
333void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
334
335 //
336 // method to set the values of the GRP parameters
337 // reading them from the old format of the GRP
338 // object, i.e. a TMap
339 //
340
341 if (mapGRP->GetValue("fAliceStartTime")){
342 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
343 }
344 else {
345 AliError(Form("No fAliceStartTime value found in GRP map!"));
346 }
347 if (mapGRP->GetValue("fAliceStopTime")){
348 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
349 }
350
351 else {
352 AliError(Form("No fAliceStopTime value found in GRP map!"));
353 }
354
355 if(mapGRP->GetValue("fAliceBeamEnergy")){
356 double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();
357 if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2; // old format was storig sqrt(s)
358 SetBeamEnergy(be);
359 }
360 else {
361 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
362 }
363 if(mapGRP->GetValue("fAliceBeamType")){
364 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
365 }
366 else {
367 AliError(Form("No fAliceBeamType value found in GRP map!"));
368 }
369 if(mapGRP->GetValue("fNumberOfDetectors")){
370 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi());
371 }
372 else {
373 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
374 }
375 if(mapGRP->GetValue("fDetectorMask")){
376 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());
377 }
378 else {
379 AliError(Form("No fDetectorMask value found in GRP map!"));
380 }
381 if(mapGRP->GetValue("fLHCPeriod")){
382 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
383 }
384 else {
385 AliError(Form("No fLHCPeriod value found in GRP map!"));
386 }
387 if(mapGRP->GetValue("fRunType")){
388 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
389 }
390 else {
391 AliError(Form("No fRunType value found in GRP map!"));
392 }
393 if(mapGRP->GetValue("fLHCState")){
394 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
395 }
396 else {
397 AliError(Form("No fLHCState value found in GRP map!"));
398 }
399 if(mapGRP->GetValue("fLHCluminosity")){
400 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
401 }
402 else {
403 AliError(Form("No fLHCLuminosity value found in GRP map!"));
404 }
405 if(mapGRP->GetValue("fBeamIntensity")){
406 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
407 }
408 else {
409 AliError(Form("No fBeamIntensity value found in GRP map!"));
410 }
411 if(mapGRP->GetValue("fL3Polarity")){
412 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
413 }
414 else {
415 AliError(Form("No fL3Polarity value found in GRP map!"));
416 }
417 if(mapGRP->GetValue("fDipolePolarity")){
418 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());
419 }
420 else {
421 AliError(Form("No fDipolePolarity value found in GRP map!"));
422 }
423 if(mapGRP->GetValue("fL3Current")){
424 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));
425 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);
426 }
427 else {
428 AliError(Form("No fL3Current value found in GRP map!"));
429 }
430 if(mapGRP->GetValue("fDipoleCurrent")){
431 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));
432 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);
433 }
434 else {
435 AliError(Form("No fDipoleCurrent value found in GRP map!"));
436 }
437 if(mapGRP->GetValue("fCavernTemperature")){
438 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));
439 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);
440 }
441 else {
442 AliError(Form("No fCavernTemperature value found in GRP map!"));
443 }
444 if(mapGRP->GetValue("fCavernAtmosPressure")){
445 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
446 }
447 else {
448 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
449 }
450 if(mapGRP->GetValue("fP2Pressure")){
451 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
452 }
453 else {
454 AliError(Form("No fP2Pressure value found in GRP map!"));
455 }
456
457 return;
458
459}
549ab3c2 460//-------------------------------------------------------------------------------
461
462Float_t AliGRPObject::GetBeamEnergy() const {
463
464 //
465 // Getting the energy
466 // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
467 //
468
469 Float_t energy = fBeamEnergy;
470 if (fBeamType=="A-A"){
471 energy = energy*82./208;
472 }
473 return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
474}
de67dd6b 475
476//-------------------------------------------------------------------------------
477
478Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const {
479//
480// Return current pressure value from 'best' cavern sensor
481// (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
482// use sensor most compatible with surface sensor
483
484 return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
485 fSurfaceAtmosPressure,time,inside);
486
487}
488
489//-------------------------------------------------------------------------------
490
491Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1,
492 AliDCSSensor* cavern2, AliDCSSensor* surface,
493 const TTimeStamp& time, Bool_t& inside) {
494//
495// Return current pressure value from 'best' cavern sensor
496// (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
497// use sensor most compatible with surface sensor
498
499
500 Double_t valueSensor2 = cavern2->Eval(time,inside);
501 Double_t valueSensor1 = cavern1->Eval(time,inside);
502 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
503 return valueSensor2;
504 } else {
505 Double_t valueSurface = surface->Eval(time,inside);
506 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
507 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
508 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
509 return valueSensor1;
510 } else {
511 return valueSensor2;
512 }
513 }
514}
515
516//-------------------------------------------------------------------------------
517
518AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1,
519 AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
520
521//
522// Return pointer to '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// Pressure measuread at time specified by TTimestamp
526
527
528 Bool_t inside;
529 Double_t valueSensor2 = cavern2->Eval(time,inside);
530 Double_t valueSensor1 = cavern1->Eval(time,inside);
531 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
532 return cavern2;
533 } else {
534 Double_t valueSurface = surface->Eval(time,inside);
535 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
536 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
537 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
538 return cavern1;
539 } else {
540 return cavern2;
541 }
542 }
543}
544
545//-------------------------------------------------------------------------------
546
547AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
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 return GetBestCavernAtmosPressure(fCavernAtmosPressure,
556 fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
557
558}
559
560//-------------------------------------------------------------------------------
561
562AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure() const {
563//
564// Return pointer to 'best' cavern sensor
565// (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
566// use sensor most compatible with surface sensor
567// Pressure measuread at start-of-run
568
569 return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));
570}
571