]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGRPPreprocessor.cxx
Fixing in/out tags in documentation
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
index 7ccbdbbdb700073ffd0802ebd9e2833593292c2d..3703aa10a48f01d272561292ad5b70fa62bdf7a8 100644 (file)
@@ -78,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 = 6;   // number of dcs dps from LHC data
+  const Int_t AliGRPPreprocessor::fgknLHCDP = 8;   // 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] = {
@@ -185,7 +185,9 @@ ClassImp(AliGRPPreprocessor)
          "LHC_BeamMode",
           "LHC_Beams_Particle_Type",
          "BPTX_Phase_Shift_B1",
-         "BPTX_Phase_Shift_B2"
+         "BPTX_Phase_Shift_B2",
+         "LHC_Particle_Type_B1",
+         "LHC_Particle_Type_B2"
   };
 
   const char* kppError[] = {
@@ -529,8 +531,6 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        Log("*************** Processing LTU Configuration");
        
        if (partition.IsNull() && !detector.IsNull()){ // standalone partition
-               Log("STANDALONE partition for current run, not retrieving LTU configuration");
-               /*
                Log("STANDALONE partition for current run, using LTU configuration dummy value");
                AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyLTUConfig");
                if (!cdbEntry) {
@@ -553,7 +553,6 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                                }
                        }
                }
-               */
        }
 
        else if (!partition.IsNull() && detector.IsNull()){ // global partition
@@ -568,7 +567,11 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                        if ((detectorMask >> i) & 0x1) {
                                TString det = AliDAQ::OfflineModuleName(i);
                                TString detCTPName = AliTriggerInput::fgkCTPDetectorName[i];
-                               if (detCTPName == "CTP") detCTPName="TRG"; // converting according to what is found in DAQ logbook_detectors
+                               if (detCTPName == "CTP") {
+                                       detCTPName="TRG"; // converting according to what is found in DAQ logbook_detectors                                     
+                                       Printf("Processing CTP (CTP Detector name %s) --> SKIPPING, CTP does not have any LTU!!!!!!",detCTPName.Data());
+                                       continue;
+                               }                               
                                Printf("Processing detector %s (CTP Detector name %s)",det.Data(),detCTPName.Data());
                                TString* ltu = GetLTUConfig(detCTPName.Data());
                                if (!ltu){
@@ -597,7 +600,7 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                                error |= 2048;
                        }               
                }
-               if (ltuarray) delete ltuarray;
+               delete ltuarray;
        }
 
        else {
@@ -736,20 +739,33 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
 
                Double_t timeBeamModeEnd = timeEnd;        // max validity for Beam Mode 
                Double_t timeMachineModeEnd = timeEnd;     // max validity for Machine Mode
-               Double_t timeBeamEnd = timeEnd;            // max validity for Beam Type
+               Double_t timeBeamEnd = timeEnd;            // max validity for Beam Type
+               Double_t timeBeamTypeEnd[2] = {timeEnd, timeEnd}; // max validity for Beam Type1,2
                Double_t timeBeamModeStart = -1;    // min validity for Beam Mode
                Double_t timeMachineModeStart = -1; // min validity for Machine Mode
                Double_t timeBeamStart = -1;        // min validity for Beam Type
+               Double_t timeBeamTypeStart[2] = {-1,-1};        // min validity for Beam Type1,2
                Int_t indexBeamMode = -1;                  // index of measurement used to set Beam Mode
-               Int_t indexMachineMode = -1;               // index of measurement used to set Beam Mode
-               Int_t indexBeam = -1;                      // index of measurement used to set Beam Mode
+               Int_t indexMachineMode = -1;               // index of measurement used to set Machine Mode
+               Int_t indexBeam = -1;                      // index of measurement used to set Beam Type
+               Int_t indexBeamType[2] = {-1, -1};                      // index of measurement used to set Beam Type1,2
                Bool_t foundBeamModeStart = kFALSE;        // flag to be set in case an entry for the Beam Mode is found before (or at) SOR
-               Bool_t foundMachineModeStart = kFALSE;     // flag to be set in case an entry for the Beam Mode is found before (or at) SOR
-               Bool_t foundBeamStart = kFALSE;            // flag to be set in case an entry for the Beam Mode is found before (or at) SOR
+               Bool_t foundMachineModeStart = kFALSE;     // flag to be set in case an entry for the Machine Mode is found before (or at) SOR
+               Bool_t foundBeamStart = kFALSE;            // flag to be set in case an entry for the Beam Type is found before (or at) SOR
+               Bool_t foundBeamTypeStart[2] = {kFALSE, kFALSE};            // flag to be set in case an entry for the Beam Type1,2 is found before (or at) SOR
                Bool_t flagBeamMode = kFALSE;  //flag set true if a changed occurred in BeamMode
                Bool_t flagMachineMode = kFALSE;  //flag set true if a changed occurred in MachineMode
                Bool_t flagBeam = kFALSE;  //flag set true if a changed occurred in BeamType
+               Bool_t flagBeamType[2] = {kFALSE, kFALSE};  //flag set true if a changed occurred in BeamType1,2
                
+               Double_t arrayTimes[5]={2.E9, 2.E9, 2.E9, 2.E9, 2.E9}; // array to keep track of the times of the possible changes of the LHC DPs; each entry set to Wed May 18 2033, 03:33:20 GMT (ALICE should not be running anymore...)
+                                                                      // arrayTimes elements order correspond to the one used in the array of the strings fgkLHCDataPoints, i.e.:
+                                                                      // arrayTimes[0] --> MachineMode
+                                                                      // arrayTimes[1] --> BeamMode
+                                                                      // arrayTimes[2] --> BeamType (when written together)
+                                                                      // arrayTimes[3] --> BeamType1 (when written separate)
+                                                                      // arrayTimes[4] --> BeamType2 (when written separate)
+
                // BeamMode
                Log("*************BeamMode (LHCState) ");
                TObjArray* beamModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[2]);
@@ -796,6 +812,8 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                                                if (bmString0.CompareTo(bmString1.Data(),TString::kIgnoreCase) == -1){
                                                                        AliWarning(Form("The beam mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",bmString0.Data(), bmString1.Data(), timeBeamModeEnd, bmString0.Data()));
                                                                        flagBeamMode = kTRUE;
+                                                                       arrayTimes[1]=timeBeamModeEnd;
+
                                                                }
                                                        }
                                                }
