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