o) Adding class AlidNdEtaAnalysisMCSelector, which builds dNdEta plot from MC to...
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 May 2006 16:42:38 +0000 (16:42 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 May 2006 16:42:38 +0000 (16:42 +0000)
o) Moving IsPrimary to AliSelector

14 files changed:
PWG0/AliSelector.cxx
PWG0/AliSelector.h
PWG0/PWG0baseLinkDef.h
PWG0/dNdEta/AlidNdEtaAnalysisMCSelector.cxx [new file with mode: 0644]
PWG0/dNdEta/AlidNdEtaAnalysisMCSelector.h [new file with mode: 0644]
PWG0/dNdEta/AlidNdEtaAnalysisSelector.cxx
PWG0/dNdEta/AlidNdEtaAnalysisSelector.h
PWG0/dNdEta/AlidNdEtaCorrectionSelector.cxx
PWG0/dNdEta/AlidNdEtaCorrectionSelector.h
PWG0/dNdEta/dNdEtaAnalysis.cxx
PWG0/dNdEta/dNdEtaAnalysis.h
PWG0/dNdEta/makeCorrection2.C
PWG0/dNdEta/testAnalysis2.C
PWG0/libPWG0base.pkg

index 40ec47aca2489d322a2922e8969a65ba61e4f42f..7f679f3eeaf23bccaa7acb5a9598ca583e2e0b6f 100644 (file)
@@ -29,6 +29,8 @@
 #include <TCanvas.h>
 #include <TRegexp.h>
 #include <TTime.h>
+#include <TParticle.h>
+#include <TParticlePDG.h>
 
 #include <AliLog.h>
 
@@ -128,7 +130,7 @@ Bool_t AliSelector::Notify()
   AliDebug(AliLog::kDebug, Form("Time: %s", gSystem->Now().AsString()));
   
   TFile *f = fChain->GetCurrentFile();
-  AliDebug(AliLog::kDebug, f->GetName());
+  AliDebug(AliLog::kInfo, Form("Processing file %s", f->GetName()));
 
   DeleteKinematicsFile();
   DeleteRunLoader();
@@ -304,3 +306,39 @@ void AliSelector::DeleteRunLoader()
   }
 }
 
+Bool_t AliSelector::IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries) const
+{
+  //
+  // Returns if the given particle is a primary particle
+  // This function or a equivalent should be available in some common place of AliRoot
+  //
+
+  // if the particle has a daughter primary, we do not want to count it
+  if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
+    return kFALSE;
+
+  Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
+
+  // skip quarks and gluon
+  if (pdgCode <= 10 || pdgCode == 21)
+    return kFALSE;
+
+  if (strcmp(aParticle->GetName(),"XXX") == 0)
+  {
+    AliDebug(AliLog::kDebug, Form("WARNING: There is a particle named XXX."));
+    return kFALSE;
+  }
+
+  TParticlePDG* pdgPart = aParticle->GetPDG();
+
+  if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
+  {
+    AliDebug(AliLog::kDebug, Form("WARNING: There is a particle with an unknown particle class (pdg code %d).", pdgCode));
+    return kFALSE;
+  }
+
+  if (pdgPart->Charge() == 0)
+    return kFALSE;
+
+  return kTRUE;
+}
index fcbcbdff5af2be43fb4e6836dba1a2cac24525e6..14c63aafb063e753f646dd7d5470ba34fc439d84 100644 (file)
@@ -10,6 +10,8 @@
 #include <AliRun.h>
 #include <AliRunLoader.h>
 