@@ -853,6 +871,7 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                                                if (mmString0.CompareTo(mmString1.Data(),TString::kIgnoreCase) == -1){
                                                                        AliWarning(Form("The machine mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",mmString0.Data(),mmString1.Data(),timeMachineModeEnd,mmString0.Data()));
                                                                        flagMachineMode = kTRUE;
+                                                                       arrayTimes[0]=timeMachineModeEnd;
                                                                }
                                                        }
                                                }
@@ -891,7 +910,7 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                        }
                                }
                                if (!foundBeamStart){
-                                       AliInfo("No value for the Beam Type found before start of run, the Machine Mode will remain empty");
+                                       AliInfo("No value for the Beam Type found before start of run, the (common) Beam Type will remain empty");
                                }
                                else {
                                        AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
@@ -925,6 +944,7 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                                                if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){
                                                                        AliWarning(Form("The Beam Type changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data()));
                                                                        flagBeam = kTRUE;
+                                                                       arrayTimes[2] = timeBeamEnd;
                                                                }
                                                        }
                                                }
@@ -939,11 +959,100 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                else{
                        AliError("Beam Type array not found in LHC Data file!!!");
                }               
+
+               // BeamType1 and BeamType2 - in separete string
+               Log("*************BeamType, 1 and 2 ");
+               Int_t indexBeamTypeString = 6;  // index of the string with the alias of BeanType1 in the array fgkLHCDataPoints
+               TString combinedBeamType = "-";  // combined beam tyope, built from beam type 1 and beam type 2
+               for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
+                       beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[indexBeamTypeString+ibeamType]);
+                       if (beamArray){                 
+                               Int_t nBeam = beamArray->GetEntries();
+                               if (nBeam==0){
+                                       AliInfo(Form("No Beam Type %s found, leaving it empty",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
+                               }
+                               else{
+                                       for (Int_t iBeam = 0; iBeam<nBeam; iBeam++){
+                                               AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
+                                               if (beam){
+                                                       if (beam->GetTimeStamp()<=timeStart && beam->GetTimeStamp()>=timeBeamTypeStart[ibeamType]){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
+                                                               timeBeamTypeStart[ibeamType] = beam->GetTimeStamp();
+                                                               indexBeamType[ibeamType] = iBeam;
+                                                               foundBeamTypeStart[ibeamType] = kTRUE;
+                                                       }
+                                                       else{
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                                       if (!foundBeamTypeStart[ibeamType]){
+                                               AliInfo(Form("No value for the Beam Type %s found before start of run, the Beam Type %d will remain empty", fgkLHCDataPoints[indexBeamTypeString+ibeamType], ibeamType));
+                                       }
+                                       else {
+                                               AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
+                                               TObjString* beamString = beam->GetStringArray(0);
+                                               TString beamType = beamString->String();
+                                               AliInfo(Form("Beam Type (for %s) = %s", fgkLHCDataPoints[indexBeamTypeString+ibeamType], beamType.Data()));     
+                                               if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
+                                                       AliInfo(Form("Setting beam type %s to p", fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
+                                                       grpobj->SetSingleBeamType(ibeamType,"p");
+                                                       if (ibeamType == 0) combinedBeamType.Prepend("p");
+                                                       else combinedBeamType.Append("p");
+                                               }
+                                               else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
+                                                       AliInfo("Setting beam type to A");
+                                                       grpobj->SetSingleBeamType(ibeamType,"A");
+                                                       if (ibeamType == 0) combinedBeamType.Prepend("A");
+                                                       else combinedBeamType.Append("A");
+                                               }
+                                               /*
+                                                 else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
+                                                 AliInfo("Setting beam type to Pb-Pb");
+                                                 grpobj->SetSingleBeamType(ibeamType, "Pb-Pb");
+                                                 }
+                                                 else{
+                                                 AliError("Beam Type not known, leaving it empty");
+                                                 }
+                                               */
+                                               if (indexBeamType[ibeamType] < nBeam-1){
+                                                       AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1);
+                                                       if (beam1){
+                                                               if (beam1->GetTimeStamp()>timeStart && beam1->GetTimeStamp()<=timeEnd){
+                                                                       timeBeamTypeEnd[ibeamType] = beam1->GetTimeStamp();
+                                                                       TObjString* beamString1 = beam1->GetStringArray(0);
+                                                                       TString beamType1 = beamString1->String();
+                                                                       if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){
+                                                                               AliWarning(Form("The Beam Type for %s changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",fgkLHCDataPoints[indexBeamTypeString+ibeamType],beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data()));
+                                                                               flagBeamType[ibeamType] = kTRUE;
+                                                                               arrayTimes[3+ibeamType] = timeBeamTypeEnd[ibeamType];
+                                                                       }
+                                                               }
+                                                       }
+                                                       else {
+                                                               AliInfo(Form("Invalid pointer for the first entry for Beam Type %s after the first valid one, not considering anything after what has already been found",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
+                                                       }
+                                               }
+                                       }
+                               }
+                               delete beamArray;
+                       }
+                       else{
+                               AliError(Form("Beam Type %s array not found in LHC Data file!!!",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
+                       }               
+               }
+               AliInfo(Form("Setting combined beam type to %s",combinedBeamType.Data()));
+               grpobj->SetBeamType(combinedBeamType);
                
                // Setting minTimeLHCValidity
+               if (flagBeamMode == kTRUE || flagMachineMode == kTRUE || flagBeam == kTRUE || flagBeamType[0] == kTRUE || flagBeamType[1] == kTRUE){ 
+                       Double_t minTimeLHCValidity= TMath::MinElement(5,arrayTimes);
+                       AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
+                       grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
+               }
+               /*
                if (timeBeamModeEnd!=0 || timeMachineModeEnd!=0 || timeBeamEnd !=0){
                        Double_t minTimeLHCValidity;
-                       if (flagBeamMode == kFALSE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam only true
+                       if (flagBeamMode == kFALSE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam only true --> it is the only one that changed
                                minTimeLHCValidity = timeBeamEnd;
                        }
                        else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode only true
@@ -968,6 +1077,7 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                        AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
                        grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
                }
+               */
                
                // Processing data to go to AliLHCData object
                AliLHCData* dt = new AliLHCData(fileName.Data(),timeStart,timeEnd);
@@ -1030,7 +1140,11 @@ UInt_t AliGRPPreprocessor::ProcessSPDMeanVertex()
                        AliInfo("The following sources produced files with the id VertexDiamond from SPD");
                        list->Print();
                        for (Int_t jj=0;jj<list->GetEntries();jj++){
-                               TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
+                               TObjString * str = dynamic_cast<TObjString*> (list->At(jj)); 
+                               if (!str){
+                                       AliError(Form("Expecting a TObjString in the list for the %d-th source, but something else was found.",jj));
+                                       continue;
+                               }
                                AliInfo(Form("found source %s", str->String().Data()));
                                TString fileNameRun = GetForeignFile("SPD", kDAQ, "VertexDiamond", str->GetName());
                                if (fileNameRun.Length()>0){
@@ -1085,6 +1199,8 @@ Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj)
        TString lhcPeriod = (TString)GetRunParameter("LHCperiod");
        TString runType = (TString)GetRunType();
 
+       if (timeEnd >= 2.E9) AliFatal("ALICE run finshed later than Wed May 18 2033, 03:33:20 GMT, maximum time allowed for LHC data --> fix the GRP preprocessor!!!");
+
        UInt_t nparameter = 0;
        if (timeStart != 0){
                grpObj->SetTimeStart(timeStart);
@@ -1164,6 +1280,7 @@ UInt_t AliGRPPreprocessor::ProcessDaqFxs()
        //======DAQ FXS======//
        
        AliRawEventHeaderV3_9::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_9 - temporary fix 
+       AliRawEventHeaderV3_11::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_11 - temporary fix 
        TList* list = GetFileSources(kDAQ);  
        if (!list) {
                Log("No raw data tag list: connection problems with DAQ FXS logbook!");
@@ -1708,10 +1825,6 @@ AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TSt
        fit->InitKnots(gr,10,10,0.0);
        fit->SplineFit(2);
        fit->Cleanup();
-       if (!fit) {
-               AliWarning(Form("%s: no fit performed",stringID.Data()));
-               return NULL;
-       } 
        return fit;
 }
 
@@ -1792,6 +1905,7 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
                        AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat()));
                        if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat));
                        if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat));
+                       delete [] parameters;
                        return NULL;
                }
                if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
@@ -1972,6 +2086,15 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
                        parameters[1] = AliGRPObject::GetInvalidFloat();
        }
 
