Adding processing of Data Quality Flag coming from LHC Data File.
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Jul 2011 10:39:42 +0000 (10:39 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Jul 2011 10:39:42 +0000 (10:39 +0000)
The start and end time of the periods during which it is set to FALSE is stored in the AliGRPObject OCDB entry (GRP/GRP/Data).
No error is issued in the present version - as decided - if the flag is not there or if it starts with a FALSE value.

GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt
GRP/ShuttleInput/testShuttle_GRP_run_number_testShuttle_data.txt
STEER/STEER/AliGRPObject.cxx
STEER/STEER/AliGRPObject.h
STEER/STEER/AliGRPPreprocessor.cxx

index 367fc31..7e2cd0d 100644 (file)
@@ -80,5 +80,5 @@ LHC_ENTRIES   81
 78     BPTX_Phase_Shift_B2     f:1     70      0.31657384615382        1020.962        0.30793230769228        1021.799        0.32352923076921        1022.221        0.26893999999998        1023.737        0.31847076923075        1024.143        0.30582461538459        1025.581        0.30181999999998        1026.894        0.30413846153844        1027.58 0.28622307692305        1028.543        0.29570769230767        1029.153        0.28959538461536        1030.356        0.30076615384613        1031.653        0.3228969230769 1032.966        0.32205384615382        1033.865        0.29444307692305        1034.287        0.29233538461536        1035.725        0.29992307692305        1036.147        0.27610615384613        1037.726        0.27420923076921        1038.991        0.28032153846151        1039.140        0.28516923076921        1040.562        0.29170307692305        1041.47 0.2954969230769 1042.500        0.30308461538459        1043.938        0.26936153846151        1044.236        0.30835384615382        1045.40 0.28495846153844        1046.494        0.29507538461536        1047.932        0.28306153846152        1048.229        0.30139846153844        1049.510        0.29444307692305        1050.440        0.29402153846151        1051.894        0.30076615384613        1052.425        0.29950153846152        1053.707        0.30224153846152        1054.176        0.3064569230769 1055.676        0.28411538461536        1056.247        0.30203076923074        1057.685        0.32036769230767        1058.169        0.28811999999997        1059.654        0.29128153846152        1060.76 0.28432615384613        1061.405        0.31825999999998        1062.100        0.30160923076921        1063.538        0.31067230769228        1064.976        0.30729999999997        1065.461        0.29655076923075        1066.930        0.30603538461536        1067.118        0.28875230769228        1068.844        0.27779230769229        1069.345        0.28474769230766        1070.642        0.27210153846152        1071.126        0.29212461538459        1072.517        0.27947846153844        1073.908        0.28854153846152        1074.854        0.28011076923075        1075.120        0.28053230769229        1076.683        0.27589538461536        1077.136        0.28959538461536        1078.496        0.28137538461536        1079.902        0.28074307692305        1080.145        0.29381076923075        1081.473        0.29423230769229        1082.974        0.2872769230769 1083.380        0.26556769230767        1084.818        0.27146923076921        1085.920        0.31277999999998        1086.233        0.30856461538459        1087.624        0.28706615384613        1088.140        0.27547384615383        1089.953        
 79     LHC_Particle_Type_B1    s:1     1       PROTON  1020.0  
 80     LHC_Particle_Type_B2    s:1     1       PROTON  1020.0  
-81     LHC_Data_Quality_Flag   b:1     1       1       1020.0  
+81     LHC_Data_Quality_Flag   b:1     10      0       1018.0  0       1019.1  1       1019.3  0       1020.2  1       1022.0  0       1022.5  0       1022.7  1       1022.8  0       1022.9  0       1023.0 
 ==== END_OF_BLOCK ====
index bb2f97c..bb9da86 100644 (file)
@@ -80,5 +80,5 @@ LHC_ENTRIES   81
 78     BPTX_Phase_Shift_B2     f:1     70      0.31657384615382        1302715830.962  0.30793230769228        1302715831.799  0.32352923076921        1302715832.221  0.26893999999998        1302715833.737  0.31847076923075        1302715834.143  0.30582461538459        1302715835.581  0.30181999999998        1302715836.894  0.30413846153844        1302715837.58   0.28622307692305        1302715838.543  0.29570769230767        1302715839.153  0.28959538461536        1302715840.356  0.30076615384613        1302715841.653  0.3228969230769 1302715842.966  0.32205384615382        1302715843.865  0.29444307692305        1302715844.287  0.29233538461536        1302715845.725  0.29992307692305        1302715846.147  0.27610615384613        1302715847.726  0.27420923076921        1302715848.991  0.28032153846151        1302715849.140  0.28516923076921        1302715850.562  0.29170307692305        1302715851.47   0.2954969230769 1302715852.500  0.30308461538459        1302715853.938  0.26936153846151        1302715854.236  0.30835384615382        1302715855.40   0.28495846153844        1302715856.494  0.29507538461536        1302715857.932  0.28306153846152        1302715858.229  0.30139846153844        1302715859.510  0.29444307692305        1302715860.440  0.29402153846151        1302715861.894  0.30076615384613        1302715862.425  0.29950153846152        1302715863.707  0.30224153846152        1302715864.176  0.3064569230769 1302715865.676  0.28411538461536        1302715866.247  0.30203076923074        1302715867.685  0.32036769230767        1302715868.169  0.28811999999997        1302715869.654  0.29128153846152        1302715870.76   0.28432615384613        1302715871.405  0.31825999999998        1302715872.100  0.30160923076921        1302715873.538  0.31067230769228        1302715874.976  0.30729999999997        1302715875.461  0.29655076923075        1302715876.930  0.30603538461536        1302715877.118  0.28875230769228        1302715878.844  0.27779230769229        1302715879.345  0.28474769230766        1302715880.642  0.27210153846152        1302715881.126  0.29212461538459        1302715882.517  0.27947846153844        1302715883.908  0.28854153846152        1302715884.854  0.28011076923075        1302715885.120  0.28053230769229        1302715886.683  0.27589538461536        1302715887.136  0.28959538461536        1302715888.496  0.28137538461536        1302715889.902  0.28074307692305        1302715890.145  0.29381076923075        1302715891.473  0.29423230769229        1302715892.974  0.2872769230769 1302715893.380  0.26556769230767        1302715894.818  0.27146923076921        1302715895.920  0.31277999999998        1302715896.233  0.30856461538459        1302715897.624  0.28706615384613        1302715898.140  0.27547384615383        1302715899.953  \r
 79     LHC_Particle_Type_B1    s:1     1       PROTON  1297160580.0    \r
 80     LHC_Particle_Type_B2    s:1     1       PROTON  1297160580.0    \r
-81     LHC_Data_Quality_Flag   b:1     1       1       1297160580.0    \r
+81     LHC_Data_Quality_Flag   b:1     5       1       1297160580.0    0       1297160581.0    0       1297160582.0    1       1297160583.0    0       1297160584.0    \r
 ==== END_OF_BLOCK ====\r
index 2154d46..19de27e 100644 (file)
@@ -111,7 +111,9 @@ AliGRPObject::AliGRPObject():
        fMachineModeArray(0x0),
        fQATrigClasses(0x0),
        fQACloningRequest(0x0),
-       fMaxTimeLHCValidity(0)
+       fMaxTimeLHCValidity(0),
+       fNFalseDataQualityFlag(0),
+       fFalseDataQualityFlag(0x0)
 {
 
        //
@@ -178,7 +180,10 @@ AliGRPObject::AliGRPObject(const AliGRPObject &obj):
        fMachineModeArray(obj.fMachineModeArray),
        fQATrigClasses(obj.fQATrigClasses),
        fQACloningRequest(obj.fQACloningRequest),
-       fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity)
+       fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity),
+       fNFalseDataQualityFlag(obj.fNFalseDataQualityFlag),
+       fFalseDataQualityFlag(obj.fFalseDataQualityFlag)
+
 
 {
 
@@ -261,6 +266,9 @@ AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
                this->fSeparateBeamType[ibeamType] = obj.fSeparateBeamType[ibeamType];
        }
 
