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),
115 fNFalseDataQualityFlag(0),
116 fFalseDataQualityFlag(0x0)
120 // AliGRPObject default ctor
123 fDimension = fgknDCSDPHallProbes*fPoints;
124 fHallProbes = new Float_t[fDimension];
126 for (Int_t nhp=0; nhp< fDimension; nhp++){ // setting to zero values for non working HP
127 if ((nhp >= 0 && nhp <= 1*fPoints-1) || // L3_BSF17_H1
128 (nhp >= 1*fPoints && nhp <= 2*fPoints-1) || // L3_BSF17_H2
129 (nhp >= 2*fPoints && nhp <= 3*fPoints-1) || // L3_BSF17_H3
130 (nhp >= 3*fPoints && nhp <= 4*fPoints-1) || // L3_BSF17_Temperature
131 (nhp >= 6*fPoints && nhp <= 7*fPoints-1) ) { // L3_BSF4_H3
132 fHallProbes[nhp] = 0; // setting to zero values for non working HP
133 AliDebug(2,Form("setting hp[%d] to zero = %f",
134 nhp, fHallProbes[nhp]));
137 fHallProbes[nhp] = fgkInvalidFloat;
142 for (Int_t i = 0; i < fPoints; i++){
144 fL3Current[i] = fgkInvalidFloat;
145 fDipoleCurrent[i] = fgkInvalidFloat;
146 fCavernTemperature[i] = fgkInvalidFloat;
149 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
150 fSeparateBeamType[ibeamType] = fgkInvalidString;
154 //-----------------------------------------------------------------------------
156 AliGRPObject::AliGRPObject(const AliGRPObject &obj):
158 fPoints(obj.fPoints),
159 fDimension(obj.fDimension),
160 fTimeStart(obj.fTimeStart),
161 fTimeEnd(obj.fTimeEnd),
162 fBeamEnergy(obj.fBeamEnergy),
163 fBeamType(obj.fBeamType),
164 fNumberOfDetectors(obj.fNumberOfDetectors),
165 fDetectorMask(obj.fDetectorMask),
166 fLHCPeriod(obj.fLHCPeriod),
167 fRunType(obj.fRunType),
168 fLHCState(obj.fLHCState),
169 fL3Polarity(obj.fL3Polarity),
170 fDipolePolarity(obj.fDipolePolarity),
171 fL3Current(new Float_t[fPoints]),
172 fDipoleCurrent(new Float_t[fPoints]),
173 fCavernTemperature(new Float_t[fPoints]),
174 fCavernAtmosPressure(obj.fCavernAtmosPressure),
175 fCavernAtmosPressure2(obj.fCavernAtmosPressure2),
176 fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),
178 fMachineMode(obj.fMachineMode),
179 fLHCStateArray(obj.fLHCStateArray),
180 fMachineModeArray(obj.fMachineModeArray),
181 fQATrigClasses(obj.fQATrigClasses),
182 fQACloningRequest(obj.fQACloningRequest),
183 fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity),
184 fNFalseDataQualityFlag(obj.fNFalseDataQualityFlag),
185 fFalseDataQualityFlag(obj.fFalseDataQualityFlag)
191 // AliGRPObject copy ctor
194 fHallProbes = new Float_t[fDimension];
196 for (Int_t nhp=0; nhp< fDimension; nhp++){
197 fHallProbes[nhp] = obj.fHallProbes[nhp];
200 for (Int_t i = 0; i < fPoints; i++){
202 fL3Current[i] = obj.fL3Current[i];
203 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
204 fCavernTemperature[i] = obj.fCavernTemperature[i];
207 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
208 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
212 //-----------------------------------------------------------------------------
214 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
218 // AliGRPObject assignment operator
221 if (&obj == this) return *this;
223 TObject::operator=(obj);
224 this->fTimeStart = obj.GetTimeStart();
225 this->fTimeEnd = obj.GetTimeEnd();
226 this->fBeamEnergy = obj.GetBeamEnergy();
227 this->fBeamType = obj.GetBeamType();
228 this->fNumberOfDetectors = obj.GetNumberOfDetectors();
229 this->fDetectorMask = obj.GetDetectorMask();
230 this->fLHCPeriod = obj.GetLHCPeriod();
231 this->fRunType = obj.GetRunType();
232 this->fLHCState = obj.GetLHCState();
233 this->fL3Polarity = obj.GetL3Polarity();
234 this->fDipolePolarity = obj.GetDipolePolarity();
235 this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();
236 this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();
237 this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();
238 this->fPoints = obj.GetPoints();
239 this->fDimension = obj.GetDimension();
241 this->fL3Current = new Float_t[fPoints];
242 this->fDipoleCurrent = new Float_t[fPoints];
243 this->fCavernTemperature = new Float_t[fPoints];
245 if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension];
246 for (Int_t nhp=0; nhp< fDimension; nhp++){
247 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);
250 for (Int_t i = 0; i < fPoints; i++){
252 this->fL3Current[i] = obj.GetL3Current((Stats)i);
253 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
254 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
257 this->fMachineMode = obj.fMachineMode;
258 this->fLHCStateArray = obj.fLHCStateArray;
259 this->fMachineModeArray = obj.fMachineModeArray;
260 this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
262 this->fQATrigClasses = obj.fQATrigClasses;
263 this->fQACloningRequest = obj.fQACloningRequest;
265 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
266 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
269 this->fNFalseDataQualityFlag = obj.fNFalseDataQualityFlag;
270 this->fFalseDataQualityFlag = obj.fFalseDataQualityFlag;
275 //-----------------------------------------------------------------------------
277 AliGRPObject::~AliGRPObject() {
284 delete [] fHallProbes;
285 delete [] fL3Current;
286 delete [] fDipoleCurrent;
287 delete [] fCavernTemperature;
289 if (fCavernAtmosPressure){
290 delete fCavernAtmosPressure;
291 fCavernAtmosPressure = 0x0;
293 if (fCavernAtmosPressure2){
294 delete fCavernAtmosPressure2;
295 fCavernAtmosPressure2 = 0x0;
297 if (fSurfaceAtmosPressure){
298 delete fSurfaceAtmosPressure;
299 fSurfaceAtmosPressure = 0x0;
302 delete fLHCStateArray;
303 fLHCStateArray = 0x0;
305 if (fMachineModeArray){
306 delete fMachineModeArray;
307 fMachineModeArray = 0x0;
309 if (fQATrigClasses) {
310 delete fQATrigClasses;
311 fQATrigClasses = 0x0;
313 if (fQACloningRequest) {
314 delete fQACloningRequest;
315 fQACloningRequest = 0x0;
317 if (fFalseDataQualityFlag){
318 delete fFalseDataQualityFlag;
319 fFalseDataQualityFlag = 0x0;
323 //-----------------------------------------------------------------------------
324 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
327 // method to return array of statistical
328 // variables for Hall Probe hp
331 Float_t* array = new Float_t[fPoints];
332 Int_t shift = fPoints*(Int_t)hp;
333 for (Int_t i=0;i<fPoints; i++){
335 array[i] = fHallProbes[shift+i];
341 //-------------------------------------------------------------------------------
343 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
346 // method to set hall probe hp
347 // from a given array
350 Int_t shift = fPoints*hp;
351 for (Int_t i = 0; i< fPoints; i++){
353 fHallProbes[i+shift] = hall_probe[i];
358 //-------------------------------------------------------------------------------
360 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
363 // method to set the values of the GRP parameters
364 // reading them from the old format of the GRP
365 // object, i.e. a TMap
368 if (mapGRP->GetValue("fAliceStartTime")){
369 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
372 AliError(Form("No fAliceStartTime value found in GRP map!"));
374 if (mapGRP->GetValue("fAliceStopTime")){
375 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
379 AliError(Form("No fAliceStopTime value found in GRP map!"));
382 if(mapGRP->GetValue("fAliceBeamEnergy")){
383 double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();
384 if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2; // old format was storig sqrt(s)
388 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
390 if(mapGRP->GetValue("fAliceBeamType")){
391 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
394 AliError(Form("No fAliceBeamType value found in GRP map!"));
396 if(mapGRP->GetValue("fNumberOfDetectors")){
397 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi());
398 AliDebug(1, Form("fNumberOfDetectors = %d", fNumberOfDetectors));
401 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
403 if(mapGRP->GetValue("fDetectorMask")){
404 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());
405 AliDebug(1, Form("fDetectorMask = %d",fDetectorMask));
408 AliError(Form("No fDetectorMask value found in GRP map!"));
410 if(mapGRP->GetValue("fLHCPeriod")){
411 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
414 AliError(Form("No fLHCPeriod value found in GRP map!"));
416 if(mapGRP->GetValue("fRunType")){
417 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
420 AliError(Form("No fRunType value found in GRP map!"));
422 if(mapGRP->GetValue("fLHCState")){
423 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
426 AliError(Form("No fLHCState value found in GRP map!"));
428 if(mapGRP->GetValue("fLHCluminosity")){
429 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
432 AliError(Form("No fLHCLuminosity value found in GRP map!"));
434 if(mapGRP->GetValue("fBeamIntensity")){
435 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
438 AliError(Form("No fBeamIntensity value found in GRP map!"));
440 if(mapGRP->GetValue("fL3Polarity")){
441 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
444 AliError(Form("No fL3Polarity value found in GRP map!"));
446 if(mapGRP->GetValue("fDipolePolarity")){
447 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());
450 AliError(Form("No fDipolePolarity value found in GRP map!"));
452 if(mapGRP->GetValue("fL3Current")){
453 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));
454 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);
457 AliError(Form("No fL3Current value found in GRP map!"));
459 if(mapGRP->GetValue("fDipoleCurrent")){
460 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));
461 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);
464 AliError(Form("No fDipoleCurrent value found in GRP map!"));
466 if(mapGRP->GetValue("fCavernTemperature")){
467 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));
468 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);
471 AliError(Form("No fCavernTemperature value found in GRP map!"));
473 if(mapGRP->GetValue("fCavernAtmosPressure")){
474 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
477 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
479 if(mapGRP->GetValue("fP2Pressure")){
480 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
483 AliError(Form("No fP2Pressure value found in GRP map!"));
489 //-------------------------------------------------------------------------------
491 Float_t AliGRPObject::GetBeamEnergy() const {
494 // Getting the energy
495 // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
498 Float_t energy = fBeamEnergy;
499 if (fBeamType=="A-A"){
500 energy = energy*82./208;
502 return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
505 //-------------------------------------------------------------------------------
507 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const {
509 // Return current pressure value from 'best' cavern sensor
510 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
511 // use sensor most compatible with surface sensor
513 return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
514 fSurfaceAtmosPressure,time,inside);
518 //-------------------------------------------------------------------------------
520 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1,
521 AliDCSSensor* cavern2, AliDCSSensor* surface,
522 const TTimeStamp& time, Bool_t& inside) {
524 // Return current pressure value from 'best' cavern sensor
525 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
526 // use sensor most compatible with surface sensor
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(AliDCSSensor* cavern1,
548 AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
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 time specified by TTimestamp
558 Double_t valueSensor2 = cavern2->Eval(time,inside);
559 Double_t valueSensor1 = cavern1->Eval(time,inside);
560 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
563 Double_t valueSurface = surface->Eval(time,inside);
564 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
565 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
566 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
574 //-------------------------------------------------------------------------------
576 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
578 // Return pointer to 'best' cavern sensor
579 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
580 // use sensor most compatible with surface sensor
581 // Pressure measuread at time specified by TTimestamp
584 return GetBestCavernAtmosPressure(fCavernAtmosPressure,
585 fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
589 //-------------------------------------------------------------------------------
591 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure() const {
593 // Return pointer to 'best' cavern sensor
594 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
595 // use sensor most compatible with surface sensor
596 // Pressure measuread at start-of-run
598 return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));
601 //-------------------------------------------------------------------------------
602 void AliGRPObject::SetFalseDataQualityFlagPeriods(Double_t* falses){
605 // setting the starts (even positions in the array) and ends (odd positions in the array)
606 // of the periods when the Data Quality Flag was set to FALSE
609 fFalseDataQualityFlag = new TArrayD(fNFalseDataQualityFlag*2,falses);
612 //-------------------------------------------------------------------------------
613 Double_t AliGRPObject::GetStartFalseDataQualityFlag(Int_t iperiod) const {
616 // returning the start timestamp of the FALSE period "iperiod"
619 if (iperiod < fNFalseDataQualityFlag){
620 return fFalseDataQualityFlag->At(iperiod*2);
623 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
628 //-------------------------------------------------------------------------------
629 Double_t AliGRPObject::GetEndFalseDataQualityFlag(Int_t iperiod) const {
632 // returning the end timestamp of the FALSE period "iperiod"
635 if (iperiod < fNFalseDataQualityFlag){
636 return fFalseDataQualityFlag->At(iperiod*2+1);
639 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));