]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - SHUTTLE/TestShuttle/TestPreprocessor.C
Updated names of the environment variables (no dollar sign). Gaussian distribution...
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / TestPreprocessor.C
... / ...
CommitLineData
1/* $Id$ */
2
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
11void TestPreprocessor()
12{
13 // load library
14 gSystem->Load("libTestShuttle.so");
15
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());
23
24 // create AliTestShuttle instance
25 // The parameters are run, startTime, endTime
26 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
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 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
61 // the "online" naming convention ALICE-INT-2003-039.
62 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "PEDESTALS", "GDC", "file1.root");
63 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root");
64 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root");
65 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2b.root");
66
67 // TODO(3)
68 //
69 // The shuttle can read run parameters stored in the DAQ run logbook.
70 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
71 // using GetRunParameter function.
72 // In real life the parameters will be retrieved automatically from the run logbook;
73 shuttle->AddInputRunParameter("totalEvents", "30000");
74 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
75
76 // TODO(4)
77 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
78 AliPreprocessor* test = new AliTestPreprocessor(shuttle);
79
80 // Test the preprocessor
81 shuttle->Process();
82
83 // TODO(5)
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
89 AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetOCDBStorage())
90 ->Get("TPC/SHUTTLE/Data", 7);
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();
101}
102
103TMap* CreateDCSAliasMap()
104{
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
112
113 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
114 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
115
116 TMap* aliasMap = new TMap;
117 aliasMap->SetOwner(1);
118
119 TRandom random;
120
121 for(int nAlias=0;nAlias<6;nAlias++)
122 {
123 TObjArray* valueSet = new TObjArray;
124 valueSet->SetOwner(1);
125
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 {
132 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
133 //printf("%s\n",dcsVal->ToString().Data());
134 valueSet->Add(dcsVal);
135 }
136 aliasMap->Add(new TObjString(aliasName), valueSet);
137 }
138
139 return aliasMap;
140}
141
142TMap* ReadDCSAliasMap()
143{
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);
151 return dynamic_cast<TMap*> (entry->GetObject());
152}
153
154void WriteDCSAliasMap()
155{
156 // This writes the output from CreateDCSAliasMap to a CDB file
157
158 TMap* dcsAliasMap = CreateDCSAliasMap();
159
160 AliCDBMetaData metaData;
161 metaData.SetBeamPeriod(0);
162 metaData.SetResponsible("Responsible person");
163 metaData.SetComment("Test object for TestPreprocessor.C");
164
165 AliCDBId id("DET/DCS/Data", 0, 0);
166
167 // initialize location of CDB
168 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
169
170 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
171}