]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGRPPreprocessor.cxx
Storing the timestamp of the second measurement in case the Machine Mode or the
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
index 6748e2003e811656ba27f63f46429cb6ef31fb91..bd4563674276ad76aab8c5c52790bff47814450a 100644 (file)
@@ -76,6 +76,8 @@ ClassImp(AliGRPPreprocessor)
   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 = 5;   // 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] = {
                    "L3Polarity",
                    "DipolePolarity",
@@ -175,11 +177,11 @@ ClassImp(AliGRPPreprocessor)
 
 
   const char* AliGRPPreprocessor::fgkLHCDataPoints[AliGRPPreprocessor::fgknLHCDP] = {
-         "dip/acc/LHC/Beam/Energy.Energy",
-         "dip/acc/LHC/RunControl/MachineMode.value",
-         "dip/acc/LHC/RunControl/BeamMode.value",
-         "dip/acc/LHC/RunControl/BeamType/Beam1.payload",
-         "dip/acc/LHC/RunControl/BeamType/Beam2.payload"
+         "lhcMon_LHCBeam.Energy",
+         "lhcMon_LHCMachineMode.value",
+         "lhcMon_LHCBeamMode.value",
+          "dip/acc/LHC/RunControl/BeamType/Beam1.payload",
+          "dip/acc/LHC/RunControl/BeamType/Beam2.payload"
   };
   const char* kppError[] = {
                    "",
@@ -340,16 +342,16 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        //=================//
        Log(Form("Starting DCS Query at %d and finishing at %d",GetStartTimeDCSQuery(),GetEndTimeDCSQuery()));
        Int_t entries = ProcessDcsDPs( valueMap, grpobj );
-       Log(Form("entries found = %d (should be %d)",entries, fgknDCSDP-1));
+       Log(Form("entries found = %d (should be %d)",entries, fgknDCSDP-fgkDCSDPNonWorking));
        if (fdaqStartEndTimeOk){
-               if( entries < fgknDCSDP-1 ) { // FIXME (!= ) L3_BSF4_H3 are not working yet...  
-                       Log(Form("Problem with the DCS data points!!! Only %d/%d entries found",entries,fgknDCSDP-4));
+               if( entries < fgknDCSDP - fgkDCSDPNonWorking ) { // L3_BSF4_H3, L3_BSF17_H1, L3_BSF17_H2, L3_BSF17_H3, L3_BSF17_Temperature are not working yet...  
+                       Log(Form("Possible problem with the DCS data points!!! Only %d/%d entries found - Please read further for more details",entries,fgknDCSDP-fgkDCSDPNonWorking));
                        Log(Form("The DPs giving problems were:"));
                        for (Int_t iDP = 0; iDP < fgknDCSDP; iDP++){
                                TObjString *dpString = (TObjString*)ffailedDPs->At(iDP);
                                if (dpString){
                                        TString name = dpString->String();
-                                       if (name != "L3_BSF4_H3"){
+                                       if (name != "L3_BSF4_H3" && name != "L3_BSF17_H1" && name != "L3_BSF17_H2" && name != "L3_BSF17_H3" && name != "L3_BSF17_Temperature" ){
                                                Log(Form("******** %s ******** not present, but foreseen --> causing an ERROR",name.Data()));
                                        }
                                        else {
@@ -505,6 +507,7 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        //=================//
 
        UInt_t iLHCData = ProcessLHCData(grpobj);
+
        if( iLHCData == 0 ) {
                Log(Form("LHC Data from DCS FXS, successful!"));
        } else  if (iLHCData == 1) {
@@ -577,11 +580,11 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
 
        TString timeStartString = (TString)GetRunParameter("DAQ_time_start");
        TString timeEndString = (TString)GetRunParameter("DAQ_time_end");
-       if (timeStartString.IsNull() || timeStartString.IsNull()){
+       if (timeStartString.IsNull() || timeEndString.IsNull()){
                if (timeStartString.IsNull()){ 
                        AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid");
                }
-               else if (timeStartString.IsNull()){
+               else if (timeEndString.IsNull()){
                        AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
                }
                return 2;
@@ -590,62 +593,74 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
        Double_t timeStart = timeStartString.Atof();
        Double_t timeEnd = timeEndString.Atof();
 
-       //      timeStart = 1260646960;
-       //timeEnd = 1260652740;
-
        TString fileName = GetFile(kDCS, "LHCData","");
        if (fileName.Length()>0){
                AliInfo("Got The LHC Data file");
-               AliLHCReader* lhcReader = new AliLHCReader();
-               TMap* lhcMap = (TMap*)lhcReader->ReadLHCDP(fileName.Data());
+               AliLHCReader lhcReader;
+               TMap* lhcMap = (TMap*)lhcReader.ReadLHCDP(fileName.Data());
                if (lhcMap) {
                        Log(Form("LHCData map entries = %d",lhcMap->GetEntries()));
                        
                        // Processing data to be put in AliGRPObject
                        // Energy
                        TObjArray* energyArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[0]);
-                       Float_t energy = ProcessEnergy(energyArray,timeStart,timeEnd);
-                       if (energy != -1) {
-                               grpobj->SetBeamEnergy(energy);
-                               grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE);
+                       if (energyArray){                       
+                               Float_t energy = ProcessEnergy(energyArray,timeStart,timeEnd);
+                               if (energy != -1) {
+                                       grpobj->SetBeamEnergy(energy);
+                                       grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE);
+                               }
                        }
-                       
+                       else {
+                               AliError("Energy not found in LHC Data file!!!");
+                       }       
                        Double_t timeBeamMode = 0;
                        Double_t timeMachineMode = 0;
                        // BeamMode
                        TObjArray* beamModeArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[2]);
-                       if (beamModeArray->GetEntries()==0){
-                               AliInfo("No Beam Mode found, setting it to UNKNOWN");
-                               grpobj->SetLHCState("UNKNOWN");
+                       if (beamModeArray){             
+                               if (beamModeArray->GetEntries()==0){
+                                       AliInfo("No Beam Mode found, setting it to UNKNOWN");
+                                       grpobj->SetLHCState("UNKNOWN");
+                               }
+                               else{
+                                       AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(0);
+                                       TObjString* beamModeString = beamMode->GetStringArray(0);
+                                       if (beamModeArray->GetEntries()>1){
+                                               AliDCSArray* beamMode1 = (AliDCSArray*)beamModeArray->At(1);
+                                               timeBeamMode = beamMode1->GetTimeStamp();
+                                               AliWarning(Form("The beam mode changed at timestamp %f! Setting it to the first value found and setting MaxTimeLHCValidity",timeBeamMode));
+                                       }
+                                       AliInfo(Form("LHC State (corresponding to BeamMode) = %s",(beamModeString->String()).Data()));
+                                       grpobj->SetLHCState(beamModeString->String());
+                               }
+                               
                        }
                        else{
-                               AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(0);
-                               TObjString* beamModeString = beamMode->GetStringArray(0);
-                               if (beamModeArray->GetEntries()>1){
-                                       timeBeamMode = beamMode->GetTimeStamp();
-                                       AliWarning(Form("The beam mode changed at timestamp %f! Setting it to the first value found and setting MaxTimeLHCValidity",timeBeamMode));
-                               }
-                               AliInfo(Form("LHC State (corresponding to BeamMode) = %s",(beamModeString->String()).Data()));
-                               grpobj->SetLHCState(beamModeString->String());
+                               AliError("Beam mode array not found in LHC Data file!!!");
                        }
-                       
                        // MachineMode
                        TObjArray* machineModeArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[1]);
-                       if (machineModeArray->GetEntries()==0){
-                               AliInfo("No Machine Mode found, setting it to UNKNOWN");
-                               grpobj->SetMachineMode("UNKNOWN");
-                       }
-                       else{
-                               AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(0);
-                               TObjString* machineModeString = machineMode->GetStringArray(0);
-                               if (machineModeArray->GetEntries()>1){
-                                       timeMachineMode = machineMode->GetTimeStamp();
-                                       AliWarning(Form("The Machine Mode changed at timestamp %f! Setting it to the first value found and setting MaxTimeLHCValidity",timeMachineMode));
+                       if (machineModeArray){
+                               if (machineModeArray->GetEntries()==0){
+                                       AliInfo("No Machine Mode found, setting it to UNKNOWN");
+                                       grpobj->SetMachineMode("UNKNOWN");
+                               }
+                               else{
+                                       AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(0);
+                                       TObjString* machineModeString = machineMode->GetStringArray(0);
+                                       if (machineModeArray->GetEntries()>1){
+                                               AliDCSArray* machineMode1 = (AliDCSArray*)machineModeArray->At(1);
+                                               timeMachineMode = machineMode1->GetTimeStamp();
+                                               AliWarning(Form("The Machine Mode changed at timestamp %f! Setting it to the first value found and setting MaxTimeLHCValidity",timeMachineMode));
+                                       }
+                                       AliInfo(Form("Machine Mode = %s",(machineModeString->String()).Data()));
+                                       grpobj->SetMachineMode(machineModeString->String());
                                }
-                               AliInfo(Form("Machine Mode = %s",(machineModeString->String()).Data()));
-                               grpobj->SetMachineMode(machineModeString->String());
                        }
-                       
+                       else {
+                               AliError("Machine mode array not found in LHC Data file!!!");
+                       }       
                        if (timeBeamMode!=0 || timeMachineMode!=0){
                                Double_t minTimeLHCValidity;
                                if (timeBeamMode == 0){
@@ -663,10 +678,20 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                        
                        // BeamType1 and BeamType2 
                        TObjArray* beam1Array = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[3]);
-                       AliInfo(Form("%d entries for Beam1",beam1Array->GetEntries()));
-                       TObjArray* beam2Array = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[4]);
-                       AliInfo(Form("%d entries for Beam2",beam2Array->GetEntries()));
-                       
+                       if (beam1Array){                        
+                               AliInfo(Form("%d entries for Beam1",beam1Array->GetEntries()));
+                       }
+                       else{
+                               AliError("Beam1 array not found in LHC data file!!!");
+                       }                       
+                       TObjArray* beam2Array = 
+                               (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[4]);
+                       if (beam2Array){
+                               AliInfo(Form("%d entries for Beam2",beam2Array->GetEntries()));
+                       }
+                       else{
+                               AliError("Beam2 array not found in LHC data file!!!");
+                       }       
                        // Processing data to go to AliLHCData object
                        AliLHCData* dt = new AliLHCData(lhcMap,timeStart,timeEnd);
                                                        
@@ -683,6 +708,7 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                else return 3;
                        }
                        else return 4;
+                       delete lhcMap; 
                }
                else {
                        AliError("Cannot read correctly LHCData file");
@@ -726,7 +752,7 @@ UInt_t AliGRPPreprocessor::ProcessSPDMeanVertex()
                                                        AliCDBMetaData md;
                                                        md.SetResponsible("Cvetan Cheshkov");
                                                        md.SetComment("SPD Mean Vertex");                                       
-                                                       storeResult = Store("GRP", "MeanVertexSPD", meanVtx, &md, 0, kTRUE); 
+                                                       storeResult = Store("Calib", "MeanVertexSPD", meanVtx, &md, 0, kTRUE); 
                                                }
                                                else{
                                                        AliWarning("No SPD Mean Vertex object found in file");
@@ -993,9 +1019,11 @@ UInt_t AliGRPPreprocessor::ProcessDcsFxs(TString partition, TString detector)
                                metaData.SetComment("CTP scalers");
                                if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
                                        Log("Unable to store the CTP scalers object to OCDB!");
+                                       delete scalers;                                 
                                        return 1;
                                }
                        }
+                       delete scalers;
                }
        }
        
@@ -1363,7 +1391,7 @@ Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpOb
                                }
                        }
                        if (!outOfRange) {
-                               ffailedDPs->RemoveAt(indexDP + 7);  // 7 = shift in the complete list of DPs to get to the Hall Probes
+                               ffailedDPs->RemoveAt(indexDP + fgkDCSDPHallTopShift);  // 7 = shift in the complete list of DPs to get to the Hall Probes
                                nHPEntries++;
                        }
                }
@@ -2575,6 +2603,7 @@ Float_t AliGRPPreprocessor::ProcessEnergy(TObjArray* array, Double_t timeStart,
 
        Int_t nCounts = array->GetEntries();
        Float_t energy = -1;
+       Bool_t inRange = kFALSE;
        AliDebug(2,Form("Energy measurements = %d\n",nCounts));
        if (nCounts ==0){
                AliWarning("No Energy values found! Beam Energy remaining invalid!");
@@ -2585,12 +2614,14 @@ Float_t AliGRPPreprocessor::ProcessEnergy(TObjArray* array, Double_t timeStart,
                        if((dcs->GetTimeStamp() >= timeStart) &&(dcs->GetTimeStamp() <= timeEnd)) {
                                energy = (Float_t)(TMath::Nint(((Double_t)(dcs->GetInt(0)))*120/1000)); // sqrt(s)/2 energy in GeV
                                AliInfo(Form("Energy value found = %d, converting --> sqrt(s)/2 = %f (GeV)", dcs->GetInt(0),energy));
+                               inRange = kTRUE;
                                break;
                        }
-                       else {
-                               AliError("No energy values found between DAQ_time_start and DAQ_time_end - energy will remain invalid!");
-                       }
                }
+               if (inRange == kFALSE){
+                               AliInfo("No Energy value found between DAQ_time_start and DAQ_time_end - energy will remain invalid!");
+               }
+       
        }
 
        return energy;