]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ESDCheck/AliTRDQATask.cxx
Memory leak corrected (Ch. Klein-Boesing)
[u/mrichter/AliRoot.git] / ESDCheck / AliTRDQATask.cxx
index 196a3149f901f848ce33b73d03c01103675b36a9..e076a0e3234648ae885b72e71871d4ba7de524ae 100644 (file)
@@ -38,6 +38,7 @@
 #include <TH2D.h>
 #include <TROOT.h>
 #include <TStyle.h>
+#include <TString.h> 
 
 #include "AliTRDQATask.h"
 #include "AliESD.h"
@@ -84,6 +85,9 @@ void AliTRDQATask::ConnectInputData(const Option_t *)
 void AliTRDQATask::CreateOutputObjects()
 {
   // create histograms 
+
+  OpenFile(0) ; 
+
   fNTracks     = new TH1D("ntracks", ";number of all tracks", 500, -0.5, 499.5); 
   fEventSize   = new TH1D("evSize", ";event size (MB)", 100, 0, 5);
 
@@ -96,19 +100,19 @@ void AliTRDQATask::CreateOutputObjects()
   fXIn  = new TH1D("xIn", ";X at the inner plane (cm)", 200, 50, 250);
   fXOut = new TH1D("xOut", ";X at the outer plane (cm)", 300, 50, 400);
   
-  const int nNameAlpha = 4;
-  const char *namesAlpha[nNameAlpha] = {"alphaTPCi", "alphaTPCo", "alphaTRDo", "alphaTRDr"};
+  const int knNameAlpha = 4;
+  const char *namesAlpha[knNameAlpha] = {"alphaTPCi", "alphaTPCo", "alphaTRDo", "alphaTRDr"};
   //TH1D *fAlpha[4];
-  for(int i=0; i<nNameAlpha; i++) {
+  for(int i=0; i<knNameAlpha; i++) {
     fAlpha[i] = new TH1D(namesAlpha[i], "alpha", 100, -4, 4);
   }
   fSectorTRD = new TH1D ("sectorTRD", ";sector TRD", 20, -0.5, 19.5);
 
 
   // track parameters
-  const int nbits = 6;
-  const char *suf[nbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
-  for(int i=0; i<nbits; i++) {
+  const int knbits = 6;
+  const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
+  for(int i=0; i<knbits; i++) {
     fPt[i]      = new TH1D(Form("pt%s",suf[i]), ";p_{T} (GeV/c);entries TPC", 50, 0, 10);
     fTheta[i]   = new TH1D(Form("theta%s", suf[i]), "theta (rad)", 100, -4, 4); 
     fSigmaY[i]  = new TH1D(Form("sigmaY%s",suf[i]),  ";sigma Y (cm)", 200, 0, 1);
@@ -184,7 +188,7 @@ void AliTRDQATask::CreateOutputObjects()
   fOutputContainer->AddAt(fAlpha[3],    counter++);
 
   fOutputContainer->AddAt(fSectorTRD,   counter++);
-  for(int i=0; i<nbits; i++) {
+  for(int i=0; i<knbits; i++) {
      fOutputContainer->AddAt(fPt[i],      counter++);
      fOutputContainer->AddAt(fTheta[i],   counter++);
      fOutputContainer->AddAt(fSigmaY[i],  counter++);
@@ -212,7 +216,7 @@ void AliTRDQATask::CreateOutputObjects()
      fOutputContainer->AddAt(fTrdSigMomPID[i], counter++);
   }
 
-  AliInfo(Form("Number of histograms = %d", counter));
+  //AliInfo(Form("Number of histograms = %d", counter));
 
  }
 
@@ -263,7 +267,7 @@ void AliTRDQATask::Exec(Option_t *)
     for(int bit=0; bit<32; bit++) 
       if (u<<bit & status) fTrackStatus->Fill(bit);
 
-    const int nbits = 6; 
+    const int knbits = 6; 
     int bit[6] = {0,0,0,0,0,0};    
     bit[0] = status & AliESDtrack::kTPCin;
     bit[1] = status & AliESDtrack::kTPCout;
@@ -277,7 +281,7 @@ void AliTRDQATask::Exec(Option_t *)
     const double *val = track->GetParameter(); // parameters at the vertex
     double pt = 1./TMath::Abs(val[4]);
 
-    for(int b=0; b<nbits; b++) {
+    for(int b=0; b<knbits; b++) {
       if (bit[b]) {
        fPt[b]->Fill(pt); 
        fTheta[b]->Fill(val[3]);
@@ -318,7 +322,7 @@ void AliTRDQATask::Exec(Option_t *)
       // fill pid histograms
       double trdr0 = 0, tpcr0 = 0;
       int trdBestPid = 5, tpcBestPid = 5;  // charged
-      const double minPidValue =  0.9;
+      const double kminPidValue =  0.9;
 
       double pp[5];
       track->GetTPCpid(pp); // ESD inconsequence
@@ -331,8 +335,8 @@ void AliTRDQATask::Exec(Option_t *)
        fTrdPID[pid]->Fill(track->GetTRDpid(pid));
        fTpcPID[pid]->Fill(pp[pid]);
        
-       if (track->GetTRDpid(pid) > minPidValue) trdBestPid = pid;
-       if (pp[pid] > minPidValue) tpcBestPid = pid;
+       if (track->GetTRDpid(pid) > kminPidValue) trdBestPid = pid;
+       if (pp[pid] > kminPidValue) tpcBestPid = pid;
       }
       
       fTrdPID[5]->Fill(trdr0); // check unitarity
@@ -352,7 +356,6 @@ void AliTRDQATask::Exec(Option_t *)
 void AliTRDQATask::Terminate(Option_t *)
 {
   // Processing when the event loop is ended
-  AliInfo("TRD QA module");
   fOutputContainer = (TObjArray*)GetOutputData(0);
   int counter = 0;
   fNTracks     = (TH1D*)fOutputContainer->At(counter++);
@@ -369,8 +372,8 @@ void AliTRDQATask::Terminate(Option_t *)
   fAlpha[3]    = (TH1D*)fOutputContainer->At(counter++);
 
   fSectorTRD   = (TH1D*)fOutputContainer->At(counter++);
-  const int nbits = 6;
-  for(int i=0; i<nbits; i++) {
+  const int knbits = 6;
+  for(int i=0; i<knbits; i++) {
      fPt[i]      = (TH1D*)fOutputContainer->At(counter++);
      fTheta[i]   = (TH1D*)fOutputContainer->At(counter++);
      fSigmaY[i]  = (TH1D*)fOutputContainer->At(counter++);
@@ -399,18 +402,34 @@ void AliTRDQATask::Terminate(Option_t *)
   }
 
   // create efficiency histograms
+  Bool_t problem = kFALSE ; 
+  AliInfo(Form(" *** %s Report:", GetName())) ; 
   
   CalculateEff();
-//  PostData(0, fOutputContainer);
 
   DrawESD() ; 
   DrawGeoESD() ; 
   //DrawConvESD() ; 
   DrawPidESD() ; 
+
+  char line[1024] ; 
+  sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
+  gROOT->ProcessLine(line);
+  
+  AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
+
+  TString report ; 
+  if(problem)
+    report="Problems found, please check!!!";  
+  else 
+    report="OK";
+
+  AliInfo(Form("*** %s Summary Report: %s\n",GetName(), report.Data())) ; 
+
 }
 
 //______________________________________________________________________________
-int AliTRDQATask::GetSector(double alpha) 
+const int AliTRDQATask::GetSector(const double alpha) const
 {
   // Gets the sector number 
 
@@ -420,13 +439,13 @@ int AliTRDQATask::GetSector(double alpha)
 }
 
 //______________________________________________________________________________
-int AliTRDQATask::CheckSector(int sector) 
+const int AliTRDQATask::CheckSector(const int sector) const  
 {  
   // Checks the sector number
-  const int nSec = 8;
+  const int knSec = 8;
   int sec[] = {2,3,5,6,11,12,13,15};
   
-  for(int i=0; i<nSec; i++) 
+  for(int i=0; i<knSec; i++) 
     if (sector == sec[i]) return 1;
   
   return 0;
@@ -453,12 +472,10 @@ void AliTRDQATask::CalculateEff()
 }
 
 //______________________________________________________________________________
-void AliTRDQATask::DrawESD() 
+void AliTRDQATask::DrawESD() const 
 {
   // Makes a few plots
 
-  AliInfo("Plotting....") ; 
-  
   TCanvas * cTRD = new TCanvas("cTRD", "TRD ESD Test", 400, 10, 600, 700) ;
   cTRD->Divide(6,3) ;
 
@@ -474,10 +491,10 @@ void AliTRDQATask::DrawESD()
 
   // draw all 
   
-  const int nplots = 18;
-  const int nover[nplots] = {1,1,1,4,1,1,1,1,1,1,2,1,1,3,1,1,1,1};
-  const int nnames = 24;
-  const char *names[nnames] = {
+  const int knplots = 18;
+  const int knover[knplots] = {1,1,1,4,1,1,1,1,1,1,2,1,1,3,1,1,1,1};
+  const int knnames = 24;
+  const char *names[knnames] = {
     "ntracks", "kinkIndex", "trackStatus", 
     "ptTPCi", "ptTPCo", "ptTRDo", "ptTRDr",  "ptTPCz", "ptTRDz",
     "eff_TPCi_TPCo",  "eff_TPCo_TRDo", "eff_TRDo_TRDr",  "eff_TPCo_TRDr",
@@ -486,7 +503,7 @@ void AliTRDQATask::DrawESD()
     "time", "budget", "signal"
   };
   
-  const int logy[nnames] = {
+  const int klogy[knnames] = {
     1,1,1,
     1,1,1,
     0,0,0,0,
@@ -496,16 +513,16 @@ void AliTRDQATask::DrawESD()
   };
 
   int nhist=0;
-  for(int i=0; i<nplots; i++) {
+  for(int i=0; i<knplots; i++) {
   cTRD->cd(i+1) ;
   
   //  new TCanvas(names[i], names[nhist], 500, 300);
-    gPad->SetLogy(logy[i]);
       
-    for(int j=0; j<nover[i]; j++) {
+    for(int j=0; j<knover[i]; j++) {
       TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[nhist++]));
       if (!hist) continue;
-      
+      if (hist->GetMaximum() > 0 ) 
+       gPad->SetLogy(klogy[i]);
       if (strstr(hist->GetName(), "eff")) {
        hist->SetMarkerStyle(20);
        hist->SetMinimum(0);
@@ -516,16 +533,14 @@ void AliTRDQATask::DrawESD()
       else hist->Draw("SAME");
     }
   }
-  cTRD->Print("TRD_ESD.gif");
+  cTRD->Print("TRD_ESD.eps");
 }
 
 //______________________________________________________________________________
-void AliTRDQATask::DrawGeoESD() 
+void AliTRDQATask::DrawGeoESD() const
 {
   // Makes a few plots
 
-  AliInfo("Plotting....") ; 
-
   TCanvas * cTRDGeo = new TCanvas("cTRDGeo", "TRD ESDGeo Test", 400, 10, 600, 700) ;
   cTRDGeo->Divide(4,2) ;
 
@@ -539,23 +554,23 @@ void AliTRDQATask::DrawGeoESD()
   gStyle->SetTitleBorderSize(0);
   
   // draw all   
-  const int nnames = 7;
-  const char *names[nnames] = {
+  const int knnames = 7;
+  const char *names[knnames] = {
     "xIn", "xOut",
     "planeYZTPCo", "planeYZTPCz", "planeYZTRDo", "planeYZTRDr", "planeYZTRDz",
   };
   
-  const char *opt[nnames] = {
+  const char *opt[knnames] = {
     "", "",
     "colz","colz", "colz", "colz", "colz"
   };
   
-  const int logy[nnames] = {
+  const int klogy[knnames] = {
     1,1,
     0,0,0,0,0
   };
   
-  for(int i=0; i<nnames; i++) {
+  for(int i=0; i<knnames; i++) {
   cTRDGeo->cd(i+1) ;
     TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[i]));
     if (!hist) continue;
@@ -563,18 +578,19 @@ void AliTRDQATask::DrawGeoESD()
     //if (i<2) new TCanvas(names[i], names[i], 500, 300);
     //else new TCanvas(names[i], names[i], 300, 900);
    
-    gPad->SetLogy(logy[i]);
+    if (hist->GetMaximum() > 0 ) 
+      gPad->SetLogy(klogy[i]);
     if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
     
     hist->Draw(opt[i]);    
     AliInfo(Form("%s\t%d", names[i], hist->GetEntries()));
   }
   
-  cTRDGeo->Print("TRD_Geo.gif");
+  cTRDGeo->Print("TRD_Geo.eps");
 }
 
 //______________________________________________________________________________
-void AliTRDQATask::DrawConvESD() 
+void AliTRDQATask::DrawConvESD() const
 {
   // Makes a few plots
 
@@ -592,32 +608,33 @@ void AliTRDQATask::DrawConvESD()
   gStyle->SetTitleFont(62, "XYZ");
   gStyle->SetPadRightMargin(0.02);
 
-  const int nnames = 9;
-  const int nplots = 5;
-  const int nover[nplots] = {3,1,1,3,1}; 
+  const int knnames = 9;
+  const int knplots = 5;
+  const int knover[knplots] = {3,1,1,3,1}; 
   
-  const char *names[nnames] = {
+  const char *names[knnames] = {
     "sigmaYTPCo","sigmaYTRDo", "sigmaYTRDr", "sigmaYTPCz", "sigmaYTRDz",
     "Chi2TPCo", "Chi2TRDo", "Chi2TRDr", "Chi2TRDz"
   };
   
-  const char *opt[nplots] = {
+  const char *opt[knplots] = {
     "", "", "","","",
   };
   
-  const int logy[nplots] = {
+  const int klogy[knplots] = {
     0,0,0,1,1
   };
 
   int nhist = 0;
-  for(int i=0; i<nplots; i++) {
+  for(int i=0; i<knplots; i++) {
     cTRDConv->cd(i+1) ;
     //new TCanvas(names[i], names[i], 500, 300);
-    gPad->SetLogy(logy[i]);
     if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
    
-    for(int j=0; j<nover[i]; j++) {
+    for(int j=0; j<knover[i]; j++) {
       TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[nhist++]));
+      if ( hist->GetMaximum() > 0 ) 
+       gPad->SetLogy(klogy[i]);
       if (!j) hist->Draw(opt[i]);
       else hist->Draw("same");
     }
@@ -627,11 +644,10 @@ void AliTRDQATask::DrawConvESD()
 }
 
 //______________________________________________________________________________
-void AliTRDQATask::DrawPidESD() 
+void AliTRDQATask::DrawPidESD() const
 {
   // Makes a few plots
 
-  AliInfo("Plotting....") ; 
   TCanvas * cTRDPid = new TCanvas("cTRDPid", "TRD ESDPid Test", 400, 10, 600, 700) ;
   cTRDPid->Divide(9,3) ;
 
@@ -650,8 +666,8 @@ void AliTRDQATask::DrawPidESD()
 
   // draw all 
  
-  const int nnames = 27;
-  const char *names[nnames] = {
+  const int knnames = 27;
+  const char *names[knnames] = {
 
     "signal", "trdSigMom", "tpcSigMom",
 
@@ -663,7 +679,7 @@ void AliTRDQATask::DrawPidESD()
 
   };
   
-  const char *opt[nnames] = {
+  const char *opt[knnames] = {
 
     "", "colz", "colz",
 
@@ -674,7 +690,7 @@ void AliTRDQATask::DrawPidESD()
     "colz", "colz", "colz", "colz", "colz", "colz" 
   };
   
-  const int logy[nnames] = {
+  const int klogy[knnames] = {
 
     0,0,0,
 
@@ -685,14 +701,15 @@ void AliTRDQATask::DrawPidESD()
     0,0,0,0,0,0    
   };
 
-  for(int i=0; i<nnames; i++) {
+  for(int i=0; i<knnames; i++) {
     cTRDPid->cd(i+1) ;
 
     TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[i]));
     if (!hist) continue;
     
     //new TCanvas(names[i], names[i], 500, 300);
-    gPad->SetLogy(logy[i]);
+    if ( hist->GetMaximum() > 0  ) 
+      gPad->SetLogy(klogy[i]);
     if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
     
     if (strstr(names[i],"sigMom")) gPad->SetLogz(1);
@@ -701,5 +718,5 @@ void AliTRDQATask::DrawPidESD()
     hist->Draw(opt[i]);    
     AliInfo(Form("%s\t%d", names[i], hist->GetEntries()));
   }
-   cTRDPid->Print("TRD_Pid.gif");
+   cTRDPid->Print("TRD_Pid.eps");
 }