]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQADataMakerSim.cxx
correct for omission
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSim.cxx
index c8c7a89736dd05b77c067d2d72eed0e029e1d342..503be71a80a204f8b00112927c6bbd659f97b18a 100644 (file)
@@ -24,7 +24,6 @@
 //
 
 // --- ROOT system ---
-#include <TCanvas.h>
 #include <TFile.h>
 #include <TTree.h>
 #include <TClonesArray.h>
@@ -40,9 +39,11 @@ ClassImp(AliQADataMakerSim)
 //____________________________________________________________________________ 
 AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) : 
   AliQADataMaker(name, title), 
-  fDigitsQAList(0x0), 
-  fHitsQAList(0x0),
-  fSDigitsQAList(0x0)
+  fDigitsQAList(NULL), 
+  fHitsQAList(NULL),
+  fSDigitsQAList(NULL),  
+  fHitsArray(NULL),
+  fSDigitsArray(NULL)
 {
        // ctor
        fDetectorDirName = GetName() ; 
@@ -53,7 +54,9 @@ AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
   AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
   fDigitsQAList(qadm.fDigitsQAList),
   fHitsQAList(qadm.fHitsQAList),
-  fSDigitsQAList(qadm.fSDigitsQAList) 
+  fSDigitsQAList(qadm.fSDigitsQAList),  
+  fHitsArray(NULL),
+  fSDigitsArray(NULL)
 {
   //copy ctor
   fDetectorDirName = GetName() ; 
@@ -65,25 +68,30 @@ AliQADataMakerSim::~AliQADataMakerSim()
        //dtor: delete the TObjArray and thei content
        if ( fDigitsQAList ) { 
     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-      if ( fDigitsQAList[specie]->IsOwner() )
                        fDigitsQAList[specie]->Delete() ;
     }
-               delete[] fDigitsQAList ;     
-       }
+               delete[] fDigitsQAList ;
+  }
        if ( fHitsQAList ) {
     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-      if ( fHitsQAList[specie]->IsOwner() ) 
                        fHitsQAList[specie]->Delete() ;
     }
-               delete[] fHitsQAList ;
-       }
+       delete[] fHitsQAList ;
+  }
        if ( fSDigitsQAList ) { 
     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-      if ( fSDigitsQAList[specie]->IsOwner() ) 
                        fSDigitsQAList[specie]->Delete() ; 
     }
-               delete[] fSDigitsQAList ; 
-       }
+               delete[] fSDigitsQAList ;
+  }
+  if (fHitsArray) {
+    fHitsArray->Clear() ; 
+    delete fHitsArray ;
+  }
+  if (fSDigitsArray) {
+    fSDigitsArray->Clear() ; 
+    delete fSDigitsArray ;
+  }  
 }
 
 //__________________________________________________________________
@@ -121,161 +129,81 @@ void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task)
   if ( ! list ) 
     return ; 
        EndOfDetectorCycle(task, list) ; 
-  TDirectory * subDir = NULL ;
-       if (fDetectorDir) 
-    subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
-       if (subDir) { 
-               subDir->cd() ; 
-    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+  fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
+       if (!fDetectorDir) 
+    fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
+  TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
+  if (!subDir)
+    subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;  
+  subDir->cd() ; 
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+    if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) ) 
+      continue ;
+    if (list[specie]->GetEntries() != 0 ) {
       TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
-      if (eventSpecieDir) {
-        eventSpecieDir->cd() ; 
-        TIter next(list[specie]) ; 
-        TObject * obj ; 
-        while ( (obj = next()) )  {
+      if (!eventSpecieDir) 
+        eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ; 
+      eventSpecieDir->cd() ; 
+      TIter next(list[specie]) ; 
+      TObject * obj ; 
+      while ( (obj = next()) )  {
+        if (!obj->TestBit(AliQAv1::GetExpertBit()))
+          obj->Write() ;
+      }
+      if (WriteExpert()) {
+        TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
+        if (!expertDir) 
+          expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; 
+        expertDir->cd() ;
+        next.Reset() ; 
+        while ( (obj = next()) ) {
           if (!obj->TestBit(AliQAv1::GetExpertBit()))
-            obj->Write() ;
-        }
-        if (WriteExpert()) {
-          TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
-          if ( expertDir ) {
-            expertDir->cd() ;
-            next.Reset() ; 
-            while ( (obj = next()) ) {
-              if (!obj->TestBit(AliQAv1::GetExpertBit()))
-                continue ; 
-            obj->Write() ;
-            }      
-          }
-        }
+            continue ; 
+          obj->Write() ;
+        }      
       }
     }
     fOutput->Save() ; 
   }
