+ // processing DPs
+ // related to
+ // evironment conditions (temperature, pressure) info
+
+ Int_t nEnvEntries = 0;
+ TObjArray *array = 0x0;
+ Int_t indexDP = -1;
+
+ AliInfo(Form("==========CavernTemperature==========="));
+ Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
+ indexDP = kCavernTemperature;
+ array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
+ if(!array) {
+ Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
+ }
+ else {
+ if (array->GetEntries() == 0){
+ AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
+ }
+ else {
+ Float_t *floatDCS = ProcessFloatAll(array);
+ if (floatDCS != NULL){
+ grpObj->SetCavernTemperature(floatDCS);
+ }
+ else{
+ outOfRange = kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ ffailedDPs->RemoveAt(indexDP);
+ nEnvEntries++;
+ }
+ }
+
+ if (array) array = 0x0;
+
+ AliInfo(Form("========== AtmosPressures (Cavern + Surface + Cavern2) ==========="));
+ AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap);
+ //dcsSensorArray->Print();
+ if( fPressure->NumFits()<kNumSensors ) {
+ Log(Form("Check the pressure sensor values! Not all the %d pressure sensors have been fit",kNumSensors));
+ }
+ 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("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("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;
+}
+//_______________________________________________________________
+
+Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpObj)
+{
+ // processing DPs
+ // related to
+ // Hall Probes info
+
+ Int_t nHPEntries = 0;
+ TObjArray *array = 0x0;
+ Int_t indexDP = -1;
+ Bool_t outOfRange; // flag to monitor if any value collected by DCS is out of range
+
+ if (fgknDCSDPHallProbes != AliGRPObject::GetNumberOfHP()){
+ AliError(Form("Number of Hall probes expected in GRP Preprocessor (i.e. %d) different from number of Hall Probes foreseen in GRP object (i.e. %d). Looping on entries from GRP object anyway.", fgknDCSDPHallProbes, AliGRPObject::GetNumberOfHP()));
+ }
+ for (indexDP = 0; indexDP < AliGRPObject::GetNumberOfHP(); indexDP++){
+ outOfRange = kFALSE; // resetting outOfRange flag at each HP
+ AliInfo(Form("==========%s===========",AliGRPObject::GetHPDP(indexDP)));
+ array = (TObjArray *)valueMap->GetValue(AliGRPObject::GetHPDP(indexDP));
+ if(!array) {
+ Log(Form("%s not found in the map!!!",AliGRPObject::GetHPDP(indexDP)));
+ }
+ else {
+ if (array->GetEntries() == 0){
+ AliError(Form("No entries found in array! setting %s to invalid...",AliGRPObject::GetHPDP(indexDP)));
+ }
+ else {
+ Float_t *floatDCS = ProcessFloatAll(array);
+ if (floatDCS != NULL){
+ AliDebug(2,Form("value[0] = %f, value[1] = %f, value[2] = %f, value[3] = %f, value[4] = %f",floatDCS[0],floatDCS[1],floatDCS[2],floatDCS[3],floatDCS[4]));
+ grpObj->SetHallProbes((AliGRPObject::DP_HallProbes)indexDP,floatDCS);
+ for (Int_t kk = 0 ; kk< 5; kk++){
+ AliDebug(2,Form("HallProbe[%d][%d]=%f",indexDP,kk,grpObj->GetHallProbes((AliGRPObject::DP_HallProbes)indexDP,(AliGRPObject::Stats)kk)));
+ }
+ }
+ else{
+ outOfRange = kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ ffailedDPs->RemoveAt(indexDP + fgkDCSDPHallTopShift); // 7 = shift in the complete list of DPs to get to the Hall Probes
+ nHPEntries++;
+ }
+ }
+ }
+
+ Log(Form("Hall Probes = %d ", nHPEntries));
+ return nHPEntries;
+}
+
+//_________________________________________________________________________
+
+AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TString& stringID){
+
+
+ //
+ // returning Spline Fit
+ //
+
+ Int_t entriesarray = array->GetEntries();
+ Float_t* value = new Float_t[entriesarray];
+ Float_t* time = new Float_t[entriesarray];
+ AliDCSValue* v = 0x0;
+ for (Int_t iarray = 0; iarray < entriesarray; iarray++){
+ v = (AliDCSValue*)array->At(iarray);
+ value[iarray] = v->GetFloat();
+ time[iarray] = v->GetTimeStamp();
+ AliDebug(2,Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray]));
+ }
+ TGraph* gr = new TGraph(entriesarray,value,time);
+ if (!gr ) {
+ AliWarning(Form("%s: no input graph to compute SplineFit",stringID.Data()));
+ return NULL;
+ }
+ AliSplineFit *fit = new AliSplineFit();
+ fit->SetMinPoints(10);
+ 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;
+}
+
+//_________________________________________________________________________
+
+TString AliGRPPreprocessor::ProcessChar(const TObjArray *array)
+{
+
+ //
+ // processing char
+ //
+
+ TString aDCSString="";
+
+ AliDCSValue *v = 0x0;
+ for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) {
+ v = (AliDCSValue *)array->At(iCount);
+ if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) {
+ AliError(Form("DCS values for the parameter outside the queried interval"));
+ continue;
+ }
+ if (iCount > 0) {
+ if (aDCSString != v->GetChar())
+ AliError(Form("DCS values for the parameter changed from %s to %c within the queried interval", aDCSString.Data(), (Char_t)v->GetChar()));
+ }
+ aDCSString = (TString)v->GetChar(); // keeping always last value in the array
+ }
+ return aDCSString;
+}
+
+//__________________________________________________________________________________________________________________
+
+Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
+{
+ //
+ // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median
+ //
+ // parameters[0] = mean
+ // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean
+ // parameters[2] = median
+ // parameters[3] = standard deviation wrt mean
+ // parameters[4] = standard deviation wrt median
+ //
+
+ 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");
+ }
+ fdaqStartEndTimeOk = kFALSE;
+ return 0;
+ }
+
+ Int_t timeStart = (Int_t)(timeStartString.Atoi());
+ Int_t timeEnd = (Int_t)(timeEndString.Atoi());
+ Float_t* parameters = new Float_t[5];
+ Int_t iCounts = 0;
+ Int_t iCountsRun = 0;
+ Int_t nCounts = array->GetEntries();
+ Float_t valueBeforeSOR = 0;
+ Float_t valueAfterEOR = 0;
+ Int_t timestampBeforeSOR = -1;
+ Int_t timestampAfterEOR = -1;
+ Int_t ientrySOR = -1;
+ Int_t ientryEOR = -1;
+ 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)) {
+ 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));
+ return NULL;
+ }
+ if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
+ AliDebug(2,Form("%d-th entry = %f at timestamp %i",i,v->GetFloat(),v->GetTimeStamp()));
+ iCounts += 1;
+ // look for the last value before SOR and the first value before EOR
+ if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) {
+ timestampBeforeSOR = (Int_t)(v->GetTimeStamp());
+ AliDebug(2,Form("timestamp of last value before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart));
+ valueBeforeSOR = v->GetFloat();
+ }
+ else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){
+ timestampAfterEOR = (Int_t)(v->GetTimeStamp());
+ valueAfterEOR = v->GetFloat();
+ AliDebug(2,Form("timestamp of first value after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd));
+ }
+ // check if there are DPs between DAQ_time_start and DAQ_time_end
+ if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->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"));
+ iCountsRun += 1;
+ }
+ }
+ else {
+ AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp()));
+ }
+ }
+
+ if (timestampBeforeSOR == -1){
+ AliWarning("No value found before SOR");
+ }
+ if (timestampAfterEOR == -1){
+ 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));
+ AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR));
+ AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR));
+ AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun));
+ AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR));
+ AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR));
+
+ Int_t nentriesUsed = 0;
+ if (iCountsRun > 1){
+ AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)");
+ AliDebug(2,"Calculating (weighted) Mean and Median");
+ arrayValues = new Float_t[iCountsRun];
+ arrayWeights = new Double_t[iCountsRun];
+ nentriesUsed = iCountsRun;
+ for (Int_t i = ientrySOR; i <= ientryEOR; i++){
+ AliDCSValue *v = (AliDCSValue *)array->At(i);
+ Int_t timestamp2 = 0;
+ if (i < ientryEOR){
+ AliDCSValue *v1 = (AliDCSValue *)array->At(i+1);
+ timestamp2 = (Int_t)v1->GetTimeStamp();
+ }
+ else {
+ timestamp2 = timeEnd+1;
+ }
+ arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp());
+ arrayValues[i-ientrySOR] = v->GetFloat();
+ }
+ parameters[0] = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
+ parameters[2] = TMath::Median(iCountsRun,arrayValues,arrayWeights);
+ }
+ else if (iCountsRun == 1){
+ AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR);
+ nentriesUsed = 2;
+ if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){
+ AliWarning("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR. Truncated mean won't be calculated.");
+ arrayValues = new Float_t[2];
+ arrayWeights = new Double_t[2];
+ arrayValues[0] = valueBeforeSOR;
+ arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR);
+ arrayValues[1] = v->GetFloat();
+ arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp());
+ 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(2,arrayValues,arrayWeights);
+ parameters[2] = TMath::Median(2,arrayValues,arrayWeights);
+ truncMeanFlag = kFALSE;
+ }
+ else{
+ AliError("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");
+ parameters[0] = AliGRPObject::GetInvalidFloat();
+ parameters[1] = AliGRPObject::GetInvalidFloat();
+ parameters[2] = AliGRPObject::GetInvalidFloat();
+ parameters[3] = AliGRPObject::GetInvalidFloat();
+ parameters[4] = AliGRPObject::GetInvalidFloat();
+ return parameters;
+ }
+ }
+ 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();
+ parameters[3] = AliGRPObject::GetInvalidFloat();
+ parameters[4] = AliGRPObject::GetInvalidFloat();
+ return parameters;
+ }
+ else {
+ 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;
+ }
+ }
+
+ Float_t temp = 0;
+ Float_t temp1 = 0;
+ Float_t sumweights = 0;
+ Int_t entriesTruncMean = 0;
+ Float_t* arrayValuesTruncMean = new Float_t[nentriesUsed];
+ Double_t* arrayWeightsTruncMean = new Double_t[nentriesUsed];
+
+ // calculating SD wrt Mean and Median
+ AliDebug(2,"Calculating SD wrt Mean and SD wrt Median");
+ 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 {
+ parameters[3] = AliGRPObject::GetInvalidFloat();
+ 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])){
+ 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++;
+ }
+ else{
+ AliDebug(2,"Discarding entry");
+ }
+ }
+ // setting truncated mean
+ if (entriesTruncMean >1){
+ AliDebug(2,Form("%d entries used for truncated mean",entriesTruncMean));
+ parameters[1] = TMath::Mean(entriesTruncMean,arrayValuesTruncMean,arrayWeightsTruncMean);
+ }
+ else{
+ AliDebug(2,Form("Too few entries (%d) to calculate truncated mean",entriesTruncMean));
+ parameters[1] = AliGRPObject::GetInvalidFloat();
+ }
+ }
+ else{
+ parameters[1] = AliGRPObject::GetInvalidFloat();
+ }
+
+ AliInfo(Form("(weighted) mean = %f ",parameters[0]));
+ AliInfo(Form("(weighted) truncated mean = %f ",parameters[1]));
+ 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]));
+
+ return parameters;
+}
+
+//__________________________________________________________________________________________________________________
+
+Float_t* AliGRPPreprocessor::ProcessFloatAllMagnet(const TObjArray* array, Int_t indexDP, Bool_t &isZero)
+{
+ //
+ // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median
+ // used for L3 and Dipole magnets, using isZero flag to decide whther the magnet was OFF/ON
+ // the flag is set according to the L3/Dipole current value
+ // current threshold for L3 = 350 A (value provided by DCS)
+ // current threshold for Dipole = 450 A (value provided by DCS)
+ //
+ // parameters[0] = mean
+ // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean
+ // parameters[2] = median
+ // parameters[3] = standard deviation wrt mean
+ // parameters[4] = standard deviation wrt median
+ //
+
+ AliInfo(Form("indexDP = %d",indexDP));
+
+ Int_t nCounts = array->GetEntries();
+ for(Int_t i = 0; i < nCounts; i++) {
+ AliDCSValue *v = (AliDCSValue *)array->At(i);
+ if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) {
+ 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));
+ return NULL;
+ }
+ if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
+ AliDebug(2,Form("%d-th entry = %f",i,v->GetFloat()));
+ if (indexDP == kL3Current && v->GetFloat() > 350 && isZero == kTRUE) isZero=kFALSE;
+ if (indexDP == kDipoleCurrent && v->GetFloat() > 450 && isZero == kTRUE) isZero=kFALSE;
+ }
+ else {
+ AliError(Form("DCS values for the parameter outside the queried interval"));
+ }
+ }
+
+ return ProcessFloatAll(array);
+}
+
+
+//_______________________________________________________________
+
+Char_t AliGRPPreprocessor::ProcessBool(const TObjArray* array, Bool_t &change)
+{
+ //
+ // processing Boolean values
+ //
+
+ Bool_t aDCSBool = kTRUE;
+
+ AliDCSValue *v = 0x0;
+
+ for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) {
+ v = (AliDCSValue *)array->At(iCount);
+ if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) {
+ AliError(Form("DCS values for the parameter outside the queried interval"));
+ continue;
+ }
+ if (iCount > 0) {
+ if (aDCSBool != v->GetBool()) {
+ AliError(Form("DCS values for the parameter changed from %d to %d within the queried interval", (UInt_t)aDCSBool, (UInt_t)v->GetBool()));
+ change = kTRUE;
+ }
+ }
+ aDCSBool = v->GetBool(); // always keeping last value
+ AliDebug(2,Form("Bool = %d",(Int_t)aDCSBool));
+ }
+
+ Char_t caDCSBool = (Char_t) aDCSBool;
+ return caDCSBool;
+