]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQADataMakerRec.cxx
Introducing event specie in QA (Yves)
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerRec.cxx
index 3f04aeb74644dad7c884b21b747f7bd4908017b8..0a0dafbe5026d0ec9c808ce15174d6d17a79f17f 100644 (file)
@@ -7,7 +7,7 @@
  * Permission to use, copy, modify and distribute this software and its   *
  * documentation strictly for non-commercial purposes is hereby granted   *
  * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
+ * copies and that both the copyright notice and this permission notifce   *
  * appear in the supporting documentation. The authors make no claims     *
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
@@ -26,6 +26,7 @@
 // --- ROOT system ---
 #include <TFile.h>
 #include <TTree.h>
+#include <TNtupleD.h>
 
 // --- Standard library ---
 
@@ -40,9 +41,11 @@ ClassImp(AliQADataMakerRec)
 //____________________________________________________________________________ 
 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) : 
   AliQADataMaker(name, title), 
-  fESDsQAList(0x0), 
-  fRawsQAList(0x0), 
-  fRecPointsQAList(0x0)
+  fESDsQAList(NULL), 
+  fRawsQAList(NULL), 
+  fRecPointsQAList(NULL),
+  fCorrNt(NULL), 
+  fRecoParam(NULL) 
 {
   // ctor
        fDetectorDirName = GetName() ; 
@@ -50,11 +53,12 @@ AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
 
 //____________________________________________________________________________ 
 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
-    AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
-    fESDsQAList(qadm.fESDsQAList),
-       fRawsQAList(qadm.fRawsQAList),
-       fRecPointsQAList(qadm.fRecPointsQAList)
-  
+  AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
+  fESDsQAList(qadm.fESDsQAList),
+  fRawsQAList(qadm.fRawsQAList),
+  fRecPointsQAList(qadm.fRecPointsQAList),
+  fCorrNt(qadm.fCorrNt),  
+  fRecoParam(qadm.fRecoParam) 
 {
   //copy ctor
        SetName(qadm.GetName()) ; 
@@ -62,6 +66,39 @@ AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
        fDetectorDirName = GetName() ; 
 }
 
+//____________________________________________________________________________ 
+AliQADataMakerRec::~AliQADataMakerRec()
+{
+       //dtor: delete the TObjArray and thei content
+       if ( fESDsQAList ) {
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      if ( fESDsQAList[specie] ) {
+        if ( fESDsQAList[specie]->IsOwner() ) 
+          fESDsQAList[specie]->Delete() ;     
+      }
+    }
+    delete[] fESDsQAList ;
+       }
+       if ( fRawsQAList ) {
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      if ( fRawsQAList[specie] ) {
+        if ( fRawsQAList[specie]->IsOwner() ) 
+          fRawsQAList[specie]->Delete() ;
+      }
+    }
+    delete[] fRawsQAList ;
+  }
+       if ( fRecPointsQAList ) {
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      if ( fRecPointsQAList[specie] ) {
+        if ( fRecPointsQAList[specie]->IsOwner() ) 
+          fRecPointsQAList[specie]->Delete() ;
+      }
+    }
+               delete[] fRecPointsQAList ; 
+       }
+}
+
 //__________________________________________________________________
 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
 {
@@ -72,11 +109,21 @@ AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm
 }
 
 //____________________________________________________________________________
-void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX task
+void AliQADataMakerRec::EndOfCycle() 
 {
-       // Finishes a cycle of QA data acquistion
+  // Finishes a cycle of QA for all the tasks
+  EndOfCycle(AliQA::kRAWS) ; 
+  EndOfCycle(AliQA::kRECPOINTS) ; 
+  EndOfCycle(AliQA::kESDS) ; 
+  ResetCycle() ; 
+}
+
+//____________________________________________________________________________
+void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX_t task) 
+{
+       // Finishes a cycle of QA 
        
-       TObjArray * list = 0x0 ; 
+       TObjArray ** list = NULL ; 
        
        if ( task == AliQA::kRAWS )     
                list = fRawsQAList ; 
@@ -84,17 +131,55 @@ void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX task)
                list = fRecPointsQAList ; 
        else if ( task == AliQA::kESDS )
                list = fESDsQAList ; 
-       
+
+       if ( ! list && ! fCorrNt ) 
+    return ; 
+  //DefaultEndOfDetectorCycle(task) ;
        EndOfDetectorCycle(task, list) ;
-       TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
+       TDirectory * subDir = NULL ;
+       if (fDetectorDir) 
+               subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
        if ( subDir ) {
                subDir->cd() ; 
-               list->Write() ;
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
+      if (eventSpecieDir) {
+        eventSpecieDir->cd() ;    
+        if (list[specie]) {
+          TIter next(list[specie]) ; 
+          TObject * obj ; 
+          while( (obj = next()) ) {
+            if (!obj->TestBit(AliQA::GetExpertBit()))
+              obj->Write() ;
+          }
+          if (WriteExpert()) {
+            TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ; 
+            if ( expertDir ) { // Write only if requested
+              expertDir->cd() ;
+              next.Reset() ; 
+              while( (obj = next()) ) {
+                if (!obj->TestBit(AliQA::GetExpertBit()))
+                  continue ; 
+                obj->Write() ;
+              }      
+            }
+          }
+        }
+        if ( !fCorrNt )
+          continue ; 
+        if (fCorrNt[specie] && AliQA::GetDetIndex(GetName()) == AliQA::kCORR) {
+          eventSpecieDir->cd() ; 
+          fCorrNt[specie]->Write() ; 
+        }
+      }
+    }
+    fOutput->Save() ; 
        }
 }
  
 //____________________________________________________________________________