-  MakeImage(task) ; 
 }
+
 //____________________________________________________________________________
 void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data) 
 { 
   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
-    
+  
        if ( task == AliQAv1::kHITS ) {  
-               AliDebug(1, "Processing Hits QA") ; 
-               TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
-               if (arr) { 
-                       MakeHits(arr) ;
-               } else {
-                       TTree * tree = dynamic_cast<TTree *>(data) ; 
-                       if (tree) {
-                               MakeHits(tree) ; 
-                       } else {
-                               AliWarning("data are neither a TClonesArray nor a TTree") ; 
-                       }
-               }
+               AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ; 
+               if (strcmp(data->ClassName(), "TClonesArray") == 0) { 
+      fHitsArray = static_cast<TClonesArray *>(data) ; 
+                       MakeHits() ;
+               } else if (strcmp(data->ClassName(), "TTree") == 0) {
+                       TTree * tree = static_cast<TTree *>(data) ; 
+      MakeHits(tree) ; 
+    } else {
+      AliWarning("data are neither a TClonesArray nor a TTree") ; 
+    }
        } else if ( task == AliQAv1::kSDIGITS ) {
-               AliDebug(1, "Processing SDigits QA") ; 
-               TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
-               if (arr) { 
-                       MakeSDigits(arr) ;
-               } else {
-                       TTree * tree = dynamic_cast<TTree *>(data) ; 
-                       if (tree) {
-                               MakeSDigits(tree) ; 
-                       } else {
-                               AliWarning("data are neither a TClonesArray nor a TTree") ; 
-                       }
-               }
-       } else if ( task == AliQAv1::kDIGITS ) {
-               AliDebug(1, "Processing Digits QA") ; 
-               TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
-               if (arr) { 
-                       MakeDigits(arr) ;
-               } else {
-                       TTree * tree = dynamic_cast<TTree *>(data) ; 
-                       if (tree) {
-                               MakeDigits(tree) ; 
-                       } else {
-                               AliWarning("data are neither a TClonesArray nor a TTree") ; 
-                       }
-               }
-       }
-}
-
-//____________________________________________________________________________ 
-void AliQADataMakerSim::MakeImage(AliQAv1::TASKINDEX_t task)
-{
-  // create a drawing of detetor defined histograms
-  TObjArray ** list = NULL ;  
-  switch (task) {
-    case AliQAv1::kRAWS:
-      break;
-    case AliQAv1::kHITS:
-      list = fHitsQAList ;
-      break;
-    case AliQAv1::kSDIGITS:
-      list = fSDigitsQAList ;
-      break;  
-    case AliQAv1::kDIGITS:
-      list = fDigitsQAList ;
-      break;  
-    case AliQAv1::kRECPOINTS:
-      break;
-    case AliQAv1::kTRACKSEGMENTS:
-      break;
-    case AliQAv1::kRECPARTICLES:
-      break;
-    case AliQAv1::kESDS:
-      break;
-    case AliQAv1::kNTASKINDEX:
-      break;
-    default:
-    break;
-  }
-  if ( !list) {
-    AliFatal("data not initialized, call AliQADataMaker::Init"); 
-  return ; 
-  }
-  TIter next(list[0]) ;  
-  TH1 * hdata = NULL ; 
-  Int_t nImages = 0 ;
-  while ( (hdata=dynamic_cast<TH1 *>(next())) ) {
-    if ( hdata->TestBit(AliQAv1::GetImageBit()) )
-      nImages++; 
-  }
-  if ( nImages == 0 ) {
-    AliInfo(Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ;  
-  } else {
-    AliInfo(Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ;  
-    Double_t w  = 1000 ;
-    Double_t h  = 1000 ;
-    for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
-      TCanvas * canvasQA = new TCanvas(Form("QA_%s_%s_%s", 
-                                            GetName(), 
-                                            AliQAv1::GetTaskName(task).Data(), 
-                                            AliRecoParam::GetEventSpecieName(esIndex)), 
-                                       Form("QA control plots for det=%s task=%s eventspecie=%s", 
-                                            GetName(), 
-                                            AliQAv1::GetTaskName(task).Data(), 
-                                            AliRecoParam::GetEventSpecieName(esIndex)), 
-                                       w, h) ;
-      canvasQA->SetWindowSize(w + (w - canvasQA->GetWw()), h + (h - canvasQA->GetWh())) ;
-      Int_t nx = TMath::Sqrt(nImages) ; 
-      Int_t ny = nx  ; 
-      if ( nx < TMath::Sqrt(nImages)) 
-        ny++ ; 
-      canvasQA->Divide(nx, ny) ; 
-      TIter nexthist(list[esIndex]) ; 
-      TH1* hist = NULL ;
-      Int_t npad = 1 ; 
-      canvasQA->cd(npad) ; 
-      while ( (hist=dynamic_cast<TH1*>(nexthist())) ) {
-        if(hist->TestBit(AliQAv1::GetImageBit())) {
-          hist->Draw() ; 
-          canvasQA->cd(++npad) ; 
-        }
-      }
-      canvasQA->Print() ; 
+               AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ; 
+               if (strcmp(data->ClassName(), "TClonesArray") == 0) { 
+      fSDigitsArray = static_cast<TClonesArray *>(data) ; 
+                       MakeSDigits() ;
+               } else if (strcmp(data->ClassName(), "TTree") == 0) {
+                       TTree * tree = static_cast<TTree *>(data) ; 
+      MakeSDigits(tree) ; 
+    } else {
+      AliWarning("data are neither a TClonesArray nor a TTree") ; 
+    }
+       } else if ( task == AliQAv1::kDIGITS ) {
+               AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ; 
+               if (strcmp(data->ClassName(), "TClonesArray") == 0) { 
+      fDigitsArray = static_cast<TClonesArray *>(data) ; 
+                       MakeDigits() ;
+               } else if (strcmp(data->ClassName(), "TTree") == 0)  {
+                       TTree * tree = static_cast<TTree *>(data) ; 
+      MakeDigits(tree) ; 
+    } else {
+      AliWarning("data are neither a TClonesArray nor a TTree") ; 
     }
   }
 }
@@ -292,36 +220,33 @@ TObjArray **  AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
                if ( ! fHitsQAList ) {
       fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-        fHitsQAList[specie] = new TObjArray(100) ;      
+        fHitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;   
         fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
       }
-                       InitHits() ;
                }
                rv = fHitsQAList ;
        } else if ( task == AliQAv1::kSDIGITS ) {
                if ( ! fSDigitsQAList ) {
       fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-        fSDigitsQAList[specie] = new TObjArray(100) ; 
+        fSDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ; 
         fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; 
       }
-      InitSDigits() ;
                }
                rv = fSDigitsQAList ;
    } else if ( task == AliQAv1::kDIGITS ) {
           if ( ! fDigitsQAList ) {
        fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
        for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {    
-         fDigitsQAList[specie] = new TObjArray(100) ;
+         fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
          fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
        }
-                  InitDigits() ;
           }
           rv =  fDigitsQAList ;
    }
   
        return rv ; 
