New steering class ro run QA stand alone
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 17:40:55 +0000 (17:40 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 17:40:55 +0000 (17:40 +0000)
STEER/AliQADataMaker.cxx
STEER/AliQADataMaker.h
STEER/AliQADataMakerSteer.cxx [new file with mode: 0644]
STEER/AliQADataMakerSteer.h [new file with mode: 0644]
STEER/STEERLinkDef.h
STEER/libSTEER.pkg

index 6546a0f..4c09c1e 100644 (file)
 #include "AliRawReader.h"
 
 ClassImp(AliQADataMaker)
-  
-TString AliQADataMaker::fDetectorDirName("") ;
-
-           
+             
 //____________________________________________________________________________ 
 AliQADataMaker::AliQADataMaker(const char * name, const char * title) : 
   TNamed(name, title), 
   fOutput(0x0),
   fDetectorDir(0x0),
+  fDetectorDirName(""), 
   fDigitsQAList(0x0), 
   fESDsQAList(0x0), 
   fHitsQAList(0x0),
@@ -69,6 +67,7 @@ AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
   TNamed(qadm.GetName(), qadm.GetTitle()),
   fOutput(qadm.fOutput),
   fDetectorDir(qadm.fDetectorDir),
+  fDetectorDirName(qadm.fDetectorDirName),
   fDigitsQAList(qadm.fDigitsQAList),
   fESDsQAList(qadm.fESDsQAList),
   fHitsQAList(qadm.fHitsQAList),
@@ -84,16 +83,10 @@ AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
   fDetectorDirName = GetName() ; 
 }
 
-//____________________________________________________________________________ 
-AliQADataMaker::~AliQADataMaker() 
-{
-// dtor
-} 
-
 //__________________________________________________________________
 AliQADataMaker& AliQADataMaker::operator = (const AliQADataMaker& qadm )
 {
-  // Equal operator.
+  // Assignment operator.
   this->~AliQADataMaker();
   new(this) AliQADataMaker(qadm);
   return *this;
@@ -150,86 +143,96 @@ void AliQADataMaker::Exec(AliQA::TASKINDEX task, TObject * data)
 { 
   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
     
-  switch (task) { 
+       switch (task) { 
   
-  case AliQA::kRAWS:
-  {
-    AliInfo("Processing Raws QA") ; 
-       AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
-    if (rawReader) 
-         MakeRaws(rawReader) ;
-        else
-         AliError("Wrong data type") ;     
-    break ; 
-  }
-  case AliQA::kHITS:
-  {  
-       AliInfo("Processing Hits QA") ; 
-       TClonesArray * hits = dynamic_cast<TClonesArray *>(data) ; 
-    if (hits) 
-     MakeHits(hits) ;
-       else 
-     AliError("Wrong type of hits container") ;
-    break ; 
-  }
-  case AliQA::kSDIGITS:
-  {
-    AliInfo("Processing SDigits QA") ; 
-    TClonesArray * sdigits = dynamic_cast<TClonesArray *>(data) ; 
-       if (sdigits) 
-      MakeSDigits(sdigits) ;
-        else    
-      AliError("Wrong type of sdigits container") ; 
-    break ; 
-  }  
-  case AliQA::kDIGITS:
-  {
-    TClonesArray * digits = dynamic_cast<TClonesArray *>(data) ; 
-    if (digits) 
-         MakeDigits(digits) ;
-        else 
-      AliError("Wrong type of digits container") ; 
-    break ;  
-  }
-  case AliQA::kRECPOINTS:
-  {
-     AliInfo("Processing RecPoints QA") ; 
-     TTree * recpoints = dynamic_cast<TTree *>(data) ; 
-    if (recpoints) 
-      MakeRecPoints(recpoints) ;
-    else 
-      AliError("Wrong type of recpoints container") ; 
-    break ;  
-  }
-   case AliQA::kTRACKSEGMENTS:
-    AliInfo("Processing Track Segments QA: not existing anymore") ; 
-//     TTree * ts = dynamic_cast<TTree *>(data) ; 
-//     if (ts) 
-//       MakeTrackSegments(ts) ;
-//     else 
-//       AliError("Wrong type of track segments container") ; 
-    break ;  
+               case AliQA::kRAWS:
+               {
+                       AliInfo("Processing Raws QA") ; 
+                       AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
+                       if (rawReader) 
+                               MakeRaws(rawReader) ;
+                       else
+                       AliError("Wrong data type") ;     
+                       break ; 
+               }
+               case AliQA::kHITS:
+               {  
+                       AliInfo("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") ; 
+                               }
+                       }
+                       break ; 
+               }
+               case AliQA::kSDIGITS:
+               {
+                       AliInfo("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") ; 
+                               }
+                       }
+                       break ; 
+               }  
+               case AliQA::kDIGITS:
+               {
+                       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") ; 
+                               }
+                       }
+                       break ;  
+               }
+               case AliQA::kRECPOINTS:
+               {
+                       AliInfo("Processing RecPoints QA") ; 
+                       TTree * tree = dynamic_cast<TTree *>(data) ; 
+                       if (tree) {
+                               MakeRecPoints(tree) ; 
+                       } else {
+                               AliWarning("data are not a TTree") ; 
+                       }
+                       break ;  
+               }
+               case AliQA::kTRACKSEGMENTS:
+                       AliInfo("Processing Track Segments QA: not existing anymore") ; 
+               //       MakeTrackSegments(ts) ;
+               break ;  
   
