o) making selector proof ready
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 May 2006 14:18:08 +0000 (14:18 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 May 2006 14:18:08 +0000 (14:18 +0000)
o) renamed selector class

PWG0/AliSelector.cxx
PWG0/AliSelector.h
PWG0/PWG0baseLinkDef.h
PWG0/dNdEta/AlidNdEtaCorrectionSelector.cxx [moved from PWG0/dNdEta/AlidNdEtaEffSelector.cxx with 72% similarity]
PWG0/dNdEta/AlidNdEtaCorrectionSelector.h [new file with mode: 0644]
PWG0/dNdEta/AlidNdEtaEffSelector.h [deleted file]
PWG0/dNdEta/dNdEtaCorrection.h
PWG0/dNdEta/makeCorrection2.C
PWG0/libPWG0base.pkg

index 508614ac51138d300a21a7e180947c92ceab967d..ff1ddccb9da02088b04a5e7c8ad1ae1eb44ca9fb 100644 (file)
@@ -40,15 +40,19 @@ AliSelector::AliSelector(TTree *) :
   fChain(0),
   fESD(0),
   fHeader(0),
-  fRunLoader(0),
-  fKineFile(0)
+  fKineFile(0),
+  fRunLoader(0)
 {
+  //
   // Constructor. Initialization of pointers
+  //
 }
 
 AliSelector::~AliSelector()
 {
-  // Remove all pointers
+  //
+  // Destructor
+  //
 
   // histograms are in the output list and deleted when the output
   // list is deleted by the TSelector dtor
@@ -59,8 +63,6 @@ void AliSelector::Begin(TTree *)
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).
-
-  //TString option = GetOption();
 }
 
 void AliSelector::SlaveBegin(TTree * tree)
