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