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