]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Function GetFromOCDB added to AliShuttle and AliTestShuttle.
authoracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Feb 2007 14:10:17 +0000 (14:10 +0000)
committeracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Feb 2007 14:10:17 +0000 (14:10 +0000)
Implementation of FXS database updates: fileChecksum, file size fields.
Setters to OCDB and reference storages, Shuttle log and temp dir in AliShuttle
and AliTestShuttle.
Small bugfixes.

SHUTTLE/TestShuttle/AliTestPreprocessor.cxx
SHUTTLE/TestShuttle/AliTestShuttle.cxx
SHUTTLE/TestShuttle/AliTestShuttle.h
SHUTTLE/TestShuttle/TestPreprocessor.C
SHUTTLE/test/TestHMPIDPreprocessor.cxx

index 40cb519e95ed39c36245220df313d9607d7be054..8135ce21243bb6c915983f292c3763af2dd5e349 100644 (file)
@@ -1,11 +1,13 @@
 #include "AliTestPreprocessor.h"
 
 #include "AliCDBMetaData.h"
+#include "AliCDBEntry.h"
 #include "AliDCSValue.h"
 #include "AliLog.h"
 #include "AliTestDataDCS.h"
 
 #include <TTimeStamp.h>
+#include <TObjString.h>
 
 //
 // This class is an example for a simple preprocessor.
@@ -81,6 +83,17 @@ UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap)
        Log(Form("Number of events not put in logbook!"));
   }
 
+  // Example of how to retrieve a condition object from OCDB
+
+  AliCDBEntry *entry = GetFromOCDB("Calib", "Data");
+  if (!entry)
+  {
+       Log("No object found in OCDB!");
+  } else {
+       TObjString *obj = dynamic_cast<TObjString*> (entry->GetObject());
+       Log(Form("Got TPC/Calib/Data object from OCDB. The object says: %s",obj->GetName()));
+  }
+
 
   //Now we have to store the final CDB file
   AliCDBMetaData metaData;