+       if (arrayValues){
+               delete [] arrayValues;
+       } 
+       if (arrayWeights){
+               delete [] arrayWeights;
+       } 
+       delete [] arrayValuesTruncMean;
+       delete [] arrayWeightsTruncMean;
+
        AliInfo(Form("(weighted) mean = %f ",parameters[0]));
        AliInfo(Form("(weighted) truncated mean = %f ",parameters[1]));
        AliInfo(Form("median = %f ",parameters[2]));
@@ -2162,6 +2285,8 @@ Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array)
                        arrayValues[i-ientrySOR] = (Float_t)v->GetInt();
                }
                aDCSArrayMean = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
+               delete [] arrayValues;
+               delete [] arrayWeights;
        }
        else if (iCountsRun == 1){
                AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR);
@@ -2177,6 +2302,8 @@ Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array)
                        AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); 
                        AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); 
                        aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights);
+                       delete [] arrayValues;
+                       delete [] arrayWeights;
                }
                else{
                        AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities");
@@ -2205,6 +2332,8 @@ Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array)
                        AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); 
                        AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); 
                        aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights);
+                       delete [] arrayValues;
+                       delete [] arrayWeights;
                }
        }
 
@@ -2317,6 +2446,8 @@ Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
                        arrayValues[i-ientrySOR] = (Float_t)v->GetUInt();
                }
                aDCSArrayMean = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
