]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGRPPreprocessor.cxx
The GRP objects will have a bit flagging the "LHC Polarities convention" ON.
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
index e2e36d10f4441b9eba660f0c90024973a2f93da4..14aa3461b9c30b328c111565733316cb510a19bd 100644 (file)
@@ -36,7 +36,7 @@
 #include "AliDCSSensor.h"
 #include "AliSplineFit.h"
 #include "AliDCSSensorArray.h"
-//#include "AliRawEventHeaderVersions.h"
+#include "AliRawEventHeaderVersions.h"
 
 #include "AliTriggerConfiguration.h"
 #include "AliTriggerRunScalers.h"
@@ -63,7 +63,7 @@ ClassImp(AliGRPPreprocessor)
 
 //_______________________________________________________________
 
-  const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook for PHYSICS runs, when beamType from DAQ logbook != Cosmics
+  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::fgknDCSDPHallProbes = 40;   // number of dcs dps
@@ -183,7 +183,7 @@ ClassImp(AliGRPPreprocessor)
                    "",
                    "(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)"
@@ -285,7 +285,8 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        Int_t iDaqLB = ProcessDaqLB(grpobj);
        TString runType = (TString)GetRunType();
        TString beamType = (TString)GetRunParameter("beamType");
-       if((runType == "PHYSICS" && iDaqLB == fgknDAQLbPar && beamType!="Cosmics") ||  (runType == "PHYSICS" && iDaqLB == fgknDAQLbParReduced && beamType=="Cosmics") || (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!!!"));
@@ -458,16 +459,18 @@ 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!="Cosmics")){
-                       nparameter++; // increasing nparameters only in case we're in PHYSICS runs with beamType != Cosmics
+               //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!="Cosmics")){
+               //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()));
                }
        }
 
@@ -478,7 +481,8 @@ Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj)
                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){
@@ -525,7 +529,7 @@ UInt_t AliGRPPreprocessor::ProcessDaqFxs()
 {
        //======DAQ FXS======//
        
-       //      AliRawEventHeaderV3_9::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_9 - temporary fix 
+       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!");
@@ -614,7 +618,7 @@ UInt_t AliGRPPreprocessor::ProcessDcsFxs(TString partition, TString detector)
        // 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..."));
@@ -694,7 +698,7 @@ Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, AliGRPObject* grpObj)
        nDipoleEntries = ProcessDipoleDPs(valueMap, grpObj);
        nEnvEntries = ProcessEnvDPs(valueMap, grpObj);
        nHallProbesEntries = ProcessHPDPs(valueMap, grpObj);
-
+       grpObj->SetPolarityConventionLHC();  // after the dipole cables swap we comply with LHC convention
        entries = nLHCEntries + nL3Entries + nDipoleEntries + nEnvEntries + nHallProbesEntries;
        return entries;
 
@@ -1524,7 +1528,7 @@ AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap)
 
   
 //_______________________________________________________________
-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
@@ -1594,6 +1598,8 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
        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); 
@@ -1601,6 +1607,8 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
        grpObj->SetDetectorMask(detectorMask);
        grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0);
        grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0);
+       grpObj->SetL3Polarity(l3Polarity);
+       grpObj->SetDipolePolarity(dipolePolarity);
 
        delete row;
        row = 0;
@@ -1681,6 +1689,44 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
                        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());