]>
Commit | Line | Data |
---|---|---|
36137ac1 | 1 | /* $Id$ */ |
2 | ||
5c6b40ae | 3 | // This class runs the test preprocessor |
4 | // It uses AliTestShuttle to simulate a full Shuttle process | |
5 | ||
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 | |
10 | ||
11 | void TestPreprocessor() | |
12 | { | |
36137ac1 | 13 | // load library |
14 | gSystem->Load("libTestShuttle.so"); | |
5c6b40ae | 15 | |
16 | // initialize location of CDB | |
36137ac1 | 17 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
5c6b40ae | 18 | |
19 | // create AliTestShuttle instance | |
17111222 | 20 | // The parameters are run, startTime, endTime |
21 | AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1); | |
36137ac1 | 22 | |
23 | // TODO(1) | |
24 | // | |
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. | |
27 | // | |
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: | |
32 | // | |
33 | //TMap* dcsAliasMap = ReadDCSAliasMap(); | |
34 | // | |
35 | // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation | |
36 | // To use it uncomment the following line: | |
37 | // | |
38 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
39 | ||
40 | // now give the alias map to the shuttle | |
41 | shuttle->SetDCSInput(dcsAliasMap); | |
42 | ||
43 | // TODO(2) | |
44 | // | |
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. | |
50 | // | |
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"); | |
59 | ||
60 | // TODO(3) | |
61 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle | |
62 | AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle); | |
63 | ||
64 | // Test the preprocessor | |
65 | shuttle->Process(); | |
66 | ||
67 | // TODO(4) | |
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 | |
71 | // | |
72 | // Check the file which should have been created | |
84090f85 | 73 | AliCDBEntry* entry = AliCDBManager::Instance()->Get("DET/SHUTTLE/Data", 7); |
36137ac1 | 74 | if (!entry) |
75 | { | |
76 | printf("The file is not there. Something went wrong.\n"); | |
77 | return; | |
78 | } | |
79 | ||
80 | AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject()); | |
81 | // If everything went fine, draw the result | |
82 | if (output) | |
83 | output->Draw(); | |
5c6b40ae | 84 | } |
85 | ||
86 | TMap* CreateDCSAliasMap() | |
87 | { | |
36137ac1 | 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 | |
5c6b40ae | 95 | |
36137ac1 | 96 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 |
97 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
5c6b40ae | 98 | |
36137ac1 | 99 | TMap* aliasMap = new TMap; |
100 | aliasMap->SetOwner(1); | |
5c6b40ae | 101 | |
36137ac1 | 102 | TRandom random; |
5c6b40ae | 103 | |
36137ac1 | 104 | for(int nAlias=0;nAlias<6;nAlias++) |
105 | { | |
106 | TObjArray* valueSet = new TObjArray; | |
107 | valueSet->SetOwner(1); | |
5c6b40ae | 108 | |
36137ac1 | 109 | TString aliasName="DCSAlias"; |
110 | aliasName += nAlias; | |
111 | //printf("\n\n alias: %s\n\n",aliasName.Data()); | |
112 | ||
113 | for (int timeStamp=0;timeStamp<1000;timeStamp+=10) | |
114 | { | |
45a493ce | 115 | AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp); |
36137ac1 | 116 | //printf("%s\n",dcsVal->ToString().Data()); |
117 | valueSet->Add(dcsVal); | |
118 | } | |
119 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
120 | } | |
5c6b40ae | 121 | |
122 | return aliasMap; | |
123 | } | |
124 | ||
125 | TMap* ReadDCSAliasMap() | |
126 | { | |
36137ac1 | 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() | |
132 | ||
133 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("DET/DCS/Data", 0); | |
5c6b40ae | 134 | return dynamic_cast<TMap*> (entry->GetObject()); |
135 | } | |
136 | ||
36137ac1 | 137 | void WriteDCSAliasMap() |
5c6b40ae | 138 | { |
36137ac1 | 139 | // This writes the output from CreateDCSAliasMap to a CDB file |
5c6b40ae | 140 | |
36137ac1 | 141 | TMap* dcsAliasMap = CreateDCSAliasMap(); |
5c6b40ae | 142 | |
36137ac1 | 143 | AliCDBMetaData metaData; |
144 | metaData.SetBeamPeriod(0); | |
145 | metaData.SetResponsible("Responsible person"); | |
146 | metaData.SetComment("Test object for TestPreprocessor.C"); | |
5c6b40ae | 147 | |
36137ac1 | 148 | AliCDBId id("DET/DCS/Data", 0, 0); |
5c6b40ae | 149 | |
36137ac1 | 150 | // initialize location of CDB |
151 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
5c6b40ae | 152 | |
36137ac1 | 153 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); |
5c6b40ae | 154 | } |