-    case AliQA::kRECPARTICLES:
-    AliInfo("Processing RecParticles QA: not existing anymore") ; 
-//     TTree * recpar = dynamic_cast<TTree *>(data) ; 
-//     if (recpar) 
-//       MakeRecParticles(recpar) ;
-//     else 
-//       AliError("Wrong type of recparticles container") ; 
-    break ;  
-    
-  case AliQA::kESDS:
-   {
-    AliInfo("Processing ESDs QA") ; 
-    AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
-    if (esd) 
-      MakeESDs(esd) ;
-    else 
-      AliError("Wrong type of esd container") ; 
-    break ;
-   }  
-  }      
+               case AliQA::kRECPARTICLES:
+                       AliInfo("Processing RecParticles QA: not existing anymore") ; 
+                       //       MakeRecParticles(recpar) ;
+               break ;  
+               case AliQA::kESDS:
+               {
+                       AliInfo("Processing ESDs QA") ; 
+                       AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
+                       if (esd) 
+                               MakeESDs(esd) ;
+                       else 
+                               AliError("Wrong type of esd container") ; 
+                       break ;
+               }  
+       }         
 }
 
 //____________________________________________________________________________ 
@@ -279,7 +282,7 @@ TList *  AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
    }     
   case AliQA::kRECPOINTS: 
    {
-       fRecPointsQAList = new TList ; 
+       fRecPointsQAList = new TList() ; 
     InitRecPoints() ;
        return fRecPointsQAList ;
     break ; 
@@ -303,18 +306,66 @@ TList *  AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
   return 0x0 ; 
 }
 
