]>
Commit | Line | Data |
---|---|---|
9e952c39 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | // The ESD is available as member fESD | |
19 | // | |
20 | // The Process function is nearly empty. Implement your analysis there and look at the other listed below functions you | |
21 | // might need. | |
22 | // | |
23 | // The following methods can be overrriden. Please do not forgot to call the base class function. | |
24 | // | |
25 | // Begin(): called everytime a loop on the tree starts, | |
26 | // a convenient place to create your histograms. | |
27 | // SlaveBegin(): called after Begin(), when on PROOF called only on the | |
28 | // slave servers. | |
29 | // Init(): called for each new tree. Enable/Disable branches here. | |
30 | // Process(): called for each event, in this function you decide what | |
31 | // to read and fill your histograms. | |
32 | // SlaveTerminate: called at the end of the loop on the tree, when on PROOF | |
33 | // called only on the slave servers. | |
34 | // Terminate(): called at the end of the loop on the tree, | |
35 | // a convenient place to draw/fit your histograms. | |
36 | // | |
37 | // Author: Jan.Fiete.Grosse-Oetringhaus@cern.ch | |
38 | ||
39 | #include "AliVertexSelector.h" | |
40 | ||
41 | #include <TH1F.h> | |
42 | #include <TH2F.h> | |
43 | #include <TFile.h> | |
44 | #include <TTree.h> | |
45 | #include <TProfile.h> | |
46 | #include <TCanvas.h> | |
47 | #include <TAxis.h> | |
48 | ||
49 | #include <AliLog.h> | |
50 | #include <AliESD.h> | |
51 | #include <AliHeader.h> | |
52 | #include <AliGenEventHeader.h> | |
53 | ||
54 | #include <AliPWG0Helper.h> | |
55 | #include "esdTrackCuts/AliESDtrackCuts.h" | |
56 | ||
57 | ClassImp(AliVertexSelector) | |
58 | ||
59 | AliVertexSelector::AliVertexSelector() : | |
60 | AliSelectorRL(), | |
61 | fEsdTrackCuts(0), | |
62 | fVertexMC(0), | |
63 | fVertexESD(0), | |
64 | fVertexCorr(0), | |
65 | fVertexCorr2(0), | |
66 | fFakes(0) | |
67 | { | |
68 | // | |
69 | // Constructor. Initialization of pointers | |
70 | // | |
71 | } | |
72 | ||
73 | AliVertexSelector::~AliVertexSelector() | |
74 | { | |
75 | // | |
76 | // Destructor | |
77 | // | |
78 | } | |
79 | ||
80 | void AliVertexSelector::SlaveBegin(TTree* tree) | |
81 | { | |
82 | AliSelectorRL::SlaveBegin(tree); | |
83 | ||
84 | fVertexMC = new TH1F("fVertexMC", "fVertexMC;MC vtx-z;Count", 501, -10, 10); | |
85 | fVertexESD = new TH1F("fVertexESD", "fVertexESD;ESD vtx-z;Count", 501, -10, 10); | |
86 | fVertexCorr = new TH2F("fVertexCorr", "fVertexCorr;MC vtx-z;ESD vtx-z - MC vtx-z", 40, -10, 10, 200, -1, 1); | |
87 | fVertexCorr2 = new TH2F("fVertexCorr2", "fVertexCorr2;MC vtx-z;ESD vtx-z - MC vtx-z", 40, -10, 10, 200, -1, 1); | |
88 | fFakes = new TH2F("fFakes", "fFakes;type;label", 5, 0, 5, 1001, -500.5, 500.5); | |
89 | ||
90 | if (!fEsdTrackCuts && fInput) | |
91 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts")); | |
92 | } | |
93 | ||
94 | void AliVertexSelector::Init(TTree* tree) | |
95 | { | |
96 | // read the user objects | |
97 | ||
98 | AliSelectorRL::Init(tree); | |
99 | ||
100 | // Enable only the needed branches | |
101 | if (tree) | |
102 | { | |
103 | tree->SetBranchStatus("*", 0); | |
104 | tree->SetBranchStatus("fTriggerMask", 1); | |
105 | tree->SetBranchStatus("fSPDVertex*", 1); | |
106 | tree->SetBranchStatus("fTracks.fLabel", 1); | |
107 | ||
108 | AliESDtrackCuts::EnableNeededBranches(tree); | |
109 | } | |
110 | } | |
111 | ||
112 | Bool_t AliVertexSelector::Process(Long64_t entry) | |
113 | { | |
114 | // | |
115 | // Implement your analysis here. Do not forget to call the parent class Process by | |
116 | // if (AliSelector::Process(entry) == kFALSE) | |
117 | // return kFALSE; | |
118 | // | |
119 | ||
120 | if (AliSelectorRL::Process(entry) == kFALSE) | |
121 | return kFALSE; | |
122 | ||
123 | // Check prerequisites | |
124 | if (!fESD) | |
125 | { | |
126 | AliDebug(AliLog::kError, "ESD branch not available"); | |
127 | return kFALSE; | |
128 | } | |
129 | ||
130 | if (!fEsdTrackCuts) | |
131 | { | |
132 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
133 | return kFALSE; | |
134 | } | |
135 | ||
136 | if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE) | |
137 | { | |
138 | AliDebug(AliLog::kDebug+1, Form("Skipping event %d because it was not triggered", (Int_t) entry)); | |
139 | return kTRUE; | |
140 | } | |
141 | ||
142 | if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE) | |
143 | { | |
144 | AliDebug(AliLog::kDebug+1, Form("Skipping event %d because its vertex was not reconstructed", (Int_t) entry)); | |
145 | return kTRUE; | |
146 | } | |
147 | ||
148 | AliHeader* header = GetHeader(); | |
149 | if (!header) | |
150 | { | |
151 | AliDebug(AliLog::kError, "Header not available"); | |
152 | return kFALSE; | |
153 | } | |
154 | ||
155 | // get the MC vertex | |
156 | AliGenEventHeader* genHeader = header->GenEventHeader(); | |
157 | ||
158 | TArrayF vtxMC(3); | |
159 | genHeader->PrimaryVertex(vtxMC); | |
160 | ||
161 | // ######################################################## | |
162 | // get the ESD vertex | |
163 | const AliESDVertex* vtxESD = fESD->GetVertex(); | |
164 | Double_t vtx[3]; | |
165 | vtxESD->GetXYZ(vtx); | |
166 | ||
167 | fVertexMC->Fill(vtxMC[2]); | |
168 | fVertexESD->Fill(vtx[2]); | |
169 | fVertexCorr->Fill(vtxMC[2], vtx[2] - vtxMC[2]); | |
170 | ||
171 | Float_t correctedVertex = vtx[2] + 2.951034e-03 + 6.859620e-04 * vtxMC[2]; | |
172 | ||
173 | fVertexCorr2->Fill(vtxMC[2], correctedVertex - vtxMC[2]); | |
174 | ||
175 | const Int_t max = 10000; | |
176 | ||
177 | Bool_t used[max]; | |
178 | for (Int_t i=0; i<max; ++i) | |
179 | used[i] = kFALSE; | |
180 | ||
181 | Int_t fakeTracks = 0; | |
182 | ||
183 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
184 | for (Int_t t=0; t<nTracks; t++) | |
185 | { | |
186 | AliESDtrack* esdTrack = fESD->GetTrack(t); | |
187 | ||
188 | if (!esdTrack) | |
189 | continue; | |
190 | ||
191 | ||
192 | if (!fEsdTrackCuts->AcceptTrack(esdTrack)) | |
193 | continue; | |
194 | ||
195 | UInt_t status = esdTrack->GetStatus(); | |
196 | if ((!status & AliESDtrack::kTPCrefit)) | |
197 | continue; | |
198 | ||
199 | Int_t label = TMath::Abs(esdTrack->GetLabel()); | |
200 | if (label < max) | |
201 | { | |
202 | if (used[label]) | |
203 | { | |
204 | fFakes->Fill(1.5, esdTrack->GetLabel()); | |
205 | fakeTracks++; | |
206 | } | |
207 | ||
208 | used[label] = kTRUE; | |
209 | } | |
210 | ||
211 | fFakes->Fill(0.5, esdTrack->GetLabel()); | |
212 | } | |
213 | ||
214 | if (fakeTracks > 10) | |
215 | printf("In event %lld we have %d fake tracks.\n", entry, fakeTracks); | |
216 | ||
217 | return kTRUE; | |
218 | } | |
219 | ||
220 | void AliVertexSelector::SlaveTerminate() | |
221 | { | |
222 | // The SlaveTerminate() function is called after all entries or objects | |
223 | // have been processed. When running with PROOF SlaveTerminate() is called | |
224 | // on each slave server. | |
225 | ||
226 | AliSelectorRL::SlaveTerminate(); | |
227 | ||
228 | fOutput->Add(fVertexMC); | |
229 | fOutput->Add(fVertexESD); | |
230 | fOutput->Add(fVertexCorr); | |
231 | fOutput->Add(fVertexCorr2); | |
232 | fOutput->Add(fFakes); | |
233 | } | |
234 | ||
235 | void AliVertexSelector::Terminate() | |
236 | { | |
237 | // The Terminate() function is the last function to be called during | |
238 | // a query. It always runs on the client, it can be used to present | |
239 | // the results graphically or save the results to file. | |
240 | ||
241 | AliSelectorRL::Terminate(); | |
242 | ||
243 | fVertexMC = dynamic_cast<TH1F*> (fOutput->FindObject("fVertexMC")); | |
244 | fVertexESD = dynamic_cast<TH1F*> (fOutput->FindObject("fVertexESD")); | |
245 | fVertexCorr = dynamic_cast<TH2F*> (fOutput->FindObject("fVertexCorr")); | |
246 | fVertexCorr2 = dynamic_cast<TH2F*> (fOutput->FindObject("fVertexCorr2")); | |
247 | fFakes = dynamic_cast<TH2F*> (fOutput->FindObject("fFakes")); | |
248 | ||
249 | if (!fVertexMC || !fVertexESD || !fVertexCorr || !fVertexCorr2 || !fFakes) | |
250 | return; | |
251 | ||
252 | TFile* file = TFile::Open("vertex.root", "RECREATE"); | |
253 | fVertexMC->Write(); | |
254 | fVertexESD->Write(); | |
255 | fVertexCorr->Write(); | |
256 | fVertexCorr2->Write(); | |
257 | fFakes->Write(); | |
258 | file->Close(); | |
259 | ||
260 | TCanvas* canvas = new TCanvas("canvas", "canvas", 1000, 1000); | |
261 | canvas->Divide(2, 2); | |
262 | ||
263 | canvas->cd(1); | |
264 | fVertexCorr->DrawCopy("COLZ"); | |
265 | ||
266 | canvas->cd(2); | |
267 | fVertexCorr->ProfileX()->DrawCopy(); | |
268 | ||
269 | canvas->cd(3); | |
270 | fVertexCorr2->DrawCopy("COLZ"); | |
271 | ||
272 | canvas->cd(4); | |
273 | fFakes->DrawCopy(); | |
274 | ||
275 | printf("%f tracks, %f with label > 0, %f with label == 0, %f with label < 0\n", fFakes->Integral(1, 1, 0, fFakes->GetYaxis()->GetNbins()), fFakes->Integral(1, 1, fFakes->GetYaxis()->FindBin(0.0), fFakes->GetYaxis()->GetNbins()), fFakes->GetBinContent(1, fFakes->GetYaxis()->FindBin(0.0)), fFakes->Integral(1, 1, 0, fFakes->GetYaxis()->FindBin(0.0))); | |
276 | printf("%f tracks, %f with label > 0, %f with label == 0, %f with label < 0\n", fFakes->Integral(2, 2, 0, fFakes->GetYaxis()->GetNbins()), fFakes->Integral(2, 2, fFakes->GetYaxis()->FindBin(0.0), fFakes->GetYaxis()->GetNbins()), fFakes->GetBinContent(2, fFakes->GetYaxis()->FindBin(0.0)), fFakes->Integral(2, 2, 0, fFakes->GetYaxis()->FindBin(0.0))); | |
277 | } |