]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
79ab56b9 | 3 | #include "AlidNdEtaCorrectionSelector.h" |
539b6cb4 | 4 | |
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
8 | #include <TParticle.h> | |
9 | #include <TParticlePDG.h> | |
ad43cff6 | 10 | #include <TH1F.h> |
539b6cb4 | 11 | |
745e836a | 12 | #include <TChain.h> |
13 | #include <TSelector.h> | |
45e97e28 | 14 | #include <TFile.h> |
745e836a | 15 | |
539b6cb4 | 16 | #include <AliLog.h> |
539b6cb4 | 17 | #include <AliTracker.h> |
fcf2fb36 | 18 | #include <AliESDVertex.h> |
19 | #include <AliESD.h> | |
20 | #include <AliESDtrack.h> | |
45e97e28 | 21 | #include <AliRunLoader.h> |
22 | #include <AliStack.h> | |
539b6cb4 | 23 | |
7584d357 | 24 | #include <AliHeader.h> |
25 | #include <AliGenEventHeader.h> | |
4c351225 | 26 | #include <../PYTHIA6/AliGenPythiaEventHeader.h> |
27 | #include <../EVGEN/AliGenCocktailEventHeader.h> | |
7584d357 | 28 | |
37dbb69e | 29 | #include "esdTrackCuts/AliESDtrackCuts.h" |
45e97e28 | 30 | #include "dNdEta/AlidNdEtaCorrection.h" |
31 | #include "AliPWG0Helper.h" | |
4c351225 | 32 | #include "AliPWG0depHelper.h" |
539b6cb4 | 33 | |
79ab56b9 | 34 | ClassImp(AlidNdEtaCorrectionSelector) |
539b6cb4 | 35 | |
fcf2fb36 | 36 | AlidNdEtaCorrectionSelector::AlidNdEtaCorrectionSelector() : |
16e24ca3 | 37 | AliSelectorRL(), |
539b6cb4 | 38 | fEsdTrackCuts(0), |
406eb63e | 39 | fdNdEtaCorrection(0), |
ad43cff6 | 40 | fPIDParticles(0), |
41 | fPIDTracks(0), | |
61385583 | 42 | fClustersITSPos(0), |
43 | fClustersTPCPos(0), | |
44 | fClustersITSNeg(0), | |
45 | fClustersTPCNeg(0), | |
406eb63e | 46 | fSignMode(0) |
539b6cb4 | 47 | { |
79ab56b9 | 48 | // |
539b6cb4 | 49 | // Constructor. Initialization of pointers |
79ab56b9 | 50 | // |
539b6cb4 | 51 | } |
52 | ||
79ab56b9 | 53 | AlidNdEtaCorrectionSelector::~AlidNdEtaCorrectionSelector() |
539b6cb4 | 54 | { |
79ab56b9 | 55 | // |
56 | // Destructor | |
57 | // | |
539b6cb4 | 58 | |
59 | // histograms are in the output list and deleted when the output | |
60 | // list is deleted by the TSelector dtor | |
61 | } | |
62 | ||
ad43cff6 | 63 | Bool_t AlidNdEtaCorrectionSelector::SignOK(TParticlePDG* particle) |
406eb63e | 64 | { |
65 | // returns if a particle with this sign should be counted | |
66 | // this is determined by the value of fSignMode, which should have the same sign | |
67 | // as the charge | |
68 | // if fSignMode is 0 all particles are counted | |
69 | ||
ad43cff6 | 70 | if (fSignMode == 0) |
71 | return kTRUE; | |
72 | ||
73 | if (!particle) | |
74 | { | |
75 | printf("WARNING: not counting a particle that does not have a pdg particle\n"); | |
76 | return kFALSE; | |
77 | } | |
78 | ||
79 | Double_t charge = particle->Charge(); | |
80 | ||
406eb63e | 81 | if (fSignMode > 0) |
82 | if (charge < 0) | |
83 | return kFALSE; | |
84 | ||
85 | if (fSignMode < 0) | |
86 | if (charge > 0) | |
87 | return kFALSE; | |
88 | ||
89 | return kTRUE; | |
90 | } | |
91 | ||
0bd1f8a0 | 92 | void AlidNdEtaCorrectionSelector::ReadUserObjects(TTree* tree) |
93 | { | |
94 | // read the user objects, called from slavebegin and begin | |
95 | ||
96 | if (!fEsdTrackCuts && fInput) | |
97 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts")); | |
98 | ||
99 | if (!fEsdTrackCuts && tree) | |
100 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts")); | |
101 | ||
102 | if (!fEsdTrackCuts) | |
103 | AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list."); | |
104 | } | |
105 | ||
79ab56b9 | 106 | void AlidNdEtaCorrectionSelector::Begin(TTree * tree) |
539b6cb4 | 107 | { |
108 | // The Begin() function is called at the start of the query. | |
109 | // When running with PROOF Begin() is only called on the client. | |
110 | // The tree argument is deprecated (on PROOF 0 is passed). | |
111 | ||
16e24ca3 | 112 | AliSelectorRL::Begin(tree); |
406eb63e | 113 | |
0bd1f8a0 | 114 | ReadUserObjects(tree); |
115 | ||
406eb63e | 116 | TString option = GetOption(); |
117 | AliInfo(Form("Called with option %s.", option.Data())); | |
118 | ||
119 | if (option.Contains("only-positive")) | |
120 | { | |
121 | AliInfo("Processing only positive particles."); | |
122 | fSignMode = 1; | |
123 | } | |
124 | else if (option.Contains("only-negative")) | |
125 | { | |
126 | AliInfo("Processing only negative particles."); | |
127 | fSignMode = -1; | |
128 | } | |
539b6cb4 | 129 | } |
130 | ||
79ab56b9 | 131 | void AlidNdEtaCorrectionSelector::SlaveBegin(TTree * tree) |
539b6cb4 | 132 | { |
133 | // The SlaveBegin() function is called after the Begin() function. | |
134 | // When running with PROOF SlaveBegin() is called on each slave server. | |
135 | // The tree argument is deprecated (on PROOF 0 is passed). | |
136 | ||
16e24ca3 | 137 | AliSelectorRL::SlaveBegin(tree); |
539b6cb4 | 138 | |
0bd1f8a0 | 139 | ReadUserObjects(tree); |
539b6cb4 | 140 | |
0bd1f8a0 | 141 | fdNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction"); |
ad43cff6 | 142 | |
143 | fPIDParticles = new TH1F("pid_particles", "PID of generated primary particles", 10001, -5000.5, 5000.5); | |
144 | fPIDTracks = new TH1F("pid_tracks", "MC PID of reconstructed tracks", 10001, -5000.5, 5000.5); | |
145 | ||
146 | fClustersITSPos = new TH1F("clusters_its_pos", "clusters_its_pos", 7, -0.5, 6.5); | |
147 | fClustersTPCPos = new TH1F("clusters_tpc_pos", "clusters_tpc_pos", 160, -0.5, 159.5); | |
148 | ||
149 | fClustersITSNeg = new TH1F("clusters_its_neg", "clusters_its_neg", 7, -0.5, 6.5); | |
150 | fClustersTPCNeg = new TH1F("clusters_tpc_neg", "clusters_tpc_neg", 160, -0.5, 159.5); | |
539b6cb4 | 151 | } |
152 | ||
4c351225 | 153 | void AlidNdEtaCorrectionSelector::Init(TTree* tree) |
154 | { | |
155 | // read the user objects | |
156 | ||
157 | AliSelectorRL::Init(tree); | |
158 | ||
159 | // Enable only the needed branches | |
160 | if (tree) | |
161 | { | |
162 | tree->SetBranchStatus("*", 0); | |
163 | tree->SetBranchStatus("fTriggerMask", 1); | |
164 | tree->SetBranchStatus("fSPDVertex*", 1); | |
165 | tree->SetBranchStatus("fTracks.fLabel", 1); | |
166 | tree->SetBranchStatus("fTracks.fITSncls", 1); | |
167 | tree->SetBranchStatus("fTracks.fTPCncls", 1); | |
168 | ||
169 | AliESDtrackCuts::EnableNeededBranches(tree); | |
170 | } | |
171 | } | |
172 | ||
79ab56b9 | 173 | Bool_t AlidNdEtaCorrectionSelector::Process(Long64_t entry) |
539b6cb4 | 174 | { |
175 | // The Process() function is called for each entry in the tree (or possibly | |
176 | // keyed object in the case of PROOF) to be processed. The entry argument | |
177 | // specifies which entry in the currently loaded tree is to be processed. | |
178 | // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() | |
179 | // to read either all or the required parts of the data. When processing | |
180 | // keyed objects with PROOF, the object is already loaded and is available | |
181 | // via the fObject pointer. | |
182 | // | |
183 | // This function should contain the "body" of the analysis. It can contain | |
184 | // simple or elaborate selection criteria, run algorithms on the data | |
185 | // of the event and typically fill histograms. | |
186 | ||
187 | // WARNING when a selector is used with a TChain, you must use | |
188 | // the pointer to the current TTree to call GetEntry(entry). | |
189 | // The entry is always the local entry number in the current tree. | |
16e24ca3 | 190 | // Assuming that fTree is the pointer to the TChain being processed, |
191 | // use fTree->GetTree()->GetEntry(entry). | |
539b6cb4 | 192 | |
7584d357 | 193 | AliDebug(AliLog::kDebug+1,"Processing event ...\n"); |
194 | ||
195 | ||
16e24ca3 | 196 | if (AliSelectorRL::Process(entry) == kFALSE) |
539b6cb4 | 197 | return kFALSE; |
198 | ||
b8e8168f | 199 | // check prerequesites |
200 | if (!fESD) | |
201 | { | |
202 | AliDebug(AliLog::kError, "ESD branch not available"); | |
203 | return kFALSE; | |
204 | } | |
205 | ||
dc740de4 | 206 | AliHeader* header = GetHeader(); |
207 | if (!header) | |
b8e8168f | 208 | { |
dc740de4 | 209 | AliDebug(AliLog::kError, "Header not available"); |
b8e8168f | 210 | return kFALSE; |
211 | } | |
212 | ||
d09fb536 | 213 | AliStack* stack = GetStack(); |
45e97e28 | 214 | if (!stack) |
215 | { | |
216 | AliDebug(AliLog::kError, "Stack not available"); | |
217 | return kFALSE; | |
218 | } | |
219 | ||
b8e8168f | 220 | if (!fEsdTrackCuts) |
221 | { | |
222 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
539b6cb4 | 223 | return kFALSE; |
b8e8168f | 224 | } |
539b6cb4 | 225 | |
45e97e28 | 226 | Bool_t vertexReconstructed = AliPWG0Helper::IsVertexReconstructed(fESD); |
745e836a | 227 | |
45e97e28 | 228 | Bool_t eventTriggered = AliPWG0Helper::IsEventTriggered(fESD); |
539b6cb4 | 229 | |
539b6cb4 | 230 | // get the MC vertex |
dc740de4 | 231 | AliGenEventHeader* genHeader = header->GenEventHeader(); |
539b6cb4 | 232 | |
233 | TArrayF vtxMC(3); | |
234 | genHeader->PrimaryVertex(vtxMC); | |
539b6cb4 | 235 | |
539b6cb4 | 236 | // loop over mc particles |
45e97e28 | 237 | Int_t nPrim = stack->GetNprimary(); |
539b6cb4 | 238 | |
45e97e28 | 239 | for (Int_t iMc = 0; iMc < nPrim; ++iMc) |
539b6cb4 | 240 | { |
45e97e28 | 241 | AliDebug(AliLog::kDebug+1, Form("MC Loop: Processing particle %d.", iMc)); |
242 | ||
243 | TParticle* particle = stack->Particle(iMc); | |
539b6cb4 | 244 | |
245 | if (!particle) | |
45e97e28 | 246 | { |
247 | AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (mc loop).", iMc)); | |
539b6cb4 | 248 | continue; |
45e97e28 | 249 | } |
539b6cb4 | 250 | |
45e97e28 | 251 | if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE) |
539b6cb4 | 252 | continue; |
253 | ||
ad43cff6 | 254 | if (SignOK(particle->GetPDG()) == kFALSE) |
10ebe68d | 255 | continue; |
ad43cff6 | 256 | |
745e836a | 257 | Float_t eta = particle->Eta(); |
45e97e28 | 258 | Float_t pt = particle->Pt(); |
259 | ||
7584d357 | 260 | if (vertexReconstructed) { |
45e97e28 | 261 | fdNdEtaCorrection->FillParticle(vtxMC[2], eta, pt); |
7584d357 | 262 | |
ad43cff6 | 263 | if (pt > 0.1 && pt < 0.2) |
7584d357 | 264 | fPIDParticles->Fill(particle->GetPdgCode()); |
ad43cff6 | 265 | } |
45e97e28 | 266 | }// end of mc particle |
e8cb44f1 | 267 | |
539b6cb4 | 268 | // ######################################################## |
269 | // loop over esd tracks | |
270 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
45e97e28 | 271 | |
406eb63e | 272 | // count the number of "good" tracks as parameter for vertex reconstruction efficiency |
45e97e28 | 273 | Int_t nGoodTracks = 0; |
539b6cb4 | 274 | for (Int_t t=0; t<nTracks; t++) |
275 | { | |
45e97e28 | 276 | AliDebug(AliLog::kDebug+1, Form("ESD Loop: Processing track %d.", t)); |
277 | ||
539b6cb4 | 278 | AliESDtrack* esdTrack = fESD->GetTrack(t); |
279 | ||
280 | // cut the esd track? | |
281 | if (!fEsdTrackCuts->AcceptTrack(esdTrack)) | |
282 | continue; | |
283 | ||
45e97e28 | 284 | nGoodTracks++; |
285 | ||
286 | // using the properties of the mc particle | |
539b6cb4 | 287 | Int_t label = TMath::Abs(esdTrack->GetLabel()); |
79ab56b9 | 288 | if (label == 0) |
539b6cb4 | 289 | { |
b8e8168f | 290 | AliDebug(AliLog::kWarning, Form("WARNING: cannot find corresponding mc part for track %d.", t)); |
539b6cb4 | 291 | continue; |
292 | } | |
539b6cb4 | 293 | |
45e97e28 | 294 | TParticle* particle = stack->Particle(label); |
295 | if (!particle) | |
296 | { | |
297 | AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (track loop).", label)); | |
298 | continue; | |
299 | } | |
539b6cb4 | 300 | |
ad43cff6 | 301 | if (SignOK(particle->GetPDG()) == kFALSE) |
406eb63e | 302 | continue; |
303 | ||
45e97e28 | 304 | if (vertexReconstructed) |
ad43cff6 | 305 | { |
45e97e28 | 306 | fdNdEtaCorrection->FillParticleWhenMeasuredTrack(vtxMC[2], particle->Eta(), particle->Pt()); |
ad43cff6 | 307 | if (particle->Pt() > 0.1 && particle->Pt() < 0.2) |
7584d357 | 308 | { |
309 | fPIDTracks->Fill(particle->GetPdgCode()); | |
ad43cff6 | 310 | if (particle->GetPDG()->Charge() > 0) |
311 | { | |
312 | fClustersITSPos->Fill(esdTrack->GetITSclusters(0)); | |
313 | fClustersTPCPos->Fill(esdTrack->GetTPCclusters(0)); | |
314 | } | |
315 | else | |
316 | { | |
317 | fClustersITSNeg->Fill(esdTrack->GetITSclusters(0)); | |
318 | fClustersTPCNeg->Fill(esdTrack->GetTPCclusters(0)); | |
319 | } | |
320 | } | |
321 | } | |
539b6cb4 | 322 | } // end of track loop |
323 | ||
7584d357 | 324 | // stuff regarding the vertex reco correction and trigger bias correction |
325 | if (eventTriggered) { | |
1afae8ff | 326 | fdNdEtaCorrection->FillEventWithTrigger(vtxMC[2], nGoodTracks); |
847489f7 | 327 | if (vertexReconstructed) |
1afae8ff | 328 | fdNdEtaCorrection->FillEventWithTriggerWithReconstructedVertex(vtxMC[2], nGoodTracks); |
847489f7 | 329 | } |
45e97e28 | 330 | |
7584d357 | 331 | // getting process information |
4c351225 | 332 | Int_t processtype = AliPWG0depHelper::GetPythiaEventProcessType(header); |
7584d357 | 333 | AliDebug(AliLog::kDebug+1,Form(" Found pythia procces type %d", processtype)); |
334 | ||
335 | if (processtype<0) | |
336 | AliDebug(AliLog::kError, Form("Unkown Pythia process type %d.", processtype)); | |
337 | ||
338 | fdNdEtaCorrection->FillEventAll(vtxMC[2], nGoodTracks, "INEL"); | |
339 | ||
340 | if (processtype!=92 && processtype!=93) | |
341 | fdNdEtaCorrection->FillEventAll(vtxMC[2], nGoodTracks, "NSD"); | |
342 | ||
343 | if (processtype!=92 && processtype!=93 && processtype!=94) | |
344 | fdNdEtaCorrection->FillEventAll(vtxMC[2], nGoodTracks, "ND"); | |
345 | ||
539b6cb4 | 346 | return kTRUE; |
347 | } | |
348 | ||
79ab56b9 | 349 | void AlidNdEtaCorrectionSelector::SlaveTerminate() |
539b6cb4 | 350 | { |
351 | // The SlaveTerminate() function is called after all entries or objects | |
352 | // have been processed. When running with PROOF SlaveTerminate() is called | |
353 | // on each slave server. | |
354 | ||
16e24ca3 | 355 | AliSelectorRL::SlaveTerminate(); |
539b6cb4 | 356 | |
357 | // Add the histograms to the output on each slave server | |
358 | if (!fOutput) | |
359 | { | |
b8e8168f | 360 | AliDebug(AliLog::kError, "ERROR: Output list not initialized"); |
539b6cb4 | 361 | return; |
362 | } | |
79ab56b9 | 363 | |
745e836a | 364 | fOutput->Add(fdNdEtaCorrection); |
539b6cb4 | 365 | } |
366 | ||
79ab56b9 | 367 | void AlidNdEtaCorrectionSelector::Terminate() |
539b6cb4 | 368 | { |
369 | // The Terminate() function is the last function to be called during | |
370 | // a query. It always runs on the client, it can be used to present | |
371 | // the results graphically or save the results to file. | |
372 | ||
16e24ca3 | 373 | AliSelectorRL::Terminate(); |
539b6cb4 | 374 | |
45e97e28 | 375 | fdNdEtaCorrection = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction")); |
ad43cff6 | 376 | if (!fdNdEtaCorrection) |
377 | { | |
378 | AliDebug(AliLog::kError, "Could not read object from output list"); | |
379 | return; | |
380 | } | |
79ab56b9 | 381 | |
45e97e28 | 382 | fdNdEtaCorrection->Finish(); |
539b6cb4 | 383 | |
406eb63e | 384 | TFile* fout = new TFile(Form("correction_map%s.root", GetOption()), "RECREATE"); |
539b6cb4 | 385 | |
0bd1f8a0 | 386 | if (fEsdTrackCuts) |
387 | fEsdTrackCuts->SaveHistograms("esd_track_cuts"); | |
45e97e28 | 388 | fdNdEtaCorrection->SaveHistograms(); |
539b6cb4 | 389 | |
390 | fout->Write(); | |
391 | fout->Close(); | |
392 | ||
45e97e28 | 393 | fdNdEtaCorrection->DrawHistograms(); |
ad43cff6 | 394 | |
0bd1f8a0 | 395 | if (fPIDParticles && fPIDTracks) |
396 | { | |
397 | new TCanvas("pidcanvas", "pidcanvas", 500, 500); | |
ad43cff6 | 398 | |
0bd1f8a0 | 399 | fPIDParticles->Draw(); |
400 | fPIDTracks->SetLineColor(2); | |
401 | fPIDTracks->Draw("SAME"); | |
ad43cff6 | 402 | |
0bd1f8a0 | 403 | TDatabasePDG* pdgDB = new TDatabasePDG; |
ad43cff6 | 404 | |
0bd1f8a0 | 405 | for (Int_t i=0; i <= fPIDParticles->GetNbinsX()+1; ++i) |
406 | if (fPIDParticles->GetBinContent(i) > 0) | |
407 | printf("PDG = %d (%s): generated: %d, reconstructed: %d, ratio: %f\n", (Int_t) fPIDParticles->GetBinCenter(i), pdgDB->GetParticle((Int_t) fPIDParticles->GetBinCenter(i))->GetName(), (Int_t) fPIDParticles->GetBinContent(i), (Int_t) fPIDTracks->GetBinContent(i), ((fPIDTracks->GetBinContent(i) > 0) ? fPIDParticles->GetBinContent(i) / fPIDTracks->GetBinContent(i) : -1)); | |
ad43cff6 | 408 | |
0bd1f8a0 | 409 | delete pdgDB; |
410 | pdgDB = 0; | |
411 | } | |
ad43cff6 | 412 | |
0bd1f8a0 | 413 | if (fClustersITSPos && fClustersITSNeg && fClustersTPCPos && fClustersTPCNeg) |
414 | { | |
415 | TCanvas* canvas = new TCanvas("clusters", "clusters", 1000, 500); | |
416 | canvas->Divide(2, 1); | |
417 | ||
418 | canvas->cd(1); | |
419 | fClustersITSPos->Draw(); | |
420 | fClustersITSNeg->SetLineColor(kRed); | |
421 | fClustersITSNeg->Draw("SAME"); | |
422 | ||
423 | canvas->cd(2); | |
424 | fClustersTPCPos->Draw(); | |
425 | fClustersTPCNeg->SetLineColor(kRed); | |
426 | fClustersTPCNeg->Draw("SAME"); | |
427 | } | |
539b6cb4 | 428 | } |