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;
145 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
146 fSeparateBeamType[ibeamType] = fgkInvalidString;
150 //-----------------------------------------------------------------------------
152 AliGRPObject::AliGRPObject(const AliGRPObject &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),
174 fMachineMode(obj.fMachineMode),
175 fLHCStateArray(obj.fLHCStateArray),
176 fMachineModeArray(obj.fMachineModeArray),
177 fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity)
182 // AliGRPObject copy ctor
185 fHallProbes = new Float_t[fDimension];
187 for (Int_t nhp=0; nhp< fDimension; nhp++){
188 fHallProbes[nhp] = obj.fHallProbes[nhp];
191 for (Int_t i = 0; i < fPoints; i++){
193 fL3Current[i] = obj.fL3Current[i];
194 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
195 fCavernTemperature[i] = obj.fCavernTemperature[i];
198 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
199 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
203 //-----------------------------------------------------------------------------
205 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
209 // AliGRPObject assignment operator
212 if (&obj == this) return *this;
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();
232 this->fL3Current = new Float_t[fPoints];
233 this->fDipoleCurrent = new Float_t[fPoints];
234 this->fCavernTemperature = new Float_t[fPoints];
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);
241 for (Int_t i = 0; i < fPoints; i++){
243 this->fL3Current[i] = obj.GetL3Current((Stats)i);
244 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
245 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
248 this->fMachineMode = obj.fMachineMode;
249 this->fLHCStateArray = obj.fLHCStateArray;
250 this->fMachineModeArray = obj.fMachineModeArray;
251 this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
253 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
254 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
260 //-----------------------------------------------------------------------------
262 AliGRPObject::~AliGRPObject() {
269 delete [] fHallProbes;
270 delete [] fL3Current;
271 delete [] fDipoleCurrent;
272 delete [] fCavernTemperature;
274 if (fCavernAtmosPressure){
275 delete fCavernAtmosPressure;
276 fCavernAtmosPressure = 0x0;
278 if (fCavernAtmosPressure2){
279 delete fCavernAtmosPressure2;
280 fCavernAtmosPressure2 = 0x0;
282 if (fSurfaceAtmosPressure){
283 delete fSurfaceAtmosPressure;
284 fSurfaceAtmosPressure = 0x0;
287 delete fLHCStateArray;
288 fLHCStateArray = 0x0;
290 if (fMachineModeArray){
291 delete fMachineModeArray;
292 fMachineModeArray = 0x0;
296 //-----------------------------------------------------------------------------
297 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
300 // method to return array of statistical
301 // variables for Hall Probe hp
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++){
308 array[i] = fHallProbes[shift+i];
314 //-------------------------------------------------------------------------------
316 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
319 // method to set hall probe hp
320 // from a given array
323 Int_t shift = fPoints*hp;
324 for (Int_t i = 0; i< fPoints; i++){
326 fHallProbes[i+shift] = hall_probe[i];
331 //-------------------------------------------------------------------------------
333 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
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
341 if (mapGRP->GetValue("fAliceStartTime")){
342 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
345 AliError(Form("No fAliceStartTime value found in GRP map!"));
347 if (mapGRP->GetValue("fAliceStopTime")){
348 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
352 AliError(Form("No fAliceStopTime value found in GRP map!"));
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)
361 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
363 if(mapGRP->GetValue("fAliceBeamType")){
364 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
367 AliError(Form("No fAliceBeamType value found in GRP map!"));
369 if(mapGRP->GetValue("fNumberOfDetectors")){
370 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi());
373 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
375 if(mapGRP->GetValue("fDetectorMask")){
376 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());
379 AliError(Form("No fDetectorMask value found in GRP map!"));
381 if(mapGRP->GetValue("fLHCPeriod")){
382 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
385 AliError(Form("No fLHCPeriod value found in GRP map!"));
387 if(mapGRP->GetValue("fRunType")){
388 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
391 AliError(Form("No fRunType value found in GRP map!"));
393 if(mapGRP->GetValue("fLHCState")){
394 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
397 AliError(Form("No fLHCState value found in GRP map!"));
399 if(mapGRP->GetValue("fLHCluminosity")){
400 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
403 AliError(Form("No fLHCLuminosity value found in GRP map!"));
405 if(mapGRP->GetValue("fBeamIntensity")){
406 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
409 AliError(Form("No fBeamIntensity value found in GRP map!"));
411 if(mapGRP->GetValue("fL3Polarity")){
412 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
415 AliError(Form("No fL3Polarity value found in GRP map!"));
417 if(mapGRP->GetValue("fDipolePolarity")){
418 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());
421 AliError(Form("No fDipolePolarity value found in GRP map!"));
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);
428 AliError(Form("No fL3Current value found in GRP map!"));
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);
435 AliError(Form("No fDipoleCurrent value found in GRP map!"));
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);
442 AliError(Form("No fCavernTemperature value found in GRP map!"));
444 if(mapGRP->GetValue("fCavernAtmosPressure")){
445 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
448 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
450 if(mapGRP->GetValue("fP2Pressure")){
451 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
454 AliError(Form("No fP2Pressure value found in GRP map!"));
460 //-------------------------------------------------------------------------------
462 Float_t AliGRPObject::GetBeamEnergy() const {
465 // Getting the energy
466 // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
469 Float_t energy = fBeamEnergy;
470 if (fBeamType=="A-A"){
471 energy = energy*82./208;
473 return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
476 //-------------------------------------------------------------------------------
478 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const {
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
484 return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
485 fSurfaceAtmosPressure,time,inside);
489 //-------------------------------------------------------------------------------
491 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1,
492 AliDCSSensor* cavern2, AliDCSSensor* surface,
493 const TTimeStamp& time, Bool_t& inside) {
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
500 Double_t valueSensor2 = cavern2->Eval(time,inside);
501 Double_t valueSensor1 = cavern1->Eval(time,inside);
502 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
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) ) {
516 //-------------------------------------------------------------------------------
518 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1,
519 AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
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
529 Double_t valueSensor2 = cavern2->Eval(time,inside);
530 Double_t valueSensor1 = cavern1->Eval(time,inside);
531 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
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) ) {
545 //-------------------------------------------------------------------------------
547 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
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
555 return GetBestCavernAtmosPressure(fCavernAtmosPressure,
556 fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
560 //-------------------------------------------------------------------------------
562 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure() const {
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
569 return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));