#include <TList.h>
#include <TMap.h>
#include <TObjString.h>
+#include <TObjArray.h>
#include <TGraph.h>
+#include <TString.h>
+#include <TFile.h>
+
+#include <float.h>
#include "AliGRPPreprocessor.h"
#include "AliGRPObject.h"
#include "AliDCSSensor.h"
#include "AliSplineFit.h"
#include "AliDCSSensorArray.h"
+#include "AliRawEventHeaderVersions.h"
#include "AliTriggerConfiguration.h"
#include "AliTriggerRunScalers.h"
#include "AliCDBMetaData.h"
#include "AliLog.h"
+#include "AliESDVertex.h"
class AliDCSValue;
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)
//_______________________________________________________________
- const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook for PHYSICS runs, when beamType from DAQ logbook != cosmic
+ 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
"Dipole_Outside_Temperature",
"CavernTemperature",
"CavernAtmosPressure",
- "SurfaceAtmosPressure"
+ "SurfaceAtmosPressure",
+ "CavernAtmosPressure2"
};
const char* AliGRPPreprocessor::fgkDCSDataPointsHallProbes[AliGRPPreprocessor::fgknDCSDPHallProbes] = {
"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",
"",
"(DAQ logbook ERROR)",
"(DAQ FXS ERROR)",
- "(DCS FXS ERROR)",
+ "(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)",
+ "(SPD Mean Vertex ERROR)"
};
//_______________________________________________________________
AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
- AliPreprocessor("GRP",shuttle), fPressure(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!
AddRunType("NOISE");
AddRunType("PULSER");
AddRunType("STANDALONE_PULSER");
+ AddRunType("STANDALONE_BC");
+
+ fmaxFloat = FLT_MAX;
+ fminFloat = -FLT_MAX;
+ fmaxDouble = DBL_MAX;
+ fminDouble = -DBL_MAX;
+ fmaxInt = kMaxInt;
+ fminInt = kMinInt;
+ fmaxUInt = kMaxUInt;
+ fminUInt = 0;
+
+ AliInfo(Form("Max allowed float = %6.5e",fmaxFloat));
+ AliInfo(Form("Min allowed float = %6.5e",fminFloat));
+ AliInfo(Form("Max allowed double = %6.5e",fmaxDouble));
+ AliInfo(Form("Min allowed double = %6.5e",fminDouble));
+ AliInfo(Form("Max allowed integer = %d",fmaxInt));
+ AliInfo(Form("Min allowed integer = %d",fminInt));
+ AliInfo(Form("Max allowed unsigned integer = %u",(Int_t)fmaxUInt));
+ AliInfo(Form("Min allowed unsigned integer = %u",(Int_t)fminUInt));
+
+ ffailedDPs->SetOwner(kTRUE);
}
//_______________________________________________________________
//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.");
- 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);
}
//_______________________________________________________________
TString detector = (TString)GetRunParameter("detector");
AliGRPObject *grpobj = new AliGRPObject(); // object to store data
-
+ grpobj->SetBeamEnergyIsSqrtSHalfGeV(); // new format
//=================//
// DAQ logbook //
//=================//
Int_t iDaqLB = ProcessDaqLB(grpobj);
TString runType = (TString)GetRunType();
TString beamType = (TString)GetRunParameter("beamType");
- if((runType == "PHYSICS" && iDaqLB == fgknDAQLbPar && beamType!="cosmic") || (runType == "PHYSICS" && iDaqLB == fgknDAQLbParReduced && beamType=="cosmic") || (runType != "PHYSICS" && iDaqLB == fgknDAQLbParReduced)) {
+ //if((runType == "PHYSICS" && iDaqLB == fgknDAQLbPar && beamType!="Cosmics") || (runType == "PHYSICS" && iDaqLB == fgknDAQLbParReduced && beamType=="Cosmics") || (runType != "PHYSICS" && iDaqLB == fgknDAQLbParReduced)) {
+ if((runType == "PHYSICS" && iDaqLB == fgknDAQLbPar && !beamType.IsNull()) || (runType == "PHYSICS" && iDaqLB == fgknDAQLbParReduced && beamType.IsNull()) || (runType != "PHYSICS" && iDaqLB == fgknDAQLbParReduced)) {
Log(Form("DAQ Logbook, successful!"));
} else {
Log(Form("DAQ Logbook, could not get all expected entries!!!"));
//=================//
Log(Form("Starting DCS Query at %d and finishing at %d",GetStartTimeDCSQuery(),GetEndTimeDCSQuery()));
Int_t entries = ProcessDcsDPs( valueMap, grpobj );
- Log(Form("entries found = %d",entries));
- if( entries < fgknDCSDP-4 ) { // FIXME (!= ) LHState, LHCLuminosity, BeamIntensity, LH3_BSF4_H3 are not working yet...
- Log(Form("Problem with the DCS data points!!!"));
- error |= 8;
- } else Log(Form("DCS data points, successful!"));
+ Log(Form("entries found = %d (should be %d)",entries, fgknDCSDP-4));
+ 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 //
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;
- md.SetResponsible("Ernesto Lopez Torres");
+ md.SetResponsible("Chiara Zampolli");
md.SetComment("Output parameters from the GRP preprocessor.");
Bool_t result = kTRUE;
result = Store("GRP", "Data", grpobj, &md);
delete grpobj;
+ //==================//
+ // SPD Mean Vertex //
+ //==================//
+ UInt_t iSPDMeanVertex = ProcessSPDMeanVertex();
+ if( iSPDMeanVertex == 1 ) {
+ Log(Form("SPD Mean Vertex, successful!"));
+ } else {
+ Log(Form("SPD Mean Vertex failed!!!"));
+ error |= 128;
+ }
+
if (result && !error ) {
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%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],
+ kppError[(error&128)?8:0]
));
return error;
}
}
+//_______________________________________________________________
+
+UInt_t AliGRPPreprocessor::ProcessSPDMeanVertex()
+{
+ //Getting the SPD Mean Vertex
+ TList* list = GetForeignFileSources("SPD", kDAQ, "VertexDiamond");
+ Bool_t storeResult = kTRUE;
+ if (list !=0x0 && list->GetEntries()!=0)
+ {
+ 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));
+ AliInfo(Form("found source %s", str->String().Data()));
+ TString fileNameRun = GetForeignFile("SPD", kDAQ, "VertexDiamond", str->GetName());
+ if (fileNameRun.Length()>0){
+ AliInfo(Form("Got the file %s", fileNameRun.Data()));
+ TFile daqFile(fileNameRun.Data(),"READ");
+ if (daqFile.IsOpen()) {
+ AliESDVertex* meanVtx = dynamic_cast<AliESDVertex*>(daqFile.Get("MeanVertexPos"));
+ if (meanVtx){
+ meanVtx->Print();
+ // storing in the OCDB
+ AliCDBMetaData md;
+ md.SetResponsible("Cvetan Cheshkov");
+ md.SetComment("SPD Mean Vertex");
+ storeResult = Store("GRP", "MeanVertexSPD", meanVtx, &md);
+ }
+ else{
+ AliWarning("No SPD Mean Vertex object found in file");
+ }
+ }
+ else {
+ AliError("Can't open file");
+ storeResult = kFALSE;
+ }
+ }
+ else{
+ AliWarning("No file found for current source for SPD Mean Vertex");
+ }
+ }
+ }
+ else {
+ AliWarning("No list found for SPD Mean Vertex");
+ }
+
+ if (list) delete list;
+
+ return storeResult;
+}
+
+
//_______________________________________________________________
Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj)
if (beamEnergy != 0){
grpObj->SetBeamEnergy(beamEnergy);
Log(Form("Beam Energy for run %d: %f",fRun, beamEnergy));
- if ((runType == "PHYSICS" && beamType!="cosmic")){
- nparameter++; // increasing nparameters only in case we're in PHYSICS runs with beamType != cosmic
+ //if ((runType == "PHYSICS" && beamType!="Cosmics")){
+ if ((runType == "PHYSICS" && !beamType.IsNull())){ // if beamType is NOT Null, then we're not in a Cosmics run
+ nparameter++; // increasing nparameters only in case we're in PHYSICS runs with beamType != NULL
}
}
else {
- if ((runType == "PHYSICS" && beamType!="cosmic")){
+ //if ((runType == "PHYSICS" && beamType!="Cosmics")){
+ if ((runType == "PHYSICS" && !beamType.IsNull())){ // if beamType is NOT Null, then we're not in a Cosmics run
Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, and producing an error (beamType = %s, runType = %s)",beamType.Data(), runType.Data()));
}
else{
- Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, but not producing any error (beamType = %s, runType = %s)",beamType.Data(), runType.Data()));
+ Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, but not producing any error (beamType = NULL, runType = %s)", runType.Data()));
}
}
nparameter++;
}
else {
- Log(Form("Beam Type not put in logbook, setting to invalid in GRP entry!"));
+ Log(Form("Beam Type not put in logbook, setting to invalid in GRP entry! Not producing any error, considering this as a Cosmics run"));
+ nparameter++;
}
if (numberOfDetectors != 0){
{
//======DAQ FXS======//
+ AliRawEventHeaderV3_9::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_9 - temporary fix
TList* list = GetFileSources(kDAQ);
if (!list) {
Log("No raw data tag list: connection problems with DAQ FXS logbook!");
// Get the CTP counters information
if (partition.IsNull() && !detector.IsNull()){ // standalone partition
- Log("STANDALONE partition for current run, using Trigger Configuration dummy value");
+ Log("STANDALONE partition for current run, using Trigger Scalers dummy value");
AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyScalers");
if (!cdbEntry) {
Log(Form("No dummy CTP scalers entry found, going into error..."));
nDipoleEntries = ProcessDipoleDPs(valueMap, 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;
// 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
- AliInfo(Form("==========L3Polarity==========="));
- indexDP = kL3Polarity;
+ AliInfo(Form("==========L3Current==========="));
+ Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
+ indexDP = kL3Current;
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 Polarity to invalid...",fgkDCSDataPoints[indexDP]));
+ AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
}
else {
- Char_t charDCS = ProcessBool(array);
- grpObj->SetL3Polarity(charDCS);
- AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetL3Polarity())));
+ Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero);
+ if (floatDCS != NULL){
+ grpObj->SetL3Current(floatDCS);
+ }
+ else{
+ outOfRange = kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ nL3Entries++;
+ ffailedDPs->RemoveAt(indexDP);
}
- nL3Entries++;
}
if (array) array = 0x0;
- AliInfo(Form("==========L3Current==========="));
- indexDP = kL3Current;
+ AliInfo(Form("==========L3Polarity==========="));
+ indexDP = kL3Polarity;
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]));
+ AliError(Form("No entries found in array! setting %s Polarity to invalid...",fgkDCSDataPoints[indexDP]));
}
else {
- Float_t *floatDCS = ProcessFloatAll(array);
- grpObj->SetL3Current(floatDCS);
- delete floatDCS;
+ Bool_t change = kFALSE;
+ Char_t charDCS = ProcessBool(array,change);
+ 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 {
+ AliError(Form("%s value changed within the run, while the magnet was ON (according to the current), setting it to invalid and considering the DP as wrong",fgkDCSDataPoints[indexDP]));
+ }
}
- nL3Entries++;
}
return nL3Entries;
Int_t nDipoleEntries = 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
- AliInfo(Form("==========DipolePolarity==========="));
- indexDP = kDipolePolarity;
+ AliInfo(Form("==========DipoleCurrent==========="));
+ Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
+ indexDP = kDipoleCurrent;
array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
if(!array) {
Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
}
else {
- Char_t charDCS = ProcessBool(array);
- grpObj->SetDipolePolarity(charDCS);
- AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetDipolePolarity())));
+ Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero);
+ if (floatDCS != NULL){
+ grpObj->SetDipoleCurrent(floatDCS);
+ }
+ else{
+ outOfRange=kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ nDipoleEntries++;
+ ffailedDPs->RemoveAt(indexDP);
}
- nDipoleEntries++;
}
if (array) array = 0x0;
- AliInfo(Form("==========DipoleCurrent==========="));
- indexDP = kDipoleCurrent;
+ AliInfo(Form("==========DipolePolarity==========="));
+ indexDP = kDipolePolarity;
array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
if(!array) {
Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
}
else {
- Float_t *floatDCS = ProcessFloatAll(array);
- grpObj->SetDipoleCurrent(floatDCS);
- delete floatDCS;
+ Bool_t change = kFALSE;
+ Char_t charDCS = ProcessBool(array,change);
+ 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{
+ AliError(Form("%s value changed within the run while the magnet was ON (according to the current), setting it to invalid and considering the DP as wrong", fgkDCSDataPoints[indexDP]));
+ }
}
- nDipoleEntries++;
}
return nDipoleEntries;
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) {
}
else {
Float_t *floatDCS = ProcessFloatAll(array);
- grpObj->SetCavernTemperature(floatDCS);
- delete floatDCS;
+ if (floatDCS != NULL){
+ grpObj->SetCavernTemperature(floatDCS);
+ }
+ else{
+ outOfRange = kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ ffailedDPs->RemoveAt(indexDP);
+ nEnvEntries++;
}
- 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;
}
//_______________________________________________________________
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) {
}
else {
Float_t *floatDCS = ProcessFloatAll(array);
- 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)));
+ 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;
}
- delete floatDCS;
}
- nHPEntries++;
+ if (!outOfRange) {
+ ffailedDPs->RemoveAt(indexDP + 7); // 7 = shift in the complete list of DPs to get to the Hall Probes
+ nHPEntries++;
+ }
}
}
grpObj->SetLHCState(AliGRPObject::GetInvalidString());
}
}
+ ffailedDPs->RemoveAt(indexDP);
nLHCEntries++;
}
if (array) array = 0x0;
AliInfo(Form("==========LHCLuminosity==========="));
+ Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
indexDP = kLHCLuminosity;
array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
if(!array) {
}
else {
Float_t *floatDCS = ProcessFloatAll(array);
- grpObj->SetLHCLuminosity(floatDCS);
- delete floatDCS;
- AliSplineFit* splfit = GetSplineFit(array,fgkDCSDataPoints[indexDP]);
- grpObj->SetLHCLuminositySplineFit(splfit);
+ if (floatDCS != NULL){
+ grpObj->SetLHCLuminosity(floatDCS);
+ AliSplineFit* splfit = GetSplineFit(array,fgkDCSDataPoints[indexDP]);
+ grpObj->SetLHCLuminositySplineFit(splfit);
// delete splfit;
+ }
+ else {
+ outOfRange = kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ ffailedDPs->RemoveAt(indexDP);
+ nLHCEntries++;
}
- nLHCEntries++;
}
if (array) array = 0x0;
AliInfo(Form("==========BeamIntensity==========="));
+ if (outOfRange) outOfRange = kFALSE; // resetting outOfRange if needed
indexDP = kBeamIntensity;
array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
if(!array) {
}
else {
Float_t *floatDCS = ProcessFloatAll(array);
- grpObj->SetBeamIntensity(floatDCS);
- delete floatDCS;
- AliSplineFit* splfit1 = GetSplineFit(array,fgkDCSDataPoints[indexDP]);
- grpObj->SetBeamIntensitySplineFit(splfit1);
- //delete splfit;
+ if (floatDCS != NULL){
+ grpObj->SetBeamIntensity(floatDCS);
+ AliSplineFit* splfit1 = GetSplineFit(array,fgkDCSDataPoints[indexDP]);
+ grpObj->SetBeamIntensitySplineFit(splfit1);
+ //delete splfit;
+ }
+ else{
+ outOfRange = kTRUE;
+ }
+ if (floatDCS){
+ delete[] floatDCS;
+ floatDCS = 0x0;
+ }
+ }
+ if (!outOfRange) {
+ nLHCEntries++;
+ ffailedDPs->RemoveAt(indexDP);
}
- nLHCEntries++;
}
return nLHCEntries;
// 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];
- Double_t aDCSArrayMean = 0; // Mean
- Double_t aDCSArrayTruncMean = 0;// Truncated Mean
- Double_t aDCSArrayMedian = 0; // Median
- Double_t aDCSArraySDMean = 0; // Standard Deviation wrt Mean
- Double_t aDCSArraySDMedian = 0; // Standard Deviation wrt Median
- Float_t aDCSArraySum = 0.0;
Int_t iCounts = 0;
- Int_t iCounts1 = 0;
- Float_t temp = 0;
- Float_t temp1 = 0;
+ Int_t iCountsRun = 0;
Int_t nCounts = array->GetEntries();
- Float_t *tempArray = new Float_t[nCounts];
+ 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())) {
- aDCSArraySum += v->GetFloat();
- tempArray[i] = v->GetFloat();
- AliDebug(2,Form("%d-th entry = %f",i,tempArray[i]));
+ 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()));
}
}
- AliDebug(2,Form("Using %i entries, starting from %i entries",iCounts,nCounts));
- if(iCounts != 0) {
- aDCSArrayMean = TMath::Mean(iCounts,tempArray);
- aDCSArrayMedian = TMath::Median(iCounts,tempArray);
- aDCSArraySDMean = TMath::RMS(iCounts,tempArray);
- AliDebug(2,Form("SD = %f",aDCSArraySDMean));
- // computing standard deviation wrt median
- AliDebug(2,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean));
- for (Int_t i = 0; i < iCounts; i++){
+ 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);
- AliDebug(2,Form("maximum = %f, minimum = %f", aDCSArrayMean+3*aDCSArraySDMean, aDCSArrayMean-3*aDCSArraySDMean));
- AliDebug(2,Form("%i-th entry = %f",i, v->GetFloat()));
- if ((v->GetFloat()<=aDCSArrayMean+3*aDCSArraySDMean) && (v->GetFloat()>=aDCSArrayMean-3*aDCSArraySDMean)){
- temp1+=v->GetFloat();
- iCounts1++;
- AliDebug(2,Form("temp1 = %f, iCounts1 = %i",temp1,iCounts1));
+ Int_t timestamp2 = 0;
+ if (i < ientryEOR){
+ AliDCSValue *v1 = (AliDCSValue *)array->At(i+1);
+ timestamp2 = (Int_t)v1->GetTimeStamp();
+ }
+ else {
+ timestamp2 = timeEnd+1;
}
- temp += (v->GetFloat()-aDCSArrayMedian)*(v->GetFloat()-aDCSArrayMedian);
+ 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);
}
- AliDebug(3,Form("temp before the ratio = %f, with %d counts", temp, iCounts));
- temp/=iCounts;
- AliDebug(3,Form("temp after the ratio = %f", temp));
- if (temp>0) {
- aDCSArraySDMedian = TMath::Sqrt(temp);
+ else {
+ AliError("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid");
+ parameters[3] = AliGRPObject::GetInvalidFloat();
}
- else if (temp==0) {
- AliInfo(Form("Radical = 0 in computing standard deviation wrt median! Setting it to zero...."));
- aDCSArraySDMedian = 0;
+ // setting SD wrt Median
+ if (nentriesUsed != 0){
+ parameters[4] = TMath::Sqrt(temp/nentriesUsed);
}
else{
- AliError(Form("Radical < 0 in computing standard deviation! Setting it to invalid...."));
- aDCSArraySDMedian = AliGRPObject::GetInvalidFloat();
+ AliError("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid");
+ parameters[4] = AliGRPObject::GetInvalidFloat();
}
}
else {
- aDCSArrayMean = AliGRPObject::GetInvalidFloat();
- aDCSArrayMedian = AliGRPObject::GetInvalidFloat();
- aDCSArraySDMean = AliGRPObject::GetInvalidFloat();
- }
- AliDebug(2,Form("iCounts1 = %d and temp1 = %f",iCounts1, temp1));
- if (iCounts1 > 0) {
- aDCSArrayTruncMean = temp1/iCounts1;
+ 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{
- aDCSArrayTruncMean = AliGRPObject::GetInvalidFloat();
+ 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]));
-
-
- AliDebug(2,Form("mean within %d counts = %f ",iCounts,aDCSArrayMean));
- AliDebug(2,Form("truncated mean within %d counts = %f (%i values used)",iCounts,aDCSArrayTruncMean,iCounts1));
- AliDebug(2,Form("median within %d counts = %f ",iCounts,aDCSArrayMedian));
- AliDebug(2,Form("standard deviation with mean within %d counts = %f ",iCounts,aDCSArraySDMean));
- AliDebug(2,Form("standard deviation with median within %d counts = %f ",iCounts,aDCSArraySDMedian));
-
- parameters[0] = aDCSArrayMean;
- parameters[1] = aDCSArrayTruncMean;
- parameters[2] = aDCSArrayMedian;
- parameters[3] = aDCSArraySDMean;
- parameters[4] = aDCSArraySDMedian;
+ return parameters;
+}
- AliDebug(2,Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4]));
- //AliInfo(Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],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)
+Char_t AliGRPPreprocessor::ProcessBool(const TObjArray* array, Bool_t &change)
{
//
// processing Boolean values
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()));
+ 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));
{
//
// processing Int values, returning mean
+ // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values
+ // are outside the queried time interval or their value is out of range
//
- Float_t aDCSArraySum = 0.0;
+ 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());
Float_t aDCSArrayMean = 0.0;
Int_t iCounts = 0;
- AliDCSValue* v = 0x0;
+ 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;
+ Int_t iCountsRun = 0;
+ Int_t nCounts = array->GetEntries();
- for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) {
- v = (AliDCSValue *)array->At(iCount);
+ for(Int_t i = 0; i < nCounts; 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();
+ }
if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
- aDCSArraySum += v->GetInt();
+ AliDebug(2,Form("%d-th entry = %d at timestamp %i",i,v->GetInt(),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 entry before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart));
+ valueBeforeSOR = (Float_t) v->GetInt();
+ }
+ else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){
+ timestampAfterEOR = (Int_t)(v->GetTimeStamp());
+ valueAfterEOR = (Float_t) v->GetInt();
+ AliDebug(2,Form("timestamp of first entry 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(iCounts != 0) aDCSArrayMean = aDCSArraySum/iCounts;
- else aDCSArrayMean = AliGRPObject::GetInvalidFloat();
-
+ 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 query interval) = %i, starting from %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");
+ 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] = (Float_t)v->GetInt();
+ }
+ aDCSArrayMean = TMath::Mean(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.");
+ arrayValues = new Float_t[2];
+ arrayWeights = new Double_t[2];
+ arrayValues[0] = valueBeforeSOR;
+ arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR);
+ arrayValues[1] = (Float_t)v->GetInt();
+ 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]));
+ aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights);
+ }
+ else{
+ AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities");
+ return AliGRPObject::GetInvalidFloat();
+ }
+ }
+ 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 - no points during the run collected, and point before SOR missing");
+ }
+ if (timestampAfterEOR == -1){
+ AliError("Cannot calculate maen - no points during the run collected, and point after EOR missing");
+ }
+ return AliGRPObject::GetInvalidFloat();
+ }
+ else {
+ AliWarning("Using last entry before SOR and first entry after EOR.");
+ 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]));
+ aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights);
+ }
+ }
+
+ AliInfo(Form("mean = %f ", aDCSArrayMean));
return aDCSArrayMean;
}
Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
{
//
- // processing Int values, returning mean
+ // processing Int values, returning mean
+ // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values
+ // are outside the queried time interval or their value is out of range
//
- Float_t aDCSArraySum = 0.0;
+ 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());
Float_t aDCSArrayMean = 0.0;
Int_t iCounts = 0;
- AliDCSValue* v = 0x0;
+ 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;
+ Int_t iCountsRun = 0;
+ Int_t nCounts = array->GetEntries();
- for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) {
- v = (AliDCSValue *)array->At(iCount);
+ for(Int_t i = 0; i < nCounts; 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();
+ }
if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
- aDCSArraySum += v->GetUInt();
+ AliDebug(2,Form("%d-th entry = %d at timestamp %i",i,v->GetUInt(),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 entry before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart));
+ valueBeforeSOR = (Float_t)v->GetUInt();
+ }
+ else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){
+ timestampAfterEOR = (Int_t)(v->GetTimeStamp());
+ valueAfterEOR = (Float_t)v->GetUInt();
+ AliDebug(2,Form("timestamp of first entry 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(iCounts != 0) aDCSArrayMean = aDCSArraySum/iCounts;
- else aDCSArrayMean = AliGRPObject::GetInvalidFloat();
-
+ 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 query interval) = %i, starting from %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");
+ 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] = (Float_t)v->GetUInt();
+ }
+ aDCSArrayMean = TMath::Mean(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.");
+ arrayValues = new Float_t[2];
+ arrayWeights = new Double_t[2];
+ arrayValues[0] = valueBeforeSOR;
+ arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR);
+ arrayValues[1] = (Float_t)v->GetUInt();
+ 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]));
+ aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights);
+ }
+ else{
+ AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities");
+ return AliGRPObject::GetInvalidFloat();
+ }
+ }
+ 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 - no points during the run collected, and point before SOR missing");
+ }
+ if (timestampAfterEOR == -1){
+ AliError("Cannot calculate maen - no points during the run collected, and point after EOR missing");
+ }
+ return AliGRPObject::GetInvalidFloat();
+ }
+ else {
+ AliWarning("Using last entry before SOR and first entry after EOR.");
+ 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]));
+ aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights);
+ }
+ }
+
+ AliInfo(Form("mean = %f ",aDCSArrayMean));
return aDCSArrayMean;
}
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!!!");
}
//_______________________________________________________________
-Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char *cdbRoot)
+Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char *cdbRoot, TString &gdc)
{
//
// Retrieves logbook and trigger information from the online logbook
UInt_t detectorMask = (UInt_t)(detectorMaskString.Atoi());
Float_t l3Current = (Float_t)(TMath::Abs(l3CurrentString.Atof()));
Float_t dipoleCurrent = (Float_t)(TMath::Abs(dipoleCurrentString.Atof()));
+ Char_t l3Polarity = (l3CurrentString.Atof() < 0) ? 1 : 0;
+ Char_t dipolePolarity = (dipoleCurrentString.Atof() < 0) ? 1 : 0;
AliGRPObject * grpObj = new AliGRPObject();
grpObj->SetTimeStart(timeStart);
grpObj->SetDetectorMask(detectorMask);
grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0);
grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0);
+ grpObj->SetL3Polarity(l3Polarity);
+ grpObj->SetDipolePolarity(dipolePolarity);
+ grpObj->SetPolarityConventionLHC(); // after the dipole cables swap we comply with LHC convention
delete row;
row = 0;
return -15;
}
+
+ // Receive list of GDCs for this run
+ sqlQuery.Form("SELECT GDC FROM logbook_stats_GDC WHERE run = %d", run);
+ result = server->Query(sqlQuery);
+ if (!result)
+ {
+ Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
+ return -24;
+ }
+
+ if (result->GetRowCount() == 0)
+ {
+ Printf("ERROR: Run %d not found in logbook_stats_GDC", run);
+ delete result;
+ return -25;
+ }
+
+ gdc = "";
+ for (Int_t iGDC = 0; iGDC < result->GetRowCount(); iGDC++) {
+ row = result->Next();
+ if (!row)
+ {
+ Printf("ERROR: Could not receive logbook_stats_GDC data from run %d", run);
+ delete result;
+ return -26;
+ }
+ gdc += row->GetField(0);
+ gdc += " ";
+ }
+
+ delete row;
+ row = 0;
+
+ delete result;
+ result = 0;
+
+ Printf("Found GDC: %s", gdc.Data());
+
// get last run with same run type that was already processed by the SHUTTLE
sqlQuery.Form("SELECT max(logbook.run) FROM logbook LEFT JOIN logbook_shuttle ON logbook_shuttle.run = logbook.run WHERE run_type = '%s' AND shuttle_done = 1", runType.Data());