updates from salvatore
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 19 Jan 2013 11:18:28 +0000 (11:18 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 19 Jan 2013 11:18:28 +0000 (11:18 +0000)
PWGJE/CMakelibPWGJEEMCALJetTasks.pkg
PWGJE/EMCALJetTasks/AliAnalysisTaskDeltaPt.cxx
PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJet.cxx
PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJetSample.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJetSample.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/AliHadCorrTask.cxx
PWGJE/EMCALJetTasks/AliJetResponseMaker.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskSAJF.cxx
PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetSample.C [new file with mode: 0644]
PWGJE/PWGJEEMCALJetTasksLinkDef.h

index 6842ece..db5d183 100644 (file)
@@ -27,6 +27,7 @@
 
 set ( SRCS 
  EMCALJetTasks/AliAnalysisTaskEmcalJet.cxx
+ EMCALJetTasks/AliAnalysisTaskEmcalJetSample.cxx
  EMCALJetTasks/AliAnalysisTaskRhoBase.cxx
  EMCALJetTasks/AliAnalysisTaskRho.cxx
  EMCALJetTasks/AliAnalysisTaskRhoFlow.cxx
index b4e9ccb..0493dcc 100644 (file)
@@ -381,11 +381,11 @@ Bool_t AliAnalysisTaskDeltaPt::FillHistograms()
       DoEmbTrackLoop();
     if (fEmbCaloClusters)
       DoEmbClusterLoop();
-    if (fEmbeddedTrackId >= 0) {
+    if (fEmbTracks && fEmbeddedTrackId >= 0) {
       AliVTrack *track2 = static_cast<AliVTrack*>(fEmbTracks->At(fEmbeddedTrackId));
       fHistEmbNotFoundPhiEta[fCentBin]->Fill(track2->Eta(), track2->Phi());
     }
-    else if (fEmbeddedClusterId >= 0) {
+    else if (fEmbCaloClusters && fEmbeddedClusterId >= 0) {
       AliVCluster *cluster2 = static_cast<AliVCluster*>(fEmbCaloClusters->At(fEmbeddedClusterId));
       TLorentzVector nPart;
       cluster2->GetMomentum(nPart, fVertex);
index 5cfe521..5cf52a2 100644 (file)
@@ -229,7 +229,10 @@ Int_t* AliAnalysisTaskEmcalJet::GetSortedArray(TClonesArray *array) const
 
   const Int_t n = array->GetEntriesFast();
 
-  if (fJets->GetClass()->GetBaseClass("AliEmcalJet")) {
+  if (n < 1)
+    return 0;
+
+  if (array->GetClass()->GetBaseClass("AliEmcalJet")) {
 
     for (Int_t i = 0; i < n; i++) {
 
@@ -249,7 +252,7 @@ Int_t* AliAnalysisTaskEmcalJet::GetSortedArray(TClonesArray *array) const
     }
   }
 
-  else if (fJets->GetClass()->GetBaseClass("AliVTrack")) {
+  else if (array->GetClass()->GetBaseClass("AliVTrack")) {
 
     for (Int_t i = 0; i < n; i++) {
 
@@ -269,7 +272,7 @@ Int_t* AliAnalysisTaskEmcalJet::GetSortedArray(TClonesArray *array) const
     }
   }
 
-  else if (fJets->GetClass()->GetBaseClass("AliVCluster")) {
+  else if (array->GetClass()->GetBaseClass("AliVCluster")) {
 
     for (Int_t i = 0; i < n; i++) {
 
diff --git a/PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJetSample.cxx b/PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJetSample.cxx
new file mode 100644 (file)
index 0000000..06804d7
--- /dev/null
@@ -0,0 +1,230 @@
+// $Id: AliAnalysisTaskEmcalJetSample.cxx $
+//
+// Jet sample analysis task.
+//
+// Author: S.Aiola
+
+#include <TClonesArray.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TList.h>
+#include <TLorentzVector.h>
+
+#include "AliVCluster.h"
+#include "AliVTrack.h"
+#include "AliEmcalJet.h"
+#include "AliRhoParameter.h"
+#include "AliLog.h"
+
+#include "AliAnalysisTaskEmcalJetSample.h"
+
+ClassImp(AliAnalysisTaskEmcalJetSample)
+
+//________________________________________________________________________
+AliAnalysisTaskEmcalJetSample::AliAnalysisTaskEmcalJetSample() : 
+  AliAnalysisTaskEmcalJet("AliAnalysisTaskEmcalJetSample", kTRUE)
+
+{
+  // Default constructor.
+
+  for (Int_t i = 0; i < 4; i++) {
+    fHistTracksPt[i] = 0;
+    fHistClustersPt[i] = 0;
+    fHistLeadingJetPt[i] = 0;
+    fHistJetsPhiEta[i] = 0;
+    fHistJetsPtArea[i] = 0;
+    fHistJetsPtLeadHad[i] = 0;
+    fHistJetsCorrPtArea[i] = 0;
+  }
+
+  SetMakeGeneralHistograms(kTRUE);
+}
+
+//________________________________________________________________________
+AliAnalysisTaskEmcalJetSample::AliAnalysisTaskEmcalJetSample(const char *name) : 
+  AliAnalysisTaskEmcalJet(name, kTRUE)
+{
+  // Standard constructor.
+
+  for (Int_t i = 0; i < 4; i++) {
+    fHistTracksPt[i] = 0;
+    fHistClustersPt[i] = 0;
+    fHistLeadingJetPt[i] = 0;
+    fHistJetsPhiEta[i] = 0;
+    fHistJetsPtArea[i] = 0;
+    fHistJetsPtLeadHad[i] = 0;
+    fHistJetsCorrPtArea[i] = 0;
+  }
+
+  SetMakeGeneralHistograms(kTRUE);
+}
+
+//________________________________________________________________________
+AliAnalysisTaskEmcalJetSample::~AliAnalysisTaskEmcalJetSample()
+{
+  // Destructor.
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEmcalJetSample::UserCreateOutputObjects()
+{
+  // Create user output.
+
+  AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
+
+  TString histname;
+
+  for (Int_t i = 0; i < 4; i++) {
+    if (!fTracksName.IsNull()) {
+      histname = "fHistTracksPt_";
+      histname += i;
+      fHistTracksPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins / 2, fMinBinPt, fMaxBinPt / 2);
+      fHistTracksPt[i]->GetXaxis()->SetTitle("p_{T,track} (GeV/c)");
+      fHistTracksPt[i]->GetYaxis()->SetTitle("counts");
+      fOutput->Add(fHistTracksPt[i]);
+    }
+
+    if (!fCaloName.IsNull()) {
+      histname = "fHistClustersPt_";
+      histname += i;
+      fHistClustersPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins / 2, fMinBinPt, fMaxBinPt / 2);
+      fHistClustersPt[i]->GetXaxis()->SetTitle("p_{T,clus} (GeV/c)");
+      fHistClustersPt[i]->GetYaxis()->SetTitle("counts");
+      fOutput->Add(fHistClustersPt[i]);
+    }
+
+    if (!fJetsName.IsNull()) {
+      histname = "fHistLeadingJetPt_";
+      histname += i;
+      fHistLeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
+      fHistLeadingJetPt[i]->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
+      fHistLeadingJetPt[i]->GetYaxis()->SetTitle("counts");
+      fOutput->Add(fHistLeadingJetPt[i]);
+      
+      histname = "fHistJetsPhiEta_";
+      histname += i;
+      fHistJetsPhiEta[i] = new TH2F(histname.Data(), histname.Data(), 50, -1, 1, 101, 0, TMath::Pi()*2 + TMath::Pi()/200);
+      fHistJetsPhiEta[i]->GetXaxis()->SetTitle("#eta");
+      fHistJetsPhiEta[i]->GetYaxis()->SetTitle("#phi");
+      fOutput->Add(fHistJetsPhiEta[i]);
+      
+      histname = "fHistJetsPtArea_";
+      histname += i;
+      fHistJetsPtArea[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt, 30, 0, 3);
+      fHistJetsPtArea[i]->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
+      fHistJetsPtArea[i]->GetYaxis()->SetTitle("area");
+      fOutput->Add(fHistJetsPtArea[i]);
+
+      histname = "fHistJetsPtLeadHad_";
+      histname += i;
+      fHistJetsPtLeadHad[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
+      fHistJetsPtLeadHad[i]->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
+      fHistJetsPtLeadHad[i]->GetYaxis()->SetTitle("p_{T,lead} (GeV/c)");
+      fHistJetsPtLeadHad[i]->GetZaxis()->SetTitle("counts");
+      fOutput->Add(fHistJetsPtLeadHad[i]);
+    
+      if (!fRhoName.IsNull()) {
+       histname = "fHistJetsCorrPtArea_";
+       histname += i;
+       fHistJetsCorrPtArea[i] = new TH2F(histname.Data(), histname.Data(), fNbins*2, -fMaxBinPt, fMaxBinPt, 30, 0, 3);
+       fHistJetsCorrPtArea[i]->GetXaxis()->SetTitle("p_{T}^{corr} [GeV/c]");
+       fHistJetsCorrPtArea[i]->GetYaxis()->SetTitle("area");
+       fOutput->Add(fHistJetsCorrPtArea[i]);
+      }
+    }
+  }
+  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskEmcalJetSample::FillHistograms()
+{
+  // Fill histograms.
+
+  if (fTracks) {
+    const Int_t ntracks = fTracks->GetEntriesFast();
+    
+    for (Int_t it = 0; it < ntracks; it++) {
+      AliVTrack *track = static_cast<AliVTrack*>(fTracks->At(it));
+
+      if (!track) {
+       AliError(Form("Could not receive track %d", it));
+       continue;
+      }
+     
+      if (!AcceptTrack(track))
+       continue;
+
+      fHistTracksPt[fCentBin]->Fill(track->Pt()); 
+    }
+  }
+  
+  if (fCaloClusters) {
+    const Int_t nclusters = fCaloClusters->GetEntriesFast();
+    
+    for (Int_t ic = 0; ic < nclusters; ic++) {
+      AliVCluster *cluster = static_cast<AliVCluster*>(fCaloClusters->At(ic));
+      
+      if (!cluster) {
+       AliError(Form("Could not receive cluster %d", ic));
+       continue;
+      }
+
+      TLorentzVector nPart;
+      cluster->GetMomentum(nPart, fVertex);
+      fHistClustersPt[fCentBin]->Fill(nPart.Pt());
+    }
+  }
+
+  if (fJets) {
+    Int_t *sortedJets = GetSortedArray(fJets);
+
+    if (sortedJets) {
+      AliEmcalJet* leadJet = static_cast<AliEmcalJet*>(fJets->At(sortedJets[0]));
+      if (leadJet)
+       fHistLeadingJetPt[fCentBin]->Fill(leadJet->Pt());
+      else
+       AliError("Could not retrieve leading jet!");
+    }
+
+    const Int_t njets = fJets->GetEntriesFast();
+    for (Int_t ij = 0; ij < njets; ij++) {
+
+      AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(ij));
+      if (!jet) {
+       AliError(Form("Could not receive jet %d", ij));
+       continue;
+      }  
+
+      if (!AcceptJet(jet))
+       continue;
+
+      fHistJetsPtArea[fCentBin]->Fill(jet->Pt(), jet->Area());
+      fHistJetsPhiEta[fCentBin]->Fill(jet->Eta(), jet->Phi());
+
+      Float_t ptLeading = GetLeadingHadronPt(jet);
+      fHistJetsPtLeadHad[fCentBin]->Fill(jet->Pt(), ptLeading);
+
+      if (fRho) {
+       Float_t corrPt = jet->Pt() - fRhoVal * jet->Area();
+       fHistJetsCorrPtArea[fCentBin]->Fill(corrPt, jet->Area());
+      }
+    }
+  }
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskEmcalJetSample::Run()
+{
+  // Run analysis code here, if needed. It will be executed before FillHistograms().
+
+  return kTRUE;  // If return kFALSE FillHistogram() will NOT be executed.
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEmcalJetSample::Terminate(Option_t *) 
+{
+  // Called once at the end of the analysis.
+}
diff --git a/PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJetSample.h b/PWGJE/EMCALJetTasks/AliAnalysisTaskEmcalJetSample.h
new file mode 100644 (file)
index 0000000..46cb7a2
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef ALIANALYSISTASKEMCALJETSAMPLE_H
+#define ALIANALYSISTASKEMCALJETSAMPLE_H
+
+// $Id: AliAnalysisTaskEmcalJetSample.h  $
+
+class TH1;
+class TH2;
+
+#include "AliAnalysisTaskEmcalJet.h"
+
+class AliAnalysisTaskEmcalJetSample : public AliAnalysisTaskEmcalJet {
+ public:
+
+  AliAnalysisTaskEmcalJetSample();
+  AliAnalysisTaskEmcalJetSample(const char *name);
+  virtual ~AliAnalysisTaskEmcalJetSample();
+
+  void                        UserCreateOutputObjects();
+  void                        Terminate(Option_t *option);
+
+ protected:
+  Bool_t                      FillHistograms()   ;
+  Bool_t                      Run()              ;
+
+  // General histograms
+  TH1                        *fHistTracksPt[4];            //!Track pt spectrum
+  TH1                        *fHistClustersPt[4];          //!Cluster pt spectrum
+  TH1                        *fHistLeadingJetPt[4];        //!Leading jet pt spectrum
+  TH2                        *fHistJetsPhiEta[4];          //!Phi-Eta distribution of jets
+  TH2                        *fHistJetsPtArea[4];          //!Jet pt vs. area
+  TH2                        *fHistJetsPtLeadHad[4];       //!Jet pt vs. leading hadron
+  TH2                        *fHistJetsCorrPtArea[4];      //!Jet pt - bkg vs. area
+
+ private:
+  AliAnalysisTaskEmcalJetSample(const AliAnalysisTaskEmcalJetSample&);            // not implemented
+  AliAnalysisTaskEmcalJetSample &operator=(const AliAnalysisTaskEmcalJetSample&); // not implemented
+
+  ClassDef(AliAnalysisTaskEmcalJetSample, 1) // jet sample analysis task
+};
+#endif
index 64359f6..12bece6 100644 (file)
@@ -46,20 +46,21 @@ AliHadCorrTask::AliHadCorrTask() :
   // Default constructor.
 
   for(Int_t i=0; i<8; i++) {
-      fHistEsubPch[i]    = 0;
-      fHistEsubPchRat[i] = 0;
-    for(Int_t j=0; j<4; j++) {
-      fHistNCellsEnergy[i][j] = 0;
-    }
+    fHistEsubPch[i]    = 0;
+    fHistEsubPchRat[i] = 0;
+
     if (i<4) {
       fHistMatchEvsP[i]    = 0;
       fHistMatchdRvsEP[i]  = 0;
       fHistNMatchEnergy[i] = 0;
+
+      for(Int_t j=0; j<4; j++)
+       fHistNCellsEnergy[i][j] = 0;
     }
+    
     for(Int_t j=0; j<9; j++) {
-      for(Int_t k=0; k<2; k++) {
+      for(Int_t k=0; k<2; k++) 
        fHistMatchEtaPhi[i][j][k] = 0;
-      }
     }
   } 
 }
@@ -86,19 +87,21 @@ AliHadCorrTask::AliHadCorrTask(const char *name, Bool_t histo) :
   // Standard constructor.
 
   for(Int_t i=0; i<8; i++) {
+    fHistEsubPch[i]    = 0;
+    fHistEsubPchRat[i] = 0;
+
     if (i<4) {
-      fHistMatchEvsP[i]   = 0;
-      fHistMatchdRvsEP[i] = 0;
-      for(Int_t j=0; j<3; j++) {
+      fHistMatchEvsP[i]    = 0;
+      fHistMatchdRvsEP[i]  = 0;
+      fHistNMatchEnergy[i] = 0;
+
+      for(Int_t j=0; j<4; j++)
        fHistNCellsEnergy[i][j] = 0;
-      }
     }
-    fHistEsubPch[i]    = 0;
-    fHistEsubPchRat[i] = 0;
+    
     for(Int_t j=0; j<9; j++) {
-      for(Int_t k=0; k<2; k++) {
+      for(Int_t k=0; k<2; k++) 
        fHistMatchEtaPhi[i][j][k] = 0;
-      }
     }
   } 
   
index 4dd268f..e7955c5 100644 (file)
@@ -355,7 +355,7 @@ Bool_t AliJetResponseMaker::RetrieveEventObjects()
 
   Double_t pthard = fPythiaHeader->GetPtHard();
 
-  for (fPtHardBin = 0; fPtHardBin <= 11; fPtHardBin++) {
+  for (fPtHardBin = 0; fPtHardBin < 11; fPtHardBin++) {
     if (pthard >= ptHardLo[fPtHardBin] && pthard < ptHardHi[fPtHardBin])
       break;
   }
index b0082ab..26289b1 100644 (file)
@@ -242,12 +242,12 @@ void AliAnalysisTaskSAJF::UserCreateOutputObjects()
 
   PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
 
-  delete binsPt;
-  delete binsCorrPt;
-  delete binsArea;
-  delete binsEta;
-  delete binsPhi;
-  delete bins120;
+  delete[] binsPt;
+  delete[] binsCorrPt;
+  delete[] binsArea;
+  delete[] binsEta;
+  delete[] binsPhi;
+  delete[] bins120;
 }
 
 //________________________________________________________________________
diff --git a/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetSample.C b/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetSample.C
new file mode 100644 (file)
index 0000000..de755c9
--- /dev/null
@@ -0,0 +1,81 @@
+// $Id: AddTaskEmcalJetSample.C $
+
+AliAnalysisTaskEmcalJetSample* AddTaskEmcalJetSample(
+  const char *ntracks            = "Tracks",
+  const char *nclusters          = "CaloClusters",
+  const char *njets              = "Jets",
+  const char *nrho               = "Rho",
+  Double_t    jetradius          = 0.2,
+  Double_t    jetptcut           = 1,
+  Double_t    jetareacut         = 0.557,
+  UInt_t      type               = AliAnalysisTaskEmcal::kEMCAL,
+  Int_t       leadhadtype        = 0,
+  const char *taskname           = "AliAnalysisTaskEmcalJetSample"
+)
+{  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr)
+  {
+    ::Error("AddTaskEmcalJetSample", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler())
+  {
+    ::Error("AddTaskEmcalJetSample", "This task requires an input event handler");
+    return NULL;
+  }
+  
+  //-------------------------------------------------------
+  // Init the task and do settings
+  //-------------------------------------------------------
+
+  TString name(taskname);
+  if (strcmp(njets,"")) {
+    name += "_";
+    name += njets;
+  }
+  if (strcmp(nrho,"")) {
+    name += "_";
+    name += nrho;
+  }
+  if (type == AliAnalysisTaskEmcal::kTPC) 
+    name += "_TPC";
+  else if (type == AliAnalysisTaskEmcal::kEMCAL) 
+    name += "_EMCAL";
+  else if (type == AliAnalysisTaskEmcal::kUser) 
+    name += "_USER";
+
+  AliAnalysisTaskEmcalJetSample* jetTask = new AliAnalysisTaskEmcalJetSample(name);
+  jetTask->SetAnaType(type);
+  jetTask->SetTracksName(ntracks);
+  jetTask->SetClusName(nclusters);
+  jetTask->SetJetsName(njets);
+  jetTask->SetRhoName(nrho);
+  jetTask->SetJetRadius(jetradius);
+  jetTask->SetJetPtCut(jetptcut);
+  jetTask->SetPercAreaCut(jetareacut);
+  jetTask->SetLeadingHadronType(leadhadtype);
+  
+  //-------------------------------------------------------
+  // Final settings, pass to manager and set the containers
+  //-------------------------------------------------------
+  
+  mgr->AddTask(jetTask);
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
+  TString contname(name);
+  contname += "_histos";
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(), 
+                                                           TList::Class(),AliAnalysisManager::kOutputContainer,
+                                                           Form("%s", AliAnalysisManager::GetCommonFileName()));
+  mgr->ConnectInput  (jetTask, 0,  cinput1 );
+  mgr->ConnectOutput (jetTask, 1, coutput1 );
+  
+  return jetTask;
+}
index 226fc0b..72efac9 100644 (file)
@@ -7,6 +7,7 @@
 #pragma link off all functions;
 
 #pragma link C++ class AliAnalysisTaskEmcalJet+;
+#pragma link C++ class AliAnalysisTaskEmcalJetSample+;
 #pragma link C++ class AliAnalysisTaskRhoBase+;
 #pragma link C++ class AliAnalysisTaskRho+;
 #pragma link C++ class AliAnalysisTaskRhoFlow+;