]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQADataMaker.cxx
Example train to produce HF candidates
[u/mrichter/AliRoot.git] / STEER / AliQADataMaker.cxx
index 56ec5800efce74bd2ae14af837867db9b4a00dc6..97e145b62b8786e534257bf347794ea0f0f902c4 100644 (file)
 #include <TList.h> 
 #include <TTree.h>
 #include <TClonesArray.h>
+#include <TParameter.h>
+#include <TH1K.h>
+#include <TH2C.h>
+#include <TH2D.h>
+#include <TH2F.h>
+#include <TH2I.h>
+#include <TH3C.h>
+#include <TH3D.h>
+#include <TH3F.h>
+#include <TH3I.h>
+#include <TH3S.h>
 
 // --- Standard library ---
 
@@ -47,13 +58,18 @@ AliQADataMaker::AliQADataMaker(const char * name, const char * title) :
   fOutput(0x0),
   fDetectorDir(0x0),
   fDetectorDirName(""), 
-  fCurrentCycle(-1), 
+  fCurrentCycle(0), 
   fCycle(9999999), 
   fCycleCounter(0), 
-  fRun(0)
+  fWriteExpert(kFALSE),
+  fParameterList(new TList*[AliRecoParam::kNSpecies]), 
+  fRun(0), 
+  fEventSpecie(AliRecoParam::kDefault)
 {
   // ctor
   fDetectorDirName = GetName() ; 
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
+    fParameterList[specie] = NULL ; 
 }
 
 //____________________________________________________________________________ 
@@ -65,51 +81,101 @@ AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
   fCurrentCycle(qadm.fCurrentCycle), 
   fCycle(qadm.fCycle), 
   fCycleCounter(qadm.fCycleCounter), 
-  fRun(qadm.fRun)
+  fWriteExpert(qadm.fWriteExpert),
+  fParameterList(qadm.fParameterList),  
+  fRun(qadm.fRun), 
+  fEventSpecie(qadm.fEventSpecie)
 {
   //copy ctor
   fDetectorDirName = GetName() ; 
 }
 
 //____________________________________________________________________________
-Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray * list
+Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray ** list, const Bool_t expert, const Bool_t saveForCorr
 { 
        // Set histograms memory resident and add to the list
        // Maximm allowed is 10000
-       if ( index > 10000 ) {
+  
+  Int_t rv = -1 ; 
+  TClass * classType = hist->Class() ;
+  TString className(classType->GetName()) ; 
+  if( ! className.BeginsWith("T") && ! classType->InheritsFrom("TH1") ) {
+    AliError(Form("QA data Object must be a generic ROOT object and derive fom TH1 and not %s", className.Data())) ; 
+       } else if ( index > 10000 ) {
                AliError("Max number of authorized QA objects is 10000") ; 
-               return -1 ; 
-       } else {
-               hist->SetDirectory(0) ; 
-               list->AddAtAndExpand(hist, index) ; 
-               return list->GetLast() ;
-       }
+  } else {    
+    if (expert) 
+      hist->SetBit(AliQA::GetExpertBit()) ; 
+               TH1 * histClone[AliRecoParam::kNSpecies] ; 
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      histClone[specie] = CloneMe(hist, specie) ; 
+      histClone[specie]->SetDirectory(0) ; 
+      list[specie]->AddAtAndExpand(histClone[specie], index) ; 
+      if(saveForCorr) {  
+        char * name = Form("%s_%s", list[AliRecoParam::kDefault]->GetName(), hist->GetName()) ;  
+        TParameter<double> * p = new TParameter<double>(name, 9999.9999) ;
+        if ( fParameterList[specie] == NULL )
+          fParameterList[specie] = new TList() ; 
+        fParameterList[specie]->Add(p) ;
+      }
+    }
+    rv = list[AliRecoParam::kDefault]->GetLast() ;
+  }
+  delete hist ; 
+  return rv ; 
+}
+
+//____________________________________________________________________________
+TH1 *  AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const  
+{
+  // clones a histogram 
+  char * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ;
+  TH1 * hClone = dynamic_cast<TH1 *>(hist->Clone(name)) ; 
+  if ( hist->TestBit(AliQA::GetExpertBit()) )
+       hClone->SetBit(AliQA::GetExpertBit()) ; 
+  return hClone ; 
+}
+
+//____________________________________________________________________________
+void AliQADataMaker::DefaultEndOfDetectorCycle(AliQA::TASKINDEX_t task) 
+{
+       // this method must be oveloaded by detectors
+       // sets the QA result to Fatal
+       AliQA::Instance(AliQA::GetDetIndex(GetName())) ;
+       AliQA * qa = AliQA::Instance(task) ;
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
+    qa->Set(AliQA::kFATAL, specie) ; 
+       AliQA::GetQAResultFile()->cd() ; 
+       qa->Write(AliQA::GetQAName(), kWriteDelete) ;   
+       AliQA::GetQAResultFile()->Close() ; 
 }
 
 //____________________________________________________________________________ 
 void AliQADataMaker::Finish() const 
 { 
-  // write to the output File
-  fOutput->Close() ; 
+       // write to the output File
+       if (fOutput) 
+               fOutput->Close() ; 
 } 
 
 //____________________________________________________________________________ 
-TObject * AliQADataMaker::GetData(TObjArray * list, const Int_t index)  
+TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index)  
 { 
        // Returns the QA object at index. Limit is 100. 
-       if ( index > 10000 ) {
-               AliError("Max number of authorized QA objects is 10000") ; 
-               return NULL; 
-       } else {
-               return list->At(index) ; 
+  if ( ! list ) {
+               AliError("Data list is NULL !!") ; 
+               return NULL ;           
        }
-} 
-
-//____________________________________________________________________________
-void AliQADataMaker::Reset(const Bool_t sameCycle) 
-{ 
-  // Resets defaut value of data members 
-       if (!sameCycle) {
-               fCycleCounter = 0 ; 
+       if (list[AliRecoParam::AConvert(fEventSpecie)]) {
+               if ( index > 10000 ) {
+                       AliError("Max number of authorized QA objects is 10000") ; 
+                       return NULL ; 
+               } else {
+      Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ; 
+      return list[esindex]->At(index) ; 
+               }       
+  } else {
+               AliError("Data list is NULL !!") ; 
+               return NULL ;           
        }
 }