+       this->fNFalseDataQualityFlag = obj.fNFalseDataQualityFlag;
+       this->fFalseDataQualityFlag = obj.fFalseDataQualityFlag;
+
        return *this;
 }
 
@@ -306,6 +314,10 @@ AliGRPObject::~AliGRPObject() {
          delete fQACloningRequest;
          fQACloningRequest = 0x0;
        }
+       if (fFalseDataQualityFlag){
+               delete fFalseDataQualityFlag;
+               fFalseDataQualityFlag = 0x0;
+       }
 }
 
 //-----------------------------------------------------------------------------
@@ -584,3 +596,45 @@ AliDCSSensor*   AliGRPObject::GetBestCavernAtmosPressure() const {
    return GetBestCavernAtmosPressure(TTimeStamp(fTimeStart));
 }
 
+//-------------------------------------------------------------------------------
+void AliGRPObject::SetFalseDataQualityFlagPeriods(Double_t* falses){
+       
+       //
+       // setting the starts (even positions in the array) and ends (odd positions in the array)
+       // of the periods when the Data Quality Flag was set to FALSE
+       //
+       
+       fFalseDataQualityFlag = new TArrayD(fNFalseDataQualityFlag*2,falses);
+}
+
+//-------------------------------------------------------------------------------
+Double_t AliGRPObject::GetStartFalseDataQualityFlag(Int_t iperiod) const {
+       
+       // 
+       // returning the start timestamp of the FALSE period "iperiod"
+       //
+       
+       if (iperiod < fNFalseDataQualityFlag){
+               return fFalseDataQualityFlag->At(iperiod*2);
+       }
+       else{
+               AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
+       }
+       return -1.;
+}
+
+//-------------------------------------------------------------------------------
+Double_t AliGRPObject::GetEndFalseDataQualityFlag(Int_t iperiod) const {
+       
+       // 
+       // returning the end timestamp of the FALSE period "iperiod"
+       //
+       
+       if (iperiod < fNFalseDataQualityFlag){
+               return fFalseDataQualityFlag->At(iperiod*2+1);
+       }
+       else{
+               AliError(Form("You are looking for FALSE period %d, but the number of FALSE periods was %d - returning -1!", iperiod, fNFalseDataQualityFlag));
+       }
+       return -1.;
+}
index 8218d50..e64f8c6 100644 (file)
@@ -15,6 +15,7 @@
 #include <time.h>\r
 #include <TString.h>\r
 #include <TTimeStamp.h>\r
