From 43a9a46280103dc4de787905e8d26d1aad887fb8 Mon Sep 17 00:00:00 2001 From: jgrosseo Date: Wed, 26 Jul 2006 16:37:55 +0000 Subject: [PATCH] adding multipicity from mc, and creation of correlation map for the corrections --- PWG0/PWG0selectorsLinkDef.h | 1 + PWG0/dNdEta/AliMultiplicityMCSelector.cxx | 238 ++++++++++++++++++++++ PWG0/dNdEta/AliMultiplicityMCSelector.h | 38 ++++ PWG0/libPWG0selectors.pkg | 1 + 4 files changed, 278 insertions(+) create mode 100644 PWG0/dNdEta/AliMultiplicityMCSelector.cxx create mode 100644 PWG0/dNdEta/AliMultiplicityMCSelector.h diff --git a/PWG0/PWG0selectorsLinkDef.h b/PWG0/PWG0selectorsLinkDef.h index ced196a0c72..6f176cd6940 100644 --- a/PWG0/PWG0selectorsLinkDef.h +++ b/PWG0/PWG0selectorsLinkDef.h @@ -13,6 +13,7 @@ #pragma link C++ class AlidNdEtaAnalysisESDSelector+; #pragma link C++ class AlidNdEtaVertexRecEffSelector+; #pragma link C++ class AliMultiplicityESDSelector+; +#pragma link C++ class AliMultiplicityMCSelector+; #pragma link C++ class AlidNdEtaSystematicsSelector+; #endif diff --git a/PWG0/dNdEta/AliMultiplicityMCSelector.cxx b/PWG0/dNdEta/AliMultiplicityMCSelector.cxx new file mode 100644 index 00000000000..f1b44ba9459 --- /dev/null +++ b/PWG0/dNdEta/AliMultiplicityMCSelector.cxx @@ -0,0 +1,238 @@ +/* $Id$ */ + +#include "AliMultiplicityMCSelector.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "esdTrackCuts/AliESDtrackCuts.h" +#include "AliPWG0Helper.h" + +ClassImp(AliMultiplicityMCSelector) + +AliMultiplicityMCSelector::AliMultiplicityMCSelector() : + AliSelectorRL(), + fMultiplicityESD(0), + fMultiplicityMC(0), + fCorrelation(0), + fEsdTrackCuts(0) +{ + // + // Constructor. Initialization of pointers + // +} + +AliMultiplicityMCSelector::~AliMultiplicityMCSelector() +{ + // + // Destructor + // + + // histograms are in the output list and deleted when the output + // list is deleted by the TSelector dtor +} + +void AliMultiplicityMCSelector::Begin(TTree* tree) +{ + // Begin function + + AliSelectorRL::Begin(tree); + + ReadUserObjects(tree); +} + +void AliMultiplicityMCSelector::ReadUserObjects(TTree* tree) +{ + // read the user objects, called from slavebegin and begin + + if (!fEsdTrackCuts && fInput) + fEsdTrackCuts = dynamic_cast (fInput->FindObject("AliESDtrackCuts")); + + if (!fEsdTrackCuts && tree) + fEsdTrackCuts = dynamic_cast (tree->GetUserInfo()->FindObject("AliESDtrackCuts")); + + if (!fEsdTrackCuts) + AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list."); +} + +void AliMultiplicityMCSelector::SlaveBegin(TTree* tree) +{ + // The SlaveBegin() function is called after the Begin() function. + // When running with PROOF SlaveBegin() is called on each slave server. + // The tree argument is deprecated (on PROOF 0 is passed). + + AliSelector::SlaveBegin(tree); + + ReadUserObjects(tree); + + fMultiplicityESD = new TH1F("fMultiplicityESD", "fMultiplicityESD;Ntracks;Count", 201, -0.5, 200.5); + fMultiplicityMC = new TH1F("fMultiplicityMC", "fMultiplicityMC;Npart;Count", 201, -0.5, 200.5); + + fCorrelation = new TH2F("fCorrelation", "fCorrelation;Npart;Ntracks", 201, -0.5, 200.5, 201, -0.5, 200.5); +} + +Bool_t AliMultiplicityMCSelector::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 + // specifies which entry in the currently loaded tree is to be processed. + // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() + // to read either all or the required parts of the data. When processing + // keyed objects with PROOF, the object is already loaded and is available + // via the fObject pointer. + // + // This function should contain the "body" of the analysis. It can contain + // simple or elaborate selection criteria, run algorithms on the data + // of the event and typically fill histograms. + + // WARNING when a selector is used with a TChain, you must use + // the pointer to the current TTree to call GetEntry(entry). + // The entry is always the local entry number in the current tree. + // Assuming that fTree is the pointer to the TChain being processed, + // use fTree->GetTree()->GetEntry(entry). + + if (AliSelectorRL::Process(entry) == kFALSE) + return kFALSE; + + // Check prerequisites + if (!fESD) + { + AliDebug(AliLog::kError, "ESD branch not available"); + return kFALSE; + } + + if (!fEsdTrackCuts) + { + AliDebug(AliLog::kError, "fESDTrackCuts not available"); + return kFALSE; + } + + AliStack* stack = GetStack(); + if (!stack) + { + AliDebug(AliLog::kError, "Stack not available"); + return kFALSE; + } + + if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE) + return kTRUE; + + if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE) + return kTRUE; + + // TODO put pt cut + + // get number of "good" tracks from ESD + Int_t nESDTracks = fEsdTrackCuts->CountAcceptedTracks(fESD); + fMultiplicityESD->Fill(nESDTracks); + + // get number of tracks from MC + // loop over mc particles + Int_t nPrim = stack->GetNprimary(); + Int_t nMCTracks = 0; + for (Int_t iMc = 0; iMc < nPrim; ++iMc) + { + AliDebug(AliLog::kDebug+1, Form("MC Loop: Processing particle %d.", iMc)); + + TParticle* particle = stack->Particle(iMc); + + if (!particle) + { + AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (mc loop).", iMc)); + continue; + } + + if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE) + continue; + + Float_t eta = particle->Eta(); + + if (TMath::Abs(eta) > 0.9) + continue; + + nMCTracks++; + }// end of mc particle + + fMultiplicityMC->Fill(nMCTracks); + + fCorrelation->Fill(nMCTracks, nESDTracks); + + return kTRUE; +} + +void AliMultiplicityMCSelector::SlaveTerminate() +{ + // The SlaveTerminate() function is called after all entries or objects + // have been processed. When running with PROOF SlaveTerminate() is called + // on each slave server. + + AliSelector::SlaveTerminate(); + + // Add the histograms to the output on each slave server + if (!fOutput) + { + AliDebug(AliLog::kError, Form("ERROR: Output list not initialized.")); + return; + } + + fOutput->Add(fMultiplicityESD); + fOutput->Add(fMultiplicityMC); + fOutput->Add(fCorrelation); +} + +void AliMultiplicityMCSelector::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 + // the results graphically or save the results to file. + + AliSelector::Terminate(); + + fOutput->Print(); + + fMultiplicityESD = dynamic_cast (fOutput->FindObject("fMultiplicityESD")); + fMultiplicityMC = dynamic_cast (fOutput->FindObject("fMultiplicityMC")); + fCorrelation = dynamic_cast (fOutput->FindObject("fCorrelation")); + + if (!fMultiplicityESD || !fMultiplicityMC || !fCorrelation) + { + AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p %p %p", (void*) fMultiplicityESD, (void*) fMultiplicityMC, (void*) fCorrelation)); + return; + } + + TCanvas* canvas = new TCanvas("AliMultiplicityMCSelector", "AliMultiplicityMCSelector", 1000, 1000); + canvas->Divide(2, 2); + + canvas->cd(1); + fMultiplicityESD->Draw(); + fMultiplicityMC->SetLineColor(2); + fMultiplicityMC->Draw("SAME"); + + canvas->cd(2); + TH1F* ratio = dynamic_cast (fMultiplicityESD->Clone("multiplicity_ratio")); + ratio->SetTitle("ratio;Ntracks;Nreco/Ngene"); + ratio->Divide(fMultiplicityMC); + ratio->Draw(); + + canvas->cd(3); + fCorrelation->Draw("COLZ"); + + TFile* file = TFile::Open("multiplicity.root", "RECREATE"); + + fMultiplicityMC->Write(); + fMultiplicityESD->Write(); + fCorrelation->Write(); + + file->Close(); +} diff --git a/PWG0/dNdEta/AliMultiplicityMCSelector.h b/PWG0/dNdEta/AliMultiplicityMCSelector.h new file mode 100644 index 00000000000..941ad55abed --- /dev/null +++ b/PWG0/dNdEta/AliMultiplicityMCSelector.h @@ -0,0 +1,38 @@ +/* $Id$ */ + +#ifndef ALIMULTIPLICITYMCSELECTOR_H +#define ALIMULTIPLICITYMCSELECTOR_H + +#include "AliSelectorRL.h" + +class AliESDtrackCuts; +class TH1F; +class TH2F; + +class AliMultiplicityMCSelector : public AliSelectorRL { + public: + AliMultiplicityMCSelector(); + virtual ~AliMultiplicityMCSelector(); + + virtual void Begin(TTree* tree); + virtual void SlaveBegin(TTree *tree); + virtual Bool_t Process(Long64_t entry); + virtual void SlaveTerminate(); + virtual void Terminate(); + + protected: + void ReadUserObjects(TTree* tree); + + TH1F* fMultiplicityESD; // multiplicity histogram + TH1F* fMultiplicityMC; // multiplicity histogram + + TH2F* fCorrelation; // (gene multiplicity) vs (meas multiplicity) + + AliESDtrackCuts* fEsdTrackCuts; // Object containing the parameters of the esd track cuts + + private: + + ClassDef(AliMultiplicityMCSelector, 0); +}; + +#endif diff --git a/PWG0/libPWG0selectors.pkg b/PWG0/libPWG0selectors.pkg index 099367c3c06..423002c4d70 100644 --- a/PWG0/libPWG0selectors.pkg +++ b/PWG0/libPWG0selectors.pkg @@ -8,6 +8,7 @@ HDRS = dNdEta/AlidNdEtaCorrectionSelector.h \ dNdEta/AlidNdEtaAnalysisESDSelector.h \ dNdEta/AlidNdEtaVertexRecEffSelector.h \ dNdEta/AliMultiplicityESDSelector.h \ + dNdEta/AliMultiplicityMCSelector.h \ dNdEta/AlidNdEtaSystematicsSelector.h SRCS = $(HDRS:.h=.cxx) -- 2.31.1