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