]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding function ReceivePromptRecoParameters to receive the parameters needed for...
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Apr 2008 16:04:36 +0000 (16:04 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Apr 2008 16:04:36 +0000 (16:04 +0000)
STEER/AliGRPPreprocessor.cxx
STEER/AliGRPPreprocessor.h

index 8291e7bf0a3e6c1c9663b9b02ef78ba01a54e77a..c0f42e8bcf676d4f6a10a68b9671e82936ef13d7 100644 (file)
@@ -44,6 +44,15 @@ class AliShuttleInterface;
 
 #include <TH1.h>
 
+// needed for ReceivePromptRecoParameters
+#include <TSQLServer.h>
+#include <TSQLResult.h>
+#include <TSQLRow.h>
+#include <AliCDBManager.h>
+#include <AliCDBMetaData.h>
+#include <AliCDBId.h>
+#include <AliTriggerConfiguration.h>
+
 const Double_t kFitFraction = 0.7;                 // Fraction of DCS sensor fits required
 
 ClassImp(AliGRPPreprocessor)
@@ -643,3 +652,151 @@ AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap, AliDCSS
   
   return result; 
   }*/
+
+  
+//_______________________________________________________________
+Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char* logbookTable, const char* triggerTable, const char *cdbRoot)
+{
+       //
+       // Retrieves logbook and trigger information from the online logbook 
+       // This information is needed for prompt reconstruction
+       //
+       // Parameters are:
+       // Run number
+       // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable
+       // cdbRoot
+       //
+       // returns 0 on success
+       //         negative on error
+       //
+       // This function is NOT called during the preprocessor run in the Shuttle!
+       //
+               
+       // CDB connection
+       AliCDBManager* cdb = AliCDBManager::Instance();
+       cdb->SetDefaultStorage(cdbRoot);
+       
+       // SQL connection
+       TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
+       
+       if (!server)
+       {
+               Printf("ERROR: Could not connect to DAQ LB");
+               return -1;
+       }
+       
+       // main logbook
+       TString sqlQuery;
+       sqlQuery.Form("SELECT time_start, run_type, detectorMask FROM %s WHERE run = %d", logbookTable, run);
+       TSQLResult* result = server->Query(sqlQuery);
+       if (!result) 
+       {
+               Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
+               return -2;
+       }
+
+       if (result->GetRowCount() == 0) 
+       {
+               Printf("ERROR: Run %d not found", run);
+               delete result;
+               return -3;
+       }
+
+       TSQLRow* row = result->Next();
+       if (!row)
+       {
+               Printf("ERROR: Could not receive data from run %d", run);
+               delete result;
+               return -4;
+       }
+       
+       TMap grpData;
+       grpData.Add(new TObjString("time_start"), new TObjString(row->GetField(0)));
+       grpData.Add(new TObjString("run_type"), new TObjString(row->GetField(1)));
+       grpData.Add(new TObjString("detectorMask"), new TObjString(row->GetField(2)));
+       
+       delete row;
+       row = 0;
+       
+       delete result;
+       result = 0;
+       
+       Printf("Storing GRP/GRP/Data object with the following content");
+       grpData.Print();
+
+       AliCDBMetaData metadata;
+       metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus");
+       metadata.SetComment("GRP Output parameters received during online running");
+       
+       AliCDBId id("GRP/GRP/Data", run, run);
+       Bool_t success = cdb->Put(&grpData, id, &metadata);
+       
+       grpData.DeleteAll();
+       
+       if (!success)
+       {
+               Printf("ERROR: Could not store GRP/GRP/Data into OCDB");
+               return -5;
+       }
+       
+       sqlQuery.Form("SELECT configFile FROM %s WHERE run = %d", triggerTable, run);
+       result = server->Query(sqlQuery);
+       if (!result) 
+       {
+               Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
+               return -11;
+       }
+
+       if (result->GetRowCount() == 0) 
+       {
+               Printf("ERROR: Run %d not found in logbook_trigger_config", run);
+               delete result;
+               return -12;
+       }
+
+       row = result->Next();
+       if (!row)
+       {
+               Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run);
+               delete result;
+               return -13;
+       }
+       
+       TString triggerConfig(row->GetField(0));
+       
+       delete row;
+       row = 0;
+       
+       delete result;
+       result = 0;
+       
+       Printf("Found trigger configuration: %s", triggerConfig.Data());
+       
+       // add a function that takes the configuration from a string...
+       AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig);
+       if (!runcfg) 
+       {
+               Printf("ERROR: Could not create CTP configuration object");
+               return -14;
+       }
+       
+       metadata.SetComment("CTP run configuration received during online running");
+       
+       AliCDBId id2("GRP/CTP/Config", run, run);
+       success = cdb->Put(runcfg, id2, &metadata);
+       
+       delete runcfg;
+       runcfg = 0;
+       
+       if (!success)
+       {
+               Printf("ERROR: Could not store GRP/CTP/Config into OCDB");
+               return -15;
+       }
+       
+       server->Close();
+       delete server;
+       server = 0;
+       
+       return 0;
+}
index 8e50717fdfbdd47ad795500dac2927182409ee48..dc5a4e3b2bebfb848da19e51852db9050174ea75 100644 (file)
@@ -31,6 +31,8 @@ class AliGRPPreprocessor: public AliPreprocessor {
   AliGRPPreprocessor(AliShuttleInterface* shuttle);
   virtual ~AliGRPPreprocessor();
   
+  static Int_t ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char* logbookTable, const char* triggerTable, const char *cdbRoot);
+
  protected:
 
   virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
@@ -42,7 +44,7 @@ class AliGRPPreprocessor: public AliPreprocessor {
   UInt_t ProcessDcsFxs();
   TList *ProcessDcsDPs(TMap* valueSet);
   AliDCSSensorArray *GetPressureMap(TMap *dcsAliasMap, AliDCSSensorArray *fPressure);
-
+  
  private:
   static const char* fgkDCSDataPoints[12]; //! names of dcs dps
   AliDCSSensorArray *fPressure; //pressure array