]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttle.cxx
Printout fixed.
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttle.cxx
index 8dfd749614509d639294ce72e33148d159a7f31c..1da5fb43038a30de70d1b364dc3431585995d29f 100644 (file)
@@ -870,7 +870,7 @@ const char* AliShuttle::GetRefFilePrefix(const char* base, const char* detector)
        //
 
        TString offDetStr(GetOfflineDetName(detector));
-       TString dir;
+       static TString dir;
        if (offDetStr == "ITS" || offDetStr == "MUON" || offDetStr == "PHOS")
        {
                dir.Form("%s/%s/%s", base, offDetStr.Data(), detector);
@@ -879,8 +879,6 @@ const char* AliShuttle::GetRefFilePrefix(const char* base, const char* detector)
        }
        
        return dir.Data();
-       
-
 }
 
 //______________________________________________________________________________________________
@@ -1939,7 +1937,7 @@ Bool_t AliShuttle::QueryShuttleLogbook(const char* whereClause,
        }
 
        // TODO Check field count!
-       const UInt_t nCols = 25;
+       const UInt_t nCols = 26;
        if (aResult->GetFieldCount() != (Int_t) nCols) {
                Log("SHUTTLE", "Invalid SQL result field number!");
                delete aResult;
@@ -2535,11 +2533,19 @@ Bool_t AliShuttle::Connect(Int_t system)
        //
 
        // check connection: if already connected return
+
        if(fServer[system] && fServer[system]->IsConnected()) {
-               // ping the server --> automatic reconnection should occur if it was broken but the
-               // server is still alive
-               fServer[system]->Ping();
-               return kTRUE;
+               // ping the server              
+               if (fServer[system]->PingVerify()==kTRUE){ // connection is still alive
+                       return kTRUE;
+               }               
+               else{
+                       AliWarning(Form("Connection got lost to FXS database for %s. Closing and reconnecting.",
+                                       AliShuttleInterface::GetSystemName(system)));
+                       fServer[system]->Close();
+                       delete fServer[system];
+                       fServer[system] = 0x0;
+               }
        }
 
        TString dbHost, dbUser, dbPass, dbName;
@@ -2706,7 +2712,7 @@ Bool_t AliShuttle::UpdateTableSkippedCase(const char* detector)
                if (detName == "ALL") whereClause = Form("where run=%d and time_processed IS NULL;",GetCurrentRun());
                else whereClause = Form("where run=%d and detector=\"%s\" and time_processed IS NULL;",GetCurrentRun(), detector);
 
-               Log("SHUTTLE",Form(" whereClause = %s ",whereClause.Data()));
+               //Log("SHUTTLE",Form(" whereClause = %s ",whereClause.Data()));
 
                TString sqlQuery = Form("update %s set time_processed=%d %s", fConfig->GetFXSdbTable(system),
                                        now.GetSec(), whereClause.Data());
@@ -3310,6 +3316,7 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
                body = Form("Dear  %s FXS experts, \n\n",sys.Data());
                body += Form("SHUTTLE couldn\'t retrieve data from the FXS for detector %s "
                             "in run %d!!\n\n", fCurrentDetector.Data(), GetCurrentRun());
+               body += Form("The contacted server was:\nDB: %s\nFXS:%s\n\n", fConfig->GetFXSdbHost(system), fConfig->GetFXSHost(system));
        }
        else {
                subject = Form("%s %s Shuttle preprocessor FAILED in run %d (run type = %s)!",
@@ -3338,7 +3345,7 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
        
        
        body += Form("Find the %s log for the current run on \n\n"
-               "\thttp://pcalishuttle01.cern.ch:8880/%s/%d/%d/%s.log \n\n", 
+               "\thttp://pcalishuttle02.cern.ch/%s/%d/%d/%s.log \n\n", 
                     fCurrentDetector.Data(), logFolder.Data(), GetCurrentRun()/10000,  
                                GetCurrentRun(), fCurrentDetector.Data());
        body += Form("The last 15 lines of %s log file are following:\n\n", fCurrentDetector.Data());
@@ -3469,6 +3476,100 @@ const char* AliShuttle::GetTriggerConfiguration()
        return triggerConfig;
 }
 
+//______________________________________________________________________________________________
+const char* AliShuttle::GetCTPTimeParams()
+{
+       // Receives the CTP time parameters from the DAQ logbook for the current run
+       
+       // check connection, if needed reconnect
+       if (!Connect(3)) 
+               return 0;
+
+       TString sqlQuery;
+       sqlQuery.Form("SELECT alignmentFile FROM logbook_trigger_config WHERE run = %d", GetCurrentRun());
+       TSQLResult* result = fServer[3]->Query(sqlQuery);
+       if (!result)
+       {
+               Log("SHUTTLE", Form("ERROR: Can't execute query <%s>!", sqlQuery.Data()));
+               return 0;
+       }
+       
+       if (result->GetRowCount() == 0)
+       {
+               Log("SHUTTLE", "ERROR: CTP time params not found in logbook_trigger_config");
+               delete result;
+               return 0;
+       }
+       
+       TSQLRow* row = result->Next();
+       if (!row)
+       {
+               Log("SHUTTLE", "ERROR: Could not receive logbook_trigger_config data");
+               delete result;
+               return 0;
+       }
+
+       // static, so that pointer remains valid when it is returned to the calling class       
+       static TString triggerTimeParams(row->GetField(0));
+       
+       delete row;
+       row = 0;
+       
+       delete result;
+       result = 0;
+       
+       Log("SHUTTLE", Form("Found trigger time parameters: %s", triggerTimeParams.Data()));
+       
+       return triggerTimeParams;
+}
+
+//______________________________________________________________________________________________
+const char* AliShuttle::GetTriggerDetectorMask()
+{
+       // Receives the trigger detector mask from DAQ logbook
+       
+       // check connection, if needed reconnect
+       if (!Connect(3)) 
+               return 0;
+
+       TString sqlQuery;
+       sqlQuery.Form("SELECT BIN(BIT_OR(inputDetectorMask)) from logbook_trigger_clusters WHERE run = %d;", GetCurrentRun());
+       TSQLResult* result = fServer[3]->Query(sqlQuery);
+       if (!result)
+       {
+               Log("SHUTTLE", Form("ERROR: Can't execute query <%s>!", sqlQuery.Data()));
+               return 0;
+       }
+       
+       if (result->GetRowCount() == 0)
+       {
+               Log("SHUTTLE", "ERROR: Trigger Detector Mask not found in logbook_trigger_clusters");
+               delete result;
+               return 0;
+       }
+       
+       TSQLRow* row = result->Next();
+       if (!row)
+       {
+               Log("SHUTTLE", "ERROR: Could not receive logbook_trigger_clusters data");
+               delete result;
+               return 0;
+       }
+
+       // static, so that pointer remains valid when it is returned to the calling class       
+       static TString triggerDetectorMask(row->GetField(0));
+       
+       delete row;
+       row = 0;
+       
+       delete result;
+       result = 0;
+       
+       Log("SHUTTLE", Form("Found Trigger Detector Mask: %s", triggerDetectorMask.Data()));
+       
+       return triggerDetectorMask;
+}
+
 //______________________________________________________________________________________________
 void AliShuttle::SetShuttleTempDir(const char* tmpDir)
 {