1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 // **********************
26 #include <TObjString.h>
28 #include "AliGRPObject.h"
29 #include "AliDCSSensor.h"
32 ClassImp(AliGRPObject)
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
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] = {
47 "L3_BSF17_Temperature",
51 "L3_BSF4_Temperature",
55 "L3_BKF17_Temperature",
59 "L3_BKF4_Temperature",
63 "L3_BSF13_Temperature",
67 "L3_BSF8_Temperature",
71 "L3_BKF13_Temperature",
75 "L3_BKF8_Temperature",
79 "Dipole_Inside_Temperature",
83 "Dipole_Outside_Temperature",
86 //-----------------------------------------------------------------------------
87 AliGRPObject::AliGRPObject():
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),
109 fMachineMode(fgkInvalidString),
111 fMachineModeArray(0x0),
112 fMaxTimeLHCValidity(0)
116 // AliGRPObject default ctor
119 fDimension = fgknDCSDPHallProbes*fPoints;
120 fHallProbes = new Float_t[fDimension];
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",
130 nhp, fHallProbes[nhp]));
133 fHallProbes[nhp] = fgkInvalidFloat;
138 for (Int_t i = 0; i < fPoints; i++){
140 fL3Current[i] = fgkInvalidFloat;
141 fDipoleCurrent[i] = fgkInvalidFloat;
142 fCavernTemperature[i] = fgkInvalidFloat;
146 //-----------------------------------------------------------------------------
148 AliGRPObject::AliGRPObject(const AliGRPObject &obj):
150 fPoints(obj.fPoints),
151 fDimension(obj.fDimension),
152 fTimeStart(obj.fTimeStart),
153 fTimeEnd(obj.fTimeEnd),
154 fBeamEnergy(obj.fBeamEnergy),
155 fBeamType(obj.fBeamType),
156 fNumberOfDetectors(obj.fNumberOfDetectors),
157 fDetectorMask(obj.fDetectorMask),
158 fLHCPeriod(obj.fLHCPeriod),
159 fRunType(obj.fRunType),
160 fLHCState(obj.fLHCState),
161 fL3Polarity(obj.fL3Polarity),
162 fDipolePolarity(obj.fDipolePolarity),
163 fL3Current(new Float_t[fPoints]),
164 fDipoleCurrent(new Float_t[fPoints]),
165 fCavernTemperature(new Float_t[fPoints]),
166 fCavernAtmosPressure(obj.fCavernAtmosPressure),
167 fCavernAtmosPressure2(obj.fCavernAtmosPressure2),
168 fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),
170 fMachineMode(obj.fMachineMode),
171 fLHCStateArray(obj.fLHCStateArray),
172 fMachineModeArray(obj.fMachineModeArray),
173 fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity)
178 // AliGRPObject copy ctor
181 fHallProbes = new Float_t[fDimension];
183 for (Int_t nhp=0; nhp< fDimension; nhp++){
184 fHallProbes[nhp] = obj.fHallProbes[nhp];
187 for (Int_t i = 0; i < fPoints; i++){
189 fL3Current[i] = obj.fL3Current[i];
190 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
191 fCavernTemperature[i] = obj.fCavernTemperature[i];
195 //-----------------------------------------------------------------------------
197 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
201 // AliGRPObject assignment operator
204 if (&obj == this) return *this;
206 TObject::operator=(obj);
207 this->fTimeStart = obj.GetTimeStart();
208 this->fTimeEnd = obj.GetTimeEnd();
209 this->fBeamEnergy = obj.GetBeamEnergy();
210 this->fBeamType = obj.GetBeamType();
211 this->fNumberOfDetectors = obj.GetNumberOfDetectors();
212 this->fDetectorMask = obj.GetDetectorMask();
213 this->fLHCPeriod = obj.GetLHCPeriod();
214 this->fRunType = obj.GetRunType();
215 this->fLHCState = obj.GetLHCState();
216 this->fL3Polarity = obj.GetL3Polarity();
217 this->fDipolePolarity = obj.GetDipolePolarity();
218 this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();
219 this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();
220 this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();
221 this->fPoints = obj.GetPoints();
222 this->fDimension = obj.GetDimension();
224 this->fL3Current = new Float_t[fPoints];
225 this->fDipoleCurrent = new Float_t[fPoints];
226 this->fCavernTemperature = new Float_t[fPoints];
228 if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension];
229 for (Int_t nhp=0; nhp< fDimension; nhp++){
230 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);
233 for (Int_t i = 0; i < fPoints; i++){
235 this->fL3Current[i] = obj.GetL3Current((Stats)i);
236 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
237 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
240 this->fMachineMode = obj.fMachineMode;
241 this->fLHCStateArray = obj.fLHCStateArray;
242 this->fMachineModeArray = obj.fMachineModeArray;
243 this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
247 //-----------------------------------------------------------------------------
249 AliGRPObject::~AliGRPObject() {
256 delete [] fHallProbes;
257 delete [] fL3Current;
258 delete [] fDipoleCurrent;
259 delete [] fCavernTemperature;
261 if (fCavernAtmosPressure){
262 delete fCavernAtmosPressure;
263 fCavernAtmosPressure = 0x0;
265 if (fCavernAtmosPressure2){
266 delete fCavernAtmosPressure2;
267 fCavernAtmosPressure2 = 0x0;
269 if (fSurfaceAtmosPressure){
270 delete fSurfaceAtmosPressure;
271 fSurfaceAtmosPressure = 0x0;
274 delete fLHCStateArray;
275 fLHCStateArray = 0x0;
277 if (fMachineModeArray){
278 delete fMachineModeArray;
279 fMachineModeArray = 0x0;
283 //-----------------------------------------------------------------------------
284 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
287 // method to return array of statistical
288 // variables for Hall Probe hp
291 Float_t* array = new Float_t[fPoints];
292 Int_t shift = fPoints*(Int_t)hp;
293 for (Int_t i=0;i<fPoints; i++){
295 array[i] = fHallProbes[shift+i];
301 //-------------------------------------------------------------------------------
303 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
306 // method to set hall probe hp
307 // from a given array
310 Int_t shift = fPoints*hp;
311 for (Int_t i = 0; i< fPoints; i++){
313 fHallProbes[i+shift] = hall_probe[i];
318 //-------------------------------------------------------------------------------
320 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
323 // method to set the values of the GRP parameters
324 // reading them from the old format of the GRP
325 // object, i.e. a TMap
328 if (mapGRP->GetValue("fAliceStartTime")){
329 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
332 AliError(Form("No fAliceStartTime value found in GRP map!"));
334 if (mapGRP->GetValue("fAliceStopTime")){
335 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
339 AliError(Form("No fAliceStopTime value found in GRP map!"));
342 if(mapGRP->GetValue("fAliceBeamEnergy")){
343 double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();
344 if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2; // old format was storig sqrt(s)
348 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
350 if(mapGRP->GetValue("fAliceBeamType")){
351 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
354 AliError(Form("No fAliceBeamType value found in GRP map!"));
356 if(mapGRP->GetValue("fNumberOfDetectors")){
357 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi());
360 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
362 if(mapGRP->GetValue("fDetectorMask")){
363 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());
366 AliError(Form("No fDetectorMask value found in GRP map!"));
368 if(mapGRP->GetValue("fLHCPeriod")){
369 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
372 AliError(Form("No fLHCPeriod value found in GRP map!"));
374 if(mapGRP->GetValue("fRunType")){
375 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
378 AliError(Form("No fRunType value found in GRP map!"));
380 if(mapGRP->GetValue("fLHCState")){
381 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
384 AliError(Form("No fLHCState value found in GRP map!"));
386 if(mapGRP->GetValue("fLHCluminosity")){
387 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
390 AliError(Form("No fLHCLuminosity value found in GRP map!"));
392 if(mapGRP->GetValue("fBeamIntensity")){
393 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
396 AliError(Form("No fBeamIntensity value found in GRP map!"));
398 if(mapGRP->GetValue("fL3Polarity")){
399 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
402 AliError(Form("No fL3Polarity value found in GRP map!"));
404 if(mapGRP->GetValue("fDipolePolarity")){
405 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());
408 AliError(Form("No fDipolePolarity value found in GRP map!"));
410 if(mapGRP->GetValue("fL3Current")){
411 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));
412 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);
415 AliError(Form("No fL3Current value found in GRP map!"));
417 if(mapGRP->GetValue("fDipoleCurrent")){
418 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));
419 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);
422 AliError(Form("No fDipoleCurrent value found in GRP map!"));
424 if(mapGRP->GetValue("fCavernTemperature")){
425 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));
426 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);
429 AliError(Form("No fCavernTemperature value found in GRP map!"));
431 if(mapGRP->GetValue("fCavernAtmosPressure")){
432 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
435 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
437 if(mapGRP->GetValue("fP2Pressure")){
438 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
441 AliError(Form("No fP2Pressure value found in GRP map!"));
447 //-------------------------------------------------------------------------------
449 Float_t AliGRPObject::GetBeamEnergy() const {
452 // Getting the energy
453 // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
456 Float_t energy = fBeamEnergy;
457 if (fBeamType=="A-A"){
458 energy = energy*82./208;
460 return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
463 //-------------------------------------------------------------------------------
465 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const {
467 // Return current pressure value from 'best' cavern sensor
468 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
469 // use sensor most compatible with surface sensor
471 return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
472 fSurfaceAtmosPressure,time,inside);
476 //-------------------------------------------------------------------------------
478 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1,
479 AliDCSSensor* cavern2, AliDCSSensor* surface,
480 const TTimeStamp& time, Bool_t& inside) {
482 // Return current pressure value from 'best' cavern sensor
483 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
484 // use sensor most compatible with surface sensor
487 Double_t valueSensor2 = cavern2->Eval(time,inside);
488 Double_t valueSensor1 = cavern1->Eval(time,inside);
489 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
492 Double_t valueSurface = surface->Eval(time,inside);
493 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
494 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
495 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
503 //-------------------------------------------------------------------------------
505 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1,
506 AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
509 // Return pointer to 'best' cavern sensor
510 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
511 // use sensor most compatible with surface sensor
512 // Pressure measuread at time specified by TTimestamp
516 Double_t valueSensor2 = cavern2->Eval(time,inside);
517 Double_t valueSensor1 = cavern1->Eval(time,inside);
518 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
521 Double_t valueSurface = surface->Eval(time,inside);
522 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
523 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
524 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
532 //-------------------------------------------------------------------------------
534 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
536 // Return pointer to 'best' cavern sensor
537 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
538 // use sensor most compatible with surface sensor
539 // Pressure measuread at time specified by TTimestamp
542 return GetBestCavernAtmosPressure(fCavernAtmosPressure,
543 fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
547 //-------------------------------------------------------------------------------
549 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure() const {
551 // Return pointer to 'best' cavern sensor
552 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
553 // use sensor most compatible with surface sensor
554 // Pressure measuread at start-of-run
556 return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));