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),
113 fQACloningRequest(0x0),
114 fMaxTimeLHCValidity(0)
118 // AliGRPObject default ctor
121 fDimension = fgknDCSDPHallProbes*fPoints;
122 fHallProbes = new Float_t[fDimension];
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",
132 nhp, fHallProbes[nhp]));
135 fHallProbes[nhp] = fgkInvalidFloat;
140 for (Int_t i = 0; i < fPoints; i++){
142 fL3Current[i] = fgkInvalidFloat;
143 fDipoleCurrent[i] = fgkInvalidFloat;
144 fCavernTemperature[i] = fgkInvalidFloat;
147 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
148 fSeparateBeamType[ibeamType] = fgkInvalidString;
152 //-----------------------------------------------------------------------------
154 AliGRPObject::AliGRPObject(const AliGRPObject &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),
176 fMachineMode(obj.fMachineMode),
177 fLHCStateArray(obj.fLHCStateArray),
178 fMachineModeArray(obj.fMachineModeArray),
179 fQATrigClasses(obj.fQATrigClasses),
180 fQACloningRequest(obj.fQACloningRequest),
181 fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity)
186 // AliGRPObject copy ctor
189 fHallProbes = new Float_t[fDimension];
191 for (Int_t nhp=0; nhp< fDimension; nhp++){
192 fHallProbes[nhp] = obj.fHallProbes[nhp];
195 for (Int_t i = 0; i < fPoints; i++){
197 fL3Current[i] = obj.fL3Current[i];
198 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
199 fCavernTemperature[i] = obj.fCavernTemperature[i];
202 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
203 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
207 //-----------------------------------------------------------------------------
209 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
213 // AliGRPObject assignment operator
216 if (&obj == this) return *this;
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();
236 this->fL3Current = new Float_t[fPoints];
237 this->fDipoleCurrent = new Float_t[fPoints];
238 this->fCavernTemperature = new Float_t[fPoints];
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);
245 for (Int_t i = 0; i < fPoints; i++){
247 this->fL3Current[i] = obj.GetL3Current((Stats)i);
248 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
249 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
252 this->fMachineMode = obj.fMachineMode;
253 this->fLHCStateArray = obj.fLHCStateArray;
254 this->fMachineModeArray = obj.fMachineModeArray;
255 this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
257 this->fQATrigClasses = obj.fQATrigClasses;
258 this->fQACloningRequest = obj.fQACloningRequest;
260 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
261 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
267 //-----------------------------------------------------------------------------
269 AliGRPObject::~AliGRPObject() {
276 delete [] fHallProbes;
277 delete [] fL3Current;
278 delete [] fDipoleCurrent;
279 delete [] fCavernTemperature;
281 if (fCavernAtmosPressure){
282 delete fCavernAtmosPressure;
283 fCavernAtmosPressure = 0x0;
285 if (fCavernAtmosPressure2){
286 delete fCavernAtmosPressure2;
287 fCavernAtmosPressure2 = 0x0;
289 if (fSurfaceAtmosPressure){
290 delete fSurfaceAtmosPressure;
291 fSurfaceAtmosPressure = 0x0;
294 delete fLHCStateArray;
295 fLHCStateArray = 0x0;
297 if (fMachineModeArray){
298 delete fMachineModeArray;
299 fMachineModeArray = 0x0;
301 if (fQATrigClasses) {
302 delete fQATrigClasses;
303 fQATrigClasses = 0x0;
305 if (fQACloningRequest) {
306 delete fQACloningRequest;
307 fQACloningRequest = 0x0;
311 //-----------------------------------------------------------------------------
312 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
315 // method to return array of statistical
316 // variables for Hall Probe hp
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++){
323 array[i] = fHallProbes[shift+i];
329 //-------------------------------------------------------------------------------
331 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
334 // method to set hall probe hp
335 // from a given array
338 Int_t shift = fPoints*hp;
339 for (Int_t i = 0; i< fPoints; i++){
341 fHallProbes[i+shift] = hall_probe[i];
346 //-------------------------------------------------------------------------------
348 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
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
356 if (mapGRP->GetValue("fAliceStartTime")){
357 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
360 AliError(Form("No fAliceStartTime value found in GRP map!"));
362 if (mapGRP->GetValue("fAliceStopTime")){
363 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
367 AliError(Form("No fAliceStopTime value found in GRP map!"));
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)
376 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
378 if(mapGRP->GetValue("fAliceBeamType")){
379 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
382 AliError(Form("No fAliceBeamType value found in GRP map!"));
384 if(mapGRP->GetValue("fNumberOfDetectors")){
385 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi());
388 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
390 if(mapGRP->GetValue("fDetectorMask")){
391 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());
394 AliError(Form("No fDetectorMask value found in GRP map!"));
396 if(mapGRP->GetValue("fLHCPeriod")){
397 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
400 AliError(Form("No fLHCPeriod value found in GRP map!"));
402 if(mapGRP->GetValue("fRunType")){
403 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
406 AliError(Form("No fRunType value found in GRP map!"));
408 if(mapGRP->GetValue("fLHCState")){
409 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
412 AliError(Form("No fLHCState value found in GRP map!"));
414 if(mapGRP->GetValue("fLHCluminosity")){
415 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
418 AliError(Form("No fLHCLuminosity value found in GRP map!"));
420 if(mapGRP->GetValue("fBeamIntensity")){
421 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
424 AliError(Form("No fBeamIntensity value found in GRP map!"));
426 if(mapGRP->GetValue("fL3Polarity")){
427 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
430 AliError(Form("No fL3Polarity value found in GRP map!"));
432 if(mapGRP->GetValue("fDipolePolarity")){
433 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());
436 AliError(Form("No fDipolePolarity value found in GRP map!"));
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);
443 AliError(Form("No fL3Current value found in GRP map!"));
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);
450 AliError(Form("No fDipoleCurrent value found in GRP map!"));
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);
457 AliError(Form("No fCavernTemperature value found in GRP map!"));
459 if(mapGRP->GetValue("fCavernAtmosPressure")){
460 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
463 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
465 if(mapGRP->GetValue("fP2Pressure")){
466 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
469 AliError(Form("No fP2Pressure value found in GRP map!"));
475 //-------------------------------------------------------------------------------
477 Float_t AliGRPObject::GetBeamEnergy() const {
480 // Getting the energy
481 // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
484 Float_t energy = fBeamEnergy;
485 if (fBeamType=="A-A"){
486 energy = energy*82./208;
488 return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
491 //-------------------------------------------------------------------------------
493 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const {
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
499 return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
500 fSurfaceAtmosPressure,time,inside);
504 //-------------------------------------------------------------------------------
506 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1,
507 AliDCSSensor* cavern2, AliDCSSensor* surface,
508 const TTimeStamp& time, Bool_t& inside) {
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
515 Double_t valueSensor2 = cavern2->Eval(time,inside);
516 Double_t valueSensor1 = cavern1->Eval(time,inside);
517 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
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) ) {
531 //-------------------------------------------------------------------------------
533 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1,
534 AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
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
544 Double_t valueSensor2 = cavern2->Eval(time,inside);
545 Double_t valueSensor1 = cavern1->Eval(time,inside);
546 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
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) ) {
560 //-------------------------------------------------------------------------------
562 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) 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 time specified by TTimestamp
570 return GetBestCavernAtmosPressure(fCavernAtmosPressure,
571 fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
575 //-------------------------------------------------------------------------------
577 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure() const {
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
584 return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));