]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/TestShuttle/TestPreprocessor.C
Adding functionality to the Shuttle/TestShuttle:
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / TestPreprocessor.C
index adba4ba9163898b47a9469322d8ec44a203b020e..7f277e166a9799d20e7a8adaec4ffb135d01e978 100644 (file)
@@ -13,11 +13,21 @@ void TestPreprocessor()
   // load library
   gSystem->Load("libTestShuttle.so");
 
-  // initialize location of CDB
-  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+   // 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
+  AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  AliTestShuttle::SetMainRefStorage("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());
 
-  // create AliTestShuttle instance
-  AliTestShuttle* shuttle = new AliTestShuttle();
 
   // TODO(1)
   //
@@ -51,32 +61,64 @@ void TestPreprocessor()
   // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
   // In this example we add a file originating from the GDC with the id PEDESTALS
   // Three files originating from different LDCs but with the same id are also added
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "PEDESTALS", "GDC", "file1.root");
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC0", "file2a.root");
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC1", "file2b.root");
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC2", "file2b.root");
+  // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
+  // the "online" naming convention ALICE-INT-2003-039.
+  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "PEDESTALS", "GDC0", "file1.root");
+  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root");
+  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root");
+  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2c.root");
 
   // TODO(3)
+  //
+  // The shuttle can read run type stored in the DAQ logbook.
+  // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
+  // using GetRunType function.
+  shuttle->SetInputRunType("PHYSICS");
+
+  // TODO(4)
+  //
+  // The shuttle can read run parameters stored in the DAQ run logbook.
+  // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
+  // using GetRunParameter function.
+  shuttle->AddInputRunParameter("totalEvents", "30000");
+  shuttle->AddInputRunParameter("NumberOfGDCs", "15");
+
+  // TODO(5)
+  //
+  // 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(6)
   // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
-  AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle);
+  AliPreprocessor* test = new AliTestPreprocessor(shuttle);
 
   // Test the preprocessor
   shuttle->Process();
 
-  // TODO(4)
+  // TODO(7)
   // 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()->Get("DET/SHUTTLE/Data", 0);
-  if (!entry)
+  AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
+                       ->Get("TPC/Calib/Data", 7);
+  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();
@@ -111,8 +153,7 @@ TMap* CreateDCSAliasMap()
 
     for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
     {
-      AliSimpleValue* simVal = new AliSimpleValue((Float_t) (random.Gaus()+5*nAlias));
-      AliDCSValue* dcsVal = new AliDCSValue(*simVal, timeStamp);
+      AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
       //printf("%s\n",dcsVal->ToString().Data());
       valueSet->Add(dcsVal);
     }
@@ -130,7 +171,8 @@ TMap* ReadDCSAliasMap()
   // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
   // An explanation of the structure can be found in CreateDCSAliasMap()
 
-  AliCDBEntry *entry = AliCDBManager::Instance()->Get("DET/DCS/Data", 0);
+  AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
+                       ->Get("DET/DCS/Data", 0);
   return dynamic_cast<TMap*> (entry->GetObject());
 }
 
@@ -147,8 +189,8 @@ void WriteDCSAliasMap()
 
   AliCDBId id("DET/DCS/Data", 0, 0);
 
-  // initialize location of CDB
-  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  // look into AliTestShuttle's CDB main folder
 
-  AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
+  AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
+                       ->Put(dcsAliasMap, id, &metaData);
 }