]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGRPPreprocessor.cxx
Increase class version (forgotten in the previous commit)
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
index 785c90eba0343864a40a6c5fc7e958916163ef14..a98dffbe8581cee57a3db5503d17a5cffb1e6ea4 100644 (file)
@@ -27,7 +27,9 @@
 #include <TList.h>
 #include <TMap.h>
 #include <TObjString.h>
+#include <TObjArray.h>
 #include <TGraph.h>
+#include <TString.h>
 
 #include <float.h>
 
@@ -56,8 +58,9 @@ class AliShuttleInterface;
 #include <AliCDBMetaData.h>
 #include <AliCDBId.h>
 #include <AliTriggerConfiguration.h>
+#include <AliCTPTimeParams.h>
 
-const Double_t kFitFraction = 0.7;                 // Fraction of DCS sensor fits required
+const Double_t kFitFraction = -1.;                 // Fraction of DCS sensor fits required
 
 ClassImp(AliGRPPreprocessor)
 
@@ -65,7 +68,7 @@ ClassImp(AliGRPPreprocessor)
 
   const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook for PHYSICS runs, when beamType from DAQ logbook == NULL
   const Int_t AliGRPPreprocessor::fgknDAQLbParReduced = 7; // num parameters in the logbook for the other cases
-  const Int_t AliGRPPreprocessor::fgknDCSDP = 50;   // number of dcs dps
+  const Int_t AliGRPPreprocessor::fgknDCSDP = 51;   // number of dcs dps
   const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40;   // number of dcs dps
   const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
                    "LHCState",              // missing in DCS
@@ -117,7 +120,8 @@ ClassImp(AliGRPPreprocessor)
                   "Dipole_Outside_Temperature",
                    "CavernTemperature",
                    "CavernAtmosPressure",
-                   "SurfaceAtmosPressure"
+                   "SurfaceAtmosPressure",
+                   "CavernAtmosPressure2"
                  };
 
   const char* AliGRPPreprocessor::fgkDCSDataPointsHallProbes[AliGRPPreprocessor::fgknDCSDPHallProbes] = {
@@ -160,11 +164,12 @@ ClassImp(AliGRPPreprocessor)
                   "Dipole_Outside_H1",
                   "Dipole_Outside_H2",
                   "Dipole_Outside_H3",
-                  "Dipole_Outside_Temperature",
+                  "Dipole_Outside_Temperature"
                  };
                  
   const Short_t kSensors = 48; // start index position of sensor in DCS DPs
-  const Short_t kNumSensors = 2; // Number of sensors in DCS DPs
+  const Short_t kNumSensors = 3; // Number of sensors in DCS DPs (CavernAtmosPressure, SurfaceAtmosPressure, CavernAtmosPressure2)
+
 
   const char* AliGRPPreprocessor::fgkLHCState[20] = {
                    "P", "PREPARE",
@@ -186,13 +191,14 @@ ClassImp(AliGRPPreprocessor)
                    "(Trigger Scalers not found in DCS FXS - ERROR)",
                    "(DCS data points ERROR)",
                    "(Trigger Configuration ERROR)",
-                   "(DAQ logbook ERROR determining partition of the run)"
+                   "(DAQ logbook ERROR determining partition of the run)",
+                   "(CTP timing ERROR)"
   };
 
 //_______________________________________________________________
 
 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
-       AliPreprocessor("GRP",shuttle),  fPressure(0), fmaxFloat(0), fminFloat(0),fmaxDouble(0), fminDouble(0), fmaxInt(0), fminInt(0), fmaxUInt(0), fminUInt(0)
+       AliPreprocessor("GRP",shuttle),  fPressure(0), fmaxFloat(0), fminFloat(0),fmaxDouble(0), fminDouble(0), fmaxInt(0), fminInt(0), fmaxUInt(0), fminUInt(0),fdaqStartEndTimeOk(kTRUE),ffailedDPs(new TObjArray(fgknDCSDP))
 {
        // constructor - shuttle must be instantiated!
 
@@ -230,6 +236,7 @@ AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
        AliInfo(Form("Max allowed unsigned integer = %u",(Int_t)fmaxUInt));
        AliInfo(Form("Min allowed unsigned integer = %u",(Int_t)fminUInt));
 
+       ffailedDPs->SetOwner(kTRUE);
 }
 
 //_______________________________________________________________