+class TParticle;
+
 class AliSelector : public TSelector {
   public:
     AliSelector(TTree *tree=0);
@@ -28,6 +30,8 @@ class AliSelector : public TSelector {
     TTree*  GetKinematics();
     AliRun* GetAliRun();
 
+    Bool_t IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries) const;
+
     TChain          *fChain;   //! pointer to the analyzed TTree or TChain
 
     AliESD*          fESD;     //! "ESD" branch in fChain
index 286ce36fecbdcee11e078c9628a8e91c1ddc1fd8..30fb70554eece7b3d6a8c68b3aa6c3a605c5cfc1 100644 (file)
@@ -12,6 +12,7 @@
 
 #pragma link C++ class AlidNdEtaCorrectionSelector+;
 #pragma link C++ class AlidNdEtaAnalysisSelector+;
+#pragma link C++ class AlidNdEtaAnalysisMCSelector+;
 #pragma link C++ class dNdEtaAnalysis+;
 #pragma link C++ class dNdEtaCorrection+;
 
diff --git a/PWG0/dNdEta/AlidNdEtaAnalysisMCSelector.cxx b/PWG0/dNdEta/AlidNdEtaAnalysisMCSelector.cxx
new file mode 100644 (file)
index 0000000..c4cf94f
--- /dev/null
@@ -0,0 +1,73 @@
+#include "AlidNdEtaAnalysisMCSelector.h"
+
+#include <TStyle.h>
+#include <TSystem.h>
+#include <TCanvas.h>
+#include <TParticle.h>
+#include <TParticlePDG.h>
+#include <TVector3.h>
+
+#include <AliLog.h>
+#include <AliGenEventHeader.h>
+#include <AliTracker.h>
+
+#include "../esdTrackCuts/AliESDtrackCuts.h"
+#include "dNdEtaCorrection.h"
+#include "dNdEtaAnalysis.h"
+
+ClassImp(AlidNdEtaAnalysisMCSelector)
+
+AlidNdEtaAnalysisMCSelector::AlidNdEtaAnalysisMCSelector(TTree * tree) :
+  AlidNdEtaAnalysisSelector(tree)
+{
+  //
+  // Constructor. Initialization of pointers
+  //
+}
+
+AlidNdEtaAnalysisMCSelector::~AlidNdEtaAnalysisMCSelector()
+{
+  //
+  // Destructor
+  //
+}
+
+Bool_t AlidNdEtaAnalysisMCSelector::Process(Long64_t entry)
+{
+  //
+
+  if (AliSelector::Process(entry) == kFALSE)
+    return kFALSE;
+
+  TTree* particleTree = GetKinematics();
+  if (!fHeader || !particleTree)
+    return kFALSE;
+
+  // get the MC vertex
+  AliGenEventHeader* genHeader = fHeader->GenEventHeader();
+
+  TArrayF vtxMC(3);
+  genHeader->PrimaryVertex(vtxMC);
+
+  TParticle* particle = 0;
+  particleTree->SetBranchAddress("Particles", &particle);
+
+  Int_t nPrim  = fHeader->GetNprimary();
+  Int_t nTotal = fHeader->GetNtrack();
+
+  for (Int_t i_mc = nTotal - nPrim; i_mc < nTotal; ++i_mc)
+  {
+    particleTree->GetEntry(i_mc);
+
+    if (!particle)
+      continue;
+
+    if (IsPrimaryCharged(particle, nPrim) == kFALSE)
+      continue;
+
+    fdNdEtaAnalysis->FillTrack(vtxMC[2], particle->Eta(), 1);
+  }
+  fdNdEtaAnalysis->FillEvent(vtxMC[2]);
+
+  return kTRUE;
+}
diff --git a/PWG0/dNdEta/AlidNdEtaAnalysisMCSelector.h b/PWG0/dNdEta/AlidNdEtaAnalysisMCSelector.h
new file mode 100644 (file)
index 0000000..2ff873d
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef ALIDNDETAANALYSISSELECTORMC_H
+#define ALIDNDETAANALYSISSELECTORMC_H
+
+#include "AlidNdEtaAnalysisSelector.h"
+
+class AlidNdEtaAnalysisMCSelector : public AlidNdEtaAnalysisSelector {
+  public:
+    AlidNdEtaAnalysisMCSelector(TTree *tree=0);
+    virtual ~AlidNdEtaAnalysisMCSelector();
+
+    virtual Bool_t  Process(Long64_t entry);
+
+ protected:
+
+ private:
+
+  ClassDef(AlidNdEtaAnalysisMCSelector, 0);
+};
+
+#endif
index a782072c2aa2577d07cabbb7559efd730d55b18a..208b04c773148e8dbf4026db126d8ae60f43edac 100644 (file)
@@ -3,8 +3,6 @@
 #include <TStyle.h>
 #include <TSystem.h>
 #include <TCanvas.h>
-#include <TParticle.h>
-#include <TParticlePDG.h>
 #include <TVector3.h>
 
 #include <AliLog.h>
@@ -128,7 +126,7 @@ Bool_t AlidNdEtaAnalysisSelector::Process(Long64_t entry)
       continue;
 
     Double_t p[3];
-    esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuter
+    esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuterPxPyPy
     TVector3 vector(p);
 
     Float_t theta = vector.Theta();
index 3f4d8885594e44bd270ceae0913841e057b486c5..7c527b89e22691f658b19ffa254621bef498eed2 100644 (file)
@@ -7,8 +7,6 @@ class AliESDtrackCuts;
 class dNdEtaCorrection;
 class dNdEtaAnalysis;
 
-class TParticle;
-
 class AlidNdEtaAnalysisSelector : public AliSelector {
   public:
     AlidNdEtaAnalysisSelector(TTree *tree=0);
index 238a066bfe4b68adf1d10046742b3305582e0c16..f4dce81850659d0b73b3165b5f886d3ad0f3ba11 100644 (file)
@@ -77,26 +77,6 @@ Bool_t AlidNdEtaCorrectionSelector::Notify()
   return kTRUE;
 }
 
-Bool_t AlidNdEtaCorrectionSelector::IsPrimary(const TParticle* aParticle, Int_t aTotalPrimaries)
-{
-  //
-  // Returns if the given particle is a primary particle
-  // This function or a equivalent should be available in some common place of AliRoot
-  //
-
-  // if the particle has a daughter primary, we do not want to count it
-  if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
-    return kFALSE;
-
-  Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
-
-  // skip quarks and gluon
-  if (pdgCode > 10 && pdgCode != 21)
-    return kTRUE;
-
-  return kFALSE;
-}
-
 Bool_t AlidNdEtaCorrectionSelector::Process(Long64_t entry)
 {
   // The Process() function is called for each entry in the tree (or possibly
@@ -179,28 +159,10 @@ Bool_t AlidNdEtaCorrectionSelector::Process(Long64_t entry)
     if (!particle)
       continue;
 
-    if (strcmp(particle->GetName(),"XXX") == 0)
-    {
-       AliDebug(AliLog::kWarning, Form("WARNING: There is a particle named XXX (%d).", i_mc));
-      continue;
-    }
-
-    TParticlePDG* pdgPart = particle->GetPDG();
-
-    if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
-    {
-       AliDebug(AliLog::kError, Form("WARNING: There is a particle with an unknown particle class (%d pdg code %d).", i_mc, particle->GetPdgCode()));
-      continue;
-    }
-
-    if (IsPrimary(particle, nPrim) == kFALSE)
-      continue;
-
-    if (pdgPart->Charge() == 0)
+    if (IsPrimaryCharged(particle, nPrim) == kFALSE)
       continue;
 
     fdNdEtaCorrection->FillGene(vtxMC[2], particle->Eta());
-
   }// end of mc particle
 
   // ########################################################
index 2f61e4a05de564cdcf076b3fc2c5e493f5e3e11c..3eba78c7b1e2f294f27dadd7ed4bbc4b04023cab 100644 (file)
@@ -21,8 +21,6 @@ class AlidNdEtaCorrectionSelector : public AliSelector {
     virtual void    Terminate();
 
  protected:
-  Bool_t IsPrimary(const TParticle* aParticle, Int_t aTotalPrimaries);
-
   AliESDtrackCuts*  fEsdTrackCuts;          // Object containing the parameters of the esd track cuts
 
   dNdEtaCorrection* fdNdEtaCorrection;      // contains the intermediate histograms (on each slave)
index 076baa2e5a15645d31f6042f2fad3c9adbe0d802..3d0590a550d8e3547026a18168533a277a864a84 100644 (file)
@@ -15,14 +15,13 @@ dNdEtaAnalysis::dNdEtaAnalysis(Char_t* name) {
   fName = TString(name);
 
   hEtaVsVtx  = new TH2F("eta_vs_vtx","",80,-20,20,120,-6,6);
-  hEtaVsVtxUncorrected = new TH2F("eta_vs_vtx_uncorrected","",80,-20,20,120,-6,6);
-  hVtx       = hEtaVsVtx->ProjectionX("vtx");
-  hdNdEta    = hEtaVsVtx->ProjectionY("dNdEta");
   hEtaVsVtx->SetXTitle("vtx z [cm]");
   hEtaVsVtx->SetYTitle("#eta");
-  hVtx->SetXTitle("vtx z [cm]");
-  hdNdEta->SetXTitle("#eta");
+
+  hEtaVsVtxUncorrected = dynamic_cast<TH2F*> (hEtaVsVtx->Clone("eta_vs_vtx_uncorrected"));
+  hVtx       = hEtaVsVtx->ProjectionX("vtx");
+  hdNdEta    = hEtaVsVtx->ProjectionY("dNdEta");
+
   hdNdEta->SetYTitle("dN/d#eta");
 
   hEtaVsVtx->Sumw2();
index 067abf8bf3d530aafc56dcb2ae16f81591279b0e..aeff7068ce51ef6a5d68adcc88738b78bfaf0f18 100644 (file)
@@ -14,6 +14,7 @@
 // - add functionality to set the bin sizes
 // - figure out correct way to treat the errors
 // - add functionality to make dn/deta for different mult classes?
+// - implement destructor
 
 #include <TObject.h>
 #include <TString.h>
index dcf5bcf7953520cbe17718de500d84b4322c808f..997c6b2d4b39103c679991f2d4687c4fc5448355 100644 (file)
@@ -26,6 +26,6 @@ void makeCorrection2(Char_t* dataDir, Int_t nRuns=20)
 
   chain->GetUserInfo()->Add(fEsdTrackCuts);
 
-  AliLog::SetClassDebugLevel("AlidNdEtaCorrectionSelector", AliLog::kWarning);
+  AliLog::SetClassDebugLevel("AlidNdEtaCorrectionSelector", AliLog::kInfo);
   chain->Process("AlidNdEtaCorrectionSelector.cxx+");
 }
index c4d0c282bd1063838fd067953fbd962e95a1f3f9..bee0f439b1c9d7c8fb4de635b8aad82c650a68ca 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "../CreateESDChain.C"
 
-testAnalysis2(Char_t* dataDir, Int_t nRuns=20)
+testAnalysis2(Char_t* dataDir, Int_t nRuns=20, Bool_t aMC = kFALSE)
 {
   gSystem->Load("libPWG0base");
 
@@ -35,7 +35,9 @@ testAnalysis2(Char_t* dataDir, Int_t nRuns=20)
 
   chain->GetUserInfo()->Add(dNdEtaCorrection);
 
-  AliLog::SetClassDebugLevel("AlidNdEtaAnalysisSelector", AliLog::kWarning);
-  
-  chain->Process("AlidNdEtaAnalysisSelector.cxx+");
+  TString selectorName = ((aMC == kFALSE) ? "AlidNdEtaAnalysisSelector" : "AlidNdEtaAnalysisMCSelector");
+
+  AliLog::SetClassDebugLevel(selectorName, AliLog::kInfo);
+
+  chain->Process(selectorName + ".cxx+");
 }
index 26611dbecb478115984c6e766dd3834e6ad127c1..0dbd8240b9b75a9a33281b79e48cd75f1b6ef7e9 100644 (file)
@@ -1,6 +1,7 @@
 SRCS= AliSelector.cxx \
       dNdEta/AlidNdEtaCorrectionSelector.cxx \
       dNdEta/AlidNdEtaAnalysisSelector.cxx \
+      dNdEta/AlidNdEtaAnalysisMCSelector.cxx \
       dNdEta/dNdEtaAnalysis.cxx \
       dNdEta/dNdEtaCorrection.cxx \
       esdTrackCuts/AliESDtrackCuts.cxx