From a3b590cfa253631b9573d4bb6de68b5efc3d1e6f Mon Sep 17 00:00:00 2001 From: marian Date: Fri, 17 Dec 2010 09:23:45 +0000 Subject: [PATCH] liTPCCalibCE.cxx.diff fix coverity warnings AliTPCcalibDButil.cxx.diff add missing include AliTPCcalibDButil.h.diff add missing forward AliTPCCalibPedestal.cxx.diff fix coverity warnings AliTPCCalibPulser.cxx.diff fix coverity warnings AliTPCCalibQAChecker.cxx.diff fix coverity warnings AliTPCcalibSummary.cxx.diff Add possibility to switch on/off time critical components via environment variable, set sampling time via environment var iable AliTPCCalibViewer.cxx.diff fix coverity warnings AliTPCCalibViewerGUI.cxx.diff fix coverity warnings AliTPCCalibViewerGUItime.cxx.diff fix coverity warnings (Jens) --- TPC/AliTPCCalibCE.cxx | 26 ++---- TPC/AliTPCCalibPedestal.cxx | 16 ++-- TPC/AliTPCCalibPulser.cxx | 11 +-- TPC/AliTPCCalibQAChecker.cxx | 2 +- TPC/AliTPCCalibViewerGUI.cxx | 9 +- TPC/AliTPCCalibViewerGUItime.cxx | 8 +- TPC/AliTPCcalibDButil.h | 2 +- TPC/AliTPCcalibSummary.cxx | 138 ++++++++++++++++++++++++++++++- 8 files changed, 164 insertions(+), 48 deletions(-) diff --git a/TPC/AliTPCCalibCE.cxx b/TPC/AliTPCCalibCE.cxx index 4b8a809b757..7e06aadf0cf 100644 --- a/TPC/AliTPCCalibCE.cxx +++ b/TPC/AliTPCCalibCE.cxx @@ -1376,16 +1376,11 @@ TH2S* AliTPCCalibCE::GetHisto(Int_t sector, TObjArray *arr, // if force is true create a new histogram if it doesn't exist allready // if ( !force || arr->UncheckedAt(sector) ) - return (TH2S*)arr->UncheckedAt(sector); + return (TH2S*)arr->UncheckedAt(sector); // if we are forced and histogram doesn't exist yet create it - Char_t name[255], title[255]; - - sprintf(name,"hCalib%s%.2d",type,sector); - sprintf(title,"%s calibration histogram sector %.2d",type,sector); - // new histogram with Q calib information. One value for each pad! - TH2S* hist = new TH2S(name,title, + TH2S* hist = new TH2S(Form("hCalib%s%.2d",type,sector),Form("%s calibration histogram sector %.2d",type,sector), nbinsY, ymin, ymax, fROC->GetNChannels(sector),0,fROC->GetNChannels(sector)); hist->SetDirectory(0); @@ -1431,16 +1426,11 @@ TH1S* AliTPCCalibCE::GetHisto(Int_t sector, TObjArray *arr, // if force is true create a new histogram if it doesn't exist allready // if ( !force || arr->UncheckedAt(sector) ) - return (TH1S*)arr->UncheckedAt(sector); + return (TH1S*)arr->UncheckedAt(sector); // if we are forced and histogram doesn't yes exist create it - Char_t name[255], title[255]; - - sprintf(name,"hCalib%s%.2d",type,sector); - sprintf(title,"%s calibration histogram sector %.2d",type,sector); - // new histogram with calib information. One value for each pad! - TH1S* hist = new TH1S(name,title, + TH1S* hist = new TH1S(Form("hCalib%s%.2d",type,sector),Form("%s calibration histogram sector %.2d",type,sector), fLastTimeBin-fFirstTimeBin,fFirstTimeBin,fLastTimeBin); hist->SetDirectory(0); arr->AddAt(hist,sector); @@ -1879,9 +1869,6 @@ TGraph *AliTPCCalibCE::MakeGraphTimeCE(Int_t sector, Int_t xVariable, Int_t fitT // for an example see class description at the beginning // - Double_t *x = new Double_t[fNevents]; - Double_t *y = new Double_t[fNevents]; - TVectorD *xVar = 0x0; TObjArray *aType = 0x0; Int_t npoints=0; @@ -1914,6 +1901,9 @@ TGraph *AliTPCCalibCE::MakeGraphTimeCE(Int_t sector, Int_t xVariable, Int_t fitT for ( Int_t i=0;iAt(sector)); @@ -1937,7 +1927,7 @@ TGraph *AliTPCCalibCE::MakeGraphTimeCE(Int_t sector, Int_t xVariable, Int_t fitT TGraph *gr = new TGraph(npoints); //sort xVariable increasing Int_t *sortIndex = new Int_t[npoints]; - TMath::Sort(npoints,x,sortIndex); + TMath::Sort(npoints,x,sortIndex, kFALSE); for (Int_t i=0;iSetPoint(i,x[sortIndex[i]],y[sortIndex[i]]); } diff --git a/TPC/AliTPCCalibPedestal.cxx b/TPC/AliTPCCalibPedestal.cxx index bc23d25ad5c..77fd7f0f17e 100644 --- a/TPC/AliTPCCalibPedestal.cxx +++ b/TPC/AliTPCCalibPedestal.cxx @@ -428,19 +428,15 @@ TH2F* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, // if force is true create a new histogram if it doesn't exist allready // if ( !force || arr->UncheckedAt(sector) ) - return (TH2F*)arr->UncheckedAt(sector); + return (TH2F*)arr->UncheckedAt(sector); // if we are forced and histogram doesn't yes exist create it - Char_t name[255], title[255]; - - sprintf(name,"hCalib%s%.2d",type,sector); - sprintf(title,"%s calibration histogram sector %.2d;ADC channel;Channel (pad)",type,sector); - // new histogram with Q calib information. One value for each pad! - TH2F* hist = new TH2F(name,title, - nbinsY, ymin, ymax, - fROC->GetNChannels(sector),0,fROC->GetNChannels(sector) - ); + TH2F* hist = new TH2F(Form("hCalib%s%.2d",type,sector), + Form("%s calibration histogram sector %.2d;ADC channel;Channel (pad)",type,sector), + nbinsY, ymin, ymax, + fROC->GetNChannels(sector),0,fROC->GetNChannels(sector) + ); hist->SetDirectory(0); arr->AddAt(hist,sector); return hist; diff --git a/TPC/AliTPCCalibPulser.cxx b/TPC/AliTPCCalibPulser.cxx index e4c6d1560a4..5c1daa74beb 100644 --- a/TPC/AliTPCCalibPulser.cxx +++ b/TPC/AliTPCCalibPulser.cxx @@ -782,14 +782,9 @@ TH2S* AliTPCCalibPulser::GetHisto(Int_t sector, TObjArray *arr, if ( !force || arr->UncheckedAt(sector) ) return (TH2S*)arr->UncheckedAt(sector); - // if we are forced and histogram doesn't yes exist create it - Char_t name[255], title[255]; - - sprintf(name,"hCalib%s%.2d",type,sector); - sprintf(title,"%s calibration histogram sector %.2d",type,sector); - - // new histogram with Q calib information. One value for each pad! - TH2S* hist = new TH2S(name,title, + // if we are forced and histogram doesn't yes exist create it + // new histogram with Q calib information. One value for each pad! + TH2S* hist = new TH2S(Form("hCalib%s%.2d",type,sector),Form("%s calibration histogram sector %.2d",type,sector), nbinsY, ymin, ymax, fROC->GetNChannels(sector),0,fROC->GetNChannels(sector)); hist->SetDirectory(0); diff --git a/TPC/AliTPCCalibQAChecker.cxx b/TPC/AliTPCCalibQAChecker.cxx index dff44ea547a..a40df943e79 100644 --- a/TPC/AliTPCCalibQAChecker.cxx +++ b/TPC/AliTPCCalibQAChecker.cxx @@ -520,7 +520,7 @@ AliTPCCalibQAChecker* AliTPCCalibQAChecker::NextSubChecker() // loop over sub checkers // if recursive, recursively return the pointers of non subchecker type sub checkers // - if (!fArrSubCheckers && !fArrSubCheckers->GetEntries()) return 0; + if (!fArrSubCheckers || !fArrSubCheckers->GetEntries()) return 0; if (!fIterSubCheckers) fIterSubCheckers=fArrSubCheckers->MakeIterator(); AliTPCCalibQAChecker *al=(AliTPCCalibQAChecker*)fIterSubCheckers->Next(); if (!al){ diff --git a/TPC/AliTPCCalibViewerGUI.cxx b/TPC/AliTPCCalibViewerGUI.cxx index 898c75821f2..cbe43b0c43c 100644 --- a/TPC/AliTPCCalibViewerGUI.cxx +++ b/TPC/AliTPCCalibViewerGUI.cxx @@ -1777,7 +1777,6 @@ void AliTPCCalibViewerGUI::DoFit() { TMatrixD covMatrix(0,0); TString cutStr(""); TString formulaStr(""); - TString *returnStr = new TString(""); // specify data to plot: TString drawStr(GetDrawString()->Data()); @@ -1815,12 +1814,14 @@ void AliTPCCalibViewerGUI::DoFit() { // ********** call AliTPCCalibViewer's fit-function ReplacePlaceHolders(drawStr); ReplacePlaceHolders(cutStr); - returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix); + TString *returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix); std::cout << std::endl; std::cout << "Your fit formula reads as follows:" << std::endl; std::cout << returnStr->Data() << std::endl; std::cout << "chi2 = " << chi2 << std::endl; + + delete returnStr; } @@ -1858,6 +1859,7 @@ void AliTPCCalibViewerGUI::DoExportNorm() { } Error("DoExportNorm", "Not yet implemented."); +/* return; // specify data to plot: @@ -1874,6 +1876,7 @@ void AliTPCCalibViewerGUI::DoExportNorm() { // finally export calPad to Cint: gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, (ULong_t) calPad)); Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName); + */ } @@ -1888,7 +1891,7 @@ void AliTPCCalibViewerGUI::GetMinMax() { ptr = listOfPrimitives->At(i); if ( ptr->InheritsFrom("TH1") ) break; } - if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1 + if ( !ptr || !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1 TH1 *hist = (TH1*)ptr; // Double_t histMax = hist->GetMaximum(); diff --git a/TPC/AliTPCCalibViewerGUItime.cxx b/TPC/AliTPCCalibViewerGUItime.cxx index 5583ddfb70f..5a39da7c729 100644 --- a/TPC/AliTPCCalibViewerGUItime.cxx +++ b/TPC/AliTPCCalibViewerGUItime.cxx @@ -662,8 +662,10 @@ const char* AliTPCCalibViewerGUItime::GetDrawString(){ id=fListVariables->GetSelectedEntry()->EntryId(); // printf("id: %d\n",id); TString branchName=selectedVariable; - const TObject *key=(*fConfigParser)(id); - if (key) branchName=(*fConfigParser)(id)->GetName(); + if (fConfigParser){ + const TObject *key=(*fConfigParser)(id); + if (key) branchName=(*fConfigParser)(id)->GetName(); + } //treat case of TVector if (branchName.EndsWith(".")){ Int_t par = (Int_t)(fNmbPar->GetNumber()); @@ -880,7 +882,7 @@ void AliTPCCalibViewerGUItime::DoDraw() { } } } - UpdateValueArrays(graphOutput, xArr); + if (xArr) UpdateValueArrays(graphOutput, xArr); // if (graphOutput){ // if (fIsCustomDraw){ // if (fDrawString.Contains(":")){ diff --git a/TPC/AliTPCcalibDButil.h b/TPC/AliTPCcalibDButil.h index 2968c0a5ab9..c3a3b699efa 100644 --- a/TPC/AliTPCcalibDButil.h +++ b/TPC/AliTPCcalibDButil.h @@ -33,7 +33,7 @@ class AliTPCdataQA; class TGraphErrors; class TTreeSRedirector; class AliTPCCalROC; - +class AliSplineFit; class AliTPCcalibDButil : public TObject { diff --git a/TPC/AliTPCcalibSummary.cxx b/TPC/AliTPCcalibSummary.cxx index 2ac158e59a6..cb31455c621 100644 --- a/TPC/AliTPCcalibSummary.cxx +++ b/TPC/AliTPCcalibSummary.cxx @@ -173,7 +173,7 @@ void AliTPCcalibSummary::ProcessRun(Int_t irun, Int_t startTime, Int_t endTime){ AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray); AliDCSSensorArray* goofieArray = fCalibDB->GetGoofieSensors(irun); // - Int_t dtime = TMath::Max((endTime-startTime)/20,10*60); + Int_t dtime = TMath::Max((endTime-startTime)/20,10); // //Goofie statistical data // @@ -313,7 +313,7 @@ void AliTPCcalibSummary::ProcessRun(Int_t irun, Int_t startTime, Int_t endTime){ } // TVectorD voltagesIROC(36); - TVectorD voltagesOROC(36); + TVectorD voltagesOROC(36); for(Int_t j=1; j<36; j++) voltagesIROC[j-1] = fCalibDB->GetChamberHighVoltage(irun, j,itime); for(Int_t j=36; j<72; j++) voltagesOROC[j-36] = fCalibDB->GetChamberHighVoltage(irun, j,itime); Double_t voltIROC = TMath::Median(36, voltagesIROC.GetMatrixArray()); @@ -383,8 +383,9 @@ void AliTPCcalibSummary::ProcessRun(Int_t irun, Int_t startTime, Int_t endTime){ ProcessCTP(irun,itime); ProcessAlign(irun,itime); ProcessGain(irun,itime); - ProcessDriftCERef(); - ProcessPulserRef(); + //ProcessDriftCERef(); + //ProcessPulserRef(); + ProcessCurrent(irun,itime); (*fPcstream)<<"dcs"<< @@ -939,6 +940,135 @@ void AliTPCcalibSummary::ProcessPulserRef(){ "PulserTChi2.="<<&vecAChi2; // chi2 (rms in cm) } +void AliTPCcalibSummary::ProcessCurrent(Int_t irun, Int_t itime){ + // + // Dump current + // + //variables to export + // + static TObjArray *currentArray=new TObjArray(72); // current graphs + static TObjArray *currentArray2=new TObjArray(72); // current graphs to export + // + static TVectorD currentIROC(36); // current snapshots + static TVectorD currentOROC(36); + static TVectorF sector(72); // + static Double_t medcurIROC = 0; + static Double_t medcurOROC = 0; + // + static TVectorF minROC(72); // current mean +-5 minutes + static TVectorF maxROC(72); + static TVectorF meanROC(72); + static TVectorF medianROC(72); + static Double_t meanIIROC=0; + static Double_t meanIOROC=0; + static Double_t medianIIROC=0; + static Double_t medianIOROC=0; + // + AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(irun); + // + for(Int_t j=1; j<36; j++) currentIROC[j-1] = fCalibDB->GetChamberHighVoltage(irun, j,itime,-1,kTRUE); + for(Int_t j=36; j<72; j++) currentOROC[j-36] = fCalibDB->GetChamberHighVoltage(irun, j,itime,-1,kTRUE); + medcurIROC = TMath::Median(36, currentIROC.GetMatrixArray()); + medcurOROC = TMath::Median(36, currentOROC.GetMatrixArray()); + + + if (currentArray->At(0)==0){ + for (Int_t isec=0; isec<72; isec++){ + TString sensorName=""; + const char* sideName=(isec%36<18) ? "A":"C"; + if (isec<36){ + //IROC + sensorName=Form("TPC_ANODE_I_%s%02d_IMEAS",sideName,isec%18); + }else{ + //OROC + sensorName=Form("TPC_ANODE_O_%s%02d_0_IMEAS",sideName,isec%18); + } + + AliDCSSensor *sensor = 0; + if (voltageArray) sensor= voltageArray->GetSensor(sensorName); + TGraph *gr=0; + if (!sensor) gr=new TGraph(1); + else{ + if (!sensor->GetGraph()) gr=new TGraph(1); + else{ + gr=sensor->GetGraph(); + Double_t startTime=sensor->GetStartTime(); + Double_t * time = new Double_t[gr->GetN()]; + for (Int_t ip=0; ipGetN(); ip++){ time[ip]= (gr->GetX()[ip]*3600.)+startTime;} + gr=new TGraph(gr->GetN(), time, gr->GetY()); + delete [] time; + } + } + gr->Sort(); + currentArray->AddAt(gr, isec); + currentArray->AddAt(gr->Clone(), isec); + } + } + + + for (Int_t isec=0; isec<72; isec++){ + sector[isec]=isec; + TGraph * gr = (TGraph*)currentArray->At(isec); + TGraph * graph2 = (TGraph*)currentArray2->At(isec); + Int_t firstBin= TMath::BinarySearch(gr->GetN(), gr->GetX(), itime-300.)-2; + Int_t lastBin= TMath::BinarySearch(gr->GetN(), gr->GetX(), itime+300.)+2; + if (firstBin<0) firstBin=0; + if (lastBin>=gr->GetN()) lastBin=gr->GetN()-1; + // + if (firstBinGetY()[firstBin])); + maxROC[isec]=TMath::MaxElement(lastBin-firstBin, &(gr->GetY()[firstBin])); + meanROC[isec]=TMath::Mean(lastBin-firstBin, &(gr->GetY()[firstBin])); + medianROC[isec]=TMath::Median(lastBin-firstBin, &(gr->GetY()[firstBin])); + graph2 = new TGraph(lastBin-firstBin, &(gr->GetX()[firstBin]), &(gr->GetY()[firstBin])); + delete currentArray2->At(isec); + currentArray2->AddAt(graph2,isec); + } + (*fPcstream)<<"dcs"<< // current information + Form("current%d.=",isec)<