@@ -239,27 +246,35 @@ AliGRPPreprocessor::~AliGRPPreprocessor()
        //destructor
        
        delete fPressure;
+       delete ffailedDPs;
+
 }
 
 //_______________________________________________________________
 
 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
 {
-  // Initialize preprocessor
+       // Initialize preprocessor
 
-  AliPreprocessor::Initialize(run, startTime, endTime);
+       AliPreprocessor::Initialize(run, startTime, endTime);
+       
+       AliInfo("Initialization of the GRP preprocessor.");
+       AliInfo(Form("Start Time DCS = %d",GetStartTimeDCSQuery()));
+       AliInfo(Form("End Time DCS = %d",GetEndTimeDCSQuery()));
+       TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors); 
+       for(Int_t j = 0; j < kNumSensors; j++) {
+               AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
+               sens->SetStringID(fgkDCSDataPoints[j+kSensors]);
+       }
+       AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
+       
+       fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array);
 
-  AliInfo("Initialization of the GRP preprocessor.");
-  AliInfo(Form("Start Time DCS = %d",GetStartTimeDCSQuery()));
-  AliInfo(Form("End Time DCS = %d",GetEndTimeDCSQuery()));
-  TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors); 
-  for(Int_t j = 0; j < kNumSensors; j++) {
-    AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
-    sens->SetStringID(fgkDCSDataPoints[j+kSensors]);
-  }
-  AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
+       for (Int_t iDP=0; iDP < fgknDCSDP; iDP++){
+               TObjString* dp = new TObjString(fgkDCSDataPoints[iDP]);
+               ffailedDPs->AddAt(dp,iDP);
+       }
 
-  fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array);
 }
 
 //_______________________________________________________________
@@ -324,10 +339,27 @@ 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-4));
-       if( entries < fgknDCSDP-4 ) { // FIXME (!= ) LHState, LHCLuminosity, BeamIntensity, LH3_BSF4_H3 are not working yet...  
-               Log(Form("Problem with the DCS data points!!! Only %d/%d entries found",entries,fgknDCSDP-4));
-               error |= 8;
-       } else  Log(Form("DCS data points, successful!"));
+       if (fdaqStartEndTimeOk){
+               if( entries < fgknDCSDP-4 ) { // FIXME (!= ) LHState, LHCLuminosity, BeamIntensity, L3_BSF4_H3 are not working yet...  
+                       Log(Form("Problem with the DCS data points!!! Only %d/%d entries found",entries,fgknDCSDP-4));
+                       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 != "LHCState" && name != "LHCLuminosity" && name != "BeamIntensity" && name != "L3_BSF4_H3"){
+                                               Log(Form("******** %s ******** not present, but foreseen --> causing an ERROR",name.Data()));
+                                       }
+                                       else {
+                                               Log(Form(" %s is not present, but was not generating any error since it is not ready in DCS - check the other DPs in this list!",name.Data()));
+                                       }
+                               }
+                       }
+                       error |= 8;
+               }
+               else  Log(Form("DCS data points, successful!"));
+       }
+       else Log(Form("Statistical values for DCS DPs could not be computed due to missing DAQ_time_start and DAQ_time_end fields in DAQ logbook")); 
        
        //=======================//
        // Trigger Configuration //
@@ -396,6 +428,74 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                error |= 32;
        }
 
