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