1 /**************************************************************************
2 * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliTPCPreprocessor.h"
18 #include "AliShuttleInterface.h"
20 #include "AliCDBMetaData.h"
21 #include "AliDCSValue.h"
23 #include "AliTPCSensorTempArray.h"
24 #include "AliTPCROC.h"
25 #include "AliTPCCalROC.h"
26 #include "AliTPCCalPad.h"
27 #include "AliTPCCalibPedestal.h"
28 #include "AliTPCCalibPulser.h"
29 #include "AliTPCCalibCE.h"
30 #include "AliTPCCalibRaw.h"
31 #include "AliTPCdataQA.h"
32 #include "ARVersion.h"
37 #include "TParameter.h"
39 #include <TTimeStamp.h>
41 const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
42 const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
43 const Double_t kHighVoltageDifference = 1e-4; // don't record High Voltage points
44 // differing by less than 1e-4 from
46 const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
47 const TString kPulserRunType = "PULSER"; // pulser run identifier
48 const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
49 const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
50 const TString kLaserRunType = "LASER"; // laser run identifier
51 const TString kDaqRunType = "DAQ"; // DAQ run identifier
52 const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
53 const TString kAmandaDDL = "DDL%d"; // Amanda string for list of active DDLs
54 const Int_t kNumDDL = 216; // number of TPC DDLs
55 const Int_t kFirstDDL = 768; // identifier of first DDL
56 //const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
57 const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
58 const Int_t kNumPressureSensors = 3; // number of pressure sensors
59 const char* kPressureSensorNames[kNumPressureSensors] = {
60 "CavernAtmosPressure",
61 "CavernAtmosPressure2",
62 "SurfaceAtmosPressure" };
66 // This class is the SHUTTLE preprocessor for the TPC detector.
69 ClassImp(AliTPCPreprocessor)
71 //______________________________________________________________________________________________
72 AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
73 AliPreprocessor("TPC",shuttle),
74 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
75 fPressure(0), fConfigOK(kTRUE), fROC(0)
78 fROC = AliTPCROC::Instance();
80 // define run types to be processed
82 AddRunType(kPedestalRunType);
83 AddRunType(kPulserRunType);
84 AddRunType(kPhysicsRunType);
85 AddRunType(kCosmicRunType);
86 AddRunType(kLaserRunType);
87 AddRunType(kDaqRunType);
90 //______________________________________________________________________________________________
91 AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) :
92 AliPreprocessor("TPC",0),
93 fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
94 fPressure(0), fConfigOK(kTRUE), fROC(0)
97 Fatal("AliTPCPreprocessor", "copy constructor not implemented");
99 // // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
102 //______________________________________________________________________________________________
103 AliTPCPreprocessor::~AliTPCPreprocessor()
109 delete fHighVoltageStat;
113 //______________________________________________________________________________________________
114 AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
116 Fatal("operator =", "assignment operator not implemented");
121 //______________________________________________________________________________________________
122 void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
126 AliPreprocessor::Initialize(run, startTime, endTime);
128 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
129 TTimeStamp((time_t)startTime,0).AsString(),
130 TTimeStamp((time_t)endTime,0).AsString()));
132 // Preprocessor configuration
134 AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
135 if (entry) fConfEnv = (TEnv*) entry->GetObject();
137 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
142 // Temperature sensors
146 TString tempConf = fConfEnv->GetValue("Temperature","ON");
148 if (tempConf != "OFF" ) {
149 entry = GetFromOCDB("Config", "Temperature");
150 if (entry) confTree = (TTree*) entry->GetObject();
152 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
156 fTemp = new AliTPCSensorTempArray(startTime, endTime, confTree, kAmandaTemp);
157 fTemp->SetValCut(kValCutTemp);
158 fTemp->SetDiffCut(kDiffCutTemp);
161 // High voltage measurements
163 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
165 if (hvConf != "OFF" ) {
168 entry = GetFromOCDB("Config", "HighVoltage");
169 if (entry) confTree = (TTree*) entry->GetObject();
171 Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
175 time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
176 time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
177 fHighVoltage = new AliDCSSensorArray (UInt_t(timeStart),
178 UInt_t(timeEnd), confTree);
181 // High voltage status values
183 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
184 hvStatConf.ToUpper();
185 if (hvStatConf != "OFF" ) {
188 entry = GetFromOCDB("Config", "HighVoltageStat");
189 if (entry) confTree = (TTree*) entry->GetObject();
191 Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
195 fHighVoltageStat = new AliDCSSensorArray(startTime, endTime, confTree);
200 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
201 goofieConf.ToUpper();
202 if (goofieConf != "OFF" ) {
205 entry = GetFromOCDB("Config", "Goofie");
206 if (entry) confTree = (TTree*) entry->GetObject();
208 Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
212 fGoofie = new AliDCSSensorArray(startTime, endTime, confTree);
217 TString runType = GetRunType();
219 if( runType == kPhysicsRunType ||
220 runType == kLaserRunType ) {
221 TString pressureConf = fConfEnv->GetValue("Pressure","ON");
222 pressureConf.ToUpper();
223 if (pressureConf != "OFF" ) {
224 TClonesArray * array = new TClonesArray("AliDCSSensor",kNumPressureSensors);
225 for(Int_t j = 0; j < kNumPressureSensors; j++) {
226 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
227 sens->SetStringID(kPressureSensorNames[j]);
229 fPressure = new AliDCSSensorArray(startTime, endTime, array);
234 //______________________________________________________________________________________________
235 UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
237 // Fills data into TPC calibrations objects
239 // Amanda servers provide information directly through dcsAliasMap
242 if (!fConfigOK) return 9;
244 TObjArray *resultArray = new TObjArray();
245 TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
246 errorHandling.ToUpper();
250 if (!dcsAliasMap) dcsResult=1;
251 if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
252 status = new TParameter<int>("dcsResult",dcsResult);
253 resultArray->Add(status);
256 TString runType = GetRunType();
258 if ( dcsResult == 0 ) {
260 // Temperature sensors are processed by AliTPCCalTemp
262 TString tempConf = fConfEnv->GetValue("Temperature","ON");
264 if (tempConf != "OFF" ) {
265 UInt_t tempResult = MapTemperature(dcsAliasMap);
266 if ( tempConf != "TRY") result+=tempResult;
267 status = new TParameter<int>("tempResult",tempResult);
268 resultArray->Add(status);
271 // High Voltage recordings
274 TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
276 if (hvConf != "OFF" ) {
277 UInt_t hvResult = MapHighVoltage(dcsAliasMap);
278 if (hvConf != "TRY") result+=hvResult;
279 status = new TParameter<int>("hvResult",hvResult);
280 resultArray->Add(status);
286 TString goofieConf = fConfEnv->GetValue("Goofie","ON");
287 goofieConf.ToUpper();
288 if (goofieConf != "OFF" ) {
289 UInt_t goofieResult = MapGoofie(dcsAliasMap);
290 if (goofieConf != "TRY") result+=goofieResult;
291 status = new TParameter<int>("goofieResult",goofieResult);
292 resultArray->Add(status);
297 if( runType == kPhysicsRunType ||
298 runType == kLaserRunType ) {
300 TString pressureConf = fConfEnv->GetValue("Pressure","ON");
301 pressureConf.ToUpper();
302 if (pressureConf != "OFF" ) {
303 UInt_t pressureResult = MapPressure(dcsAliasMap);
304 status = new TParameter<int>("pressureResult",pressureResult);
305 resultArray->Add(status);
309 // Other calibration information will be retrieved through FXS files
311 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
312 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
314 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
315 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
319 if(runType == kPedestalRunType) {
320 Int_t numSources = 1;
321 Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
322 TString source = fConfEnv->GetValue("Pedestal","DAQ");
324 if (source != "OFF" ) {
325 if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
326 if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
327 if (source == "HLTDAQ" ) {
329 pedestalSource[0] = AliShuttleInterface::kHLT;
330 pedestalSource[1] = AliShuttleInterface::kDAQ;
332 if (source == "DAQHLT" ) numSources=2;
333 UInt_t pedestalResult=0;
334 for (Int_t i=0; i<numSources; i++ ) {
335 pedestalResult = ExtractPedestals(pedestalSource[i]);
336 if ( pedestalResult == 0 ) break;
338 result += pedestalResult;
339 status = new TParameter<int>("pedestalResult",pedestalResult);
340 resultArray->Add(status);
344 // pulser trigger processing
346 if(runType == kPulserRunType) {
347 Int_t numSources = 1;
348 Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
349 TString source = fConfEnv->GetValue("Pulser","DAQ");
351 if ( source != "OFF") {
352 if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
353 if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
354 if (source == "HLTDAQ" ) {
356 pulserSource[0] = AliShuttleInterface::kHLT;
357 pulserSource[1] = AliShuttleInterface::kDAQ;
359 if (source == "DAQHLT" ) numSources=2;
360 if (source == "TRY" ) numSources=2;
361 UInt_t pulserResult=0;
362 for (Int_t i=0; i<numSources; i++ ) {
363 pulserResult = ExtractPulser(pulserSource[i]);
364 if ( pulserResult == 0 ) break;
366 if (source != "TRY") result += pulserResult;
367 status = new TParameter<int>("pulserResult",pulserResult);
368 resultArray->Add(status);
373 // raw calibration processing
375 if(runType == kPhysicsRunType) {
376 Int_t numSources = 1;
377 Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
378 TString source = fConfEnv->GetValue("Raw","DAQ");
380 if ( source != "OFF") {
381 if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
382 if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
383 if (source == "HLTDAQ" ) {
385 rawSource[0] = AliShuttleInterface::kHLT;
386 rawSource[1] = AliShuttleInterface::kDAQ;
388 if (source == "DAQHLT" ) numSources=2;
389 if (source == "TRY" ) numSources=2;
391 for (Int_t i=0; i<numSources; i++ ) {
392 rawResult = ExtractRaw(rawSource[i]);
393 if ( rawResult == 0 ) break;
395 if (source != "TRY" )result += rawResult;
396 status = new TParameter<int>("rawResult",rawResult);
397 resultArray->Add(status);
402 // Altro configuration
405 TString altroConf = fConfEnv->GetValue("AltroConf","ON");
407 if (altroConf != "OFF" ) {
408 UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS,dcsAliasMap);
409 if (altroConf != "TRY" ) result+=altroResult;
410 status = new TParameter<int>("altroResult",altroResult);
411 resultArray->Add(status);
415 // Central Electrode processing
417 if( runType == kPhysicsRunType ||
418 runType == kLaserRunType ) {
420 Int_t numSources = 1;
421 Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
422 TString source = fConfEnv->GetValue("CE","DAQ");
424 if ( source != "OFF" ) {
425 if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
426 if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
427 if (source == "HLTDAQ" ) {
429 ceSource[0] = AliShuttleInterface::kHLT;
430 ceSource[1] = AliShuttleInterface::kDAQ;
432 if (source == "DAQHLT" ) numSources=2;
433 if (source == "TRY" ) numSources=2;
435 for (Int_t i=0; i<numSources; i++ ) {
436 ceResult = ExtractCE(ceSource[i]);
437 if ( ceResult == 0 ) break;
440 // only flag error if CE result is missing from LASER runs
441 // -- for PHYSICS run do CE processing if data available
443 if ( runType == kLaserRunType && source != "TRY" && ceResult<10 ) result += ceResult;
444 status = new TParameter<int>("ceResult",ceResult);
445 resultArray->Add(status);
448 Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
449 source = fConfEnv->GetValue("QA","DAQ");
451 if ( source != "OFF" ) {
452 if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
453 if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
454 if (source == "HLTDAQ" ) {
456 qaSource[0] = AliShuttleInterface::kHLT;
457 qaSource[1] = AliShuttleInterface::kDAQ;
459 if (source == "DAQHLT" ) numSources=2;
460 if (source == "TRY" ) numSources=2;
462 for (Int_t i=0; i<numSources; i++ ) {
463 qaResult = ExtractQA(qaSource[i]);
464 if ( qaResult == 0 ) break;
466 // result += qaResult;
467 if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
468 status = new TParameter<int>("qaResult",qaResult);
469 resultArray->Add(status);
474 // Store component status to OCDB
476 AliCDBMetaData metaData;
477 metaData.SetBeamPeriod(0);
478 metaData.SetResponsible("Haavard Helstrup");
479 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
480 metaData.SetComment("Preprocessor AliTPC status.");
481 Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
482 resultArray->Delete();
485 if (errorHandling == "OFF" ) return 0;
489 //______________________________________________________________________________________________
490 UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
493 // extract DCS temperature maps. Perform fits to save space
496 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
498 fTemp->MakeSplineFit(map);
499 Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
500 if (fitFraction > kFitFraction ) {
501 AliInfo(Form("Temperature values extracted, fits performed.\n"));
503 Log ("Too few temperature maps fitted. \n");
507 Log("No temperature map extracted. \n");
511 // Now store the final CDB file
514 AliCDBMetaData metaData;
515 metaData.SetBeamPeriod(0);
516 metaData.SetResponsible("Haavard Helstrup");
517 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
518 metaData.SetComment("Preprocessor AliTPC data base entries.");
520 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
521 if ( !storeOK ) result=1;
528 //______________________________________________________________________________________________
529 UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
532 // extract DCS pressure maps. Perform fits to save space
535 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
537 fPressure->MakeSplineFit(map);
538 Double_t fitFraction = 1.0*fPressure->NumFits()/fPressure->NumSensors();
539 if (fitFraction > kFitFraction ) {
540 AliInfo(Form("Pressure values extracted, fits performed.\n"));
542 Log ("Too few pressure maps fitted. \n");
546 Log("No pressure map extracted. \n");
553 //______________________________________________________________________________________________
554 UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
557 // extract DCS HV maps. Perform fits to save space
560 TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
562 fHighVoltage->ClearFit();
563 fHighVoltage->RemoveGraphDuplicates(kHighVoltageDifference);
564 // don't keep new point if too similar to previous one
565 fHighVoltage->SetGraph(map);
567 Log("No high voltage recordings extracted. \n");
572 TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
573 hvStatConf.ToUpper();
574 if (hvStatConf != "OFF" ) {
575 TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
577 fHighVoltageStat->ClearFit();
578 fHighVoltageStat->SetGraph(map2);
580 Log("No high voltage status recordings extracted. \n");
585 // add status maps to high voltage sensor array
587 fHighVoltage->AddSensors(fHighVoltageStat);
589 // Now store the final CDB file
592 AliCDBMetaData metaData;
593 metaData.SetBeamPeriod(0);
594 metaData.SetResponsible("Haavard Helstrup");
595 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
596 metaData.SetComment("Preprocessor AliTPC data base entries.");
598 Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
599 if ( !storeOK ) result=1;
607 //______________________________________________________________________________________________
608 UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
611 // extract DCS Goofie maps. Do not perform fits (low update rate)
615 TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
618 fGoofie->SetGraph(map);
620 Log("No Goofie recordings extracted. \n");
625 // Now store the final CDB file
628 AliCDBMetaData metaData;
629 metaData.SetBeamPeriod(0);
630 metaData.SetResponsible("Haavard Helstrup");
631 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
632 metaData.SetComment("Preprocessor AliTPC data base entries.");
634 Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
635 if ( !storeOK ) result=1;
644 //______________________________________________________________________________________________
646 UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
649 // Read pedestal file from file exchage server
650 // Keep original entry from OCDB in case no new pedestals are available
652 AliTPCCalPad *calPadPed=0;
653 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
654 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
655 if ( calPadPed==NULL ) {
656 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
657 calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
660 AliTPCCalPad *calPadRMS=0;
661 entry = GetFromOCDB("Calib", "PadNoise");
662 if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
663 if ( calPadRMS==NULL ) {
664 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
665 calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
671 Int_t nSectors = fROC->GetNSectors();
672 TList* list = GetFileSources(sourceFXS,"pedestals");
674 if (list && list->GetEntries()>0) {
676 // loop through all files from LDCs
678 Bool_t changed=false;
680 while (list->At(index)!=NULL) {
681 TObjString* fileNameEntry = (TObjString*) list->At(index);
682 if (fileNameEntry!=NULL) {
683 TString fileName = GetFile(sourceFXS, "pedestals",
684 fileNameEntry->GetString().Data());
685 TFile *f = TFile::Open(fileName);
687 Log ("Error opening pedestal file.");
691 AliTPCCalibPedestal *calPed;
692 f->GetObject("tpcCalibPedestal",calPed);
694 Log ("No pedestal calibration object in file.");
699 // replace entries for the sectors available in the present file
702 for (Int_t sector=0; sector<nSectors; sector++) {
703 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
704 if ( rocPed ) calPadPed->SetCalROC(rocPed,sector);
705 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
706 if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector);
714 // Store updated pedestal entry to OCDB
717 AliCDBMetaData metaData;
718 metaData.SetBeamPeriod(0);
719 metaData.SetResponsible("Haavard Helstrup");
720 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
721 metaData.SetComment("Preprocessor AliTPC data base entries.");
723 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
724 if ( !storeOK ) ++result;
725 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
726 if ( !storeOK ) ++result;
729 Log ("Error: no entries in pedestal file list!");
739 //______________________________________________________________________________________________
742 UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
745 // Read pulser calibration file from file exchage server
746 // Keep original entry from OCDB in case no new pulser calibration is available
748 TObjArray *pulserObjects=0;
749 AliTPCCalPad *pulserTmean=0;
750 AliTPCCalPad *pulserTrms=0;
751 AliTPCCalPad *pulserQmean=0;
752 AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
753 if (entry) pulserObjects = (TObjArray*)entry->GetObject();
754 if ( pulserObjects==NULL ) {
755 Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
756 pulserObjects = new TObjArray;
759 pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
760 if ( !pulserTmean ) {
761 pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
762 pulserObjects->Add(pulserTmean);
764 pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
766 pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
767 pulserObjects->Add(pulserTrms);
769 pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
770 if ( !pulserQmean ) {
771 pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
772 pulserObjects->Add(pulserQmean);
778 Int_t nSectors = fROC->GetNSectors();
779 TList* list = GetFileSources(sourceFXS,"pulser");
781 if (list && list->GetEntries()>0) {
783 // loop through all files from LDCs
785 Bool_t changed=false;
787 while (list->At(index)!=NULL) {
788 TObjString* fileNameEntry = (TObjString*) list->At(index);
789 if (fileNameEntry!=NULL) {
790 TString fileName = GetFile(sourceFXS, "pulser",
791 fileNameEntry->GetString().Data());
792 TFile *f = TFile::Open(fileName);
794 Log ("Error opening pulser file.");
798 AliTPCCalibPulser *calPulser;
799 f->GetObject("tpcCalibPulser",calPulser);
801 Log ("No pulser calibration object in file.");
806 // replace entries for the sectors available in the present file
809 for (Int_t sector=0; sector<nSectors; sector++) {
810 AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
811 if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector);
812 AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
813 if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector);
814 AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
815 if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector);
823 // Store updated pedestal entry to OCDB
826 AliCDBMetaData metaData;
827 metaData.SetBeamPeriod(0);
828 metaData.SetResponsible("Haavard Helstrup");
829 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
830 metaData.SetComment("Preprocessor AliTPC data base entries.");
832 Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
833 if ( !storeOK ) ++result;
836 Log ("Error: no entries in pulser file list!");
839 pulserObjects->Delete();
840 delete pulserObjects;
845 //______________________________________________________________________________________________
848 UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
851 // Read Raw calibration file from file exchage server
855 TObjArray* rawArray = new TObjArray;
857 TList* list = GetFileSources(sourceFXS,"tpcCalibRaw");
859 if (list && list->GetEntries()>0) {
861 // loop through all files
864 while (list->At(index)!=NULL) {
865 TObjString* fileNameEntry = (TObjString*) list->At(index);
866 if (fileNameEntry!=NULL) {
867 TString fileName = GetFile(sourceFXS, "tpcCalibRaw",
868 fileNameEntry->GetString().Data());
869 TFile *f = TFile::Open(fileName);
871 Log ("Error opening raw file.");
875 AliTPCCalibRaw *calRaw;
876 f->GetObject("tpcCalibRaw",calRaw);
878 Log ("No raw calibration object in file.");
882 rawArray->Add(calRaw);
888 // Store updated pedestal entry to OCDB
890 AliCDBMetaData metaData;
891 metaData.SetBeamPeriod(0);
892 metaData.SetResponsible("Haavard Helstrup");
893 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
894 metaData.SetComment("Preprocessor AliTPC data base entries.");
896 Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE);
897 if ( !storeOK ) ++result;
899 Log ("Error: no entries in raw file list!");
908 //______________________________________________________________________________________________
910 UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
913 // Read Central Electrode file from file exchage server
916 AliTPCCalPad *ceTmean=0;
917 AliTPCCalPad *ceTrms=0;
918 AliTPCCalPad *ceQmean=0;
919 TObjArray *rocTtime=0;
920 TObjArray *rocQtime=0;
922 TObjArray *ceObjects= new TObjArray;
925 Int_t nSectors = fROC->GetNSectors();
927 ceTmean = new AliTPCCalPad("CETmean","CETmean");
928 ceObjects->Add(ceTmean);
930 ceTrms = new AliTPCCalPad("CETrms","CETrms");
931 ceObjects->Add(ceTrms);
933 ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
934 ceObjects->Add(ceQmean);
936 rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average
937 rocTtime->SetName("rocTtime");
938 ceObjects->Add(rocTtime);
940 rocQtime = new TObjArray(nSectors);
941 rocQtime->SetName("rocQtime");
942 ceObjects->Add(rocQtime);
947 AliTPCSensorTempArray *tempMap = new AliTPCSensorTempArray(*fTemp);
948 tempMap->SetNameTitle("TempMap","TempMap");
949 ceObjects->Add(tempMap);
955 AliDCSSensor *sensor=0, *sensorCopy=0;
956 for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
957 sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
959 sensorCopy = new AliDCSSensor(*sensor);
960 sensorCopy->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);
961 ceObjects->Add(sensorCopy);
968 TList* list = GetFileSources(sourceFXS,"CE");
970 if (list && list->GetEntries()>0) {
972 // loop through all files from LDCs
975 while (list->At(index)!=NULL) {
976 TObjString* fileNameEntry = (TObjString*) list->At(index);
977 if (fileNameEntry!=NULL) {
978 TString fileName = GetFile(sourceFXS, "CE",
979 fileNameEntry->GetString().Data());
980 TFile *f = TFile::Open(fileName);
982 Log ("Error opening central electrode file.");
986 AliTPCCalibCE *calCE;
987 f->GetObject("tpcCalibCE",calCE);
990 Log ("No valid calibCE object.");
994 // replace entries for the sectors available in the present file
996 for (Int_t sector=0; sector<nSectors; sector++) {
997 AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
998 if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
999 AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
1000 if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
1001 AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
1002 if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
1003 TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
1004 if ( grT ) rocTtime->AddAt(grT,sector);
1005 TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
1006 if ( grQ ) rocQtime->AddAt(grQ,sector);
1009 TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
1011 rocTtime->AddAt(grT,nSectors);
1015 grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
1017 rocTtime->AddAt(grT,nSectors+1);
1027 // Store updated pedestal entry to OCDB
1029 AliCDBMetaData metaData;
1030 metaData.SetBeamPeriod(0);
1031 metaData.SetResponsible("Haavard Helstrup");
1032 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
1033 metaData.SetComment("Preprocessor AliTPC data base entries.");
1035 if ( result == 0 ) {
1036 Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
1037 if ( !storeOK ) ++result;
1039 Log ("Warning: Average time graphs not available - no OCDB entry written");
1042 Log ("Error: no CE entries available from FXS!");
1046 ceObjects->Delete();
1051 //______________________________________________________________________________________________
1053 UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
1056 // Read Quality Assurance file from file exchage server
1061 TList* list = GetFileSources(sourceFXS,"QA");
1063 if (list && list->GetEntries()>0) {
1065 // only one QA objetc should be available!
1067 AliTPCdataQA *calQA;
1069 UInt_t nentries = list->GetEntries();
1071 if ( nentries > 1) Log ( "More than one QA entry. First one processed");
1072 TObjString* fileNameEntry = (TObjString*) list->At(index);
1073 if (fileNameEntry!=NULL) {
1074 TString fileName = GetFile(sourceFXS, "QA",
1075 fileNameEntry->GetString().Data());
1076 TFile *f = TFile::Open(fileName);
1078 Log ("Error opening QA file.");
1081 f->GetObject("tpcCalibQA",calQA);
1084 // Store updated pedestal entry to OCDB
1086 AliCDBMetaData metaData;
1087 metaData.SetBeamPeriod(0);
1088 metaData.SetResponsible("Haavard Helstrup");
1089 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
1090 metaData.SetComment("Preprocessor AliTPC data base entries.");
1092 Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
1093 if ( !storeOK ) ++result;
1099 Log ("Error: no QA files on FXS!");
1103 Log ("Error: no QA entries in FXS list!");
1109 //______________________________________________________________________________________________
1112 UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS, TMap* dcsMap)
1115 // Read Altro configuration file from file exchage server
1116 // Keep original entry from OCDB in case no new pulser calibration is available
1118 TObjArray *altroObjects=0;
1119 AliTPCCalPad *acqStart=0;
1120 AliTPCCalPad *zsThr=0;
1121 AliTPCCalPad *acqStop=0;
1122 AliTPCCalPad *FPED=0;
1123 AliTPCCalPad *masked=0;
1124 AliTPCCalPad *k1=0, *k2=0, *k3=0;
1125 AliTPCCalPad *l1=0, *l2=0, *l3=0;
1126 TMap *mapRCUconfig=0;
1128 AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
1129 if (entry) altroObjects = (TObjArray*)entry->GetObject();
1130 if ( altroObjects==NULL ) {
1131 Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
1132 altroObjects = new TObjArray;
1135 acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1137 acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1138 altroObjects->Add(acqStart);
1140 zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
1142 zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1143 altroObjects->Add(zsThr);
1145 FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
1147 FPED = new AliTPCCalPad("FPED","FPED");
1148 altroObjects->Add(FPED);
1150 acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1152 acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1153 altroObjects->Add(acqStop);
1155 masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
1157 masked = new AliTPCCalPad("Masked","Masked");
1158 altroObjects->Add(masked);
1160 k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
1162 k1 = new AliTPCCalPad("K1","K1");
1163 altroObjects->Add(k1);
1165 k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
1167 k2 = new AliTPCCalPad("K2","K2");
1168 altroObjects->Add(k2);
1170 k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
1172 k3 = new AliTPCCalPad("K3","K3");
1173 altroObjects->Add(k3);
1175 l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
1177 l1 = new AliTPCCalPad("L1","L1");
1178 altroObjects->Add(l1);
1180 l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
1182 l2 = new AliTPCCalPad("L2","L2");
1183 altroObjects->Add(l2);
1185 l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
1187 l3 = new AliTPCCalPad("L3","L3");
1188 altroObjects->Add(l3);
1190 mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1191 if (!mapRCUconfig) {
1192 mapRCUconfig = new TMap();
1193 mapRCUconfig->SetName("RCUconfig");
1194 altroObjects->Add(mapRCUconfig);
1199 TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1201 Int_t nSectors = fROC->GetNSectors();
1202 Bool_t changed=false;
1203 if (altroObjects == 0 ) altroObjects = new TObjArray;
1205 // extract list of active DDLs
1208 TString arrDDL(kNumDDL);
1209 arrDDL.Append('x',kNumDDL);
1210 for ( Int_t iDDL = 0; iDDL<kNumDDL; iDDL++ ) {
1211 TString stringID = Form (kAmandaDDL.Data(),iDDL+kFirstDDL);
1212 TPair *pair = (TPair*)dcsMap->FindObject(stringID.Data());
1215 TObjArray *valueSet=(TObjArray*)pair->Value();
1217 AliDCSValue *val = (AliDCSValue*)valueSet->At(0);
1219 found = val->GetBool();
1229 TObjString *ddlArray = new TObjString;
1230 ddlArray->SetString(arrDDL);
1231 TMap *activeDDL = new TMap;
1232 activeDDL->SetName("DDLArray");
1233 TObjString *key = new TObjString("DDLArray");
1234 activeDDL->Add(key,ddlArray);
1235 altroObjects->Add(activeDDL);
1239 // extract Altro configuration files
1241 for ( Int_t id=0; id<2; id++) {
1242 TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
1244 if (list && list->GetEntries()>0) {
1246 // loop through all files from LDCs
1249 while (list->At(index)!=NULL) {
1250 TObjString* fileNameEntry = (TObjString*) list->At(index);
1251 if (fileNameEntry!=NULL) {
1252 TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1253 fileNameEntry->GetString().Data());
1254 TFile *f = TFile::Open(fileName);
1257 sprintf(message,"Error opening Altro configuration file, id = %d",id);
1262 TObjArray *altroFXS;
1263 f->GetObject("AltroConfig",altroFXS);
1265 Log ("No Altro configuration object in file.");
1270 // replace entries for the sectors available in the present file
1271 AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1272 AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1273 AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1274 AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1275 AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
1276 AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1277 AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1278 AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1279 AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1280 AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1281 AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1282 TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1283 TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
1286 for (Int_t sector=0; sector<nSectors; sector++) {
1289 AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1290 if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1293 AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1294 if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1297 AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1298 if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1301 AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
1302 if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
1305 AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1306 if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1309 AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1310 if ( rocK1 ) k1->SetCalROC(rocK1,sector);
1313 AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1314 if ( rocK2 ) k2->SetCalROC(rocK2,sector);
1317 AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1318 if ( rocK3 ) k3->SetCalROC(rocK3,sector);
1321 AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1322 if ( rocL1 ) l1->SetCalROC(rocL1,sector);
1325 AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1326 if ( rocL2 ) l2->SetCalROC(rocL2,sector);
1329 AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1330 if ( rocL3 ) l3->SetCalROC(rocL3,sector);
1333 if (mapRCUconfigFXS) {
1334 Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1337 TVectorF* vec; // nSectors = 72 (total number of inner/outer sectors)
1338 for (Int_t i=0; i<mapEntries; ++i) {
1339 keyFXS=(TObjString*)mapFXSiter->Next();
1340 vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1341 vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1343 vec = new TVectorF(3*nSectors);
1345 mapRCUconfig->Add(keyFXS,vec);
1347 if (vec->GetNoElements() != 3*nSectors ) {
1348 vec->ResizeTo(3*nSectors);
1350 if (id==0) { // A side
1351 vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1352 vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1354 vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1355 vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1365 Log ("Error: no entries in AltroConfig file list!");
1371 // Store updated pedestal entry to OCDB
1374 AliCDBMetaData metaData;
1375 metaData.SetBeamPeriod(0);
1376 metaData.SetResponsible("Haavard Helstrup");
1377 metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
1378 metaData.SetComment("Preprocessor AliTPC data base entries.");
1380 Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
1381 if ( !storeOK ) ++result;
1384 altroObjects->Delete();
1385 delete altroObjects;