+        //===========================//
+       // Trigger Timing Parameters //
+        //===========================//
+
+       
+       const char * triggerCTPtiming = GetCTPTimeParams();
+
+       if (partition.IsNull() && !detector.IsNull()){ // standalone partition
+               Log("STANDALONE partition for current run, using CTP timing params dummy value");
+               AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyCTPtime");
+               if (!cdbEntry) {
+                       Log(Form("No dummy CTP timing parameters entry found, going into error..."));
+                       error |= 64;
+               }
+               else{
+                       AliCTPTimeParams *runCTPtiming = (AliCTPTimeParams*)cdbEntry->GetObject();
+                       if (!runCTPtiming){
+                               Log(Form("dummy CTP timing parameters not found in OCDB entry, going into error..."));
+                               error |= 64;
+                       }
+                       else {
+                               TString titleCTPtiming = Form("CTP timing params for run %i from Dummy entry in OCDB",fRun);
+                               runCTPtiming->SetTitle(titleCTPtiming);
+                               AliCDBMetaData metadata;
+                               metadata.SetResponsible("Roman Lietava");
+                               metadata.SetComment("CTP run timing parameters from dummy entry in OCDB");
+                               if (!Store("CTP","CTPtiming", runCTPtiming, &metadata, 0, 0)) {
+                                       Log("Unable to store the dummy CTP timing params object to OCDB!");
+                                       error |= 64;
+                               }
+                       }
+               }
+       }
+
+       else if (!partition.IsNull() && detector.IsNull()){ // global partition
+               Log("GLOBAL partition for current run, using Trigger Timing Parameters from DAQ Logbook");
+               if (triggerCTPtiming!= NULL) {
+                       Log("Found trigger timing params in DAQ logbook");
+                       AliDebug(2,Form("%s",triggerCTPtiming));
+                       AliCTPTimeParams *runCTPtiming = AliCTPTimeParams::LoadCTPTimeParamsFromString(triggerCTPtiming);         
+                       if (!runCTPtiming) {
+                               Log("Bad CTP trigger timing params file from DAQ logbook! The corresponding CDB entry will not be filled!");
+                               error |= 64;
+                       }
+                       else {
+                               TString titleCTPtiming = Form("CTP timing params for run %i from DAQ",fRun);
+                               runCTPtiming->SetTitle(titleCTPtiming);
+                               AliCDBMetaData metadata;
+                               metadata.SetBeamPeriod(0);
+                               metadata.SetResponsible("Roman Lietava");
+                               metadata.SetComment("CTP timing params from DAQ logbook");
+                               if (!Store("CTP","CTPtiming", runCTPtiming, &metadata, 0, 0)) {
+                                       Log("Unable to store the CTP timing params object to OCDB!");
+                                       error |= 64;
+                               }
+                       }
+               }
+
+               else {
+                       Log("Trigger timing params NULL in DAQ logbook");
+                       error |= 64;
+               }
+       }
+
+       else {
+               Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger timing parameters...",partition.Data(),detector.Data()));
+               error |= 32;
+       }
        // storing AliGRPObject in OCDB
 
        AliCDBMetaData md;
@@ -410,13 +510,14 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                Log("GRP Preprocessor Success");
                return 0;
        } else {
-               Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s",
+               Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s%s",
                          kppError[(error&1)?1:0],
                          kppError[(error&2)?2:0],
                          kppError[(error&4)?3:0],
                          kppError[(error&8)?4:0],
                          kppError[(error&16)?5:0],
-                         kppError[(error&32)?6:0]
+                         kppError[(error&32)?6:0],
+                         kppError[(error&64)?7:0]
                          ));
                return error;
        }
@@ -699,6 +800,7 @@ Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, AliGRPObject* grpObj)
        nEnvEntries = ProcessEnvDPs(valueMap, grpObj);
        nHallProbesEntries = ProcessHPDPs(valueMap, grpObj);
        grpObj->SetPolarityConventionLHC();  // after the dipole cables swap we comply with LHC convention
