]>
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 | |
eba76848 | 16 | // TODO if needed, change location of OCDB and Reference test folders |
17 | // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference | |
18 | // AliTestShuttle::SetOCDBStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
19 | // AliTestShuttle::SetReferenceStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
20 | ||
21 | printf("Test OCDB storage Uri: %s\n", AliTestShuttle::GetOCDBStorage().Data()); | |
22 | printf("Test Reference storage Uri: %s\n", AliTestShuttle::GetReferenceStorage().Data()); | |
5c6b40ae | 23 | |
24 | // create AliTestShuttle instance | |
17111222 | 25 | // The parameters are run, startTime, endTime |
26 | AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1); | |
36137ac1 | 27 | |
28 | // TODO(1) | |
29 | // | |
30 | // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data, | |
31 | // some fake data has to be created. | |
32 | // | |
33 | // The "fake" input data can be taken using either (a) or (b): | |
34 | // (a) data from a file: Use ReadDCSAliasMap() | |
35 | // the format of the file is explained in ReadDCSAliasMap() | |
36 | // To use it uncomment the following line: | |
37 | // | |
38 | //TMap* dcsAliasMap = ReadDCSAliasMap(); | |
39 | // | |
40 | // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation | |
41 | // To use it uncomment the following line: | |
42 | // | |
43 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
44 | ||
45 | // now give the alias map to the shuttle | |
46 | shuttle->SetDCSInput(dcsAliasMap); | |
47 | ||
48 | // TODO(2) | |
49 | // | |
50 | // The shuttle can also process files that originate from DCS, DAQ and HLT. | |
51 | // To test it, we provide some local files and locations where these would be found when | |
52 | // the online machinery would be there. | |
53 | // In real life this functions would be produces by the sub-detectors | |
54 | // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle. | |
55 | // | |
56 | // Files are added with the function AliTestShuttle::AddInputFile. The syntax is: | |
57 | // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>) | |
58 | // In this example we add a file originating from the GDC with the id PEDESTALS | |
59 | // Three files originating from different LDCs but with the same id are also added | |
60 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "PEDESTALS", "GDC", "file1.root"); | |
61 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC0", "file2a.root"); | |
62 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC1", "file2b.root"); | |
63 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC2", "file2b.root"); | |
64 | ||
65 | // TODO(3) | |
eba76848 | 66 | // |
67 | // The shuttle can read run parameters stored in the DAQ run logbook. | |
68 | // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor | |
69 | // using GetRunParameter function. | |
70 | // In real life the parameters will be retrieved automatically from the run logbook; | |
71 | shuttle->AddInputRunParameter("totalEvents", "30000"); | |
72 | shuttle->AddInputRunParameter("NumberOfGDCs", "15"); | |
73 | ||
74 | // TODO(4) | |
36137ac1 | 75 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle |
eba76848 | 76 | // AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle); |
77 | // AliPreprocessor* start = new AliSTARTPreprocessor("T00", shuttle); | |
78 | AliPreprocessor* test = new AliTestPreprocessor("DET", shuttle); | |
36137ac1 | 79 | |
80 | // Test the preprocessor | |
81 | shuttle->Process(); | |
82 | ||
eba76848 | 83 | // TODO(5) |
36137ac1 | 84 | // In the preprocessor AliShuttleInterface::Store should be called to put the final |
85 | // data to the CDB. To check if all went fine have a look at the files produced in | |
86 | // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data | |
87 | // | |
88 | // Check the file which should have been created | |
eba76848 | 89 | AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetOCDBStorage()) |
90 | ->Get("DET/SHUTTLE/Data", 7); | |
36137ac1 | 91 | if (!entry) |
92 | { | |
93 | printf("The file is not there. Something went wrong.\n"); | |
94 | return; | |
95 | } | |
96 | ||
97 | AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject()); | |
98 | // If everything went fine, draw the result | |
99 | if (output) | |
100 | output->Draw(); | |
5c6b40ae | 101 | } |
102 | ||
103 | TMap* CreateDCSAliasMap() | |
104 | { | |
36137ac1 | 105 | // Creates a DCS structure |
106 | // The structure is the following: | |
107 | // TMap (key --> value) | |
108 | // <DCSAlias> --> <valueList> | |
109 | // <DCSAlias> is a string | |
110 | // <valueList> is a TObjArray of AliDCSValue | |
111 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
5c6b40ae | 112 | |
36137ac1 | 113 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 |
114 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
5c6b40ae | 115 | |
36137ac1 | 116 | TMap* aliasMap = new TMap; |
117 | aliasMap->SetOwner(1); | |
5c6b40ae | 118 | |
36137ac1 | 119 | TRandom random; |
5c6b40ae | 120 | |
36137ac1 | 121 | for(int nAlias=0;nAlias<6;nAlias++) |
122 | { | |
123 | TObjArray* valueSet = new TObjArray; | |
124 | valueSet->SetOwner(1); | |
5c6b40ae | 125 | |
36137ac1 | 126 | TString aliasName="DCSAlias"; |
127 | aliasName += nAlias; | |
128 | //printf("\n\n alias: %s\n\n",aliasName.Data()); | |
129 | ||
130 | for (int timeStamp=0;timeStamp<1000;timeStamp+=10) | |
131 | { | |
45a493ce | 132 | AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp); |
36137ac1 | 133 | //printf("%s\n",dcsVal->ToString().Data()); |
134 | valueSet->Add(dcsVal); | |
135 | } | |
136 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
137 | } | |
5c6b40ae | 138 | |
139 | return aliasMap; | |
140 | } | |
141 | ||
142 | TMap* ReadDCSAliasMap() | |
143 | { | |
36137ac1 | 144 | // Open a file that contains DCS input data |
145 | // The CDB framework is used to open the file, this means the file is located | |
146 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
147 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
148 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
149 | ||
150 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("DET/DCS/Data", 0); | |
5c6b40ae | 151 | return dynamic_cast<TMap*> (entry->GetObject()); |
152 | } | |
153 | ||
36137ac1 | 154 | void WriteDCSAliasMap() |
5c6b40ae | 155 | { |
36137ac1 | 156 | // This writes the output from CreateDCSAliasMap to a CDB file |
5c6b40ae | 157 | |
36137ac1 | 158 | TMap* dcsAliasMap = CreateDCSAliasMap(); |
5c6b40ae | 159 | |
36137ac1 | 160 | AliCDBMetaData metaData; |
161 | metaData.SetBeamPeriod(0); | |
162 | metaData.SetResponsible("Responsible person"); | |
163 | metaData.SetComment("Test object for TestPreprocessor.C"); | |
5c6b40ae | 164 | |
36137ac1 | 165 | AliCDBId id("DET/DCS/Data", 0, 0); |
5c6b40ae | 166 | |
36137ac1 | 167 | // initialize location of CDB |
168 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
5c6b40ae | 169 | |
36137ac1 | 170 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); |
5c6b40ae | 171 | } |