]>
Commit | Line | Data |
---|---|---|
ccc28861 | 1 | /* |
2 | $Id$ | |
3 | */ | |
4 | ||
5 | // This class runs the test TOF preprocessor | |
6 | // It uses AliTestShuttle to simulate a full Shuttle process | |
7 | ||
8 | // The input data is created in the functions | |
9 | // CreateDCSAliasMap() creates input that would in the same way come from DCS | |
10 | // ReadDCSAliasMap() reads from a file | |
11 | // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle | |
12 | ||
13 | void TOFPreprocessor() | |
14 | { | |
15 | gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so"); | |
16 | ||
17 | // initialize location of CDB | |
58f7f59a | 18 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
19 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
20 | ||
ccc28861 | 21 | |
22 | // create AliTestShuttle instance | |
23 | AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000); | |
24 | ||
25 | // Generation of "fake" input DCS data | |
26 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
27 | ||
28 | // now give the alias map to the shuttle | |
29 | shuttle->SetDCSInput(dcsAliasMap); | |
30 | ||
31 | // processing files. for the time being, the files are local. | |
5abdf772 | 32 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root"); |
33 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root"); | |
ccc28861 | 34 | |
35 | // instantiation of the preprocessor | |
124a2863 | 36 | AliPreprocessor* pp = new AliTOFPreprocessor(shuttle); |
ccc28861 | 37 | |
38 | // preprocessing | |
39 | shuttle->Process(); | |
40 | ||
41 | // checking the file which should have been created | |
42 | AliCDBEntry* entry = AliCDBManager::Instance()->Get("TOF/Calib/OnlineDelay", 0); | |
43 | if (!entry) | |
44 | { | |
45 | printf("The file is not there. Something went wrong.\n"); | |
46 | return; | |
47 | } | |
48 | ||
49 | AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (entry->GetObject()); | |
50 | // If everything went fine, draw the result | |
51 | if (output) | |
52 | output->Draw(); | |
53 | ||
54 | } | |
55 | ||
56 | TMap* CreateDCSAliasMap() | |
57 | { | |
58 | // Creates a DCS structure | |
59 | // The structure is the following: | |
124a2863 | 60 | // TMap (key --> value) |
61 | // <DCSAlias> --> <valueList> | |
62 | // <DCSAlias> is a string | |
63 | // <valueList> is a TObjArray of AliDCSValue | |
ccc28861 | 64 | |
ccc28861 | 65 | |
66 | TMap* aliasMap = new TMap; | |
67 | aliasMap->SetOwner(1); | |
68 | ||
69 | TRandom random; | |
70 | TDatime *datime = new TDatime(); | |
71 | Int_t time = datime->GetTime(); | |
72 | Int_t date = datime->GetDate(); | |
73 | Int_t pid = gSystem->GetPid(); | |
74 | delete datime; | |
75 | Int_t iseed = TMath::Abs(10000 * pid + time - date); | |
76 | ||
124a2863 | 77 | Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5, |
78 | tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48, | |
79 | tentLVi33=100, tentLVi50=3.0, tentLVi48=10, | |
80 | tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45, | |
81 | tentTemp=25, tentPress=900; | |
82 | Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0, | |
83 | sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1, | |
84 | sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2, | |
85 | sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4, | |
86 | sigmaTemp=1, sigmaPress=10; | |
ccc28861 | 87 | |
88 | Float_t tent=0, sigma=0, thr=0; | |
124a2863 | 89 | Int_t NAliases=10514, NHV=90, NLV=576, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840, NT=1, NP=1; |
ccc28861 | 90 | |
91 | for(int nAlias=0;nAlias<NAliases;nAlias++) { | |
92 | ||
93 | TObjArray* valueSet = new TObjArray; | |
94 | valueSet->SetOwner(1); | |
95 | ||
124a2863 | 96 | TString sindex; |
ccc28861 | 97 | TString aliasName; |
98 | if (nAlias<NHV){ | |
124a2863 | 99 | aliasName = "tof_hv_vp_"; |
100 | sindex.Form("%02i",nAlias); | |
101 | aliasName += sindex; | |
102 | //aliasName += nAlias; | |
ccc28861 | 103 | tent=tentHVv; |
104 | sigma=sigmaHVv; | |
105 | // thr=thrHVv; | |
106 | } | |
107 | else if (nAlias<NHV*2){ | |
124a2863 | 108 | // aliasName = "HVvneg"; |
109 | //aliasName += nAlias-NHV; | |
110 | aliasName = "tof_hv_vn_"; | |
111 | sindex.Form("%02i",nAlias-NHV); | |
112 | aliasName += sindex; | |
ccc28861 | 113 | tent=-tentHVv; |
114 | sigma=-sigmaHVv; | |
115 | //thr=-thrHVv; | |
116 | } | |
117 | else if (nAlias<NHV*3){ | |
124a2863 | 118 | // aliasName = "HVcpos"; |
119 | //aliasName += nAlias-2*NHV; | |
120 | aliasName = "tof_hv_ip_"; | |
121 | sindex.Form("%02i",nAlias-2*NHV); | |
122 | aliasName += sindex; | |
123 | tent=tentHVi; | |
124 | sigma=sigmaHVi; | |
ccc28861 | 125 | //thr=thrHVc; |
126 | } | |
127 | else if (nAlias<NHV*4){ | |
124a2863 | 128 | // aliasName = "HVcneg"; |
129 | //aliasName += nAlias-3*NHV; | |
130 | aliasName = "tof_hv_in_"; | |
131 | sindex.Form("%02i",nAlias-3*NHV); | |
132 | aliasName += sindex; | |
133 | tent=-tentHVi; | |
134 | sigma=-sigmaHVi; | |
ccc28861 | 135 | //thr=-thrHVc; |
136 | } | |
137 | else if (nAlias<NHV*4+NLV){ | |
124a2863 | 138 | // aliasName = "LVv"; |
139 | //aliasName += nAlias-4*NHV; | |
140 | aliasName = "tof_lv_vfea_"; | |
141 | sindex.Form("%03i",nAlias-4*NHV); | |
142 | aliasName += sindex; | |
ccc28861 | 143 | tent=tentLVv; |
144 | sigma=sigmaLVv; | |
145 | //thr=thrLVv; | |
146 | } | |
147 | else if (nAlias<NHV*4+2*NLV){ | |
124a2863 | 148 | // aliasName = "LVc"; |
149 | //aliasName += nAlias-(4*NHV+NLV); | |
150 | aliasName = "tof_lv_ifea_"; | |
151 | sindex.Form("%03i",nAlias-(4*NHV+NLV)); | |
152 | aliasName += sindex; | |
153 | tent=tentLVi; | |
154 | sigma=sigmaLVi; | |
ccc28861 | 155 | //thr=thrLVc; |
156 | } | |
124a2863 | 157 | else if (nAlias<NHV*4+2*NLV+NLV33){ |
158 | // aliasName = "LVc"; | |
159 | //aliasName += nAlias-(4*NHV+NLV); | |
160 | aliasName = "tof_lv_v33_"; | |
161 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV)); | |
162 | aliasName += sindex; | |
163 | tent=tentLVv33; | |
164 | sigma=sigmaLVv33; | |
165 | //thr=thrLVc; | |
166 | } | |
167 | else if (nAlias<NHV*4+2*NLV+2*NLV33){ | |
168 | // aliasName = "LVc"; | |
169 | //aliasName += nAlias-(4*NHV+NLV); | |
170 | aliasName = "tof_lv_i33_"; | |
171 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33)); | |
172 | aliasName += sindex; | |
173 | tent=tentLVi33; | |
174 | sigma=sigmaLVi33; | |
175 | //thr=thrLVc; | |
176 | } | |
177 | else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){ | |
178 | // aliasName = "LVc"; | |
179 | //aliasName += nAlias-(4*NHV+NLV); | |
180 | aliasName = "tof_lv_v50_"; | |
181 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33)); | |
182 | aliasName += sindex; | |
183 | tent=tentLVv50; | |
184 | sigma=sigmaLVv50; | |
185 | //thr=thrLVc; | |
186 | } | |
187 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){ | |
188 | // aliasName = "LVc"; | |
189 | //aliasName += nAlias-(4*NHV+NLV); | |
190 | aliasName = "tof_lv_i50_"; | |
191 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50)); | |
192 | aliasName += sindex; | |
193 | tent=tentLVi50; | |
194 | sigma=sigmaLVi50; | |
195 | //thr=thrLVc; | |
196 | } | |
197 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){ | |
198 | // aliasName = "LVc"; | |
199 | //aliasName += nAlias-(4*NHV+NLV); | |
200 | aliasName = "tof_lv_v48_"; | |
201 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50)); | |
202 | aliasName += sindex; | |
203 | tent=tentLVv48; | |
204 | sigma=sigmaLVv48; | |
205 | //thr=thrLVc; | |
206 | } | |
207 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){ | |
208 | // aliasName = "LVc"; | |
209 | //aliasName += nAlias-(4*NHV+NLV); | |
210 | aliasName = "tof_lv_i48_"; | |
211 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48)); | |
212 | aliasName += sindex; | |
213 | tent=tentLVi48; | |
214 | sigma=sigmaLVi48; | |
215 | //thr=thrLVc; | |
216 | } | |
217 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){ | |
218 | // aliasName = "FEEthr"; | |
219 | //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48)); | |
220 | aliasName = "tof_fee_th_"; | |
221 | sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48)); | |
222 | aliasName += sindex; | |
ccc28861 | 223 | tent=tentFEEthr; |
224 | sigma=sigmaFEEthr; | |
225 | //thr=thrFEEthr; | |
226 | } | |
124a2863 | 227 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){ |
228 | //cout << " nalias fee temp = " << nAlias << endl; | |
229 | // aliasName = "FEEt"; | |
230 | //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr); | |
231 | aliasName = "tof_fee_tfeac_"; | |
232 | sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr)); | |
233 | aliasName += sindex; | |
234 | //cout << " nalias fee temp name = " << aliasName << endl; | |
235 | tent=tentFEEtfeac; | |
236 | sigma=sigmaFEEtfeac; | |
237 | //thr=thrFEEthr; | |
238 | } | |
239 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){ | |
ccc28861 | 240 | //cout << " nalias fee temp = " << nAlias << endl; |
124a2863 | 241 | // aliasName = "FEEt"; |
242 | //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr); | |
243 | aliasName = "tof_fee_ttrm_"; | |
244 | sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac)); | |
245 | aliasName += sindex; | |
ccc28861 | 246 | //cout << " nalias fee temp name = " << aliasName << endl; |
124a2863 | 247 | tent=tentFEEttrm; |
248 | sigma=sigmaFEEttrm; | |
ccc28861 | 249 | //thr=thrFEEthr; |
250 | } | |
124a2863 | 251 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm+1){ |
252 | cout << " putting temperature" << endl; | |
253 | aliasName = "temperature"; | |
ccc28861 | 254 | tent=tentTemp; |
255 | sigma=sigmaTemp; | |
256 | //thr=thrTemp; | |
257 | } | |
124a2863 | 258 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm+2){ |
259 | cout << " putting pressure" << endl; | |
260 | aliasName = "pressure"; | |
ccc28861 | 261 | tent=tentPress; |
262 | sigma=sigmaPress; | |
263 | //thr=thrPress; | |
264 | } | |
265 | ||
266 | ||
267 | // gauss generation of values | |
268 | for (int timeStamp=0;timeStamp<1000;timeStamp+=10){ | |
269 | Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma)); | |
270 | if (TMath::Abs(gaussvalue-tent)>sigma){ | |
271 | AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp); | |
272 | valueSet->Add(dcsVal); | |
273 | } | |
274 | } | |
275 | ||
276 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
277 | } | |
278 | ||
279 | return aliasMap; | |
280 | } | |
281 | ||
282 | TMap* ReadDCSAliasMap() | |
283 | { | |
284 | // Open a file that contains DCS input data | |
285 | // The CDB framework is used to open the file, this means the file is located | |
286 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
287 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
288 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
289 | ||
290 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0); | |
291 | return dynamic_cast<TMap*> (entry->GetObject()); | |
292 | } | |
293 | ||
294 | void WriteDCSAliasMap() | |
295 | { | |
296 | // This writes the output from CreateDCSAliasMap to a CDB file | |
297 | ||
298 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
299 | ||
300 | AliCDBMetaData metaData; | |
301 | metaData.SetBeamPeriod(0); | |
302 | metaData.SetResponsible("Chiara"); | |
303 | metaData.SetComment("Test object for TOFPreprocessor.C"); | |
304 | ||
305 | AliCDBId id("TOF/DCS/Data", 0, 0); | |
306 | ||
307 | // initialize location of CDB | |
308 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
309 | ||
310 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); | |
311 | } |