@@ -202,6 +204,10 @@ void AliSelector::Terminate()
 
 TTree* AliSelector::GetKinematics()
 {
+  // Returns kinematics tree corresponding to current ESD active in fChain
+  // Loads the kinematics from the kinematics file, the file is identified by replacing "AliESDs" to
+  // "Kinematics" in the file path of the ESD file. This is a hack, to be changed!
+
   if (!fKineFile)
   {
     if (!fChain->GetCurrentFile())
@@ -253,6 +259,10 @@ TTree* AliSelector::GetKinematics()
 
 void AliSelector::DeleteKinematicsFile()
 {
+  //
+  // Closes the kinematics file and deletes the pointer.
+  //
+
   if (fKineFile)
   {
     fKineFile->Close();
@@ -263,6 +273,10 @@ void AliSelector::DeleteKinematicsFile()
 
 AliRun* AliSelector::GetAliRun()
 {
+  // Returns AliRun instance corresponding to current ESD active in fChain
+  // Loads galice.root, the file is identified by replacing "AliESDs" to
+  // "galice" in the file path of the ESD file. This is a hack, to be changed!
+
   if (!fRunLoader)
   {
     if (!fChain->GetCurrentFile())
@@ -283,6 +297,10 @@ AliRun* AliSelector::GetAliRun()
 
 void AliSelector::DeleteRunLoader()
 {
+  //
+  // deletes the runloader
+  //
+  
   if (fRunLoader)
   {
     fRunLoader->Delete();
index 97b2f5d5054ea3ae517e368598db28246f39a0ad..fcbcbdff5af2be43fb4e6836dba1a2cac24525e6 100644 (file)
@@ -30,16 +30,15 @@ class AliSelector : public TSelector {
 
     TChain          *fChain;   //! pointer to the analyzed TTree or TChain
 
-    AliESD*          fESD;
-    AliHeader*       fHeader;
-
-    AliRunLoader* fRunLoader;
+    AliESD*          fESD;     //! "ESD" branch in fChain
+    AliHeader*       fHeader;  //! "TE" branch in fChain, contains event header
 
  private:
   void DeleteKinematicsFile();
   void DeleteRunLoader();
 
-  TFile*           fKineFile;
+  TFile*        fKineFile;  //! pointer to Kinematics.root if the file was opened
+  AliRunLoader* fRunLoader;    //! pointer to the RunLoader if galice.root was opened
 
   ClassDef(AliSelector,0);
 };
index 5c92f27608fef547230b67a0bfd3db67eba688cb..efb6184553b7af271c35c5da1e55b1b87c1c7633 100644 (file)
@@ -10,7 +10,7 @@
  
 #pragma link C++ class AliSelector+;
 
-#pragma link C++ class AlidNdEtaEffSelector+;
+#pragma link C++ class AlidNdEtaCorrectionSelector+;
 #pragma link C++ class dNdEtaAnalysis+;
 #pragma link C++ class dNdEtaCorrection+;
 
similarity index 72%
rename from PWG0/dNdEta/AlidNdEtaEffSelector.cxx
rename to PWG0/dNdEta/AlidNdEtaCorrectionSelector.cxx
index 832b386dbe712b8db5ed415f39d0bd1dd2ffdb00..1b04957c3adaf68cf0bee12f31e1f59db23cd515 100644 (file)
@@ -1,4 +1,4 @@
-#include "AlidNdEtaEffSelector.h"
+#include "AlidNdEtaCorrectionSelector.h"
 
 #include <TStyle.h>
 #include <TSystem.h>
@@ -7,43 +7,44 @@
 #include <TParticlePDG.h>
 
 #include <AliLog.h>
-#include <../PYTHIA6/AliGenPythiaEventHeader.h>
-#include <../TPC/AliTPCtrack.h>
+#include <AliGenEventHeader.h>
 #include <AliTracker.h>
 
-#include <iostream>
-using namespace std;
+#include "../esdTrackCuts/AliESDtrackCuts.h"
+#include "dNdEtaCorrection.h"
 
-ClassImp(AlidNdEtaEffSelector)
+ClassImp(AlidNdEtaCorrectionSelector)
 
-AlidNdEtaEffSelector::AlidNdEtaEffSelector(TTree *) :
+AlidNdEtaCorrectionSelector::AlidNdEtaCorrectionSelector(TTree *) :
   AliSelector(),
   fEsdTrackCuts(0),
   fdNdEtaCorrection(0)
 {
+  //
   // Constructor. Initialization of pointers
+  //
 }
 
-AlidNdEtaEffSelector::~AlidNdEtaEffSelector()
+AlidNdEtaCorrectionSelector::~AlidNdEtaCorrectionSelector()
 {
-  // Remove all pointers
+  //
+  // Destructor
+  //
 
   // histograms are in the output list and deleted when the output
   // list is deleted by the TSelector dtor
 }
 
-void AlidNdEtaEffSelector::Begin(TTree * tree)
+void AlidNdEtaCorrectionSelector::Begin(TTree * tree)
 {
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).
 
   AliSelector::Begin(tree);
-
-  fdNdEtaCorrection = new dNdEtaCorrection();
 }
 
-void AlidNdEtaEffSelector::SlaveBegin(TTree * tree)
+void AlidNdEtaCorrectionSelector::SlaveBegin(TTree * tree)
 {
   // The SlaveBegin() function is called after the Begin() function.
   // When running with PROOF SlaveBegin() is called on each slave server.
@@ -51,21 +52,18 @@ void AlidNdEtaEffSelector::SlaveBegin(TTree * tree)
 
   AliSelector::SlaveBegin(tree);
 
-  fEsdTrackCuts = new AliESDtrackCuts();
-  fEsdTrackCuts->DefineHistograms(1);
+  fdNdEtaCorrection = new dNdEtaCorrection();
 
-  fEsdTrackCuts->SetMinNClustersTPC(50);
-  fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
-  fEsdTrackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
-  fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
+  if (fChain)
+    fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fChain->GetUserInfo()->FindObject("AliESDtrackCuts"));
 
-  fEsdTrackCuts->SetMinNsigmaToVertex(3);
-  fEsdTrackCuts->SetAcceptKingDaughters(kFALSE);
+  if (!fEsdTrackCuts)
+    printf("ERROR: Could not read EsdTrackCuts from user info\n");
 
   AliLog::SetClassDebugLevel("ESDtrackQualityCuts",1);
 }
 
-Bool_t AlidNdEtaEffSelector::Notify()
+Bool_t AlidNdEtaCorrectionSelector::Notify()
 {
   // The Notify() function is called when a new file is opened. This
   // can be either for a new TTree in a TChain or when when a new TTree
@@ -77,15 +75,16 @@ Bool_t AlidNdEtaEffSelector::Notify()
   if (AliSelector::Notify() == kFALSE)
     return kFALSE;
 
-  // ########################################################
-  // Magnetic field
-  AliTracker::SetFieldMap(GetAliRun()->Field(), kTRUE); // kTRUE means uniform magnetic field
-
   return kTRUE;
 }
 
-Bool_t AlidNdEtaEffSelector::IsPrimary(const TParticle* aParticle, Int_t aTotalPrimaries)
+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;
@@ -99,7 +98,7 @@ Bool_t AlidNdEtaEffSelector::IsPrimary(const TParticle* aParticle, Int_t aTotalP
   return kFALSE;
 }
 
-Bool_t AlidNdEtaEffSelector::Process(Long64_t entry)
+Bool_t AlidNdEtaCorrectionSelector::Process(Long64_t entry)
 {
   // The Process() function is called for each entry in the tree (or possibly
   // keyed object in the case of PROOF) to be processed. The entry argument
@@ -129,31 +128,25 @@ Bool_t AlidNdEtaEffSelector::Process(Long64_t entry)
   // get the EDS vertex
   const AliESDVertex* vtxESD = fESD->GetVertex();
 
-  Double_t vtx[3];
-  Double_t vtx_res[3];
-  vtxESD->GetXYZ(vtx);
+  // the vertex should be reconstructed
+  if (strcmp(vtxESD->GetName(),"default")==0)
+    return kTRUE;
 
+  Double_t vtx_res[3];
   vtx_res[0] = vtxESD->GetXRes();
   vtx_res[1] = vtxESD->GetYRes();
   vtx_res[2] = vtxESD->GetZRes();
 
-  // the vertex should be reconstructed
-  if (strcmp(vtxESD->GetName(),"default")==0)
-    return kTRUE;
-
   // the resolution should be reasonable???
   if (vtx_res[2]==0 || vtx_res[2]>0.1)
     return kTRUE;
 
   // ########################################################
   // get the MC vertex
-  AliGenPythiaEventHeader* genHeader = (AliGenPythiaEventHeader*) fHeader->GenEventHeader();
+  AliGenEventHeader* genHeader = fHeader->GenEventHeader();
 
   TArrayF vtxMC(3);
   genHeader->PrimaryVertex(vtxMC);
-  vtx[0] = vtxMC[0];
-  vtx[1] = vtxMC[1];
-  vtx[2] = vtxMC[2];
 
   // ########################################################
   // loop over mc particles
@@ -191,7 +184,7 @@ Bool_t AlidNdEtaEffSelector::Process(Long64_t entry)
     if (pdgPart->Charge() == 0)
       continue;
 
-    fdNdEtaCorrection->FillGene(vtx[2], particle->Eta());
+    fdNdEtaCorrection->FillGene(vtxMC[2], particle->Eta());
 
   }// end of mc particle
 
@@ -206,33 +199,23 @@ Bool_t AlidNdEtaEffSelector::Process(Long64_t entry)
     if (!fEsdTrackCuts->AcceptTrack(esdTrack))
       continue;
 
-    AliTPCtrack* tpcTrack = new AliTPCtrack(*esdTrack);
-    if (tpcTrack->GetAlpha()==0)
-    {
-      cout << " Warning esd track alpha = 0" << endl;
-      continue;
-    }
-
-    //Float_t theta = tpcTrack->Theta();
-    //Float_t eta   = -TMath::Log(TMath::Tan(theta/2.));
-
     // using the eta of the mc particle
     Int_t label = TMath::Abs(esdTrack->GetLabel());
-    if (label<0) 
+    if (label == 0)
     {
-      cout << " cannot find corresponding mc part !!! " << label << endl;
+      printf("WARNING: cannot find corresponding mc part for track %d.", t);
       continue;
     }
     particleTree->GetEntry(nTotal - nPrim + label);
 
-    fdNdEtaCorrection->FillMeas(vtx[2], particle->Eta());
+    fdNdEtaCorrection->FillMeas(vtxMC[2], particle->Eta());
 
   } // end of track loop
 
   return kTRUE;
 }
 
-void AlidNdEtaEffSelector::SlaveTerminate()
+void AlidNdEtaCorrectionSelector::SlaveTerminate()
 {
   // The SlaveTerminate() function is called after all entries or objects
   // have been processed. When running with PROOF SlaveTerminate() is called
@@ -246,9 +229,12 @@ void AlidNdEtaEffSelector::SlaveTerminate()
     printf("ERROR: Output list not initialized\n");
     return;
   }
+
+  fOutput->Add(fdNdEtaCorrection->GetGeneratedHistogram());
+  fOutput->Add(fdNdEtaCorrection->GetMeasuredHistogram());
 }
 
-void AlidNdEtaEffSelector::Terminate()
+void AlidNdEtaCorrectionSelector::Terminate()
 {
   // The Terminate() function is the last function to be called during
   // a query. It always runs on the client, it can be used to present
@@ -256,15 +242,26 @@ void AlidNdEtaEffSelector::Terminate()
 
   AliSelector::Terminate();
 
-  fdNdEtaCorrection->Finish();
+  fdNdEtaCorrectionFinal = new dNdEtaCorrection();
+  TH2F* measuredHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("etaVsVtx_meas"));
+  TH2F* generatedHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("etaVsVtx_gene"));
+  if (!measuredHistogram || !generatedHistogram)
+  {
+    printf("ERROR: Histograms not available %p %p\n", (void*) generatedHistogram, (void*) measuredHistogram);
+    return;
+  }
+  fdNdEtaCorrectionFinal->SetGeneratedHistogram(generatedHistogram);
+  fdNdEtaCorrectionFinal->SetMeasuredHistogram(measuredHistogram);
+
+  fdNdEtaCorrectionFinal->Finish();
 
   TFile* fout = new TFile("correction_map.root","RECREATE");
 
   fEsdTrackCuts->SaveHistograms("esd_track_cuts");
-  fdNdEtaCorrection->SaveHistograms();
+  fdNdEtaCorrectionFinal->SaveHistograms();
 
   fout->Write();
   fout->Close();
 
-  fdNdEtaCorrection->DrawHistograms();
+  fdNdEtaCorrectionFinal->DrawHistograms();
 }
diff --git a/PWG0/dNdEta/AlidNdEtaCorrectionSelector.h b/PWG0/dNdEta/AlidNdEtaCorrectionSelector.h
new file mode 100644 (file)
index 0000000..2f61e4a
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef ALIDNDETACORRECTIONSELECTOR_H
+#define ALIDNDETACORRECTIONSELECTOR_H
+
+#include "../AliSelector.h"
+
+class AliESDtrackCuts;
+class dNdEtaCorrection;
+
+class TParticle;
+
+class AlidNdEtaCorrectionSelector : public AliSelector {
+  public:
+    AlidNdEtaCorrectionSelector(TTree *tree=0);
+    virtual ~AlidNdEtaCorrectionSelector();
+
+    virtual void    Begin(TTree *tree);
+    virtual void    SlaveBegin(TTree *tree);
+    virtual Bool_t  Notify();
+    virtual Bool_t  Process(Long64_t entry);
+    virtual void    SlaveTerminate();
+    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)
+  dNdEtaCorrection* fdNdEtaCorrectionFinal; // contains the final histograms
+
+ private:
+
+  ClassDef(AlidNdEtaCorrectionSelector, 0);
+};
+
+#endif
diff --git a/PWG0/dNdEta/AlidNdEtaEffSelector.h b/PWG0/dNdEta/AlidNdEtaEffSelector.h
deleted file mode 100644 (file)
index 30d06bc..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef ALIDNDETAEFFSELECTOR_H
-#define ALIDNDETAEFFSELECTOR_H
-
-#include <TH2F.h>
-
-#include "../AliSelector.h"
-#include "../esdTrackCuts/AliESDtrackCuts.h"
-#include "dNdEtaCorrection.h"
-
-class TParticle;
-
-class AlidNdEtaEffSelector : public AliSelector {
-  public:
-    AlidNdEtaEffSelector(TTree *tree=0);
-    virtual ~AlidNdEtaEffSelector();
-
-    virtual void    Begin(TTree *tree);
-    virtual void    SlaveBegin(TTree *tree);
-    virtual Bool_t  Notify();
-    virtual Bool_t  Process(Long64_t entry);
-    virtual void    SlaveTerminate();
-    virtual void    Terminate();
-
- protected:
-  Bool_t IsPrimary(const TParticle* aParticle, Int_t aTotalPrimaries);
-
-  AliESDtrackCuts* fEsdTrackCuts;
-  dNdEtaCorrection* fdNdEtaCorrection;
-
- private:
-
-  ClassDef(AlidNdEtaEffSelector,0);
-};
-
-#endif
index 2091b85bdfedbe7e0d875b76b720e6975bb4cfc3..ccf7e7f1b2c4ce861e7badd14f3d5e27c23d3c0c 100644 (file)
@@ -40,6 +40,12 @@ protected:
 public:
   dNdEtaCorrection(Char_t* name="dndeta_correction");
 
