Better cuts for V0 (Ana Marin)
[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"
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"
bb30a935 35#include "TGraph.h"
7b54c8e9 36#include "TEnv.h"
bb30a935 37#include "TParameter.h"
54472e4f 38
39#include <TTimeStamp.h>
40
a7dce0bc 41const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
42const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
bb30a935 43const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
9054511b 44const TString kPulserRunType = "PULSER"; // pulser run identifier
bdffc5fb 45const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
9054511b 46const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
47const TString kLaserRunType = "LASER"; // laser run identifier
9c754ce7 48const TString kDaqRunType = "DAQ"; // DAQ run identifier
87d77b35 49const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
bee89eeb 50//const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
68b512ca 51const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
72df5829 52
cf4216a3 53
54472e4f 54//
55// This class is the SHUTTLE preprocessor for the TPC detector.
54472e4f 56//
57
58ClassImp(AliTPCPreprocessor)
59
60//______________________________________________________________________________________________
6d07bf74 61AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
62 AliPreprocessor("TPC",shuttle),
b6e9fd45 63 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0)
54472e4f 64{
65 // constructor
a7dce0bc 66 fROC = AliTPCROC::Instance();
72534123 67
68 // define run types to be processed
69
70 AddRunType(kPedestalRunType);
71 AddRunType(kPulserRunType);
72 AddRunType(kPhysicsRunType);
72534123 73 AddRunType(kCosmicRunType);
74 AddRunType(kLaserRunType);
75 AddRunType(kDaqRunType);
76
54472e4f 77}
72df5829 78//______________________________________________________________________________________________
f4a89669 79 AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) :
80 AliPreprocessor("TPC",0),
b6e9fd45 81 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0)
f4a89669 82 {
83
84 Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 85//
86// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
f4a89669 87 }
54472e4f 88
89//______________________________________________________________________________________________
90AliTPCPreprocessor::~AliTPCPreprocessor()
91{
92 // destructor
a7dce0bc 93
54472e4f 94 delete fTemp;
bdffc5fb 95 delete fHighVoltage;
795dbd3b 96 delete fHighVoltageStat;
97 delete fGoofie;
54472e4f 98}
72df5829 99//______________________________________________________________________________________________
100AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
101{
102 Fatal("operator =", "assignment operator not implemented");
103 return *this;
104}
105
54472e4f 106
107//______________________________________________________________________________________________
108void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
109 UInt_t endTime)
110{
bb30a935 111 // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start
54472e4f 112
dca91b3f 113 UInt_t startTimeLocal = startTime-3600;
114 UInt_t endTimeLocal = endTime+1800;
bb30a935 115
dca91b3f 116 AliPreprocessor::Initialize(run, startTimeLocal, endTimeLocal);
54472e4f 117
118 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
f4a89669 119 TTimeStamp((time_t)startTime,0).AsString(),
120 TTimeStamp((time_t)endTime,0).AsString()));
54472e4f 121
7b54c8e9 122 // Preprocessor configuration
123
37092b2b 124 AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
7b54c8e9 125 if (entry) fConfEnv = (TEnv*) entry->GetObject();
126 if ( fConfEnv==0 ) {
7b54c8e9 127 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
37092b2b 128 fConfigOK = kFALSE;
129 return;
7b54c8e9 130 }
131
18eade96 132 // Temperature sensors
133
136e44f7 134 TTree *confTree = 0;
135
136 TString tempConf = fConfEnv->GetValue("Temperature","ON");
137 tempConf.ToUpper();
138 if (tempConf != "OFF" ) {
7b54c8e9 139 entry = GetFromOCDB("Config", "Temperature");
f7f602cc 140 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 141 if ( confTree==0 ) {
18eade96 142 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
143 fConfigOK = kFALSE;
f7f602cc 144 return;
18eade96 145 }
dca91b3f 146 fTemp = new AliTPCSensorTempArray(startTimeLocal, endTimeLocal, confTree, kAmandaTemp);
18eade96 147 fTemp->SetValCut(kValCutTemp);
148 fTemp->SetDiffCut(kDiffCutTemp);
136e44f7 149 }
18eade96 150
bdffc5fb 151 // High voltage measurements
152
136e44f7 153 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
154 hvConf.ToUpper();
155 if (hvConf != "OFF" ) {
bdffc5fb 156 confTree=0;
157 entry=0;
158 entry = GetFromOCDB("Config", "HighVoltage");
159 if (entry) confTree = (TTree*) entry->GetObject();
160 if ( confTree==0 ) {
161 Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
162 fConfigOK = kFALSE;
163 return;
164 }
fe7f3fe2 165 fHighVoltage = new AliDCSSensorArray(startTime, endTime, confTree);
bff20895 166 }
9d2ce539 167
168 // High voltage status values
169
bff20895 170 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
171 hvStatConf.ToUpper();
172 if (hvStatConf != "OFF" ) {
9d2ce539 173 confTree=0;
174 entry=0;
175 entry = GetFromOCDB("Config", "HighVoltageStat");
176 if (entry) confTree = (TTree*) entry->GetObject();
177 if ( confTree==0 ) {
178 Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
179 fConfigOK = kFALSE;
180 return;
181 }
fe7f3fe2 182 fHighVoltageStat = new AliDCSSensorArray(startTime, endTime, confTree);
bdffc5fb 183 }
b6e9fd45 184
185 // Goofie values
186
187 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
188 goofieConf.ToUpper();
189 if (goofieConf != "OFF" ) {
190 confTree=0;
191 entry=0;
192 entry = GetFromOCDB("Config", "Goofie");
193 if (entry) confTree = (TTree*) entry->GetObject();
194 if ( confTree==0 ) {
195 Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
196 fConfigOK = kFALSE;
197 return;
198 }
199 fGoofie = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree);
200 }
201
202
54472e4f 203}
204
205//______________________________________________________________________________________________
206UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
207{
208 // Fills data into TPC calibrations objects
209
54472e4f 210 // Amanda servers provide information directly through dcsAliasMap
211
bb30a935 212
a7dce0bc 213 if (!fConfigOK) return 9;
136e44f7 214 UInt_t result = 0;
bb30a935 215 TObjArray *resultArray = new TObjArray();
216 TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
217 errorHandling.ToUpper();
218 TObject * status;
219
220 UInt_t dcsResult=0;
cf4216a3 221 if (!dcsAliasMap) dcsResult=1;
222 if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
223 status = new TParameter<int>("dcsResult",dcsResult);
224 resultArray->Add(status);
bb30a935 225
226
a7dce0bc 227 TString runType = GetRunType();
228
cf4216a3 229 if ( dcsResult == 0 ) {
230
54472e4f 231 // Temperature sensors are processed by AliTPCCalTemp
72df5829 232
cf4216a3 233 TString tempConf = fConfEnv->GetValue("Temperature","ON");
234 tempConf.ToUpper();
235 if (tempConf != "OFF" ) {
236 UInt_t tempResult = MapTemperature(dcsAliasMap);
237 result=tempResult;
238 status = new TParameter<int>("tempResult",tempResult);
239 resultArray->Add(status);
240 }
18eade96 241
bdffc5fb 242 // High Voltage recordings
243
244
cf4216a3 245 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
246 hvConf.ToUpper();
247 if (hvConf != "OFF" ) {
248 UInt_t hvResult = MapHighVoltage(dcsAliasMap);
249 result+=hvResult;
250 status = new TParameter<int>("hvResult",hvResult);
251 resultArray->Add(status);
252 }
f7f602cc 253
cf4216a3 254 // Goofie values
b6e9fd45 255
256
cf4216a3 257 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
258 goofieConf.ToUpper();
259 if (goofieConf != "OFF" ) {
260 UInt_t goofieResult = MapGoofie(dcsAliasMap);
261 result+=goofieResult;
262 status = new TParameter<int>("goofieResult",goofieResult);
263 resultArray->Add(status);
264 }
265 }
54472e4f 266 // Other calibration information will be retrieved through FXS files
a7dce0bc 267 // examples:
54472e4f 268 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
269 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
270 //
271 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
272 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
273
9f016d99 274 // pedestal entries
54472e4f 275
a7dce0bc 276 if(runType == kPedestalRunType) {
68b512ca 277 Int_t numSources = 1;
278 Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
7b54c8e9 279 TString source = fConfEnv->GetValue("Pedestal","DAQ");
280 source.ToUpper();
136e44f7 281 if (source != "OFF" ) {
282 if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
283 if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
284 if (source == "HLTDAQ" ) {
285 numSources=2;
286 pedestalSource[0] = AliShuttleInterface::kHLT;
287 pedestalSource[1] = AliShuttleInterface::kDAQ;
288 }
289 if (source == "DAQHLT" ) numSources=2;
290 UInt_t pedestalResult=0;
291 for (Int_t i=0; i<numSources; i++ ) {
453bd596 292 pedestalResult = ExtractPedestals(pedestalSource[i]);
136e44f7 293 if ( pedestalResult == 0 ) break;
294 }
295 result += pedestalResult;
bb30a935 296 status = new TParameter<int>("pedestalResult",pedestalResult);
297 resultArray->Add(status);
68b512ca 298 }
a7dce0bc 299 }
300
9f016d99 301 // pulser trigger processing
302
68b512ca 303 if(runType == kPulserRunType) {
304 Int_t numSources = 1;
305 Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 306 TString source = fConfEnv->GetValue("Pulser","DAQ");
307 source.ToUpper();
136e44f7 308 if ( source != "OFF") {
309 if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
310 if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
311 if (source == "HLTDAQ" ) {
312 numSources=2;
313 pulserSource[0] = AliShuttleInterface::kHLT;
314 pulserSource[1] = AliShuttleInterface::kDAQ;
315 }
316 if (source == "DAQHLT" ) numSources=2;
317 UInt_t pulserResult=0;
318 for (Int_t i=0; i<numSources; i++ ) {
319 pulserResult = ExtractPulser(pulserSource[i]);
320 if ( pulserResult == 0 ) break;
321 }
322 result += pulserResult;
bb30a935 323 status = new TParameter<int>("pulserResult",pulserResult);
324 resultArray->Add(status);
68b512ca 325 }
9f016d99 326 }
327
70f224dd 328
329// raw calibration processing
330
331 if(runType == kPhysicsRunType) {
332 Int_t numSources = 1;
333 Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
334 TString source = fConfEnv->GetValue("Raw","DAQ");
335 source.ToUpper();
336 if ( source != "OFF") {
337 if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
338 if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
339 if (source == "HLTDAQ" ) {
340 numSources=2;
341 rawSource[0] = AliShuttleInterface::kHLT;
342 rawSource[1] = AliShuttleInterface::kDAQ;
343 }
344 if (source == "DAQHLT" ) numSources=2;
345 UInt_t rawResult=0;
346 for (Int_t i=0; i<numSources; i++ ) {
347 rawResult = ExtractRaw(rawSource[i]);
348 if ( rawResult == 0 ) break;
349 }
350 result += rawResult;
351 status = new TParameter<int>("rawResult",rawResult);
352 resultArray->Add(status);
353 }
354 }
355
356
9054511b 357 // Altro configuration
358
359
360 TString altroConf = fConfEnv->GetValue("AltroConf","ON");
cf4216a3 361 altroConf.ToUpper();
9054511b 362 if (altroConf != "OFF" ) {
db9ef692 363 UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS);
9054511b 364 result+=altroResult;
365 status = new TParameter<int>("altroResult",altroResult);
366 resultArray->Add(status);
367 }
68b512ca 368
369
9f016d99 370 // Central Electrode processing
371
9054511b 372 if( runType == kPhysicsRunType ||
6f3699dd 373 runType == kLaserRunType ) {
68b512ca 374
375 Int_t numSources = 1;
376 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 377 TString source = fConfEnv->GetValue("CE","DAQ");
378 source.ToUpper();
136e44f7 379 if ( source != "OFF" ) {
380 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
381 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
382 if (source == "HLTDAQ" ) {
68b512ca 383 numSources=2;
384 ceSource[0] = AliShuttleInterface::kHLT;
385 ceSource[1] = AliShuttleInterface::kDAQ;
136e44f7 386 }
387 if (source == "DAQHLT" ) numSources=2;
388 UInt_t ceResult=0;
389 for (Int_t i=0; i<numSources; i++ ) {
390 ceResult = ExtractCE(ceSource[i]);
391 if ( ceResult == 0 ) break;
392 }
6f3699dd 393
394 // only flag error if CE result is missing from LASER runs
395 // -- for PHYSICS run do CE processing if data available
396
397 if ( runType == kLaserRunType ) result += ceResult;
bb30a935 398 status = new TParameter<int>("ceResult",ceResult);
399 resultArray->Add(status);
dca91b3f 400
401 numSources = 1;
402 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
5e5c1e83 403 source = fConfEnv->GetValue("QA","DAQ");
dca91b3f 404 source.ToUpper();
405 if ( source != "OFF" ) {
406 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
407 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
408 if (source == "HLTDAQ" ) {
409 numSources=2;
410 qaSource[0] = AliShuttleInterface::kHLT;
411 qaSource[1] = AliShuttleInterface::kDAQ;
412 }
413 if (source == "DAQHLT" ) numSources=2;
414 UInt_t qaResult=0;
415 for (Int_t i=0; i<numSources; i++ ) {
416 qaResult = ExtractQA(qaSource[i]);
417 if ( qaResult == 0 ) break;
418 }
419// result += qaResult;
420 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
421 status = new TParameter<int>("qaResult",qaResult);
422 resultArray->Add(status);
68b512ca 423 }
dca91b3f 424 }
9f016d99 425 }
136e44f7 426
136e44f7 427 if (errorHandling == "OFF" ) {
bb30a935 428 AliCDBMetaData metaData;
429 metaData.SetBeamPeriod(0);
430 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 431 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bb30a935 432 metaData.SetComment("Preprocessor AliTPC status.");
433 Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
434 resultArray->Delete();
795dbd3b 435 delete resultArray;
bb30a935 436 return 0;
136e44f7 437 } else {
795dbd3b 438 delete resultArray;
bb30a935 439 return result;
136e44f7 440 }
54472e4f 441}
442//______________________________________________________________________________________________
443UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
444{
445
446 // extract DCS temperature maps. Perform fits to save space
447
72df5829 448 UInt_t result=0;
54472e4f 449 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
450 if (map) {
451 fTemp->MakeSplineFit(map);
68b512ca 452 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
67a165ed 453 if (fitFraction > kFitFraction ) {
454 AliInfo(Form("Temperature values extracted, fits performed.\n"));
455 } else {
456 Log ("Too few temperature maps fitted. \n");
457 result = 9;
458 }
54472e4f 459 } else {
67a165ed 460 Log("No temperature map extracted. \n");
72df5829 461 result=9;
54472e4f 462 }
463 delete map;
464 // Now store the final CDB file
a7dce0bc 465
466 if ( result == 0 ) {
72df5829 467 AliCDBMetaData metaData;
54472e4f 468 metaData.SetBeamPeriod(0);
469 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 470 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
54472e4f 471 metaData.SetComment("Preprocessor AliTPC data base entries.");
472
a7dce0bc 473 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
474 if ( !storeOK ) result=1;
475
72df5829 476 }
54472e4f 477
478 return result;
7b54c8e9 479
54472e4f 480}
7b54c8e9 481
bdffc5fb 482//______________________________________________________________________________________________
483UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
484{
485
486 // extract DCS HV maps. Perform fits to save space
487
488 UInt_t result=0;
489 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
490 if (map) {
fe7f3fe2 491 fHighVoltage->MakeSplineFit(map, kTRUE); // keep both spline fits and original maps
68b512ca 492 Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors();
bdffc5fb 493 if (fitFraction > kFitFraction ) {
136e44f7 494 AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
bdffc5fb 495 } else {
496 Log ("Too few high voltage recordings fitted. \n");
497 result = 9;
498 }
499 } else {
500 Log("No high voltage recordings extracted. \n");
501 result=9;
502 }
503 delete map;
9d2ce539 504
bff20895 505 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
506 hvStatConf.ToUpper();
507 if (hvStatConf != "OFF" ) {
508 TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
509 if (map2) {
dca91b3f 510 fHighVoltageStat->ClearFit();
511 fHighVoltageStat->SetGraph(map2);
bff20895 512 } else {
513 Log("No high voltage status recordings extracted. \n");
514 result=9;
515 }
516 delete map2;
9d2ce539 517
bff20895 518 // add status maps to high voltage sensor array
9d2ce539 519
bff20895 520 fHighVoltage->AddSensors(fHighVoltageStat);
521 }
bdffc5fb 522 // Now store the final CDB file
523
524 if ( result == 0 ) {
525 AliCDBMetaData metaData;
526 metaData.SetBeamPeriod(0);
527 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 528 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 529 metaData.SetComment("Preprocessor AliTPC data base entries.");
530
531 Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
532 if ( !storeOK ) result=1;
533
534 }
535
536 return result;
537
538}
539
b6e9fd45 540//______________________________________________________________________________________________
541UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
542{
543
544 // extract DCS Goofie maps. Do not perform fits (low update rate)
545
546 UInt_t result=0;
547
548 TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
549 if (map) {
550 fGoofie->ClearFit();
551 fGoofie->SetGraph(map);
552 } else {
553 Log("No Goofie recordings extracted. \n");
554 result=9;
555 }
556 delete map;
557
558 // Now store the final CDB file
559
560 if ( result == 0 ) {
561 AliCDBMetaData metaData;
562 metaData.SetBeamPeriod(0);
563 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 564 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
b6e9fd45 565 metaData.SetComment("Preprocessor AliTPC data base entries.");
566
567 Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
568 if ( !storeOK ) result=1;
569
570 }
571
572 return result;
573
574}
575
7b54c8e9 576
a7dce0bc 577//______________________________________________________________________________________________
7b54c8e9 578
579UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
a7dce0bc 580{
581 //
582 // Read pedestal file from file exchage server
583 // Keep original entry from OCDB in case no new pedestals are available
584 //
585 AliTPCCalPad *calPadPed=0;
586 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
587 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
588 if ( calPadPed==NULL ) {
a7dce0bc 589 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
7b54c8e9 590 calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
591 }
592
593 AliTPCCalPad *calPadRMS=0;
d63b9ad7 594 entry = GetFromOCDB("Calib", "PadNoise");
7b54c8e9 595 if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
596 if ( calPadRMS==NULL ) {
7b54c8e9 597 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
598 calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
a7dce0bc 599 }
600
7b54c8e9 601
a7dce0bc 602 UInt_t result=0;
603
604 Int_t nSectors = fROC->GetNSectors();
7b54c8e9 605 TList* list = GetFileSources(sourceFXS,"pedestals");
9f016d99 606
607 if (list && list->GetEntries()>0) {
a7dce0bc 608
609// loop through all files from LDCs
610
bdffc5fb 611 Bool_t changed=false;
a7dce0bc 612 UInt_t index = 0;
613 while (list->At(index)!=NULL) {
614 TObjString* fileNameEntry = (TObjString*) list->At(index);
615 if (fileNameEntry!=NULL) {
7b54c8e9 616 TString fileName = GetFile(sourceFXS, "pedestals",
a7dce0bc 617 fileNameEntry->GetString().Data());
618 TFile *f = TFile::Open(fileName);
9f016d99 619 if (!f) {
620 Log ("Error opening pedestal file.");
621 result =2;
622 break;
623 }
a7dce0bc 624 AliTPCCalibPedestal *calPed;
e73181c9 625 f->GetObject("tpcCalibPedestal",calPed);
67a165ed 626 if ( !calPed ) {
627 Log ("No pedestal calibration object in file.");
628 result = 2;
629 break;
630 }
a7dce0bc 631
632 // replace entries for the sectors available in the present file
633
bdffc5fb 634 changed=true;
c9c23d80 635 for (Int_t sector=0; sector<nSectors; sector++) {
7b54c8e9 636 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
637 if ( rocPed ) calPadPed->SetCalROC(rocPed,sector);
638 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
639 if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector);
a7dce0bc 640 }
a480de15 641 delete calPed;
342d3b42 642 f->Close();
a7dce0bc 643 }
644 ++index;
645 } // while(list)
646//
647// Store updated pedestal entry to OCDB
648//
bdffc5fb 649 if (changed) {
650 AliCDBMetaData metaData;
651 metaData.SetBeamPeriod(0);
652 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 653 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 654 metaData.SetComment("Preprocessor AliTPC data base entries.");
655
656 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
657 if ( !storeOK ) ++result;
658 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
659 if ( !storeOK ) ++result;
660 }
9f016d99 661 } else {
cf4216a3 662 Log ("Error: no entries in pedestal file list!");
9f016d99 663 result = 1;
7b54c8e9 664 }
a7dce0bc 665
795dbd3b 666 delete calPadPed;
667 delete calPadRMS;
668
a7dce0bc 669 return result;
670}
7b54c8e9 671
672//______________________________________________________________________________________________
673
674
9f016d99 675UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
676{
677 //
678 // Read pulser calibration file from file exchage server
679 // Keep original entry from OCDB in case no new pulser calibration is available
680 //
681 TObjArray *pulserObjects=0;
682 AliTPCCalPad *pulserTmean=0;
683 AliTPCCalPad *pulserTrms=0;
684 AliTPCCalPad *pulserQmean=0;
685 AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
686 if (entry) pulserObjects = (TObjArray*)entry->GetObject();
687 if ( pulserObjects==NULL ) {
688 Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
689 pulserObjects = new TObjArray;
690 }
691
692 pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
693 if ( !pulserTmean ) {
694 pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
695 pulserObjects->Add(pulserTmean);
696 }
697 pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
698 if ( !pulserTrms ) {
699 pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
700 pulserObjects->Add(pulserTrms);
701 }
702 pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
703 if ( !pulserQmean ) {
704 pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
705 pulserObjects->Add(pulserQmean);
706 }
707
708
709 UInt_t result=0;
710
711 Int_t nSectors = fROC->GetNSectors();
712 TList* list = GetFileSources(sourceFXS,"pulser");
713
714 if (list && list->GetEntries()>0) {
715
716// loop through all files from LDCs
717
bdffc5fb 718 Bool_t changed=false;
9f016d99 719 UInt_t index = 0;
720 while (list->At(index)!=NULL) {
721 TObjString* fileNameEntry = (TObjString*) list->At(index);
722 if (fileNameEntry!=NULL) {
723 TString fileName = GetFile(sourceFXS, "pulser",
724 fileNameEntry->GetString().Data());
725 TFile *f = TFile::Open(fileName);
726 if (!f) {
727 Log ("Error opening pulser file.");
728 result =2;
729 break;
730 }
731 AliTPCCalibPulser *calPulser;
e73181c9 732 f->GetObject("tpcCalibPulser",calPulser);
67a165ed 733 if ( !calPulser ) {
734 Log ("No pulser calibration object in file.");
735 result = 2;
736 break;
737 }
9f016d99 738
739 // replace entries for the sectors available in the present file
740
bdffc5fb 741 changed=true;
9f016d99 742 for (Int_t sector=0; sector<nSectors; sector++) {
743 AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
744 if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector);
745 AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
746 if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector);
747 AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
748 if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector);
749 }
a480de15 750 delete calPulser;
342d3b42 751 f->Close();
9f016d99 752 }
753 ++index;
754 } // while(list)
755//
756// Store updated pedestal entry to OCDB
757//
bdffc5fb 758 if (changed) {
759 AliCDBMetaData metaData;
760 metaData.SetBeamPeriod(0);
761 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 762 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 763 metaData.SetComment("Preprocessor AliTPC data base entries.");
764
765 Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
766 if ( !storeOK ) ++result;
767 }
9f016d99 768 } else {
cf4216a3 769 Log ("Error: no entries in pulser file list!");
9f016d99 770 result = 1;
771 }
795dbd3b 772 pulserObjects->Delete();
773 delete pulserObjects;
9f016d99 774
775 return result;
776}
777
70f224dd 778//______________________________________________________________________________________________
779
780
781UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
782{
783 //
784 // Read Raw calibration file from file exchage server
785 //
786
787 UInt_t result=0;
90581ff1 788 TObjArray* rawArray = new TObjArray;
70f224dd 789
9b1478f9 790 TList* list = GetFileSources(sourceFXS,"tpcCalibRaw");
70f224dd 791
792 if (list && list->GetEntries()>0) {
793
794// loop through all files
795
796 UInt_t index = 0;
797 while (list->At(index)!=NULL) {
798 TObjString* fileNameEntry = (TObjString*) list->At(index);
799 if (fileNameEntry!=NULL) {
800 TString fileName = GetFile(sourceFXS, "tpcCalibRaw",
801 fileNameEntry->GetString().Data());
802 TFile *f = TFile::Open(fileName);
803 if (!f) {
804 Log ("Error opening raw file.");
805 result =2;
806 break;
807 }
90581ff1 808 AliTPCCalibRaw *calRaw;
70f224dd 809 f->GetObject("tpcCalibRaw",calRaw);
810 if ( !calRaw ) {
811 Log ("No raw calibration object in file.");
812 result = 2;
813 break;
814 }
90581ff1 815 rawArray->Add(calRaw);
70f224dd 816 f->Close();
817 }
818 ++index;
819 } // while(list)
820//
821// Store updated pedestal entry to OCDB
822//
823 AliCDBMetaData metaData;
824 metaData.SetBeamPeriod(0);
825 metaData.SetResponsible("Haavard Helstrup");
826 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
827 metaData.SetComment("Preprocessor AliTPC data base entries.");
828
90581ff1 829 Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE);
70f224dd 830 if ( !storeOK ) ++result;
831 } else {
cf4216a3 832 Log ("Error: no entries in raw file list!");
70f224dd 833 result = 1;
834 }
795dbd3b 835
836 rawArray->Delete();
837 delete rawArray;
70f224dd 838
839 return result;
840}
841//______________________________________________________________________________________________
842
9f016d99 843UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
844{
845 //
846 // Read Central Electrode file from file exchage server
70f224dd 847 //
9f016d99 848 //
9f016d99 849 AliTPCCalPad *ceTmean=0;
850 AliTPCCalPad *ceTrms=0;
851 AliTPCCalPad *ceQmean=0;
bb30a935 852 TObjArray *rocTtime=0;
853 TObjArray *rocQtime=0;
854
70f224dd 855 TObjArray *ceObjects= new TObjArray;
856
9f016d99 857
bb30a935 858 Int_t nSectors = fROC->GetNSectors();
859
70f224dd 860 ceTmean = new AliTPCCalPad("CETmean","CETmean");
861 ceObjects->Add(ceTmean);
9f016d99 862
70f224dd 863 ceTrms = new AliTPCCalPad("CETrms","CETrms");
864 ceObjects->Add(ceTrms);
865
866 ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
867 ceObjects->Add(ceQmean);
868
869 rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average
870 rocTtime->SetName("rocTtime");
871 ceObjects->Add(rocTtime);
872
873 rocQtime = new TObjArray(nSectors);
874 rocQtime->SetName("rocQtime");
875 ceObjects->Add(rocQtime);
876
9f016d99 877
878 UInt_t result=0;
879
9f016d99 880 TList* list = GetFileSources(sourceFXS,"CE");
881
882 if (list && list->GetEntries()>0) {
883
884// loop through all files from LDCs
885
886 UInt_t index = 0;
887 while (list->At(index)!=NULL) {
888 TObjString* fileNameEntry = (TObjString*) list->At(index);
889 if (fileNameEntry!=NULL) {
890 TString fileName = GetFile(sourceFXS, "CE",
891 fileNameEntry->GetString().Data());
892 TFile *f = TFile::Open(fileName);
893 if (!f) {
894 Log ("Error opening central electrode file.");
895 result =2;
896 break;
897 }
898 AliTPCCalibCE *calCE;
e73181c9 899 f->GetObject("tpcCalibCE",calCE);
9f016d99 900
7c2575c4 901 if (!calCE) {
902 Log ("No valid calibCE object.");
903 result=2;
904 break;
905 }
9f016d99 906 // replace entries for the sectors available in the present file
907
908 for (Int_t sector=0; sector<nSectors; sector++) {
909 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
910 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
911 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
912 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
913 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
38fcad6d 914 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
bb30a935 915 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
916 if ( grT ) rocTtime->AddAt(grT,sector);
917 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
a8ee5a87 918 if ( grQ ) rocQtime->AddAt(grQ,sector);
9f016d99 919 }
70f224dd 920
921 TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
922 if ( grT ) rocTtime->AddAt(grT,nSectors);
923 grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
924 if ( grT ) rocTtime->AddAt(grT,nSectors+1);
925
926
a480de15 927 delete calCE;
342d3b42 928 f->Close();
9f016d99 929 }
930 ++index;
931 } // while(list)
932//
933// Store updated pedestal entry to OCDB
934//
935 AliCDBMetaData metaData;
936 metaData.SetBeamPeriod(0);
937 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 938 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9f016d99 939 metaData.SetComment("Preprocessor AliTPC data base entries.");
940
941 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
942 if ( !storeOK ) ++result;
943
944 } else {
cf4216a3 945 Log ("Error: no CE entries available from FXS!");
9f016d99 946 result = 1;
947 }
948
795dbd3b 949 ceObjects->Delete();
950 delete ceObjects;
951
9f016d99 952 return result;
953}
dca91b3f 954//______________________________________________________________________________________________
955
956UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
957{
958 //
959 // Read Quality Assurance file from file exchage server
960 //
961
962 UInt_t result=0;
963
964 TList* list = GetFileSources(sourceFXS,"QA");
965
966 if (list && list->GetEntries()>0) {
967
968// only one QA objetc should be available!
969
970 AliTPCdataQA *calQA;
971
972 UInt_t nentries = list->GetEntries();
973 UInt_t index=0;
974 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
975 TObjString* fileNameEntry = (TObjString*) list->At(index);
976 if (fileNameEntry!=NULL) {
977 TString fileName = GetFile(sourceFXS, "QA",
978 fileNameEntry->GetString().Data());
979 TFile *f = TFile::Open(fileName);
980 if (!f) {
981 Log ("Error opening QA file.");
a2465b54 982 result =2;
983 } else {
984 f->GetObject("tpcCalibQA",calQA);
7c2575c4 985 if ( calQA ) {
dca91b3f 986//
987// Store updated pedestal entry to OCDB
988//
7c2575c4 989 AliCDBMetaData metaData;
990 metaData.SetBeamPeriod(0);
991 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 992 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
7c2575c4 993 metaData.SetComment("Preprocessor AliTPC data base entries.");
994
cf4216a3 995 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
7c2575c4 996 if ( !storeOK ) ++result;
795dbd3b 997
998 delete calQA;
7c2575c4 999 }
a2465b54 1000 }
1001 } else {
1002 Log ("Error: no QA files on FXS!");
1003 result = 2;
1004 }
dca91b3f 1005 } else {
a2465b54 1006 Log ("Error: no QA entries in FXS list!");
dca91b3f 1007 result = 1;
1008 }
dca91b3f 1009 return result;
1010}
1011
9054511b 1012//______________________________________________________________________________________________
1013
1014
1015UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS)
1016{
1017 //
1018 // Read pulser calibration file from file exchage server
1019 // Keep original entry from OCDB in case no new pulser calibration is available
1020 //
1021 TObjArray *altroObjects=0;
1022 AliTPCCalPad *acqStart=0;
1023 AliTPCCalPad *zsThr=0;
1024 AliTPCCalPad *acqStop=0;
1025 AliTPCCalPad *FPED=0;
1026 AliTPCCalPad *masked=0;
cf4216a3 1027 AliTPCCalPad *k1=0, *k2=0, *k3=0;
1028 AliTPCCalPad *l1=0, *l2=0, *l3=0;
1029 TMap *mapRCUconfig=0;
9054511b 1030
14ae505e 1031 AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
9054511b 1032 if (entry) altroObjects = (TObjArray*)entry->GetObject();
1033 if ( altroObjects==NULL ) {
1034 Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
1035 altroObjects = new TObjArray;
1036 }
1037
1038 acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1039 if ( !acqStart ) {
1040 acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1041 altroObjects->Add(acqStart);
1042 }
1043 zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
1044 if ( !zsThr ) {
1045 zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1046 altroObjects->Add(zsThr);
1047 }
1048 FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
1049 if ( !FPED ) {
1050 FPED = new AliTPCCalPad("FPED","FPED");
1051 altroObjects->Add(FPED);
1052 }
1053 acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1054 if ( !acqStop ) {
1055 acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1056 altroObjects->Add(acqStop);
1057 }
1058 masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
1059 if ( !masked ) {
1060 masked = new AliTPCCalPad("Masked","Masked");
1061 altroObjects->Add(masked);
1062 }
cf4216a3 1063 k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
1064 if ( !k1 ) {
1065 k1 = new AliTPCCalPad("K1","K1");
1066 altroObjects->Add(k1);
1067 }
1068 k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
1069 if ( !k2 ) {
1070 k2 = new AliTPCCalPad("K2","K2");
1071 altroObjects->Add(k2);
1072 }
1073 k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
1074 if ( !k3 ) {
1075 k3 = new AliTPCCalPad("K3","K3");
1076 altroObjects->Add(k3);
1077 }
1078 l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
1079 if ( !l1 ) {
1080 l1 = new AliTPCCalPad("L1","L1");
1081 altroObjects->Add(l1);
1082 }
1083 l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
1084 if ( !l2 ) {
1085 l2 = new AliTPCCalPad("L2","L2");
1086 altroObjects->Add(l2);
1087 }
1088 l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
1089 if ( !l3 ) {
1090 l3 = new AliTPCCalPad("L3","L3");
1091 altroObjects->Add(l3);
1092 }
1093 mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1094 if (!mapRCUconfig) {
1095 mapRCUconfig = new TMap();
1096 mapRCUconfig->SetName("RCUconfig");
1097 altroObjects->Add(mapRCUconfig);
1098 }
9054511b 1099
1100
1101 UInt_t result=0;
1102 TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1103
1104 Int_t nSectors = fROC->GetNSectors();
1105 Bool_t changed=false;
1106 for ( Int_t id=0; id<2; id++) {
1107 TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
1108
1109 if (list && list->GetEntries()>0) {
1110 if (altroObjects == 0 ) altroObjects = new TObjArray;
1111
1112// loop through all files from LDCs
1113
1114 UInt_t index = 0;
1115 while (list->At(index)!=NULL) {
1116 TObjString* fileNameEntry = (TObjString*) list->At(index);
1117 if (fileNameEntry!=NULL) {
1118 TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1119 fileNameEntry->GetString().Data());
1120 TFile *f = TFile::Open(fileName);
1121 if (!f) {
1122 char message[40];
1123 sprintf(message,"Error opening Altro configuration file, id = %d",id);
1124 Log (message);
1125 result =2;
1126 break;
1127 }
1128 TObjArray *altroFXS;
1129 f->GetObject("AltroConfig",altroFXS);
1130 if ( !altroFXS ) {
1131 Log ("No Altro configuration object in file.");
1132 result = 2;
1133 break;
1134 }
1135
1136 // replace entries for the sectors available in the present file
1137 AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1138 AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1139 AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1140 AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1141 AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
cf4216a3 1142 AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1143 AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1144 AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1145 AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1146 AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1147 AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1148 TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1149 TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
1150
9054511b 1151 changed=true;
1152 for (Int_t sector=0; sector<nSectors; sector++) {
1153
1154 if (acqStartFXS) {
1155 AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1156 if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1157 }
1158 if (zsThrFXS ) {
1159 AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1160 if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1161 }
1162 if (acqStopFXS) {
1163 AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1164 if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1165 }
1166 if (FPEDFXS ) {
1167 AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
2d47cfd4 1168 if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
9054511b 1169 }
1170 if (maskedFXS) {
1171 AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1172 if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1173 }
cf4216a3 1174 if (k1FXS) {
1175 AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1176 if ( rocK1 ) k1->SetCalROC(rocK1,sector);
1177 }
1178 if (k2FXS) {
1179 AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1180 if ( rocK2 ) k2->SetCalROC(rocK2,sector);
1181 }
1182 if (k3FXS) {
1183 AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1184 if ( rocK3 ) k3->SetCalROC(rocK3,sector);
1185 }
1186 if (l1FXS) {
1187 AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1188 if ( rocL1 ) l1->SetCalROC(rocL1,sector);
1189 }
1190 if (l2FXS) {
1191 AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1192 if ( rocL2 ) l2->SetCalROC(rocL2,sector);
1193 }
1194 if (l3FXS) {
1195 AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1196 if ( rocL3 ) l3->SetCalROC(rocL3,sector);
1197 }
1198 }
1199 if (mapRCUconfigFXS) {
1200 Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1201 TObjString* keyFXS;
1202 TVectorF* vecFXS;
1203 TVectorF* vec; // nSectors = 72 (total number of inner/outer sectors)
1204 for (Int_t i=0; i<mapEntries; ++i) {
1205 keyFXS=(TObjString*)mapFXSiter->Next();
1206 vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1207 vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1208 if (!vec) {
1209 vec = new TVectorF(3*nSectors);
1210 *vec = -1;
1211 mapRCUconfig->Add(keyFXS,vec);
1212 }
1213 if (vec->GetNoElements() != 3*nSectors ) {
1214 vec->ResizeTo(3*nSectors);
1215 }
1216 if (id==0) { // A side
1217 vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1218 vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1219 } else { // C side
1220 vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1221 vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1222 }
1223 }
9054511b 1224 }
1225 delete altroFXS;
1226 f->Close();
1227 }
1228 ++index;
1229 } // while(list)
1230 } else {
cf4216a3 1231 Log ("Error: no entries in AltroConfig file list!");
9054511b 1232 result = 1;
1233 }
1234
1235 } // for - id
1236//
1237// Store updated pedestal entry to OCDB
1238//
1239 if (changed) {
1240 AliCDBMetaData metaData;
1241 metaData.SetBeamPeriod(0);
1242 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1243 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9054511b 1244 metaData.SetComment("Preprocessor AliTPC data base entries.");
1245
dbc10140 1246 Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
9054511b 1247 if ( !storeOK ) ++result;
1248 }
1249
795dbd3b 1250 altroObjects->Delete();
1251 delete altroObjects;
1252
9054511b 1253 return result;
1254}