]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCPreprocessor.cxx
Minors
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessor.cxx
CommitLineData
54472e4f 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
72df5829 16
54472e4f 17#include "AliTPCPreprocessor.h"
a7dce0bc 18#include "AliShuttleInterface.h"
54472e4f 19
20#include "AliCDBMetaData.h"
21#include "AliDCSValue.h"
22#include "AliLog.h"
23#include "AliTPCSensorTempArray.h"
a7dce0bc 24#include "AliTPCROC.h"
25#include "AliTPCCalROC.h"
26#include "AliTPCCalPad.h"
27#include "AliTPCCalibPedestal.h"
9f016d99 28#include "AliTPCCalibPulser.h"
29#include "AliTPCCalibCE.h"
dca91b3f 30#include "AliTPCdataQA.h"
9e66a8dd 31#include "TFile.h"
7b54c8e9 32#include "TTree.h"
bb30a935 33#include "TGraph.h"
7b54c8e9 34#include "TEnv.h"
bb30a935 35#include "TParameter.h"
54472e4f 36
37#include <TTimeStamp.h>
38
a7dce0bc 39const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
40const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
bb30a935 41const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
4c778358 42const TString kPulserRunType = "CALIBRATION_PULSER"; // pulser run identifier
bdffc5fb 43const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
9c754ce7 44const TString kStandAloneRunType = "STANDALONE"; // standalone run identifier
4c778358 45const TString kStandAlonePulserRunType = "STANDALONE_PULSER"; // standalone run identifier
0ec9f1fa 46const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
47const TString kLaserRunType = "LASER"; // laser run identifier
9c754ce7 48const TString kDaqRunType = "DAQ"; // DAQ run identifier
87d77b35 49const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
bee89eeb 50//const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
68b512ca 51const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
72df5829 52
54472e4f 53//
54// This class is the SHUTTLE preprocessor for the TPC detector.
54472e4f 55//
56
57ClassImp(AliTPCPreprocessor)
58
59//______________________________________________________________________________________________
6d07bf74 60AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
61 AliPreprocessor("TPC",shuttle),
9d2ce539 62 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fConfigOK(kTRUE), fROC(0)
54472e4f 63{
64 // constructor
a7dce0bc 65 fROC = AliTPCROC::Instance();
72534123 66
67 // define run types to be processed
68
69 AddRunType(kPedestalRunType);
70 AddRunType(kPulserRunType);
71 AddRunType(kPhysicsRunType);
72 AddRunType(kStandAloneRunType);
4c778358 73 AddRunType(kStandAlonePulserRunType);
72534123 74 AddRunType(kCosmicRunType);
75 AddRunType(kLaserRunType);
76 AddRunType(kDaqRunType);
77
54472e4f 78}
72df5829 79//______________________________________________________________________________________________
f4a89669 80 AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) :
81 AliPreprocessor("TPC",0),
9d2ce539 82 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fConfigOK(kTRUE), fROC(0)
f4a89669 83 {
84
85 Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 86//
87// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
f4a89669 88 }
54472e4f 89
90//______________________________________________________________________________________________
91AliTPCPreprocessor::~AliTPCPreprocessor()
92{
93 // destructor
a7dce0bc 94
54472e4f 95 delete fTemp;
bdffc5fb 96 delete fHighVoltage;
54472e4f 97}
72df5829 98//______________________________________________________________________________________________
99AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
100{
101 Fatal("operator =", "assignment operator not implemented");
102 return *this;
103}
104
54472e4f 105
106//______________________________________________________________________________________________
107void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
108 UInt_t endTime)
109{
bb30a935 110 // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start
54472e4f 111
dca91b3f 112 UInt_t startTimeLocal = startTime-3600;
113 UInt_t endTimeLocal = endTime+1800;
bb30a935 114
dca91b3f 115 AliPreprocessor::Initialize(run, startTimeLocal, endTimeLocal);
54472e4f 116
117 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
f4a89669 118 TTimeStamp((time_t)startTime,0).AsString(),
119 TTimeStamp((time_t)endTime,0).AsString()));
54472e4f 120
7b54c8e9 121 // Preprocessor configuration
122
37092b2b 123 AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
7b54c8e9 124 if (entry) fConfEnv = (TEnv*) entry->GetObject();
125 if ( fConfEnv==0 ) {
7b54c8e9 126 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
37092b2b 127 fConfigOK = kFALSE;
128 return;
7b54c8e9 129 }
130
18eade96 131 // Temperature sensors
132
136e44f7 133 TTree *confTree = 0;
134
135 TString tempConf = fConfEnv->GetValue("Temperature","ON");
136 tempConf.ToUpper();
137 if (tempConf != "OFF" ) {
7b54c8e9 138 entry = GetFromOCDB("Config", "Temperature");
f7f602cc 139 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 140 if ( confTree==0 ) {
18eade96 141 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
142 fConfigOK = kFALSE;
f7f602cc 143 return;
18eade96 144 }
dca91b3f 145 fTemp = new AliTPCSensorTempArray(startTimeLocal, endTimeLocal, confTree, kAmandaTemp);
18eade96 146 fTemp->SetValCut(kValCutTemp);
147 fTemp->SetDiffCut(kDiffCutTemp);
136e44f7 148 }
18eade96 149
bdffc5fb 150 // High voltage measurements
151
136e44f7 152 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
153 hvConf.ToUpper();
154 if (hvConf != "OFF" ) {
bdffc5fb 155 confTree=0;
156 entry=0;
157 entry = GetFromOCDB("Config", "HighVoltage");
158 if (entry) confTree = (TTree*) entry->GetObject();
159 if ( confTree==0 ) {
160 Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
161 fConfigOK = kFALSE;
162 return;
163 }
dca91b3f 164 fHighVoltage = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree);
bff20895 165 }
9d2ce539 166
167 // High voltage status values
168
bff20895 169 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
170 hvStatConf.ToUpper();
171 if (hvStatConf != "OFF" ) {
9d2ce539 172 confTree=0;
173 entry=0;
174 entry = GetFromOCDB("Config", "HighVoltageStat");
175 if (entry) confTree = (TTree*) entry->GetObject();
176 if ( confTree==0 ) {
177 Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
178 fConfigOK = kFALSE;
179 return;
180 }
dca91b3f 181 fHighVoltageStat = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree);
bdffc5fb 182 }
54472e4f 183}
184
185//______________________________________________________________________________________________
186UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
187{
188 // Fills data into TPC calibrations objects
189
54472e4f 190 // Amanda servers provide information directly through dcsAliasMap
191
bb30a935 192
a7dce0bc 193 if (!fConfigOK) return 9;
136e44f7 194 UInt_t result = 0;
bb30a935 195 TObjArray *resultArray = new TObjArray();
196 TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
197 errorHandling.ToUpper();
198 TObject * status;
199
200 UInt_t dcsResult=0;
201 if (errorHandling == "OFF" ) {
202 if (!dcsAliasMap) dcsResult=1;
203 if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
204 status = new TParameter<int>("dcsResult",dcsResult);
205 resultArray->Add(status);
206 } else {
207 if (!dcsAliasMap) return 9;
208 if (dcsAliasMap->GetEntries() == 0 ) return 9;
209 }
210
211
212
a7dce0bc 213
214 TString runType = GetRunType();
215
54472e4f 216 // Temperature sensors are processed by AliTPCCalTemp
72df5829 217
136e44f7 218 TString tempConf = fConfEnv->GetValue("Temperature","ON");
219 tempConf.ToUpper();
220 if (tempConf != "OFF" ) {
221 UInt_t tempResult = MapTemperature(dcsAliasMap);
222 result=tempResult;
bb30a935 223 status = new TParameter<int>("tempResult",tempResult);
224 resultArray->Add(status);
136e44f7 225 }
18eade96 226
bdffc5fb 227 // High Voltage recordings
228
229
136e44f7 230 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
231 hvConf.ToUpper();
232 if (hvConf != "OFF" ) {
233 UInt_t hvResult = MapHighVoltage(dcsAliasMap);
234 result+=hvResult;
bb30a935 235 status = new TParameter<int>("hvResult",hvResult);
236 resultArray->Add(status);
bdffc5fb 237 }
f7f602cc 238
54472e4f 239 // Other calibration information will be retrieved through FXS files
a7dce0bc 240 // examples:
54472e4f 241 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
242 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
243 //
244 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
245 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
246
9f016d99 247 // pedestal entries
54472e4f 248
a7dce0bc 249 if(runType == kPedestalRunType) {
68b512ca 250 Int_t numSources = 1;
251 Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
7b54c8e9 252 TString source = fConfEnv->GetValue("Pedestal","DAQ");
253 source.ToUpper();
136e44f7 254 if (source != "OFF" ) {
255 if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
256 if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
257 if (source == "HLTDAQ" ) {
258 numSources=2;
259 pedestalSource[0] = AliShuttleInterface::kHLT;
260 pedestalSource[1] = AliShuttleInterface::kDAQ;
261 }
262 if (source == "DAQHLT" ) numSources=2;
263 UInt_t pedestalResult=0;
264 for (Int_t i=0; i<numSources; i++ ) {
453bd596 265 pedestalResult = ExtractPedestals(pedestalSource[i]);
136e44f7 266 if ( pedestalResult == 0 ) break;
267 }
268 result += pedestalResult;
bb30a935 269 status = new TParameter<int>("pedestalResult",pedestalResult);
270 resultArray->Add(status);
68b512ca 271 }
a7dce0bc 272 }
273
9f016d99 274 // pulser trigger processing
275
68b512ca 276 if(runType == kPulserRunType) {
277 Int_t numSources = 1;
278 Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 279 TString source = fConfEnv->GetValue("Pulser","DAQ");
280 source.ToUpper();
136e44f7 281 if ( source != "OFF") {
282 if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
283 if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
284 if (source == "HLTDAQ" ) {
285 numSources=2;
286 pulserSource[0] = AliShuttleInterface::kHLT;
287 pulserSource[1] = AliShuttleInterface::kDAQ;
288 }
289 if (source == "DAQHLT" ) numSources=2;
290 UInt_t pulserResult=0;
291 for (Int_t i=0; i<numSources; i++ ) {
292 pulserResult = ExtractPulser(pulserSource[i]);
293 if ( pulserResult == 0 ) break;
294 }
295 result += pulserResult;
bb30a935 296 status = new TParameter<int>("pulserResult",pulserResult);
297 resultArray->Add(status);
68b512ca 298 }
9f016d99 299 }
300
68b512ca 301
302
9f016d99 303 // Central Electrode processing
304
9d2ce539 305 if( runType == kPhysicsRunType || runType == kStandAloneRunType ||
306 runType == kDaqRunType ) {
68b512ca 307
9d2ce539 308// if (true) { // do CE processing for all run types
68b512ca 309 Int_t numSources = 1;
310 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 311 TString source = fConfEnv->GetValue("CE","DAQ");
312 source.ToUpper();
136e44f7 313 if ( source != "OFF" ) {
314 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
315 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
316 if (source == "HLTDAQ" ) {
68b512ca 317 numSources=2;
318 ceSource[0] = AliShuttleInterface::kHLT;
319 ceSource[1] = AliShuttleInterface::kDAQ;
136e44f7 320 }
321 if (source == "DAQHLT" ) numSources=2;
322 UInt_t ceResult=0;
323 for (Int_t i=0; i<numSources; i++ ) {
324 ceResult = ExtractCE(ceSource[i]);
325 if ( ceResult == 0 ) break;
326 }
327 result += ceResult;
bb30a935 328 status = new TParameter<int>("ceResult",ceResult);
329 resultArray->Add(status);
dca91b3f 330
331 numSources = 1;
332 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
333 TString source = fConfEnv->GetValue("QA","DAQ");
334 source.ToUpper();
335 if ( source != "OFF" ) {
336 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
337 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
338 if (source == "HLTDAQ" ) {
339 numSources=2;
340 qaSource[0] = AliShuttleInterface::kHLT;
341 qaSource[1] = AliShuttleInterface::kDAQ;
342 }
343 if (source == "DAQHLT" ) numSources=2;
344 UInt_t qaResult=0;
345 for (Int_t i=0; i<numSources; i++ ) {
346 qaResult = ExtractQA(qaSource[i]);
347 if ( qaResult == 0 ) break;
348 }
349// result += qaResult;
350 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
351 status = new TParameter<int>("qaResult",qaResult);
352 resultArray->Add(status);
68b512ca 353 }
dca91b3f 354 }
9f016d99 355 }
136e44f7 356
136e44f7 357 if (errorHandling == "OFF" ) {
bb30a935 358 AliCDBMetaData metaData;
359 metaData.SetBeamPeriod(0);
360 metaData.SetResponsible("Haavard Helstrup");
361 metaData.SetComment("Preprocessor AliTPC status.");
362 Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
363 resultArray->Delete();
364 return 0;
136e44f7 365 } else {
bb30a935 366 return result;
136e44f7 367 }
54472e4f 368}
369//______________________________________________________________________________________________
370UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
371{
372
373 // extract DCS temperature maps. Perform fits to save space
374
72df5829 375 UInt_t result=0;
54472e4f 376 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
377 if (map) {
378 fTemp->MakeSplineFit(map);
68b512ca 379 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
67a165ed 380 if (fitFraction > kFitFraction ) {
381 AliInfo(Form("Temperature values extracted, fits performed.\n"));
382 } else {
383 Log ("Too few temperature maps fitted. \n");
384 result = 9;
385 }
54472e4f 386 } else {
67a165ed 387 Log("No temperature map extracted. \n");
72df5829 388 result=9;
54472e4f 389 }
390 delete map;
391 // Now store the final CDB file
a7dce0bc 392
393 if ( result == 0 ) {
72df5829 394 AliCDBMetaData metaData;
54472e4f 395 metaData.SetBeamPeriod(0);
396 metaData.SetResponsible("Haavard Helstrup");
397 metaData.SetComment("Preprocessor AliTPC data base entries.");
398
a7dce0bc 399 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
400 if ( !storeOK ) result=1;
401
72df5829 402 }
54472e4f 403
404 return result;
7b54c8e9 405
54472e4f 406}
7b54c8e9 407
bdffc5fb 408//______________________________________________________________________________________________
409UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
410{
411
412 // extract DCS HV maps. Perform fits to save space
413
414 UInt_t result=0;
415 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
416 if (map) {
417 fHighVoltage->MakeSplineFit(map);
68b512ca 418 Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors();
bdffc5fb 419 if (fitFraction > kFitFraction ) {
136e44f7 420 AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
bdffc5fb 421 } else {
422 Log ("Too few high voltage recordings fitted. \n");
423 result = 9;
424 }
425 } else {
426 Log("No high voltage recordings extracted. \n");
427 result=9;
428 }
429 delete map;
9d2ce539 430
bff20895 431 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
432 hvStatConf.ToUpper();
433 if (hvStatConf != "OFF" ) {
434 TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
435 if (map2) {
dca91b3f 436 fHighVoltageStat->ClearFit();
437 fHighVoltageStat->SetGraph(map2);
bff20895 438 } else {
439 Log("No high voltage status recordings extracted. \n");
440 result=9;
441 }
442 delete map2;
9d2ce539 443
bff20895 444 // add status maps to high voltage sensor array
9d2ce539 445
bff20895 446 fHighVoltage->AddSensors(fHighVoltageStat);
447 }
bdffc5fb 448 // Now store the final CDB file
449
450 if ( result == 0 ) {
451 AliCDBMetaData metaData;
452 metaData.SetBeamPeriod(0);
453 metaData.SetResponsible("Haavard Helstrup");
454 metaData.SetComment("Preprocessor AliTPC data base entries.");
455
456 Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
457 if ( !storeOK ) result=1;
458
459 }
460
461 return result;
462
463}
464
7b54c8e9 465
a7dce0bc 466//______________________________________________________________________________________________
7b54c8e9 467
468UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
a7dce0bc 469{
470 //
471 // Read pedestal file from file exchage server
472 // Keep original entry from OCDB in case no new pedestals are available
473 //
474 AliTPCCalPad *calPadPed=0;
475 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
476 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
477 if ( calPadPed==NULL ) {
a7dce0bc 478 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
7b54c8e9 479 calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
480 }
481
482 AliTPCCalPad *calPadRMS=0;
d63b9ad7 483 entry = GetFromOCDB("Calib", "PadNoise");
7b54c8e9 484 if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
485 if ( calPadRMS==NULL ) {
7b54c8e9 486 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
487 calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
a7dce0bc 488 }
489
7b54c8e9 490
a7dce0bc 491 UInt_t result=0;
492
493 Int_t nSectors = fROC->GetNSectors();
7b54c8e9 494 TList* list = GetFileSources(sourceFXS,"pedestals");
9f016d99 495
496 if (list && list->GetEntries()>0) {
a7dce0bc 497
498// loop through all files from LDCs
499
bdffc5fb 500 Bool_t changed=false;
a7dce0bc 501 UInt_t index = 0;
502 while (list->At(index)!=NULL) {
503 TObjString* fileNameEntry = (TObjString*) list->At(index);
504 if (fileNameEntry!=NULL) {
7b54c8e9 505 TString fileName = GetFile(sourceFXS, "pedestals",
a7dce0bc 506 fileNameEntry->GetString().Data());
507 TFile *f = TFile::Open(fileName);
9f016d99 508 if (!f) {
509 Log ("Error opening pedestal file.");
510 result =2;
511 break;
512 }
a7dce0bc 513 AliTPCCalibPedestal *calPed;
e73181c9 514 f->GetObject("tpcCalibPedestal",calPed);
67a165ed 515 if ( !calPed ) {
516 Log ("No pedestal calibration object in file.");
517 result = 2;
518 break;
519 }
a7dce0bc 520
521 // replace entries for the sectors available in the present file
522
bdffc5fb 523 changed=true;
c9c23d80 524 for (Int_t sector=0; sector<nSectors; sector++) {
7b54c8e9 525 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
526 if ( rocPed ) calPadPed->SetCalROC(rocPed,sector);
527 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
528 if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector);
a7dce0bc 529 }
a480de15 530 delete calPed;
342d3b42 531 f->Close();
a7dce0bc 532 }
533 ++index;
534 } // while(list)
535//
536// Store updated pedestal entry to OCDB
537//
bdffc5fb 538 if (changed) {
539 AliCDBMetaData metaData;
540 metaData.SetBeamPeriod(0);
541 metaData.SetResponsible("Haavard Helstrup");
542 metaData.SetComment("Preprocessor AliTPC data base entries.");
543
544 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
545 if ( !storeOK ) ++result;
546 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
547 if ( !storeOK ) ++result;
548 }
9f016d99 549 } else {
67a165ed 550 Log ("Error: no entries in input file list!");
9f016d99 551 result = 1;
7b54c8e9 552 }
a7dce0bc 553
a7dce0bc 554 return result;
555}
7b54c8e9 556
557//______________________________________________________________________________________________
558
559
9f016d99 560UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
561{
562 //
563 // Read pulser calibration file from file exchage server
564 // Keep original entry from OCDB in case no new pulser calibration is available
565 //
566 TObjArray *pulserObjects=0;
567 AliTPCCalPad *pulserTmean=0;
568 AliTPCCalPad *pulserTrms=0;
569 AliTPCCalPad *pulserQmean=0;
570 AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
571 if (entry) pulserObjects = (TObjArray*)entry->GetObject();
572 if ( pulserObjects==NULL ) {
573 Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
574 pulserObjects = new TObjArray;
575 }
576
577 pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
578 if ( !pulserTmean ) {
579 pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
580 pulserObjects->Add(pulserTmean);
581 }
582 pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
583 if ( !pulserTrms ) {
584 pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
585 pulserObjects->Add(pulserTrms);
586 }
587 pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
588 if ( !pulserQmean ) {
589 pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
590 pulserObjects->Add(pulserQmean);
591 }
592
593
594 UInt_t result=0;
595
596 Int_t nSectors = fROC->GetNSectors();
597 TList* list = GetFileSources(sourceFXS,"pulser");
598
599 if (list && list->GetEntries()>0) {
600
601// loop through all files from LDCs
602
bdffc5fb 603 Bool_t changed=false;
9f016d99 604 UInt_t index = 0;
605 while (list->At(index)!=NULL) {
606 TObjString* fileNameEntry = (TObjString*) list->At(index);
607 if (fileNameEntry!=NULL) {
608 TString fileName = GetFile(sourceFXS, "pulser",
609 fileNameEntry->GetString().Data());
610 TFile *f = TFile::Open(fileName);
611 if (!f) {
612 Log ("Error opening pulser file.");
613 result =2;
614 break;
615 }
616 AliTPCCalibPulser *calPulser;
e73181c9 617 f->GetObject("tpcCalibPulser",calPulser);
67a165ed 618 if ( !calPulser ) {
619 Log ("No pulser calibration object in file.");
620 result = 2;
621 break;
622 }
9f016d99 623
624 // replace entries for the sectors available in the present file
625
bdffc5fb 626 changed=true;
9f016d99 627 for (Int_t sector=0; sector<nSectors; sector++) {
628 AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
629 if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector);
630 AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
631 if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector);
632 AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
633 if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector);
634 }
a480de15 635 delete calPulser;
342d3b42 636 f->Close();
9f016d99 637 }
638 ++index;
639 } // while(list)
640//
641// Store updated pedestal entry to OCDB
642//
bdffc5fb 643 if (changed) {
644 AliCDBMetaData metaData;
645 metaData.SetBeamPeriod(0);
646 metaData.SetResponsible("Haavard Helstrup");
647 metaData.SetComment("Preprocessor AliTPC data base entries.");
648
649 Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
650 if ( !storeOK ) ++result;
651 }
9f016d99 652 } else {
67a165ed 653 Log ("Error: no entries in input file list!");
9f016d99 654 result = 1;
655 }
656
657 return result;
658}
659
660UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
661{
662 //
663 // Read Central Electrode file from file exchage server
664 // Keep original entry from OCDB in case no new CE calibration is available
665 //
666 TObjArray *ceObjects=0;
667 AliTPCCalPad *ceTmean=0;
668 AliTPCCalPad *ceTrms=0;
669 AliTPCCalPad *ceQmean=0;
bb30a935 670 TObjArray *rocTtime=0;
671 TObjArray *rocQtime=0;
672
9f016d99 673 AliCDBEntry* entry = GetFromOCDB("Calib", "CE");
674 if (entry) ceObjects = (TObjArray*)entry->GetObject();
675 if ( ceObjects==NULL ) {
676 Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n");
677 ceObjects = new TObjArray;
678 }
679
bb30a935 680 Int_t nSectors = fROC->GetNSectors();
681
9f016d99 682 ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean");
683 if ( !ceTmean ) {
684 ceTmean = new AliTPCCalPad("CETmean","CETmean");
685 ceObjects->Add(ceTmean);
686 }
687 ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms");
688 if ( !ceTrms ) {
689 ceTrms = new AliTPCCalPad("CETrms","CETrms");
690 ceObjects->Add(ceTrms);
691 }
692 ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean");
693 if ( !ceQmean ) {
694 ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
695 ceObjects->Add(ceQmean);
696 }
38fcad6d 697 //!new from here please have a look!!!
698 rocTtime = (TObjArray*)ceObjects->FindObject("rocTtime");
699 if ( !rocTtime ) {
bb30a935 700 rocTtime = new TObjArray(nSectors);
38fcad6d 701 rocTtime->SetName("rocTtime");
702 ceObjects->Add(rocTtime);
703 }
bb30a935 704
705 rocQtime = (TObjArray*)ceObjects->FindObject("rocQtime");
38fcad6d 706 if ( !rocQtime ) {
bb30a935 707 rocQtime = new TObjArray(nSectors);
38fcad6d 708 rocQtime->SetName("rocQtime");
709 ceObjects->Add(rocQtime);
710 }
9f016d99 711
712
713 UInt_t result=0;
714
9f016d99 715 TList* list = GetFileSources(sourceFXS,"CE");
716
717 if (list && list->GetEntries()>0) {
718
719// loop through all files from LDCs
720
721 UInt_t index = 0;
722 while (list->At(index)!=NULL) {
723 TObjString* fileNameEntry = (TObjString*) list->At(index);
724 if (fileNameEntry!=NULL) {
725 TString fileName = GetFile(sourceFXS, "CE",
726 fileNameEntry->GetString().Data());
727 TFile *f = TFile::Open(fileName);
728 if (!f) {
729 Log ("Error opening central electrode file.");
730 result =2;
731 break;
732 }
733 AliTPCCalibCE *calCE;
e73181c9 734 f->GetObject("tpcCalibCE",calCE);
9f016d99 735
736 // replace entries for the sectors available in the present file
737
738 for (Int_t sector=0; sector<nSectors; sector++) {
739 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
740 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
741 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
742 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
743 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
38fcad6d 744 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
bb30a935 745 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
746 if ( grT ) rocTtime->AddAt(grT,sector);
747 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
748 if ( grQ ) rocTtime->AddAt(grQ,sector);
9f016d99 749 }
a480de15 750 delete calCE;
342d3b42 751 f->Close();
9f016d99 752 }
753 ++index;
754 } // while(list)
755//
756// Store updated pedestal entry to OCDB
757//
758 AliCDBMetaData metaData;
759 metaData.SetBeamPeriod(0);
760 metaData.SetResponsible("Haavard Helstrup");
761 metaData.SetComment("Preprocessor AliTPC data base entries.");
762
763 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
764 if ( !storeOK ) ++result;
765
766 } else {
767 Log ("Error: no entries!");
768 result = 1;
769 }
770
771 return result;
772}
dca91b3f 773//______________________________________________________________________________________________
774
775UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
776{
777 //
778 // Read Quality Assurance file from file exchage server
779 //
780
781 UInt_t result=0;
782
783 TList* list = GetFileSources(sourceFXS,"QA");
784
785 if (list && list->GetEntries()>0) {
786
787// only one QA objetc should be available!
788
789 AliTPCdataQA *calQA;
790
791 UInt_t nentries = list->GetEntries();
792 UInt_t index=0;
793 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
794 TObjString* fileNameEntry = (TObjString*) list->At(index);
795 if (fileNameEntry!=NULL) {
796 TString fileName = GetFile(sourceFXS, "QA",
797 fileNameEntry->GetString().Data());
798 TFile *f = TFile::Open(fileName);
799 if (!f) {
800 Log ("Error opening QA file.");
a2465b54 801 result =2;
802 } else {
803 f->GetObject("tpcCalibQA",calQA);
804
dca91b3f 805//
806// Store updated pedestal entry to OCDB
807//
a2465b54 808 AliCDBMetaData metaData;
809 metaData.SetBeamPeriod(0);
810 metaData.SetResponsible("Haavard Helstrup");
811 metaData.SetComment("Preprocessor AliTPC data base entries.");
dca91b3f 812
a2465b54 813 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kTRUE);
814 if ( !storeOK ) ++result;
815 }
816 } else {
817 Log ("Error: no QA files on FXS!");
818 result = 2;
819 }
dca91b3f 820 } else {
a2465b54 821 Log ("Error: no QA entries in FXS list!");
dca91b3f 822 result = 1;
823 }
dca91b3f 824 return result;
825}
826