UInt_t ne=0;
while ((aValue = (AliDCSValue*) iterarray.Next())) {
+
val[ne] = aValue->GetSimpleValue().GetFloat();
time[ne] = (Double_t) (aValue->GetTimeStamp());
// fill histos (alias 0-2)
fGraphs.SetOwner(1);
for(int i=0;i<kNAliases;i++){
- fAliasNames[i] = "TpcHvSect0";
+ fAliasNames[i] = "DCSAlias";
fAliasNames[i] += i;
- fAliasNames[i] += ".FloatValue";
}
for(int i=0;i<kNHistos;i++){
- fHv[i] = new TH1F(fAliasNames[0].Data(),fAliasNames[0].Data(), 20, kHvMin, kHvMax);
+ fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax);
fHv[i]->GetXaxis()->SetTitle("Hv");
}
}
class AliTestDataDCS : public TObject {
public:
enum {kNAliases=6, kNHistos=3, kNGraphs=3, kNFunctions=2};
- enum {kHvMin=0, kHvMax=500};
+ enum {kHvMin=0, kHvMax=20};
AliTestDataDCS();
AliTestDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime);
ClassImp(AliTestPreprocessor)
+//______________________________________________________________________________________________
AliTestPreprocessor::AliTestPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
AliPreprocessor(detector, shuttle),
fData(0)
// constructor
}
+//______________________________________________________________________________________________
AliTestPreprocessor::~AliTestPreprocessor()
{
// destructor
}
+//______________________________________________________________________________________________
void AliTestPreprocessor::Initialize(Int_t run, UInt_t startTime,
UInt_t endTime)
{
fData = new AliTestDataDCS(fRun, fStartTime, fEndTime);
}
-Int_t AliTestPreprocessor::Process(TMap* dcsAliasMap)
+//______________________________________________________________________________________________
+UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap)
{
// Fills data into a AliTestDataDCS object
if (!dcsAliasMap)
- return -1;
+ return 0;
+ // The processing of the DCS input data is forwarded to AliTestDataDCS
fData->ProcessData(*dcsAliasMap);
const char* fileName = GetFile(kDAQ, "PEDESTALS", "GDC");
if (fileName)
AliInfo(Form("Got the file %s, now we can extract some values.", fileName));
- // open file, extract some values, write them to fData
-
+ //TODO here the file could be opened, some values extracted and written to e.g. fData
+
+ TList* list = GetFileSources(kDAQ, "DRIFTVELOCITY");
+ if (list)
+ {
+ AliInfo("The following sources produced files with the id DRIFTVELOCITY");
+ list->Print();
+ delete list;
+ }
+ //TODO here the files could be opened, some values extracted and written to e.g. fData
+
+ //Now we have to store the final CDB file
AliCDBMetaData metaData;
metaData.SetBeamPeriod(0);
metaData.SetResponsible("Alberto Colla");
metaData.SetComment("This preprocessor fills an AliTestDataDCS object.");
- Store(fData, &metaData);
+ UInt_t result = Store(fData, &metaData);
delete fData;
fData = 0;
- return 0;
+ return result;
}
protected:
virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
- virtual Int_t Process(TMap* dcsAliasMap);
+ virtual UInt_t Process(TMap* dcsAliasMap);
private:
AliTestDataDCS *fData; // CDB class that stores the data
#include "AliCDBManager.h"
#include "AliCDBMetaData.h"
#include "AliCDBId.h"
+#include "AliPreprocessor.h"
#include <TMap.h>
#include <TList.h>
ClassImp(AliTestShuttle)
-AliTestShuttle::AliTestShuttle(TMap* inputFiles) : fInputFiles(inputFiles)
+//______________________________________________________________________________________________
+AliTestShuttle::AliTestShuttle() :
+ fInputFiles(0),
+ fPreprocessors(0),
+ fDcsAliasMap(0)
{
// constructor
- // inputFiles contains the map of local files that can be retrieved by the preprocessor
- // check TestPreprocessor.C for an example of its structure
+
+ fInputFiles = new TMap;
+ fPreprocessors = new TObjArray;
}
+//______________________________________________________________________________________________
AliTestShuttle::~AliTestShuttle()
{
// destructor
+
+ delete fInputFiles;
+ fInputFiles = 0;
+
+ delete fPreprocessors;
+ fPreprocessors = 0;
+
+ delete fDcsAliasMap;
+ fDcsAliasMap = 0;
}
-Int_t AliTestShuttle::Store(const char* detector, TObject* object, AliCDBMetaData* metaData)
+//______________________________________________________________________________________________
+UInt_t AliTestShuttle::Store(const char* detector, TObject* object, AliCDBMetaData* metaData)
{
// Stores the CDB object
// This function should be called at the end of the preprocessor cycle
AliCDBId id(Form("%s/SHUTTLE/Data", detector), 0, 0);
- AliCDBManager::Instance()->Put(object, id, metaData);
-
- return -1;
+ return AliCDBManager::Instance()->Put(object, id, metaData);
}
+//______________________________________________________________________________________________
const char* AliTestShuttle::GetFile(Int_t system, const char* detector, const char* id, const char* source)
{
// This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
TObjString* fileName = dynamic_cast<TObjString*> (fileNamePair->Value());
if (!fileName)
{
- AliError(Form("Could not find files from source %s in %s with id %s", source, fkSystemNames[system], id));
+ AliError(Form("Could not find files from source %s in %s with id %s",
+ source, fkSystemNames[system], id));
return 0;
}
return fileName->GetString().Data();
}
+//______________________________________________________________________________________________
TList* AliTestShuttle::GetFileSources(Int_t system, const char* detector, const char* id)
{
// Returns a list of sources in a given system that saved a file with the given id
return list;
}
+//______________________________________________________________________________________________
void AliTestShuttle::Log(const char* detector, const char* message)
{
// test implementation of Log
AliInfo(Form("%s: %s", detector, message));
}
+//______________________________________________________________________________________________
+void AliTestShuttle::AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName)
+{
+ // This function adds a file to the list of input files
+
+ TString key;
+ key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
+ TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
+ TMap* sourceList = 0;
+ if (sourceListPair)
+ sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
+ if (!sourceList)
+ {
+ sourceList = new TMap;
+ fInputFiles->Add(new TObjString(key), sourceList);
+ }
+
+ sourceList->Add(new TObjString(source), new TObjString(fileName));
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::Process()
+{
+ // This function tests all preprocessors that are registered to it
+ // All preprocessors get the same dcs alias map and have access to the same list of files.
+
+ for (Int_t i=0; i<fPreprocessors->GetEntries(); ++i)
+ {
+ AliPreprocessor* preprocessor = dynamic_cast<AliPreprocessor*> (fPreprocessors->At(i));
+ if (preprocessor)
+ {
+ preprocessor->Initialize(0, 1, 0);
+ preprocessor->Process(fDcsAliasMap);
+ }
+ }
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor)
+{
+ // registers a preprocessor
+
+ fPreprocessors->Add(preprocessor);
+}
class AliTestShuttle : public AliShuttleInterface
{
public:
- AliTestShuttle(TMap* inputFiles);
+ AliTestShuttle();
virtual ~AliTestShuttle();
- virtual Int_t Store(const char* detector, TObject* object, AliCDBMetaData* metaData);
+ void AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName);
+ void SetDCSInput(TMap* dcsAliasMap) { fDcsAliasMap = dcsAliasMap; }
+
+ void Process();
+
+ // AliShuttleInterface functions
+ virtual UInt_t Store(const char* detector, TObject* object, AliCDBMetaData* metaData);
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 void Log(const char* detector, const char* message);
+ virtual void RegisterPreprocessor(AliPreprocessor* preprocessor);
+
protected:
TMap* fInputFiles; // files for GetFile, GetFileSources
+ TObjArray* fPreprocessors; // list of preprocessors that are to be tested
+ TMap* fDcsAliasMap; // DCS data for testing
private:
ClassDef(AliTestShuttle, 0);
+/* $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 decide where to read the data
- TMap* dcsAliasMap = 0;
- //dcsAliasMap = CreateDCSAliasMap();
- dcsAliasMap = ReadDCSAliasMap();
-
- // create TMap of available files
- TMap* inputFiles = CreateInputFilesMap();
+ AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
// create AliTestShuttle instance
- AliTestShuttle* shuttle = new AliTestShuttle(inputFiles);
- TestShuttle(shuttle);
-
- // create preprocessor
- AliPreprocessor* pp = new AliTestPreprocessor("TPC", shuttle);
-
- // call preprocessor
- pp->Initialize(0, 0, 1);
- pp->Process(dcsAliasMap);
+ AliTestShuttle* shuttle = new AliTestShuttle();
+
+ // 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
+ 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");
+
+ // TODO(3)
+ // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
+ AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle);
+
+ // Test the preprocessor
+ shuttle->Process();
+
+ // TODO(4)
+ // 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)
+ {
+ 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)
+ {
+ AliSimpleValue* simVal = new AliSimpleValue((Float_t) (random.Gaus()+5*nAlias));
+ AliDCSValue* dcsVal = new AliDCSValue(*simVal, 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()->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
+ // This writes the output from CreateDCSAliasMap to a CDB file
- inputFile1 = new TMap;
- inputFile1->Add(new TObjString("GDC"), new TObjString("file1.root"));
+ TMap* dcsAliasMap = CreateDCSAliasMap();
- 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"));
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Responsible person");
+ metaData.SetComment("Test object for TestPreprocessor.C");
- TMap* inputFiles = new TMap;
- inputFiles->Add(new TObjString("DAQ-TPC-PEDESTALS"), inputFile1);
- inputFiles->Add(new TObjString("DAQ-TPC-DRIFTVELOCITY"), inputFile2);
-
- return inputFiles;
-}
+ AliCDBId id("DET/DCS/Data", 0, 0);
-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();
-
- shuttle->Log("TPC", "Log test");
+ // initialize location of CDB
+ AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
- //shuttle->Store();
+ AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
}