-}
+} 
 
 //____________________________________________________________________________ 
 void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
@@ -341,6 +266,35 @@ void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t
        } 
 }
 
+//____________________________________________________________________________ 
+void AliQADataMakerSim::ResetDetector(AliQAv1::TASKINDEX_t task)
+{
+    // default reset that resets all the QA objects.
+    // to be overloaded by detectors, if necessary
+  
+  TObjArray ** list = NULL ; 
+  if ( task == AliQAv1::kHITS ) {
+               list = fHitsQAList ;     
+       } else if ( task == AliQAv1::kSDIGITS ) {
+               list = fSDigitsQAList ; 
+       } else if ( task == AliQAv1::kDIGITS ) {
+               list = fDigitsQAList ; 
+       }
+    //list was not initialized, skip
+  if (!list) 
+    return ; 
+  
+  for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
+    if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
+      continue;
+    TIter next(list[spec]) ; 
+    TH1 * histo = NULL ; 
+    while ( (histo = dynamic_cast<TH1*> (next())) ) {
+      histo->Reset() ;
+    }
+  }
+}
+  
 //____________________________________________________________________________
 void AliQADataMakerSim::StartOfCycle(Int_t run) 
 { 
@@ -365,24 +319,24 @@ void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const
        fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;     
        }       
 
-       AliInfo(Form(" Run %d Cycle %d task %s file %s", 
+       AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s", 
                                 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
 
-       fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
-       if (!fDetectorDir)
-               fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
-
-       TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
-       if (!subDir)
-               subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;  
-  
-  for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
-    TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ; 
-    if (!eventSpecieDir) 
-      eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ; 
-    TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
-    if (!expertDir) 
-      expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; 
-   }   
+       //fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
+//     if (!fDetectorDir)
+//             fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
+//
+//     TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; 
+//     if (!subDir)
+//             subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;  
+//  
+//  for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
+//    TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ; 
+//    if (!eventSpecieDir) 
+//      eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ; 
+//    TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; 
+//    if (!expertDir) 
+//      expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; 
+//   }   
        StartOfDetectorCycle() ; 
 }