]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
liTPCCalibCE.cxx.diff fix coverity warnings
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Dec 2010 09:23:45 +0000 (09:23 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Dec 2010 09:23:45 +0000 (09:23 +0000)
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
TPC/AliTPCCalibPedestal.cxx
TPC/AliTPCCalibPulser.cxx
TPC/AliTPCCalibQAChecker.cxx
TPC/AliTPCCalibViewerGUI.cxx
TPC/AliTPCCalibViewerGUItime.cxx
TPC/AliTPCcalibDButil.h
TPC/AliTPCcalibSummary.cxx

index 4b8a809b75750b6b32f932aaf6ac14f3ec620bd5..7e06aadf0cf2b9d7ce6115cbb3ac5a8b07557753 100644 (file)
@@ -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;i<fNevents; ++i) (*xVar)[i]=i;
   }
   
+  Double_t *x = new Double_t[fNevents];
+  Double_t *y = new Double_t[fNevents];
+  
   for (Int_t ievent =0; ievent<fNevents; ++ievent){
     if ( fitType<2 ){
       TObjArray *events = (TObjArray*)(aType->At(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;i<npoints;++i){
     gr->SetPoint(i,x[sortIndex[i]],y[sortIndex[i]]);
   }
index bc23d25ad5cef06217c237fd411f993f9c0e33cb..77fd7f0f17eec374f80c7b8d3f5c95434fc44654 100644 (file)
@@ -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;
index e4c6d1560a4c1b55f2feaa9ac195d367a56cf6d0..5c1daa74beb42524a48dd6ab653e10ba11f4348b 100644 (file)
@@ -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);
index dff44ea547ad27c020013dba808885809adeb85f..a40df943e79f4f20cd38a3b8244e0b53d7725ef5 100644 (file)
@@ -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){
index 898c75821f22e1177cbf12fd5beb2f2ed0f3c82d..cbe43b0c43c5340ea293625464a2370a0012c88a 100644 (file)
@@ -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();
index 5583ddfb70f515f39a7c0e83dca87adbaa11d21f..5a39da7c729f1ea664b8c92f9ae1dee9a9fba07d 100644 (file)
@@ -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(":")){
index 2968c0a5ab9e38f78b5d357a63add22867b05dd6..c3a3b699efacc5159e42e77c87451072276e2013 100644 (file)
@@ -33,7 +33,7 @@ class AliTPCdataQA;
 class TGraphErrors;
 class TTreeSRedirector;
 class AliTPCCalROC;
-
+class AliSplineFit;
 
 class AliTPCcalibDButil : public TObject
 {
index 2ac158e59a6f677af6345186907f131cc8da4dbf..cb31455c621578c446efca8b233b2db5bddbfe22 100644 (file)
@@ -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; ip<gr->GetN(); 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 (firstBin<lastBin){
+      //
+      minROC[isec]=TMath::MinElement(lastBin-firstBin, &(gr->GetY()[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)<<graph2;
+  }     
+  meanIIROC=TMath::Mean(36, &(meanROC.GetMatrixArray()[0]));
+  meanIOROC=TMath::Mean(36, &(meanROC.GetMatrixArray()[36]));
+  medianIIROC=TMath::Median(36, &(meanROC.GetMatrixArray()[0]));
+  medianIOROC=TMath::Median(36, &(meanROC.GetMatrixArray()[36]));
+  //
+  (*fPcstream)<<"dcs"<<     // current information
+    "isec.="<<&sector<<                       //sector number
+    "IIROC.="<<&currentIROC<<               // current sample at given moment
+    "IOROC.="<<&currentOROC<<               // current sample at given moment
+    "medianIIROC="<<medcurIROC<<            // median at given moment 
+    "medianIOROC="<<medcurOROC<<            // median at given moment
+    //
+    "minIROC.="<<&minROC<<                  // minimum in +-5 min 
+    "maxIROC.="<<&maxROC<<                  // maximum in +-5 min
+    "meanIROC.="<<&meanROC<<                // mean in +-5 min
+    "medianIROC.="<<&medianROC<<              // median in +-5 min
+    "meanIIROC5="<<meanIIROC<<               // mean current in IROC +-5 minutes 
+    "meanIOROC5="<<meanIOROC<<               // mean current in OROC 
+    "medianIIROC5="<<medianIIROC<<           // median current in IROC 
+    "medianIOROC5="<<medianIOROC;           // medianan current in OROC 
+   
+
+  (*fPcstream)<<"current"<<     // current information
+    "time="<<itime<<
+    "isec.="<<&sector<<                       //sector number
+    "IIROC.="<<&currentIROC<<               // current sample at given moment
+    "IOROC.="<<&currentOROC<<               // current sample at given moment
+    "medianIIROC="<<medcurIROC<<            // median at given moment 
+    "medianIOROC="<<medcurOROC<<            // median at given moment
+    //
+    "minIROC.="<<&minROC<<                  // minimum in +-5 min 
+    "maxIROC.="<<&maxROC<<                  // maximum in +-5 min
+    "meanIROC.="<<&meanROC<<                // mean in +-5 min
+    "medianIROC.="<<&medianROC<<              // median in +-5 min
+    "meanIIROC5="<<meanIIROC<<               // mean current in IROC +-5 minutes 
+    "meanIOROC5="<<meanIOROC<<               // mean current in OROC 
+    "medianIIROC5="<<medianIIROC<<           // median current in IROC 
+    "medianIOROC5="<<medianIOROC<< // medianan current in OROC 
+    "\n";
+
+}