]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ESDCheck/AliEMCALQATask.cxx
Updates in GRP Preprocessor (Ernesto)
[u/mrichter/AliRoot.git] / ESDCheck / AliEMCALQATask.cxx
index 1c94fe2656c60331111dca3fb1b250e16a354001..0657786aa8d2adc79906ffb7f3d13d9c92ec9061 100644 (file)
 
 //_________________________________________________________________________
 // An analysis task to check the EMCAL photon data in simulated data
+// An analysis task to check the EMCAL photon data in simulated data
+// An analysis task to check the EMCAL photon data in simulated data
+// An analysis task to check the EMCAL photon data in simulated data
+// An analysis task to check the EMCAL photon data in simulated data
 //
 //*-- Yves Schutz 
 //////////////////////////////////////////////////////////////////////////////
 #include <TChain.h>
 #include <TFile.h> 
 #include <TH1.h>
-#include <TH1F.h>
-#include <TH1I.h>
-#include <TLegend.h> 
 #include <TNtuple.h>
 #include <TROOT.h>
 #include <TVector3.h> 
+#include <TString.h> 
 
 #include "AliEMCALQATask.h" 
 #include "AliESD.h" 
@@ -41,6 +43,7 @@ AliEMCALQATask::AliEMCALQATask(const char *name) :
   AliAnalysisTask(name,""),  
   fChain(0),
   fESD(0), 
+  fOutputContainer(0), 
   fhEMCALPos(0),
   fhEMCAL(0),
   fhEMCALEnergy(0),
@@ -57,6 +60,34 @@ AliEMCALQATask::AliEMCALQATask(const char *name) :
   DefineOutput(0,  TObjArray::Class()) ; 
 }
 
+//____________________________________________________________________________
+AliEMCALQATask::AliEMCALQATask(const AliEMCALQATask& ta) :
+  AliAnalysisTask(ta.GetName(),""),  
+  fChain(ta.fChain),
+  fESD(ta.fESD), 
+  fOutputContainer(ta.fOutputContainer), 
+  fhEMCALPos(ta.fhEMCALPos),
+  fhEMCAL(ta.fhEMCAL),
+  fhEMCALEnergy(ta.fhEMCALEnergy),
+  fhEMCALDigits(ta.fhEMCALDigits),
+  fhEMCALRecParticles(ta.fhEMCALRecParticles),
+  fhEMCALPhotons(ta.fhEMCALPhotons),
+  fhEMCALInvariantMass(ta.fhEMCALInvariantMass),
+  fhEMCALDigitsEvent(ta.fhEMCALDigitsEvent)
+{ 
+  // cpy ctor
+}
+
+//_____________________________________________________________________________
+AliEMCALQATask& AliEMCALQATask::operator = (const AliEMCALQATask& ap)
+{
+// assignment operator
+
+  this->~AliEMCALQATask();
+  new(this) AliEMCALQATask(ap);
+  return *this;
+}
+
 //______________________________________________________________________________
 AliEMCALQATask::~AliEMCALQATask()
 {
@@ -75,7 +106,7 @@ AliEMCALQATask::~AliEMCALQATask()
 }
 
 //______________________________________________________________________________
-void AliEMCALQATask::Init(const Option_t*)
+void AliEMCALQATask::ConnectInputData(const Option_t*)
 {
   // Initialisation of branch container and histograms 
     
@@ -88,25 +119,23 @@ void AliEMCALQATask::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() ; 
-  
-  // create histograms 
+}
   
