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 AliTestShuttle* shuttle = new AliTestShuttle();
24 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
25 // some fake data has to be created.
27 // The "fake" input data can be taken using either (a) or (b):
28 // (a) data from a file: Use ReadDCSAliasMap()
29 // the format of the file is explained in ReadDCSAliasMap()
30 // To use it uncomment the following line:
32 //TMap* dcsAliasMap = ReadDCSAliasMap();
34 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
35 // To use it uncomment the following line:
37 TMap* dcsAliasMap = CreateDCSAliasMap();
39 // now give the alias map to the shuttle
40 shuttle->SetDCSInput(dcsAliasMap);
44 // The shuttle can also process files that originate from DCS, DAQ and HLT.
45 // To test it, we provide some local files and locations where these would be found when
46 // the online machinery would be there.
47 // In real life this functions would be produces by the sub-detectors
48 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
50 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
51 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
52 // In this example we add a file originating from the GDC with the id PEDESTALS
53 // Three files originating from different LDCs but with the same id are also added
54 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "PEDESTALS", "GDC", "file1.root");
55 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC0", "file2a.root");
56 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC1", "file2b.root");
57 shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC2", "file2b.root");
60 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
61 AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle);
63 // Test the preprocessor
67 // In the preprocessor AliShuttleInterface::Store should be called to put the final
68 // data to the CDB. To check if all went fine have a look at the files produced in
69 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
71 // Check the file which should have been created
72 AliCDBEntry* entry = AliCDBManager::Instance()->Get("DET/SHUTTLE/Data", 0);
75 printf("The file is not there. Something went wrong.\n");
79 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject());
80 // If everything went fine, draw the result
85 TMap* CreateDCSAliasMap()
87 // Creates a DCS structure
88 // The structure is the following:
89 // TMap (key --> value)
90 // <DCSAlias> --> <valueList>
91 // <DCSAlias> is a string
92 // <valueList> is a TObjArray of AliDCSValue
93 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
95 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
96 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
98 TMap* aliasMap = new TMap;
99 aliasMap->SetOwner(1);
103 for(int nAlias=0;nAlias<6;nAlias++)
105 TObjArray* valueSet = new TObjArray;
106 valueSet->SetOwner(1);
108 TString aliasName="DCSAlias";
110 //printf("\n\n alias: %s\n\n",aliasName.Data());
112 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
114 AliSimpleValue* simVal = new AliSimpleValue((Float_t) (random.Gaus()+5*nAlias));
115 AliDCSValue* dcsVal = new AliDCSValue(*simVal, 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);