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