From 79ab56b9a835738691120444d087de4251e36d5d Mon Sep 17 00:00:00 2001 From: jgrosseo Date: Tue, 16 May 2006 14:18:08 +0000 Subject: [PATCH] o) making selector proof ready o) renamed selector class --- PWG0/AliSelector.cxx | 28 ++++- PWG0/AliSelector.h | 9 +- PWG0/PWG0baseLinkDef.h | 2 +- ...or.cxx => AlidNdEtaCorrectionSelector.cxx} | 113 +++++++++--------- PWG0/dNdEta/AlidNdEtaCorrectionSelector.h | 36 ++++++ PWG0/dNdEta/AlidNdEtaEffSelector.h | 35 ------ PWG0/dNdEta/dNdEtaCorrection.h | 6 + PWG0/dNdEta/makeCorrection2.C | 21 +++- PWG0/libPWG0base.pkg | 2 +- 9 files changed, 141 insertions(+), 111 deletions(-) rename PWG0/dNdEta/{AlidNdEtaEffSelector.cxx => AlidNdEtaCorrectionSelector.cxx} (72%) create mode 100644 PWG0/dNdEta/AlidNdEtaCorrectionSelector.h delete mode 100644 PWG0/dNdEta/AlidNdEtaEffSelector.h diff --git a/PWG0/AliSelector.cxx b/PWG0/AliSelector.cxx index 508614ac511..ff1ddccb9da 100644 --- a/PWG0/AliSelector.cxx +++ b/PWG0/AliSelector.cxx @@ -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(); diff --git a/PWG0/AliSelector.h b/PWG0/AliSelector.h index 97b2f5d5054..fcbcbdff5af 100644 --- a/PWG0/AliSelector.h +++ b/PWG0/AliSelector.h @@ -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); }; diff --git a/PWG0/PWG0baseLinkDef.h b/PWG0/PWG0baseLinkDef.h index 5c92f27608f..efb6184553b 100644 --- a/PWG0/PWG0baseLinkDef.h +++ b/PWG0/PWG0baseLinkDef.h @@ -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+; diff --git a/PWG0/dNdEta/AlidNdEtaEffSelector.cxx b/PWG0/dNdEta/AlidNdEtaCorrectionSelector.cxx similarity index 72% rename from PWG0/dNdEta/AlidNdEtaEffSelector.cxx rename to PWG0/dNdEta/AlidNdEtaCorrectionSelector.cxx index 832b386dbe7..1b04957c3ad 100644 --- a/PWG0/dNdEta/AlidNdEtaEffSelector.cxx +++ b/PWG0/dNdEta/AlidNdEtaCorrectionSelector.cxx @@ -1,4 +1,4 @@ -#include "AlidNdEtaEffSelector.h" +#include "AlidNdEtaCorrectionSelector.h" #include #include @@ -7,43 +7,44 @@ #include #include -#include <../PYTHIA6/AliGenPythiaEventHeader.h> -#include <../TPC/AliTPCtrack.h> +#include #include -#include -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 (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 (fOutput->FindObject("etaVsVtx_meas")); + TH2F* generatedHistogram = dynamic_cast (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 index 00000000000..2f61e4a05de --- /dev/null +++ b/PWG0/dNdEta/AlidNdEtaCorrectionSelector.h @@ -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 index 30d06bc2925..00000000000 --- a/PWG0/dNdEta/AlidNdEtaEffSelector.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef ALIDNDETAEFFSELECTOR_H -#define ALIDNDETAEFFSELECTOR_H - -#include - -#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 diff --git a/PWG0/dNdEta/dNdEtaCorrection.h b/PWG0/dNdEta/dNdEtaCorrection.h index 2091b85bdfe..ccf7e7f1b2c 100644 --- a/PWG0/dNdEta/dNdEtaCorrection.h +++ b/PWG0/dNdEta/dNdEtaCorrection.h @@ -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);} diff --git a/PWG0/dNdEta/makeCorrection2.C b/PWG0/dNdEta/makeCorrection2.C index d392882fa7b..5f1e6472d9a 100644 --- a/PWG0/dNdEta/makeCorrection2.C +++ b/PWG0/dNdEta/makeCorrection2.C @@ -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+"); } diff --git a/PWG0/libPWG0base.pkg b/PWG0/libPWG0base.pkg index 93b91236eb0..2683d1cbc91 100644 --- a/PWG0/libPWG0base.pkg +++ b/PWG0/libPWG0base.pkg @@ -1,5 +1,5 @@ SRCS= AliSelector.cxx \ - dNdEta/AlidNdEtaEffSelector.cxx \ + dNdEta/AlidNdEtaCorrectionSelector.cxx \ dNdEta/dNdEtaAnalysis.cxx \ dNdEta/dNdEtaCorrection.cxx \ esdTrackCuts/AliESDtrackCuts.cxx -- 2.31.1