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),
117 fBeamTypeFromLHC(fgkInvalidString)
121 // AliGRPObject default ctor
124 fDimension = fgknDCSDPHallProbes*fPoints;
125 fHallProbes = new Float_t[fDimension];
127 for (Int_t nhp=0; nhp< fDimension; nhp++){ // setting to zero values for non working HP
128 if ((nhp >= 0 && nhp <= 1*fPoints-1) || // L3_BSF17_H1
129 (nhp >= 1*fPoints && nhp <= 2*fPoints-1) || // L3_BSF17_H2
130 (nhp >= 2*fPoints && nhp <= 3*fPoints-1) || // L3_BSF17_H3
131 (nhp >= 3*fPoints && nhp <= 4*fPoints-1) || // L3_BSF17_Temperature
132 (nhp >= 6*fPoints && nhp <= 7*fPoints-1) ) { // L3_BSF4_H3
133 fHallProbes[nhp] = 0; // setting to zero values for non working HP
134 AliDebug(2,Form("setting hp[%d] to zero = %f",
135 nhp, fHallProbes[nhp]));
138 fHallProbes[nhp] = fgkInvalidFloat;
143 for (Int_t i = 0; i < fPoints; i++){
145 fL3Current[i] = fgkInvalidFloat;
146 fDipoleCurrent[i] = fgkInvalidFloat;
147 fCavernTemperature[i] = fgkInvalidFloat;
150 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
151 fSeparateBeamType[ibeamType] = fgkInvalidString;
155 //-----------------------------------------------------------------------------
157 AliGRPObject::AliGRPObject(const AliGRPObject &obj):
159 fPoints(obj.fPoints),
160 fDimension(obj.fDimension),
161 fTimeStart(obj.fTimeStart),
162 fTimeEnd(obj.fTimeEnd),
163 fBeamEnergy(obj.fBeamEnergy),
164 fBeamType(obj.fBeamType),
165 fNumberOfDetectors(obj.fNumberOfDetectors),
166 fDetectorMask(obj.fDetectorMask),
167 fLHCPeriod(obj.fLHCPeriod),
168 fRunType(obj.fRunType),
169 fLHCState(obj.fLHCState),
170 fL3Polarity(obj.fL3Polarity),
171 fDipolePolarity(obj.fDipolePolarity),
172 fL3Current(new Float_t[fPoints]),
173 fDipoleCurrent(new Float_t[fPoints]),
174 fCavernTemperature(new Float_t[fPoints]),
175 fCavernAtmosPressure(obj.fCavernAtmosPressure),
176 fCavernAtmosPressure2(obj.fCavernAtmosPressure2),
177 fSurfaceAtmosPressure(obj.fSurfaceAtmosPressure),
179 fMachineMode(obj.fMachineMode),
180 fLHCStateArray(obj.fLHCStateArray),
181 fMachineModeArray(obj.fMachineModeArray),
182 fQATrigClasses(obj.fQATrigClasses),
183 fQACloningRequest(obj.fQACloningRequest),
184 fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity),
185 fNFalseDataQualityFlag(obj.fNFalseDataQualityFlag),
186 fFalseDataQualityFlag(obj.fFalseDataQualityFlag),
187 fBeamTypeFromLHC(obj.fBeamTypeFromLHC)
193 // AliGRPObject copy ctor
196 fHallProbes = new Float_t[fDimension];
198 for (Int_t nhp=0; nhp< fDimension; nhp++){
199 fHallProbes[nhp] = obj.fHallProbes[nhp];
202 for (Int_t i = 0; i < fPoints; i++){
204 fL3Current[i] = obj.fL3Current[i];
205 fDipoleCurrent[i] = obj.fDipoleCurrent[i];
206 fCavernTemperature[i] = obj.fCavernTemperature[i];
209 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
210 fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
214 //-----------------------------------------------------------------------------
216 AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
220 // AliGRPObject assignment operator
223 if (&obj == this) return *this;
225 TObject::operator=(obj);
226 this->fTimeStart = obj.GetTimeStart();
227 this->fTimeEnd = obj.GetTimeEnd();
228 this->fBeamEnergy = obj.GetBeamEnergy();
229 this->fBeamType = obj.GetBeamType();
230 this->fNumberOfDetectors = obj.GetNumberOfDetectors();
231 this->fDetectorMask = obj.GetDetectorMask();
232 this->fLHCPeriod = obj.GetLHCPeriod();
233 this->fRunType = obj.GetRunType();
234 this->fLHCState = obj.GetLHCState();
235 this->fL3Polarity = obj.GetL3Polarity();
236 this->fDipolePolarity = obj.GetDipolePolarity();
237 this->fCavernAtmosPressure = obj.GetCavernAtmosPressure();
238 this->fCavernAtmosPressure2 = obj.GetCavernAtmosPressure2();
239 this->fSurfaceAtmosPressure = obj.GetSurfaceAtmosPressure();
240 this->fPoints = obj.GetPoints();
241 this->fDimension = obj.GetDimension();
243 this->fL3Current = new Float_t[fPoints];
244 this->fDipoleCurrent = new Float_t[fPoints];
245 this->fCavernTemperature = new Float_t[fPoints];
247 if (this->fHallProbes==NULL) this->fHallProbes = new Float_t[this->fDimension];
248 for (Int_t nhp=0; nhp< fDimension; nhp++){
249 this->fHallProbes[nhp] = obj.GetHallProbes(nhp);
252 for (Int_t i = 0; i < fPoints; i++){
254 this->fL3Current[i] = obj.GetL3Current((Stats)i);
255 this->fDipoleCurrent[i] = obj.GetDipoleCurrent((Stats)i);
256 this->fCavernTemperature[i] = obj.GetCavernTemperature((Stats)i);
259 this->fMachineMode = obj.fMachineMode;
260 this->fLHCStateArray = obj.fLHCStateArray;
261 this->fMachineModeArray = obj.fMachineModeArray;
262 this->fMaxTimeLHCValidity = obj.fMaxTimeLHCValidity;
264 this->fQATrigClasses = obj.fQATrigClasses;
265 this->fQACloningRequest = obj.fQACloningRequest;
267 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
268 this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
271 this->fNFalseDataQualityFlag = obj.fNFalseDataQualityFlag;
272 this->fFalseDataQualityFlag = obj.fFalseDataQualityFlag;
273 this->fBeamTypeFromLHC = obj.fBeamTypeFromLHC;
278 //-----------------------------------------------------------------------------
280 AliGRPObject::~AliGRPObject() {
287 delete [] fHallProbes;
288 delete [] fL3Current;
289 delete [] fDipoleCurrent;
290 delete [] fCavernTemperature;
292 if (fCavernAtmosPressure){
293 delete fCavernAtmosPressure;
294 fCavernAtmosPressure = 0x0;
296 if (fCavernAtmosPressure2){
297 delete fCavernAtmosPressure2;
298 fCavernAtmosPressure2 = 0x0;
300 if (fSurfaceAtmosPressure){
301 delete fSurfaceAtmosPressure;
302 fSurfaceAtmosPressure = 0x0;
305 delete fLHCStateArray;
306 fLHCStateArray = 0x0;
308 if (fMachineModeArray){
309 delete fMachineModeArray;
310 fMachineModeArray = 0x0;
312 if (fQATrigClasses) {
313 delete fQATrigClasses;
314 fQATrigClasses = 0x0;
316 if (fQACloningRequest) {
317 delete fQACloningRequest;
318 fQACloningRequest = 0x0;
320 if (fFalseDataQualityFlag){
321 delete fFalseDataQualityFlag;
322 fFalseDataQualityFlag = 0x0;
326 //-----------------------------------------------------------------------------
327 Float_t* AliGRPObject::GetHallProbesArray(DP_HallProbes hp) const {
330 // method to return array of statistical
331 // variables for Hall Probe hp
334 Float_t* array = new Float_t[fPoints];
335 Int_t shift = fPoints*(Int_t)hp;
336 for (Int_t i=0;i<fPoints; i++){
338 array[i] = fHallProbes[shift+i];
344 //-------------------------------------------------------------------------------
346 void AliGRPObject::SetHallProbes(DP_HallProbes hp, const Float_t* hall_probe){
349 // method to set hall probe hp
350 // from a given array
353 Int_t shift = fPoints*hp;
354 for (Int_t i = 0; i< fPoints; i++){
356 fHallProbes[i+shift] = hall_probe[i];
361 //-------------------------------------------------------------------------------
363 void AliGRPObject::ReadValuesFromMap(const TMap* mapGRP){
366 // method to set the values of the GRP parameters
367 // reading them from the old format of the GRP
368 // object, i.e. a TMap
371 if (mapGRP->GetValue("fAliceStartTime")){
372 SetTimeStart((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi());
375 AliError(Form("No fAliceStartTime value found in GRP map!"));
377 if (mapGRP->GetValue("fAliceStopTime")){
378 SetTimeEnd((time_t)(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi());
382 AliError(Form("No fAliceStopTime value found in GRP map!"));
385 if(mapGRP->GetValue("fAliceBeamEnergy")){
386 double be = (((TObjString*)(mapGRP->GetValue("fAliceBeamEnergy")))->GetString()).Atof();
387 if (IsBeamEnergyIsSqrtSHalfGeV()) be/=2; // old format was storig sqrt(s)
391 AliError(Form("No fAliceBeamEnergy value found in GRP map!"));
393 if(mapGRP->GetValue("fAliceBeamType")){
394 SetBeamType(((TObjString*)(mapGRP->GetValue("fAliceBeamType")))->GetString());
397 AliError(Form("No fAliceBeamType value found in GRP map!"));
399 if(mapGRP->GetValue("fNumberOfDetectors")){
400 SetNumberOfDetectors((Char_t)(((TObjString*)(mapGRP->GetValue("fNumberOfDetectors")))->GetString()).Atoi());
401 AliDebug(1, Form("fNumberOfDetectors = %d", fNumberOfDetectors));
404 AliError(Form("No fNumberOfDetectors value found in GRP map!"));
406 if(mapGRP->GetValue("fDetectorMask")){
407 SetDetectorMask((UInt_t)(((TObjString*)(mapGRP->GetValue("fDetectorMask")))->GetString()).Atoi());
408 AliDebug(1, Form("fDetectorMask = %d",fDetectorMask));
411 AliError(Form("No fDetectorMask value found in GRP map!"));
413 if(mapGRP->GetValue("fLHCPeriod")){
414 SetLHCPeriod(((TObjString*)(mapGRP->GetValue("fLHCPeriod")))->GetString());
417 AliError(Form("No fLHCPeriod value found in GRP map!"));
419 if(mapGRP->GetValue("fRunType")){
420 SetRunType(((TObjString*)(mapGRP->GetValue("fRunType")))->GetString());
423 AliError(Form("No fRunType value found in GRP map!"));
425 if(mapGRP->GetValue("fLHCState")){
426 SetLHCState(((TObjString*)(mapGRP->GetValue("fLHCState")))->GetString());
429 AliError(Form("No fLHCState value found in GRP map!"));
431 if(mapGRP->GetValue("fLHCluminosity")){
432 AliInfo(Form("fLHCLuminosity found, but not there anymore in the new object"));
435 AliError(Form("No fLHCLuminosity value found in GRP map!"));
437 if(mapGRP->GetValue("fBeamIntensity")){
438 AliInfo(Form("fBeamIntensity found, but not there anymore in the new object"));
441 AliError(Form("No fBeamIntensity value found in GRP map!"));
443 if(mapGRP->GetValue("fL3Polarity")){
444 SetL3Polarity((Char_t)(((TObjString*)(mapGRP->GetValue("fL3Polarity")))->GetString()).Atoi());
447 AliError(Form("No fL3Polarity value found in GRP map!"));
449 if(mapGRP->GetValue("fDipolePolarity")){
450 SetDipolePolarity((Char_t)(((TObjString*)(mapGRP->GetValue("fDipolePolarity")))->GetString()).Atoi());
453 AliError(Form("No fDipolePolarity value found in GRP map!"));
455 if(mapGRP->GetValue("fL3Current")){
456 AliInfo(Form("fL3Current found, but porting only average to the new object, since the other values are not available in the old object"));
457 SetL3Current((Float_t)(((TObjString*)(mapGRP->GetValue("fL3Current")))->GetString()).Atof(),(Stats)0);
460 AliError(Form("No fL3Current value found in GRP map!"));
462 if(mapGRP->GetValue("fDipoleCurrent")){
463 AliInfo(Form("fDipoleCurrent found, but porting only average to the new object, since the other values are not available in the old object"));
464 SetDipoleCurrent((Float_t)(((TObjString*)(mapGRP->GetValue("fDipoleCurrent")))->GetString()).Atof(),(Stats)0);
467 AliError(Form("No fDipoleCurrent value found in GRP map!"));
469 if(mapGRP->GetValue("fCavernTemperature")){
470 AliInfo(Form("fCaverntemperature found, but porting only average to the new object, since the other values are not available in the old object"));
471 SetCavernTemperature((Float_t)(((TObjString*)(mapGRP->GetValue("fCavernTemperature")))->GetString()).Atof(),(Stats)0);
474 AliError(Form("No fCavernTemperature value found in GRP map!"));
476 if(mapGRP->GetValue("fCavernAtmosPressure")){
477 AliInfo(Form("fCavernAtmosPressure found, but not ported to the new object since of a different type"));
480 AliError(Form("No fCavernAtmosPressure value found in GRP map!"));
482 if(mapGRP->GetValue("fP2Pressure")){
483 SetSurfaceAtmosPressure((AliDCSSensor*)((TObjString*)(mapGRP->GetValue("fP2Pressure"))));
486 AliError(Form("No fP2Pressure value found in GRP map!"));
492 //-------------------------------------------------------------------------------
494 Float_t AliGRPObject::GetBeamEnergy() const {
497 // Getting the energy
498 // in case of BeamType = A-A, multiplying by 82/208 (for PbPb)
501 Float_t energy = fBeamEnergy;
502 if (fBeamType=="A-A"){
503 energy = energy*82./208;
505 return IsBeamEnergyIsSqrtSHalfGeV() ? energy : energy/2;
508 //-------------------------------------------------------------------------------
510 Double_t AliGRPObject::EvalCavernPressure(const TTimeStamp& time, Bool_t& inside) const {
512 // Return current pressure value from 'best' cavern sensor
513 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
514 // use sensor most compatible with surface sensor
516 return EvalCavernPressure(fCavernAtmosPressure,fCavernAtmosPressure2,
517 fSurfaceAtmosPressure,time,inside);
521 //-------------------------------------------------------------------------------
523 Double_t AliGRPObject::EvalCavernPressure(AliDCSSensor* cavern1,
524 AliDCSSensor* cavern2, AliDCSSensor* surface,
525 const TTimeStamp& time, Bool_t& inside) {
527 // Return current pressure value from 'best' cavern sensor
528 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
529 // use sensor most compatible with surface sensor
532 Double_t valueSensor2 = cavern2->Eval(time,inside);
533 Double_t valueSensor1 = cavern1->Eval(time,inside);
534 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
537 Double_t valueSurface = surface->Eval(time,inside);
538 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
539 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
540 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
548 //-------------------------------------------------------------------------------
550 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(AliDCSSensor* cavern1,
551 AliDCSSensor* cavern2, AliDCSSensor* surface, const TTimeStamp& time) {
554 // Return pointer to 'best' cavern sensor
555 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
556 // use sensor most compatible with surface sensor
557 // Pressure measuread at time specified by TTimestamp
561 Double_t valueSensor2 = cavern2->Eval(time,inside);
562 Double_t valueSensor1 = cavern1->Eval(time,inside);
563 if (TMath::Abs(valueSensor2-valueSensor1)<kCavernCut) {
566 Double_t valueSurface = surface->Eval(time,inside);
567 Double_t diff1 = TMath::Abs(valueSensor1-valueSurface-kSurfaceDifference);
568 Double_t diff2 = TMath::Abs(valueSensor2-valueSurface-kSurfaceDifference);
569 if (TMath::Abs(diff1)<TMath::Abs(diff2) ) {
577 //-------------------------------------------------------------------------------
579 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure(const TTimeStamp& time) const {
581 // Return pointer to 'best' cavern sensor
582 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
583 // use sensor most compatible with surface sensor
584 // Pressure measuread at time specified by TTimestamp
587 return GetBestCavernAtmosPressure(fCavernAtmosPressure,
588 fCavernAtmosPressure2, fSurfaceAtmosPressure, time);
592 //-------------------------------------------------------------------------------
594 AliDCSSensor* AliGRPObject::GetBestCavernAtmosPressure() const {
596 // Return pointer to 'best' cavern sensor
597 // (default sensor 2. If sensor 1 and sensor 2 are sufficiently different,
598 // use sensor most compatible with surface sensor
599 // Pressure measuread at start-of-run
601 return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));
604 //-------------------------------------------------------------------------------
605 void AliGRPObject::SetFalseDataQualityFlagPeriods(Double_t* falses){
608 // setting the starts (even positions in the array) and ends (odd positions in the array)
609 // of the periods when the Data Quality Flag was set to FALSE
612 fFalseDataQualityFlag = new TArrayD(fNFalseDataQualityFlag*2,falses);
615 //-------------------------------------------------------------------------------
616 Double_t AliGRPObject::GetStartFalseDataQualityFlag(Int_t iperiod) const {
619 // returning the start timestamp of the FALSE period "iperiod"
622 if (iperiod < fNFalseDataQualityFlag){
623 return fFalseDataQualityFlag->At(iperiod*2);
626 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
631 //-------------------------------------------------------------------------------
632 Double_t AliGRPObject::GetEndFalseDataQualityFlag(Int_t iperiod) const {
635 // returning the end timestamp of the FALSE period "iperiod"
638 if (iperiod < fNFalseDataQualityFlag){
639 return fFalseDataQualityFlag->At(iperiod*2+1);
642 AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));