Test version
[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);
257 result=tempResult;
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);
269 result+=hvResult;
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);
281 result+=goofieResult;
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;
351 UInt_t pulserResult=0;
352 for (Int_t i=0; i<numSources; i++ ) {
353 pulserResult = ExtractPulser(pulserSource[i]);
354 if ( pulserResult == 0 ) break;
355 }
356 result += pulserResult;
bb30a935 357 status = new TParameter<int>("pulserResult",pulserResult);
358 resultArray->Add(status);
68b512ca 359 }
9f016d99 360 }
361
70f224dd 362
363// raw calibration processing
364
365 if(runType == kPhysicsRunType) {
366 Int_t numSources = 1;
367 Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
368 TString source = fConfEnv->GetValue("Raw","DAQ");
369 source.ToUpper();
370 if ( source != "OFF") {
371 if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
372 if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
373 if (source == "HLTDAQ" ) {
374 numSources=2;
375 rawSource[0] = AliShuttleInterface::kHLT;
376 rawSource[1] = AliShuttleInterface::kDAQ;
377 }
378 if (source == "DAQHLT" ) numSources=2;
379 UInt_t rawResult=0;
380 for (Int_t i=0; i<numSources; i++ ) {
381 rawResult = ExtractRaw(rawSource[i]);
382 if ( rawResult == 0 ) break;
383 }
384 result += rawResult;
385 status = new TParameter<int>("rawResult",rawResult);
386 resultArray->Add(status);
387 }
388 }
389
390
9054511b 391 // Altro configuration
392
393
394 TString altroConf = fConfEnv->GetValue("AltroConf","ON");
cf4216a3 395 altroConf.ToUpper();
9054511b 396 if (altroConf != "OFF" ) {
db9ef692 397 UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS);
9054511b 398 result+=altroResult;
399 status = new TParameter<int>("altroResult",altroResult);
400 resultArray->Add(status);
401 }
68b512ca 402
403
9f016d99 404 // Central Electrode processing
405
9054511b 406 if( runType == kPhysicsRunType ||
6f3699dd 407 runType == kLaserRunType ) {
68b512ca 408
409 Int_t numSources = 1;
410 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 411 TString source = fConfEnv->GetValue("CE","DAQ");
412 source.ToUpper();
136e44f7 413 if ( source != "OFF" ) {
414 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
415 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
416 if (source == "HLTDAQ" ) {
68b512ca 417 numSources=2;
418 ceSource[0] = AliShuttleInterface::kHLT;
419 ceSource[1] = AliShuttleInterface::kDAQ;
136e44f7 420 }
421 if (source == "DAQHLT" ) numSources=2;
422 UInt_t ceResult=0;
423 for (Int_t i=0; i<numSources; i++ ) {
424 ceResult = ExtractCE(ceSource[i]);
425 if ( ceResult == 0 ) break;
426 }
6f3699dd 427
428 // only flag error if CE result is missing from LASER runs
429 // -- for PHYSICS run do CE processing if data available
430
431 if ( runType == kLaserRunType ) result += ceResult;
bb30a935 432 status = new TParameter<int>("ceResult",ceResult);
433 resultArray->Add(status);
dca91b3f 434
435 numSources = 1;
436 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
5e5c1e83 437 source = fConfEnv->GetValue("QA","DAQ");
dca91b3f 438 source.ToUpper();
439 if ( source != "OFF" ) {
440 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
441 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
442 if (source == "HLTDAQ" ) {
443 numSources=2;
444 qaSource[0] = AliShuttleInterface::kHLT;
445 qaSource[1] = AliShuttleInterface::kDAQ;
446 }
447 if (source == "DAQHLT" ) numSources=2;
448 UInt_t qaResult=0;
449 for (Int_t i=0; i<numSources; i++ ) {
450 qaResult = ExtractQA(qaSource[i]);
451 if ( qaResult == 0 ) break;
452 }
453// result += qaResult;
454 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
455 status = new TParameter<int>("qaResult",qaResult);
456 resultArray->Add(status);
68b512ca 457 }
dca91b3f 458 }
9f016d99 459 }
136e44f7 460
136e44f7 461 if (errorHandling == "OFF" ) {
bb30a935 462 AliCDBMetaData metaData;
463 metaData.SetBeamPeriod(0);
464 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 465 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bb30a935 466 metaData.SetComment("Preprocessor AliTPC status.");
467 Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
468 resultArray->Delete();
795dbd3b 469 delete resultArray;
bb30a935 470 return 0;
136e44f7 471 } else {
795dbd3b 472 delete resultArray;
bb30a935 473 return result;
136e44f7 474 }
54472e4f 475}
476//______________________________________________________________________________________________
477UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
478{
479
480 // extract DCS temperature maps. Perform fits to save space
481
72df5829 482 UInt_t result=0;
54472e4f 483 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
484 if (map) {
485 fTemp->MakeSplineFit(map);
68b512ca 486 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
67a165ed 487 if (fitFraction > kFitFraction ) {
488 AliInfo(Form("Temperature values extracted, fits performed.\n"));
489 } else {
490 Log ("Too few temperature maps fitted. \n");
491 result = 9;
492 }
54472e4f 493 } else {
67a165ed 494 Log("No temperature map extracted. \n");
72df5829 495 result=9;
54472e4f 496 }
497 delete map;
498 // Now store the final CDB file
a7dce0bc 499
500 if ( result == 0 ) {
72df5829 501 AliCDBMetaData metaData;
54472e4f 502 metaData.SetBeamPeriod(0);
503 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 504 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
54472e4f 505 metaData.SetComment("Preprocessor AliTPC data base entries.");
506
a7dce0bc 507 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
508 if ( !storeOK ) result=1;
509
72df5829 510 }
54472e4f 511
512 return result;
7b54c8e9 513
54472e4f 514}
09a746c5 515//______________________________________________________________________________________________
516UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
517{
518
519 // extract DCS pressure maps. Perform fits to save space
520
521 UInt_t result=0;
522 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
523 if (map) {
524 fPressure->MakeSplineFit(map);
525 Double_t fitFraction = 1.0*fPressure->NumFits()/fPressure->NumSensors();
526 if (fitFraction > kFitFraction ) {
1a63b1b0 527 AliInfo(Form("Pressure values extracted, fits performed.\n"));
09a746c5 528 } else {
529 Log ("Too few pressure maps fitted. \n");
530 result = 9;
531 }
532 } else {
533 Log("No pressure map extracted. \n");
534 result=9;
535 }
536 delete map;
537 return result;
538}
7b54c8e9 539
bdffc5fb 540//______________________________________________________________________________________________
541UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
542{
543
544 // extract DCS HV maps. Perform fits to save space
545
546 UInt_t result=0;
547 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
548 if (map) {
fe7f3fe2 549 fHighVoltage->MakeSplineFit(map, kTRUE); // keep both spline fits and original maps
68b512ca 550 Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors();
bdffc5fb 551 if (fitFraction > kFitFraction ) {
136e44f7 552 AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
bdffc5fb 553 } else {
554 Log ("Too few high voltage recordings fitted. \n");
555 result = 9;
556 }
557 } else {
558 Log("No high voltage recordings extracted. \n");
559 result=9;
560 }
561 delete map;
9d2ce539 562
bff20895 563 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
564 hvStatConf.ToUpper();
565 if (hvStatConf != "OFF" ) {
566 TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
567 if (map2) {
dca91b3f 568 fHighVoltageStat->ClearFit();
569 fHighVoltageStat->SetGraph(map2);
bff20895 570 } else {
571 Log("No high voltage status recordings extracted. \n");
572 result=9;
573 }
574 delete map2;
9d2ce539 575
bff20895 576 // add status maps to high voltage sensor array
9d2ce539 577
bff20895 578 fHighVoltage->AddSensors(fHighVoltageStat);
579 }
bdffc5fb 580 // Now store the final CDB file
581
582 if ( result == 0 ) {
583 AliCDBMetaData metaData;
584 metaData.SetBeamPeriod(0);
585 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 586 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 587 metaData.SetComment("Preprocessor AliTPC data base entries.");
588
589 Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
590 if ( !storeOK ) result=1;
591
592 }
593
594 return result;
595
596}
597
b6e9fd45 598//______________________________________________________________________________________________
599UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
600{
601
602 // extract DCS Goofie maps. Do not perform fits (low update rate)
603
604 UInt_t result=0;
605
606 TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
607 if (map) {
608 fGoofie->ClearFit();
609 fGoofie->SetGraph(map);
610 } else {
611 Log("No Goofie recordings extracted. \n");
612 result=9;
613 }
614 delete map;
615
616 // Now store the final CDB file
617
618 if ( result == 0 ) {
619 AliCDBMetaData metaData;
620 metaData.SetBeamPeriod(0);
621 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 622 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
b6e9fd45 623 metaData.SetComment("Preprocessor AliTPC data base entries.");
624
625 Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
626 if ( !storeOK ) result=1;
627
628 }
629
630 return result;
631
632}
633
7b54c8e9 634
a7dce0bc 635//______________________________________________________________________________________________
7b54c8e9 636
637UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
a7dce0bc 638{
639 //
640 // Read pedestal file from file exchage server
641 // Keep original entry from OCDB in case no new pedestals are available
642 //
643 AliTPCCalPad *calPadPed=0;
644 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
645 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
646 if ( calPadPed==NULL ) {
a7dce0bc 647 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
7b54c8e9 648 calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
649 }
650
651 AliTPCCalPad *calPadRMS=0;
d63b9ad7 652 entry = GetFromOCDB("Calib", "PadNoise");
7b54c8e9 653 if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
654 if ( calPadRMS==NULL ) {
7b54c8e9 655 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
656 calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
a7dce0bc 657 }
658
7b54c8e9 659
a7dce0bc 660 UInt_t result=0;
661
662 Int_t nSectors = fROC->GetNSectors();
7b54c8e9 663 TList* list = GetFileSources(sourceFXS,"pedestals");
9f016d99 664
665 if (list && list->GetEntries()>0) {
a7dce0bc 666
667// loop through all files from LDCs
668
bdffc5fb 669 Bool_t changed=false;
a7dce0bc 670 UInt_t index = 0;
671 while (list->At(index)!=NULL) {
672 TObjString* fileNameEntry = (TObjString*) list->At(index);
673 if (fileNameEntry!=NULL) {
7b54c8e9 674 TString fileName = GetFile(sourceFXS, "pedestals",
a7dce0bc 675 fileNameEntry->GetString().Data());
676 TFile *f = TFile::Open(fileName);
9f016d99 677 if (!f) {
678 Log ("Error opening pedestal file.");
679 result =2;
680 break;
681 }
a7dce0bc 682 AliTPCCalibPedestal *calPed;
e73181c9 683 f->GetObject("tpcCalibPedestal",calPed);
67a165ed 684 if ( !calPed ) {
685 Log ("No pedestal calibration object in file.");
686 result = 2;
687 break;
688 }
a7dce0bc 689
690 // replace entries for the sectors available in the present file
691
bdffc5fb 692 changed=true;
c9c23d80 693 for (Int_t sector=0; sector<nSectors; sector++) {
7b54c8e9 694 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
695 if ( rocPed ) calPadPed->SetCalROC(rocPed,sector);
696 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
697 if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector);
a7dce0bc 698 }
a480de15 699 delete calPed;
342d3b42 700 f->Close();
a7dce0bc 701 }
702 ++index;
703 } // while(list)
704//
705// Store updated pedestal entry to OCDB
706//
bdffc5fb 707 if (changed) {
708 AliCDBMetaData metaData;
709 metaData.SetBeamPeriod(0);
710 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 711 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 712 metaData.SetComment("Preprocessor AliTPC data base entries.");
713
714 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
715 if ( !storeOK ) ++result;
716 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
717 if ( !storeOK ) ++result;
718 }
9f016d99 719 } else {
cf4216a3 720 Log ("Error: no entries in pedestal file list!");
9f016d99 721 result = 1;
7b54c8e9 722 }
a7dce0bc 723
795dbd3b 724 delete calPadPed;
725 delete calPadRMS;
726
a7dce0bc 727 return result;
728}
7b54c8e9 729
730//______________________________________________________________________________________________
731
732
9f016d99 733UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
734{
735 //
736 // Read pulser calibration file from file exchage server
737 // Keep original entry from OCDB in case no new pulser calibration is available
738 //
739 TObjArray *pulserObjects=0;
740 AliTPCCalPad *pulserTmean=0;
741 AliTPCCalPad *pulserTrms=0;
742 AliTPCCalPad *pulserQmean=0;
743 AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
744 if (entry) pulserObjects = (TObjArray*)entry->GetObject();
745 if ( pulserObjects==NULL ) {
746 Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
747 pulserObjects = new TObjArray;
748 }
749
750 pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
751 if ( !pulserTmean ) {
752 pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
753 pulserObjects->Add(pulserTmean);
754 }
755 pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
756 if ( !pulserTrms ) {
757 pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
758 pulserObjects->Add(pulserTrms);
759 }
760 pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
761 if ( !pulserQmean ) {
762 pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
763 pulserObjects->Add(pulserQmean);
764 }
765
766
767 UInt_t result=0;
768
769 Int_t nSectors = fROC->GetNSectors();
770 TList* list = GetFileSources(sourceFXS,"pulser");
771
772 if (list && list->GetEntries()>0) {
773
774// loop through all files from LDCs
775
bdffc5fb 776 Bool_t changed=false;
9f016d99 777 UInt_t index = 0;
778 while (list->At(index)!=NULL) {
779 TObjString* fileNameEntry = (TObjString*) list->At(index);
780 if (fileNameEntry!=NULL) {
781 TString fileName = GetFile(sourceFXS, "pulser",
782 fileNameEntry->GetString().Data());
783 TFile *f = TFile::Open(fileName);
784 if (!f) {
785 Log ("Error opening pulser file.");
786 result =2;
787 break;
788 }
789 AliTPCCalibPulser *calPulser;
e73181c9 790 f->GetObject("tpcCalibPulser",calPulser);
67a165ed 791 if ( !calPulser ) {
792 Log ("No pulser calibration object in file.");
793 result = 2;
794 break;
795 }
9f016d99 796
797 // replace entries for the sectors available in the present file
798
bdffc5fb 799 changed=true;
9f016d99 800 for (Int_t sector=0; sector<nSectors; sector++) {
801 AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
802 if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector);
803 AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
804 if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector);
805 AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
806 if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector);
807 }
a480de15 808 delete calPulser;
342d3b42 809 f->Close();
9f016d99 810 }
811 ++index;
812 } // while(list)
813//
814// Store updated pedestal entry to OCDB
815//
bdffc5fb 816 if (changed) {
817 AliCDBMetaData metaData;
818 metaData.SetBeamPeriod(0);
819 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 820 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 821 metaData.SetComment("Preprocessor AliTPC data base entries.");
822
823 Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
824 if ( !storeOK ) ++result;
825 }
9f016d99 826 } else {
cf4216a3 827 Log ("Error: no entries in pulser file list!");
9f016d99 828 result = 1;
829 }
795dbd3b 830 pulserObjects->Delete();
831 delete pulserObjects;
9f016d99 832
833 return result;
834}
835
70f224dd 836//______________________________________________________________________________________________
837
838
839UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
840{
841 //
842 // Read Raw calibration file from file exchage server
843 //
844
845 UInt_t result=0;
90581ff1 846 TObjArray* rawArray = new TObjArray;
70f224dd 847
9b1478f9 848 TList* list = GetFileSources(sourceFXS,"tpcCalibRaw");
70f224dd 849
850 if (list && list->GetEntries()>0) {
851
852// loop through all files
853
854 UInt_t index = 0;
855 while (list->At(index)!=NULL) {
856 TObjString* fileNameEntry = (TObjString*) list->At(index);
857 if (fileNameEntry!=NULL) {
858 TString fileName = GetFile(sourceFXS, "tpcCalibRaw",
859 fileNameEntry->GetString().Data());
860 TFile *f = TFile::Open(fileName);
861 if (!f) {
862 Log ("Error opening raw file.");
863 result =2;
864 break;
865 }
90581ff1 866 AliTPCCalibRaw *calRaw;
70f224dd 867 f->GetObject("tpcCalibRaw",calRaw);
868 if ( !calRaw ) {
869 Log ("No raw calibration object in file.");
870 result = 2;
871 break;
872 }
90581ff1 873 rawArray->Add(calRaw);
70f224dd 874 f->Close();
875 }
876 ++index;
877 } // while(list)
878//
879// Store updated pedestal entry to OCDB
880//
881 AliCDBMetaData metaData;
882 metaData.SetBeamPeriod(0);
883 metaData.SetResponsible("Haavard Helstrup");
884 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
885 metaData.SetComment("Preprocessor AliTPC data base entries.");
886
90581ff1 887 Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE);
70f224dd 888 if ( !storeOK ) ++result;
889 } else {
cf4216a3 890 Log ("Error: no entries in raw file list!");
70f224dd 891 result = 1;
892 }
795dbd3b 893
894 rawArray->Delete();
895 delete rawArray;
70f224dd 896
897 return result;
898}
899//______________________________________________________________________________________________
900
9f016d99 901UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
902{
903 //
904 // Read Central Electrode file from file exchage server
70f224dd 905 //
9f016d99 906 //
9f016d99 907 AliTPCCalPad *ceTmean=0;
908 AliTPCCalPad *ceTrms=0;
909 AliTPCCalPad *ceQmean=0;
bb30a935 910 TObjArray *rocTtime=0;
911 TObjArray *rocQtime=0;
912
70f224dd 913 TObjArray *ceObjects= new TObjArray;
914
9f016d99 915
bb30a935 916 Int_t nSectors = fROC->GetNSectors();
917
70f224dd 918 ceTmean = new AliTPCCalPad("CETmean","CETmean");
919 ceObjects->Add(ceTmean);
9f016d99 920
70f224dd 921 ceTrms = new AliTPCCalPad("CETrms","CETrms");
922 ceObjects->Add(ceTrms);
923
924 ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
925 ceObjects->Add(ceQmean);
926
927 rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average
928 rocTtime->SetName("rocTtime");
929 ceObjects->Add(rocTtime);
930
931 rocQtime = new TObjArray(nSectors);
932 rocQtime->SetName("rocQtime");
933 ceObjects->Add(rocQtime);
09a746c5 934
935// Temperature maps
936
937 if (fTemp) {
938 fTemp->SetNameTitle("TempMap","TempMap");
939 ceObjects->Add(fTemp);
940 }
941
942// Pressure maps
943
944 if (fPressure) {
945 AliDCSSensor *sensor=0;
946 for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
947 sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
948 sensor->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);
949 ceObjects->Add(sensor);
950 }
951 }
9f016d99 952
953 UInt_t result=0;
954
9f016d99 955 TList* list = GetFileSources(sourceFXS,"CE");
956
957 if (list && list->GetEntries()>0) {
958
959// loop through all files from LDCs
960
961 UInt_t index = 0;
962 while (list->At(index)!=NULL) {
963 TObjString* fileNameEntry = (TObjString*) list->At(index);
964 if (fileNameEntry!=NULL) {
965 TString fileName = GetFile(sourceFXS, "CE",
966 fileNameEntry->GetString().Data());
967 TFile *f = TFile::Open(fileName);
968 if (!f) {
969 Log ("Error opening central electrode file.");
970 result =2;
971 break;
972 }
973 AliTPCCalibCE *calCE;
e73181c9 974 f->GetObject("tpcCalibCE",calCE);
9f016d99 975
7c2575c4 976 if (!calCE) {
977 Log ("No valid calibCE object.");
978 result=2;
979 break;
980 }
9f016d99 981 // replace entries for the sectors available in the present file
982
983 for (Int_t sector=0; sector<nSectors; sector++) {
984 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
985 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
986 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
987 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
988 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
38fcad6d 989 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
bb30a935 990 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
991 if ( grT ) rocTtime->AddAt(grT,sector);
992 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
a8ee5a87 993 if ( grQ ) rocQtime->AddAt(grQ,sector);
9f016d99 994 }
70f224dd 995
996 TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
997 if ( grT ) rocTtime->AddAt(grT,nSectors);
998 grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
999 if ( grT ) rocTtime->AddAt(grT,nSectors+1);
1000
1001
a480de15 1002 delete calCE;
342d3b42 1003 f->Close();
9f016d99 1004 }
1005 ++index;
1006 } // while(list)
1007//
1008// Store updated pedestal entry to OCDB
1009//
1010 AliCDBMetaData metaData;
1011 metaData.SetBeamPeriod(0);
1012 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1013 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9f016d99 1014 metaData.SetComment("Preprocessor AliTPC data base entries.");
1015
1016 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
1017 if ( !storeOK ) ++result;
1018
1019 } else {
cf4216a3 1020 Log ("Error: no CE entries available from FXS!");
9f016d99 1021 result = 1;
1022 }
1023
795dbd3b 1024 ceObjects->Delete();
1025 delete ceObjects;
1026
9f016d99 1027 return result;
1028}
dca91b3f 1029//______________________________________________________________________________________________
1030
1031UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
1032{
1033 //
1034 // Read Quality Assurance file from file exchage server
1035 //
1036
1037 UInt_t result=0;
1038
1039 TList* list = GetFileSources(sourceFXS,"QA");
1040
1041 if (list && list->GetEntries()>0) {
1042
1043// only one QA objetc should be available!
1044
1045 AliTPCdataQA *calQA;
1046
1047 UInt_t nentries = list->GetEntries();
1048 UInt_t index=0;
1049 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
1050 TObjString* fileNameEntry = (TObjString*) list->At(index);
1051 if (fileNameEntry!=NULL) {
1052 TString fileName = GetFile(sourceFXS, "QA",
1053 fileNameEntry->GetString().Data());
1054 TFile *f = TFile::Open(fileName);
1055 if (!f) {
1056 Log ("Error opening QA file.");
a2465b54 1057 result =2;
1058 } else {
1059 f->GetObject("tpcCalibQA",calQA);
7c2575c4 1060 if ( calQA ) {
dca91b3f 1061//
1062// Store updated pedestal entry to OCDB
1063//
7c2575c4 1064 AliCDBMetaData metaData;
1065 metaData.SetBeamPeriod(0);
1066 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1067 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
7c2575c4 1068 metaData.SetComment("Preprocessor AliTPC data base entries.");
1069
cf4216a3 1070 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
7c2575c4 1071 if ( !storeOK ) ++result;
795dbd3b 1072
1073 delete calQA;
7c2575c4 1074 }
a2465b54 1075 }
1076 } else {
1077 Log ("Error: no QA files on FXS!");
1078 result = 2;
1079 }
dca91b3f 1080 } else {
a2465b54 1081 Log ("Error: no QA entries in FXS list!");
dca91b3f 1082 result = 1;
1083 }
dca91b3f 1084 return result;
1085}
1086
9054511b 1087//______________________________________________________________________________________________
1088
1089
1090UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS)
1091{
1092 //
1093 // Read pulser calibration file from file exchage server
1094 // Keep original entry from OCDB in case no new pulser calibration is available
1095 //
1096 TObjArray *altroObjects=0;
1097 AliTPCCalPad *acqStart=0;
1098 AliTPCCalPad *zsThr=0;
1099 AliTPCCalPad *acqStop=0;
1100 AliTPCCalPad *FPED=0;
1101 AliTPCCalPad *masked=0;
cf4216a3 1102 AliTPCCalPad *k1=0, *k2=0, *k3=0;
1103 AliTPCCalPad *l1=0, *l2=0, *l3=0;
1104 TMap *mapRCUconfig=0;
9054511b 1105
14ae505e 1106 AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
9054511b 1107 if (entry) altroObjects = (TObjArray*)entry->GetObject();
1108 if ( altroObjects==NULL ) {
1109 Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
1110 altroObjects = new TObjArray;
1111 }
1112
1113 acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1114 if ( !acqStart ) {
1115 acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1116 altroObjects->Add(acqStart);
1117 }
1118 zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
1119 if ( !zsThr ) {
1120 zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1121 altroObjects->Add(zsThr);
1122 }
1123 FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
1124 if ( !FPED ) {
1125 FPED = new AliTPCCalPad("FPED","FPED");
1126 altroObjects->Add(FPED);
1127 }
1128 acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1129 if ( !acqStop ) {
1130 acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1131 altroObjects->Add(acqStop);
1132 }
1133 masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
1134 if ( !masked ) {
1135 masked = new AliTPCCalPad("Masked","Masked");
1136 altroObjects->Add(masked);
1137 }
cf4216a3 1138 k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
1139 if ( !k1 ) {
1140 k1 = new AliTPCCalPad("K1","K1");
1141 altroObjects->Add(k1);
1142 }
1143 k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
1144 if ( !k2 ) {
1145 k2 = new AliTPCCalPad("K2","K2");
1146 altroObjects->Add(k2);
1147 }
1148 k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
1149 if ( !k3 ) {
1150 k3 = new AliTPCCalPad("K3","K3");
1151 altroObjects->Add(k3);
1152 }
1153 l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
1154 if ( !l1 ) {
1155 l1 = new AliTPCCalPad("L1","L1");
1156 altroObjects->Add(l1);
1157 }
1158 l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
1159 if ( !l2 ) {
1160 l2 = new AliTPCCalPad("L2","L2");
1161 altroObjects->Add(l2);
1162 }
1163 l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
1164 if ( !l3 ) {
1165 l3 = new AliTPCCalPad("L3","L3");
1166 altroObjects->Add(l3);
1167 }
1168 mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1169 if (!mapRCUconfig) {
1170 mapRCUconfig = new TMap();
1171 mapRCUconfig->SetName("RCUconfig");
1172 altroObjects->Add(mapRCUconfig);
1173 }
9054511b 1174
1175
1176 UInt_t result=0;
1177 TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1178
1179 Int_t nSectors = fROC->GetNSectors();
1180 Bool_t changed=false;
1181 for ( Int_t id=0; id<2; id++) {
1182 TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
1183
1184 if (list && list->GetEntries()>0) {
1185 if (altroObjects == 0 ) altroObjects = new TObjArray;
1186
1187// loop through all files from LDCs
1188
1189 UInt_t index = 0;
1190 while (list->At(index)!=NULL) {
1191 TObjString* fileNameEntry = (TObjString*) list->At(index);
1192 if (fileNameEntry!=NULL) {
1193 TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1194 fileNameEntry->GetString().Data());
1195 TFile *f = TFile::Open(fileName);
1196 if (!f) {
1197 char message[40];
1198 sprintf(message,"Error opening Altro configuration file, id = %d",id);
1199 Log (message);
1200 result =2;
1201 break;
1202 }
1203 TObjArray *altroFXS;
1204 f->GetObject("AltroConfig",altroFXS);
1205 if ( !altroFXS ) {
1206 Log ("No Altro configuration object in file.");
1207 result = 2;
1208 break;
1209 }
1210
1211 // replace entries for the sectors available in the present file
1212 AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1213 AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1214 AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1215 AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1216 AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
cf4216a3 1217 AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1218 AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1219 AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1220 AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1221 AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1222 AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1223 TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1224 TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
1225
9054511b 1226 changed=true;
1227 for (Int_t sector=0; sector<nSectors; sector++) {
1228
1229 if (acqStartFXS) {
1230 AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1231 if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1232 }
1233 if (zsThrFXS ) {
1234 AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1235 if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1236 }
1237 if (acqStopFXS) {
1238 AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1239 if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1240 }
1241 if (FPEDFXS ) {
1242 AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
2d47cfd4 1243 if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
9054511b 1244 }
1245 if (maskedFXS) {
1246 AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1247 if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1248 }
cf4216a3 1249 if (k1FXS) {
1250 AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1251 if ( rocK1 ) k1->SetCalROC(rocK1,sector);
1252 }
1253 if (k2FXS) {
1254 AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1255 if ( rocK2 ) k2->SetCalROC(rocK2,sector);
1256 }
1257 if (k3FXS) {
1258 AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1259 if ( rocK3 ) k3->SetCalROC(rocK3,sector);
1260 }
1261 if (l1FXS) {
1262 AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1263 if ( rocL1 ) l1->SetCalROC(rocL1,sector);
1264 }
1265 if (l2FXS) {
1266 AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1267 if ( rocL2 ) l2->SetCalROC(rocL2,sector);
1268 }
1269 if (l3FXS) {
1270 AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1271 if ( rocL3 ) l3->SetCalROC(rocL3,sector);
1272 }
1273 }
1274 if (mapRCUconfigFXS) {
1275 Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1276 TObjString* keyFXS;
1277 TVectorF* vecFXS;
1278 TVectorF* vec; // nSectors = 72 (total number of inner/outer sectors)
1279 for (Int_t i=0; i<mapEntries; ++i) {
1280 keyFXS=(TObjString*)mapFXSiter->Next();
1281 vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1282 vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1283 if (!vec) {
1284 vec = new TVectorF(3*nSectors);
1285 *vec = -1;
1286 mapRCUconfig->Add(keyFXS,vec);
1287 }
1288 if (vec->GetNoElements() != 3*nSectors ) {
1289 vec->ResizeTo(3*nSectors);
1290 }
1291 if (id==0) { // A side
1292 vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1293 vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1294 } else { // C side
1295 vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1296 vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1297 }
1298 }
9054511b 1299 }
1300 delete altroFXS;
1301 f->Close();
1302 }
1303 ++index;
1304 } // while(list)
1305 } else {
cf4216a3 1306 Log ("Error: no entries in AltroConfig file list!");
9054511b 1307 result = 1;
1308 }
1309
1310 } // for - id
1311//
1312// Store updated pedestal entry to OCDB
1313//
1314 if (changed) {
1315 AliCDBMetaData metaData;
1316 metaData.SetBeamPeriod(0);
1317 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1318 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9054511b 1319 metaData.SetComment("Preprocessor AliTPC data base entries.");
1320
dbc10140 1321 Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
9054511b 1322 if ( !storeOK ) ++result;
1323 }
1324
795dbd3b 1325 altroObjects->Delete();
1326 delete altroObjects;
1327
9054511b 1328 return result;
1329}