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