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