+               delete [] arrayValues;
+               delete [] arrayWeights;
        }
        else if (iCountsRun == 1){
                AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR);
@@ -2332,6 +2463,8 @@ Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
                        AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); 
                        AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); 
                        aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights);
+                       delete [] arrayValues;
+                       delete [] arrayWeights;
                }
                else{
                        AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities");
@@ -2360,6 +2493,8 @@ Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
                        AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0])); 
                        AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1])); 
                        aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights);
+                       delete [] arrayValues;
+                       delete [] arrayWeights;
                }
        }
 
@@ -2643,239 +2778,6 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
        
        return lastRun;
 }
-//-----------------------------------------------------------------
-Double_t AliGRPPreprocessor::CalculateMean(TObjArray* const array){
-
-       //
-       // Calculating mean over TObjArray from LHC Data
-       //
-
-       TString timeStartString = (TString)GetRunParameter("DAQ_time_start");
-       TString timeEndString = (TString)GetRunParameter("DAQ_time_end");
-       if (timeStartString.IsNull() || timeStartString.IsNull()){
-               if (timeStartString.IsNull()){ 
-                       AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid");
-               }
-               else if (timeStartString.IsNull()){
-                       AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
-               }
-               return 0;
-       }  
-
-       Int_t timeStart = (Int_t)(timeStartString.Atoi());
-       Int_t timeEnd = (Int_t)(timeEndString.Atoi());
-       timeStart = 1260646960;
-       timeEnd = 1260652740;
-       Double_t* parameters = new Double_t[5];
-       parameters[0] = -1.;
-       parameters[1] = -1.;
-       parameters[2] = -1.;
-       parameters[3] = -1.;
-       parameters[4] = -1.;
-       Int_t iCounts = 0;
-       Int_t iCountsRun = 0;
-       Int_t nCounts = array->GetEntries();
-       printf("ncounts = %d\n",nCounts);
-       Double_t valueBeforeSOR = 0;
-       Double_t valueAfterEOR = 0;
-       Double_t timestampBeforeSOR = -1.;
-       Double_t timestampAfterEOR = -1.;
-       Int_t ientrySOR = -1;
-       Int_t ientryEOR = -1;
-       Double_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++) {
-               AliDCSArray *dcs = (AliDCSArray*)array->At(i);
-               if((dcs->GetTimeStamp() >= timeStart) &&(dcs->GetTimeStamp() <= timeEnd)) {
-                       AliDebug(2,Form("%d-th entry = %f at timestamp %f\n",i,(Double_t)(dcs->GetInt(0)),dcs->GetTimeStamp()));
-                       iCounts += 1;
-                       // look for the last value before SOR and the first value before EOR
-                       if ((dcs->GetTimeStamp() >= timeStart) && (dcs->GetTimeStamp() < timeStart)) {
-                               timestampBeforeSOR = dcs->GetTimeStamp();
-                               AliDebug(2,Form("timestamp of last value before SOR = %f, with DAQ_time_start = %d\n",timestampBeforeSOR,timeStart));
-                               valueBeforeSOR = (Double_t)(dcs->GetInt(0));
-                       }
-                       else if ((dcs->GetTimeStamp() <= timeEnd) && (dcs->GetTimeStamp() > timeEnd) && timestampAfterEOR == -1){
-                               timestampAfterEOR = dcs->GetTimeStamp();
-                               valueAfterEOR = (Double_t)(dcs->GetInt(0));
-                               AliDebug(2,Form("timestamp of first value after EOR = %f, with DAQ_time_end = %d\n",timestampAfterEOR,timeEnd));
-                       }
-                       // check if there are DPs between DAQ_time_start and DAQ_time_end
-                       if((dcs->GetTimeStamp() >= timeStart) &&(dcs->GetTimeStamp() <= timeEnd)) {
-                               if (ientrySOR == -1) ientrySOR = i;  // first entry after SOR
-                               if (ientryEOR < i) ientryEOR = i;  // last entry before EOR
-                               AliDebug(2,Form("entry between SOR and EOR\n"));
-                               iCountsRun += 1;
-                       }
-               }
-               else {
-                       printf("DCS values for the parameter outside the queried interval: timestamp = %f\n",dcs->GetTimeStamp());
-               }
-       }
-
-       if (timestampBeforeSOR == -1.){
-               printf("No value found before SOR\n");
-       }
-       if (timestampAfterEOR == -1.){
-               printf("No value found after EOR\n");
-       }
-
-       printf("Number of valid entries (within DCS query interval) = %i, from a total amount of %i entries\n",iCounts,nCounts);
-       printf("Last value before DAQ_time_start (SOR) = %f at timestamp = %f\n",valueBeforeSOR,timestampBeforeSOR);
-       printf("First value after DAQ_time_end (EOR)   = %f at timestamp = %f\n",valueAfterEOR,timestampAfterEOR);
-       printf("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)\n",iCountsRun);
-       printf("Index of first entry after DAQ_time_start (SOR) = %d\n ",ientrySOR);
-       printf("Index of first entry before DAQ_time_end (EOR) = %d\n ",ientryEOR);
-
-       Int_t nentriesUsed = 0;
-       if (iCountsRun > 1){
-               printf("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)\n");
-               printf("Calculating (weighted) Mean and Median\n" );
-               arrayValues = new Double_t[iCountsRun]; 
-               arrayWeights = new Double_t[iCountsRun]; 
-               nentriesUsed = iCountsRun;
-               for (Int_t i = ientrySOR; i <= ientryEOR; i++){
-                       AliDCSArray *dcs = (AliDCSArray *)array->At(i);
-                       Double_t timestamp2 = 0;
-                       if (i < ientryEOR){
-                               AliDCSArray *dcs1 = (AliDCSArray *)array->At(i+1);
-                               timestamp2 = dcs1->GetTimeStamp();
-                       }
-                       else {
-                               timestamp2 = (Double_t)timeEnd+1;
-                       }
-                       arrayWeights[i-ientrySOR] = (Double_t)((Double_t)timestamp2 - dcs->GetTimeStamp());
-                       arrayValues[i-ientrySOR] = (Double_t)(dcs->GetInt(0));
-                       printf("Entry %d: value = %f, weight = %f\n",i-ientrySOR,arrayValues[i-ientrySOR],arrayWeights[i-ientrySOR]);
-               }
-               parameters[0] = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
-               parameters[2] = TMath::Median(iCountsRun,arrayValues,arrayWeights);
-       }
-       else if (iCountsRun == 1){
-               AliDCSArray* dcs = (AliDCSArray *)array->At(ientrySOR);
-               nentriesUsed = 2;
-               if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)dcs->GetTimeStamp()){
-                       printf("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR. Truncated mean won't be calculated.\n");
-                       arrayValues = new Double_t[2];
-                       arrayWeights = new Double_t[2];
-                       arrayValues[0] = valueBeforeSOR;
-                       arrayWeights[0] = (Double_t)(dcs->GetTimeStamp()-(Double_t)timestampBeforeSOR);
-                       arrayValues[1] = (Double_t)(dcs->GetInt(0));
-                       arrayWeights[1] = (Double_t)((Double_t)timeEnd+1-dcs->GetTimeStamp());
-                       printf("value0 = %f, with weight = %f\n",arrayValues[0],arrayWeights[0]); 
-                       printf("value1 = %f, with weight = %f\n",arrayValues[1],arrayWeights[1]); 
-                       parameters[0] = TMath::Mean(2,arrayValues,arrayWeights);
-                       parameters[2] = TMath::Median(2,arrayValues,arrayWeights);
-                       truncMeanFlag = kFALSE;
-               }
-               else{
-                       printf("Cannot calculate mean, truncated mean, median, SD wrt mean, SD wrt median for current DP - only one value collected during the run, but no value before with which to calculate the statistical quantities\n");
-                       parameters[0] = -1;
-                       parameters[1] = -1;
-                       parameters[2] = -1;
-                       parameters[3] = -1;
-                       parameters[4] = -1;
-                       return parameters[0];
-               }
-       }
-       else { // iCountsRun == 0, using only the point immediately before SOR
-               if (timestampBeforeSOR == -1.){
-                       printf("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\n");
-                       parameters[0] = -1;
-                       parameters[1] = -1;
-                       parameters[2] = -1;
-                       parameters[3] = -1;
-                       parameters[4] = -1;
-                       return parameters[0];
-               }
-               else {
-                       printf("Using only last entry before SOR. Truncated mean and Standard deviations (wrt mean/median) won't be calculated.\n");
-                       printf("value = %f\n",valueBeforeSOR); 
-                       parameters[0] = valueBeforeSOR;
-                       parameters[2] = valueBeforeSOR;
-                       truncMeanFlag = kFALSE;
-                       sdFlag = kFALSE;
-               }
-       }
-
-       Double_t temp = 0;
-       Double_t temp1 = 0;
-       Double_t sumweights = 0; 
-       Int_t entriesTruncMean = 0;
-       Double_t* arrayValuesTruncMean = new Double_t[nentriesUsed]; 
-       Double_t* arrayWeightsTruncMean = new Double_t[nentriesUsed]; 
-
-       // calculating SD wrt Mean and Median
-       printf("Calculating SD wrt Mean and SD wrt Median\n");
-       if (sdFlag){
-               for (Int_t i =0; i< nentriesUsed; i++){
-                       //printf("Entry %d: value = %f, weight = %f\n",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 {
-                       printf("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid\n");
-                       parameters[3] = -1;
-               }
-               // setting SD wrt Median
-               if (nentriesUsed != 0){
-                       parameters[4] = TMath::Sqrt(temp/nentriesUsed);
-               }
-               else{
-                       printf("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid\n");
-                       parameters[4] = -1;
-               }
-       }
-       else {
-               parameters[3] = -1;
-               parameters[4] = -1;
-       }               
-
-       // calculating truncated mean (this comes afterwards since you need the SD wrt Mean)
-       if (truncMeanFlag){
-               printf("Calculating Truncated Mean\n");
-               for (Int_t i =0; i< nentriesUsed; i++){
-                       //printf("Entry %d: value = %f, weight = %f\n",i,arrayValues[i],arrayWeights[i]);
-                       if ((arrayValues[i]<=parameters[0]+3*parameters[3]) && (arrayValues[i]>=parameters[0]-3*parameters[3])){
-                               arrayValuesTruncMean[entriesTruncMean]=arrayValues[i];
-                               arrayWeightsTruncMean[entriesTruncMean]=arrayWeights[i];
-                               printf("For Truncated Mean: Entry %d: value = %f, weight = %f\n",entriesTruncMean,arrayValuesTruncMean[entriesTruncMean],arrayWeightsTruncMean[entriesTruncMean]);
-                               entriesTruncMean++;                     
-                       }
-                       else{
-                               printf("Discarding entry\n");
-                       }
-               }
-               // setting truncated mean 
-               if (entriesTruncMean >1){
-                       printf("%d entries used for truncated mean\n",entriesTruncMean);
-                       parameters[1] = TMath::Mean(entriesTruncMean,arrayValuesTruncMean,arrayWeightsTruncMean);
-               }
-               else{   
-                       printf("Too few entries (%d) to calculate truncated mean\n",entriesTruncMean);
-                       parameters[1] = -1;
-               }
-       }
-       else{
-                       parameters[1] = -1;
-       }
-       
-       printf("(weighted) mean = %f \n",parameters[0]);
-       printf("(weighted) truncated mean = %f \n",parameters[1]);
-       printf("median = %f \n",parameters[2]);
-       printf("(weighted) standard deviation with (weighted) mean = %f \n",parameters[3]);
-       printf("standard deviation with median = %f \n",parameters[4]);
-       
-       return (parameters[0]);
-}
 //------------------------------------------------------------------------------------------------------
 Float_t AliGRPPreprocessor::ProcessEnergy(TObjArray* const array, Double_t timeStart){