]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ESDCheck/AliFMDQATask.cxx
Fixes to calls for MeanMaterialBudget (now in AliTracker) (From Jouri Belikov)
[u/mrichter/AliRoot.git] / ESDCheck / AliFMDQATask.cxx
index ee3af257fe81dd08f0892cb54c1082ed9a58db80..9ae3191359f774424746af514050db870614830d 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+
+/* $Id$ */
+
 //_________________________________________________________________________
 // An analysis task to check the FMD data in simulated data
 //
 //*-- Hans Hjersing Dalsgaard 
 //////////////////////////////////////////////////////////////////////////////
 
+#include <TCanvas.h> 
 #include <TChain.h>
+#include <TF1.h> 
 #include <TFile.h> 
-#include <TCanvas.h> 
 #include <TH1D.h> 
-#include <TF1.h> 
+#include <TROOT.h>
+#include <TString.h> 
 
 #include "AliFMDQATask.h" 
 #include "AliESD.h" 
@@ -63,7 +68,7 @@ AliFMDQATask::~AliFMDQATask()
 }
 
 //______________________________________________________________________________
-void AliFMDQATask::Init(const Option_t*)
+void AliFMDQATask::ConnectInputData(const Option_t*)
 {
   // Initialisation of branch container and histograms 
     
@@ -76,24 +81,23 @@ void AliFMDQATask::Init(const Option_t*)
     return ;
   }
   
-  if (!fESD) {
-    // One should first check if the branch address was taken by some other task
-    char ** address = (char **)GetBranchAddress(0, "ESD") ;
-    if (address) 
-      fESD = (AliESD *)(*address) ; 
-    if (!fESD) 
-      fChain->SetBranchAddress("ESD", &fESD) ;  
+  // One should first check if the branch address was taken by some other task
+  char ** address = (char **)GetBranchAddress(0, "ESD");
+  if (address) {
+    fESD = (AliESD*)(*address);
+  } else {
+    fESD = new AliESD();
+    SetBranchAddress(0, "ESD", &fESD);
   }
-  // The output objects will be written to 
-  TDirectory * cdir = gDirectory ; 
-  // Open a file for output #0
-  char outputName[1024] ; 
-  sprintf(outputName, "%s.root", GetName() ) ; 
-  OpenFile(0, outputName , "RECREATE") ; 
-  if (cdir) 
-    cdir->cd() ; 
-  
+}
+
+//________________________________________________________________________
+void AliFMDQATask::CreateOutputObjects()
+{  
   // create histograms 
+
+  OpenFile(0) ; 
+
   fhFMD1i = new TH1D("FMD1i", "FMD1i", 100, -0.5, 3);
   fhFMD2i = new TH1D("FMD2i", "FMD2i", 100, -0.5, 3);
   fhFMD2o = new TH1D("FMD2o", "FMD2o", 100, -0.5, 3);
@@ -129,11 +133,12 @@ void AliFMDQATask::Exec(Option_t *)
     AliInfo(Form("%s ----> Processing event # %lld", currentFile->GetName(), entry)) ; 
            
   // ************************  FMD *************************************
-  
-  AliESDFMD * fmd = fESD->GetFMDData() ;
-  
-  fmd->CheckNeedUShort(currentFile);
-
+ AliESDFMD * fmd = fESD->GetFMDData() ;
+ if ( ! fmd ) {
+   AliError("No FMD found in ESD") ; 
+   return ; 
+ }
+ fmd->CheckNeedUShort(currentFile);
   Int_t nFMD1 = 0, nFMD2i = 0, nFMD2o = 0, nFMD3i = 0, nFMD3o = 0 ;
   
   UShort_t detector = 1 ;
@@ -186,6 +191,16 @@ void AliFMDQATask::Terminate(Option_t *)
 {
   // Processing when the event loop is ended
  
+  fOutputContainer = (TObjArray*)GetOutputData(0);
+  if ( ! fOutputContainer ) 
+    return ; 
+
+  fhFMD1i = (TH1D*)fOutputContainer->At(0);
+  fhFMD2i = (TH1D*)fOutputContainer->At(1);
+  fhFMD2o = (TH1D*)fOutputContainer->At(2);
+  fhFMD3i = (TH1D*)fOutputContainer->At(3);
+  fhFMD3o = (TH1D*)fOutputContainer->At(4);
+
   TCanvas * cFMD1 = new TCanvas("cFMD1", "FMD ESD Test", 400, 10, 600, 700);
   cFMD1->Divide(3, 2) ;