-void AliQADataMakerRec::Exec(AliQA::TASKINDEX task, TObject * data) 
+void AliQADataMakerRec::Exec(AliQA::TASKINDEX_t task, TObject * data) 
 { 
   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
        
@@ -104,7 +189,7 @@ void AliQADataMakerRec::Exec(AliQA::TASKINDEX task, TObject * data)
                if (rawReader) 
                        MakeRaws(rawReader) ;
                else
-               AliError("Wrong data type") ;     
+               AliInfo("Raw data are not processed") ;     
        } else if ( task == AliQA::kRECPOINTS ) {
                AliDebug(1, "Processing RecPoints QA") ; 
                TTree * tree = dynamic_cast<TTree *>(data) ; 
@@ -124,35 +209,51 @@ void AliQADataMakerRec::Exec(AliQA::TASKINDEX task, TObject * data)
 }
 
 //____________________________________________________________________________ 
-TObjArray *  AliQADataMakerRec::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
+TObjArray **  AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, Int_t cycles)
 {
   // general intialisation
-       
-       TObjArray * rv = NULL ; 
+
+       TObjArray ** rv = NULL ; 
   
-       fRun = run ;
        if (cycles > 0)
                SetCycle(cycles) ;  
        
        if ( task == AliQA::kRAWS ) {
-               fRawsQAList = new TObjArray(100) ;       
-               InitRaws() ;
+               if (! fRawsQAList ) { 
+      fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
+      for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+        fRawsQAList[specie] = new TObjArray(100) ;      
+        fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
+      }
+                       InitRaws() ;
+               }
                rv = fRawsQAList ;
        } else if ( task == AliQA::kRECPOINTS ) {
-               fRecPointsQAList = new TObjArray(100) ; 
-               InitRecPoints() ;
+               if ( ! fRecPointsQAList ) {
+      fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
+      for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+        fRecPointsQAList[specie] = new TObjArray(100) ; 
+        fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; 
+      }
+      InitRecPoints() ;
+               }
                rv = fRecPointsQAList ;
        } else if ( task == AliQA::kESDS ) {
-               fESDsQAList = new TObjArray(100) ; 
-               InitESDs() ;
+               if ( ! fESDsQAList ) {
+      fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; 
+      for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+        fESDsQAList[specie] = new TObjArray(100) ;
+        fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; 
+      }
+                       InitESDs() ;
+               }
                rv = fESDsQAList ;
        }
-       
        return rv ; 
 }
 
 //____________________________________________________________________________ 
-void AliQADataMakerRec::Init(AliQA::TASKINDEX task, TObjArray * list, Int_t run, Int_t cycles)
+void AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
 {
   // Intialisation by passing the list of QA data booked elsewhere
   
@@ -170,16 +271,29 @@ void AliQADataMakerRec::Init(AliQA::TASKINDEX task, TObjArray * list, Int_t run,
 }
 
 //____________________________________________________________________________
-void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCycle) 
+void AliQADataMakerRec::StartOfCycle(Int_t run) 
+{
+  // Finishes a cycle of QA for all the tasks
+  Bool_t samecycle = kFALSE ; 
+  StartOfCycle(AliQA::kRAWS,      run, samecycle) ;
+  samecycle = kTRUE ; 
+  StartOfCycle(AliQA::kRECPOINTS, run, samecycle) ; 
+  StartOfCycle(AliQA::kESDS,      run, samecycle) ; 
+}
+
+//____________________________________________________________________________
+void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) 
 { 
   // Finishes a cycle of QA data acquistion
+  if ( run > 0 ) 
+    fRun = run ; 
        if ( !sameCycle || fCurrentCycle == -1) {
                ResetCycle() ;
                if (fOutput) 
                        fOutput->Close() ; 
-               fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;        
+               fOutput = AliQA::GetQADataFile(GetName(), fRun) ;       
        }       
-       AliDebug(1, Form(" Run %d Cycle %d task %s file %s", 
+       AliInfo(Form(" Run %d Cycle %d task %s file %s", 
                                 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
 
        fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
@@ -189,21 +303,14 @@ void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCyc
        TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
        if (!subDir)
                subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;  
-       subDir->cd() ; 
-
-       TObjArray * list = 0x0 ; 
   
-  if ( task == AliQA::kRAWS ) 
-         list = fRawsQAList ; 
-  else if ( task == AliQA::kRECPOINTS)  
-         list = fRecPointsQAList ;
-  else if ( task == AliQA::kESDS )  
-         list = fESDsQAList ;
-
-       TIter next(list) ;
-       TH1 * h ; 
-       while ( (h = dynamic_cast<TH1 *>(next())) )
-               h->Reset() ;  
-
+  for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
+    TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ; 
+    if (!eventSpecieDir) 
+      eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ; 
+    TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ; 
+    if (!expertDir)
+      expertDir = eventSpecieDir->mkdir(AliQA::GetExpert()) ; 
+  } 
        StartOfDetectorCycle() ; 
 }