+       Log(Form("nLHCEntries = %d, L3Entries = %d, nDipoleEntries =%d, nEnvEntries = %d, nHallProbesEntries = %d", nLHCEntries, nL3Entries, nDipoleEntries, nEnvEntries, nHallProbesEntries));
        entries = nLHCEntries + nL3Entries + nDipoleEntries + nEnvEntries + nHallProbesEntries;
        return entries;
 
@@ -714,6 +816,7 @@ Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpOb
        // L3 info
 
        Int_t nL3Entries = 0;
+
        TObjArray *array = 0x0;
        Int_t indexDP = -1;
        Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change
@@ -742,7 +845,10 @@ Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpOb
                                floatDCS = 0x0;
                        }
                }
-               if (!outOfRange) nL3Entries++;
+               if (!outOfRange) {
+                       nL3Entries++;
+                       ffailedDPs->RemoveAt(indexDP);
+               }
        }
 
        if (array) array = 0x0;
@@ -763,10 +869,12 @@ Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpOb
                        if (change == kFALSE){
                                grpObj->SetL3Polarity(charDCS);
                                AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetL3Polarity())));
+                               ffailedDPs->RemoveAt(indexDP);
                                nL3Entries++;
                        }
                        else if (isZero){
                                AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP]));
+                               ffailedDPs->RemoveAt(indexDP);
                                nL3Entries++;
                        }
                        else {
@@ -815,7 +923,10 @@ Int_t AliGRPPreprocessor::ProcessDipoleDPs(const TMap* valueMap, AliGRPObject* g
                                floatDCS = 0x0;
                        }
                }
-               if (!outOfRange) nDipoleEntries++;
+               if (!outOfRange) {
+                       nDipoleEntries++;
+                       ffailedDPs->RemoveAt(indexDP);
+               }
        }
 
        if (array) array = 0x0;
@@ -836,10 +947,12 @@ Int_t AliGRPPreprocessor::ProcessDipoleDPs(const TMap* valueMap, AliGRPObject* g
                        if (!change){
                                grpObj->SetDipolePolarity(charDCS);
                                AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetDipolePolarity())));
+                               ffailedDPs->RemoveAt(indexDP);
                                nDipoleEntries++;
                        }
                        else if (isZero){
                                AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP]));
+                               ffailedDPs->RemoveAt(indexDP);
                                nDipoleEntries++;
                        }
                        else{
@@ -887,47 +1000,95 @@ Int_t AliGRPPreprocessor::ProcessEnvDPs(TMap* valueMap, AliGRPObject* grpObj)
                                floatDCS = 0x0;
                        }
                }
-               if (!outOfRange) nEnvEntries++;
+               if (!outOfRange) {
+                       ffailedDPs->RemoveAt(indexDP);
+                       nEnvEntries++;
+               }
        }
 
        if (array) array = 0x0;
 
-       AliInfo(Form("==========AtmosPressures (Cavern + Surface)==========="));
+       AliInfo(Form("========== AtmosPressures (Cavern + Surface + Cavern2) ==========="));
        AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap);
