CMake: Retrieve Git information
[u/mrichter/AliRoot.git] / TPC / TPCbase / 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"
70f224dd 30#include "AliTPCCalibRaw.h"
dca91b3f 31#include "AliTPCdataQA.h"
eeeac1b2 32#include "ARVersion.h"
9e66a8dd 33#include "TFile.h"
7b54c8e9 34#include "TTree.h"
40ec49dc 35#include "TGraph.h"
7b54c8e9 36#include "TEnv.h"
bb30a935 37#include "TParameter.h"
54472e4f 38
39#include <TTimeStamp.h>
40
40ec49dc 41const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
42const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
43const Double_t kHighVoltageDifference = 1e-4; // don't record High Voltage points
2b00f997 44 // differing by less than 1e-4 from
45 // previous point.
40ec49dc 46const Double_t kGasCompositionDifference = 1e-3; // don't record Gas Composition points
41c979ea 47 // differing by less than 1e-3 from
48 // previous point
40ec49dc 49const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
50const TString kPulserRunType = "PULSER"; // pulser run identifier
51const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
52const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
53const TString kLaserRunType = "LASER"; // laser run identifier
54const TString kDaqRunType = "DAQ"; // DAQ run identifier
55const TString kStandaloneRunType = "STANDALONE"; // STANDALONE run identifier
56const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
57const TString kAmandaDDL = "DDL%d"; // Amanda string for list of active DDLs
58const Int_t kNumDDL = 216; // number of TPC DDLs
59const Int_t kFirstDDL = 768; // identifier of first DDL
60//const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
61const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
62const Int_t kNumPressureSensors = 3; // number of pressure sensors
09a746c5 63const char* kPressureSensorNames[kNumPressureSensors] = {
64 "CavernAtmosPressure",
65 "CavernAtmosPressure2",
66 "SurfaceAtmosPressure" };
40ec49dc 67const Int_t kMinCESectors = 32; // minimum number of sectors (per side)
1fc96a8a 68 // to accept CE calibration
40ec49dc 69
cf4216a3 70
54472e4f 71//
72// This class is the SHUTTLE preprocessor for the TPC detector.
54472e4f 73//
74
75ClassImp(AliTPCPreprocessor)
76
77//______________________________________________________________________________________________
6d07bf74 78AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
79 AliPreprocessor("TPC",shuttle),
09a746c5 80 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
41c979ea 81 fPressure(0), fGasComposition(0), fConfigOK(kTRUE), fROC(0)
54472e4f 82{
83 // constructor
a7dce0bc 84 fROC = AliTPCROC::Instance();
72534123 85
86 // define run types to be processed
40ec49dc 87
72534123 88 AddRunType(kPedestalRunType);
89 AddRunType(kPulserRunType);
90 AddRunType(kPhysicsRunType);
72534123 91 AddRunType(kCosmicRunType);
92 AddRunType(kLaserRunType);
93 AddRunType(kDaqRunType);
57588877 94 AddRunType(kStandaloneRunType);
40ec49dc 95
54472e4f 96}
72df5829 97//______________________________________________________________________________________________
f4a89669 98 AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) :
99 AliPreprocessor("TPC",0),
09a746c5 100 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
41c979ea 101 fPressure(0), fGasComposition(0), fConfigOK(kTRUE), fROC(0)
f4a89669 102 {
103
104 Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 105//
106// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
f4a89669 107 }
54472e4f 108
109//______________________________________________________________________________________________
110AliTPCPreprocessor::~AliTPCPreprocessor()
111{
40ec49dc 112 // destructor
a7dce0bc 113
54472e4f 114 delete fTemp;
bdffc5fb 115 delete fHighVoltage;
795dbd3b 116 delete fHighVoltageStat;
117 delete fGoofie;
33f6bae5 118 delete fGasComposition;
09a746c5 119 delete fPressure;
54472e4f 120}
72df5829 121//______________________________________________________________________________________________
122AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
123{
124 Fatal("operator =", "assignment operator not implemented");
125 return *this;
126}
127
54472e4f 128
129//______________________________________________________________________________________________
130void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
131 UInt_t endTime)
132{
bb30a935 133
09a746c5 134 AliPreprocessor::Initialize(run, startTime, endTime);
54472e4f 135
136 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
f4a89669 137 TTimeStamp((time_t)startTime,0).AsString(),
138 TTimeStamp((time_t)endTime,0).AsString()));
54472e4f 139
7b54c8e9 140 // Preprocessor configuration
141
37092b2b 142 AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
7b54c8e9 143 if (entry) fConfEnv = (TEnv*) entry->GetObject();
144 if ( fConfEnv==0 ) {
7b54c8e9 145 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
37092b2b 146 fConfigOK = kFALSE;
147 return;
7b54c8e9 148 }
149
18eade96 150 // Temperature sensors
151
136e44f7 152 TTree *confTree = 0;
153
154 TString tempConf = fConfEnv->GetValue("Temperature","ON");
155 tempConf.ToUpper();
156 if (tempConf != "OFF" ) {
7b54c8e9 157 entry = GetFromOCDB("Config", "Temperature");
f7f602cc 158 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 159 if ( confTree==0 ) {
18eade96 160 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
161 fConfigOK = kFALSE;
f7f602cc 162 return;
18eade96 163 }
09a746c5 164 fTemp = new AliTPCSensorTempArray(startTime, endTime, confTree, kAmandaTemp);
18eade96 165 fTemp->SetValCut(kValCutTemp);
166 fTemp->SetDiffCut(kDiffCutTemp);
136e44f7 167 }
18eade96 168
bdffc5fb 169 // High voltage measurements
170
136e44f7 171 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
172 hvConf.ToUpper();
40ec49dc 173 if (hvConf != "OFF" ) {
bdffc5fb 174 confTree=0;
175 entry=0;
176 entry = GetFromOCDB("Config", "HighVoltage");
177 if (entry) confTree = (TTree*) entry->GetObject();
178 if ( confTree==0 ) {
179 Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
180 fConfigOK = kFALSE;
181 return;
182 }
03d57022 183 time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
184 time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
40ec49dc 185 fHighVoltage = new AliDCSSensorArray (UInt_t(timeStart),
03d57022 186 UInt_t(timeEnd), confTree);
bff20895 187 }
9d2ce539 188
189 // High voltage status values
40ec49dc 190
bff20895 191 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
192 hvStatConf.ToUpper();
40ec49dc 193 if (hvStatConf != "OFF" ) {
9d2ce539 194 confTree=0;
195 entry=0;
196 entry = GetFromOCDB("Config", "HighVoltageStat");
197 if (entry) confTree = (TTree*) entry->GetObject();
198 if ( confTree==0 ) {
199 Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
200 fConfigOK = kFALSE;
201 return;
202 }
fe7f3fe2 203 fHighVoltageStat = new AliDCSSensorArray(startTime, endTime, confTree);
bdffc5fb 204 }
b6e9fd45 205
206 // Goofie values
40ec49dc 207
b6e9fd45 208 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
209 goofieConf.ToUpper();
40ec49dc 210 if (goofieConf != "OFF" ) {
b6e9fd45 211 confTree=0;
212 entry=0;
213 entry = GetFromOCDB("Config", "Goofie");
214 if (entry) confTree = (TTree*) entry->GetObject();
215 if ( confTree==0 ) {
216 Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
217 fConfigOK = kFALSE;
218 return;
219 }
09a746c5 220 fGoofie = new AliDCSSensorArray(startTime, endTime, confTree);
b6e9fd45 221 }
222
41c979ea 223
224 // Gas composition measurements
225
226 TString gasConf = fConfEnv->GetValue("GasComposition","OFF");
227 gasConf.ToUpper();
40ec49dc 228 if (gasConf != "OFF" ) {
41c979ea 229 confTree=0;
230 entry=0;
231 entry = GetFromOCDB("Config", "GasComposition");
232 if (entry) confTree = (TTree*) entry->GetObject();
233 if ( confTree==0 ) {
234 Log("AliTPCPreprocsessor: Gas Composition Config OCDB entry missing.\n");
235 fConfigOK = kFALSE;
236 return;
237 }
238 time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
239 time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
40ec49dc 240 fGasComposition = new AliDCSSensorArray (UInt_t(timeStart),
41c979ea 241 UInt_t(timeEnd), confTree);
242 }
09a746c5 243 // Pressure values
40ec49dc 244
09a746c5 245 TString runType = GetRunType();
246
40ec49dc 247 if( runType == kPhysicsRunType ||
248 runType == kLaserRunType || runType == kStandaloneRunType ) {
09a746c5 249 TString pressureConf = fConfEnv->GetValue("Pressure","ON");
250 pressureConf.ToUpper();
40ec49dc 251 if (pressureConf != "OFF" ) {
252 TClonesArray * array = new TClonesArray("AliDCSSensor",kNumPressureSensors);
09a746c5 253 for(Int_t j = 0; j < kNumPressureSensors; j++) {
254 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
255 sens->SetStringID(kPressureSensorNames[j]);
256 }
257 fPressure = new AliDCSSensorArray(startTime, endTime, array);
258 }
259 }
54472e4f 260}
261
262//______________________________________________________________________________________________
263UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
264{
40ec49dc 265 // Fills data into TPC calibrations objects
54472e4f 266
54472e4f 267 // Amanda servers provide information directly through dcsAliasMap
268
40ec49dc 269
a7dce0bc 270 if (!fConfigOK) return 9;
136e44f7 271 UInt_t result = 0;
bb30a935 272 TObjArray *resultArray = new TObjArray();
273 TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
274 errorHandling.ToUpper();
275 TObject * status;
276
277 UInt_t dcsResult=0;
40ec49dc 278 if (!dcsAliasMap) {
ff7d4b88 279 dcsResult=1;
280 } else {
281 if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
40ec49dc 282 }
cf4216a3 283 status = new TParameter<int>("dcsResult",dcsResult);
284 resultArray->Add(status);
bb30a935 285
286
a7dce0bc 287 TString runType = GetRunType();
288
cf4216a3 289 if ( dcsResult == 0 ) {
290
54472e4f 291 // Temperature sensors are processed by AliTPCCalTemp
72df5829 292
cf4216a3 293 TString tempConf = fConfEnv->GetValue("Temperature","ON");
294 tempConf.ToUpper();
295 if (tempConf != "OFF" ) {
296 UInt_t tempResult = MapTemperature(dcsAliasMap);
c589a949 297 if ( tempConf != "TRY") result+=tempResult;
cf4216a3 298 status = new TParameter<int>("tempResult",tempResult);
299 resultArray->Add(status);
300 }
18eade96 301
bdffc5fb 302 // High Voltage recordings
303
304
cf4216a3 305 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
306 hvConf.ToUpper();
40ec49dc 307 if (hvConf != "OFF" ) {
cf4216a3 308 UInt_t hvResult = MapHighVoltage(dcsAliasMap);
c589a949 309 if (hvConf != "TRY") result+=hvResult;
cf4216a3 310 status = new TParameter<int>("hvResult",hvResult);
311 resultArray->Add(status);
312 }
f7f602cc 313
cf4216a3 314 // Goofie values
b6e9fd45 315
316
cf4216a3 317 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
318 goofieConf.ToUpper();
40ec49dc 319 if (goofieConf != "OFF" ) {
cf4216a3 320 UInt_t goofieResult = MapGoofie(dcsAliasMap);
c589a949 321 if (goofieConf != "TRY") result+=goofieResult;
cf4216a3 322 status = new TParameter<int>("goofieResult",goofieResult);
323 resultArray->Add(status);
324 }
09a746c5 325
41c979ea 326
327 // Gas composition recordings
328
329
88bca400 330 TString gasConf = fConfEnv->GetValue("GasComposition","OFF");
41c979ea 331 gasConf.ToUpper();
40ec49dc 332 if (gasConf != "OFF" ) {
41c979ea 333 UInt_t gasResult = MapGasComposition(dcsAliasMap);
334 if (gasConf != "TRY") result+=gasResult;
335 status = new TParameter<int>("gasResult",gasResult);
336 resultArray->Add(status);
337 }
338
09a746c5 339 // Pressure values
340
341 if( runType == kPhysicsRunType ||
57588877 342 runType == kLaserRunType || runType == kStandaloneRunType ) {
09a746c5 343
344 TString pressureConf = fConfEnv->GetValue("Pressure","ON");
345 pressureConf.ToUpper();
40ec49dc 346 if (pressureConf != "OFF" ) {
09a746c5 347 UInt_t pressureResult = MapPressure(dcsAliasMap);
348 status = new TParameter<int>("pressureResult",pressureResult);
349 resultArray->Add(status);
350 }
351 }
cf4216a3 352 }
54472e4f 353 // Other calibration information will be retrieved through FXS files
a7dce0bc 354 // examples:
54472e4f 355 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
356 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
357 //
358 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
359 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
360
9f016d99 361 // pedestal entries
54472e4f 362
a7dce0bc 363 if(runType == kPedestalRunType) {
68b512ca 364 Int_t numSources = 1;
365 Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
7b54c8e9 366 TString source = fConfEnv->GetValue("Pedestal","DAQ");
367 source.ToUpper();
40ec49dc 368 if (source != "OFF" ) {
136e44f7 369 if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
370 if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
371 if (source == "HLTDAQ" ) {
372 numSources=2;
373 pedestalSource[0] = AliShuttleInterface::kHLT;
374 pedestalSource[1] = AliShuttleInterface::kDAQ;
375 }
376 if (source == "DAQHLT" ) numSources=2;
377 UInt_t pedestalResult=0;
40ec49dc 378 for (Int_t i=0; i<numSources; i++ ) {
453bd596 379 pedestalResult = ExtractPedestals(pedestalSource[i]);
136e44f7 380 if ( pedestalResult == 0 ) break;
381 }
382 result += pedestalResult;
bb30a935 383 status = new TParameter<int>("pedestalResult",pedestalResult);
384 resultArray->Add(status);
68b512ca 385 }
a7dce0bc 386 }
387
9f016d99 388 // pulser trigger processing
389
68b512ca 390 if(runType == kPulserRunType) {
391 Int_t numSources = 1;
392 Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 393 TString source = fConfEnv->GetValue("Pulser","DAQ");
394 source.ToUpper();
40ec49dc 395 if ( source != "OFF") {
136e44f7 396 if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
397 if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
398 if (source == "HLTDAQ" ) {
399 numSources=2;
400 pulserSource[0] = AliShuttleInterface::kHLT;
401 pulserSource[1] = AliShuttleInterface::kDAQ;
402 }
403 if (source == "DAQHLT" ) numSources=2;
20f17bef 404 if (source == "TRY" ) numSources=1;
136e44f7 405 UInt_t pulserResult=0;
40ec49dc 406 for (Int_t i=0; i<numSources; i++ ) {
136e44f7 407 pulserResult = ExtractPulser(pulserSource[i]);
408 if ( pulserResult == 0 ) break;
409 }
c589a949 410 if (source != "TRY") result += pulserResult;
bb30a935 411 status = new TParameter<int>("pulserResult",pulserResult);
412 resultArray->Add(status);
68b512ca 413 }
9f016d99 414 }
415
70f224dd 416
417// raw calibration processing
418
419 if(runType == kPhysicsRunType) {
420 Int_t numSources = 1;
421 Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
422 TString source = fConfEnv->GetValue("Raw","DAQ");
423 source.ToUpper();
40ec49dc 424 if ( source != "OFF") {
70f224dd 425 if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
426 if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
427 if (source == "HLTDAQ" ) {
428 numSources=2;
429 rawSource[0] = AliShuttleInterface::kHLT;
430 rawSource[1] = AliShuttleInterface::kDAQ;
431 }
432 if (source == "DAQHLT" ) numSources=2;
20f17bef 433 if (source == "TRY" ) numSources=1;
70f224dd 434 UInt_t rawResult=0;
40ec49dc 435 for (Int_t i=0; i<numSources; i++ ) {
70f224dd 436 rawResult = ExtractRaw(rawSource[i]);
437 if ( rawResult == 0 ) break;
438 }
c589a949 439 if (source != "TRY" )result += rawResult;
70f224dd 440 status = new TParameter<int>("rawResult",rawResult);
441 resultArray->Add(status);
442 }
443 }
444
445
9054511b 446 // Altro configuration
447
448
449 TString altroConf = fConfEnv->GetValue("AltroConf","ON");
cf4216a3 450 altroConf.ToUpper();
40ec49dc 451 if (altroConf != "OFF" ) {
f6b5fa33 452 UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS,dcsAliasMap);
c589a949 453 if (altroConf != "TRY" ) result+=altroResult;
9054511b 454 status = new TParameter<int>("altroResult",altroResult);
455 resultArray->Add(status);
57588877 456 }
68b512ca 457
458
9f016d99 459 // Central Electrode processing
460
40ec49dc 461 if( runType == kPhysicsRunType ||
462 runType == kLaserRunType ) {
68b512ca 463
464 Int_t numSources = 1;
465 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 466 TString source = fConfEnv->GetValue("CE","DAQ");
467 source.ToUpper();
40ec49dc 468 if ( source != "OFF" ) {
136e44f7 469 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
470 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
471 if (source == "HLTDAQ" ) {
68b512ca 472 numSources=2;
473 ceSource[0] = AliShuttleInterface::kHLT;
474 ceSource[1] = AliShuttleInterface::kDAQ;
136e44f7 475 }
476 if (source == "DAQHLT" ) numSources=2;
20f17bef 477 if (source == "TRY" ) numSources=1;
136e44f7 478 UInt_t ceResult=0;
40ec49dc 479 for (Int_t i=0; i<numSources; i++ ) {
136e44f7 480 ceResult = ExtractCE(ceSource[i]);
481 if ( ceResult == 0 ) break;
482 }
6f3699dd 483
484 // only flag error if CE result is missing from LASER runs
485 // -- for PHYSICS run do CE processing if data available
40ec49dc 486
dee76880 487 if ( runType == kLaserRunType && source != "TRY" && ceResult<10 ) result += ceResult;
bb30a935 488 status = new TParameter<int>("ceResult",ceResult);
489 resultArray->Add(status);
dca91b3f 490
491 numSources = 1;
492 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
5e5c1e83 493 source = fConfEnv->GetValue("QA","DAQ");
dca91b3f 494 source.ToUpper();
40ec49dc 495 if ( source != "OFF" ) {
dca91b3f 496 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
497 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
498 if (source == "HLTDAQ" ) {
499 numSources=2;
500 qaSource[0] = AliShuttleInterface::kHLT;
501 qaSource[1] = AliShuttleInterface::kDAQ;
502 }
503 if (source == "DAQHLT" ) numSources=2;
20f17bef 504 if (source == "TRY" ) numSources=1;
dca91b3f 505 UInt_t qaResult=0;
40ec49dc 506 for (Int_t i=0; i<numSources; i++ ) {
dca91b3f 507 qaResult = ExtractQA(qaSource[i]);
508 if ( qaResult == 0 ) break;
509 }
510// result += qaResult;
511 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
512 status = new TParameter<int>("qaResult",qaResult);
513 resultArray->Add(status);
68b512ca 514 }
dca91b3f 515 }
9f016d99 516 }
40ec49dc 517
c589a949 518// Store component status to OCDB
519
520 AliCDBMetaData metaData;
521 metaData.SetBeamPeriod(0);
522 metaData.SetResponsible("Haavard Helstrup");
5420ed56 523 metaData.SetAliRootVersion(ALIROOT_VERSION);
c589a949 524 metaData.SetComment("Preprocessor AliTPC status.");
f085dc93 525 Bool_t storeOK = Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
526 if (!storeOK) Log ("Unable to store preprocessor status entry");
40ec49dc 527
c589a949 528 resultArray->Delete();
529 delete resultArray;
530
531 if (errorHandling == "OFF" ) return 0;
532 return result;
40ec49dc 533
54472e4f 534}
535//______________________________________________________________________________________________
536UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
537{
538
40ec49dc 539 // extract DCS temperature maps. Perform fits to save space
54472e4f 540
72df5829 541 UInt_t result=0;
54472e4f 542 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
543 if (map) {
544 fTemp->MakeSplineFit(map);
40ec49dc 545 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
67a165ed 546 if (fitFraction > kFitFraction ) {
547 AliInfo(Form("Temperature values extracted, fits performed.\n"));
40ec49dc 548 } else {
67a165ed 549 Log ("Too few temperature maps fitted. \n");
550 result = 9;
551 }
54472e4f 552 } else {
67a165ed 553 Log("No temperature map extracted. \n");
72df5829 554 result=9;
54472e4f 555 }
556 delete map;
557 // Now store the final CDB file
a7dce0bc 558
559 if ( result == 0 ) {
72df5829 560 AliCDBMetaData metaData;
54472e4f 561 metaData.SetBeamPeriod(0);
562 metaData.SetResponsible("Haavard Helstrup");
5420ed56 563 metaData.SetAliRootVersion(ALIROOT_VERSION);
54472e4f 564 metaData.SetComment("Preprocessor AliTPC data base entries.");
565
a7dce0bc 566 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
567 if ( !storeOK ) result=1;
568
72df5829 569 }
54472e4f 570
571 return result;
7b54c8e9 572
54472e4f 573}
09a746c5 574//______________________________________________________________________________________________
575UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
576{
577
40ec49dc 578 // extract DCS pressure maps. Perform fits to save space
09a746c5 579
580 UInt_t result=0;
581 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
582 if (map) {
583 fPressure->MakeSplineFit(map);
40ec49dc 584 Double_t fitFraction = 1.0*fPressure->NumFits()/fPressure->NumSensors();
09a746c5 585 if (fitFraction > kFitFraction ) {
1a63b1b0 586 AliInfo(Form("Pressure values extracted, fits performed.\n"));
40ec49dc 587 } else {
09a746c5 588 Log ("Too few pressure maps fitted. \n");
589 result = 9;
590 }
591 } else {
592 Log("No pressure map extracted. \n");
593 result=9;
594 }
595 delete map;
596 return result;
597}
7b54c8e9 598
bdffc5fb 599//______________________________________________________________________________________________
600UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
601{
602
40ec49dc 603 // extract DCS HV maps. Perform fits to save space
bdffc5fb 604
605 UInt_t result=0;
606 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
607 if (map) {
379fc89a 608 fHighVoltage->ClearFit();
2b00f997 609 fHighVoltage->RemoveGraphDuplicates(kHighVoltageDifference);
610 // don't keep new point if too similar to previous one
379fc89a 611 fHighVoltage->SetGraph(map);
bdffc5fb 612 } else {
613 Log("No high voltage recordings extracted. \n");
614 result=9;
615 }
616 delete map;
9d2ce539 617
bff20895 618 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
619 hvStatConf.ToUpper();
40ec49dc 620 if (hvStatConf != "OFF" ) {
bff20895 621 TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
622 if (map2) {
dca91b3f 623 fHighVoltageStat->ClearFit();
624 fHighVoltageStat->SetGraph(map2);
bff20895 625 } else {
626 Log("No high voltage status recordings extracted. \n");
627 result=9;
628 }
629 delete map2;
9d2ce539 630
bff20895 631 // add status maps to high voltage sensor array
9d2ce539 632
bff20895 633 fHighVoltage->AddSensors(fHighVoltageStat);
634 }
bdffc5fb 635 // Now store the final CDB file
636
637 if ( result == 0 ) {
638 AliCDBMetaData metaData;
639 metaData.SetBeamPeriod(0);
640 metaData.SetResponsible("Haavard Helstrup");
5420ed56 641 metaData.SetAliRootVersion(ALIROOT_VERSION);
bdffc5fb 642 metaData.SetComment("Preprocessor AliTPC data base entries.");
643
644 Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
645 if ( !storeOK ) result=1;
646
647 }
648
649 return result;
650
651}
652
b6e9fd45 653//______________________________________________________________________________________________
654UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
655{
656
40ec49dc 657 // extract DCS Goofie maps. Do not perform fits (low update rate)
b6e9fd45 658
659 UInt_t result=0;
660
661 TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
662 if (map) {
663 fGoofie->ClearFit();
664 fGoofie->SetGraph(map);
665 } else {
666 Log("No Goofie recordings extracted. \n");
667 result=9;
668 }
669 delete map;
670
671 // Now store the final CDB file
672
673 if ( result == 0 ) {
674 AliCDBMetaData metaData;
675 metaData.SetBeamPeriod(0);
676 metaData.SetResponsible("Haavard Helstrup");
5420ed56 677 metaData.SetAliRootVersion(ALIROOT_VERSION);
b6e9fd45 678 metaData.SetComment("Preprocessor AliTPC data base entries.");
679
680 Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
681 if ( !storeOK ) result=1;
682
683 }
684
685 return result;
686
687}
688
41c979ea 689//______________________________________________________________________________________________
690UInt_t AliTPCPreprocessor::MapGasComposition(TMap* dcsAliasMap)
691{
692
40ec49dc 693 // extract DCS HV maps. Perform fits to save space
41c979ea 694
695 UInt_t result=0;
696 TMap *map = fGasComposition->ExtractDCS(dcsAliasMap);
697 if (map) {
33f6bae5 698 fGasComposition->ClearFit();
699 fGasComposition->RemoveGraphDuplicates(kGasCompositionDifference);
41c979ea 700 // don't keep new point if too similar to previous one
33f6bae5 701 fGasComposition->SetGraph(map);
41c979ea 702 } else {
703 Log("No gas composition recordings extracted. \n");
704 result=9;
705 }
706 delete map;
707
708 // Now store the final CDB file
709
710 if ( result == 0 ) {
711 AliCDBMetaData metaData;
712 metaData.SetBeamPeriod(0);
713 metaData.SetResponsible("Haavard Helstrup");
5420ed56 714 metaData.SetAliRootVersion(ALIROOT_VERSION);
41c979ea 715 metaData.SetComment("Preprocessor AliTPC data base entries.");
716
717 Bool_t storeOK = Store("Calib", "GasComposition", fGasComposition, &metaData, 0, kFALSE);
718 if ( !storeOK ) result=1;
719
720 }
721
722 return result;
723
724}
725
7b54c8e9 726
a7dce0bc 727//______________________________________________________________________________________________
7b54c8e9 728
729UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
a7dce0bc 730{
40ec49dc 731 //
732 // Read pedestal file from file exchage server
733 // Keep original entry from OCDB in case no new pedestals are available
734 //
ccf58a39 735 AliTPCCalPad *calPadPedOCDB=0;
a7dce0bc 736 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
ccf58a39 737 if (entry) calPadPedOCDB = (AliTPCCalPad*)entry->GetObject();
738 if ( calPadPedOCDB==NULL ) {
a7dce0bc 739 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
7b54c8e9 740 }
741
ccf58a39 742 AliTPCCalPad *calPadRMSOCDB=0;
d63b9ad7 743 entry = GetFromOCDB("Calib", "PadNoise");
ccf58a39 744 if (entry) calPadRMSOCDB = (AliTPCCalPad*)entry->GetObject();
745 if ( calPadRMSOCDB==NULL ) {
7b54c8e9 746 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
a7dce0bc 747 }
748
ccf58a39 749 AliTPCCalPad* calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
750 AliTPCCalPad* calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
751
7b54c8e9 752
a7dce0bc 753 UInt_t result=0;
754
755 Int_t nSectors = fROC->GetNSectors();
ccf58a39 756 TVectorD foundSectorsPed(nSectors);
757 foundSectorsPed=0;
758 TVectorD foundSectorsRMS(nSectors);
759 foundSectorsRMS=0;
760
7b54c8e9 761 TList* list = GetFileSources(sourceFXS,"pedestals");
40ec49dc 762
9f016d99 763 if (list && list->GetEntries()>0) {
a7dce0bc 764
765// loop through all files from LDCs
766
bdffc5fb 767 Bool_t changed=false;
a7dce0bc 768 UInt_t index = 0;
769 while (list->At(index)!=NULL) {
770 TObjString* fileNameEntry = (TObjString*) list->At(index);
771 if (fileNameEntry!=NULL) {
7b54c8e9 772 TString fileName = GetFile(sourceFXS, "pedestals",
a7dce0bc 773 fileNameEntry->GetString().Data());
774 TFile *f = TFile::Open(fileName);
9f016d99 775 if (!f) {
776 Log ("Error opening pedestal file.");
777 result =2;
778 break;
779 }
a7dce0bc 780 AliTPCCalibPedestal *calPed;
e73181c9 781 f->GetObject("tpcCalibPedestal",calPed);
67a165ed 782 if ( !calPed ) {
783 Log ("No pedestal calibration object in file.");
784 result = 2;
785 break;
786 }
a7dce0bc 787
788 // replace entries for the sectors available in the present file
789
bdffc5fb 790 changed=true;
c9c23d80 791 for (Int_t sector=0; sector<nSectors; sector++) {
7b54c8e9 792 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
ccf58a39 793 if ( rocPed ) {
794 AliTPCCalROC* roc=calPadPed->GetCalROC(sector);
795 roc->Add(rocPed,1);
796 foundSectorsPed[sector]++;
797 }
7b54c8e9 798 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
ccf58a39 799 if ( rocRMS ) {
800 AliTPCCalROC* roc=calPadRMS->GetCalROC(sector);
801 roc->Add(rocRMS,1);
802 foundSectorsRMS[sector]++;
40ec49dc 803 }
a7dce0bc 804 }
40ec49dc 805 delete calPed;
342d3b42 806 f->Close();
a7dce0bc 807 }
808 ++index;
809 } // while(list)
ccf58a39 810
811//
812// Check if calibration is complete -- otherwise take from old OCDB entry
813
814// inner sectors
815 for (Int_t sector=0; sector<nSectors/2; sector++) {
816 if (foundSectorsPed[sector] < 1 ) {
f3652e39 817 if (calPadPedOCDB) {
818 AliTPCCalROC *rocOCDB=calPadPedOCDB->GetCalROC(sector);
819 calPadPed->SetCalROC(rocOCDB,sector);
820 } else {
821 const int mess_length=100;
822 char message[mess_length];
823 snprintf(message,mess_length,"Missing pedestals for sector %d - also not available from previous OCDB entry.\n",
824 sector);
825 Log (message);
826 result = 2;
827 }
ccf58a39 828 }
829 if (foundSectorsRMS[sector] < 1 ) {
f3652e39 830 if (calPadRMSOCDB) {
831 AliTPCCalROC *rocOCDB=calPadRMSOCDB->GetCalROC(sector);
832 calPadRMS->SetCalROC(rocOCDB,sector);
833 } else {
834 const int mess_length=100;
835 char message[mess_length];
836 snprintf(message,mess_length,"Missing pedestal RMS for sector %d - also not available from previous OCDB entry.\n",
837 sector);
838 Log (message);
839 result = 2;
40ec49dc 840 }
ccf58a39 841 }
842 }
f3652e39 843
ccf58a39 844// outer sectors -- two updates needed
f3652e39 845
ccf58a39 846 for (Int_t sector=nSectors/2; sector<nSectors; sector++) {
847 if (foundSectorsPed[sector] < 2 ) {
f3652e39 848 if (calPadPedOCDB) {
849 AliTPCCalROC *rocOCDB=calPadPedOCDB->GetCalROC(sector);
850 calPadPed->SetCalROC(rocOCDB,sector);
851 } else {
852 const int mess_length=100;
853 char message[mess_length];
854 snprintf(message,mess_length,"Missing pedestals for sector %d - also not available from previous OCDB entry.\n",
855 sector);
856 Log (message);
857 result = 2;
858 }
859
ccf58a39 860 }
861 if (foundSectorsRMS[sector] < 2 ) {
f3652e39 862 if (calPadRMSOCDB) {
863 AliTPCCalROC *rocOCDB=calPadRMSOCDB->GetCalROC(sector);
864 calPadRMS->SetCalROC(rocOCDB,sector);
865 } else {
866 const int mess_length=100;
867 char message[mess_length];
868 snprintf(message,mess_length,"Missing pedestal RMS for sector %d - also not available from previous OCDB entry.\n",
869 sector);
870 Log (message);
871 result = 2;
40ec49dc 872 }
f3652e39 873
40ec49dc 874 }
ccf58a39 875 }
876
40ec49dc 877
a7dce0bc 878//
879// Store updated pedestal entry to OCDB
880//
bdffc5fb 881 if (changed) {
882 AliCDBMetaData metaData;
883 metaData.SetBeamPeriod(0);
884 metaData.SetResponsible("Haavard Helstrup");
5420ed56 885 metaData.SetAliRootVersion(ALIROOT_VERSION);
40ec49dc 886 metaData.SetComment("Preprocessor AliTPC data base entries.");
887
bdffc5fb 888 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
889 if ( !storeOK ) ++result;
890 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
891 if ( !storeOK ) ++result;
892 }
9f016d99 893 } else {
cf4216a3 894 Log ("Error: no entries in pedestal file list!");
9f016d99 895 result = 1;
7b54c8e9 896 }
a7dce0bc 897
795dbd3b 898 delete calPadPed;
899 delete calPadRMS;
ccf58a39 900 delete calPadPedOCDB;
901 delete calPadRMSOCDB;
795dbd3b 902
a7dce0bc 903 return result;
904}
7b54c8e9 905
906//______________________________________________________________________________________________
907
908
9f016d99 909UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
910{
40ec49dc 911 //
912 // Read pulser calibration file from file exchage server
913 // Keep original entry from OCDB in case no new pulser calibration is available
914 //
915
ccf58a39 916 TObjArray *pulserObjects = new TObjArray;
40ec49dc 917 TObjArray *pulserObjectsOCDB=0;
918
9f016d99 919 AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
ccf58a39 920 if (entry) pulserObjectsOCDB = (TObjArray*)entry->GetObject();
921 if ( pulserObjectsOCDB==NULL ) {
9f016d99 922 Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
9f016d99 923 }
924
ccf58a39 925 AliTPCCalPad *pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
926 pulserObjects->Add(pulserTmean);
40ec49dc 927
ccf58a39 928 AliTPCCalPad *pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
929 pulserObjects->Add(pulserTrms);
40ec49dc 930
ccf58a39 931 AliTPCCalPad *pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
932 pulserObjects->Add(pulserQmean);
40ec49dc 933
9f016d99 934
935
936 UInt_t result=0;
937
938 Int_t nSectors = fROC->GetNSectors();
ccf58a39 939 TVectorD foundTmean(nSectors);
940 foundTmean=0;
941 TVectorD foundTrms(nSectors);
942 foundTrms=0;
943 TVectorD foundQmean(nSectors);
944 foundQmean=0;
945
946
9f016d99 947 TList* list = GetFileSources(sourceFXS,"pulser");
40ec49dc 948
9f016d99 949 if (list && list->GetEntries()>0) {
950
951// loop through all files from LDCs
952
bdffc5fb 953 Bool_t changed=false;
9f016d99 954 UInt_t index = 0;
955 while (list->At(index)!=NULL) {
956 TObjString* fileNameEntry = (TObjString*) list->At(index);
957 if (fileNameEntry!=NULL) {
958 TString fileName = GetFile(sourceFXS, "pulser",
959 fileNameEntry->GetString().Data());
960 TFile *f = TFile::Open(fileName);
961 if (!f) {
962 Log ("Error opening pulser file.");
963 result =2;
964 break;
965 }
966 AliTPCCalibPulser *calPulser;
e73181c9 967 f->GetObject("tpcCalibPulser",calPulser);
67a165ed 968 if ( !calPulser ) {
969 Log ("No pulser calibration object in file.");
970 result = 2;
971 break;
972 }
9f016d99 973
974 // replace entries for the sectors available in the present file
975
bdffc5fb 976 changed=true;
9f016d99 977 for (Int_t sector=0; sector<nSectors; sector++) {
978 AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
ccf58a39 979 if ( rocTmean ) {
980 AliTPCCalROC* roc=pulserTmean->GetCalROC(sector);
981 roc->Add(rocTmean,1);
982 foundTmean[sector]++;
983 }
9f016d99 984 AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
ccf58a39 985 if ( rocTrms ) {
986 AliTPCCalROC* roc=pulserTrms->GetCalROC(sector);
987 roc->Add(rocTrms,1);
988 foundTrms[sector]++;
989 }
9f016d99 990 AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
ccf58a39 991 if ( rocQmean ) {
992 AliTPCCalROC* roc=pulserQmean->GetCalROC(sector);
993 roc->Add(rocQmean,1);
994 foundQmean[sector]++;
995 }
9f016d99 996 }
a480de15 997 delete calPulser;
342d3b42 998 f->Close();
9f016d99 999 }
1000 ++index;
1001 } // while(list)
ccf58a39 1002
1003
1004
1005
1006if (pulserObjectsOCDB) {
1007 AliTPCCalPad* pulserTmeanOCDB = (AliTPCCalPad*)pulserObjectsOCDB->FindObject("PulserTmean");
1008 AliTPCCalPad* pulserTrmsOCDB = (AliTPCCalPad*)pulserObjectsOCDB->FindObject("PulserTrms");
1009 AliTPCCalPad* pulserQmeanOCDB = (AliTPCCalPad*)pulserObjectsOCDB->FindObject("PulserQmean");
40ec49dc 1010
ccf58a39 1011//
1012// Check if calibration is complete -- otherwise take from old OCDB entry
1013
1014// inner sectors
1015 for (Int_t sector=0; sector<nSectors/2; sector++) {
1016 if (foundTmean[sector] < 1 ) {
1017 if (pulserTmeanOCDB) {
1018 AliTPCCalROC* rocOCDB = pulserTmeanOCDB->GetCalROC(sector);
1019 if ( rocOCDB ) pulserTmean->SetCalROC(rocOCDB,sector);
1020 }
1021 }
1022 if (foundTrms[sector] < 1 ) {
1023 if (pulserTrmsOCDB) {
1024 AliTPCCalROC* rocOCDB = pulserTrmsOCDB->GetCalROC(sector);
1025 if ( rocOCDB ) pulserTrms->SetCalROC(rocOCDB,sector);
1026 }
1027 }
1028 if (foundQmean[sector] < 1 ) {
1029 if (pulserQmeanOCDB) {
1030 AliTPCCalROC* rocOCDB = pulserQmeanOCDB->GetCalROC(sector);
1031 if ( rocOCDB ) pulserQmean->SetCalROC(rocOCDB,sector);
1032 }
1033 }
1034 }
40ec49dc 1035
ccf58a39 1036// outer sectors -- two updates needed
1037
1038 for (Int_t sector=0; sector<nSectors/2; sector++) {
1039 if (foundTmean[sector] < 2 ) {
1040 if (pulserTmeanOCDB) {
1041 AliTPCCalROC* rocOCDB = pulserTmeanOCDB->GetCalROC(sector);
1042 if ( rocOCDB ) pulserTmean->SetCalROC(rocOCDB,sector);
1043 }
1044 }
1045 if (foundTrms[sector] < 2 ) {
1046 if (pulserTrmsOCDB) {
1047 AliTPCCalROC* rocOCDB = pulserTrmsOCDB->GetCalROC(sector);
1048 if ( rocOCDB ) pulserTrms->SetCalROC(rocOCDB,sector);
1049 }
1050 }
1051 if (foundQmean[sector] < 2 ) {
1052 if (pulserQmeanOCDB) {
1053 AliTPCCalROC* rocOCDB = pulserQmeanOCDB->GetCalROC(sector);
1054 if ( rocOCDB ) pulserQmean->SetCalROC(rocOCDB,sector);
1055 }
1056 }
1057
1058 }
1059}
1060
9f016d99 1061//
1062// Store updated pedestal entry to OCDB
1063//
bdffc5fb 1064 if (changed) {
1065 AliCDBMetaData metaData;
1066 metaData.SetBeamPeriod(0);
1067 metaData.SetResponsible("Haavard Helstrup");
5420ed56 1068 metaData.SetAliRootVersion(ALIROOT_VERSION);
bdffc5fb 1069 metaData.SetComment("Preprocessor AliTPC data base entries.");
1070
1071 Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
1072 if ( !storeOK ) ++result;
40ec49dc 1073 }
9f016d99 1074 } else {
cf4216a3 1075 Log ("Error: no entries in pulser file list!");
9f016d99 1076 result = 1;
1077 }
795dbd3b 1078 pulserObjects->Delete();
1079 delete pulserObjects;
f3652e39 1080 if (pulserObjectsOCDB) pulserObjectsOCDB->Delete();
ccf58a39 1081 delete pulserObjectsOCDB;
9f016d99 1082
1083 return result;
1084}
1085
70f224dd 1086//______________________________________________________________________________________________
1087
1088
1089UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
1090{
40ec49dc 1091 //
1092 // Read Raw calibration file from file exchage server
1093 //
1094
70f224dd 1095 UInt_t result=0;
90581ff1 1096 TObjArray* rawArray = new TObjArray;
70f224dd 1097
9b1478f9 1098 TList* list = GetFileSources(sourceFXS,"tpcCalibRaw");
40ec49dc 1099
70f224dd 1100 if (list && list->GetEntries()>0) {
1101
1102// loop through all files
1103
1104 UInt_t index = 0;
1105 while (list->At(index)!=NULL) {
1106 TObjString* fileNameEntry = (TObjString*) list->At(index);
1107 if (fileNameEntry!=NULL) {
1108 TString fileName = GetFile(sourceFXS, "tpcCalibRaw",
1109 fileNameEntry->GetString().Data());
1110 TFile *f = TFile::Open(fileName);
1111 if (!f) {
1112 Log ("Error opening raw file.");
1113 result =2;
1114 break;
1115 }
90581ff1 1116 AliTPCCalibRaw *calRaw;
70f224dd 1117 f->GetObject("tpcCalibRaw",calRaw);
1118 if ( !calRaw ) {
1119 Log ("No raw calibration object in file.");
1120 result = 2;
1121 break;
1122 }
90581ff1 1123 rawArray->Add(calRaw);
70f224dd 1124 f->Close();
1125 }
1126 ++index;
1127 } // while(list)
1128//
1129// Store updated pedestal entry to OCDB
1130//
1131 AliCDBMetaData metaData;
1132 metaData.SetBeamPeriod(0);
1133 metaData.SetResponsible("Haavard Helstrup");
5420ed56 1134 metaData.SetAliRootVersion(ALIROOT_VERSION);
70f224dd 1135 metaData.SetComment("Preprocessor AliTPC data base entries.");
1136
90581ff1 1137 Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE);
70f224dd 1138 if ( !storeOK ) ++result;
1139 } else {
cf4216a3 1140 Log ("Error: no entries in raw file list!");
70f224dd 1141 result = 1;
1142 }
40ec49dc 1143
795dbd3b 1144 rawArray->Delete();
1145 delete rawArray;
70f224dd 1146
1147 return result;
1148}
1149//______________________________________________________________________________________________
1150
9f016d99 1151UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
1152{
40ec49dc 1153 //
1154 // Read Central Electrode file from file exchage server
1155 //
1156 //
e2d642a2 1157 AliTPCCalPad *ceTmean=0;
1158 AliTPCCalPad *ceTrms=0;
1159 AliTPCCalPad *ceQmean=0;
1160 TObjArray *rocTtime=0;
1161 TObjArray *rocQtime=0;
40ec49dc 1162
e2d642a2 1163 TObjArray *ceObjects= new TObjArray;
40ec49dc 1164
1165
e2d642a2 1166 Int_t nSectors = fROC->GetNSectors();
40ec49dc 1167
e2d642a2 1168 ceTmean = new AliTPCCalPad("CETmean","CETmean");
1169 ceObjects->Add(ceTmean);
40ec49dc 1170
e2d642a2 1171 ceTrms = new AliTPCCalPad("CETrms","CETrms");
1172 ceObjects->Add(ceTrms);
40ec49dc 1173
e2d642a2 1174 ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
1175 ceObjects->Add(ceQmean);
40ec49dc 1176
e2d642a2 1177 rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average
1178 rocTtime->SetName("rocTtime");
1179 ceObjects->Add(rocTtime);
40ec49dc 1180
e2d642a2 1181 rocQtime = new TObjArray(nSectors);
1182 rocQtime->SetName("rocQtime");
1183 ceObjects->Add(rocQtime);
1184
1185 //=== new part
1186 TObjArray *arrFitGraphs=new TObjArray;
1187 arrFitGraphs->SetName("ceFitsDrift");
1188 ceObjects->Add(arrFitGraphs);
40ec49dc 1189
1190// Temperature maps
1191
e2d642a2 1192 if (fTemp) {
df8595b9 1193 AliTPCSensorTempArray *tempMap = new AliTPCSensorTempArray(*fTemp);
1194 tempMap->SetNameTitle("TempMap","TempMap");
1195 ceObjects->Add(tempMap);
e2d642a2 1196 }
40ec49dc 1197
09a746c5 1198// Pressure maps
40ec49dc 1199
e2d642a2 1200 if (fPressure) {
1201 AliDCSSensor *sensor=0, *sensorCopy=0;
1202 for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
09a746c5 1203 sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
b5886f0f 1204 if (sensor) {
e2d642a2 1205 sensorCopy = new AliDCSSensor(*sensor);
1206 sensorCopy->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);
1207 ceObjects->Add(sensorCopy);
b5886f0f 1208 }
e2d642a2 1209 }
1210 }
40ec49dc 1211
e2d642a2 1212 UInt_t result=0;
40ec49dc 1213
e2d642a2 1214 TList* list = GetFileSources(sourceFXS,"CE");
40ec49dc 1215
e2d642a2 1216 if (list && list->GetEntries()>0) {
40ec49dc 1217
9f016d99 1218// loop through all files from LDCs
40ec49dc 1219
9f016d99 1220 UInt_t index = 0;
1221 while (list->At(index)!=NULL) {
e2d642a2 1222 TObjString* fileNameEntry = (TObjString*) list->At(index);
1223 if (fileNameEntry!=NULL) {
9f016d99 1224 TString fileName = GetFile(sourceFXS, "CE",
e2d642a2 1225 fileNameEntry->GetString().Data());
40ec49dc 1226 AliTPCCalibCE *calCE=AliTPCCalibCE::ReadFromFile(fileName.Data());
1227
7c2575c4 1228 if (!calCE) {
e2d642a2 1229 Log ("No valid calibCE object.");
1230 result=2;
1231 break;
1232 }
9f016d99 1233 // replace entries for the sectors available in the present file
40ec49dc 1234
9f016d99 1235 for (Int_t sector=0; sector<nSectors; sector++) {
e2d642a2 1236 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
1237 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
1238 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
1239 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
1240 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
1241 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
1242 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
1243 if ( grT ) rocTtime->AddAt(grT,sector);
1244 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
1245 if ( grQ ) rocQtime->AddAt(grQ,sector);
9f016d99 1246 }
40ec49dc 1247
e2d642a2 1248 TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
1249 if ( grT ) {
1250 rocTtime->AddAt(grT,nSectors);
1251 } else {
31c50f68 1252 result=10;
e2d642a2 1253 }
1254 grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
1255 if ( grT ) {
1256 rocTtime->AddAt(grT,nSectors+1);
1257 } else {
31c50f68 1258 result=10;
e2d642a2 1259 }
1fc96a8a 1260
e2d642a2 1261 delete calCE;
9f016d99 1262 }
e2d642a2 1263 ++index;
9f016d99 1264 } // while(list)
1fc96a8a 1265//
1266// Check number of calibrated sectors per side
40ec49dc 1267//
1fc96a8a 1268 Int_t aside=0, cside=0;
1269 for (Int_t ind=0; ind<nSectors/4; ind++ ) {
1270 TGraph *grT=(TGraph*)rocTtime->At(ind);
1271 if (grT) aside++;
1272 grT=(TGraph*)rocTtime->At(ind+nSectors/2);
1273 if (grT) aside++;
1274 grT=(TGraph*)rocTtime->At(ind+nSectors/4);
1275 if (grT) cside++;
1276 grT=(TGraph*)rocTtime->At(ind+3*nSectors/4);
1277 if (grT) cside++;
1278 }
f085dc93 1279 if ( (aside<kMinCESectors) && (cside<kMinCESectors) ) {
1280 Log (Form("ExtractCE: Too few fitted sectors: Aside =%d, Cside=%d\n",
1281 aside, cside)) ;
1282 result=10;
1283 }
e2d642a2 1284
1285 //
1286 //=== New CE part
1287 // if it is validated this part needs to be modified again
1288 // currently its only processed if there is a valid standard CE object
1289 //
1290 list = GetFileSources(sourceFXS,"CEnew");
40ec49dc 1291
e2d642a2 1292 if (result==0 && list && list->GetEntries()>0) {
40ec49dc 1293
e2d642a2 1294// loop through all files from LDCs
40ec49dc 1295
e2d642a2 1296 UInt_t index2 = 0;
1297 while (list->At(index2)!=NULL) {
1298 TObjString* fileNameEntry = (TObjString*) list->At(index2);
1299 if (fileNameEntry!=NULL) {
1300 TString fileName = GetFile(sourceFXS, "CEnew",
1301 fileNameEntry->GetString().Data());
40ec49dc 1302 AliTPCCalibCE *calCE=AliTPCCalibCE::ReadFromFile(fileName.Data());
1303
e2d642a2 1304 if (!calCE) {
1305 Log ("No valid new calibCE object.");
1306// result=2;
1307 break;
1308 }
1309
1310 TIter nextObj(calCE->GetArrFitGraphs());
1311 TObject *obj=0x0;
1312 while ( (obj=nextObj()) ){
1313 arrFitGraphs->Add(obj->Clone());
1314 }
1315 delete calCE;
e2d642a2 1316 }
1317 ++index2;
1318 }
1319 }
40ec49dc 1320
9f016d99 1321//
1322// Store updated pedestal entry to OCDB
1323//
1324 AliCDBMetaData metaData;
1325 metaData.SetBeamPeriod(0);
1326 metaData.SetResponsible("Haavard Helstrup");
5420ed56 1327 metaData.SetAliRootVersion(ALIROOT_VERSION);
9f016d99 1328 metaData.SetComment("Preprocessor AliTPC data base entries.");
40ec49dc 1329
31c50f68 1330 if ( result == 0 ) {
e2d642a2 1331 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
1332 if ( !storeOK ) ++result;
31c50f68 1333 } else {
e2d642a2 1334 Log ("Warning: Average time graphs not available - no OCDB entry written");
1335 }
9f016d99 1336 } else {
cf4216a3 1337 Log ("Error: no CE entries available from FXS!");
9f016d99 1338 result = 1;
1339 }
40ec49dc 1340
795dbd3b 1341 ceObjects->Delete();
1342 delete ceObjects;
40ec49dc 1343
9f016d99 1344 return result;
1345}
dca91b3f 1346//______________________________________________________________________________________________
1347
1348UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
1349{
40ec49dc 1350 //
1351 // Read Quality Assurance file from file exchage server
1352 //
1353
dca91b3f 1354 UInt_t result=0;
1355
1356 TList* list = GetFileSources(sourceFXS,"QA");
40ec49dc 1357
dca91b3f 1358 if (list && list->GetEntries()>0) {
1359
ccf58a39 1360// only one QA object should be available!
dca91b3f 1361
1362 AliTPCdataQA *calQA;
1363
40ec49dc 1364 UInt_t nentries = list->GetEntries();
dca91b3f 1365 UInt_t index=0;
40ec49dc 1366 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
dca91b3f 1367 TObjString* fileNameEntry = (TObjString*) list->At(index);
1368 if (fileNameEntry!=NULL) {
1369 TString fileName = GetFile(sourceFXS, "QA",
1370 fileNameEntry->GetString().Data());
1371 TFile *f = TFile::Open(fileName);
1372 if (!f) {
1373 Log ("Error opening QA file.");
40ec49dc 1374 result =2;
a2465b54 1375 } else {
1376 f->GetObject("tpcCalibQA",calQA);
40ec49dc 1377 if ( calQA ) {
dca91b3f 1378//
1379// Store updated pedestal entry to OCDB
1380//
7c2575c4 1381 AliCDBMetaData metaData;
1382 metaData.SetBeamPeriod(0);
1383 metaData.SetResponsible("Haavard Helstrup");
5420ed56 1384 metaData.SetAliRootVersion(ALIROOT_VERSION);
7c2575c4 1385 metaData.SetComment("Preprocessor AliTPC data base entries.");
1386
cf4216a3 1387 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
7c2575c4 1388 if ( !storeOK ) ++result;
795dbd3b 1389
1390 delete calQA;
7c2575c4 1391 }
a2465b54 1392 }
1393 } else {
1394 Log ("Error: no QA files on FXS!");
1395 result = 2;
1396 }
dca91b3f 1397 } else {
a2465b54 1398 Log ("Error: no QA entries in FXS list!");
dca91b3f 1399 result = 1;
1400 }
dca91b3f 1401 return result;
1402}
1403
9054511b 1404//______________________________________________________________________________________________
1405
1406
f6b5fa33 1407UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS, TMap* dcsMap)
9054511b 1408{
40ec49dc 1409 //
1410 // Read Altro configuration file from file exchage server
1411 // Keep original entry from OCDB in case no new pulser calibration is available
1412 //
9054511b 1413 TObjArray *altroObjects=0;
1414 AliTPCCalPad *acqStart=0;
1415 AliTPCCalPad *zsThr=0;
1416 AliTPCCalPad *acqStop=0;
1417 AliTPCCalPad *FPED=0;
1418 AliTPCCalPad *masked=0;
cf4216a3 1419 AliTPCCalPad *k1=0, *k2=0, *k3=0;
1420 AliTPCCalPad *l1=0, *l2=0, *l3=0;
1421 TMap *mapRCUconfig=0;
9054511b 1422
14ae505e 1423 AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
9054511b 1424 if (entry) altroObjects = (TObjArray*)entry->GetObject();
1425 if ( altroObjects==NULL ) {
1426 Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
40ec49dc 1427 altroObjects = new TObjArray;
9054511b 1428 }
1429
1430 acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1431 if ( !acqStart ) {
1432 acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1433 altroObjects->Add(acqStart);
1434 }
1435 zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
40ec49dc 1436 if ( !zsThr ) {
9054511b 1437 zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1438 altroObjects->Add(zsThr);
1439 }
1440 FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
40ec49dc 1441 if ( !FPED ) {
9054511b 1442 FPED = new AliTPCCalPad("FPED","FPED");
1443 altroObjects->Add(FPED);
1444 }
1445 acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1446 if ( !acqStop ) {
1447 acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1448 altroObjects->Add(acqStop);
1449 }
1450 masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
40ec49dc 1451 if ( !masked ) {
9054511b 1452 masked = new AliTPCCalPad("Masked","Masked");
1453 altroObjects->Add(masked);
1454 }
cf4216a3 1455 k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
40ec49dc 1456 if ( !k1 ) {
cf4216a3 1457 k1 = new AliTPCCalPad("K1","K1");
1458 altroObjects->Add(k1);
1459 }
1460 k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
40ec49dc 1461 if ( !k2 ) {
cf4216a3 1462 k2 = new AliTPCCalPad("K2","K2");
1463 altroObjects->Add(k2);
1464 }
1465 k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
40ec49dc 1466 if ( !k3 ) {
cf4216a3 1467 k3 = new AliTPCCalPad("K3","K3");
1468 altroObjects->Add(k3);
1469 }
1470 l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
40ec49dc 1471 if ( !l1 ) {
cf4216a3 1472 l1 = new AliTPCCalPad("L1","L1");
1473 altroObjects->Add(l1);
1474 }
1475 l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
40ec49dc 1476 if ( !l2 ) {
cf4216a3 1477 l2 = new AliTPCCalPad("L2","L2");
1478 altroObjects->Add(l2);
1479 }
1480 l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
40ec49dc 1481 if ( !l3 ) {
cf4216a3 1482 l3 = new AliTPCCalPad("L3","L3");
1483 altroObjects->Add(l3);
1484 }
1485 mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1486 if (!mapRCUconfig) {
1487 mapRCUconfig = new TMap();
1488 mapRCUconfig->SetName("RCUconfig");
1489 altroObjects->Add(mapRCUconfig);
1490 }
9054511b 1491
1492
1493 UInt_t result=0;
1494 TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1495
1496 Int_t nSectors = fROC->GetNSectors();
1497 Bool_t changed=false;
f6b5fa33 1498 if (altroObjects == 0 ) altroObjects = new TObjArray;
1499
1500// extract list of active DDLs
1501
f3652e39 1502 if (dcsMap) {
40ec49dc 1503 Bool_t found;
f6b5fa33 1504 TString arrDDL(kNumDDL);
2b00f997 1505 arrDDL.Append('x',kNumDDL);
f6b5fa33 1506 for ( Int_t iDDL = 0; iDDL<kNumDDL; iDDL++ ) {
1507 TString stringID = Form (kAmandaDDL.Data(),iDDL+kFirstDDL);
1508 TPair *pair = (TPair*)dcsMap->FindObject(stringID.Data());
1509 found = false;
1510 if ( pair ) {
1511 TObjArray *valueSet=(TObjArray*)pair->Value();
40ec49dc 1512 if ( valueSet) {
f6b5fa33 1513 AliDCSValue *val = (AliDCSValue*)valueSet->At(0);
40ec49dc 1514 if (val) {
2b00f997 1515 found = val->GetBool();
1516 if (found){
1517 arrDDL[iDDL] = '1';
40ec49dc 1518 } else {
2b00f997 1519 arrDDL[iDDL] = '0';
1520 }
40ec49dc 1521 }
f6b5fa33 1522 }
40ec49dc 1523 }
f6b5fa33 1524 }
1525 TObjString *ddlArray = new TObjString;
1526 ddlArray->SetString(arrDDL);
1527 TMap *activeDDL = new TMap;
1528 activeDDL->SetName("DDLArray");
1529 TObjString *key = new TObjString("DDLArray");
1530 activeDDL->Add(key,ddlArray);
1531 altroObjects->Add(activeDDL);
1532 changed=true;
f3652e39 1533 } else {
1534 Log ("ExtractAltro: No DCS map available. Active DDL list cannot be obtained.");
1535 result = 3;
40ec49dc 1536 }
f6b5fa33 1537
1538// extract Altro configuration files
1539
9054511b 1540 for ( Int_t id=0; id<2; id++) {
1541 TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
40ec49dc 1542
9054511b 1543 if (list && list->GetEntries()>0) {
9054511b 1544
1545// loop through all files from LDCs
1546
1547 UInt_t index = 0;
1548 while (list->At(index)!=NULL) {
1549 TObjString* fileNameEntry = (TObjString*) list->At(index);
1550 if (fileNameEntry!=NULL) {
1551 TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1552 fileNameEntry->GetString().Data());
1553 TFile *f = TFile::Open(fileName);
1554 if (!f) {
ff7d4b88 1555 const int mess_length=40;
1556 char message[mess_length];
1557 snprintf(message,mess_length,"Error opening Altro configuration file, id = %d",id);
9054511b 1558 Log (message);
1559 result =2;
1560 break;
1561 }
1562 TObjArray *altroFXS;
1563 f->GetObject("AltroConfig",altroFXS);
1564 if ( !altroFXS ) {
1565 Log ("No Altro configuration object in file.");
1566 result = 2;
1567 break;
1568 }
1569
1570 // replace entries for the sectors available in the present file
1571 AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1572 AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1573 AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1574 AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1575 AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
cf4216a3 1576 AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1577 AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1578 AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1579 AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1580 AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1581 AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1582 TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1583 TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
40ec49dc 1584
9054511b 1585 changed=true;
1586 for (Int_t sector=0; sector<nSectors; sector++) {
40ec49dc 1587
9054511b 1588 if (acqStartFXS) {
1589 AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1590 if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1591 }
1592 if (zsThrFXS ) {
1593 AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1594 if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1595 }
1596 if (acqStopFXS) {
1597 AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1598 if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1599 }
1600 if (FPEDFXS ) {
1601 AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
2d47cfd4 1602 if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
9054511b 1603 }
1604 if (maskedFXS) {
1605 AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1606 if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1607 }
cf4216a3 1608 if (k1FXS) {
1609 AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1610 if ( rocK1 ) k1->SetCalROC(rocK1,sector);
1611 }
1612 if (k2FXS) {
1613 AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1614 if ( rocK2 ) k2->SetCalROC(rocK2,sector);
1615 }
1616 if (k3FXS) {
1617 AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1618 if ( rocK3 ) k3->SetCalROC(rocK3,sector);
1619 }
1620 if (l1FXS) {
1621 AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1622 if ( rocL1 ) l1->SetCalROC(rocL1,sector);
1623 }
1624 if (l2FXS) {
1625 AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1626 if ( rocL2 ) l2->SetCalROC(rocL2,sector);
1627 }
1628 if (l3FXS) {
1629 AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1630 if ( rocL3 ) l3->SetCalROC(rocL3,sector);
1631 }
1632 }
1633 if (mapRCUconfigFXS) {
1634 Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1635 TObjString* keyFXS;
1636 TVectorF* vecFXS;
1637 TVectorF* vec; // nSectors = 72 (total number of inner/outer sectors)
1638 for (Int_t i=0; i<mapEntries; ++i) {
1639 keyFXS=(TObjString*)mapFXSiter->Next();
1640 vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1641 vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1642 if (!vec) {
1643 vec = new TVectorF(3*nSectors);
1644 *vec = -1;
1645 mapRCUconfig->Add(keyFXS,vec);
1646 }
1647 if (vec->GetNoElements() != 3*nSectors ) {
1648 vec->ResizeTo(3*nSectors);
1649 }
1650 if (id==0) { // A side
1651 vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1652 vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1653 } else { // C side
1654 vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1655 vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1656 }
1657 }
9054511b 1658 }
1659 delete altroFXS;
1660 f->Close();
1661 }
1662 ++index;
1663 } // while(list)
1664 } else {
cf4216a3 1665 Log ("Error: no entries in AltroConfig file list!");
9054511b 1666 result = 1;
1667 }
1668
1669 } // for - id
1670//
1671// Store updated pedestal entry to OCDB
1672//
1673 if (changed) {
1674 AliCDBMetaData metaData;
1675 metaData.SetBeamPeriod(0);
1676 metaData.SetResponsible("Haavard Helstrup");
5420ed56 1677 metaData.SetAliRootVersion(ALIROOT_VERSION);
9054511b 1678 metaData.SetComment("Preprocessor AliTPC data base entries.");
1679
dbc10140 1680 Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
9054511b 1681 if ( !storeOK ) ++result;
40ec49dc 1682 }
9054511b 1683
795dbd3b 1684 altroObjects->Delete();
1685 delete altroObjects;
40ec49dc 1686
9054511b 1687 return result;
1688}