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