-       dcsSensorArray->Print();
-       if( fPressure->NumFits()==0 ) {
-               Log("Problem with the pressure sensor values!!!");
+       //dcsSensorArray->Print();
+       if( fPressure->NumFits()<kNumSensors ) {
+               Log(Form("Check the pressure sensor values! Not all the %d pressure sensors have been fit",kNumSensors));
        } 
-       else {
-               AliInfo(Form("==========CavernAtmosPressure==========="));
-               indexDP = kCavernAtmosPressure;
-               AliDCSSensor* sensorCavernP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
-               AliDebug(2,Form("sensorCavernP2 = %p", sensorCavernP2));
-               if( sensorCavernP2->GetFit() ) {
-                       Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun));
-                       grpObj->SetCavernAtmosPressure(sensorCavernP2);
-                       nEnvEntries++;
-               } 
-               //if (sensorP2) delete sensorP2;
+       Log(Form("Number of fits performed = %d",fPressure->NumFits()));
+
+       AliInfo(Form("==========CavernAtmosPressure==========="));
+       indexDP = kCavernAtmosPressure;
+       AliDCSSensor* sensorCavernP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
+       TGraph* graph = sensorCavernP2->GetGraph();
+       AliDebug(3,Form("index = %d",indexDP));
+       AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP]));
+       AliDebug(2,Form("graph = %p",graph));
+       AliDebug(3,Form("sensorCavernP2 = %p", sensorCavernP2));
+       if(sensorCavernP2->GetFit() || graph) {
+               if (sensorCavernP2->GetFit()){
+                       Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP]));
+               }
                else {
-                       Log(Form("ERROR Sensor Fit for %s not found ", fgkDCSDataPoints[indexDP] ));
-               }
-               AliInfo(Form("==========SurfaceAtmosPressure==========="));
-               indexDP = kSurfaceAtmosPressure;
-               AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
-               AliDebug(2,Form("sensorP2 = %p", sensorP2));
-               if( sensorP2->GetFit() ) {
-                       Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun));
-                       grpObj->SetSurfaceAtmosPressure(sensorP2);
-                       nEnvEntries++;
-               } 
-               //if (sensorP2) delete sensorP2;
+                       Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP]));
+               }
+               grpObj->SetCavernAtmosPressure(sensorCavernP2);
+               ffailedDPs->RemoveAt(indexDP);
+               nEnvEntries++;
+       } 
+       //if (sensorP2) delete sensorP2;
+       else {
+               Log(Form("ERROR!!! Neither graph nor fit found for sensor %s - this will not increase the number of found DCS DPs and will cause an error", fgkDCSDataPoints[indexDP] ));
+       }
+       
+       AliInfo(Form("==========SurfaceAtmosPressure==========="));
+       indexDP = kSurfaceAtmosPressure;
+       AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
+       graph = sensorP2->GetGraph();
+       AliDebug(3,Form("index = %d",indexDP));
+       AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP]));
+       AliDebug(2,Form("graph = %p",graph));   
+       AliDebug(3,Form("sensorP2 = %p", sensorP2));
+       if(sensorP2->GetFit() || graph) {
+               if (sensorP2->GetFit()){
+                       Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP]));
+               }
                else {
-                       Log(Form("ERROR Sensor Fit for %s not found ", fgkDCSDataPoints[indexDP] ));
+                       Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP]));
                }
-               
+               grpObj->SetSurfaceAtmosPressure(sensorP2);
+               ffailedDPs->RemoveAt(indexDP);
+               nEnvEntries++;
+       } 
+       //if (sensorP2) delete sensorP2;
+       else {
+               Log(Form("ERROR!!! Neither graph nor fit found for sensor %s - this will not increase the number of found DCS DPs and will cause an error", fgkDCSDataPoints[indexDP] ));
        }
 
+       AliInfo(Form("==========CavernAtmosPressure2==========="));
+       indexDP = kCavernAtmosPressure2;
+       AliDCSSensor* sensorCavernP22 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
+       graph = sensorCavernP22->GetGraph();
+       AliDebug(3,Form("index = %d",indexDP));
+       AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP]));
+       AliDebug(2,Form("graph = %p",graph));   
+       AliDebug(3,Form("sensorCavernP2_2 = %p", sensorCavernP22));
+       if(sensorCavernP22->GetFit() || graph) {
+               if (sensorCavernP22->GetFit()){
+                       Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP]));
+               }
+               else {
+                       Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP]));
+               }
+               grpObj->SetCavernAtmosPressure2(sensorCavernP22);
+               ffailedDPs->RemoveAt(indexDP);
+               nEnvEntries++;
+       } 
+       //if (sensorP2) delete sensorP2;
+       else {
+               Log(Form("ERROR!!! Neither graph nor fit found for sensor %s - this will not increase the number of found DCS DPs and will cause an error", fgkDCSDataPoints[indexDP] ));
+       }
+       
+       
        return nEnvEntries;
 }
 //_______________________________________________________________
