]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
4dd2ad81 | 3 | #include "AlidNdEtaAnalysisMCSelector.h" |
4 | ||
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
8 | #include <TParticle.h> | |
9 | #include <TParticlePDG.h> | |
10 | #include <TVector3.h> | |
5af55649 | 11 | #include <TH1F.h> |
dc740de4 | 12 | #include <TH3F.h> |
7029240a | 13 | #include <TTree.h> |
16e24ca3 | 14 | #include <TFile.h> |
4dd2ad81 | 15 | |
16 | #include <AliLog.h> | |
17 | #include <AliGenEventHeader.h> | |
7029240a | 18 | #include <AliHeader.h> |
4dd2ad81 | 19 | |
16e24ca3 | 20 | #include "dNdEta/dNdEtaAnalysis.h" |
45e97e28 | 21 | #include "AliPWG0Helper.h" |
4dd2ad81 | 22 | |
dc740de4 | 23 | |
4dd2ad81 | 24 | ClassImp(AlidNdEtaAnalysisMCSelector) |
25 | ||
dc740de4 | 26 | AlidNdEtaAnalysisMCSelector::AlidNdEtaAnalysisMCSelector() : |
16e24ca3 | 27 | AliSelectorRL(), |
28 | fdNdEtaAnalysis(0), | |
5af55649 | 29 | fVertex(0), |
30 | fPartEta(0), | |
31 | fEvents(0) | |
4dd2ad81 | 32 | { |
33 | // | |
34 | // Constructor. Initialization of pointers | |
35 | // | |
36 | } | |
37 | ||
38 | AlidNdEtaAnalysisMCSelector::~AlidNdEtaAnalysisMCSelector() | |
39 | { | |
40 | // | |
41 | // Destructor | |
42 | // | |
43 | } | |
44 | ||
16e24ca3 | 45 | void AlidNdEtaAnalysisMCSelector::SlaveBegin(TTree * tree) |
46 | { | |
47 | // The SlaveBegin() function is called after the Begin() function. | |
48 | // When running with PROOF SlaveBegin() is called on each slave server. | |
49 | // The tree argument is deprecated (on PROOF 0 is passed). | |
50 | ||
51 | AliSelectorRL::SlaveBegin(tree); | |
52 | ||
53 | fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta"); | |
54 | } | |
55 | ||
944f0536 | 56 | void AlidNdEtaAnalysisMCSelector::Init(TTree *tree) |
57 | { | |
16e24ca3 | 58 | AliSelectorRL::Init(tree); |
944f0536 | 59 | |
60 | tree->SetBranchStatus("ESD", 0); | |
dc740de4 | 61 | |
5af55649 | 62 | fVertex = new TH3F("vertex_check", "vertex_check", 50, -50, 50, 50, -50, 50, 50, -50, 50); |
63 | fPartEta = new TH1F("dndeta_check", "dndeta_check", 120, -6, 6); | |
64 | fPartEta->Sumw2(); | |
944f0536 | 65 | } |
66 | ||
4dd2ad81 | 67 | Bool_t AlidNdEtaAnalysisMCSelector::Process(Long64_t entry) |
68 | { | |
16e24ca3 | 69 | // fill the dNdEtaAnalysis class from the monte carlo |
4dd2ad81 | 70 | |
16e24ca3 | 71 | if (AliSelectorRL::Process(entry) == kFALSE) |
4dd2ad81 | 72 | return kFALSE; |
73 | ||
74 | TTree* particleTree = GetKinematics(); | |
dc740de4 | 75 | if (!particleTree) |
76 | { | |
77 | AliDebug(AliLog::kError, "Kinematics not available"); | |
4dd2ad81 | 78 | return kFALSE; |
dc740de4 | 79 | } |
80 | ||
81 | AliHeader* header = GetHeader(); | |
82 | if (!header) | |
83 | { | |
84 | AliDebug(AliLog::kError, "Header not available"); | |
85 | return kFALSE; | |
86 | } | |
4dd2ad81 | 87 | |
88 | // get the MC vertex | |
dc740de4 | 89 | AliGenEventHeader* genHeader = header->GenEventHeader(); |
4dd2ad81 | 90 | |
91 | TArrayF vtxMC(3); | |
92 | genHeader->PrimaryVertex(vtxMC); | |
93 | ||
944f0536 | 94 | particleTree->SetBranchStatus("*", 0); |
95 | particleTree->SetBranchStatus("fDaughter[2]", 1); | |
96 | particleTree->SetBranchStatus("fPdgCode", 1); | |
97 | particleTree->SetBranchStatus("fPx", 1); | |
98 | particleTree->SetBranchStatus("fPy", 1); | |
99 | particleTree->SetBranchStatus("fPz", 1); | |
dc740de4 | 100 | particleTree->SetBranchStatus("fVx", 1); |
101 | particleTree->SetBranchStatus("fVy", 1); | |
102 | particleTree->SetBranchStatus("fVz", 1); | |
103 | ||
4dd2ad81 | 104 | TParticle* particle = 0; |
105 | particleTree->SetBranchAddress("Particles", &particle); | |
106 | ||
dc740de4 | 107 | Int_t nPrim = header->GetNprimary(); |
108 | Int_t nTotal = header->GetNtrack(); | |
4dd2ad81 | 109 | |
110 | for (Int_t i_mc = nTotal - nPrim; i_mc < nTotal; ++i_mc) | |
111 | { | |
112 | particleTree->GetEntry(i_mc); | |
113 | ||
114 | if (!particle) | |
115 | continue; | |
116 | ||
45e97e28 | 117 | if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE) |
4dd2ad81 | 118 | continue; |
119 | ||
dc740de4 | 120 | AliDebug(AliLog::kDebug+1, Form("Accepted primary %d, unique ID: %d", i_mc, particle->GetUniqueID())); |
121 | ||
45e97e28 | 122 | fdNdEtaAnalysis->FillTrack(vtxMC[2], particle->Eta(), particle->Pt(), 1); |
dc740de4 | 123 | fVertex->Fill(particle->Vx(), particle->Vy(), particle->Vz()); |
5af55649 | 124 | |
125 | fPartEta->Fill(particle->Eta()); | |
4dd2ad81 | 126 | } |
45e97e28 | 127 | fdNdEtaAnalysis->FillEvent(vtxMC[2], 1); |
4dd2ad81 | 128 | |
5af55649 | 129 | ++fEvents; |
130 | ||
4dd2ad81 | 131 | return kTRUE; |
132 | } | |
dc740de4 | 133 | |
16e24ca3 | 134 | void AlidNdEtaAnalysisMCSelector::SlaveTerminate() |
135 | { | |
136 | // The SlaveTerminate() function is called after all entries or objects | |
137 | // have been processed. When running with PROOF SlaveTerminate() is called | |
138 | // on each slave server. | |
139 | ||
140 | AliSelectorRL::SlaveTerminate(); | |
141 | ||
142 | // Add the histograms to the output on each slave server | |
143 | if (!fOutput) | |
144 | { | |
145 | AliDebug(AliLog::kError, Form("ERROR: Output list not initialized.")); | |
146 | return; | |
147 | } | |
148 | ||
149 | fOutput->Add(fdNdEtaAnalysis); | |
150 | } | |
151 | ||
dc740de4 | 152 | void AlidNdEtaAnalysisMCSelector::Terminate() |
153 | { | |
16e24ca3 | 154 | // |
155 | ||
156 | AliSelectorRL::Terminate(); | |
157 | ||
158 | fdNdEtaAnalysis = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndeta")); | |
159 | ||
160 | if (!fdNdEtaAnalysis) | |
161 | { | |
162 | AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p", (void*) fdNdEtaAnalysis)); | |
163 | return; | |
164 | } | |
165 | ||
d09fb536 | 166 | fdNdEtaAnalysis->Finish(0, -1); |
167 | ||
16e24ca3 | 168 | TFile* fout = new TFile("analysis_mc.root","RECREATE"); |
169 | ||
170 | fdNdEtaAnalysis->SaveHistograms(); | |
171 | ||
172 | fout->Write(); | |
173 | fout->Close(); | |
dc740de4 | 174 | |
5af55649 | 175 | fPartEta->Scale(1.0/fEvents); |
176 | fPartEta->Scale(1.0/fPartEta->GetBinWidth(1)); | |
177 | ||
178 | TCanvas* canvas = new TCanvas("control", "control", 900, 450); | |
179 | canvas->Divide(2, 1); | |
180 | ||
181 | canvas->cd(1); | |
dc740de4 | 182 | fVertex->Draw(); |
5af55649 | 183 | |
184 | canvas->cd(2); | |
185 | fPartEta->Draw(); | |
dc740de4 | 186 | } |