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