]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ESDCheck/AliFMDQATask.cxx
New class for dE/dx analysis (comparison with Bethe-Bloch, check of response function...
[u/mrichter/AliRoot.git] / ESDCheck / AliFMDQATask.cxx
index 11e3115aa07a4a94e1885afafe3006f4dc3a4de5..956d199dc6463ed5e7f25249a432433f7cd618ea 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" 
@@ -33,6 +38,7 @@ AliFMDQATask::AliFMDQATask(const char *name) :
   AliAnalysisTask(name,""),  
   fChain(0),
   fESD(0), 
+  fOutputContainer(0),
   fhFMD1i(0),
   fhFMD2i(0), 
   fhFMD2o(0), 
@@ -63,7 +69,7 @@ AliFMDQATask::~AliFMDQATask()
 }
 
 //______________________________________________________________________________
-void AliFMDQATask::Init(const Option_t*)
+void AliFMDQATask::ConnectInputData(const Option_t*)
 {
   // Initialisation of branch container and histograms 
     
@@ -76,24 +82,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);
@@ -124,14 +129,17 @@ void AliFMDQATask::Exec(Option_t *)
     return ; 
   }
   
+  TFile * currentFile = (dynamic_cast<TChain *>(fChain))->GetFile() ; 
   if ( !((entry-1)%100) ) 
-    AliInfo(Form("%s ----> Processing event # %lld",  (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; 
-  
+    AliInfo(Form("%s ----> Processing event # %lld", currentFile->GetName(), entry)) ; 
+           
   // ************************  FMD *************************************
-  AliESDFMD * fmd = fESD->GetFMDData() ;
-  fmd->CheckNeedUShort(fChain->GetFile());
-
+ 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 ;
@@ -184,6 +192,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) ; 
 
@@ -258,18 +276,18 @@ Bool_t AliFMDQATask::TestHisto(TH1D * hTest) const
   }
 
   Bool_t   ret   = kFALSE ;
-  Char_t * test  = "not OK";
-  Char_t * test2 = "not OK";
+  const Char_t * test  = "not OK";
+  const Char_t * test2 = "not OK";
   
   if(chiSq < chiMax && chiSq > chiLow)
     test = "OK" ;
   if(mpv > 0.6 && mpv < 1)
     test2 = "OK" ;
  
-  if(test == "OK" && test2 == "OK")
+  if(!strcmp(test,"OK") && !strcmp(test2,"OK"))
     ret = kTRUE;
   
-  if(test == "not OK" || test2 == "not OK") {
+  if(!strcmp(test,"not OK") || !strcmp(test2,"not OK")) {
     AliWarning("Bad fit results") ; 
     printf("Detector : %s\n", hTest->GetName()) ;
     printf("Landau fit Chi Square / NDF = %f / %d which is %s\n", chiSq*ndf, ndf, test) ;