+/* $Id$ */
+
// This class runs the test preprocessor
// It uses AliTestShuttle to simulate a full Shuttle process
void TestPreprocessor()
{
- gSystem->Load("libTestShuttle");
+ // load library
+ gSystem->Load("libTestShuttle.so");
- // initialize location of CDB
- AliCDBManager *man = AliCDBManager::Instance();
- man->SetDefaultStorage("local://TestCDB");
+ // 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");
- // TODO decide where to read the data
- TMap* dcsAliasMap = 0;
- //dcsAliasMap = CreateDCSAliasMap();
- dcsAliasMap = ReadDCSAliasMap();
+ printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
+ printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
- // create TMap of available files
- TMap* inputFiles = CreateInputFilesMap();
+ // 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");
- // create AliTestShuttle instance
- AliTestShuttle* shuttle = new AliTestShuttle(inputFiles);
- TestShuttle(shuttle);
+ printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
+ printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir());
- // create preprocessor
- AliPreprocessor* pp = new AliTestPreprocessor("TPC", shuttle);
- // call preprocessor
- pp->Initialize(0, 0, 1);
- pp->Process(dcsAliasMap);
+ // create AliTestShuttle instance
+ // The parameters are run, startTime, endTime
+ AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
+
+ // TODO(1)
+ //
+ // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
+ // some fake data has to be created.
+ //
+ // The "fake" input data can be taken using either (a) or (b):
+ // (a) data from a file: Use ReadDCSAliasMap()
+ // the format of the file is explained in ReadDCSAliasMap()
+ // To use it uncomment the following line:
+ //
+ //TMap* dcsAliasMap = ReadDCSAliasMap();
+ //
+ // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
+ // To use it uncomment the following line:
+ //
+ TMap* dcsAliasMap = CreateDCSAliasMap();
+
+ // now give the alias map to the shuttle
+ shuttle->SetDCSInput(dcsAliasMap);
+
+ // TODO(2)
+ //
+ // The shuttle can also process files that originate from DCS, DAQ and HLT.
+ // To test it, we provide some local files and locations where these would be found when
+ // the online machinery would be there.
+ // In real life this functions would be produces by the sub-detectors
+ // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
+ //
+ // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
+ // 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
+ // 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", "GDC", "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", "file2b.root");
+
+ // TODO(3)
+ //
+ // 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.
+ // In real life the parameters will be retrieved automatically from the run logbook;
+ shuttle->AddInputRunParameter("totalEvents", "30000");
+ shuttle->AddInputRunParameter("NumberOfGDCs", "15");
+
+ // TODO(4)
+ // 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)
+ // 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())
+ ->Get("TPC/SHUTTLE/Data", 7);
+ if (!entry)
+ {
+ printf("The file is not there. Something went wrong.\n");
+ return;
+ }
+
+ AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject());
+ // If everything went fine, draw the result
+ if (output)
+ output->Draw();
}
TMap* CreateDCSAliasMap()
{
- // fill fake DCS object
+ // Creates a DCS structure
+ // The structure is the following:
+ // TMap (key --> value)
+ // <DCSAlias> --> <valueList>
+ // <DCSAlias> is a string
+ // <valueList> is a TObjArray of AliDCSValue
+ // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
- TObjArray* valueSet1 = new TObjArray;
+ // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
+ // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
+ TMap* aliasMap = new TMap;
+ aliasMap->SetOwner(1);
- valueSet1->Add();
+ TRandom random;
- TObjArray* valueSet2 = new TObjArray;
- valueSet2->Add();
+ for(int nAlias=0;nAlias<6;nAlias++)
+ {
+ TObjArray* valueSet = new TObjArray;
+ valueSet->SetOwner(1);
- TMap* aliasMap = new TMap;
- aliasMap->Add(new TObjString("DCSAlias1"), valueSet1);
- aliasMap->Add(new TObjString("DCSAlias2"), valueSet2);
+ TString aliasName="DCSAlias";
+ aliasName += nAlias;
+ //printf("\n\n alias: %s\n\n",aliasName.Data());
+
+ for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
+ {
+ AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
+ //printf("%s\n",dcsVal->ToString().Data());
+ valueSet->Add(dcsVal);
+ }
+ aliasMap->Add(new TObjString(aliasName), valueSet);
+ }
return aliasMap;
}
TMap* ReadDCSAliasMap()
{
- // open the file
- AliCDBEntry *entry = AliCDBManager::Instance()->Get("TPC/DCS/Data",21200);
+ // Open a file that contains DCS input data
+ // The CDB framework is used to open the file, this means the file is located
+ // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
+ // 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()->GetStorage(AliShuttleInterface::GetMainCDB())
+ ->Get("DET/DCS/Data", 0);
return dynamic_cast<TMap*> (entry->GetObject());
}
-TMap* CreateInputFilesMap()
+void WriteDCSAliasMap()
{
- // create a list of files which will be available from the AliTestShuttle
-
- inputFile1 = new TMap;
- inputFile1->Add(new TObjString("GDC"), new TObjString("file1.root"));
+ // This writes the output from CreateDCSAliasMap to a CDB file
- inputFile2 = new TMap;
- inputFile2->Add(new TObjString("LDC0"), new TObjString("file2a.root"));
- inputFile2->Add(new TObjString("LDC1"), new TObjString("file2b.root"));
- inputFile2->Add(new TObjString("LDC2"), new TObjString("file2c.root"));
+ TMap* dcsAliasMap = CreateDCSAliasMap();
- TMap* inputFiles = new TMap;
- inputFiles->Add(new TObjString("DAQ-TPC-PEDESTALS"), inputFile1);
- inputFiles->Add(new TObjString("DAQ-TPC-DRIFTVELOCITY"), inputFile2);
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Responsible person");
+ metaData.SetComment("Test object for TestPreprocessor.C");
- return inputFiles;
-}
-
-void TestShuttle(AliShuttleInterface* shuttle)
-{
- const char* file = shuttle->GetFile(AliShuttleInterface::kDAQ, "TPC", "PEDESTALS", "GDC");
- cout << "GetFile: " << file << endl;
- cout << "GetFileSources: " << endl;
- shuttle->GetFileSources(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY")->Print();
+ AliCDBId id("DET/DCS/Data", 0, 0);
- shuttle->Log("TPC", "Log test");
+ // look into AliTestShuttle's CDB main folder
- //shuttle->Store();
+ AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
+ ->Put(dcsAliasMap, id, &metaData);
}