@@ -974,7 +1135,10 @@ Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpOb
                                        floatDCS = 0x0;
                                }
                        }
-                       if (!outOfRange) nHPEntries++;
+                       if (!outOfRange) {
+                               ffailedDPs->RemoveAt(indexDP + 7);  // 7 = shift in the complete list of DPs to get to the Hall Probes
+                               nHPEntries++;
+                       }
                }
        }
                
@@ -1033,6 +1197,7 @@ Int_t AliGRPPreprocessor::ProcessLHCDPs(const TMap* valueMap, AliGRPObject* grpO
                                grpObj->SetLHCState(AliGRPObject::GetInvalidString());
                        }         
                }
+               ffailedDPs->RemoveAt(indexDP);
                nLHCEntries++;
        }
        
@@ -1065,7 +1230,10 @@ Int_t AliGRPPreprocessor::ProcessLHCDPs(const TMap* valueMap, AliGRPObject* grpO
                                floatDCS = 0x0;
                        }
                }
-               if (!outOfRange) nLHCEntries++;
+               if (!outOfRange) {
+                       ffailedDPs->RemoveAt(indexDP);
+                       nLHCEntries++;
+               }
        }
 
        if (array) array = 0x0;
@@ -1097,7 +1265,10 @@ Int_t AliGRPPreprocessor::ProcessLHCDPs(const TMap* valueMap, AliGRPObject* grpO
                                floatDCS = 0x0;
                        }
                }
-               if (!outOfRange) nLHCEntries++;
+               if (!outOfRange) {
+                       nLHCEntries++;
+                       ffailedDPs->RemoveAt(indexDP);
+               }
        }
 
        return nLHCEntries;
@@ -1188,6 +1359,7 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
                else if (timeStartString.IsNull()){
                        AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
                }
+               fdaqStartEndTimeOk = kFALSE;
                return 0;
        }  
 
@@ -1206,6 +1378,8 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
        Float_t* arrayValues = 0x0; 
        Double_t* arrayWeights = 0x0; 
        Bool_t truncMeanFlag = kTRUE;  // flag to indicate whether Truncated Mean should be calculated or not
+       Bool_t sdFlag = kTRUE;  // flag to indicate whether SD (wrt Mean/Median) should be calculated or not
+
        for(Int_t i = 0; i < nCounts; i++) {
                AliDCSValue *v = (AliDCSValue *)array->At(i);
                if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) {
@@ -1242,10 +1416,10 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
        }
 
        if (timestampBeforeSOR == -1){
-               AliWarning("No value found before SOR!");
+               AliWarning("No value found before SOR");
        }
        if (timestampAfterEOR == -1){
-               AliWarning("No value found after EOR!");
+               AliWarning("No value found after EOR");
        }
 
        AliDebug(2,Form("Number of valid entries (within DCS query interval) = %i, from a total amount of %i entries",iCounts,nCounts));
@@ -1305,14 +1479,9 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
                        return parameters;
                }
        }
