added += and + for AliFlowVector
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessor.cxx
CommitLineData
54472e4f 1/**************************************************************************
2 * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
72df5829 16
54472e4f 17#include "AliTPCPreprocessor.h"
a7dce0bc 18#include "AliShuttleInterface.h"
54472e4f 19
20#include "AliCDBMetaData.h"
21#include "AliDCSValue.h"
22#include "AliLog.h"
23#include "AliTPCSensorTempArray.h"
a7dce0bc 24#include "AliTPCROC.h"
25#include "AliTPCCalROC.h"
26#include "AliTPCCalPad.h"
27#include "AliTPCCalibPedestal.h"
9f016d99 28#include "AliTPCCalibPulser.h"
29#include "AliTPCCalibCE.h"
70f224dd 30#include "AliTPCCalibRaw.h"
dca91b3f 31#include "AliTPCdataQA.h"
eeeac1b2 32#include "ARVersion.h"
9e66a8dd 33#include "TFile.h"
7b54c8e9 34#include "TTree.h"
bb30a935 35#include "TGraph.h"
7b54c8e9 36#include "TEnv.h"
bb30a935 37#include "TParameter.h"
54472e4f 38
39#include <TTimeStamp.h>
40
a7dce0bc 41const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
42const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
bb30a935 43const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
9054511b 44const TString kPulserRunType = "PULSER"; // pulser run identifier
bdffc5fb 45const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
9054511b 46const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
47const TString kLaserRunType = "LASER"; // laser run identifier
9c754ce7 48const TString kDaqRunType = "DAQ"; // DAQ run identifier
87d77b35 49const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
bee89eeb 50//const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
68b512ca 51const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
09a746c5 52const Int_t kNumPressureSensors = 3; // number of pressure sensors
53const char* kPressureSensorNames[kNumPressureSensors] = {
54 "CavernAtmosPressure",
55 "CavernAtmosPressure2",
56 "SurfaceAtmosPressure" };
57
cf4216a3 58
54472e4f 59//
60// This class is the SHUTTLE preprocessor for the TPC detector.
54472e4f 61//
62
63ClassImp(AliTPCPreprocessor)
64
65//______________________________________________________________________________________________
6d07bf74 66AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
67 AliPreprocessor("TPC",shuttle),
09a746c5 68 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
69 fPressure(0), fConfigOK(kTRUE), fROC(0)
54472e4f 70{
71 // constructor
a7dce0bc 72 fROC = AliTPCROC::Instance();
72534123 73
74 // define run types to be processed
75
76 AddRunType(kPedestalRunType);
77 AddRunType(kPulserRunType);
78 AddRunType(kPhysicsRunType);
72534123 79 AddRunType(kCosmicRunType);
80 AddRunType(kLaserRunType);
81 AddRunType(kDaqRunType);
82
54472e4f 83}
72df5829 84//______________________________________________________________________________________________
f4a89669 85 AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) :
86 AliPreprocessor("TPC",0),
09a746c5 87 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
88 fPressure(0), fConfigOK(kTRUE), fROC(0)
f4a89669 89 {
90
91 Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 92//
93// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
f4a89669 94 }
54472e4f 95
96//______________________________________________________________________________________________
97AliTPCPreprocessor::~AliTPCPreprocessor()
98{
99 // destructor
a7dce0bc 100
54472e4f 101 delete fTemp;
bdffc5fb 102 delete fHighVoltage;
795dbd3b 103 delete fHighVoltageStat;
104 delete fGoofie;
09a746c5 105 delete fPressure;
54472e4f 106}
72df5829 107//______________________________________________________________________________________________
108AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
109{
110 Fatal("operator =", "assignment operator not implemented");
111 return *this;
112}
113
54472e4f 114
115//______________________________________________________________________________________________
116void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
117 UInt_t endTime)
118{
bb30a935 119
09a746c5 120 AliPreprocessor::Initialize(run, startTime, endTime);
54472e4f 121
122 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
f4a89669 123 TTimeStamp((time_t)startTime,0).AsString(),
124 TTimeStamp((time_t)endTime,0).AsString()));
54472e4f 125
7b54c8e9 126 // Preprocessor configuration
127
37092b2b 128 AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
7b54c8e9 129 if (entry) fConfEnv = (TEnv*) entry->GetObject();
130 if ( fConfEnv==0 ) {
7b54c8e9 131 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
37092b2b 132 fConfigOK = kFALSE;
133 return;
7b54c8e9 134 }
135
18eade96 136 // Temperature sensors
137
136e44f7 138 TTree *confTree = 0;
139
140 TString tempConf = fConfEnv->GetValue("Temperature","ON");
141 tempConf.ToUpper();
142 if (tempConf != "OFF" ) {
7b54c8e9 143 entry = GetFromOCDB("Config", "Temperature");
f7f602cc 144 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 145 if ( confTree==0 ) {
18eade96 146 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
147 fConfigOK = kFALSE;
f7f602cc 148 return;
18eade96 149 }
09a746c5 150 fTemp = new AliTPCSensorTempArray(startTime, endTime, confTree, kAmandaTemp);
18eade96 151 fTemp->SetValCut(kValCutTemp);
152 fTemp->SetDiffCut(kDiffCutTemp);
136e44f7 153 }
18eade96 154
bdffc5fb 155 // High voltage measurements
156
136e44f7 157 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
158 hvConf.ToUpper();
159 if (hvConf != "OFF" ) {
bdffc5fb 160 confTree=0;
161 entry=0;
162 entry = GetFromOCDB("Config", "HighVoltage");
163 if (entry) confTree = (TTree*) entry->GetObject();
164 if ( confTree==0 ) {
165 Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
166 fConfigOK = kFALSE;
167 return;
168 }
fe7f3fe2 169 fHighVoltage = new AliDCSSensorArray(startTime, endTime, confTree);
bff20895 170 }
9d2ce539 171
172 // High voltage status values
173
bff20895 174 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
175 hvStatConf.ToUpper();
176 if (hvStatConf != "OFF" ) {
9d2ce539 177 confTree=0;
178 entry=0;
179 entry = GetFromOCDB("Config", "HighVoltageStat");
180 if (entry) confTree = (TTree*) entry->GetObject();
181 if ( confTree==0 ) {
182 Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
183 fConfigOK = kFALSE;
184 return;
185 }
fe7f3fe2 186 fHighVoltageStat = new AliDCSSensorArray(startTime, endTime, confTree);
bdffc5fb 187 }
b6e9fd45 188
189 // Goofie values
190
191 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
192 goofieConf.ToUpper();
193 if (goofieConf != "OFF" ) {
194 confTree=0;
195 entry=0;
196 entry = GetFromOCDB("Config", "Goofie");
197 if (entry) confTree = (TTree*) entry->GetObject();
198 if ( confTree==0 ) {
199 Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
200 fConfigOK = kFALSE;
201 return;
202 }
09a746c5 203 fGoofie = new AliDCSSensorArray(startTime, endTime, confTree);
b6e9fd45 204 }
205
09a746c5 206 // Pressure values
207
208 TString runType = GetRunType();
209
210 if( runType == kPhysicsRunType ||
211 runType == kLaserRunType ) {
212 TString pressureConf = fConfEnv->GetValue("Pressure","ON");
213 pressureConf.ToUpper();
214 if (pressureConf != "OFF" ) {
215 TClonesArray * array = new TClonesArray("AliDCSSensor",kNumPressureSensors);
216 for(Int_t j = 0; j < kNumPressureSensors; j++) {
217 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
218 sens->SetStringID(kPressureSensorNames[j]);
219 }
220 fPressure = new AliDCSSensorArray(startTime, endTime, array);
221 }
222 }
54472e4f 223}
224
225//______________________________________________________________________________________________
226UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
227{
228 // Fills data into TPC calibrations objects
229
54472e4f 230 // Amanda servers provide information directly through dcsAliasMap
231
bb30a935 232
a7dce0bc 233 if (!fConfigOK) return 9;
136e44f7 234 UInt_t result = 0;
bb30a935 235 TObjArray *resultArray = new TObjArray();
236 TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
237 errorHandling.ToUpper();
238 TObject * status;
239
240 UInt_t dcsResult=0;
cf4216a3 241 if (!dcsAliasMap) dcsResult=1;
242 if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
243 status = new TParameter<int>("dcsResult",dcsResult);
244 resultArray->Add(status);
bb30a935 245
246
a7dce0bc 247 TString runType = GetRunType();
248
cf4216a3 249 if ( dcsResult == 0 ) {
250
54472e4f 251 // Temperature sensors are processed by AliTPCCalTemp
72df5829 252
cf4216a3 253 TString tempConf = fConfEnv->GetValue("Temperature","ON");
254 tempConf.ToUpper();
255 if (tempConf != "OFF" ) {
256 UInt_t tempResult = MapTemperature(dcsAliasMap);
c589a949 257 if ( tempConf != "TRY") result+=tempResult;
cf4216a3 258 status = new TParameter<int>("tempResult",tempResult);
259 resultArray->Add(status);
260 }
18eade96 261
bdffc5fb 262 // High Voltage recordings
263
264
cf4216a3 265 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
266 hvConf.ToUpper();
267 if (hvConf != "OFF" ) {
268 UInt_t hvResult = MapHighVoltage(dcsAliasMap);
c589a949 269 if (hvConf != "TRY") result+=hvResult;
cf4216a3 270 status = new TParameter<int>("hvResult",hvResult);
271 resultArray->Add(status);
272 }
f7f602cc 273
cf4216a3 274 // Goofie values
b6e9fd45 275
276
cf4216a3 277 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
278 goofieConf.ToUpper();
279 if (goofieConf != "OFF" ) {
280 UInt_t goofieResult = MapGoofie(dcsAliasMap);
c589a949 281 if (goofieConf != "TRY") result+=goofieResult;
cf4216a3 282 status = new TParameter<int>("goofieResult",goofieResult);
283 resultArray->Add(status);
284 }
09a746c5 285
286 // Pressure values
287
288 if( runType == kPhysicsRunType ||
289 runType == kLaserRunType ) {
290
291 TString pressureConf = fConfEnv->GetValue("Pressure","ON");
292 pressureConf.ToUpper();
293 if (pressureConf != "OFF" ) {
294 UInt_t pressureResult = MapPressure(dcsAliasMap);
295 status = new TParameter<int>("pressureResult",pressureResult);
296 resultArray->Add(status);
297 }
298 }
cf4216a3 299 }
54472e4f 300 // Other calibration information will be retrieved through FXS files
a7dce0bc 301 // examples:
54472e4f 302 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
303 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
304 //
305 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
306 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
307
9f016d99 308 // pedestal entries
54472e4f 309
a7dce0bc 310 if(runType == kPedestalRunType) {
68b512ca 311 Int_t numSources = 1;
312 Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
7b54c8e9 313 TString source = fConfEnv->GetValue("Pedestal","DAQ");
314 source.ToUpper();
136e44f7 315 if (source != "OFF" ) {
316 if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
317 if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
318 if (source == "HLTDAQ" ) {
319 numSources=2;
320 pedestalSource[0] = AliShuttleInterface::kHLT;
321 pedestalSource[1] = AliShuttleInterface::kDAQ;
322 }
323 if (source == "DAQHLT" ) numSources=2;
324 UInt_t pedestalResult=0;
325 for (Int_t i=0; i<numSources; i++ ) {
453bd596 326 pedestalResult = ExtractPedestals(pedestalSource[i]);
136e44f7 327 if ( pedestalResult == 0 ) break;
328 }
329 result += pedestalResult;
bb30a935 330 status = new TParameter<int>("pedestalResult",pedestalResult);
331 resultArray->Add(status);
68b512ca 332 }
a7dce0bc 333 }
334
9f016d99 335 // pulser trigger processing
336
68b512ca 337 if(runType == kPulserRunType) {
338 Int_t numSources = 1;
339 Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 340 TString source = fConfEnv->GetValue("Pulser","DAQ");
341 source.ToUpper();
136e44f7 342 if ( source != "OFF") {
343 if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
344 if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
345 if (source == "HLTDAQ" ) {
346 numSources=2;
347 pulserSource[0] = AliShuttleInterface::kHLT;
348 pulserSource[1] = AliShuttleInterface::kDAQ;
349 }
350 if (source == "DAQHLT" ) numSources=2;
c589a949 351 if (source == "TRY" ) numSources=2;
136e44f7 352 UInt_t pulserResult=0;
353 for (Int_t i=0; i<numSources; i++ ) {
354 pulserResult = ExtractPulser(pulserSource[i]);
355 if ( pulserResult == 0 ) break;
356 }
c589a949 357 if (source != "TRY") result += pulserResult;
bb30a935 358 status = new TParameter<int>("pulserResult",pulserResult);
359 resultArray->Add(status);
68b512ca 360 }
9f016d99 361 }
362
70f224dd 363
364// raw calibration processing
365
366 if(runType == kPhysicsRunType) {
367 Int_t numSources = 1;
368 Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
369 TString source = fConfEnv->GetValue("Raw","DAQ");
370 source.ToUpper();
371 if ( source != "OFF") {
372 if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
373 if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
374 if (source == "HLTDAQ" ) {
375 numSources=2;
376 rawSource[0] = AliShuttleInterface::kHLT;
377 rawSource[1] = AliShuttleInterface::kDAQ;
378 }
379 if (source == "DAQHLT" ) numSources=2;
c589a949 380 if (source == "TRY" ) numSources=2;
70f224dd 381 UInt_t rawResult=0;
382 for (Int_t i=0; i<numSources; i++ ) {
383 rawResult = ExtractRaw(rawSource[i]);
384 if ( rawResult == 0 ) break;
385 }
c589a949 386 if (source != "TRY" )result += rawResult;
70f224dd 387 status = new TParameter<int>("rawResult",rawResult);
388 resultArray->Add(status);
389 }
390 }
391
392
9054511b 393 // Altro configuration
394
395
396 TString altroConf = fConfEnv->GetValue("AltroConf","ON");
cf4216a3 397 altroConf.ToUpper();
9054511b 398 if (altroConf != "OFF" ) {
db9ef692 399 UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS);
c589a949 400 if (altroConf != "TRY" ) result+=altroResult;
9054511b 401 status = new TParameter<int>("altroResult",altroResult);
402 resultArray->Add(status);
403 }
68b512ca 404
405
9f016d99 406 // Central Electrode processing
407
9054511b 408 if( runType == kPhysicsRunType ||
6f3699dd 409 runType == kLaserRunType ) {
68b512ca 410
411 Int_t numSources = 1;
412 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 413 TString source = fConfEnv->GetValue("CE","DAQ");
414 source.ToUpper();
136e44f7 415 if ( source != "OFF" ) {
416 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
417 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
418 if (source == "HLTDAQ" ) {
68b512ca 419 numSources=2;
420 ceSource[0] = AliShuttleInterface::kHLT;
421 ceSource[1] = AliShuttleInterface::kDAQ;
136e44f7 422 }
423 if (source == "DAQHLT" ) numSources=2;
c589a949 424 if (source == "TRY" ) numSources=2;
136e44f7 425 UInt_t ceResult=0;
426 for (Int_t i=0; i<numSources; i++ ) {
427 ceResult = ExtractCE(ceSource[i]);
428 if ( ceResult == 0 ) break;
429 }
6f3699dd 430
431 // only flag error if CE result is missing from LASER runs
432 // -- for PHYSICS run do CE processing if data available
433
c589a949 434 if ( runType == kLaserRunType && source != "TRY" ) result += ceResult;
bb30a935 435 status = new TParameter<int>("ceResult",ceResult);
436 resultArray->Add(status);
dca91b3f 437
438 numSources = 1;
439 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
5e5c1e83 440 source = fConfEnv->GetValue("QA","DAQ");
dca91b3f 441 source.ToUpper();
442 if ( source != "OFF" ) {
443 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
444 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
445 if (source == "HLTDAQ" ) {
446 numSources=2;
447 qaSource[0] = AliShuttleInterface::kHLT;
448 qaSource[1] = AliShuttleInterface::kDAQ;
449 }
450 if (source == "DAQHLT" ) numSources=2;
c589a949 451 if (source == "TRY" ) numSources=2;
dca91b3f 452 UInt_t qaResult=0;
453 for (Int_t i=0; i<numSources; i++ ) {
454 qaResult = ExtractQA(qaSource[i]);
455 if ( qaResult == 0 ) break;
456 }
457// result += qaResult;
458 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
459 status = new TParameter<int>("qaResult",qaResult);
460 resultArray->Add(status);
68b512ca 461 }
dca91b3f 462 }
9f016d99 463 }
136e44f7 464
c589a949 465// Store component status to OCDB
466
467 AliCDBMetaData metaData;
468 metaData.SetBeamPeriod(0);
469 metaData.SetResponsible("Haavard Helstrup");
470 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
471 metaData.SetComment("Preprocessor AliTPC status.");
472 Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
473 resultArray->Delete();
474 delete resultArray;
475
476 if (errorHandling == "OFF" ) return 0;
477 return result;
478
54472e4f 479}
480//______________________________________________________________________________________________
481UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
482{
483
484 // extract DCS temperature maps. Perform fits to save space
485
72df5829 486 UInt_t result=0;
54472e4f 487 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
488 if (map) {
489 fTemp->MakeSplineFit(map);
68b512ca 490 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
67a165ed 491 if (fitFraction > kFitFraction ) {
492 AliInfo(Form("Temperature values extracted, fits performed.\n"));
493 } else {
494 Log ("Too few temperature maps fitted. \n");
495 result = 9;
496 }
54472e4f 497 } else {
67a165ed 498 Log("No temperature map extracted. \n");
72df5829 499 result=9;
54472e4f 500 }
501 delete map;
502 // Now store the final CDB file
a7dce0bc 503
504 if ( result == 0 ) {
72df5829 505 AliCDBMetaData metaData;
54472e4f 506 metaData.SetBeamPeriod(0);
507 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 508 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
54472e4f 509 metaData.SetComment("Preprocessor AliTPC data base entries.");
510
a7dce0bc 511 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
512 if ( !storeOK ) result=1;
513
72df5829 514 }
54472e4f 515
516 return result;
7b54c8e9 517
54472e4f 518}
09a746c5 519//______________________________________________________________________________________________
520UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
521{
522
523 // extract DCS pressure maps. Perform fits to save space
524
525 UInt_t result=0;
526 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
527 if (map) {
528 fPressure->MakeSplineFit(map);
529 Double_t fitFraction = 1.0*fPressure->NumFits()/fPressure->NumSensors();
530 if (fitFraction > kFitFraction ) {
1a63b1b0 531 AliInfo(Form("Pressure values extracted, fits performed.\n"));
09a746c5 532 } else {
533 Log ("Too few pressure maps fitted. \n");
534 result = 9;
535 }
536 } else {
537 Log("No pressure map extracted. \n");
538 result=9;
539 }
540 delete map;
541 return result;
542}
7b54c8e9 543
bdffc5fb 544//______________________________________________________________________________________________
545UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
546{
547
548 // extract DCS HV maps. Perform fits to save space
549
550 UInt_t result=0;
551 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
552 if (map) {
fe7f3fe2 553 fHighVoltage->MakeSplineFit(map, kTRUE); // keep both spline fits and original maps
68b512ca 554 Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors();
bdffc5fb 555 if (fitFraction > kFitFraction ) {
136e44f7 556 AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
bdffc5fb 557 } else {
558 Log ("Too few high voltage recordings fitted. \n");
559 result = 9;
560 }
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) {
942 fTemp->SetNameTitle("TempMap","TempMap");
943 ceObjects->Add(fTemp);
944 }
945
946// Pressure maps
947
948 if (fPressure) {
949 AliDCSSensor *sensor=0;
950 for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
951 sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
952 sensor->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);
953 ceObjects->Add(sensor);
954 }
955 }
9f016d99 956
957 UInt_t result=0;
958
9f016d99 959 TList* list = GetFileSources(sourceFXS,"CE");
960
961 if (list && list->GetEntries()>0) {
962
963// loop through all files from LDCs
964
965 UInt_t index = 0;
966 while (list->At(index)!=NULL) {
967 TObjString* fileNameEntry = (TObjString*) list->At(index);
968 if (fileNameEntry!=NULL) {
969 TString fileName = GetFile(sourceFXS, "CE",
970 fileNameEntry->GetString().Data());
971 TFile *f = TFile::Open(fileName);
972 if (!f) {
973 Log ("Error opening central electrode file.");
974 result =2;
975 break;
976 }
977 AliTPCCalibCE *calCE;
e73181c9 978 f->GetObject("tpcCalibCE",calCE);
9f016d99 979
7c2575c4 980 if (!calCE) {
981 Log ("No valid calibCE object.");
982 result=2;
983 break;
984 }
9f016d99 985 // replace entries for the sectors available in the present file
986
987 for (Int_t sector=0; sector<nSectors; sector++) {
988 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
989 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
990 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
991 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
992 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
38fcad6d 993 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
bb30a935 994 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
995 if ( grT ) rocTtime->AddAt(grT,sector);
996 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
a8ee5a87 997 if ( grQ ) rocQtime->AddAt(grQ,sector);
9f016d99 998 }
70f224dd 999
1000 TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
1001 if ( grT ) rocTtime->AddAt(grT,nSectors);
1002 grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
1003 if ( grT ) rocTtime->AddAt(grT,nSectors+1);
1004
1005
a480de15 1006 delete calCE;
342d3b42 1007 f->Close();
9f016d99 1008 }
1009 ++index;
1010 } // while(list)
1011//
1012// Store updated pedestal entry to OCDB
1013//
1014 AliCDBMetaData metaData;
1015 metaData.SetBeamPeriod(0);
1016 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1017 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9f016d99 1018 metaData.SetComment("Preprocessor AliTPC data base entries.");
1019
1020 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
1021 if ( !storeOK ) ++result;
1022
1023 } else {
cf4216a3 1024 Log ("Error: no CE entries available from FXS!");
9f016d99 1025 result = 1;
1026 }
1027
795dbd3b 1028 ceObjects->Delete();
1029 delete ceObjects;
1030
9f016d99 1031 return result;
1032}
dca91b3f 1033//______________________________________________________________________________________________
1034
1035UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
1036{
1037 //
1038 // Read Quality Assurance file from file exchage server
1039 //
1040
1041 UInt_t result=0;
1042
1043 TList* list = GetFileSources(sourceFXS,"QA");
1044
1045 if (list && list->GetEntries()>0) {
1046
1047// only one QA objetc should be available!
1048
1049 AliTPCdataQA *calQA;
1050
1051 UInt_t nentries = list->GetEntries();
1052 UInt_t index=0;
1053 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
1054 TObjString* fileNameEntry = (TObjString*) list->At(index);
1055 if (fileNameEntry!=NULL) {
1056 TString fileName = GetFile(sourceFXS, "QA",
1057 fileNameEntry->GetString().Data());
1058 TFile *f = TFile::Open(fileName);
1059 if (!f) {
1060 Log ("Error opening QA file.");
a2465b54 1061 result =2;
1062 } else {
1063 f->GetObject("tpcCalibQA",calQA);
7c2575c4 1064 if ( calQA ) {
dca91b3f 1065//
1066// Store updated pedestal entry to OCDB
1067//
7c2575c4 1068 AliCDBMetaData metaData;
1069 metaData.SetBeamPeriod(0);
1070 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1071 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
7c2575c4 1072 metaData.SetComment("Preprocessor AliTPC data base entries.");
1073
cf4216a3 1074 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
7c2575c4 1075 if ( !storeOK ) ++result;
795dbd3b 1076
1077 delete calQA;
7c2575c4 1078 }
a2465b54 1079 }
1080 } else {
1081 Log ("Error: no QA files on FXS!");
1082 result = 2;
1083 }
dca91b3f 1084 } else {
a2465b54 1085 Log ("Error: no QA entries in FXS list!");
dca91b3f 1086 result = 1;
1087 }
dca91b3f 1088 return result;
1089}
1090
9054511b 1091//______________________________________________________________________________________________
1092
1093
1094UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS)
1095{
1096 //
1097 // Read pulser calibration file from file exchage server
1098 // Keep original entry from OCDB in case no new pulser calibration is available
1099 //
1100 TObjArray *altroObjects=0;
1101 AliTPCCalPad *acqStart=0;
1102 AliTPCCalPad *zsThr=0;
1103 AliTPCCalPad *acqStop=0;
1104 AliTPCCalPad *FPED=0;
1105 AliTPCCalPad *masked=0;
cf4216a3 1106 AliTPCCalPad *k1=0, *k2=0, *k3=0;
1107 AliTPCCalPad *l1=0, *l2=0, *l3=0;
1108 TMap *mapRCUconfig=0;
9054511b 1109
14ae505e 1110 AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
9054511b 1111 if (entry) altroObjects = (TObjArray*)entry->GetObject();
1112 if ( altroObjects==NULL ) {
1113 Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
1114 altroObjects = new TObjArray;
1115 }
1116
1117 acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1118 if ( !acqStart ) {
1119 acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1120 altroObjects->Add(acqStart);
1121 }
1122 zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
1123 if ( !zsThr ) {
1124 zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1125 altroObjects->Add(zsThr);
1126 }
1127 FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
1128 if ( !FPED ) {
1129 FPED = new AliTPCCalPad("FPED","FPED");
1130 altroObjects->Add(FPED);
1131 }
1132 acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1133 if ( !acqStop ) {
1134 acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1135 altroObjects->Add(acqStop);
1136 }
1137 masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
1138 if ( !masked ) {
1139 masked = new AliTPCCalPad("Masked","Masked");
1140 altroObjects->Add(masked);
1141 }
cf4216a3 1142 k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
1143 if ( !k1 ) {
1144 k1 = new AliTPCCalPad("K1","K1");
1145 altroObjects->Add(k1);
1146 }
1147 k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
1148 if ( !k2 ) {
1149 k2 = new AliTPCCalPad("K2","K2");
1150 altroObjects->Add(k2);
1151 }
1152 k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
1153 if ( !k3 ) {
1154 k3 = new AliTPCCalPad("K3","K3");
1155 altroObjects->Add(k3);
1156 }
1157 l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
1158 if ( !l1 ) {
1159 l1 = new AliTPCCalPad("L1","L1");
1160 altroObjects->Add(l1);
1161 }
1162 l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
1163 if ( !l2 ) {
1164 l2 = new AliTPCCalPad("L2","L2");
1165 altroObjects->Add(l2);
1166 }
1167 l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
1168 if ( !l3 ) {
1169 l3 = new AliTPCCalPad("L3","L3");
1170 altroObjects->Add(l3);
1171 }
1172 mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1173 if (!mapRCUconfig) {
1174 mapRCUconfig = new TMap();
1175 mapRCUconfig->SetName("RCUconfig");
1176 altroObjects->Add(mapRCUconfig);
1177 }
9054511b 1178
1179
1180 UInt_t result=0;
1181 TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1182
1183 Int_t nSectors = fROC->GetNSectors();
1184 Bool_t changed=false;
1185 for ( Int_t id=0; id<2; id++) {
1186 TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
1187
1188 if (list && list->GetEntries()>0) {
1189 if (altroObjects == 0 ) altroObjects = new TObjArray;
1190
1191// loop through all files from LDCs
1192
1193 UInt_t index = 0;
1194 while (list->At(index)!=NULL) {
1195 TObjString* fileNameEntry = (TObjString*) list->At(index);
1196 if (fileNameEntry!=NULL) {
1197 TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1198 fileNameEntry->GetString().Data());
1199 TFile *f = TFile::Open(fileName);
1200 if (!f) {
1201 char message[40];
1202 sprintf(message,"Error opening Altro configuration file, id = %d",id);
1203 Log (message);
1204 result =2;
1205 break;
1206 }
1207 TObjArray *altroFXS;
1208 f->GetObject("AltroConfig",altroFXS);
1209 if ( !altroFXS ) {
1210 Log ("No Altro configuration object in file.");
1211 result = 2;
1212 break;
1213 }
1214
1215 // replace entries for the sectors available in the present file
1216 AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1217 AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1218 AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1219 AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1220 AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
cf4216a3 1221 AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1222 AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1223 AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1224 AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1225 AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1226 AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1227 TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1228 TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
1229
9054511b 1230 changed=true;
1231 for (Int_t sector=0; sector<nSectors; sector++) {
1232
1233 if (acqStartFXS) {
1234 AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1235 if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1236 }
1237 if (zsThrFXS ) {
1238 AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1239 if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1240 }
1241 if (acqStopFXS) {
1242 AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1243 if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1244 }
1245 if (FPEDFXS ) {
1246 AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
2d47cfd4 1247 if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
9054511b 1248 }
1249 if (maskedFXS) {
1250 AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1251 if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1252 }
cf4216a3 1253 if (k1FXS) {
1254 AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1255 if ( rocK1 ) k1->SetCalROC(rocK1,sector);
1256 }
1257 if (k2FXS) {
1258 AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1259 if ( rocK2 ) k2->SetCalROC(rocK2,sector);
1260 }
1261 if (k3FXS) {
1262 AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1263 if ( rocK3 ) k3->SetCalROC(rocK3,sector);
1264 }
1265 if (l1FXS) {
1266 AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1267 if ( rocL1 ) l1->SetCalROC(rocL1,sector);
1268 }
1269 if (l2FXS) {
1270 AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1271 if ( rocL2 ) l2->SetCalROC(rocL2,sector);
1272 }
1273 if (l3FXS) {
1274 AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1275 if ( rocL3 ) l3->SetCalROC(rocL3,sector);
1276 }
1277 }
1278 if (mapRCUconfigFXS) {
1279 Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1280 TObjString* keyFXS;
1281 TVectorF* vecFXS;
1282 TVectorF* vec; // nSectors = 72 (total number of inner/outer sectors)
1283 for (Int_t i=0; i<mapEntries; ++i) {
1284 keyFXS=(TObjString*)mapFXSiter->Next();
1285 vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1286 vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1287 if (!vec) {
1288 vec = new TVectorF(3*nSectors);
1289 *vec = -1;
1290 mapRCUconfig->Add(keyFXS,vec);
1291 }
1292 if (vec->GetNoElements() != 3*nSectors ) {
1293 vec->ResizeTo(3*nSectors);
1294 }
1295 if (id==0) { // A side
1296 vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1297 vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1298 } else { // C side
1299 vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1300 vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1301 }
1302 }
9054511b 1303 }
1304 delete altroFXS;
1305 f->Close();
1306 }
1307 ++index;
1308 } // while(list)
1309 } else {
cf4216a3 1310 Log ("Error: no entries in AltroConfig file list!");
9054511b 1311 result = 1;
1312 }
1313
1314 } // for - id
1315//
1316// Store updated pedestal entry to OCDB
1317//
1318 if (changed) {
1319 AliCDBMetaData metaData;
1320 metaData.SetBeamPeriod(0);
1321 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1322 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9054511b 1323 metaData.SetComment("Preprocessor AliTPC data base entries.");
1324
dbc10140 1325 Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
9054511b 1326 if ( !storeOK ) ++result;
1327 }
1328
795dbd3b 1329 altroObjects->Delete();
1330 delete altroObjects;
1331
9054511b 1332 return result;
1333}