index a9c87d0893922aee99e5860a53056d2beae3efdf..8df8415489d6c878b5b071749b385b5ddc1ac515 100644 (file)
 
 /*
 $Log$
+Revision 1.8  2007/02/13 11:22:25  acolla
+Shuttle getters and setters of main/local OCDB/Reference storages, temp and log
+folders moved to AliShuttleInterface
+
 Revision 1.6  2006/11/06 14:22:47  jgrosseo
 major update (Alberto)
 o) reading of run parameters from the logbook
@@ -262,6 +266,36 @@ void AliTestShuttle::AddInputFile(Int_t system, const char* detector, const char
   sourceList->Add(new TObjString(source), new TObjString(fileName));
 }
 
+//______________________________________________________________________________________________
+Bool_t AliTestShuttle::AddInputCDBEntry(AliCDBEntry* entry)
+{
+  // This function adds an object in the OCDB to be later retrieved with GetFromOCDB
+
+       AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
+       if (!sto)
+       {
+               Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
+               return 0;
+       }
+
+       return sto->Put(entry);
+}
+
+//______________________________________________________________________________________________
+AliCDBEntry* AliTestShuttle::GetFromOCDB(const AliCDBPath& path)
+{
+// returns obiect from OCDB valid for current run
+
+       AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
+       if (!sto)
+       {
+               Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
+               return 0;
+       }
+
+       return (AliCDBEntry*) sto->Get(path, fRun);
+}
+
 //______________________________________________________________________________________________
 void AliTestShuttle::Process()
 {
@@ -320,3 +354,19 @@ const char* AliTestShuttle::GetRunParameter(const char* key){
        return value->GetName();
 }
 
+//______________________________________________________________________________________________
+void AliTestShuttle::SetShuttleTempDir(const char* tmpDir)
+{
+// sets Shuttle temp directory
+
+       fgkShuttleTempDir = gSystem->ExpandPathName(tmpDir);
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::SetShuttleLogDir(const char* logDir)
+{
+// sets Shuttle log directory
+
+       fgkShuttleLogDir = gSystem->ExpandPathName(logDir);
+}
+
index ef42d29dfe0bca0dc4cc0739a9407dac263bc94c..0c6988181356934c5a4b75001224f1c44dff319d 100644 (file)
@@ -17,6 +17,7 @@ class TMap;
 class TList;
 class AliCDBMetaData;
 class AliCDBPath;
+class AliCDBPath;
 
 class AliTestShuttle : public AliShuttleInterface
 {
@@ -27,6 +28,7 @@ class AliTestShuttle : public AliShuttleInterface
     void AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName);
     void SetDCSInput(TMap* dcsAliasMap) { fDcsAliasMap = dcsAliasMap; }
     void AddInputRunParameter(const char* key, const char* value);
+    Bool_t AddInputCDBEntry(AliCDBEntry* entry);
 
     void Process();
 
@@ -37,10 +39,20 @@ class AliTestShuttle : public AliShuttleInterface
     virtual const char* GetFile(Int_t system, const char* detector, const char* id, const char* source);
     virtual TList* GetFileSources(Int_t system, const char* detector, const char* id);
     virtual const char* GetRunParameter(const char* key);
+    virtual AliCDBEntry* GetFromOCDB(const AliCDBPath& path);
     virtual void Log(const char* detector, const char* message);
 
     virtual void RegisterPreprocessor(AliPreprocessor* preprocessor);
 
+    static void SetMainCDB (TString mainCDB) {fgkMainCDB = mainCDB;}
+    static void SetLocalCDB (TString localCDB) {fgkLocalCDB = localCDB;}
+
+    static void SetMainRefStorage (TString mainRefStorage) {fgkMainRefStorage = mainRefStorage;}
+    static void SetLocalRefStorage (TString localRefStorage) {fgkLocalRefStorage = localRefStorage;}
+
+    static void SetShuttleTempDir (const char* tmpDir);
+    static void SetShuttleLogDir (const char* logDir);
+
   protected:
 
     Int_t fRun;         // run that is simulated with the AliTestShuttle
index 15d987e9c6c57c68bf91213b15e103ea33a1fcf2..61c2b37063fb7b3d252ba83278d8cf684f37fcd0 100644 (file)
@@ -13,26 +13,21 @@ void TestPreprocessor()
   // load library
   gSystem->Load("libTestShuttle.so");
 
+   // create AliTestShuttle instance
+  // The parameters are run, startTime, endTime
+  AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
+
+
+  printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
+
   // TODO if needed, change location of OCDB and Reference test folders
   // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
-  AliShuttleInterface::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
-  AliShuttleInterface::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  AliTestShuttle::SetTestShuttleCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  AliTestShuttle::SetTestShuttleRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
 
   printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
   printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
 
-  // TODO if needed, change location of temp and log folders (however they are not explicitly used here)
-  // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/temp and log
-  AliShuttleInterface::SetShuttleTempDir("$ALICE_ROOT/SHUTTLE/TestShuttle/temp");
-  AliShuttleInterface::SetShuttleLogDir("$ALICE_ROOT/SHUTTLE/TestShuttle/log");
-
-  printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
-  printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir());
-
-
-  // create AliTestShuttle instance
-  // The parameters are run, startTime, endTime
-  AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
 
   // TODO(1)
   //
@@ -83,27 +78,41 @@ void TestPreprocessor()
   shuttle->AddInputRunParameter("NumberOfGDCs", "15");
 
   // TODO(4)
+  //
+  // The shuttle can query condition parameters valid from the current run from the OCDB
+  // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
+  // using GetFromOCDB function.
+
+  TObjString obj("This is a condition parameter stored in OCDB");
+  AliCDBId id("TPC/Calib/Data", 0, AliCDBRunRange::Infinity());
+  AliCDBMetaData md;
+  AliCDBEntry entry(&obj, id, &md);
+
+  shuttle->AddInputCDBEntry(&entry);
+
+
+  // TODO(5)
   // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
   AliPreprocessor* test = new AliTestPreprocessor(shuttle);
 
   // Test the preprocessor
   shuttle->Process();
 
-  // TODO(5)
+  // TODO(6)
   // In the preprocessor AliShuttleInterface::Store should be called to put the final
   // data to the CDB. To check if all went fine have a look at the files produced in
   // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
   //
   // Check the file which should have been created
-  AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
+  AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
                        ->Get("TPC/SHUTTLE/Data", 7);
-  if (!entry)
+  if (!chkEntry)
   {
     printf("The file is not there. Something went wrong.\n");
     return;
   }
 
-  AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject());
+  AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
   // If everything went fine, draw the result
   if (output)
     output->Draw();
index 544db9fe9a99f0fcfa0e363a80fde81f9233aeba..39bdf59fcc52220bb5c80c9fee1739e996b7aa2c 100644 (file)
@@ -112,53 +112,53 @@ UInt_t TestHMPIDPreprocessor::Process(TMap* /*valueMap*/)
        }
        delete filesources;
        