+//____________________________________________________________________________ 
+void AliQADataMaker::Init(AliQA::TASKINDEX task, TList * list, Int_t run, Int_t cycles)
+{
+  // Intialisation by passing the list of QA data booked elsewhere
+  
+  fRun = run ;
+  if (cycles > 0)
+    SetCycle(cycles) ;  
+       
+  switch (task) {
+  case AliQA::kRAWS: 
+   {
+       fRawsQAList = list ;     
+    break ; 
+   }
+  case AliQA::kHITS: 
+   {
+       fHitsQAList = list ;     
+    break ; 
+   }
+  case AliQA::kSDIGITS: 
+   {
+       fSDigitsQAList = list ; 
+    break ; 
+   }
+  case AliQA::kDIGITS: 
+   {
+       fDigitsQAList = list ; 
+       break ; 
+   }     
+  case AliQA::kRECPOINTS: 
+   {
+       fRecPointsQAList = list ; 
+    break ; 
+  }
+  case AliQA::kTRACKSEGMENTS: 
+    break ; 
+    
+  case AliQA::kRECPARTICLES: 
+    break ; 
+    
+  case AliQA::kESDS: 
+   {
+       fESDsQAList = list ; 
+    break ; 
+   }
+  }  
+}
+
 //____________________________________________________________________________
 void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, Option_t * sameCycle) 
 { 
   // Finishes a cycle of QA data acquistion
  
- if ( (strcmp(sameCycle, "new") == 0) )  {
-   ResetCycle() ;
-   if (fOutput) 
-       fOutput->Close() ; 
-   fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;   
- }
-       
+ if ( (strcmp(sameCycle, "new") == 0) ) {
+       ResetCycle() ;
+       if (fOutput) 
+               fOutput->Close() ; 
+       fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;       
+ }     
  AliInfo(Form(" Run %d Cycle %d task %s file %s", 
        fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
 
index 6bb37c6..34d32ec 100644 (file)
@@ -38,27 +38,28 @@ public:
   AliQADataMaker(const char * name="", const char * title="") ;          // ctor
   AliQADataMaker(const AliQADataMaker& qadm) ;   
   AliQADataMaker& operator = (const AliQADataMaker& qadm) ;
-  virtual ~AliQADataMaker() ; // dtor
+  virtual ~AliQADataMaker() {;} // dtor
   
-  virtual void        Exec(AliQA::TASKINDEX, TObject * data) ;
-  void                EndOfCycle(AliQA::TASKINDEX) ;
-  void                Finish(AliQA::TASKINDEX task) const ; 
-  static const char * GetDetectorDirName() { return fDetectorDirName.Data() ; }
-  const Int_t         Increment() { return ++fCycleCounter ; } 
-  TList *             Init(AliQA::TASKINDEX, Int_t run, Int_t cycles = -1) ;
-  const Bool_t        IsCycleDone() const { return fCycleCounter > fCycle ? kTRUE : kFALSE ; }
   const Int_t         Add2DigitsList(TH1 * hist, const Int_t index)    { return Add2List(hist, index, fDigitsQAList) ; }
   const Int_t         Add2ESDsList(TH1 * hist, const Int_t index)      { return Add2List(hist, index, fESDsQAList) ; }
   const Int_t         Add2HitsList(TH1 * hist, const Int_t index)      { return Add2List(hist, index, fHitsQAList) ; }
   const Int_t         Add2RecPointsList(TH1 * hist, const Int_t index) { return Add2List(hist, index, fRecPointsQAList) ; }
   const Int_t         Add2RawsList(TH1 * hist, const Int_t index)      { return Add2List(hist, index, fRawsQAList) ; }
   const Int_t         Add2SDigitsList(TH1 * hist, const Int_t index)   { return Add2List(hist, index, fSDigitsQAList) ; }
+  virtual void        Exec(AliQA::TASKINDEX, TObject * data) ;
+  void                EndOfCycle(AliQA::TASKINDEX) ;
+  void                Finish(AliQA::TASKINDEX task) const ; 
   TH1 *               GetDigitsData(const Int_t index)    { return dynamic_cast<TH1 *>(GetData(fDigitsQAList, index)) ; }
   TH1 *               GetESDsData(const Int_t index)      { return dynamic_cast<TH1 *>(GetData(fESDsQAList, index)) ; }
   TH1 *               GetHitsData(const Int_t index)      { return dynamic_cast<TH1 *>(GetData(fHitsQAList, index)) ; }
   TH1 *               GetRecPointsData(const Int_t index) { return dynamic_cast<TH1 *>(GetData(fRecPointsQAList, index)) ; }
   TH1 *               GetRawsData(const Int_t index)      { return dynamic_cast<TH1 *>(GetData(fRawsQAList, index)) ; }
   TH1 *               GetSDigitsData(const Int_t index)   { return dynamic_cast<TH1 *>(GetData(fSDigitsQAList, index)) ; }
+  const char *        GetDetectorDirName() { return fDetectorDirName.Data() ; }
+  const Int_t         Increment() { return ++fCycleCounter ; } 
+  TList *             Init(AliQA::TASKINDEX, Int_t run, Int_t cycles = -1) ;
+  void                Init(AliQA::TASKINDEX, TList * list, Int_t run, Int_t cycles = -1) ;
+  const Bool_t        IsCycleDone() const { return fCycleCounter > fCycle ? kTRUE : kFALSE ; }
   void                SetCycle(Int_t nevts) { fCycle = nevts ; } 
   void                StartOfCycle(AliQA::TASKINDEX, Option_t * sameCycle = "new") ;
 
@@ -77,18 +78,21 @@ protected:
   //virtual void   InitTrackSegments() {AliInfo("To ne implemented by detectors");}
   virtual void   MakeESDs(AliESDEvent * )          {AliInfo("To be implemented by detectors");} 
   virtual void   MakeHits(TClonesArray * )         {AliInfo("To be implemented by detectors");} 
+  virtual void   MakeHits(TTree * )                {AliInfo("To be implemented by detectors");} 
   virtual void   MakeDigits(TClonesArray * )       {AliInfo("To be implemented by detectors");} 
+  virtual void   MakeDigits(TTree * )              {AliInfo("To be implemented by detectors");} 
   //  virtual void   MakeRecParticles(TClonesArray * ) {AliInfo("To be implemented by detectors");} 
   virtual void   MakeRaws(AliRawReader *)          {AliInfo("To be implemented by detectors");} 
   virtual void   MakeRecPoints(TTree * )           {AliInfo("To be implemented by detectors");} 
   virtual void   MakeSDigits(TClonesArray * )      {AliInfo("To be implemented by detectors");} 
+  virtual void   MakeSDigits(TTree * )             {AliInfo("To be implemented by detectors");} 
   //virtual void   MakeTrackSegments(TTree * )       {AliInfo("To be implemented by detectors");} 
   void           ResetCycle() { fCurrentCycle++ ; fCycleCounter = 0 ; } 
   virtual void   StartOfDetectorCycle() {AliInfo("To be implemented by detectors");} 
 
   TFile *        fOutput ;          //! output root file
   TDirectory *   fDetectorDir ;     //! directory for the given detector in the file
-  static TString fDetectorDirName ; //! detector directory name in the quality assurance data file
+  TString        fDetectorDirName ; //! detector directory name in the quality assurance data file
   TList *        fDigitsQAList ;    //! list of the digits QA data objects
   TList *        fESDsQAList ;      //! list of the ESDs QA data objects
   TList *        fHitsQAList ;      //! list of the hits QA data objects
diff --git a/STEER/AliQADataMakerSteer.cxx b/STEER/AliQADataMakerSteer.cxx
new file mode 100644 (file)
index 0000000..0637781
--- /dev/null
@@ -0,0 +1,372 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * 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   *
+ * 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+#include <TFile.h>
+#include <TPluginManager.h>
+#include <TROOT.h>
+#include <TString.h>
+#include <TSystem.h>
+
+#include "AliESDEvent.h"
+#include "AliLog.h"
+#include "AliQA.h"
+#include "AliQADataMaker.h"
+#include "AliQADataMakerSteer.h" 
+#include "AliRawReaderRoot.h"
+#include "AliRun.h"
+#include "AliRunLoader.h"
+
+ClassImp(AliQADataMakerSteer) 
+
+//_____________________________________________________________________________
+AliQADataMakerSteer::AliQADataMakerSteer(const char* gAliceFilename, const char * name, const char * title) :
+       TNamed(name, title), 
+       fCycleOption("new"), 
+       fESD(NULL), 
+       fESDTree(NULL),
+       fFirst(kTRUE),  
+       fGAliceFileName(gAliceFilename), 
+       fRunNumber(0), 
+       fNumberOfEvents(0), 
+       fRawReader(NULL), 
+       fRunLoader(NULL)  
+{
+       // default ctor
+       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+               fLoader[iDet]      = NULL ;
+               fQADataMaker[iDet] = NULL ;
+               fQACycles[iDet]    = 999999 ;   
+       }       
+}
+
+//_____________________________________________________________________________
+AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) : 
+       TNamed(qas), 
+       fCycleOption("new"), 
+       fESD(NULL), 
+       fESDTree(NULL), 
+       fFirst(qas.fFirst),  
+       fGAliceFileName(qas.fGAliceFileName), 
+       fRunNumber(qas.fRunNumber), 
+       fNumberOfEvents(qas.fNumberOfEvents), 
+       fRawReader(NULL), 
+       fRunLoader(NULL)  
+{
+       // cpy ctor
+       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+               fLoader[iDet]      = qas.fLoader[iDet] ;
+               fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
+               fQACycles[iDet]    = qas.fQACycles[iDet] ;      
+       }
+}
+
+//_____________________________________________________________________________
+AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas) 
+{
+       // assignment operator
+  this->~AliQADataMakerSteer() ;
+  new(this) AliQADataMakerSteer(qas) ;
+  return *this ;
+}
+
+//_____________________________________________________________________________
+AliQADataMakerSteer::~AliQADataMakerSteer() 
+{
+       // dtor
+  for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+    fLoader[iDet] = NULL;
+    delete fQADataMaker[iDet];
+    fQADataMaker[iDet] = NULL;
+  }
+
+  delete fRunLoader;
+  fRunLoader = NULL;
+  delete fRawReader;
+  fRawReader = NULL;
+}
+
+//_____________________________________________________________________________
+AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
+{
+       // get the loader for a detector
+       
+       TString detName = AliQA::GetDetName(iDet) ;
+    fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
+       if (fLoader[iDet]) 
+               return fLoader[iDet] ;
+       
+       // load the QA data maker object
+       TPluginManager* pluginManager = gROOT->GetPluginManager() ;
+       TString loaderName = "Ali" + detName + "Loader" ;
+
+       AliLoader * loader = NULL ;
+       // first check if a plugin is defined for the quality assurance data maker
+       TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
+       // if not, add a plugin for it
+       if (!pluginHandler) {
+               AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
+               TString libs = gSystem->GetLibraries() ;
+               if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
+                       pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
+               } else {
+                       pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
+               }
+               pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
+       }
+       if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
+               loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
+       }
+       if (loader) 
+               fLoader[iDet] = loader ;
+       return loader ;
+}
+
+//_____________________________________________________________________________
+AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(Int_t iDet)
+{
+       // get the quality assurance data maker for a detector
+       
+       if (fQADataMaker[iDet]) 
+               return fQADataMaker[iDet] ;
+       
+       AliQADataMaker * qadm = NULL ;
+       
+       if (fFirst) {
+               // load the QA data maker object
+               TPluginManager* pluginManager = gROOT->GetPluginManager() ;
+               TString detName = AliQA::GetDetName(iDet) ;
+               TString qadmName = "Ali" + detName + "QADataMaker" ;
+
+               // first check if a plugin is defined for the quality assurance data maker
+               TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
+               // if not, add a plugin for it
+               if (!pluginHandler) {
+                       AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
+                       TString libs = gSystem->GetLibraries() ;
+                       if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
+                               pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
+                       } else {
+                               pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
+                       }
+                       pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
+               }
+               if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
+                       qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
+               }
+               if (qadm) 
+                       fQADataMaker[iDet] = qadm ;
+       }
+       return qadm ;
+}
+
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX taskIndex, const  char * fileName )
+{
+       // Initialize the event source and QA data makers
+       
+       if (taskIndex == AliQA::kRAWS) {
+               fRawReader = new AliRawReaderRoot(fileName) ; 
+           if ( ! fRawReader ) 
+                       return kFALSE ; 
+               fRawReader->NextEvent() ; 
+               fRunNumber = fRawReader->GetRunNumber() ; 
+               fRawReader->RewindEvents();
+               fNumberOfEvents = 999999 ;
+               
+       } else if (taskIndex == AliQA::kESDS) {
+               if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
+                       TFile * esdFile = TFile::Open("AliESDs.root") ;
+                       fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ; 
+               fESD     = new AliESDEvent() ;
+            fESD->ReadFromTree(fESDTree) ;
+                       fESDTree->GetEntry(0) ; 
+                       fRunNumber = fESD->GetRunNumber() ; 
+                       fNumberOfEvents = fESDTree->GetEntries() ;
+               } else {
+                       AliError("AliESDs.root not found") ; 
+                       return kFALSE ; 
+               }
+               
+       } else {
+               if ( !InitRunLoader() ) {
+                       AliError("Problems in getting the Run Loader") ; 
+                       return kFALSE ; 
+               } else {
+                       fRunNumber      = fRunLoader->GetAliRun()->GetRunNumber() ; 
+                       fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
+               }
+       }
+               
+       // Initialize all QA data makers for all detectors
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+               if (!qadm) {
+                       AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ; 
+               } else {
+                       AliInfo(Form("Data Maker found for %s", qadm->GetName())) ; 
+                       qadm->Init(taskIndex, fRunNumber, GetQACycles(iDet)) ;
+                       qadm->StartOfCycle(taskIndex, fCycleOption) ;
+               }
+       } 
+       fFirst = kFALSE ;
+       return kTRUE ; 
+}
+
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::InitRunLoader()
+{
+       // get or create the run loader
+       if (fRunLoader) {
+               fCycleOption = "same" ; 
+               return kTRUE ;
+       } 
+               
+       if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
+    // load all base libraries to get the loader classes
+               TString libs = gSystem->GetLibraries() ;
+               for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+                       TString detName = AliQA::GetDetName(iDet) ;
+                       if (detName == "HLT") 
+                               continue;
+                       if (libs.Contains("lib" + detName + "base.so")) 
+                               continue;
+                       gSystem->Load("lib" + detName + "base.so");
+               }
+               fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
+               if (!fRunLoader) {
+                       AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
+                       return kFALSE;
+               }
+               fRunLoader->CdGAFile();
+               if (fRunLoader->LoadgAlice() == 0) {
+                       gAlice = fRunLoader->GetAliRun();
+               }
+               if (!gAlice) {
+                       AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
+                       return kFALSE;
+               }
+
+       } else {               // galice.root does not exist
+               AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
+               return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX taskIndex) 
+{
+       // write output to file for all detectors
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+               if (qadm) {
+                       qadm->EndOfCycle(taskIndex) ; 
+                       qadm->Finish(taskIndex) ; 
+               }
+       }
+       return kTRUE ; 
+}
+
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::Run(const AliQA::TASKINDEX taskIndex, const  char * fileName )
+{
+       // Runs all the QA data Maker for every detector
+       Bool_t rv = kFALSE ;
+       
+       if ( !Init(taskIndex, fileName) ) 
+               return kFALSE ; 
+               
+    // Fill QA data in event loop 
+       for (UInt_t iEvent = 0 ; iEvent < fNumberOfEvents ; iEvent++) {
+               // Get the event
+               AliInfo(Form("processing event %d", iEvent));
+               if ( taskIndex == AliQA::kRAWS ) {
+                       if ( !fRawReader->NextEvent() )
+                               break ;
+               } else if ( taskIndex == AliQA::kESDS ) {
+                       fESDTree->GetEntry(iEvent) ;
+               } else {
+                       fRunLoader->GetEvent(iEvent);
+               }
+               // loop over detectors
+               for (UInt_t iDet = 0 ; iDet < fgkNDetectors ; iDet++) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+                       if (!qadm) {
+                               rv = kFALSE ;
+                       } else {
+                               if ( qadm->IsCycleDone() ) {
+                                       qadm->EndOfCycle(AliQA::kRAWS) ;
+                                       qadm->StartOfCycle(AliQA::kRAWS) ;
+                               }
+                               TTree * data ; 
+                               switch (taskIndex) {
+                                       case AliQA::kRAWS :
+                                               qadm->Exec(taskIndex, fRawReader) ; 
+                                       break ; 
+                                       case AliQA::kHITS :
+                                               GetLoader(iDet)->LoadHits() ; 
+                                               data = GetLoader(iDet)->TreeH() ; 
+                                               if ( ! data ) {
+                                                       AliWarning(Form(" Hit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                                               } else {
+                                                       qadm->Exec(taskIndex, data) ;
+                                               } 
+                                       break ;
+                                       case AliQA::kSDIGITS :
+                                               GetLoader(iDet)->LoadSDigits() ; 
+                                               data = GetLoader(iDet)->TreeS() ; 
+                                               if ( ! data ) {
+                                                       AliWarning(Form(" SDigit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                                               } else {
+                                                       qadm->Exec(taskIndex, data) ; 
+                                               }
+                                       break; 
+                                       case AliQA::kDIGITS :
+                                               GetLoader(iDet)->LoadDigits() ; 
+                                               data = GetLoader(iDet)->TreeD() ; 
+                                               if ( ! data ) {
+                                                       AliWarning(Form(" Digit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                                               } else {
+                                                       qadm->Exec(taskIndex, data) ;
+                                               }
+                                       break; 
+                                       case AliQA::kRECPOINTS :
+                                               GetLoader(iDet)->LoadRecPoints() ; 
+                                               data = GetLoader(iDet)->TreeR() ; 
+                                               if (!data) {
+                                                       AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ; 
+                                               } else {
+                                                       qadm->Exec(taskIndex, data) ; 
+                                               }
+                                       break; 
+                                       case AliQA::kTRACKSEGMENTS :
+                                       break; 
+                                       case AliQA::kRECPARTICLES :
+                                       break; 
+                                       case AliQA::kESDS :
+                                               qadm->Exec(taskIndex, fESD) ;
+                                       break; 
+                               } //task switch
+                               qadm->Increment() ; 
+                       } //data maker exist
+               } // detector loop
+       } // event loop 
+       // Save QA data for all detectors
+       rv = Finish(taskIndex) ;
+       return rv ; 
+}
\ No newline at end of file
diff --git a/STEER/AliQADataMakerSteer.h b/STEER/AliQADataMakerSteer.h
new file mode 100644 (file)
index 0000000..8c7483a
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef ALIQADATAMAKERSTEER_H
+#define ALIQADATAMAKERSTEER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for running the QA makers                                           //
+//                                                                           //
+//   AliQADataMakerSteer qas;                                                //
+//   qas.Run(AliQA::kRAWS, rawROOTFileName);                                 //
+//   qas.Run(AliQA::kHITS);                                                  //
+//   qas.Run(AliQA::kSDIGITS);                                               //
+//   qas.Run(AliQA::kDIGITS);                                                //
+//   qas.Run(AliQA::kRECPOINTS);                                             //
+//   qas.Run(AliQA::kESDS);                                                  //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TNamed.h>
+#include "AliQA.h"
+#include "AliLoader.h" 
+class AliQADataMaker ;
+class AliRawReaderRoot ;  
+class AliRunLoader ; 
+
+class AliQADataMakerSteer: public TNamed {
+public:
+       AliQADataMakerSteer(const char* gAliceFilename = "galice.root", 
+                                               const char * name = "AliQADataMakerSteer", 
+                                               const char * title = "QA makers") ; 
+       AliQADataMakerSteer(const AliQADataMakerSteer & qas) ; 
+       AliQADataMakerSteer & operator = (const AliQADataMakerSteer & qas) ; 
+       virtual ~AliQADataMakerSteer() ; 
+       Bool_t Run(const AliQA::TASKINDEX taskIndex, const char * fileName = NULL) ; 
+       void   SetCycleLength(const AliQA::DETECTORINDEX det, const Int_t cycle) { fQACycles[det] = cycle ; }
+
+private: 
+       AliLoader      * GetLoader(Int_t iDet) ; 
+       const Int_t      GetQACycles(const Int_t iDet) { return fQACycles[iDet] ; }
+       AliQADataMaker * GetQADataMaker(Int_t iDet) ; 
+       Bool_t                   Init(const AliQA::TASKINDEX taskIndex, const  char * fileName = NULL) ;
+       Bool_t           InitRunLoader() ; 
+       Bool_t           Finish(const AliQA::TASKINDEX taskIndex) ;
+
+       Option_t *         fCycleOption ;                  //! new or same in case of 2 consecutive data making for a same detector   
+       AliESDEvent *      fESD ;                          //! current ESD
+       TTree *            fESDTree ;                      //! current ESD Tree
+       Bool_t             fFirst ;                        //! to search the detector QA data maker only once
+       TString            fGAliceFileName ;               //! name of the galice file
+       UInt_t             fRunNumber ;                    //! current run number
+       Long64_t           fNumberOfEvents ;               //! number of events in the run 
+       AliRawReaderRoot * fRawReader ;                    //! current raw reader object 
+       AliRunLoader *     fRunLoader ;                    //! current run loader object
+       static const UInt_t fgkNDetectors = AliQA::kNDET ; //! number of detectors    
+       AliLoader      *   fLoader[fgkNDetectors];         //! array of detectors loader
+       AliQADataMaker *   fQADataMaker[fgkNDetectors];    //! array of QA data maker objects
+       Int_t              fQACycles[fgkNDetectors];       //! array of QA cycle length
+       
+  ClassDef(AliQADataMakerSteer, 0)      // class for running the QA makers
+};
+
+#endif
index afe7fdd..aae03b4 100644 (file)
 
 #pragma link C++ class AliQA+;
 #pragma link C++ class AliQADataMaker+;
+#pragma link C++ class AliQADataMakerSteer+;
 #pragma link C++ class AliQAChecker+;
 #pragma link C++ class AliQACheckerBase+;
 #pragma link C++ class AliMillepede+;
index 3003e82..78cd3e5 100644 (file)
@@ -47,6 +47,7 @@ AliFstream.cxx \
 AliCTPRawData.cxx \
 AliQA.cxx \
 AliQADataMaker.cxx \
+AliQADataMakerSteer.cxx \
 AliQAChecker.cxx \
 AliQACheckerBase.cxx \
 AliMillepede.cxx