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