]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQACheckerBase.cxx
Updated tracklet algorithm (using phi, theta, phishift)
[u/mrichter/AliRoot.git] / STEER / AliQACheckerBase.cxx
index eda65bb1f7ad6844cab09b565721736c3c4dad11..27563e0e2a357d18e00ecfab12e38ebde9f92773 100644 (file)
@@ -23,6 +23,7 @@
 //
 
 // --- ROOT system ---
+#include <TCanvas.h>
 #include <TClass.h>
 #include <TH1F.h> 
 #include <TH1I.h> 
@@ -31,6 +32,7 @@
 #include <TFile.h> 
 #include <TList.h>
 #include <TNtupleD.h>
+#include <TPaveText.h>
 
 // --- Standard library ---
 
@@ -51,7 +53,9 @@ AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) :
   fRefSubDir(0x0), 
   fRefOCDBSubDir(0x0), 
   fLowTestValue(0x0),
-  fUpTestValue(0x0)
+  fUpTestValue(0x0),
+  fImage(new TCanvas*[AliRecoParam::kNSpecies]), 
+  fPrintImage(kTRUE)
 {
   // ctor
   fLowTestValue = new Float_t[AliQAv1::kNBIT] ; 
@@ -74,6 +78,9 @@ AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) :
                               fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ; 
     AliInfo(Form("%s", text)) ; 
   }
+  
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
+    fImage[specie] = NULL ; 
 }
 
 //____________________________________________________________________________ 
@@ -83,22 +90,25 @@ AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
   fRefSubDir(qac.fRefSubDir), 
   fRefOCDBSubDir(qac.fRefOCDBSubDir), 
   fLowTestValue(qac.fLowTestValue),
-  fUpTestValue(qac.fLowTestValue)
+  fUpTestValue(qac.fLowTestValue), 
+  fImage(NULL),  
+  fPrintImage(kTRUE)
 {
   //copy ctor
   for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
     fLowTestValue[index]  = qac.fLowTestValue[index] ; 
     fUpTestValue[index] = qac.fUpTestValue[index] ; 
   }
-    
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
+    fImage[specie] = qac.fImage[specie] ; 
 }
 
 //____________________________________________________________________________
-AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
+AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qac )
 {
   // Equal operator.
   this->~AliQACheckerBase();
-  new(this) AliQACheckerBase(qadm);
+  new(this) AliQACheckerBase(qac);
   return *this;
 }
 
@@ -107,6 +117,11 @@ AliQACheckerBase::~AliQACheckerBase()
 {
   delete [] fLowTestValue ; 
   delete [] fUpTestValue ; 
+  for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
+    if ( fImage[esIndex] ) 
+      delete fImage[esIndex] ;
+  }
+  delete[] fImage ; 
 }
 
 //____________________________________________________________________________
@@ -171,7 +186,7 @@ Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** li
 
   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
     test[specie] = 1.0 ; 
-    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) 
+    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie)) 
       continue ; 
     if (list[specie]->GetEntries() == 0)  
       test[specie] = 0. ; // nothing to check
@@ -231,8 +246,8 @@ Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
 Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
 {
   // compares two histograms using the Kolmogorov test
-  if ( hin->Integral() == 0 ) {
-    AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ; 
+  if ( hin->Integral() == 0 || href->Integral() == 0) {
+    AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s or its reference is empty", hin->GetName())) ; 
     return 0. ;
   }
     
@@ -269,6 +284,67 @@ void AliQACheckerBase::Finish() const
        AliQAv1::GetQAResultFile()->Close() ; 
 }
 
+//____________________________________________________________________________ 
+void AliQACheckerBase::MakeImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode) 
+{
+  // makes the QA image for sim and rec
+  Int_t nImages = 0 ;
+  for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
+    if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) ) 
+      continue ;
+    TIter next(list[esIndex]) ;  
+    TH1 * hdata = NULL ; 
+    while ( (hdata=static_cast<TH1 *>(next())) ) {
+      TString cln(hdata->ClassName()) ; 
+      if ( ! cln.Contains("TH1") )
+        continue ; 
+      if ( hdata->TestBit(AliQAv1::GetImageBit()) )
+        nImages++; 
+    }
+    break ; 
+  }
+  if ( nImages == 0 ) {
+    AliDebug(AliQAv1::GetQADebugLevel(), Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ;  
+  } else {
+    AliDebug(AliQAv1::GetQADebugLevel(), Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ;  
+    for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
+      if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) ) 
+        continue ;
+      const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ; 
+      if ( !fImage[esIndex] ) {
+        fImage[esIndex] = new TCanvas(title, title) ;
+      }
+      fImage[esIndex]->Clear() ; 
+      fImage[esIndex]->SetTitle(title) ; 
+      fImage[esIndex]->cd() ; 
+      TPaveText someText(0.015, 0.015, 0.98, 0.98) ;
+      someText.AddText(title) ;
+      someText.Draw() ; 
+      fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat())) ; 
+      fImage[esIndex]->Clear() ; 
+      Int_t nx = TMath::Sqrt(nImages) ; 
+      Int_t ny = nx  ; 
+      if ( nx < TMath::Sqrt(nImages)) 
+        ny++ ; 
+      fImage[esIndex]->Divide(nx, ny) ; 
+      TIter nexthist(list[esIndex]) ; 
+      TH1* hist = NULL ;
+      Int_t npad = 1 ; 
+      fImage[esIndex]->cd(npad) ; 
+      while ( (hist=static_cast<TH1*>(nexthist())) ) {
+        TString cln(hist->ClassName()) ; 
+        if ( ! cln.Contains("TH1") )
+          continue ; 
+        if(hist->TestBit(AliQAv1::GetImageBit())) {
+          hist->Draw() ; 
+          fImage[esIndex]->cd(++npad) ; 
+        }
+      }
+      fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat())) ; 
+    }
+  }  
+}
+
 //____________________________________________________________________________
 void AliQACheckerBase::SetHiLo(Float_t * hiValue, Float_t * lowValue) 
 {