]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCPreprocessor.cxx
adapted macro to QAManager
[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"
dca91b3f 30#include "AliTPCdataQA.h"
eeeac1b2 31#include "ARVersion.h"
9e66a8dd 32#include "TFile.h"
7b54c8e9 33#include "TTree.h"
bb30a935 34#include "TGraph.h"
7b54c8e9 35#include "TEnv.h"
bb30a935 36#include "TParameter.h"
54472e4f 37
38#include <TTimeStamp.h>
39
a7dce0bc 40const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
41const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
bb30a935 42const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
9054511b 43const TString kPulserRunType = "PULSER"; // pulser run identifier
bdffc5fb 44const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
9054511b 45const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
46const TString kLaserRunType = "LASER"; // laser run identifier
9c754ce7 47const TString kDaqRunType = "DAQ"; // DAQ run identifier
87d77b35 48const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
bee89eeb 49//const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
68b512ca 50const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
72df5829 51
54472e4f 52//
53// This class is the SHUTTLE preprocessor for the TPC detector.
54472e4f 54//
55
56ClassImp(AliTPCPreprocessor)
57
58//______________________________________________________________________________________________
6d07bf74 59AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
60 AliPreprocessor("TPC",shuttle),
b6e9fd45 61 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0)
54472e4f 62{
63 // constructor
a7dce0bc 64 fROC = AliTPCROC::Instance();
72534123 65
66 // define run types to be processed
67
68 AddRunType(kPedestalRunType);
69 AddRunType(kPulserRunType);
70 AddRunType(kPhysicsRunType);
72534123 71 AddRunType(kCosmicRunType);
72 AddRunType(kLaserRunType);
73 AddRunType(kDaqRunType);
74
54472e4f 75}
72df5829 76//______________________________________________________________________________________________
f4a89669 77 AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) :
78 AliPreprocessor("TPC",0),
b6e9fd45 79 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0)
f4a89669 80 {
81
82 Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 83//
84// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
f4a89669 85 }
54472e4f 86
87//______________________________________________________________________________________________
88AliTPCPreprocessor::~AliTPCPreprocessor()
89{
90 // destructor
a7dce0bc 91
54472e4f 92 delete fTemp;
bdffc5fb 93 delete fHighVoltage;
54472e4f 94}
72df5829 95//______________________________________________________________________________________________
96AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
97{
98 Fatal("operator =", "assignment operator not implemented");
99 return *this;
100}
101
54472e4f 102
103//______________________________________________________________________________________________
104void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
105 UInt_t endTime)
106{
bb30a935 107 // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start
54472e4f 108
dca91b3f 109 UInt_t startTimeLocal = startTime-3600;
110 UInt_t endTimeLocal = endTime+1800;
bb30a935 111
dca91b3f 112 AliPreprocessor::Initialize(run, startTimeLocal, endTimeLocal);
54472e4f 113
114 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
f4a89669 115 TTimeStamp((time_t)startTime,0).AsString(),
116 TTimeStamp((time_t)endTime,0).AsString()));
54472e4f 117
7b54c8e9 118 // Preprocessor configuration
119
37092b2b 120 AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
7b54c8e9 121 if (entry) fConfEnv = (TEnv*) entry->GetObject();
122 if ( fConfEnv==0 ) {
7b54c8e9 123 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
37092b2b 124 fConfigOK = kFALSE;
125 return;
7b54c8e9 126 }
127
18eade96 128 // Temperature sensors
129
136e44f7 130 TTree *confTree = 0;
131
132 TString tempConf = fConfEnv->GetValue("Temperature","ON");
133 tempConf.ToUpper();
134 if (tempConf != "OFF" ) {
7b54c8e9 135 entry = GetFromOCDB("Config", "Temperature");
f7f602cc 136 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 137 if ( confTree==0 ) {
18eade96 138 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
139 fConfigOK = kFALSE;
f7f602cc 140 return;
18eade96 141 }
dca91b3f 142 fTemp = new AliTPCSensorTempArray(startTimeLocal, endTimeLocal, confTree, kAmandaTemp);
18eade96 143 fTemp->SetValCut(kValCutTemp);
144 fTemp->SetDiffCut(kDiffCutTemp);
136e44f7 145 }
18eade96 146
bdffc5fb 147 // High voltage measurements
148
136e44f7 149 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
150 hvConf.ToUpper();
151 if (hvConf != "OFF" ) {
bdffc5fb 152 confTree=0;
153 entry=0;
154 entry = GetFromOCDB("Config", "HighVoltage");
155 if (entry) confTree = (TTree*) entry->GetObject();
156 if ( confTree==0 ) {
157 Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
158 fConfigOK = kFALSE;
159 return;
160 }
dca91b3f 161 fHighVoltage = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree);
bff20895 162 }
9d2ce539 163
164 // High voltage status values
165
bff20895 166 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
167 hvStatConf.ToUpper();
168 if (hvStatConf != "OFF" ) {
9d2ce539 169 confTree=0;
170 entry=0;
171 entry = GetFromOCDB("Config", "HighVoltageStat");
172 if (entry) confTree = (TTree*) entry->GetObject();
173 if ( confTree==0 ) {
174 Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
175 fConfigOK = kFALSE;
176 return;
177 }
dca91b3f 178 fHighVoltageStat = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree);
bdffc5fb 179 }
b6e9fd45 180
181 // Goofie values
182
183 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
184 goofieConf.ToUpper();
185 if (goofieConf != "OFF" ) {
186 confTree=0;
187 entry=0;
188 entry = GetFromOCDB("Config", "Goofie");
189 if (entry) confTree = (TTree*) entry->GetObject();
190 if ( confTree==0 ) {
191 Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
192 fConfigOK = kFALSE;
193 return;
194 }
195 fGoofie = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree);
196 }
197
198
54472e4f 199}
200
201//______________________________________________________________________________________________
202UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
203{
204 // Fills data into TPC calibrations objects
205
54472e4f 206 // Amanda servers provide information directly through dcsAliasMap
207
bb30a935 208
a7dce0bc 209 if (!fConfigOK) return 9;
136e44f7 210 UInt_t result = 0;
bb30a935 211 TObjArray *resultArray = new TObjArray();
212 TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
213 errorHandling.ToUpper();
214 TObject * status;
215
216 UInt_t dcsResult=0;
217 if (errorHandling == "OFF" ) {
218 if (!dcsAliasMap) dcsResult=1;
219 if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
220 status = new TParameter<int>("dcsResult",dcsResult);
221 resultArray->Add(status);
222 } else {
223 if (!dcsAliasMap) return 9;
224 if (dcsAliasMap->GetEntries() == 0 ) return 9;
225 }
226
227
228
a7dce0bc 229
230 TString runType = GetRunType();
231
54472e4f 232 // Temperature sensors are processed by AliTPCCalTemp
72df5829 233
136e44f7 234 TString tempConf = fConfEnv->GetValue("Temperature","ON");
235 tempConf.ToUpper();
236 if (tempConf != "OFF" ) {
237 UInt_t tempResult = MapTemperature(dcsAliasMap);
238 result=tempResult;
bb30a935 239 status = new TParameter<int>("tempResult",tempResult);
240 resultArray->Add(status);
136e44f7 241 }
18eade96 242
bdffc5fb 243 // High Voltage recordings
244
245
136e44f7 246 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
247 hvConf.ToUpper();
248 if (hvConf != "OFF" ) {
249 UInt_t hvResult = MapHighVoltage(dcsAliasMap);
250 result+=hvResult;
bb30a935 251 status = new TParameter<int>("hvResult",hvResult);
252 resultArray->Add(status);
bdffc5fb 253 }
f7f602cc 254
b6e9fd45 255 // Goofie values
256
257
258 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
259 goofieConf.ToUpper();
260 if (goofieConf != "OFF" ) {
261 UInt_t goofieResult = MapGoofie(dcsAliasMap);
262 result+=goofieResult;
263 status = new TParameter<int>("goofieResult",goofieResult);
264 resultArray->Add(status);
265 }
266
54472e4f 267 // Other calibration information will be retrieved through FXS files
a7dce0bc 268 // examples:
54472e4f 269 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
270 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
271 //
272 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
273 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
274
9f016d99 275 // pedestal entries
54472e4f 276
a7dce0bc 277 if(runType == kPedestalRunType) {
68b512ca 278 Int_t numSources = 1;
279 Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
7b54c8e9 280 TString source = fConfEnv->GetValue("Pedestal","DAQ");
281 source.ToUpper();
136e44f7 282 if (source != "OFF" ) {
283 if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
284 if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
285 if (source == "HLTDAQ" ) {
286 numSources=2;
287 pedestalSource[0] = AliShuttleInterface::kHLT;
288 pedestalSource[1] = AliShuttleInterface::kDAQ;
289 }
290 if (source == "DAQHLT" ) numSources=2;
291 UInt_t pedestalResult=0;
292 for (Int_t i=0; i<numSources; i++ ) {
453bd596 293 pedestalResult = ExtractPedestals(pedestalSource[i]);
136e44f7 294 if ( pedestalResult == 0 ) break;
295 }
296 result += pedestalResult;
bb30a935 297 status = new TParameter<int>("pedestalResult",pedestalResult);
298 resultArray->Add(status);
68b512ca 299 }
a7dce0bc 300 }
301
9f016d99 302 // pulser trigger processing
303
68b512ca 304 if(runType == kPulserRunType) {
305 Int_t numSources = 1;
306 Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 307 TString source = fConfEnv->GetValue("Pulser","DAQ");
308 source.ToUpper();
136e44f7 309 if ( source != "OFF") {
310 if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
311 if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
312 if (source == "HLTDAQ" ) {
313 numSources=2;
314 pulserSource[0] = AliShuttleInterface::kHLT;
315 pulserSource[1] = AliShuttleInterface::kDAQ;
316 }
317 if (source == "DAQHLT" ) numSources=2;
318 UInt_t pulserResult=0;
319 for (Int_t i=0; i<numSources; i++ ) {
320 pulserResult = ExtractPulser(pulserSource[i]);
321 if ( pulserResult == 0 ) break;
322 }
323 result += pulserResult;
bb30a935 324 status = new TParameter<int>("pulserResult",pulserResult);
325 resultArray->Add(status);
68b512ca 326 }
9f016d99 327 }
328
9054511b 329 // Altro configuration
330
331
332 TString altroConf = fConfEnv->GetValue("AltroConf","ON");
333 goofieConf.ToUpper();
334 if (altroConf != "OFF" ) {
db9ef692 335 UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS);
9054511b 336 result+=altroResult;
337 status = new TParameter<int>("altroResult",altroResult);
338 resultArray->Add(status);
339 }
68b512ca 340
341
9f016d99 342 // Central Electrode processing
343
9054511b 344 if( runType == kPhysicsRunType ||
6f3699dd 345 runType == kLaserRunType ) {
68b512ca 346
347 Int_t numSources = 1;
348 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
9f016d99 349 TString source = fConfEnv->GetValue("CE","DAQ");
350 source.ToUpper();
136e44f7 351 if ( source != "OFF" ) {
352 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
353 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
354 if (source == "HLTDAQ" ) {
68b512ca 355 numSources=2;
356 ceSource[0] = AliShuttleInterface::kHLT;
357 ceSource[1] = AliShuttleInterface::kDAQ;
136e44f7 358 }
359 if (source == "DAQHLT" ) numSources=2;
360 UInt_t ceResult=0;
361 for (Int_t i=0; i<numSources; i++ ) {
362 ceResult = ExtractCE(ceSource[i]);
363 if ( ceResult == 0 ) break;
364 }
6f3699dd 365
366 // only flag error if CE result is missing from LASER runs
367 // -- for PHYSICS run do CE processing if data available
368
369 if ( runType == kLaserRunType ) result += ceResult;
bb30a935 370 status = new TParameter<int>("ceResult",ceResult);
371 resultArray->Add(status);
dca91b3f 372
373 numSources = 1;
374 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
5e5c1e83 375 source = fConfEnv->GetValue("QA","DAQ");
dca91b3f 376 source.ToUpper();
377 if ( source != "OFF" ) {
378 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
379 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
380 if (source == "HLTDAQ" ) {
381 numSources=2;
382 qaSource[0] = AliShuttleInterface::kHLT;
383 qaSource[1] = AliShuttleInterface::kDAQ;
384 }
385 if (source == "DAQHLT" ) numSources=2;
386 UInt_t qaResult=0;
387 for (Int_t i=0; i<numSources; i++ ) {
388 qaResult = ExtractQA(qaSource[i]);
389 if ( qaResult == 0 ) break;
390 }
391// result += qaResult;
392 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
393 status = new TParameter<int>("qaResult",qaResult);
394 resultArray->Add(status);
68b512ca 395 }
dca91b3f 396 }
9f016d99 397 }
136e44f7 398
136e44f7 399 if (errorHandling == "OFF" ) {
bb30a935 400 AliCDBMetaData metaData;
401 metaData.SetBeamPeriod(0);
402 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 403 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bb30a935 404 metaData.SetComment("Preprocessor AliTPC status.");
405 Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
406 resultArray->Delete();
407 return 0;
136e44f7 408 } else {
bb30a935 409 return result;
136e44f7 410 }
54472e4f 411}
412//______________________________________________________________________________________________
413UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
414{
415
416 // extract DCS temperature maps. Perform fits to save space
417
72df5829 418 UInt_t result=0;
54472e4f 419 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
420 if (map) {
421 fTemp->MakeSplineFit(map);
68b512ca 422 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
67a165ed 423 if (fitFraction > kFitFraction ) {
424 AliInfo(Form("Temperature values extracted, fits performed.\n"));
425 } else {
426 Log ("Too few temperature maps fitted. \n");
427 result = 9;
428 }
54472e4f 429 } else {
67a165ed 430 Log("No temperature map extracted. \n");
72df5829 431 result=9;
54472e4f 432 }
433 delete map;
434 // Now store the final CDB file
a7dce0bc 435
436 if ( result == 0 ) {
72df5829 437 AliCDBMetaData metaData;
54472e4f 438 metaData.SetBeamPeriod(0);
439 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 440 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
54472e4f 441 metaData.SetComment("Preprocessor AliTPC data base entries.");
442
a7dce0bc 443 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
444 if ( !storeOK ) result=1;
445
72df5829 446 }
54472e4f 447
448 return result;
7b54c8e9 449
54472e4f 450}
7b54c8e9 451
bdffc5fb 452//______________________________________________________________________________________________
453UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
454{
455
456 // extract DCS HV maps. Perform fits to save space
457
458 UInt_t result=0;
459 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
460 if (map) {
461 fHighVoltage->MakeSplineFit(map);
68b512ca 462 Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors();
bdffc5fb 463 if (fitFraction > kFitFraction ) {
136e44f7 464 AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
bdffc5fb 465 } else {
466 Log ("Too few high voltage recordings fitted. \n");
467 result = 9;
468 }
469 } else {
470 Log("No high voltage recordings extracted. \n");
471 result=9;
472 }
473 delete map;
9d2ce539 474
bff20895 475 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
476 hvStatConf.ToUpper();
477 if (hvStatConf != "OFF" ) {
478 TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
479 if (map2) {
dca91b3f 480 fHighVoltageStat->ClearFit();
481 fHighVoltageStat->SetGraph(map2);
bff20895 482 } else {
483 Log("No high voltage status recordings extracted. \n");
484 result=9;
485 }
486 delete map2;
9d2ce539 487
bff20895 488 // add status maps to high voltage sensor array
9d2ce539 489
bff20895 490 fHighVoltage->AddSensors(fHighVoltageStat);
491 }
bdffc5fb 492 // Now store the final CDB file
493
494 if ( result == 0 ) {
495 AliCDBMetaData metaData;
496 metaData.SetBeamPeriod(0);
497 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 498 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 499 metaData.SetComment("Preprocessor AliTPC data base entries.");
500
501 Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
502 if ( !storeOK ) result=1;
503
504 }
505
506 return result;
507
508}
509
b6e9fd45 510//______________________________________________________________________________________________
511UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
512{
513
514 // extract DCS Goofie maps. Do not perform fits (low update rate)
515
516 UInt_t result=0;
517
518 TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
519 if (map) {
520 fGoofie->ClearFit();
521 fGoofie->SetGraph(map);
522 } else {
523 Log("No Goofie recordings extracted. \n");
524 result=9;
525 }
526 delete map;
527
528 // Now store the final CDB file
529
530 if ( result == 0 ) {
531 AliCDBMetaData metaData;
532 metaData.SetBeamPeriod(0);
533 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 534 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
b6e9fd45 535 metaData.SetComment("Preprocessor AliTPC data base entries.");
536
537 Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
538 if ( !storeOK ) result=1;
539
540 }
541
542 return result;
543
544}
545
7b54c8e9 546
a7dce0bc 547//______________________________________________________________________________________________
7b54c8e9 548
549UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
a7dce0bc 550{
551 //
552 // Read pedestal file from file exchage server
553 // Keep original entry from OCDB in case no new pedestals are available
554 //
555 AliTPCCalPad *calPadPed=0;
556 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
557 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
558 if ( calPadPed==NULL ) {
a7dce0bc 559 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
7b54c8e9 560 calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
561 }
562
563 AliTPCCalPad *calPadRMS=0;
d63b9ad7 564 entry = GetFromOCDB("Calib", "PadNoise");
7b54c8e9 565 if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
566 if ( calPadRMS==NULL ) {
7b54c8e9 567 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
568 calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
a7dce0bc 569 }
570
7b54c8e9 571
a7dce0bc 572 UInt_t result=0;
573
574 Int_t nSectors = fROC->GetNSectors();
7b54c8e9 575 TList* list = GetFileSources(sourceFXS,"pedestals");
9f016d99 576
577 if (list && list->GetEntries()>0) {
a7dce0bc 578
579// loop through all files from LDCs
580
bdffc5fb 581 Bool_t changed=false;
a7dce0bc 582 UInt_t index = 0;
583 while (list->At(index)!=NULL) {
584 TObjString* fileNameEntry = (TObjString*) list->At(index);
585 if (fileNameEntry!=NULL) {
7b54c8e9 586 TString fileName = GetFile(sourceFXS, "pedestals",
a7dce0bc 587 fileNameEntry->GetString().Data());
588 TFile *f = TFile::Open(fileName);
9f016d99 589 if (!f) {
590 Log ("Error opening pedestal file.");
591 result =2;
592 break;
593 }
a7dce0bc 594 AliTPCCalibPedestal *calPed;
e73181c9 595 f->GetObject("tpcCalibPedestal",calPed);
67a165ed 596 if ( !calPed ) {
597 Log ("No pedestal calibration object in file.");
598 result = 2;
599 break;
600 }
a7dce0bc 601
602 // replace entries for the sectors available in the present file
603
bdffc5fb 604 changed=true;
c9c23d80 605 for (Int_t sector=0; sector<nSectors; sector++) {
7b54c8e9 606 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
607 if ( rocPed ) calPadPed->SetCalROC(rocPed,sector);
608 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
609 if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector);
a7dce0bc 610 }
a480de15 611 delete calPed;
342d3b42 612 f->Close();
a7dce0bc 613 }
614 ++index;
615 } // while(list)
616//
617// Store updated pedestal entry to OCDB
618//
bdffc5fb 619 if (changed) {
620 AliCDBMetaData metaData;
621 metaData.SetBeamPeriod(0);
622 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 623 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 624 metaData.SetComment("Preprocessor AliTPC data base entries.");
625
626 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
627 if ( !storeOK ) ++result;
628 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
629 if ( !storeOK ) ++result;
630 }
9f016d99 631 } else {
67a165ed 632 Log ("Error: no entries in input file list!");
9f016d99 633 result = 1;
7b54c8e9 634 }
a7dce0bc 635
a7dce0bc 636 return result;
637}
7b54c8e9 638
639//______________________________________________________________________________________________
640
641
9f016d99 642UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
643{
644 //
645 // Read pulser calibration file from file exchage server
646 // Keep original entry from OCDB in case no new pulser calibration is available
647 //
648 TObjArray *pulserObjects=0;
649 AliTPCCalPad *pulserTmean=0;
650 AliTPCCalPad *pulserTrms=0;
651 AliTPCCalPad *pulserQmean=0;
652 AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
653 if (entry) pulserObjects = (TObjArray*)entry->GetObject();
654 if ( pulserObjects==NULL ) {
655 Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
656 pulserObjects = new TObjArray;
657 }
658
659 pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
660 if ( !pulserTmean ) {
661 pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
662 pulserObjects->Add(pulserTmean);
663 }
664 pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
665 if ( !pulserTrms ) {
666 pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
667 pulserObjects->Add(pulserTrms);
668 }
669 pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
670 if ( !pulserQmean ) {
671 pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
672 pulserObjects->Add(pulserQmean);
673 }
674
675
676 UInt_t result=0;
677
678 Int_t nSectors = fROC->GetNSectors();
679 TList* list = GetFileSources(sourceFXS,"pulser");
680
681 if (list && list->GetEntries()>0) {
682
683// loop through all files from LDCs
684
bdffc5fb 685 Bool_t changed=false;
9f016d99 686 UInt_t index = 0;
687 while (list->At(index)!=NULL) {
688 TObjString* fileNameEntry = (TObjString*) list->At(index);
689 if (fileNameEntry!=NULL) {
690 TString fileName = GetFile(sourceFXS, "pulser",
691 fileNameEntry->GetString().Data());
692 TFile *f = TFile::Open(fileName);
693 if (!f) {
694 Log ("Error opening pulser file.");
695 result =2;
696 break;
697 }
698 AliTPCCalibPulser *calPulser;
e73181c9 699 f->GetObject("tpcCalibPulser",calPulser);
67a165ed 700 if ( !calPulser ) {
701 Log ("No pulser calibration object in file.");
702 result = 2;
703 break;
704 }
9f016d99 705
706 // replace entries for the sectors available in the present file
707
bdffc5fb 708 changed=true;
9f016d99 709 for (Int_t sector=0; sector<nSectors; sector++) {
710 AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
711 if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector);
712 AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
713 if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector);
714 AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
715 if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector);
716 }
a480de15 717 delete calPulser;
342d3b42 718 f->Close();
9f016d99 719 }
720 ++index;
721 } // while(list)
722//
723// Store updated pedestal entry to OCDB
724//
bdffc5fb 725 if (changed) {
726 AliCDBMetaData metaData;
727 metaData.SetBeamPeriod(0);
728 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 729 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
bdffc5fb 730 metaData.SetComment("Preprocessor AliTPC data base entries.");
731
732 Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
733 if ( !storeOK ) ++result;
734 }
9f016d99 735 } else {
67a165ed 736 Log ("Error: no entries in input file list!");
9f016d99 737 result = 1;
738 }
739
740 return result;
741}
742
743UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
744{
745 //
746 // Read Central Electrode file from file exchage server
747 // Keep original entry from OCDB in case no new CE calibration is available
748 //
749 TObjArray *ceObjects=0;
750 AliTPCCalPad *ceTmean=0;
751 AliTPCCalPad *ceTrms=0;
752 AliTPCCalPad *ceQmean=0;
bb30a935 753 TObjArray *rocTtime=0;
754 TObjArray *rocQtime=0;
755
9f016d99 756 AliCDBEntry* entry = GetFromOCDB("Calib", "CE");
757 if (entry) ceObjects = (TObjArray*)entry->GetObject();
758 if ( ceObjects==NULL ) {
759 Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n");
760 ceObjects = new TObjArray;
761 }
762
bb30a935 763 Int_t nSectors = fROC->GetNSectors();
764
9f016d99 765 ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean");
766 if ( !ceTmean ) {
767 ceTmean = new AliTPCCalPad("CETmean","CETmean");
768 ceObjects->Add(ceTmean);
769 }
770 ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms");
771 if ( !ceTrms ) {
772 ceTrms = new AliTPCCalPad("CETrms","CETrms");
773 ceObjects->Add(ceTrms);
774 }
775 ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean");
776 if ( !ceQmean ) {
777 ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
778 ceObjects->Add(ceQmean);
779 }
38fcad6d 780 //!new from here please have a look!!!
781 rocTtime = (TObjArray*)ceObjects->FindObject("rocTtime");
782 if ( !rocTtime ) {
bb30a935 783 rocTtime = new TObjArray(nSectors);
38fcad6d 784 rocTtime->SetName("rocTtime");
785 ceObjects->Add(rocTtime);
786 }
bb30a935 787
788 rocQtime = (TObjArray*)ceObjects->FindObject("rocQtime");
38fcad6d 789 if ( !rocQtime ) {
bb30a935 790 rocQtime = new TObjArray(nSectors);
38fcad6d 791 rocQtime->SetName("rocQtime");
792 ceObjects->Add(rocQtime);
793 }
9f016d99 794
795
796 UInt_t result=0;
797
9f016d99 798 TList* list = GetFileSources(sourceFXS,"CE");
799
800 if (list && list->GetEntries()>0) {
801
802// loop through all files from LDCs
803
804 UInt_t index = 0;
805 while (list->At(index)!=NULL) {
806 TObjString* fileNameEntry = (TObjString*) list->At(index);
807 if (fileNameEntry!=NULL) {
808 TString fileName = GetFile(sourceFXS, "CE",
809 fileNameEntry->GetString().Data());
810 TFile *f = TFile::Open(fileName);
811 if (!f) {
812 Log ("Error opening central electrode file.");
813 result =2;
814 break;
815 }
816 AliTPCCalibCE *calCE;
e73181c9 817 f->GetObject("tpcCalibCE",calCE);
9f016d99 818
7c2575c4 819 if (!calCE) {
820 Log ("No valid calibCE object.");
821 result=2;
822 break;
823 }
9f016d99 824 // replace entries for the sectors available in the present file
825
826 for (Int_t sector=0; sector<nSectors; sector++) {
827 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
828 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
829 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
830 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
831 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
38fcad6d 832 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
bb30a935 833 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
834 if ( grT ) rocTtime->AddAt(grT,sector);
835 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
836 if ( grQ ) rocTtime->AddAt(grQ,sector);
9f016d99 837 }
a480de15 838 delete calCE;
342d3b42 839 f->Close();
9f016d99 840 }
841 ++index;
842 } // while(list)
843//
844// Store updated pedestal entry to OCDB
845//
846 AliCDBMetaData metaData;
847 metaData.SetBeamPeriod(0);
848 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 849 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9f016d99 850 metaData.SetComment("Preprocessor AliTPC data base entries.");
851
852 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
853 if ( !storeOK ) ++result;
854
855 } else {
856 Log ("Error: no entries!");
857 result = 1;
858 }
859
860 return result;
861}
dca91b3f 862//______________________________________________________________________________________________
863
864UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
865{
866 //
867 // Read Quality Assurance file from file exchage server
868 //
869
870 UInt_t result=0;
871
872 TList* list = GetFileSources(sourceFXS,"QA");
873
874 if (list && list->GetEntries()>0) {
875
876// only one QA objetc should be available!
877
878 AliTPCdataQA *calQA;
879
880 UInt_t nentries = list->GetEntries();
881 UInt_t index=0;
882 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
883 TObjString* fileNameEntry = (TObjString*) list->At(index);
884 if (fileNameEntry!=NULL) {
885 TString fileName = GetFile(sourceFXS, "QA",
886 fileNameEntry->GetString().Data());
887 TFile *f = TFile::Open(fileName);
888 if (!f) {
889 Log ("Error opening QA file.");
a2465b54 890 result =2;
891 } else {
892 f->GetObject("tpcCalibQA",calQA);
7c2575c4 893 if ( calQA ) {
dca91b3f 894//
895// Store updated pedestal entry to OCDB
896//
7c2575c4 897 AliCDBMetaData metaData;
898 metaData.SetBeamPeriod(0);
899 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 900 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
7c2575c4 901 metaData.SetComment("Preprocessor AliTPC data base entries.");
902
903 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kTRUE);
904 if ( !storeOK ) ++result;
905 }
a2465b54 906 }
907 } else {
908 Log ("Error: no QA files on FXS!");
909 result = 2;
910 }
dca91b3f 911 } else {
a2465b54 912 Log ("Error: no QA entries in FXS list!");
dca91b3f 913 result = 1;
914 }
dca91b3f 915 return result;
916}
917
9054511b 918//______________________________________________________________________________________________
919
920
921UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS)
922{
923 //
924 // Read pulser calibration file from file exchage server
925 // Keep original entry from OCDB in case no new pulser calibration is available
926 //
927 TObjArray *altroObjects=0;
928 AliTPCCalPad *acqStart=0;
929 AliTPCCalPad *zsThr=0;
930 AliTPCCalPad *acqStop=0;
931 AliTPCCalPad *FPED=0;
932 AliTPCCalPad *masked=0;
933
934 AliCDBEntry* entry = GetFromOCDB("Calib", "Altro");
935 if (entry) altroObjects = (TObjArray*)entry->GetObject();
936 if ( altroObjects==NULL ) {
937 Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
938 altroObjects = new TObjArray;
939 }
940
941 acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
942 if ( !acqStart ) {
943 acqStart = new AliTPCCalPad("AcqStart","AcqStart");
944 altroObjects->Add(acqStart);
945 }
946 zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
947 if ( !zsThr ) {
948 zsThr = new AliTPCCalPad("ZsThr","ZsThr");
949 altroObjects->Add(zsThr);
950 }
951 FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
952 if ( !FPED ) {
953 FPED = new AliTPCCalPad("FPED","FPED");
954 altroObjects->Add(FPED);
955 }
956 acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
957 if ( !acqStop ) {
958 acqStop = new AliTPCCalPad("AcqStop","AcqStop");
959 altroObjects->Add(acqStop);
960 }
961 masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
962 if ( !masked ) {
963 masked = new AliTPCCalPad("Masked","Masked");
964 altroObjects->Add(masked);
965 }
966
967
968
969 UInt_t result=0;
970 TString idFXS[2]={"AltroConfigA","AltroConfigC"};
971
972 Int_t nSectors = fROC->GetNSectors();
973 Bool_t changed=false;
974 for ( Int_t id=0; id<2; id++) {
975 TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
976
977 if (list && list->GetEntries()>0) {
978 if (altroObjects == 0 ) altroObjects = new TObjArray;
979
980// loop through all files from LDCs
981
982 UInt_t index = 0;
983 while (list->At(index)!=NULL) {
984 TObjString* fileNameEntry = (TObjString*) list->At(index);
985 if (fileNameEntry!=NULL) {
986 TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
987 fileNameEntry->GetString().Data());
988 TFile *f = TFile::Open(fileName);
989 if (!f) {
990 char message[40];
991 sprintf(message,"Error opening Altro configuration file, id = %d",id);
992 Log (message);
993 result =2;
994 break;
995 }
996 TObjArray *altroFXS;
997 f->GetObject("AltroConfig",altroFXS);
998 if ( !altroFXS ) {
999 Log ("No Altro configuration object in file.");
1000 result = 2;
1001 break;
1002 }
1003
1004 // replace entries for the sectors available in the present file
1005 AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1006 AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1007 AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1008 AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1009 AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
1010
1011 changed=true;
1012 for (Int_t sector=0; sector<nSectors; sector++) {
1013
1014 if (acqStartFXS) {
1015 AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1016 if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1017 }
1018 if (zsThrFXS ) {
1019 AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1020 if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1021 }
1022 if (acqStopFXS) {
1023 AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1024 if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1025 }
1026 if (FPEDFXS ) {
1027 AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
2d47cfd4 1028 if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
9054511b 1029 }
1030 if (maskedFXS) {
1031 AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1032 if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1033 }
1034 }
1035 delete altroFXS;
1036 f->Close();
1037 }
1038 ++index;
1039 } // while(list)
1040 } else {
1041 Log ("Error: no entries in input file list!");
1042 result = 1;
1043 }
1044
1045 } // for - id
1046//
1047// Store updated pedestal entry to OCDB
1048//
1049 if (changed) {
1050 AliCDBMetaData metaData;
1051 metaData.SetBeamPeriod(0);
1052 metaData.SetResponsible("Haavard Helstrup");
eeeac1b2 1053 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
9054511b 1054 metaData.SetComment("Preprocessor AliTPC data base entries.");
1055
1056 Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kTRUE);
1057 if ( !storeOK ) ++result;
1058 }
1059
1060 return result;
1061}