]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | #include "AliTPCPreprocessor.h" | |
18 | #include "AliShuttleInterface.h" | |
19 | ||
20 | #include "AliCDBMetaData.h" | |
21 | #include "AliDCSValue.h" | |
22 | #include "AliLog.h" | |
23 | #include "AliTPCSensorTempArray.h" | |
24 | #include "AliTPCROC.h" | |
25 | #include "AliTPCCalROC.h" | |
26 | #include "AliTPCCalPad.h" | |
27 | #include "AliTPCCalibPedestal.h" | |
28 | #include "AliTPCCalibPulser.h" | |
29 | #include "AliTPCCalibCE.h" | |
30 | #include "AliTPCdataQA.h" | |
31 | #include "TFile.h" | |
32 | #include "TTree.h" | |
33 | #include "TGraph.h" | |
34 | #include "TEnv.h" | |
35 | #include "TParameter.h" | |
36 | ||
37 | #include <TTimeStamp.h> | |
38 | ||
39 | const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees | |
40 | const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees | |
41 | const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier | |
42 | const TString kPulserRunType = "PULSER"; // pulser run identifier | |
43 | const TString kPhysicsRunType = "PHYSICS"; // physics run identifier | |
44 | const TString kCosmicRunType = "COSMIC"; // cosmic run identifier | |
45 | const TString kLaserRunType = "LASER"; // laser run identifier | |
46 | const TString kDaqRunType = "DAQ"; // DAQ run identifier | |
47 | const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries | |
48 | //const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required | |
49 | const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run | |
50 | ||
51 | // | |
52 | // This class is the SHUTTLE preprocessor for the TPC detector. | |
53 | // | |
54 | ||
55 | ClassImp(AliTPCPreprocessor) | |
56 | ||
57 | //______________________________________________________________________________________________ | |
58 | AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) : | |
59 | AliPreprocessor("TPC",shuttle), | |
60 | fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0) | |
61 | { | |
62 | // constructor | |
63 | fROC = AliTPCROC::Instance(); | |
64 | ||
65 | // define run types to be processed | |
66 | ||
67 | AddRunType(kPedestalRunType); | |
68 | AddRunType(kPulserRunType); | |
69 | AddRunType(kPhysicsRunType); | |
70 | AddRunType(kCosmicRunType); | |
71 | AddRunType(kLaserRunType); | |
72 | AddRunType(kDaqRunType); | |
73 | ||
74 | } | |
75 | //______________________________________________________________________________________________ | |
76 | AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) : | |
77 | AliPreprocessor("TPC",0), | |
78 | fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0) | |
79 | { | |
80 | ||
81 | Fatal("AliTPCPreprocessor", "copy constructor not implemented"); | |
82 | // | |
83 | // // fTemp = new AliTPCSensorTempArray(*(org.fTemp)); | |
84 | } | |
85 | ||
86 | //______________________________________________________________________________________________ | |
87 | AliTPCPreprocessor::~AliTPCPreprocessor() | |
88 | { | |
89 | // destructor | |
90 | ||
91 | delete fTemp; | |
92 | delete fHighVoltage; | |
93 | } | |
94 | //______________________________________________________________________________________________ | |
95 | AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& ) | |
96 | { | |
97 | Fatal("operator =", "assignment operator not implemented"); | |
98 | return *this; | |
99 | } | |
100 | ||
101 | ||
102 | //______________________________________________________________________________________________ | |
103 | void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
104 | UInt_t endTime) | |
105 | { | |
106 | // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start | |
107 | ||
108 | UInt_t startTimeLocal = startTime-3600; | |
109 | UInt_t endTimeLocal = endTime+1800; | |
110 | ||
111 | AliPreprocessor::Initialize(run, startTimeLocal, endTimeLocal); | |
112 | ||
113 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
114 | TTimeStamp((time_t)startTime,0).AsString(), | |
115 | TTimeStamp((time_t)endTime,0).AsString())); | |
116 | ||
117 | // Preprocessor configuration | |
118 | ||
119 | AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor"); | |
120 | if (entry) fConfEnv = (TEnv*) entry->GetObject(); | |
121 | if ( fConfEnv==0 ) { | |
122 | Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n"); | |
123 | fConfigOK = kFALSE; | |
124 | return; | |
125 | } | |
126 | ||
127 | // Temperature sensors | |
128 | ||
129 | TTree *confTree = 0; | |
130 | ||
131 | TString tempConf = fConfEnv->GetValue("Temperature","ON"); | |
132 | tempConf.ToUpper(); | |
133 | if (tempConf != "OFF" ) { | |
134 | entry = GetFromOCDB("Config", "Temperature"); | |
135 | if (entry) confTree = (TTree*) entry->GetObject(); | |
136 | if ( confTree==0 ) { | |
137 | Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n"); | |
138 | fConfigOK = kFALSE; | |
139 | return; | |
140 | } | |
141 | fTemp = new AliTPCSensorTempArray(startTimeLocal, endTimeLocal, confTree, kAmandaTemp); | |
142 | fTemp->SetValCut(kValCutTemp); | |
143 | fTemp->SetDiffCut(kDiffCutTemp); | |
144 | } | |
145 | ||
146 | // High voltage measurements | |
147 | ||
148 | TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); | |
149 | hvConf.ToUpper(); | |
150 | if (hvConf != "OFF" ) { | |
151 | confTree=0; | |
152 | entry=0; | |
153 | entry = GetFromOCDB("Config", "HighVoltage"); | |
154 | if (entry) confTree = (TTree*) entry->GetObject(); | |
155 | if ( confTree==0 ) { | |
156 | Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n"); | |
157 | fConfigOK = kFALSE; | |
158 | return; | |
159 | } | |
160 | fHighVoltage = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree); | |
161 | } | |
162 | ||
163 | // High voltage status values | |
164 | ||
165 | TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON"); | |
166 | hvStatConf.ToUpper(); | |
167 | if (hvStatConf != "OFF" ) { | |
168 | confTree=0; | |
169 | entry=0; | |
170 | entry = GetFromOCDB("Config", "HighVoltageStat"); | |
171 | if (entry) confTree = (TTree*) entry->GetObject(); | |
172 | if ( confTree==0 ) { | |
173 | Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n"); | |
174 | fConfigOK = kFALSE; | |
175 | return; | |
176 | } | |
177 | fHighVoltageStat = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree); | |
178 | } | |
179 | ||
180 | // Goofie values | |
181 | ||
182 | TString goofieConf = fConfEnv->GetValue("Goofie","ON"); | |
183 | goofieConf.ToUpper(); | |
184 | if (goofieConf != "OFF" ) { | |
185 | confTree=0; | |
186 | entry=0; | |
187 | entry = GetFromOCDB("Config", "Goofie"); | |
188 | if (entry) confTree = (TTree*) entry->GetObject(); | |
189 | if ( confTree==0 ) { | |
190 | Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n"); | |
191 | fConfigOK = kFALSE; | |
192 | return; | |
193 | } | |
194 | fGoofie = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree); | |
195 | } | |
196 | ||
197 | ||
198 | } | |
199 | ||
200 | //______________________________________________________________________________________________ | |
201 | UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap) | |
202 | { | |
203 | // Fills data into TPC calibrations objects | |
204 | ||
205 | // Amanda servers provide information directly through dcsAliasMap | |
206 | ||
207 | ||
208 | if (!fConfigOK) return 9; | |
209 | UInt_t result = 0; | |
210 | TObjArray *resultArray = new TObjArray(); | |
211 | TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON"); | |
212 | errorHandling.ToUpper(); | |
213 | TObject * status; | |
214 | ||
215 | UInt_t dcsResult=0; | |
216 | if (errorHandling == "OFF" ) { | |
217 | if (!dcsAliasMap) dcsResult=1; | |
218 | if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1; | |
219 | status = new TParameter<int>("dcsResult",dcsResult); | |
220 | resultArray->Add(status); | |
221 | } else { | |
222 | if (!dcsAliasMap) return 9; | |
223 | if (dcsAliasMap->GetEntries() == 0 ) return 9; | |
224 | } | |
225 | ||
226 | ||
227 | ||
228 | ||
229 | TString runType = GetRunType(); | |
230 | ||
231 | // Temperature sensors are processed by AliTPCCalTemp | |
232 | ||
233 | TString tempConf = fConfEnv->GetValue("Temperature","ON"); | |
234 | tempConf.ToUpper(); | |
235 | if (tempConf != "OFF" ) { | |
236 | UInt_t tempResult = MapTemperature(dcsAliasMap); | |
237 | result=tempResult; | |
238 | status = new TParameter<int>("tempResult",tempResult); | |
239 | resultArray->Add(status); | |
240 | } | |
241 | ||
242 | // High Voltage recordings | |
243 | ||
244 | ||
245 | TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); | |
246 | hvConf.ToUpper(); | |
247 | if (hvConf != "OFF" ) { | |
248 | UInt_t hvResult = MapHighVoltage(dcsAliasMap); | |
249 | result+=hvResult; | |
250 | status = new TParameter<int>("hvResult",hvResult); | |
251 | resultArray->Add(status); | |
252 | } | |
253 | ||
254 | // Goofie values | |
255 | ||
256 | ||
257 | TString goofieConf = fConfEnv->GetValue("Goofie","ON"); | |
258 | goofieConf.ToUpper(); | |
259 | if (goofieConf != "OFF" ) { | |
260 | UInt_t goofieResult = MapGoofie(dcsAliasMap); | |
261 | result+=goofieResult; | |
262 | status = new TParameter<int>("goofieResult",goofieResult); | |
263 | resultArray->Add(status); | |
264 | } | |
265 | ||
266 | // Other calibration information will be retrieved through FXS files | |
267 | // examples: | |
268 | // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals"); | |
269 | // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1"); | |
270 | // | |
271 | // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib"); | |
272 | // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1"); | |
273 | ||
274 | // pedestal entries | |
275 | ||
276 | if(runType == kPedestalRunType) { | |
277 | Int_t numSources = 1; | |
278 | Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
279 | TString source = fConfEnv->GetValue("Pedestal","DAQ"); | |
280 | source.ToUpper(); | |
281 | if (source != "OFF" ) { | |
282 | if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT; | |
283 | if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ; | |
284 | if (source == "HLTDAQ" ) { | |
285 | numSources=2; | |
286 | pedestalSource[0] = AliShuttleInterface::kHLT; | |
287 | pedestalSource[1] = AliShuttleInterface::kDAQ; | |
288 | } | |
289 | if (source == "DAQHLT" ) numSources=2; | |
290 | UInt_t pedestalResult=0; | |
291 | for (Int_t i=0; i<numSources; i++ ) { | |
292 | pedestalResult = ExtractPedestals(pedestalSource[i]); | |
293 | if ( pedestalResult == 0 ) break; | |
294 | } | |
295 | result += pedestalResult; | |
296 | status = new TParameter<int>("pedestalResult",pedestalResult); | |
297 | resultArray->Add(status); | |
298 | } | |
299 | } | |
300 | ||
301 | // pulser trigger processing | |
302 | ||
303 | if(runType == kPulserRunType) { | |
304 | Int_t numSources = 1; | |
305 | Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
306 | TString source = fConfEnv->GetValue("Pulser","DAQ"); | |
307 | source.ToUpper(); | |
308 | if ( source != "OFF") { | |
309 | if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT; | |
310 | if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ; | |
311 | if (source == "HLTDAQ" ) { | |
312 | numSources=2; | |
313 | pulserSource[0] = AliShuttleInterface::kHLT; | |
314 | pulserSource[1] = AliShuttleInterface::kDAQ; | |
315 | } | |
316 | if (source == "DAQHLT" ) numSources=2; | |
317 | UInt_t pulserResult=0; | |
318 | for (Int_t i=0; i<numSources; i++ ) { | |
319 | pulserResult = ExtractPulser(pulserSource[i]); | |
320 | if ( pulserResult == 0 ) break; | |
321 | } | |
322 | result += pulserResult; | |
323 | status = new TParameter<int>("pulserResult",pulserResult); | |
324 | resultArray->Add(status); | |
325 | } | |
326 | } | |
327 | ||
328 | // Altro configuration | |
329 | ||
330 | ||
331 | TString altroConf = fConfEnv->GetValue("AltroConf","ON"); | |
332 | goofieConf.ToUpper(); | |
333 | if (altroConf != "OFF" ) { | |
334 | UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS); | |
335 | result+=altroResult; | |
336 | status = new TParameter<int>("altroResult",altroResult); | |
337 | resultArray->Add(status); | |
338 | } | |
339 | ||
340 | ||
341 | // Central Electrode processing | |
342 | ||
343 | if( runType == kPhysicsRunType || | |
344 | runType == kDaqRunType ) { | |
345 | ||
346 | // if (true) { // do CE processing for all run types | |
347 | Int_t numSources = 1; | |
348 | Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
349 | TString source = fConfEnv->GetValue("CE","DAQ"); | |
350 | source.ToUpper(); | |
351 | if ( source != "OFF" ) { | |
352 | if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT; | |
353 | if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ; | |
354 | if (source == "HLTDAQ" ) { | |
355 | numSources=2; | |
356 | ceSource[0] = AliShuttleInterface::kHLT; | |
357 | ceSource[1] = AliShuttleInterface::kDAQ; | |
358 | } | |
359 | if (source == "DAQHLT" ) numSources=2; | |
360 | UInt_t ceResult=0; | |
361 | for (Int_t i=0; i<numSources; i++ ) { | |
362 | ceResult = ExtractCE(ceSource[i]); | |
363 | if ( ceResult == 0 ) break; | |
364 | } | |
365 | result += ceResult; | |
366 | status = new TParameter<int>("ceResult",ceResult); | |
367 | resultArray->Add(status); | |
368 | ||
369 | numSources = 1; | |
370 | Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
371 | source = fConfEnv->GetValue("QA","DAQ"); | |
372 | source.ToUpper(); | |
373 | if ( source != "OFF" ) { | |
374 | if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT; | |
375 | if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ; | |
376 | if (source == "HLTDAQ" ) { | |
377 | numSources=2; | |
378 | qaSource[0] = AliShuttleInterface::kHLT; | |
379 | qaSource[1] = AliShuttleInterface::kDAQ; | |
380 | } | |
381 | if (source == "DAQHLT" ) numSources=2; | |
382 | UInt_t qaResult=0; | |
383 | for (Int_t i=0; i<numSources; i++ ) { | |
384 | qaResult = ExtractQA(qaSource[i]); | |
385 | if ( qaResult == 0 ) break; | |
386 | } | |
387 | // result += qaResult; | |
388 | if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available."); | |
389 | status = new TParameter<int>("qaResult",qaResult); | |
390 | resultArray->Add(status); | |
391 | } | |
392 | } | |
393 | } | |
394 | ||
395 | if (errorHandling == "OFF" ) { | |
396 | AliCDBMetaData metaData; | |
397 | metaData.SetBeamPeriod(0); | |
398 | metaData.SetResponsible("Haavard Helstrup"); | |
399 | metaData.SetComment("Preprocessor AliTPC status."); | |
400 | Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE); | |
401 | resultArray->Delete(); | |
402 | return 0; | |
403 | } else { | |
404 | return result; | |
405 | } | |
406 | } | |
407 | //______________________________________________________________________________________________ | |
408 | UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap) | |
409 | { | |
410 | ||
411 | // extract DCS temperature maps. Perform fits to save space | |
412 | ||
413 | UInt_t result=0; | |
414 | TMap *map = fTemp->ExtractDCS(dcsAliasMap); | |
415 | if (map) { | |
416 | fTemp->MakeSplineFit(map); | |
417 | Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); | |
418 | if (fitFraction > kFitFraction ) { | |
419 | AliInfo(Form("Temperature values extracted, fits performed.\n")); | |
420 | } else { | |
421 | Log ("Too few temperature maps fitted. \n"); | |
422 | result = 9; | |
423 | } | |
424 | } else { | |
425 | Log("No temperature map extracted. \n"); | |
426 | result=9; | |
427 | } | |
428 | delete map; | |
429 | // Now store the final CDB file | |
430 | ||
431 | if ( result == 0 ) { | |
432 | AliCDBMetaData metaData; | |
433 | metaData.SetBeamPeriod(0); | |
434 | metaData.SetResponsible("Haavard Helstrup"); | |
435 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
436 | ||
437 | Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE); | |
438 | if ( !storeOK ) result=1; | |
439 | ||
440 | } | |
441 | ||
442 | return result; | |
443 | ||
444 | } | |
445 | ||
446 | //______________________________________________________________________________________________ | |
447 | UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap) | |
448 | { | |
449 | ||
450 | // extract DCS HV maps. Perform fits to save space | |
451 | ||
452 | UInt_t result=0; | |
453 | TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap); | |
454 | if (map) { | |
455 | fHighVoltage->MakeSplineFit(map); | |
456 | Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors(); | |
457 | if (fitFraction > kFitFraction ) { | |
458 | AliInfo(Form("High voltage recordings extracted, fits performed.\n")); | |
459 | } else { | |
460 | Log ("Too few high voltage recordings fitted. \n"); | |
461 | result = 9; | |
462 | } | |
463 | } else { | |
464 | Log("No high voltage recordings extracted. \n"); | |
465 | result=9; | |
466 | } | |
467 | delete map; | |
468 | ||
469 | TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON"); | |
470 | hvStatConf.ToUpper(); | |
471 | if (hvStatConf != "OFF" ) { | |
472 | TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap); | |
473 | if (map2) { | |
474 | fHighVoltageStat->ClearFit(); | |
475 | fHighVoltageStat->SetGraph(map2); | |
476 | } else { | |
477 | Log("No high voltage status recordings extracted. \n"); | |
478 | result=9; | |
479 | } | |
480 | delete map2; | |
481 | ||
482 | // add status maps to high voltage sensor array | |
483 | ||
484 | fHighVoltage->AddSensors(fHighVoltageStat); | |
485 | } | |
486 | // Now store the final CDB file | |
487 | ||
488 | if ( result == 0 ) { | |
489 | AliCDBMetaData metaData; | |
490 | metaData.SetBeamPeriod(0); | |
491 | metaData.SetResponsible("Haavard Helstrup"); | |
492 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
493 | ||
494 | Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE); | |
495 | if ( !storeOK ) result=1; | |
496 | ||
497 | } | |
498 | ||
499 | return result; | |
500 | ||
501 | } | |
502 | ||
503 | //______________________________________________________________________________________________ | |
504 | UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap) | |
505 | { | |
506 | ||
507 | // extract DCS Goofie maps. Do not perform fits (low update rate) | |
508 | ||
509 | UInt_t result=0; | |
510 | ||
511 | TMap *map = fGoofie->ExtractDCS(dcsAliasMap); | |
512 | if (map) { | |
513 | fGoofie->ClearFit(); | |
514 | fGoofie->SetGraph(map); | |
515 | } else { | |
516 | Log("No Goofie recordings extracted. \n"); | |
517 | result=9; | |
518 | } | |
519 | delete map; | |
520 | ||
521 | // Now store the final CDB file | |
522 | ||
523 | if ( result == 0 ) { | |
524 | AliCDBMetaData metaData; | |
525 | metaData.SetBeamPeriod(0); | |
526 | metaData.SetResponsible("Haavard Helstrup"); | |
527 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
528 | ||
529 | Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE); | |
530 | if ( !storeOK ) result=1; | |
531 | ||
532 | } | |
533 | ||
534 | return result; | |
535 | ||
536 | } | |
537 | ||
538 | ||
539 | //______________________________________________________________________________________________ | |
540 | ||
541 | UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) | |
542 | { | |
543 | // | |
544 | // Read pedestal file from file exchage server | |
545 | // Keep original entry from OCDB in case no new pedestals are available | |
546 | // | |
547 | AliTPCCalPad *calPadPed=0; | |
548 | AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals"); | |
549 | if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject(); | |
550 | if ( calPadPed==NULL ) { | |
551 | Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n"); | |
552 | calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean"); | |
553 | } | |
554 | ||
555 | AliTPCCalPad *calPadRMS=0; | |
556 | entry = GetFromOCDB("Calib", "PadNoise"); | |
557 | if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject(); | |
558 | if ( calPadRMS==NULL ) { | |
559 | Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n"); | |
560 | calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS"); | |
561 | } | |
562 | ||
563 | ||
564 | UInt_t result=0; | |
565 | ||
566 | Int_t nSectors = fROC->GetNSectors(); | |
567 | TList* list = GetFileSources(sourceFXS,"pedestals"); | |
568 | ||
569 | if (list && list->GetEntries()>0) { | |
570 | ||
571 | // loop through all files from LDCs | |
572 | ||
573 | Bool_t changed=false; | |
574 | UInt_t index = 0; | |
575 | while (list->At(index)!=NULL) { | |
576 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
577 | if (fileNameEntry!=NULL) { | |
578 | TString fileName = GetFile(sourceFXS, "pedestals", | |
579 | fileNameEntry->GetString().Data()); | |
580 | TFile *f = TFile::Open(fileName); | |
581 | if (!f) { | |
582 | Log ("Error opening pedestal file."); | |
583 | result =2; | |
584 | break; | |
585 | } | |
586 | AliTPCCalibPedestal *calPed; | |
587 | f->GetObject("tpcCalibPedestal",calPed); | |
588 | if ( !calPed ) { | |
589 | Log ("No pedestal calibration object in file."); | |
590 | result = 2; | |
591 | break; | |
592 | } | |
593 | ||
594 | // replace entries for the sectors available in the present file | |
595 | ||
596 | changed=true; | |
597 | for (Int_t sector=0; sector<nSectors; sector++) { | |
598 | AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE); | |
599 | if ( rocPed ) calPadPed->SetCalROC(rocPed,sector); | |
600 | AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE); | |
601 | if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector); | |
602 | } | |
603 | delete calPed; | |
604 | f->Close(); | |
605 | } | |
606 | ++index; | |
607 | } // while(list) | |
608 | // | |
609 | // Store updated pedestal entry to OCDB | |
610 | // | |
611 | if (changed) { | |
612 | AliCDBMetaData metaData; | |
613 | metaData.SetBeamPeriod(0); | |
614 | metaData.SetResponsible("Haavard Helstrup"); | |
615 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
616 | ||
617 | Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE); | |
618 | if ( !storeOK ) ++result; | |
619 | storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE); | |
620 | if ( !storeOK ) ++result; | |
621 | } | |
622 | } else { | |
623 | Log ("Error: no entries in input file list!"); | |
624 | result = 1; | |
625 | } | |
626 | ||
627 | return result; | |
628 | } | |
629 | ||
630 | //______________________________________________________________________________________________ | |
631 | ||
632 | ||
633 | UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) | |
634 | { | |
635 | // | |
636 | // Read pulser calibration file from file exchage server | |
637 | // Keep original entry from OCDB in case no new pulser calibration is available | |
638 | // | |
639 | TObjArray *pulserObjects=0; | |
640 | AliTPCCalPad *pulserTmean=0; | |
641 | AliTPCCalPad *pulserTrms=0; | |
642 | AliTPCCalPad *pulserQmean=0; | |
643 | AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser"); | |
644 | if (entry) pulserObjects = (TObjArray*)entry->GetObject(); | |
645 | if ( pulserObjects==NULL ) { | |
646 | Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n"); | |
647 | pulserObjects = new TObjArray; | |
648 | } | |
649 | ||
650 | pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean"); | |
651 | if ( !pulserTmean ) { | |
652 | pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean"); | |
653 | pulserObjects->Add(pulserTmean); | |
654 | } | |
655 | pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms"); | |
656 | if ( !pulserTrms ) { | |
657 | pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms"); | |
658 | pulserObjects->Add(pulserTrms); | |
659 | } | |
660 | pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean"); | |
661 | if ( !pulserQmean ) { | |
662 | pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean"); | |
663 | pulserObjects->Add(pulserQmean); | |
664 | } | |
665 | ||
666 | ||
667 | UInt_t result=0; | |
668 | ||
669 | Int_t nSectors = fROC->GetNSectors(); | |
670 | TList* list = GetFileSources(sourceFXS,"pulser"); | |
671 | ||
672 | if (list && list->GetEntries()>0) { | |
673 | ||
674 | // loop through all files from LDCs | |
675 | ||
676 | Bool_t changed=false; | |
677 | UInt_t index = 0; | |
678 | while (list->At(index)!=NULL) { | |
679 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
680 | if (fileNameEntry!=NULL) { | |
681 | TString fileName = GetFile(sourceFXS, "pulser", | |
682 | fileNameEntry->GetString().Data()); | |
683 | TFile *f = TFile::Open(fileName); | |
684 | if (!f) { | |
685 | Log ("Error opening pulser file."); | |
686 | result =2; | |
687 | break; | |
688 | } | |
689 | AliTPCCalibPulser *calPulser; | |
690 | f->GetObject("tpcCalibPulser",calPulser); | |
691 | if ( !calPulser ) { | |
692 | Log ("No pulser calibration object in file."); | |
693 | result = 2; | |
694 | break; | |
695 | } | |
696 | ||
697 | // replace entries for the sectors available in the present file | |
698 | ||
699 | changed=true; | |
700 | for (Int_t sector=0; sector<nSectors; sector++) { | |
701 | AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector); | |
702 | if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector); | |
703 | AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector); | |
704 | if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector); | |
705 | AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector); | |
706 | if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector); | |
707 | } | |
708 | delete calPulser; | |
709 | f->Close(); | |
710 | } | |
711 | ++index; | |
712 | } // while(list) | |
713 | // | |
714 | // Store updated pedestal entry to OCDB | |
715 | // | |
716 | if (changed) { | |
717 | AliCDBMetaData metaData; | |
718 | metaData.SetBeamPeriod(0); | |
719 | metaData.SetResponsible("Haavard Helstrup"); | |
720 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
721 | ||
722 | Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE); | |
723 | if ( !storeOK ) ++result; | |
724 | } | |
725 | } else { | |
726 | Log ("Error: no entries in input file list!"); | |
727 | result = 1; | |
728 | } | |
729 | ||
730 | return result; | |
731 | } | |
732 | ||
733 | UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) | |
734 | { | |
735 | // | |
736 | // Read Central Electrode file from file exchage server | |
737 | // Keep original entry from OCDB in case no new CE calibration is available | |
738 | // | |
739 | TObjArray *ceObjects=0; | |
740 | AliTPCCalPad *ceTmean=0; | |
741 | AliTPCCalPad *ceTrms=0; | |
742 | AliTPCCalPad *ceQmean=0; | |
743 | TObjArray *rocTtime=0; | |
744 | TObjArray *rocQtime=0; | |
745 | ||
746 | AliCDBEntry* entry = GetFromOCDB("Calib", "CE"); | |
747 | if (entry) ceObjects = (TObjArray*)entry->GetObject(); | |
748 | if ( ceObjects==NULL ) { | |
749 | Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n"); | |
750 | ceObjects = new TObjArray; | |
751 | } | |
752 | ||
753 | Int_t nSectors = fROC->GetNSectors(); | |
754 | ||
755 | ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean"); | |
756 | if ( !ceTmean ) { | |
757 | ceTmean = new AliTPCCalPad("CETmean","CETmean"); | |
758 | ceObjects->Add(ceTmean); | |
759 | } | |
760 | ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms"); | |
761 | if ( !ceTrms ) { | |
762 | ceTrms = new AliTPCCalPad("CETrms","CETrms"); | |
763 | ceObjects->Add(ceTrms); | |
764 | } | |
765 | ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean"); | |
766 | if ( !ceQmean ) { | |
767 | ceQmean = new AliTPCCalPad("CEQmean","CEQmean"); | |
768 | ceObjects->Add(ceQmean); | |
769 | } | |
770 | //!new from here please have a look!!! | |
771 | rocTtime = (TObjArray*)ceObjects->FindObject("rocTtime"); | |
772 | if ( !rocTtime ) { | |
773 | rocTtime = new TObjArray(nSectors); | |
774 | rocTtime->SetName("rocTtime"); | |
775 | ceObjects->Add(rocTtime); | |
776 | } | |
777 | ||
778 | rocQtime = (TObjArray*)ceObjects->FindObject("rocQtime"); | |
779 | if ( !rocQtime ) { | |
780 | rocQtime = new TObjArray(nSectors); | |
781 | rocQtime->SetName("rocQtime"); | |
782 | ceObjects->Add(rocQtime); | |
783 | } | |
784 | ||
785 | ||
786 | UInt_t result=0; | |
787 | ||
788 | TList* list = GetFileSources(sourceFXS,"CE"); | |
789 | ||
790 | if (list && list->GetEntries()>0) { | |
791 | ||
792 | // loop through all files from LDCs | |
793 | ||
794 | UInt_t index = 0; | |
795 | while (list->At(index)!=NULL) { | |
796 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
797 | if (fileNameEntry!=NULL) { | |
798 | TString fileName = GetFile(sourceFXS, "CE", | |
799 | fileNameEntry->GetString().Data()); | |
800 | TFile *f = TFile::Open(fileName); | |
801 | if (!f) { | |
802 | Log ("Error opening central electrode file."); | |
803 | result =2; | |
804 | break; | |
805 | } | |
806 | AliTPCCalibCE *calCE; | |
807 | f->GetObject("tpcCalibCE",calCE); | |
808 | ||
809 | if (!calCE) { | |
810 | Log ("No valid calibCE object."); | |
811 | result=2; | |
812 | break; | |
813 | } | |
814 | // replace entries for the sectors available in the present file | |
815 | ||
816 | for (Int_t sector=0; sector<nSectors; sector++) { | |
817 | AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector); | |
818 | if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector); | |
819 | AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector); | |
820 | if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector); | |
821 | AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector); | |
822 | if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector); | |
823 | TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph | |
824 | if ( grT ) rocTtime->AddAt(grT,sector); | |
825 | TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph | |
826 | if ( grQ ) rocTtime->AddAt(grQ,sector); | |
827 | } | |
828 | delete calCE; | |
829 | f->Close(); | |
830 | } | |
831 | ++index; | |
832 | } // while(list) | |
833 | // | |
834 | // Store updated pedestal entry to OCDB | |
835 | // | |
836 | AliCDBMetaData metaData; | |
837 | metaData.SetBeamPeriod(0); | |
838 | metaData.SetResponsible("Haavard Helstrup"); | |
839 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
840 | ||
841 | Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE); | |
842 | if ( !storeOK ) ++result; | |
843 | ||
844 | } else { | |
845 | Log ("Error: no entries!"); | |
846 | result = 1; | |
847 | } | |
848 | ||
849 | return result; | |
850 | } | |
851 | //______________________________________________________________________________________________ | |
852 | ||
853 | UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS) | |
854 | { | |
855 | // | |
856 | // Read Quality Assurance file from file exchage server | |
857 | // | |
858 | ||
859 | UInt_t result=0; | |
860 | ||
861 | TList* list = GetFileSources(sourceFXS,"QA"); | |
862 | ||
863 | if (list && list->GetEntries()>0) { | |
864 | ||
865 | // only one QA objetc should be available! | |
866 | ||
867 | AliTPCdataQA *calQA; | |
868 | ||
869 | UInt_t nentries = list->GetEntries(); | |
870 | UInt_t index=0; | |
871 | if ( nentries > 1) Log ( "More than one QA entry. First one processed"); | |
872 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
873 | if (fileNameEntry!=NULL) { | |
874 | TString fileName = GetFile(sourceFXS, "QA", | |
875 | fileNameEntry->GetString().Data()); | |
876 | TFile *f = TFile::Open(fileName); | |
877 | if (!f) { | |
878 | Log ("Error opening QA file."); | |
879 | result =2; | |
880 | } else { | |
881 | f->GetObject("tpcCalibQA",calQA); | |
882 | if ( calQA ) { | |
883 | // | |
884 | // Store updated pedestal entry to OCDB | |
885 | // | |
886 | AliCDBMetaData metaData; | |
887 | metaData.SetBeamPeriod(0); | |
888 | metaData.SetResponsible("Haavard Helstrup"); | |
889 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
890 | ||
891 | Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kTRUE); | |
892 | if ( !storeOK ) ++result; | |
893 | } | |
894 | } | |
895 | } else { | |
896 | Log ("Error: no QA files on FXS!"); | |
897 | result = 2; | |
898 | } | |
899 | } else { | |
900 | Log ("Error: no QA entries in FXS list!"); | |
901 | result = 1; | |
902 | } | |
903 | return result; | |
904 | } | |
905 | ||
906 | //______________________________________________________________________________________________ | |
907 | ||
908 | ||
909 | UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS) | |
910 | { | |
911 | // | |
912 | // Read pulser calibration file from file exchage server | |
913 | // Keep original entry from OCDB in case no new pulser calibration is available | |
914 | // | |
915 | TObjArray *altroObjects=0; | |
916 | AliTPCCalPad *acqStart=0; | |
917 | AliTPCCalPad *zsThr=0; | |
918 | AliTPCCalPad *acqStop=0; | |
919 | AliTPCCalPad *FPED=0; | |
920 | AliTPCCalPad *masked=0; | |
921 | ||
922 | AliCDBEntry* entry = GetFromOCDB("Calib", "Altro"); | |
923 | if (entry) altroObjects = (TObjArray*)entry->GetObject(); | |
924 | if ( altroObjects==NULL ) { | |
925 | Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n"); | |
926 | altroObjects = new TObjArray; | |
927 | } | |
928 | ||
929 | acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart"); | |
930 | if ( !acqStart ) { | |
931 | acqStart = new AliTPCCalPad("AcqStart","AcqStart"); | |
932 | altroObjects->Add(acqStart); | |
933 | } | |
934 | zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr"); | |
935 | if ( !zsThr ) { | |
936 | zsThr = new AliTPCCalPad("ZsThr","ZsThr"); | |
937 | altroObjects->Add(zsThr); | |
938 | } | |
939 | FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED"); | |
940 | if ( !FPED ) { | |
941 | FPED = new AliTPCCalPad("FPED","FPED"); | |
942 | altroObjects->Add(FPED); | |
943 | } | |
944 | acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop"); | |
945 | if ( !acqStop ) { | |
946 | acqStop = new AliTPCCalPad("AcqStop","AcqStop"); | |
947 | altroObjects->Add(acqStop); | |
948 | } | |
949 | masked = (AliTPCCalPad*)altroObjects->FindObject("Masked"); | |
950 | if ( !masked ) { | |
951 | masked = new AliTPCCalPad("Masked","Masked"); | |
952 | altroObjects->Add(masked); | |
953 | } | |
954 | ||
955 | ||
956 | ||
957 | UInt_t result=0; | |
958 | TString idFXS[2]={"AltroConfigA","AltroConfigC"}; | |
959 | ||
960 | Int_t nSectors = fROC->GetNSectors(); | |
961 | Bool_t changed=false; | |
962 | for ( Int_t id=0; id<2; id++) { | |
963 | TList* list = GetFileSources(sourceFXS,idFXS[id].Data()); | |
964 | ||
965 | if (list && list->GetEntries()>0) { | |
966 | if (altroObjects == 0 ) altroObjects = new TObjArray; | |
967 | ||
968 | // loop through all files from LDCs | |
969 | ||
970 | UInt_t index = 0; | |
971 | while (list->At(index)!=NULL) { | |
972 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
973 | if (fileNameEntry!=NULL) { | |
974 | TString fileName = GetFile(sourceFXS, idFXS[id].Data(), | |
975 | fileNameEntry->GetString().Data()); | |
976 | TFile *f = TFile::Open(fileName); | |
977 | if (!f) { | |
978 | char message[40]; | |
979 | sprintf(message,"Error opening Altro configuration file, id = %d",id); | |
980 | Log (message); | |
981 | result =2; | |
982 | break; | |
983 | } | |
984 | TObjArray *altroFXS; | |
985 | f->GetObject("AltroConfig",altroFXS); | |
986 | if ( !altroFXS ) { | |
987 | Log ("No Altro configuration object in file."); | |
988 | result = 2; | |
989 | break; | |
990 | } | |
991 | ||
992 | // replace entries for the sectors available in the present file | |
993 | AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart"); | |
994 | AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr"); | |
995 | AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop"); | |
996 | AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED"); | |
997 | AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked"); | |
998 | ||
999 | changed=true; | |
1000 | for (Int_t sector=0; sector<nSectors; sector++) { | |
1001 | ||
1002 | if (acqStartFXS) { | |
1003 | AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector); | |
1004 | if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector); | |
1005 | } | |
1006 | if (zsThrFXS ) { | |
1007 | AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector); | |
1008 | if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector); | |
1009 | } | |
1010 | if (acqStopFXS) { | |
1011 | AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector); | |
1012 | if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector); | |
1013 | } | |
1014 | if (FPEDFXS ) { | |
1015 | AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector); | |
1016 | if ( rocFPED ) FPED->SetCalROC(rocFPED,sector); | |
1017 | } | |
1018 | if (maskedFXS) { | |
1019 | AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector); | |
1020 | if ( rocMasked ) masked->SetCalROC(rocMasked,sector); | |
1021 | } | |
1022 | } | |
1023 | delete altroFXS; | |
1024 | f->Close(); | |
1025 | } | |
1026 | ++index; | |
1027 | } // while(list) | |
1028 | } else { | |
1029 | Log ("Error: no entries in input file list!"); | |
1030 | result = 1; | |
1031 | } | |
1032 | ||
1033 | } // for - id | |
1034 | // | |
1035 | // Store updated pedestal entry to OCDB | |
1036 | // | |
1037 | if (changed) { | |
1038 | AliCDBMetaData metaData; | |
1039 | metaData.SetBeamPeriod(0); | |
1040 | metaData.SetResponsible("Haavard Helstrup"); | |
1041 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
1042 | ||
1043 | Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kTRUE); | |
1044 | if ( !storeOK ) ++result; | |
1045 | } | |
1046 | ||
1047 | return result; | |
1048 | } |