3 // This class runs the test preprocessor
4 // It uses AliTestShuttle to simulate a full Shuttle process
6 // The input data is created in the functions
7 // CreateDCSAliasMap() creates input that would in the same way come from DCS
8 // ReadDCSAliasMap() reads from a file
9 // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
11 void TestPreprocessor()
14 gSystem->Load("libTestShuttle.so");
16 // initialize location of CDB
17 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
19 // create AliTestShuttle instance
20 // The parameters are run, startTime, endTime
21 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
25 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
26 // some fake data has to be created.
28 // The "fake" input data can be taken using either (a) or (b):
29 // (a) data from a file: Use ReadDCSAliasMap()
30 // the format of the file is explained in ReadDCSAliasMap()
31 // To use it uncomment the following line:
33 //TMap* dcsAliasMap = ReadDCSAliasMap();
35 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
36 // To use it uncomment the following line:
38 TMap* dcsAliasMap = CreateDCSAliasMap();
40 // now give the alias map to the shuttle
41 shuttle->SetDCSInput(dcsAliasMap);
45 // The shuttle can also process files that originate from DCS, DAQ and HLT.
46 // To test it, we provide some local files and locations where these would be found when
47 // the online machinery would be there.
48 // In real life this functions would be produces by the sub-detectors
49 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
51 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
52 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
53 // In this example we add a file originating from the GDC with the id PEDESTALS
54 // Three files originating from different LDCs but with the same id are also added
55 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "PEDESTALS", "GDC", "file1.root");
56 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC0", "file2a.root");
57 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC1", "file2b.root");
58 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC2", "file2b.root");
61 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
62 AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle);
64 // Test the preprocessor
68 // In the preprocessor AliShuttleInterface::Store should be called to put the final
69 // data to the CDB. To check if all went fine have a look at the files produced in
70 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
72 // Check the file which should have been created
73 AliCDBEntry* entry = AliCDBManager::Instance()->Get("DET/SHUTTLE/Data", 0);
76 printf("The file is not there. Something went wrong.\n");
80 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject());
81 // If everything went fine, draw the result
86 TMap* CreateDCSAliasMap()
88 // Creates a DCS structure
89 // The structure is the following:
90 // TMap (key --> value)
91 // <DCSAlias> --> <valueList>
92 // <DCSAlias> is a string
93 // <valueList> is a TObjArray of AliDCSValue
94 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
96 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
97 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
99 TMap* aliasMap = new TMap;
100 aliasMap->SetOwner(1);
104 for(int nAlias=0;nAlias<6;nAlias++)
106 TObjArray* valueSet = new TObjArray;
107 valueSet->SetOwner(1);
109 TString aliasName="DCSAlias";
111 //printf("\n\n alias: %s\n\n",aliasName.Data());
113 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
115 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
116 //printf("%s\n",dcsVal->ToString().Data());
117 valueSet->Add(dcsVal);
119 aliasMap->Add(new TObjString(aliasName), valueSet);
125 TMap* ReadDCSAliasMap()
127 // Open a file that contains DCS input data
128 // The CDB framework is used to open the file, this means the file is located
129 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
130 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
131 // An explanation of the structure can be found in CreateDCSAliasMap()
133 AliCDBEntry *entry = AliCDBManager::Instance()->Get("DET/DCS/Data", 0);
134 return dynamic_cast<TMap*> (entry->GetObject());
137 void WriteDCSAliasMap()
139 // This writes the output from CreateDCSAliasMap to a CDB file
141 TMap* dcsAliasMap = CreateDCSAliasMap();
143 AliCDBMetaData metaData;
144 metaData.SetBeamPeriod(0);
145 metaData.SetResponsible("Responsible person");
146 metaData.SetComment("Test object for TestPreprocessor.C");
148 AliCDBId id("DET/DCS/Data", 0, 0);
150 // initialize location of CDB
151 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
153 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);