+#include <TArrayD.h>\r
 \r
 class TMap;\r
 \r
@@ -160,6 +161,15 @@ class AliGRPObject : public TObject {
        void SetSingleBeamType(Int_t ibeamType, TString beamType)  {fSeparateBeamType[ibeamType] = beamType;}\r
        TString   GetSingleBeamType(Int_t ibeamType) const {return fBeamType[ibeamType];}\r
 \r
+       void SetNFalseDataQualityFlag(Int_t nFalses) {fNFalseDataQualityFlag = nFalses;}\r
+       Int_t GetNFalseDataQualityFlag() const {return fNFalseDataQualityFlag;}\r
+\r
+       void SetFalseDataQualityFlagPeriods(Double_t* falses);\r
+       TArrayD* GetFalseDataQualityFlagPeriods() const {return fFalseDataQualityFlag;}\r
+\r
+       Double_t GetStartFalseDataQualityFlag(Int_t iperiod) const;\r
+       Double_t GetEndFalseDataQualityFlag(Int_t iperiod) const;\r
+\r
  private:\r
 \r
        static const Float_t fgkInvalidFloat;   // value to identify invalid data - float\r
@@ -206,8 +216,11 @@ class AliGRPObject : public TObject {
        TObjArray* fQACloningRequest;  // RS: Array of cloning requests for QA histos\r
        Double_t fMaxTimeLHCValidity;    // time until which the LHC Data Machine Mode and Beam Mode didn't change \r
        TString  fSeparateBeamType[2];   // separate beam Types from LHC\r
-\r
-       ClassDef(AliGRPObject,8)\r
+       Int_t fNFalseDataQualityFlag;    // number of times the data quality flag turned to FALSE\r
+       TArrayD* fFalseDataQualityFlag;  // array of starts (even positions) and ends (odd poistions) of the periods\r
+                                        // when the data quality flag was FALSE\r
+       \r
+       ClassDef(AliGRPObject,9)\r
 \r
 };\r
 \r
index 9f5b1a0..15ed3cf 100644 (file)
@@ -65,8 +65,9 @@ class AliShuttleInterface;
 #include <AliCDBManager.h>
 #include <AliCDBMetaData.h>
 #include <AliCDBId.h>
-#include "AliCTPTimeParams.h"
-#include "AliLHCClockPhase.h"
+#include <AliTriggerConfiguration.h>
+#include <AliCTPTimeParams.h>
+#include <AliLHCClockPhase.h>
 
 const Double_t kFitFraction = -1.;                 // Fraction of DCS sensor fits required
 
@@ -77,7 +78,7 @@ ClassImp(AliGRPPreprocessor)
   const Int_t AliGRPPreprocessor::fgknDAQLbPar = 6; // num parameters in the logbook used to fill the GRP object
   const Int_t AliGRPPreprocessor::fgknDCSDP = 48;   // number of dcs dps
   const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40;   // number of dcs dps
-  const Int_t AliGRPPreprocessor::fgknLHCDP = 8;   // number of dcs dps from LHC data
+  const Int_t AliGRPPreprocessor::fgknLHCDP = 9;   // number of dcs dps from LHC data
   const Int_t AliGRPPreprocessor::fgkDCSDPHallTopShift = 4;   // shift from the top to get tp the Hall Probes names in the list of DCS DPs
   const Int_t AliGRPPreprocessor::fgkDCSDPNonWorking = 5; // number of non working DCS DPs
   const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
@@ -186,7 +187,8 @@ ClassImp(AliGRPPreprocessor)
          "BPTX_Phase_Shift_B1",
          "BPTX_Phase_Shift_B2",
          "LHC_Particle_Type_B1",
-         "LHC_Particle_Type_B2"
+         "LHC_Particle_Type_B2",
+         "LHC_Data_Quality_Flag"
   };
 
   const char* kppError[] = {
@@ -1048,7 +1050,8 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                        AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
                        grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
                }
