]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
75e130df | 3 | #include "AlidNdEtaAnalysisSelector.h" |
4 | ||
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
75e130df | 8 | #include <TVector3.h> |
dc740de4 | 9 | #include <TH2F.h> |
75e130df | 10 | |
11 | #include <AliLog.h> | |
12 | #include <AliGenEventHeader.h> | |
75e130df | 13 | |
75e130df | 14 | #include "dNdEtaAnalysis.h" |
15 | ||
16 | ClassImp(AlidNdEtaAnalysisSelector) | |
17 | ||
dc740de4 | 18 | AlidNdEtaAnalysisSelector::AlidNdEtaAnalysisSelector() : |
75e130df | 19 | AliSelector(), |
75e130df | 20 | fdNdEtaAnalysis(0), |
75e130df | 21 | fdNdEtaAnalysisFinal(0) |
22 | { | |
23 | // | |
24 | // Constructor. Initialization of pointers | |
25 | // | |
26 | } | |
27 | ||
28 | AlidNdEtaAnalysisSelector::~AlidNdEtaAnalysisSelector() | |
29 | { | |
30 | // | |
31 | // Destructor | |
32 | // | |
33 | ||
34 | // histograms are in the output list and deleted when the output | |
35 | // list is deleted by the TSelector dtor | |
36 | } | |
37 | ||
38 | void AlidNdEtaAnalysisSelector::SlaveBegin(TTree * tree) | |
39 | { | |
40 | // The SlaveBegin() function is called after the Begin() function. | |
41 | // When running with PROOF SlaveBegin() is called on each slave server. | |
42 | // The tree argument is deprecated (on PROOF 0 is passed). | |
43 | ||
44 | AliSelector::SlaveBegin(tree); | |
45 | ||
46 | fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta"); | |
75e130df | 47 | } |
48 | ||
49 | void AlidNdEtaAnalysisSelector::SlaveTerminate() | |
50 | { | |
51 | // The SlaveTerminate() function is called after all entries or objects | |
52 | // have been processed. When running with PROOF SlaveTerminate() is called | |
53 | // on each slave server. | |
54 | ||
55 | AliSelector::SlaveTerminate(); | |
56 | ||
57 | // Add the histograms to the output on each slave server | |
58 | if (!fOutput) | |
59 | { | |
b8e8168f | 60 | AliDebug(AliLog::kError, Form("ERROR: Output list not initialized.")); |
75e130df | 61 | return; |
62 | } | |
63 | ||
64 | fOutput->Add(fdNdEtaAnalysis->GetEtaVsVtxHistogram()); | |
65 | fOutput->Add(fdNdEtaAnalysis->GetEtaVsVtxUncorrectedHistogram()); | |
66 | fOutput->Add(fdNdEtaAnalysis->GetVtxHistogram()); | |
67 | ||
68 | fdNdEtaAnalysis->GetVtxHistogram()->Print(); | |
69 | fOutput->Print(); | |
70 | } | |
71 | ||
72 | void AlidNdEtaAnalysisSelector::Terminate() | |
73 | { | |
74 | // The Terminate() function is the last function to be called during | |
75 | // a query. It always runs on the client, it can be used to present | |
76 | // the results graphically or save the results to file. | |
77 | ||
78 | AliSelector::Terminate(); | |
79 | ||
80 | TH2F* etaVsVtxHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("eta_vs_vtx")); | |
81 | TH2F* etaVsVtxUncorrectedHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("eta_vs_vtx_uncorrected")); | |
82 | TH1D* vtxHistogram = dynamic_cast<TH1D*> (fOutput->FindObject("vtx")); | |
83 | ||
84 | if (!etaVsVtxHistogram || !vtxHistogram || !etaVsVtxUncorrectedHistogram) | |
85 | { | |
b8e8168f | 86 | AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p %p %p", (void*) etaVsVtxHistogram, (void*) etaVsVtxUncorrectedHistogram, (void*) vtxHistogram)); |
75e130df | 87 | return; |
88 | } | |
89 | ||
90 | fdNdEtaAnalysisFinal = new dNdEtaAnalysis("dNdEtaResult"); | |
91 | ||
92 | fdNdEtaAnalysisFinal->SetEtaVsVtxHistogram(etaVsVtxHistogram); | |
93 | fdNdEtaAnalysisFinal->SetEtaVsVtxUncorrectedHistogram(etaVsVtxUncorrectedHistogram); | |
94 | fdNdEtaAnalysisFinal->SetVtxHistogram(vtxHistogram); | |
95 | ||
96 | fdNdEtaAnalysisFinal->Finish(); | |
97 | ||
98 | TFile* fout = new TFile("out.root","RECREATE"); | |
dc740de4 | 99 | WriteObjects(); |
75e130df | 100 | fout->Write(); |
101 | fout->Close(); | |
102 | ||
103 | fdNdEtaAnalysisFinal->DrawHistograms(); | |
104 | } | |
dc740de4 | 105 | |
106 | void AlidNdEtaAnalysisSelector::WriteObjects() | |
107 | { | |
108 | // Write objects to output file | |
109 | // this is an extra function to be overloaded... | |
110 | // | |
111 | ||
112 | fdNdEtaAnalysisFinal->SaveHistograms(); | |
113 | } |