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