-               /*
+               /* 
+                  // Old way to determine the Maximum Time during which the LHC info is valid
                if (timeBeamModeEnd!=0 || timeMachineModeEnd!=0 || timeBeamEnd !=0){
                        Double_t minTimeLHCValidity;
                        if (flagBeamMode == kFALSE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam only true --> it is the only one that changed
@@ -1078,6 +1081,122 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                }
                */
                
+               // Data Quality Flag --> storing start and end values of periods within the run during which the value was found to be FALSE
+               Log("*************Data Quality Flag ");
+               TObjArray* dataQualityArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[8]);
+               Int_t nDataQuality = -1;
+               Double_t timeDataQualityStart = -1; // min validity for Data Quality Flag
+               Int_t indexDataQuality = -1;               // index of first measurement used to set Data Quality Flag
+               Bool_t foundDataQualityStart = kFALSE;     // flag to be set in case an entry for the Data Quality Flag is found before (or at) SOR
+
+               if (dataQualityArray){
+                       nDataQuality = dataQualityArray->GetEntries();
+                       if (nDataQuality==0){
+                               AliInfo("No Data Quality Flag found, leaving it empty");
+                       }
+                       else{
+                               for (Int_t iDataQuality = 0; iDataQuality<nDataQuality; iDataQuality++){
+                                       AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
+                                       if (dataQuality){
+                                               if (dataQuality->GetTimeStamp()<=timeStart && dataQuality->GetTimeStamp()>=timeDataQualityStart){// taking always the very last entry: if two measurements have the same timestamp, the last one is taken
+                                                       timeDataQualityStart = dataQuality->GetTimeStamp();
+                                                       indexDataQuality = iDataQuality;
+                                                       foundDataQualityStart = kTRUE;
+                                               }
+                                               else{
+                                                       // we suppose here that if the first measurement is not before SOR, then none will be (they MUST be in chronological order!!!) 
+                                                       break;
+                                               }
+                                       }
+                               }
+                               if (!foundDataQualityStart){
+                                       // The Data Quality Flag should be found and TRUE at the start of the run. For the time being, if it is not found, don't do anything, but it means there is a problem..
+                                       AliInfo("No value for the Data Quality Flag found before start of run, the Data Quality Flag will remain empty");
+                               }
+                               else {
+                                       // counting how many FALSE values there are
+                                       Bool_t foundEndOfFalse = kFALSE;
+                                       Int_t nFalse = 0;
+                                       for (Int_t iDataQuality = indexDataQuality; iDataQuality < nDataQuality; iDataQuality ++){
+                                               AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
+                                               AliDebug(4,Form("dataQuality->GetTimeStamp() = %f, timeDataQualityStart = %f, timeEnd = %f", dataQuality->GetTimeStamp(), timeDataQualityStart, timeEnd ));
+                                               if (dataQuality->GetTimeStamp()>=timeDataQualityStart && dataQuality->GetTimeStamp()<=timeEnd){ // considering only values between the first valid and the end of the run
+                                                       Bool_t dataQualityFlag = dataQuality->GetBool(0);
+                                                       AliDebug(3,Form("DataQuality = %d (set at %f)",(Int_t)dataQualityFlag,dataQuality->GetTimeStamp()));
+                                                       if (dataQualityFlag != kTRUE){
+                                                               if (iDataQuality == indexDataQuality) {  // the first Data Quality value should be TRUE, but ignoring the problem now...
+                                                                       AliError("The first value for the Data Quality MUST be TRUE! Ignoring for now...");
+                                                               }
+                                                               nFalse++;
+                                                       }
+                                               }
+                                       }
+
+                                       AliInfo(Form("Found %d FALSE values for the Data Quality Flag",nFalse));
+                                       Double_t falses[nFalse*2];  // dimensioning this to the maximum possible, as if each false value was followed by a true one --> the false periods correspond to the number of falses
+
+                                       Int_t iDataQuality = indexDataQuality;
+                                       if (nFalse > 0){
+                                               Int_t iFalse = 0;
+                                               // filling the info about the periods when the flag was set to FALSE
+                                               // starting, like for the other DPS, from the measurement closest to SOR (the index of which is iDataQuality)
+                                               while (iDataQuality < nDataQuality){
+                                                       AliDebug(3,Form("iDataQuality = %d",iDataQuality));
+                                                       AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
+                                                       if (dataQuality->GetTimeStamp()>=timeDataQualityStart && dataQuality->GetTimeStamp()<=timeEnd){ // considering only values between the first valid and the end of the run
+                                                               Bool_t dataQualityFlag = dataQuality->GetBool(0);
+                                                               AliDebug(3,Form("DataQuality = %d (set at %f)",(Int_t)dataQualityFlag,dataQuality->GetTimeStamp()));
+                                                               if (dataQualityFlag == kTRUE){
+                                                                       // found TRUE value, continuing
+                                                                       iDataQuality++;
+                                                                       continue;
+                                                               }
+                                                               else{
+                                                                       /*
+                                                                       // the check was already done before
+                                                                       if (iDataQuality == indexDataQuality) {  // the first Data Quality value should be TRUE, but ignoring the problem now...
+                                                                       AliError("The first value for the Data Quality MUST be TRUE! Ignoring for now...");
+                                                                       }
+                                                                       */
+                                                                       falses[iFalse*2] = dataQuality->GetTimeStamp();
+                                                                       foundEndOfFalse = kFALSE;
+                                                                       Int_t iDataQualityNext = iDataQuality+1;
+                                                                       while (iDataQualityNext < nDataQuality){
+                                                                               AliDCSArray* dataQualityNext = (AliDCSArray*)dataQualityArray->At(iDataQualityNext);
+                                                                               if (dataQualityNext->GetTimeStamp()>timeDataQualityStart && dataQualityNext->GetTimeStamp()<=timeEnd && dataQualityNext->GetTimeStamp() > dataQuality->GetTimeStamp()){ // considering only values between the first valid and the end of the run, and subsequent to the current value
+                                                                                       Bool_t dataQualityFlagNext = dataQualityNext->GetBool(0);
+                                                                                       AliDebug(3,Form("DataQualityNext = %d (set at %f)",(Int_t)dataQualityFlagNext,dataQualityNext->GetTimeStamp()));
+                                                                                       if (dataQualityFlagNext == kTRUE){
+                                                                                               // found TRUE value, first FALSE period completed
+                                                                                               foundEndOfFalse = kTRUE;
+                                                                                               falses[iFalse*2+1] = dataQualityNext->GetTimeStamp();
+                                                                                               iFalse++;
+                                                                                               break;
+                                                                                       }
+                                                                                       iDataQualityNext++;
+                                                                               }
+                                                                       }
+                                                                       if (!foundEndOfFalse) {
+                                                                               AliInfo("Please, note that the last FALSE value lasted until the end of the run");
+                                                                               falses[iFalse*2+1] = timeEnd;
+                                                                               iFalse++;
+                                                                               break;
+                                                                       }
+                                                                       iDataQuality = iDataQualityNext+1;
+                                                               }
+                                                       }
+                                               }
+                                               grpobj->SetNFalseDataQualityFlag(iFalse);
+                                               grpobj->SetFalseDataQualityFlagPeriods(falses);
+                                       }
+                               }
+                       }
+                       delete dataQualityArray;
+               }
+               else{
+                       AliError("Data Quality Flag array not found in LHC Data file!!!");
+               }
+
                // Processing data to go to AliLHCData object
                AliLHCData* dt = new AliLHCData(fileName.Data(),timeStart,timeEnd);
                // storing AliLHCData in OCDB