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