+//______________________________________________________________________________
+void AliEMCALQATask::CreateOutputObjects()  
+{
+// create histograms  
+
+  OpenFile(0) ; 
+
   fhEMCALPos           = new TNtuple("EMCALPos"        , "Position in EMCAL" , "x:y:z");
   fhEMCAL              = new TNtuple("EMCAL"           , "EMCAL" , "event:digits:clusters:photons");
   fhEMCALEnergy        = new TH1D("EMCALEnergy"        , "EMCALEnergy"       , 1000, 0., 10. ) ;
@@ -148,10 +177,10 @@ void AliEMCALQATask::Exec(Option_t *)
   
   //************************  EMCAL *************************************
   Int_t       firstEmcalCluster       = fESD->GetFirstEMCALCluster() ;
-  const Int_t mumberOfEmcalClusters   = fESD->GetNumberOfEMCALClusters() ;
+  const Int_t kNumberOfEmcalClusters   = fESD->GetNumberOfEMCALClusters() ;
 
-  TVector3 ** emcalVector        = new TVector3*[mumberOfEmcalClusters] ;
-  Float_t   * emcalPhotonsEnergy = new Float_t[mumberOfEmcalClusters] ;
+  TVector3 ** emcalVector        = new TVector3*[kNumberOfEmcalClusters] ;
+  Float_t   * emcalPhotonsEnergy = new Float_t[kNumberOfEmcalClusters] ;
   Int_t      emcalCluster ; 
   Int_t      numberOfEmcalClustersv1 = 0 ; 
   Int_t      numberOfPhotonsInEmcal  = 0 ;
@@ -159,21 +188,21 @@ void AliEMCALQATask::Exec(Option_t *)
 
 
   // loop over all the EMCAL Cluster
-  for(emcalCluster = firstEmcalCluster ; emcalCluster < firstEmcalCluster + mumberOfEmcalClusters ; emcalCluster++) {
+  for(emcalCluster = firstEmcalCluster ; emcalCluster < firstEmcalCluster + kNumberOfEmcalClusters ; emcalCluster++) {
     AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(emcalCluster) ;
     if (caloCluster) {
       Float_t pos[3] ;
-      fhEMCALPos->Fill(pos[0],pos[1],pos[2]) ;
-      if(caloCluster->GetClusterType() == AliESDCaloCluster::kClusterv1) {  
-       caloCluster->GetGlobalPosition(pos) ;
-       fhEMCALEnergy->Fill(caloCluster->GetClusterEnergy()) ;
+      if(caloCluster->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1) {  
+       caloCluster->GetPosition(pos) ;
+       fhEMCALPos->Fill(pos[0],pos[1],pos[2]) ;
+       fhEMCALEnergy->Fill(caloCluster->E()) ;
        fhEMCALDigits->Fill(entry, caloCluster->GetNumberOfDigits()) ;
        numberOfEmcalClustersv1++ ;
        numberOfDigitsInEmcal += caloCluster->GetNumberOfDigits() ;    
        // Float_t * pid = clus->GetPid() ;
        // if(pid[AliPID::kPhoton]>0.9){
        emcalVector[numberOfPhotonsInEmcal] = new TVector3(pos[0],pos[1],pos[2]) ;
-       emcalPhotonsEnergy[numberOfPhotonsInEmcal] = caloCluster->GetClusterEnergy() ;
+       emcalPhotonsEnergy[numberOfPhotonsInEmcal] = caloCluster->E() ;
        numberOfPhotonsInEmcal++ ; 
       }
     }
@@ -208,37 +237,50 @@ void AliEMCALQATask::Exec(Option_t *)
 void AliEMCALQATask::Terminate(Option_t *)
 {
   // Processing when the event loop is ended
-  
-  printf("EMCALEnergy Mean        : %5.3f , RMS : %5.3f \n", fhEMCALEnergy->GetMean(),        fhEMCALEnergy->GetRMS()        ) ;
-  printf("EMCALDigits Mean        : %5.3f , RMS : %5.3f \n", fhEMCALDigits->GetMean(),        fhEMCALDigits->GetRMS()        ) ;
-  printf("EMCALRecParticles Mean  : %5.3f , RMS : %5.3f \n", fhEMCALRecParticles->GetMean(),  fhEMCALRecParticles->GetRMS()  ) ;
-  printf("EMCALPhotons Mean       : %5.3f , RMS : %5.3f \n", fhEMCALPhotons->GetMean(),       fhEMCALPhotons->GetRMS()       ) ;
-  printf("EMCALInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhEMCALInvariantMass->GetMean(), fhEMCALInvariantMass->GetRMS() ) ;
-  printf("EMCALDigitsEvent Mean   : %5.3f , RMS : %5.3f \n", fhEMCALDigitsEvent->GetMean(),   fhEMCALDigitsEvent->GetRMS()   ) ;
+  fOutputContainer = (TObjArray*)GetOutputData(0);
+  fhEMCALEnergy = (TH1D*)fOutputContainer->At(2);
+  fhEMCALDigits = (TH1I*)fOutputContainer->At(3);
+  fhEMCALRecParticles = (TH1D*)fOutputContainer->At(4);
+  fhEMCALPhotons = (TH1I*)fOutputContainer->At(5);
+  fhEMCALInvariantMass = (TH1D*)fOutputContainer->At(6);
+  fhEMCALDigitsEvent = (TH1I*)fOutputContainer->At(7);
+  Bool_t problem = kFALSE ; 
+  AliInfo(Form(" *** %s Report:", GetName())) ; 
+  printf("        EMCALEnergy Mean        : %5.3f , RMS : %5.3f \n", fhEMCALEnergy->GetMean(),        fhEMCALEnergy->GetRMS()        ) ;
+  printf("        EMCALDigits Mean        : %5.3f , RMS : %5.3f \n", fhEMCALDigits->GetMean(),        fhEMCALDigits->GetRMS()        ) ;
+  printf("        EMCALRecParticles Mean  : %5.3f , RMS : %5.3f \n", fhEMCALRecParticles->GetMean(),  fhEMCALRecParticles->GetRMS()  ) ;
+  printf("        EMCALPhotons Mean       : %5.3f , RMS : %5.3f \n", fhEMCALPhotons->GetMean(),       fhEMCALPhotons->GetRMS()       ) ;
+  printf("        EMCALInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhEMCALInvariantMass->GetMean(), fhEMCALInvariantMass->GetRMS() ) ;
+  printf("        EMCALDigitsEvent Mean   : %5.3f , RMS : %5.3f \n", fhEMCALDigitsEvent->GetMean(),   fhEMCALDigitsEvent->GetRMS()   ) ;
 
   TCanvas  * cEMCAL = new TCanvas("EMCAL", "EMCAL ESD Test", 400, 10, 600, 700);
   cEMCAL->Divide(3, 2) ; 
 
   cEMCAL->cd(1) ; 
-  gPad->SetLogy();
+  if ( fhEMCALEnergy->GetMaximum() > 0. ) 
+    gPad->SetLogy();
   fhEMCALEnergy->SetAxisRange(0, 25.);
   fhEMCALEnergy->SetXTitle("Energy (GeV)");
   fhEMCALEnergy->Draw();
   
   cEMCAL->cd(2) ; 
-  gPad->SetLogy();
+  if ( fhEMCALDigits->GetMaximum() > 0. ) 
+    gPad->SetLogy();
   fhEMCALDigits->SetAxisRange(0, 25.);
   fhEMCALDigits->SetXTitle("DigitsPerCluster");
   fhEMCALDigits->Draw();
  
   cEMCAL->cd(3) ; 
-  gPad->SetLogy();
+  if ( fhEMCALRecParticles->GetMaximum() > 0. ) 
+     gPad->SetLogy();
   fhEMCALRecParticles->SetAxisRange(0, 25.);
   fhEMCALRecParticles->SetXTitle("RecParticles");
   fhEMCALRecParticles->Draw();
  
   cEMCAL->cd(4) ; 
-  gPad->SetLogy();
+  if ( fhEMCALPhotons->GetMaximum() > 0. ) 
+    gPad->SetLogy();
   fhEMCALPhotons->SetAxisRange(0, 25.);
   fhEMCALPhotons->SetXTitle("Photons");
   fhEMCALPhotons->Draw();
@@ -248,7 +290,8 @@ void AliEMCALQATask::Terminate(Option_t *)
   fhEMCALInvariantMass->Draw();
  
   cEMCAL->cd(6) ; 
-  gPad->SetLogy();
+  if ( fhEMCALDigitsEvent->GetMaximum() > 0. ) 
+    gPad->SetLogy();
   fhEMCALDigitsEvent->SetAxisRange(0, 40.);
   fhEMCALDigitsEvent->SetXTitle("DigitsPerEvent");
   fhEMCALDigitsEvent->Draw();
@@ -256,10 +299,18 @@ void AliEMCALQATask::Terminate(Option_t *)
   cEMCAL->Print("EMCAL.eps");
  
   char line[1024] ; 
-  sprintf(line, ".!tar -zcvf %s.tar.gz *.eps", GetName()) ; 
+  sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
   gROOT->ProcessLine(line);
   sprintf(line, ".!rm -fR *.eps"); 
   gROOT->ProcessLine(line);
  
-  AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! \n", GetName())) ;
+  AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
+
+  TString report ; 
+  if(problem)
+    report="Problems found, please check!!!";  
+  else 
+    report="OK";
+
+  AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report.Data())) ; 
 }