]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/TestZDCPreprocessor.C
Macro to test the ZDC preprocessor under TestShuttle dir
[u/mrichter/AliRoot.git] / ZDC / TestZDCPreprocessor.C
CommitLineData
438a188c 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 TestZDCPreprocessor()
12{
13 // load library
14 gSystem->Load("libTestShuttle.so");
15
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
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
25 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
26 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
27
28 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
29 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
30
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 //WriteDCSAliasMap();
49
50 // now give the alias map to the shuttle
51 shuttle->SetDCSInput(dcsAliasMap);
52
53 // TODO(2)
54 //
55 // The shuttle can also process files that originate from DCS, DAQ and HLT.
56 // To test it, we provide some local files and locations where these would be found when
57 // the online machinery would be there.
58 // In real life this functions would be produces by the sub-detectors
59 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
60 //
61 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
62 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
63 // In this example we add a file originating from the GDC with the id PEDESTALS
64 // Three files originating from different LDCs but with the same id are also added
65 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
66 // the "online" naming convention ALICE-INT-2003-039.
67 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCPedestal.dat");
68 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCEMDCalib.dat");
69
70 // TODO(3)
71 //
72 // The shuttle can read run type stored in the DAQ logbook.
73 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
74 // using GetRunType function.
75 shuttle->SetInputRunType("PEDESTALS");
76
77 // TODO(4)
78 //
79 // The shuttle can read run parameters stored in the DAQ run logbook.
80 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
81 // using GetRunParameter function.
82 // In real life the parameters will be retrieved automatically from the run logbook;
83 shuttle->AddInputRunParameter("totalEvents", "1000");
84 shuttle->AddInputRunParameter("NumberOfGDCs", "1");
85
86 // TODO(5)
87 //
88 // The shuttle can query condition parameters valid from the current run from the OCDB
89 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
90 // using GetFromOCDB function.
91
92 TObjString obj("This is a condition parameter stored in OCDB");
93 AliCDBId id("ZDC/Calib/Data", 0, AliCDBRunRange::Infinity());
94 AliCDBMetaData md;
95 AliCDBEntry entry(&obj, id, &md);
96
97 shuttle->AddInputCDBEntry(&entry);
98
99 // TODO(6)
100 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
101 AliPreprocessor* test = new AliZDCPreprocessor("ZDC",shuttle);
102
103 // Test the preprocessor
104 shuttle->Process();
105
106 // TODO(7)
107 // In the preprocessor AliShuttleInterface::Store should be called to put the final
108 // data to the CDB. To check if all went fine have a look at the files produced in
109 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
110 //
111 // Check the file which should have been created
112 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())
113 ->Get("ZDC/DCS/Data", 7);
114 if (!chkEntry)
115 {
116 printf("The file is not there. Something went wrong.\n");
117 return;
118 }
119
120 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
121 // If everything went fine, draw the result
122 if (output)
123 output->Draw();
124}
125
126TMap* CreateDCSAliasMap()
127{
128 // Creates a DCS structure
129 // The structure is the following:
130 // TMap (key --> value)
131 // <DCSAlias> --> <valueList>
132 // <DCSAlias> is a string
133 // <valueList> is a TObjArray of AliDCSValue
134 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
135
136 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
137 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
138
139 TMap* aliasMap = new TMap;
140 aliasMap->SetOwner(1);
141
142 TRandom random;
143 TString aliasNames[26];
144
145 // ******************************** alignment values
146 aliasNames[0] = "ZDC_ZNA_POS.actual.position";
147 aliasNames[1] = "ZDC_ZPA_POS.actual.position";
148 aliasNames[2] = "ZDC_ZNC_POS.actual.position";
149 aliasNames[3] = "ZDC_ZPC_POS.actual.position";
150 //
151 for(int nAlias=0; nAlias<4; nAlias++)
152 {
153 TObjArray* valueSet = new TObjArray;
154 valueSet->SetOwner(1);
155
156 TString aliasName = aliasNames[nAlias];
157 printf("\n\n alias: %s\n\n",aliasName.Data());
158
159 Float_t simVal = (Float_t) (random.Rndm()*0.025+random.Rndm()*0.1);
160 for(int i=0;i<3;i++)
161 {
162 int timeStamp1[3] = {0,500,1000};
163 AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp1[i]);
164 printf("%s\n",dcsVal->ToString());
165 valueSet->Add(dcsVal);
166 }
167 aliasMap->Add(new TObjString(aliasName), valueSet);
168 }
169 // ******************************** HV values
170 /*TString ZNAAlias = "ZNA_HV.actual.vMon";
171 TString ZPAAlias = "ZPA_HV.actual.vMon";
172 TString ZNCAlias = "ZNC_HV.actual.vMon";
173 TString ZPCAlias = "ZPC_HV.actual.vMon";
174 TString idat[5];
175 for(int i=0;i<5;i++)
176 {
177 idat[i] = i;
178 aliasNames[i+3] = ZNAAlias.Insert(6,idat[i]);
179 aliasNames[i+7] = ZPAAlias.Insert(6,idat[i]);
180 aliasNames[i+11] = ZNCAlias.Insert(6,idat[i]);
181 aliasNames[i+15] = ZPCAlias.Insert(6,idat[i]);
182 }*/
183 aliasNames[4] = "ZDC_ZNA_HV0.actual.vMon";
184 aliasNames[5] = "ZDC_ZNA_HV1.actual.vMon";
185 aliasNames[6] = "ZDC_ZNA_HV2.actual.vMon";
186 aliasNames[7] = "ZDC_ZNA_HV3.actual.vMon";
187 aliasNames[8] = "ZDC_ZNA_HV4.actual.vMon";
188 //
189 aliasNames[9] = "ZDC_ZPA_HV0.actual.vMon";
190 aliasNames[10] = "ZDC_ZPA_HV1.actual.vMon";
191 aliasNames[11] = "ZDC_ZPA_HV2.actual.vMon";
192 aliasNames[12] = "ZDC_ZPA_HV3.actual.vMon";
193 aliasNames[13] = "ZDC_ZPA_HV4.actual.vMon";
194 //
195 aliasNames[14] = "ZDC_ZNC_HV0.actual.vMon";
196 aliasNames[15] = "ZDC_ZNC_HV1.actual.vMon";
197 aliasNames[16] = "ZDC_ZNC_HV2.actual.vMon";
198 aliasNames[17] = "ZDC_ZNC_HV3.actual.vMon";
199 aliasNames[18] = "ZDC_ZNC_HV4.actual.vMon";
200 //
201 aliasNames[19] = "ZDC_ZPC_HV0.actual.vMon";
202 aliasNames[20] = "ZDC_ZPC_HV1.actual.vMon";
203 aliasNames[21] = "ZDC_ZPC_HV2.actual.vMon";
204 aliasNames[22] = "ZDC_ZPC_HV3.actual.vMon";
205 aliasNames[23] = "ZDC_ZPC_HV4.actual.vMon";
206 //
207 aliasNames[24] = "ZDC_ZEM1_HV0.actual.vMon";
208 aliasNames[25] = "ZDC_ZEM2_HV1.actual.vMon";
209 //
210 for(int nAlias=4;nAlias<26;nAlias++)
211 {
212 TObjArray* valueSet = new TObjArray;
213 valueSet->SetOwner(1);
214
215 TString aliasName = aliasNames[nAlias];
216 printf("\n\n alias: %s\n\n",aliasName.Data());
217
218 for(int timeStamp=0;timeStamp<=1000;timeStamp+=500)
219 {
220 Float_t simVal = (Float_t) (random.Gaus()*600.+1800.);
221 AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp);
222 printf("%s\n",dcsVal->ToString());
223 valueSet->Add(dcsVal);
224 }
225 aliasMap->Add(new TObjString(aliasName), valueSet);
226 }
227
228 return aliasMap;
229}
230
231TMap* ReadDCSAliasMap()
232{
233 // Open a file that contains DCS input data
234 // The CDB framework is used to open the file, this means the file is located
235 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
236 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
237 // An explanation of the structure can be found in CreateDCSAliasMap()
238
239 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/DCS/Data", 0);
240 return dynamic_cast<TMap*> (entry->GetObject());
241}
242
243void WriteDCSAliasMap()
244{
245 // This writes the output from CreateDCSAliasMap to a CDB file
246
247 TMap* dcsAliasMap = CreateDCSAliasMap();
248
249 AliCDBMetaData metaData;
250 metaData.SetBeamPeriod(0);
251 metaData.SetResponsible("Responsible person");
252 metaData.SetComment("Test object for TestPreprocessor.C");
253
254 AliCDBId id("ZDC/DCS/Data", 0, 0);
255
256 // initialize location of CDB
257 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
258
259 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
260}