X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TPC%2FAliTPCPreprocessor.cxx;h=f06c379cb82b35c413cf278f31b77c28c75a787b;hb=1f2c671694ecefff79f959edd2c8025af66132ca;hp=b1ec880f59ed90113b0ee18362c8c710aaefb402;hpb=9c754ce7fce0ff8e3db6c2179c648bf4e98d95f8;p=u%2Fmrichter%2FAliRoot.git diff --git a/TPC/AliTPCPreprocessor.cxx b/TPC/AliTPCPreprocessor.cxx index b1ec880f59e..f06c379cb82 100644 --- a/TPC/AliTPCPreprocessor.cxx +++ b/TPC/AliTPCPreprocessor.cxx @@ -27,21 +27,28 @@ #include "AliTPCCalibPedestal.h" #include "AliTPCCalibPulser.h" #include "AliTPCCalibCE.h" +#include "AliTPCCalibRaw.h" +#include "AliTPCdataQA.h" +#include "ARVersion.h" #include "TFile.h" #include "TTree.h" +#include "TGraph.h" #include "TEnv.h" +#include "TParameter.h" #include const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees -const TString kPedestalRunType = "PEDESTAL_RUN"; // pedestal run identifier -const TString kPulserRunType = "PULSER_RUN"; // pulser run identifier +const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier +const TString kPulserRunType = "PULSER"; // pulser run identifier const TString kPhysicsRunType = "PHYSICS"; // physics run identifier -const TString kStandAloneRunType = "STANDALONE"; // standalone run identifier +const TString kCosmicRunType = "COSMIC"; // cosmic run identifier +const TString kLaserRunType = "LASER"; // laser run identifier const TString kDaqRunType = "DAQ"; // DAQ run identifier -const TString kAmandaTemp = "tpc_PT_%d.Temperature"; // Amanda string for temperature entries -const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required +const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries +//const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required +const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run // // This class is the SHUTTLE preprocessor for the TPC detector. @@ -52,23 +59,31 @@ ClassImp(AliTPCPreprocessor) //______________________________________________________________________________________________ AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) : AliPreprocessor("TPC",shuttle), - fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE), fROC(0) + fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0) { // constructor fROC = AliTPCROC::Instance(); + + // define run types to be processed + + AddRunType(kPedestalRunType); + AddRunType(kPulserRunType); + AddRunType(kPhysicsRunType); + AddRunType(kCosmicRunType); + AddRunType(kLaserRunType); + AddRunType(kDaqRunType); + } //______________________________________________________________________________________________ -// AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) : -// AliPreprocessor(org), -// fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE) -// { -// // copy constructor not implemented -// // -- missing underlying copy constructor in AliPreprocessor -// -// Fatal("AliTPCPreprocessor", "copy constructor not implemented"); + AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& ) : + AliPreprocessor("TPC",0), + fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0), fConfigOK(kTRUE), fROC(0) + { + + Fatal("AliTPCPreprocessor", "copy constructor not implemented"); // // // fTemp = new AliTPCSensorTempArray(*(org.fTemp)); -// } + } //______________________________________________________________________________________________ AliTPCPreprocessor::~AliTPCPreprocessor() @@ -90,13 +105,16 @@ AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& ) void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) { - // Creates AliTestDataDCS object + // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start - AliPreprocessor::Initialize(run, startTime, endTime); + UInt_t startTimeLocal = startTime-3600; + UInt_t endTimeLocal = endTime+1800; + + AliPreprocessor::Initialize(run, startTimeLocal, endTimeLocal); AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, - TTimeStamp(startTime).AsString(), - TTimeStamp(endTime).AsString())); + TTimeStamp((time_t)startTime,0).AsString(), + TTimeStamp((time_t)endTime,0).AsString())); // Preprocessor configuration @@ -110,7 +128,11 @@ void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, // Temperature sensors - TTree *confTree = 0; + TTree *confTree = 0; + + TString tempConf = fConfEnv->GetValue("Temperature","ON"); + tempConf.ToUpper(); + if (tempConf != "OFF" ) { entry = GetFromOCDB("Config", "Temperature"); if (entry) confTree = (TTree*) entry->GetObject(); if ( confTree==0 ) { @@ -118,14 +140,16 @@ void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, fConfigOK = kFALSE; return; } - fTemp = new AliTPCSensorTempArray(fStartTime, fEndTime, confTree, kAmandaTemp); + fTemp = new AliTPCSensorTempArray(startTimeLocal, endTimeLocal, confTree, kAmandaTemp); fTemp->SetValCut(kValCutTemp); fTemp->SetDiffCut(kDiffCutTemp); - + } // High voltage measurements - if (false) { // high voltage maps not yet implemented... + TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); + hvConf.ToUpper(); + if (hvConf != "OFF" ) { confTree=0; entry=0; entry = GetFromOCDB("Config", "HighVoltage"); @@ -135,8 +159,44 @@ void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, fConfigOK = kFALSE; return; } - fHighVoltage = new AliDCSSensorArray(fStartTime, fEndTime, confTree); + fHighVoltage = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree); + } + + // High voltage status values + + TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON"); + hvStatConf.ToUpper(); + if (hvStatConf != "OFF" ) { + confTree=0; + entry=0; + entry = GetFromOCDB("Config", "HighVoltageStat"); + if (entry) confTree = (TTree*) entry->GetObject(); + if ( confTree==0 ) { + Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n"); + fConfigOK = kFALSE; + return; + } + fHighVoltageStat = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree); } + + // Goofie values + + TString goofieConf = fConfEnv->GetValue("Goofie","ON"); + goofieConf.ToUpper(); + if (goofieConf != "OFF" ) { + confTree=0; + entry=0; + entry = GetFromOCDB("Config", "Goofie"); + if (entry) confTree = (TTree*) entry->GetObject(); + if ( confTree==0 ) { + Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n"); + fConfigOK = kFALSE; + return; + } + fGoofie = new AliDCSSensorArray(startTimeLocal, endTimeLocal, confTree); + } + + } //______________________________________________________________________________________________ @@ -146,26 +206,63 @@ UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap) // Amanda servers provide information directly through dcsAliasMap - if (!dcsAliasMap) return 9; - if (dcsAliasMap->GetEntries() == 0 ) return 9; + if (!fConfigOK) return 9; + UInt_t result = 0; + TObjArray *resultArray = new TObjArray(); + TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON"); + errorHandling.ToUpper(); + TObject * status; + + UInt_t dcsResult=0; + if (errorHandling == "OFF" ) { + if (!dcsAliasMap) dcsResult=1; + if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1; + status = new TParameter("dcsResult",dcsResult); + resultArray->Add(status); + } else { + if (!dcsAliasMap) return 9; + if (dcsAliasMap->GetEntries() == 0 ) return 9; + } + + + TString runType = GetRunType(); // Temperature sensors are processed by AliTPCCalTemp - - UInt_t tempResult = MapTemperature(dcsAliasMap); - UInt_t result=tempResult; + TString tempConf = fConfEnv->GetValue("Temperature","ON"); + tempConf.ToUpper(); + if (tempConf != "OFF" ) { + UInt_t tempResult = MapTemperature(dcsAliasMap); + result=tempResult; + status = new TParameter("tempResult",tempResult); + resultArray->Add(status); + } // High Voltage recordings - if (false) { // High Voltage maps not yet implemented.. - - UInt_t hvResult = MapHighVoltage(dcsAliasMap); - result+=hvResult; + TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); + hvConf.ToUpper(); + if (hvConf != "OFF" ) { + UInt_t hvResult = MapHighVoltage(dcsAliasMap); + result+=hvResult; + status = new TParameter("hvResult",hvResult); + resultArray->Add(status); + } + + // Goofie values + + TString goofieConf = fConfEnv->GetValue("Goofie","ON"); + goofieConf.ToUpper(); + if (goofieConf != "OFF" ) { + UInt_t goofieResult = MapGoofie(dcsAliasMap); + result+=goofieResult; + status = new TParameter("goofieResult",goofieResult); + resultArray->Add(status); } // Other calibration information will be retrieved through FXS files @@ -179,44 +276,168 @@ UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap) // pedestal entries if(runType == kPedestalRunType) { - Int_t pedestalSource = AliShuttleInterface::kDAQ; + Int_t numSources = 1; + Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; TString source = fConfEnv->GetValue("Pedestal","DAQ"); source.ToUpper(); - if ( source == "HLT" ) pedestalSource = AliShuttleInterface::kHLT; - if (!GetHLTStatus()) pedestalSource = AliShuttleInterface::kDAQ; - UInt_t pedestalResult = ExtractPedestals(pedestalSource); - result += pedestalResult; - + if (source != "OFF" ) { + if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT; + if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ; + if (source == "HLTDAQ" ) { + numSources=2; + pedestalSource[0] = AliShuttleInterface::kHLT; + pedestalSource[1] = AliShuttleInterface::kDAQ; + } + if (source == "DAQHLT" ) numSources=2; + UInt_t pedestalResult=0; + for (Int_t i=0; i("pedestalResult",pedestalResult); + resultArray->Add(status); + } } // pulser trigger processing - if( runType == kPulserRunType ) { - Int_t pulserSource = AliShuttleInterface::kDAQ; + if(runType == kPulserRunType) { + Int_t numSources = 1; + Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; TString source = fConfEnv->GetValue("Pulser","DAQ"); source.ToUpper(); - if ( source == "HLT" ) pulserSource = AliShuttleInterface::kHLT; - if (!GetHLTStatus()) pulserSource = AliShuttleInterface::kDAQ; - UInt_t pulserResult = ExtractPulser(pulserSource); - result += pulserResult; + if ( source != "OFF") { + if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT; + if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ; + if (source == "HLTDAQ" ) { + numSources=2; + pulserSource[0] = AliShuttleInterface::kHLT; + pulserSource[1] = AliShuttleInterface::kDAQ; + } + if (source == "DAQHLT" ) numSources=2; + UInt_t pulserResult=0; + for (Int_t i=0; i("pulserResult",pulserResult); + resultArray->Add(status); + } + } + +// raw calibration processing + + if(runType == kPhysicsRunType) { + Int_t numSources = 1; + Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; + TString source = fConfEnv->GetValue("Raw","DAQ"); + source.ToUpper(); + if ( source != "OFF") { + if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT; + if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ; + if (source == "HLTDAQ" ) { + numSources=2; + rawSource[0] = AliShuttleInterface::kHLT; + rawSource[1] = AliShuttleInterface::kDAQ; + } + if (source == "DAQHLT" ) numSources=2; + UInt_t rawResult=0; + for (Int_t i=0; i("rawResult",rawResult); + resultArray->Add(status); + } } + + // Altro configuration + + + TString altroConf = fConfEnv->GetValue("AltroConf","ON"); + goofieConf.ToUpper(); + if (altroConf != "OFF" ) { + UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS); + result+=altroResult; + status = new TParameter("altroResult",altroResult); + resultArray->Add(status); + } + + // Central Electrode processing - if( runType == kPhysicsRunType || runType == kStandAloneRunType || - runType == kDaqRunType ) { - Int_t ceSource = AliShuttleInterface::kDAQ; + if( runType == kPhysicsRunType || + runType == kLaserRunType ) { + + Int_t numSources = 1; + Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; TString source = fConfEnv->GetValue("CE","DAQ"); source.ToUpper(); - if ( source == "HLT" ) ceSource = AliShuttleInterface::kHLT; - if (!GetHLTStatus()) ceSource = AliShuttleInterface::kDAQ; - UInt_t ceResult = ExtractCE(ceSource); - result += ceResult; - + if ( source != "OFF" ) { + if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT; + if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ; + if (source == "HLTDAQ" ) { + numSources=2; + ceSource[0] = AliShuttleInterface::kHLT; + ceSource[1] = AliShuttleInterface::kDAQ; + } + if (source == "DAQHLT" ) numSources=2; + UInt_t ceResult=0; + for (Int_t i=0; i("ceResult",ceResult); + resultArray->Add(status); + + numSources = 1; + Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; + source = fConfEnv->GetValue("QA","DAQ"); + source.ToUpper(); + if ( source != "OFF" ) { + if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT; + if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ; + if (source == "HLTDAQ" ) { + numSources=2; + qaSource[0] = AliShuttleInterface::kHLT; + qaSource[1] = AliShuttleInterface::kDAQ; + } + if (source == "DAQHLT" ) numSources=2; + UInt_t qaResult=0; + for (Int_t i=0; i("qaResult",qaResult); + resultArray->Add(status); + } + } + } + + if (errorHandling == "OFF" ) { + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); + metaData.SetComment("Preprocessor AliTPC status."); + Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE); + resultArray->Delete(); + return 0; + } else { + return result; } - - return result; } //______________________________________________________________________________________________ UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap) @@ -228,7 +449,7 @@ UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap) TMap *map = fTemp->ExtractDCS(dcsAliasMap); if (map) { fTemp->MakeSplineFit(map); - Double_t fitFraction = fTemp->NumFits()/fTemp->NumSensors(); + Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); if (fitFraction > kFitFraction ) { AliInfo(Form("Temperature values extracted, fits performed.\n")); } else { @@ -246,6 +467,7 @@ UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap) AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); metaData.SetComment("Preprocessor AliTPC data base entries."); Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE); @@ -267,9 +489,9 @@ UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap) TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap); if (map) { fHighVoltage->MakeSplineFit(map); - Double_t fitFraction = fHighVoltage->NumFits()/fHighVoltage->NumSensors(); + Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors(); if (fitFraction > kFitFraction ) { - AliInfo(Form("High volatge recordings extracted, fits performed.\n")); + AliInfo(Form("High voltage recordings extracted, fits performed.\n")); } else { Log ("Too few high voltage recordings fitted. \n"); result = 9; @@ -279,12 +501,31 @@ UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap) result=9; } delete map; + + TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON"); + hvStatConf.ToUpper(); + if (hvStatConf != "OFF" ) { + TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap); + if (map2) { + fHighVoltageStat->ClearFit(); + fHighVoltageStat->SetGraph(map2); + } else { + Log("No high voltage status recordings extracted. \n"); + result=9; + } + delete map2; + + // add status maps to high voltage sensor array + + fHighVoltage->AddSensors(fHighVoltageStat); + } // Now store the final CDB file if ( result == 0 ) { AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); metaData.SetComment("Preprocessor AliTPC data base entries."); Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE); @@ -296,6 +537,42 @@ UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap) } +//______________________________________________________________________________________________ +UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap) +{ + + // extract DCS Goofie maps. Do not perform fits (low update rate) + + UInt_t result=0; + + TMap *map = fGoofie->ExtractDCS(dcsAliasMap); + if (map) { + fGoofie->ClearFit(); + fGoofie->SetGraph(map); + } else { + Log("No Goofie recordings extracted. \n"); + result=9; + } + delete map; + + // Now store the final CDB file + + if ( result == 0 ) { + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); + metaData.SetComment("Preprocessor AliTPC data base entries."); + + Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE); + if ( !storeOK ) result=1; + + } + + return result; + +} + //______________________________________________________________________________________________ @@ -314,7 +591,7 @@ UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) } AliTPCCalPad *calPadRMS=0; - entry = GetFromOCDB("Calib", "Noise"); + entry = GetFromOCDB("Calib", "PadNoise"); if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject(); if ( calPadRMS==NULL ) { Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n"); @@ -345,7 +622,7 @@ UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) break; } AliTPCCalibPedestal *calPed; - f->GetObject("AliTPCCalibPedestal",calPed); + f->GetObject("tpcCalibPedestal",calPed); if ( !calPed ) { Log ("No pedestal calibration object in file."); result = 2; @@ -361,6 +638,8 @@ UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE); if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector); } + delete calPed; + f->Close(); } ++index; } // while(list) @@ -371,6 +650,7 @@ UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); metaData.SetComment("Preprocessor AliTPC data base entries."); Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE); @@ -446,7 +726,7 @@ UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) break; } AliTPCCalibPulser *calPulser; - f->GetObject("AliTPCCalibPulser",calPulser); + f->GetObject("tpcCalibPulser",calPulser); if ( !calPulser ) { Log ("No pulser calibration object in file."); result = 2; @@ -464,6 +744,8 @@ UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector); if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector); } + delete calPulser; + f->Close(); } ++index; } // while(list) @@ -474,6 +756,7 @@ UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); metaData.SetComment("Preprocessor AliTPC data base entries."); Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE); @@ -487,43 +770,104 @@ UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) return result; } +//______________________________________________________________________________________________ + + +UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS) +{ + // + // Read Raw calibration file from file exchage server + // + + UInt_t result=0; + TObjArray *calRaw; + + TList* list = GetFileSources(sourceFXS,"AliTPCCalibRaw"); + + if (list && list->GetEntries()>0) { + +// loop through all files + + UInt_t index = 0; + while (list->At(index)!=NULL) { + TObjString* fileNameEntry = (TObjString*) list->At(index); + if (fileNameEntry!=NULL) { + TString fileName = GetFile(sourceFXS, "tpcCalibRaw", + fileNameEntry->GetString().Data()); + TFile *f = TFile::Open(fileName); + if (!f) { + Log ("Error opening raw file."); + result =2; + break; + } + f->GetObject("tpcCalibRaw",calRaw); + if ( !calRaw ) { + Log ("No raw calibration object in file."); + result = 2; + break; + } + + f->Close(); + } + ++index; + } // while(list) +// +// Store updated pedestal entry to OCDB +// + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); + metaData.SetComment("Preprocessor AliTPC data base entries."); + + Bool_t storeOK = Store("Calib", "Raw", calRaw, &metaData, 0, kTRUE); + if ( !storeOK ) ++result; + } else { + Log ("Error: no entries in input file list!"); + result = 1; + } + + return result; +} +//______________________________________________________________________________________________ + UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) { // // Read Central Electrode file from file exchage server - // Keep original entry from OCDB in case no new CE calibration is available + // // - TObjArray *ceObjects=0; AliTPCCalPad *ceTmean=0; AliTPCCalPad *ceTrms=0; AliTPCCalPad *ceQmean=0; - AliCDBEntry* entry = GetFromOCDB("Calib", "CE"); - if (entry) ceObjects = (TObjArray*)entry->GetObject(); - if ( ceObjects==NULL ) { - Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n"); - ceObjects = new TObjArray; - } + TObjArray *rocTtime=0; + TObjArray *rocQtime=0; - ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean"); - if ( !ceTmean ) { - ceTmean = new AliTPCCalPad("CETmean","CETmean"); - ceObjects->Add(ceTmean); - } - ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms"); - if ( !ceTrms ) { - ceTrms = new AliTPCCalPad("CETrms","CETrms"); - ceObjects->Add(ceTrms); - } - ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean"); - if ( !ceQmean ) { - ceQmean = new AliTPCCalPad("CEQmean","CEQmean"); - ceObjects->Add(ceQmean); - } + TObjArray *ceObjects= new TObjArray; + + + Int_t nSectors = fROC->GetNSectors(); + ceTmean = new AliTPCCalPad("CETmean","CETmean"); + ceObjects->Add(ceTmean); + + ceTrms = new AliTPCCalPad("CETrms","CETrms"); + ceObjects->Add(ceTrms); + + ceQmean = new AliTPCCalPad("CEQmean","CEQmean"); + ceObjects->Add(ceQmean); + + rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average + rocTtime->SetName("rocTtime"); + ceObjects->Add(rocTtime); + + rocQtime = new TObjArray(nSectors); + rocQtime->SetName("rocQtime"); + ceObjects->Add(rocQtime); + UInt_t result=0; - Int_t nSectors = fROC->GetNSectors(); TList* list = GetFileSources(sourceFXS,"CE"); if (list && list->GetEntries()>0) { @@ -543,8 +887,13 @@ UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) break; } AliTPCCalibCE *calCE; - f->GetObject("AliTPCCalibCE",calCE); + f->GetObject("tpcCalibCE",calCE); + if (!calCE) { + Log ("No valid calibCE object."); + result=2; + break; + } // replace entries for the sectors available in the present file for (Int_t sector=0; sectorGetCalRocRMS(sector); if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector); AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector); - if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector); + if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector); + TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph + if ( grT ) rocTtime->AddAt(grT,sector); + TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph + if ( grQ ) rocTtime->AddAt(grQ,sector); } + + TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average + if ( grT ) rocTtime->AddAt(grT,nSectors); + grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average + if ( grT ) rocTtime->AddAt(grT,nSectors+1); + + + delete calCE; + f->Close(); } ++index; } // while(list) @@ -564,6 +926,7 @@ UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); metaData.SetComment("Preprocessor AliTPC data base entries."); Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE); @@ -576,3 +939,203 @@ UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) return result; } +//______________________________________________________________________________________________ + +UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS) +{ + // + // Read Quality Assurance file from file exchage server + // + + UInt_t result=0; + + TList* list = GetFileSources(sourceFXS,"QA"); + + if (list && list->GetEntries()>0) { + +// only one QA objetc should be available! + + AliTPCdataQA *calQA; + + UInt_t nentries = list->GetEntries(); + UInt_t index=0; + if ( nentries > 1) Log ( "More than one QA entry. First one processed"); + TObjString* fileNameEntry = (TObjString*) list->At(index); + if (fileNameEntry!=NULL) { + TString fileName = GetFile(sourceFXS, "QA", + fileNameEntry->GetString().Data()); + TFile *f = TFile::Open(fileName); + if (!f) { + Log ("Error opening QA file."); + result =2; + } else { + f->GetObject("tpcCalibQA",calQA); + if ( calQA ) { +// +// Store updated pedestal entry to OCDB +// + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); + metaData.SetComment("Preprocessor AliTPC data base entries."); + + Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kTRUE); + if ( !storeOK ) ++result; + } + } + } else { + Log ("Error: no QA files on FXS!"); + result = 2; + } + } else { + Log ("Error: no QA entries in FXS list!"); + result = 1; + } + return result; +} + +//______________________________________________________________________________________________ + + +UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS) +{ + // + // Read pulser calibration file from file exchage server + // Keep original entry from OCDB in case no new pulser calibration is available + // + TObjArray *altroObjects=0; + AliTPCCalPad *acqStart=0; + AliTPCCalPad *zsThr=0; + AliTPCCalPad *acqStop=0; + AliTPCCalPad *FPED=0; + AliTPCCalPad *masked=0; + + AliCDBEntry* entry = GetFromOCDB("Calib", "Altro"); + if (entry) altroObjects = (TObjArray*)entry->GetObject(); + if ( altroObjects==NULL ) { + Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n"); + altroObjects = new TObjArray; + } + + acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart"); + if ( !acqStart ) { + acqStart = new AliTPCCalPad("AcqStart","AcqStart"); + altroObjects->Add(acqStart); + } + zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr"); + if ( !zsThr ) { + zsThr = new AliTPCCalPad("ZsThr","ZsThr"); + altroObjects->Add(zsThr); + } + FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED"); + if ( !FPED ) { + FPED = new AliTPCCalPad("FPED","FPED"); + altroObjects->Add(FPED); + } + acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop"); + if ( !acqStop ) { + acqStop = new AliTPCCalPad("AcqStop","AcqStop"); + altroObjects->Add(acqStop); + } + masked = (AliTPCCalPad*)altroObjects->FindObject("Masked"); + if ( !masked ) { + masked = new AliTPCCalPad("Masked","Masked"); + altroObjects->Add(masked); + } + + + + UInt_t result=0; + TString idFXS[2]={"AltroConfigA","AltroConfigC"}; + + Int_t nSectors = fROC->GetNSectors(); + Bool_t changed=false; + for ( Int_t id=0; id<2; id++) { + TList* list = GetFileSources(sourceFXS,idFXS[id].Data()); + + if (list && list->GetEntries()>0) { + if (altroObjects == 0 ) altroObjects = new TObjArray; + +// loop through all files from LDCs + + UInt_t index = 0; + while (list->At(index)!=NULL) { + TObjString* fileNameEntry = (TObjString*) list->At(index); + if (fileNameEntry!=NULL) { + TString fileName = GetFile(sourceFXS, idFXS[id].Data(), + fileNameEntry->GetString().Data()); + TFile *f = TFile::Open(fileName); + if (!f) { + char message[40]; + sprintf(message,"Error opening Altro configuration file, id = %d",id); + Log (message); + result =2; + break; + } + TObjArray *altroFXS; + f->GetObject("AltroConfig",altroFXS); + if ( !altroFXS ) { + Log ("No Altro configuration object in file."); + result = 2; + break; + } + + // replace entries for the sectors available in the present file + AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart"); + AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr"); + AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop"); + AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED"); + AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked"); + + changed=true; + for (Int_t sector=0; sectorGetCalROC(sector); + if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector); + } + if (zsThrFXS ) { + AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector); + if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector); + } + if (acqStopFXS) { + AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector); + if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector); + } + if (FPEDFXS ) { + AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector); + if ( rocFPED ) FPED->SetCalROC(rocFPED,sector); + } + if (maskedFXS) { + AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector); + if ( rocMasked ) masked->SetCalROC(rocMasked,sector); + } + } + delete altroFXS; + f->Close(); + } + ++index; + } // while(list) + } else { + Log ("Error: no entries in input file list!"); + result = 1; + } + + } // for - id +// +// Store updated pedestal entry to OCDB +// + if (changed) { + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Haavard Helstrup"); + metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH); + metaData.SetComment("Preprocessor AliTPC data base entries."); + + Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kTRUE); + if ( !storeOK ) ++result; + } + + return result; +}