]>
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 "TFile.h" | |
31 | #include "TTree.h" | |
32 | #include "TEnv.h" | |
33 | #include "TParameter.h" | |
34 | ||
35 | #include <TTimeStamp.h> | |
36 | ||
37 | const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees | |
38 | const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees | |
39 | const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier | |
40 | const TString kPulserRunType = "PULSER"; // pulser run identifier | |
41 | const TString kPhysicsRunType = "PHYSICS"; // physics run identifier | |
42 | const TString kStandAloneRunType = "STANDALONE"; // standalone run identifier | |
43 | const TString kDaqRunType = "DAQ"; // DAQ run identifier | |
44 | const TString kAmandaTemp = "tpc_PT_%d.Temperature"; // Amanda string for temperature entries | |
45 | //const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required | |
46 | const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run | |
47 | ||
48 | // | |
49 | // This class is the SHUTTLE preprocessor for the TPC detector. | |
50 | // | |
51 | ||
52 | ClassImp(AliTPCPreprocessor) | |
53 | ||
54 | //______________________________________________________________________________________________ | |
55 | AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) : | |
56 | AliPreprocessor("TPC",shuttle), | |
57 | fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE), fROC(0) | |
58 | { | |
59 | // constructor | |
60 | fROC = AliTPCROC::Instance(); | |
61 | } | |
62 | //______________________________________________________________________________________________ | |
63 | // AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) : | |
64 | // AliPreprocessor(org), | |
65 | // fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE) | |
66 | // { | |
67 | // // copy constructor not implemented | |
68 | // // -- missing underlying copy constructor in AliPreprocessor | |
69 | // | |
70 | // Fatal("AliTPCPreprocessor", "copy constructor not implemented"); | |
71 | // | |
72 | // // fTemp = new AliTPCSensorTempArray(*(org.fTemp)); | |
73 | // } | |
74 | ||
75 | //______________________________________________________________________________________________ | |
76 | AliTPCPreprocessor::~AliTPCPreprocessor() | |
77 | { | |
78 | // destructor | |
79 | ||
80 | delete fTemp; | |
81 | delete fHighVoltage; | |
82 | } | |
83 | //______________________________________________________________________________________________ | |
84 | AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& ) | |
85 | { | |
86 | Fatal("operator =", "assignment operator not implemented"); | |
87 | return *this; | |
88 | } | |
89 | ||
90 | ||
91 | //______________________________________________________________________________________________ | |
92 | void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
93 | UInt_t endTime) | |
94 | { | |
95 | // Creates AliTestDataDCS object | |
96 | ||
97 | UInt_t startTimeLocal = startTime-3600; | |
98 | ||
99 | AliPreprocessor::Initialize(run, startTimeLocal, endTime); | |
100 | ||
101 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
102 | TTimeStamp(startTime).AsString(), | |
103 | TTimeStamp(endTime).AsString())); | |
104 | ||
105 | // Preprocessor configuration | |
106 | ||
107 | AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor"); | |
108 | if (entry) fConfEnv = (TEnv*) entry->GetObject(); | |
109 | if ( fConfEnv==0 ) { | |
110 | Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n"); | |
111 | fConfigOK = kFALSE; | |
112 | return; | |
113 | } | |
114 | ||
115 | // Temperature sensors | |
116 | ||
117 | TTree *confTree = 0; | |
118 | ||
119 | TString tempConf = fConfEnv->GetValue("Temperature","ON"); | |
120 | tempConf.ToUpper(); | |
121 | if (tempConf != "OFF" ) { | |
122 | entry = GetFromOCDB("Config", "Temperature"); | |
123 | if (entry) confTree = (TTree*) entry->GetObject(); | |
124 | if ( confTree==0 ) { | |
125 | Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n"); | |
126 | fConfigOK = kFALSE; | |
127 | return; | |
128 | } | |
129 | fTemp = new AliTPCSensorTempArray(startTimeLocal, endTime, confTree, kAmandaTemp); | |
130 | fTemp->SetValCut(kValCutTemp); | |
131 | fTemp->SetDiffCut(kDiffCutTemp); | |
132 | } | |
133 | ||
134 | // High voltage measurements | |
135 | ||
136 | TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); | |
137 | hvConf.ToUpper(); | |
138 | if (hvConf != "OFF" ) { | |
139 | confTree=0; | |
140 | entry=0; | |
141 | entry = GetFromOCDB("Config", "HighVoltage"); | |
142 | if (entry) confTree = (TTree*) entry->GetObject(); | |
143 | if ( confTree==0 ) { | |
144 | Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n"); | |
145 | fConfigOK = kFALSE; | |
146 | return; | |
147 | } | |
148 | fHighVoltage = new AliDCSSensorArray(startTimeLocal, endTime, confTree); | |
149 | } | |
150 | } | |
151 | ||
152 | //______________________________________________________________________________________________ | |
153 | UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap) | |
154 | { | |
155 | // Fills data into TPC calibrations objects | |
156 | ||
157 | // Amanda servers provide information directly through dcsAliasMap | |
158 | ||
159 | if (!fConfigOK) return 9; | |
160 | UInt_t result = 0; | |
161 | TObjArray *resultArray = new TObjArray(); | |
162 | TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON"); | |
163 | errorHandling.ToUpper(); | |
164 | TObject * status; | |
165 | ||
166 | UInt_t dcsResult=0; | |
167 | if (errorHandling == "OFF" ) { | |
168 | if (!dcsAliasMap) dcsResult=1; | |
169 | if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1; | |
170 | status = new TParameter<int>("dcsResult",dcsResult); | |
171 | resultArray->Add(status); | |
172 | } else { | |
173 | if (!dcsAliasMap) return 9; | |
174 | if (dcsAliasMap->GetEntries() == 0 ) return 9; | |
175 | } | |
176 | ||
177 | TString runType = GetRunType(); | |
178 | ||
179 | // Temperature sensors are processed by AliTPCCalTemp | |
180 | ||
181 | TString tempConf = fConfEnv->GetValue("Temperature","ON"); | |
182 | tempConf.ToUpper(); | |
183 | if (tempConf != "OFF" ) { | |
184 | UInt_t tempResult = MapTemperature(dcsAliasMap); | |
185 | result=tempResult; | |
186 | status = new TParameter<int>("tempResult",tempResult); | |
187 | resultArray->Add(status); | |
188 | } | |
189 | ||
190 | // High Voltage recordings | |
191 | ||
192 | ||
193 | TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); | |
194 | hvConf.ToUpper(); | |
195 | if (hvConf != "OFF" ) { | |
196 | UInt_t hvResult = MapHighVoltage(dcsAliasMap); | |
197 | result+=hvResult; | |
198 | status = new TParameter<int>("hvResult",hvResult); | |
199 | resultArray->Add(status); | |
200 | } | |
201 | ||
202 | // Other calibration information will be retrieved through FXS files | |
203 | // examples: | |
204 | // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals"); | |
205 | // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1"); | |
206 | // | |
207 | // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib"); | |
208 | // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1"); | |
209 | ||
210 | // pedestal entries | |
211 | ||
212 | if(runType == kPedestalRunType) { | |
213 | Int_t numSources = 1; | |
214 | Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
215 | TString source = fConfEnv->GetValue("Pedestal","DAQ"); | |
216 | source.ToUpper(); | |
217 | if (source != "OFF" ) { | |
218 | if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT; | |
219 | if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ; | |
220 | if (source == "HLTDAQ" ) { | |
221 | numSources=2; | |
222 | pedestalSource[0] = AliShuttleInterface::kHLT; | |
223 | pedestalSource[1] = AliShuttleInterface::kDAQ; | |
224 | } | |
225 | if (source == "DAQHLT" ) numSources=2; | |
226 | UInt_t pedestalResult=0; | |
227 | for (Int_t i=0; i<numSources; i++ ) { | |
228 | UInt_t pedestalResult = ExtractPedestals(pedestalSource[i]); | |
229 | if ( pedestalResult == 0 ) break; | |
230 | } | |
231 | result += pedestalResult; | |
232 | status = new TParameter<int>("pedestalResult",pedestalResult); | |
233 | resultArray->Add(status); | |
234 | } | |
235 | } | |
236 | ||
237 | // pulser trigger processing | |
238 | ||
239 | if(runType == kPulserRunType) { | |
240 | Int_t numSources = 1; | |
241 | Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
242 | TString source = fConfEnv->GetValue("Pulser","DAQ"); | |
243 | source.ToUpper(); | |
244 | if ( source != "OFF") { | |
245 | if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT; | |
246 | if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ; | |
247 | if (source == "HLTDAQ" ) { | |
248 | numSources=2; | |
249 | pulserSource[0] = AliShuttleInterface::kHLT; | |
250 | pulserSource[1] = AliShuttleInterface::kDAQ; | |
251 | } | |
252 | if (source == "DAQHLT" ) numSources=2; | |
253 | UInt_t pulserResult=0; | |
254 | for (Int_t i=0; i<numSources; i++ ) { | |
255 | pulserResult = ExtractPulser(pulserSource[i]); | |
256 | if ( pulserResult == 0 ) break; | |
257 | } | |
258 | result += pulserResult; | |
259 | status = new TParameter<int>("pulserResult",pulserResult); | |
260 | resultArray->Add(status); | |
261 | } | |
262 | } | |
263 | ||
264 | ||
265 | ||
266 | // Central Electrode processing | |
267 | ||
268 | if( runType == kPhysicsRunType || runType == kStandAloneRunType || | |
269 | runType == kDaqRunType ) { | |
270 | ||
271 | Int_t numSources = 1; | |
272 | Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
273 | TString source = fConfEnv->GetValue("CE","DAQ"); | |
274 | source.ToUpper(); | |
275 | if ( source != "OFF" ) { | |
276 | if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT; | |
277 | if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ; | |
278 | if (source == "HLTDAQ" ) { | |
279 | numSources=2; | |
280 | ceSource[0] = AliShuttleInterface::kHLT; | |
281 | ceSource[1] = AliShuttleInterface::kDAQ; | |
282 | } | |
283 | if (source == "DAQHLT" ) numSources=2; | |
284 | UInt_t ceResult=0; | |
285 | for (Int_t i=0; i<numSources; i++ ) { | |
286 | ceResult = ExtractCE(ceSource[i]); | |
287 | if ( ceResult == 0 ) break; | |
288 | } | |
289 | result += ceResult; | |
290 | status = new TParameter<int>("ceResult",ceResult); | |
291 | resultArray->Add(status); | |
292 | } | |
293 | } | |
294 | ||
295 | if (errorHandling == "OFF" ) { | |
296 | AliCDBMetaData metaData; | |
297 | metaData.SetBeamPeriod(0); | |
298 | metaData.SetResponsible("Haavard Helstrup"); | |
299 | metaData.SetComment("Preprocessor AliTPC status."); | |
300 | Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE); | |
301 | resultArray->Delete(); | |
302 | return 0; | |
303 | } else { | |
304 | return result; | |
305 | } | |
306 | } | |
307 | //______________________________________________________________________________________________ | |
308 | UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap) | |
309 | { | |
310 | ||
311 | // extract DCS temperature maps. Perform fits to save space | |
312 | ||
313 | UInt_t result=0; | |
314 | TMap *map = fTemp->ExtractDCS(dcsAliasMap); | |
315 | if (map) { | |
316 | fTemp->MakeSplineFit(map); | |
317 | Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); | |
318 | if (fitFraction > kFitFraction ) { | |
319 | AliInfo(Form("Temperature values extracted, fits performed.\n")); | |
320 | } else { | |
321 | Log ("Too few temperature maps fitted. \n"); | |
322 | result = 9; | |
323 | } | |
324 | } else { | |
325 | Log("No temperature map extracted. \n"); | |
326 | result=9; | |
327 | } | |
328 | delete map; | |
329 | // Now store the final CDB file | |
330 | ||
331 | if ( result == 0 ) { | |
332 | AliCDBMetaData metaData; | |
333 | metaData.SetBeamPeriod(0); | |
334 | metaData.SetResponsible("Haavard Helstrup"); | |
335 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
336 | ||
337 | Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE); | |
338 | if ( !storeOK ) result=1; | |
339 | ||
340 | } | |
341 | ||
342 | return result; | |
343 | ||
344 | } | |
345 | ||
346 | //______________________________________________________________________________________________ | |
347 | UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap) | |
348 | { | |
349 | ||
350 | // extract DCS HV maps. Perform fits to save space | |
351 | ||
352 | UInt_t result=0; | |
353 | TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap); | |
354 | if (map) { | |
355 | fHighVoltage->MakeSplineFit(map); | |
356 | Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors(); | |
357 | if (fitFraction > kFitFraction ) { | |
358 | AliInfo(Form("High voltage recordings extracted, fits performed.\n")); | |
359 | } else { | |
360 | Log ("Too few high voltage recordings fitted. \n"); | |
361 | result = 9; | |
362 | } | |
363 | } else { | |
364 | Log("No high voltage recordings extracted. \n"); | |
365 | result=9; | |
366 | } | |
367 | delete map; | |
368 | // Now store the final CDB file | |
369 | ||
370 | if ( result == 0 ) { | |
371 | AliCDBMetaData metaData; | |
372 | metaData.SetBeamPeriod(0); | |
373 | metaData.SetResponsible("Haavard Helstrup"); | |
374 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
375 | ||
376 | Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE); | |
377 | if ( !storeOK ) result=1; | |
378 | ||
379 | } | |
380 | ||
381 | return result; | |
382 | ||
383 | } | |
384 | ||
385 | ||
386 | //______________________________________________________________________________________________ | |
387 | ||
388 | UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) | |
389 | { | |
390 | // | |
391 | // Read pedestal file from file exchage server | |
392 | // Keep original entry from OCDB in case no new pedestals are available | |
393 | // | |
394 | AliTPCCalPad *calPadPed=0; | |
395 | AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals"); | |
396 | if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject(); | |
397 | if ( calPadPed==NULL ) { | |
398 | Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n"); | |
399 | calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean"); | |
400 | } | |
401 | ||
402 | AliTPCCalPad *calPadRMS=0; | |
403 | entry = GetFromOCDB("Calib", "Noise"); | |
404 | if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject(); | |
405 | if ( calPadRMS==NULL ) { | |
406 | Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n"); | |
407 | calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS"); | |
408 | } | |
409 | ||
410 | ||
411 | UInt_t result=0; | |
412 | ||
413 | Int_t nSectors = fROC->GetNSectors(); | |
414 | TList* list = GetFileSources(sourceFXS,"pedestals"); | |
415 | ||
416 | if (list && list->GetEntries()>0) { | |
417 | ||
418 | // loop through all files from LDCs | |
419 | ||
420 | Bool_t changed=false; | |
421 | UInt_t index = 0; | |
422 | while (list->At(index)!=NULL) { | |
423 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
424 | if (fileNameEntry!=NULL) { | |
425 | TString fileName = GetFile(sourceFXS, "pedestals", | |
426 | fileNameEntry->GetString().Data()); | |
427 | TFile *f = TFile::Open(fileName); | |
428 | if (!f) { | |
429 | Log ("Error opening pedestal file."); | |
430 | result =2; | |
431 | break; | |
432 | } | |
433 | AliTPCCalibPedestal *calPed; | |
434 | f->GetObject("AliTPCCalibPedestal",calPed); | |
435 | if ( !calPed ) { | |
436 | Log ("No pedestal calibration object in file."); | |
437 | result = 2; | |
438 | break; | |
439 | } | |
440 | ||
441 | // replace entries for the sectors available in the present file | |
442 | ||
443 | changed=true; | |
444 | for (Int_t sector=0; sector<nSectors; sector++) { | |
445 | AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE); | |
446 | if ( rocPed ) calPadPed->SetCalROC(rocPed,sector); | |
447 | AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE); | |
448 | if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector); | |
449 | } | |
450 | } | |
451 | ++index; | |
452 | } // while(list) | |
453 | // | |
454 | // Store updated pedestal entry to OCDB | |
455 | // | |
456 | if (changed) { | |
457 | AliCDBMetaData metaData; | |
458 | metaData.SetBeamPeriod(0); | |
459 | metaData.SetResponsible("Haavard Helstrup"); | |
460 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
461 | ||
462 | Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE); | |
463 | if ( !storeOK ) ++result; | |
464 | storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE); | |
465 | if ( !storeOK ) ++result; | |
466 | } | |
467 | } else { | |
468 | Log ("Error: no entries in input file list!"); | |
469 | result = 1; | |
470 | } | |
471 | ||
472 | return result; | |
473 | } | |
474 | ||
475 | //______________________________________________________________________________________________ | |
476 | ||
477 | ||
478 | UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) | |
479 | { | |
480 | // | |
481 | // Read pulser calibration file from file exchage server | |
482 | // Keep original entry from OCDB in case no new pulser calibration is available | |
483 | // | |
484 | TObjArray *pulserObjects=0; | |
485 | AliTPCCalPad *pulserTmean=0; | |
486 | AliTPCCalPad *pulserTrms=0; | |
487 | AliTPCCalPad *pulserQmean=0; | |
488 | AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser"); | |
489 | if (entry) pulserObjects = (TObjArray*)entry->GetObject(); | |
490 | if ( pulserObjects==NULL ) { | |
491 | Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n"); | |
492 | pulserObjects = new TObjArray; | |
493 | } | |
494 | ||
495 | pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean"); | |
496 | if ( !pulserTmean ) { | |
497 | pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean"); | |
498 | pulserObjects->Add(pulserTmean); | |
499 | } | |
500 | pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms"); | |
501 | if ( !pulserTrms ) { | |
502 | pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms"); | |
503 | pulserObjects->Add(pulserTrms); | |
504 | } | |
505 | pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean"); | |
506 | if ( !pulserQmean ) { | |
507 | pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean"); | |
508 | pulserObjects->Add(pulserQmean); | |
509 | } | |
510 | ||
511 | ||
512 | UInt_t result=0; | |
513 | ||
514 | Int_t nSectors = fROC->GetNSectors(); | |
515 | TList* list = GetFileSources(sourceFXS,"pulser"); | |
516 | ||
517 | if (list && list->GetEntries()>0) { | |
518 | ||
519 | // loop through all files from LDCs | |
520 | ||
521 | Bool_t changed=false; | |
522 | UInt_t index = 0; | |
523 | while (list->At(index)!=NULL) { | |
524 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
525 | if (fileNameEntry!=NULL) { | |
526 | TString fileName = GetFile(sourceFXS, "pulser", | |
527 | fileNameEntry->GetString().Data()); | |
528 | TFile *f = TFile::Open(fileName); | |
529 | if (!f) { | |
530 | Log ("Error opening pulser file."); | |
531 | result =2; | |
532 | break; | |
533 | } | |
534 | AliTPCCalibPulser *calPulser; | |
535 | f->GetObject("AliTPCCalibPulser",calPulser); | |
536 | if ( !calPulser ) { | |
537 | Log ("No pulser calibration object in file."); | |
538 | result = 2; | |
539 | break; | |
540 | } | |
541 | ||
542 | // replace entries for the sectors available in the present file | |
543 | ||
544 | changed=true; | |
545 | for (Int_t sector=0; sector<nSectors; sector++) { | |
546 | AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector); | |
547 | if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector); | |
548 | AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector); | |
549 | if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector); | |
550 | AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector); | |
551 | if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector); | |
552 | } | |
553 | } | |
554 | ++index; | |
555 | } // while(list) | |
556 | // | |
557 | // Store updated pedestal entry to OCDB | |
558 | // | |
559 | if (changed) { | |
560 | AliCDBMetaData metaData; | |
561 | metaData.SetBeamPeriod(0); | |
562 | metaData.SetResponsible("Haavard Helstrup"); | |
563 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
564 | ||
565 | Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE); | |
566 | if ( !storeOK ) ++result; | |
567 | } | |
568 | } else { | |
569 | Log ("Error: no entries in input file list!"); | |
570 | result = 1; | |
571 | } | |
572 | ||
573 | return result; | |
574 | } | |
575 | ||
576 | UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) | |
577 | { | |
578 | // | |
579 | // Read Central Electrode file from file exchage server | |
580 | // Keep original entry from OCDB in case no new CE calibration is available | |
581 | // | |
582 | TObjArray *ceObjects=0; | |
583 | AliTPCCalPad *ceTmean=0; | |
584 | AliTPCCalPad *ceTrms=0; | |
585 | AliTPCCalPad *ceQmean=0; | |
586 | AliCDBEntry* entry = GetFromOCDB("Calib", "CE"); | |
587 | if (entry) ceObjects = (TObjArray*)entry->GetObject(); | |
588 | if ( ceObjects==NULL ) { | |
589 | Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n"); | |
590 | ceObjects = new TObjArray; | |
591 | } | |
592 | ||
593 | ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean"); | |
594 | if ( !ceTmean ) { | |
595 | ceTmean = new AliTPCCalPad("CETmean","CETmean"); | |
596 | ceObjects->Add(ceTmean); | |
597 | } | |
598 | ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms"); | |
599 | if ( !ceTrms ) { | |
600 | ceTrms = new AliTPCCalPad("CETrms","CETrms"); | |
601 | ceObjects->Add(ceTrms); | |
602 | } | |
603 | ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean"); | |
604 | if ( !ceQmean ) { | |
605 | ceQmean = new AliTPCCalPad("CEQmean","CEQmean"); | |
606 | ceObjects->Add(ceQmean); | |
607 | } | |
608 | ||
609 | ||
610 | UInt_t result=0; | |
611 | ||
612 | Int_t nSectors = fROC->GetNSectors(); | |
613 | TList* list = GetFileSources(sourceFXS,"CE"); | |
614 | ||
615 | if (list && list->GetEntries()>0) { | |
616 | ||
617 | // loop through all files from LDCs | |
618 | ||
619 | UInt_t index = 0; | |
620 | while (list->At(index)!=NULL) { | |
621 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
622 | if (fileNameEntry!=NULL) { | |
623 | TString fileName = GetFile(sourceFXS, "CE", | |
624 | fileNameEntry->GetString().Data()); | |
625 | TFile *f = TFile::Open(fileName); | |
626 | if (!f) { | |
627 | Log ("Error opening central electrode file."); | |
628 | result =2; | |
629 | break; | |
630 | } | |
631 | AliTPCCalibCE *calCE; | |
632 | f->GetObject("AliTPCCalibCE",calCE); | |
633 | ||
634 | // replace entries for the sectors available in the present file | |
635 | ||
636 | for (Int_t sector=0; sector<nSectors; sector++) { | |
637 | AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector); | |
638 | if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector); | |
639 | AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector); | |
640 | if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector); | |
641 | AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector); | |
642 | if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector); | |
643 | } | |
644 | } | |
645 | ++index; | |
646 | } // while(list) | |
647 | // | |
648 | // Store updated pedestal entry to OCDB | |
649 | // | |
650 | AliCDBMetaData metaData; | |
651 | metaData.SetBeamPeriod(0); | |
652 | metaData.SetResponsible("Haavard Helstrup"); | |
653 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
654 | ||
655 | Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE); | |
656 | if ( !storeOK ) ++result; | |
657 | ||
658 | } else { | |
659 | Log ("Error: no entries!"); | |
660 | result = 1; | |
661 | } | |
662 | ||
663 | return result; | |
664 | } |