+  TH2F* GetGeneratedHistogram() { return hEtaVsVtx_gene; }
+  TH2F* GetMeasuredHistogram() { return hEtaVsVtx_meas; }
+
+  void SetGeneratedHistogram(TH2F* aGeneratedHistogram) { hEtaVsVtx_gene = aGeneratedHistogram; }
+  void SetMeasuredHistogram(TH2F* aMeasuredHistogram) { hEtaVsVtx_meas = aMeasuredHistogram; }
+
   void FillMeas(Float_t vtx, Float_t eta) {hEtaVsVtx_meas->Fill(vtx, eta);}
   void FillGene(Float_t vtx, Float_t eta) {hEtaVsVtx_gene->Fill(vtx, eta);}
 
index d392882fa7b331475292a2bb4aa6f05c143bfa89..5f1e6472d9a54157f0b776d61f6683cfdc42cdf9 100644 (file)
@@ -11,11 +11,20 @@ void makeCorrection2(Char_t* dataDir, Int_t nRuns=20)
 {
   gSystem->Load("libPWG0base");
 
-  /*gSystem->Load("../esdTrackCuts/libESDtrackQuality.so");
-  gSystem->Load("libdNdEta.so");
-  gSystem->Load("../AliSelector_cxx.so");*/
-  //gSystem->Load("AlidNdEtaEffSelector_cxx.so");
-
   TChain* chain = CreateESDChain(dataDir, nRuns);
-  chain->Process("AlidNdEtaEffSelector.cxx+");
+
+  fEsdTrackCuts = new AliESDtrackCuts();
+  fEsdTrackCuts->DefineHistograms(1);
+
+  fEsdTrackCuts->SetMinNClustersTPC(50);
+  fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
+  fEsdTrackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
+  fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
+
+  fEsdTrackCuts->SetMinNsigmaToVertex(3);
+  fEsdTrackCuts->SetAcceptKingDaughters(kFALSE);
+
+  chain->GetUserInfo()->Add(fEsdTrackCuts);
+
+  chain->Process("AlidNdEtaCorrectionSelector.cxx+");
 }
index 93b91236eb06b2a34a6adca08bffd1d40efcf61e..2683d1cbc91a6799fa7cc01ae4db559af2804d7b 100644 (file)
@@ -1,5 +1,5 @@
 SRCS= AliSelector.cxx \
-      dNdEta/AlidNdEtaEffSelector.cxx \
+      dNdEta/AlidNdEtaCorrectionSelector.cxx \
       dNdEta/dNdEtaAnalysis.cxx \
       dNdEta/dNdEtaCorrection.cxx \
       esdTrackCuts/AliESDtrackCuts.cxx