-       else { // iCountsRun == 0, using the point immediately before SOR and the one immediately after EOR
-               if (timestampBeforeSOR == -1 || timestampAfterEOR == -1){
-                       if (timestampBeforeSOR == -1){
-                               AliError("Cannot calculate mean, truncated mean, median, SD wrt mean, SD wrt median for current DP - no points during the run collected, and point before SOR missing");
-                       }
-                       if (timestampAfterEOR == -1){
-                               AliError("Cannot calculate mean, truncated mean, median, SD wrt mean, SD wrt median for current DP - no points during the run collected, and point after EOR missing");
-                       }
+       else { // iCountsRun == 0, using only the point immediately before SOR
+               if (timestampBeforeSOR == -1){
+                       AliError("Cannot set mean, truncated mean, median, SD wrt mean, SD wrt median for current DP - no points during the run collected, and point before SOR missing");
                        parameters[0] = AliGRPObject::GetInvalidFloat();
                        parameters[1] = AliGRPObject::GetInvalidFloat();
                        parameters[2] = AliGRPObject::GetInvalidFloat();
@@ -1321,19 +1490,12 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
                        return parameters;
                }
                else {
-                       AliWarning("Using last entry before SOR and first entry after EOR. Truncated mean won't be calculated.");
-                       nentriesUsed = 2;
-                       arrayValues = new Float_t[2];
-                       arrayWeights = new Double_t[2];
-                       arrayValues[0] = valueBeforeSOR;
-                       arrayWeights[0] = (Double_t)(timestampAfterEOR - timestampBeforeSOR);
-                       arrayValues[1] = valueAfterEOR;
-                       arrayWeights[1] = 1.;
-                       AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); 
-                       AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); 
-                       parameters[0] = TMath::Mean(1,arrayValues,arrayWeights);
-                       parameters[2] = TMath::Median(1,arrayValues,arrayWeights);
+                       AliWarning("Using only last entry before SOR. Truncated mean and Standard deviations (wrt mean/median) won't be calculated.");
+                       AliDebug(2,Form("value = %f",valueBeforeSOR)); 
+                       parameters[0] = valueBeforeSOR;
+                       parameters[2] = valueBeforeSOR;
                        truncMeanFlag = kFALSE;
+                       sdFlag = kFALSE;
                }
        }
 
@@ -1346,38 +1508,48 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
 
        // calculating SD wrt Mean and Median
        AliDebug(2,"Calculating SD wrt Mean and SD wrt Median");
-       for (Int_t i =0; i< nentriesUsed; i++){
-               AliInfo(Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i]));
-               temp += (arrayValues[i]-parameters[2])*(arrayValues[i]-parameters[2]);
-               temp1 += arrayWeights[i]*(arrayValues[i]-parameters[0])*(arrayValues[i]-parameters[0]);
-               sumweights += arrayWeights[i];
-       }
-       // setting SD wrt Mean 
-       if (sumweights != 0 ){
-               parameters[3] = TMath::Sqrt(temp1/sumweights);
+       if (sdFlag){
+               for (Int_t i =0; i< nentriesUsed; i++){
+                       AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i]));
+                       temp += (arrayValues[i]-parameters[2])*(arrayValues[i]-parameters[2]);
+                       temp1 += arrayWeights[i]*(arrayValues[i]-parameters[0])*(arrayValues[i]-parameters[0]);
+                       sumweights += arrayWeights[i];
+               }
+               // setting SD wrt Mean 
+               if (sumweights != 0 ){
+                       parameters[3] = TMath::Sqrt(temp1/sumweights);
+               }
+               else {
+                       AliError("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid");
+                       parameters[3] = AliGRPObject::GetInvalidFloat();
+               }
+               // setting SD wrt Median
+               if (nentriesUsed != 0){
+                       parameters[4] = TMath::Sqrt(temp/nentriesUsed);
+               }
+               else{
+                       AliError("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid");
+                       parameters[4] = AliGRPObject::GetInvalidFloat();
+               }
        }
        else {
-               AliError("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid");
                parameters[3] = AliGRPObject::GetInvalidFloat();
-       }
-       // setting SD wrt Median
-       if (nentriesUsed != 0){
-               parameters[4] = TMath::Sqrt(temp/nentriesUsed);
-       }
-       else{
-               AliError("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid");
                parameters[4] = AliGRPObject::GetInvalidFloat();
-       }
+       }               
 
        // calculating truncated mean (this comes afterwards since you need the SD wrt Mean)
        if (truncMeanFlag){
                AliDebug(2,"Calculating Truncated Mean");
                for (Int_t i =0; i< nentriesUsed; i++){
+                       AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i]));
                        if ((arrayValues[i]<=parameters[0]+3*parameters[3]) && (arrayValues[i]>=parameters[0]-3*parameters[3])){
-                               AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i]));
+                               arrayValuesTruncMean[entriesTruncMean]=arrayValues[i];
+                               arrayWeightsTruncMean[entriesTruncMean]=arrayWeights[i];
+                               AliDebug(2,Form("For Truncated Mean: Entry %d: value = %f, weight = %f",entriesTruncMean,arrayValuesTruncMean[entriesTruncMean],arrayWeightsTruncMean[entriesTruncMean]));
                                entriesTruncMean++;                     