-       // DCS
-       TString filename = GetFile(AliShuttleInterface::kDCS, "DCSFile", 0);
-       if(!filename.Length()) {
-               AliError(Form("Error: retrieval of file from DCS failed!"));
-               return 0;
-       }
-       TString command = Form("more %s", filename.Data());
-       gSystem->Exec(command.Data());
-
-       // STORAGE! The First file name will be stored into CDB, the second into reference storage
-       TObjString filenameObj(filename);
-       AliCDBMetaData metaData;
-       result = Store("Calib", "DCSData", &filenameObj, &metaData);
-
-       // HLT
-       filesources = GetFileSources(AliShuttleInterface::kHLT, "HLTFile");
-
-       if(!filesources) {
-               Log(Form("No sources found for HLTFile for run %d !", fRun));
-               return 0;
-       }
-
-       AliInfo("Here's the list of sources for HLTFile");
-       filesources->Print();
-
-       TIter iter2(filesources);
-       i = 0;
-       while((source=dynamic_cast<TObjString*> (iter2.Next()))){
-               printf("\n\n Getting file #%d\n",++i);
-               //if(i==1) continue;
-               TString filename = GetFile(AliShuttleInterface::kHLT, "HLTFile", source->GetName());
-               if(!filename.Length()) {
-                       AliError(Form("Error: retrieval of file from source %s failed!", source->GetName()));
-                       delete filesources;
-                       return 0;
-               }
-               TString command = Form("more %s",filename.Data());
-               gSystem->Exec(command.Data());
-
-               // STORAGE! The First file name will be stored into CDB, the second into reference storage
-               TObjString filenameObj(filename);
-               AliCDBMetaData metaData;
-               if(i==1) result = Store("Calib", "HLTData", &filenameObj, &metaData);
-               if(i==2) result = StoreReferenceData("Calib", "RefHLTData", &filenameObj, &metaData);
-
-       }
-       delete filesources;
+//     // DCS
+//     TString filename = GetFile(AliShuttleInterface::kDCS, "DCSFile", 0);
+//     if(!filename.Length()) {
+//             AliError(Form("Error: retrieval of file from DCS failed!"));
+//             return 0;
+//     }
+//     TString command = Form("more %s", filename.Data());
+//     gSystem->Exec(command.Data());
+// 
+//     // STORAGE! The First file name will be stored into CDB, the second into reference storage
+//     TObjString filenameObj(filename);
+//     AliCDBMetaData metaData;
+//     result = Store("Calib", "DCSData", &filenameObj, &metaData);
+
+      // HLT
+      filesources = GetFileSources(AliShuttleInterface::kHLT, "HLTFile");
+      if(!filesources) {
+             Log(Form("No sources found for HLTFile for run %d !", fRun));
+             return 0;
+      }
+      AliInfo("Here's the list of sources for HLTFile");
+      filesources->Print();
+      TIter iter2(filesources);
+      i = 0;
+      while((source=dynamic_cast<TObjString*> (iter2.Next()))){
+             printf("\n\n Getting file #%d\n",++i);
+             //if(i==1) continue;
+             TString filename = GetFile(AliShuttleInterface::kHLT, "HLTFile", source->GetName());
+             if(!filename.Length()) {
+                     AliError(Form("Error: retrieval of file from source %s failed!", source->GetName()));
+                     delete filesources;
+                     return 0;
+             }
+             TString command = Form("more %s",filename.Data());
+             gSystem->Exec(command.Data());
+             // STORAGE! The First file name will be stored into CDB, the second into reference storage
+             TObjString filenameObj(filename);
+             AliCDBMetaData metaData;
+             if(i==1) result = Store("Calib", "HLTData", &filenameObj, &metaData);
+             if(i==2) result = StoreReferenceData("Calib", "RefHLTData", &filenameObj, &metaData);
+      }
+      delete filesources;
        
 
        return result;