3 #include "AlidNdEtaVertexRecEffSelector.h"
12 #include <AliGenEventHeader.h>
13 #include <AliHeader.h>
15 #include <AliESDVertex.h>
17 #include "AliPWG0Helper.h"
20 // This class plots the vertex reconstruction efficiency
21 // If a vertex was reconstructed is decided by the function CheckVertex()
22 // In any case the *generated* multiplicity is filled into the histogram
25 ClassImp(AlidNdEtaVertexRecEffSelector)
27 const Float_t AlidNdEtaVertexRecEffSelector::fkEtaRange = 0.9;
29 AlidNdEtaVertexRecEffSelector::AlidNdEtaVertexRecEffSelector() :
37 // Constructor. Initialization of pointers
41 AlidNdEtaVertexRecEffSelector::~AlidNdEtaVertexRecEffSelector()
47 // histograms are in the output list and deleted when the output
48 // list is deleted by the TSelector dtor
51 void AlidNdEtaVertexRecEffSelector::SlaveBegin(TTree * tree)
53 // initializes the histograms
55 AliSelectorRL::SlaveBegin(tree);
57 fdNGen = new TH1F("dNGen", "dNGen", 90, 0, 50);
58 fdNRec = dynamic_cast<TH1F*>(fdNGen->Clone("dNRec"));
60 fdNGen->SetTitle("Generated Events;dN_{Gen};Count");
61 fdNRec->SetTitle("Events with reconstructed vertex;dN_{Gen};Count");
63 fVtxGen = new TH1F("VtxGen", "VtxGen", 200, -20, 20);
64 fVtxRec = dynamic_cast<TH1F*>(fVtxGen->Clone("VtxRec"));
67 Bool_t AlidNdEtaVertexRecEffSelector::CheckVertex()
70 // check if the vertex has been reconstructed well enough
75 const AliESDVertex* vtxESD = fESD->GetVertex();
77 // the vertex should be reconstructed
78 if (strcmp(vtxESD->GetName(),"default")==0)
82 vtxRes[0] = vtxESD->GetXRes();
83 vtxRes[1] = vtxESD->GetYRes();
84 vtxRes[2] = vtxESD->GetZRes();
86 // the resolution should be reasonable???
87 if (vtxRes[2]==0 || vtxRes[2]>0.1)
93 Bool_t AlidNdEtaVertexRecEffSelector::Process(Long64_t entry)
96 // fills fdNGen and fdNRec
99 if (AliSelectorRL::Process(entry) == kFALSE)
102 // check prerequisites
105 AliDebug(AliLog::kError, "ESD branch not available");
109 AliHeader* header = GetHeader();
112 AliDebug(AliLog::kError, "Header not available");
117 // loop over mc particles
118 TTree* particleTree = GetKinematics();
119 TParticle* particle = 0;
120 particleTree->SetBranchAddress("Particles", &particle);
122 Int_t nPrim = header->GetNprimary();
123 Int_t nTotal = header->GetNtrack();
127 for (Int_t iMc = nTotal - nPrim; iMc < nTotal; ++iMc)
129 particleTree->GetEntry(iMc);
134 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
137 if (TMath::Abs(particle->Eta()) < fkEtaRange)
139 }// end of mc particle
141 Float_t dN = (Float_t) n / (fkEtaRange*2);
145 // check vertex reconstruction
146 if (CheckVertex() != kFALSE)
149 AliGenEventHeader* genHeader = header->GenEventHeader();
152 genHeader->PrimaryVertex(vtxMC);
154 fVtxGen->Fill(vtxMC[2]);
156 if (CheckVertex() != kFALSE)
157 fVtxRec->Fill(vtxMC[2]);
162 void AlidNdEtaVertexRecEffSelector::SlaveTerminate()
164 // The SlaveTerminate() function is called after all entries or objects
165 // have been processed. When running with PROOF SlaveTerminate() is called
166 // on each slave server.
168 AliSelectorRL::SlaveTerminate();
170 // Add the histograms to the output on each slave server
173 AliDebug(AliLog::kError, "ERROR: Output list not initialized");
177 fOutput->Add(fdNGen);
178 fOutput->Add(fdNRec);
179 fOutput->Add(fVtxGen);
180 fOutput->Add(fVtxRec);
183 void AlidNdEtaVertexRecEffSelector::Terminate()
185 // The Terminate() function is the last function to be called during
186 // a query. It always runs on the client, it can be used to present
187 // the results graphically or save the results to file.
189 AliSelectorRL::Terminate();
193 AliDebug(AliLog::kError, "ERROR: Output list not initialized");
197 fdNGen = dynamic_cast<TH1F*> (fOutput->FindObject("dNGen"));
198 fdNRec = dynamic_cast<TH1F*> (fOutput->FindObject("dNRec"));
199 fVtxGen = dynamic_cast<TH1F*> (fOutput->FindObject("VtxGen"));
200 fVtxRec = dynamic_cast<TH1F*> (fOutput->FindObject("VtxRec"));
201 if (!fdNGen || !fdNRec || !fVtxGen || !fVtxRec)
203 AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p %p %p %p", (void*) fdNGen, (void*) fdNRec, (void*) fVtxGen, (void*) fVtxRec));
207 TFile* fout = new TFile("vertexRecEff.root","RECREATE");
218 TCanvas* canvas = new TCanvas("dN", "dN", 900, 450);
219 canvas->Divide(2, 1);
223 fdNRec->SetLineColor(kRed);
224 fdNRec->Draw("SAME");
228 fVtxRec->SetLineColor(kRed);
229 fVtxRec->Draw("SAME");