-                               arrayValuesTruncMean[i]=arrayValues[i];
-                               arrayWeightsTruncMean[i]=arrayWeights[i];
+                       }
+                       else{
+                               AliDebug(2,"Discarding entry");
                        }
                }
                // setting truncated mean 
@@ -1396,7 +1568,7 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
 
        AliInfo(Form("(weighted) mean = %f ",parameters[0]));
        AliInfo(Form("(weighted) truncated mean = %f ",parameters[1]));
-       AliInfo(Form("median within = %f ",parameters[2]));
+       AliInfo(Form("median = %f ",parameters[2]));
        AliInfo(Form("(weighted) standard deviation with (weighted) mean = %f ",parameters[3]));
        AliInfo(Form("standard deviation with median = %f ",parameters[4]));
        
@@ -1505,7 +1677,6 @@ Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array)
        Int_t timeEnd = (Int_t)(timeEndString.Atoi());
        Float_t aDCSArrayMean = 0.0;
        Int_t iCounts = 0;
-       AliDCSValue* v = 0x0;
        Float_t valueBeforeSOR = 0;
        Float_t valueAfterEOR = 0;
        Int_t timestampBeforeSOR = -1;
@@ -1518,7 +1689,7 @@ Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array)
        Int_t nCounts = array->GetEntries();
 
        for(Int_t i = 0; i < nCounts; i++) {
-               v = (AliDCSValue *)array->At(i);
+               AliDCSValue* v = (AliDCSValue *)array->At(i);
                if ((v->GetInt() < fminInt) || (v->GetInt() > fmaxInt)) {
                        AliError(Form("Error! Int value found in DCS map at %d-th entry is OUT OF RANGE: value = %d",i, v->GetInt()));
                        return AliGRPObject::GetInvalidFloat();
@@ -1661,7 +1832,6 @@ Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
        Int_t timeEnd = (Int_t)(timeEndString.Atoi());
        Float_t aDCSArrayMean = 0.0;
        Int_t iCounts = 0;
-       AliDCSValue* v = 0x0;
        Float_t valueBeforeSOR = 0;
        Float_t valueAfterEOR = 0;
        Int_t timestampBeforeSOR = -1;
@@ -1674,7 +1844,7 @@ Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
        Int_t nCounts = array->GetEntries();
 
        for(Int_t i = 0; i < nCounts; i++) {
-               v = (AliDCSValue *)array->At(i);
+               AliDCSValue* v = (AliDCSValue *)array->At(i);
                if ((v->GetUInt() < fminUInt) || (v->GetUInt() > fmaxUInt)) {
                        AliError(Form("Error! UInt value found in DCS map at %d-th entry is OUT OF RANGE: value = %u",i,v->GetUInt()));
                        return AliGRPObject::GetInvalidFloat();
@@ -1801,10 +1971,11 @@ AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap)
        
        TMap *map = fPressure->ExtractDCS(dcsAliasMap);
        if (map) {
+               AliDebug(2,Form("Map has %d entries",map->GetEntries()));
                fPressure->MakeSplineFit(map);
                Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); 
                if (fitFraction > kFitFraction ) {
-                       AliInfo(Form("Pressure values extracted, %d fits performed.", fPressure->NumFits()));
+                       AliInfo(Form("Pressure values extracted, %d fits performed for %d sensors.", fPressure->NumFits(),fPressure->NumSensors()));
                } else { 
                        AliInfo("Too few pressure maps fitted!!!");
                }