]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliAnalysisTaskCheckV0tenderII.cxx
Remove obsolte Jpsi classes
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliAnalysisTaskCheckV0tenderII.cxx
CommitLineData
3a72645a 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// Task fir checking the performance of the V0 tender
17//
18//
6555e2ad 19// Authors:
3a72645a 20// Matus Kalisky <matus.kalisky@cern.ch>
21//
22
23#include <TH1F.h>
24#include <TList.h>
25
26#include "AliAnalysisManager.h"
27#include "AliMCEventHandler.h"
28#include "AliESDInputHandler.h"
29#include "AliESDv0.h"
30#include "AliESDtrack.h"
31#include "AliMCParticle.h"
32#include "AliMCEvent.h"
33#include "AliESDv0KineCuts.h"
34#include "AliKFVertex.h"
35
36#include "AliHFEtools.h"
37#include "AliHFEcollection.h"
38
39#include "AliAnalysisTaskCheckV0tenderII.h"
40
41ClassImp(AliAnalysisTaskCheckV0tenderII)
42
43//__________________________________________________________
44AliAnalysisTaskCheckV0tenderII::AliAnalysisTaskCheckV0tenderII():
45 AliAnalysisTaskSE("CheckV0tenderTask")
46 , fOutput(0x0)
47 , fColl(0x0)
48 , fCollMC(0x0)
49 , fV0cuts(0x0)
50 , fPrimaryVertex(0x0)
51 , fpdgV0(0)
52 , fpdgP(0)
53 , fpdgN(0)
54 , fEvents(0x0)
55{
56 //
57 // Default Constructor
58 //
59
60
61 DefineOutput(1, TH1F::Class());
62 DefineOutput(2, TList::Class());
63
64
65}
66//__________________________________________________________
67AliAnalysisTaskCheckV0tenderII::AliAnalysisTaskCheckV0tenderII(const Char_t *name):
68 AliAnalysisTaskSE(name)
69 , fOutput(0x0)
70 , fColl(0x0)
71 , fCollMC(0x0)
72 , fV0cuts(0x0)
73 , fPrimaryVertex(0x0)
74 , fpdgV0(0)
75 , fpdgP(0)
76 , fpdgN(0)
77 , fEvents(0x0)
78{
79 //
80 // Constructor
81 //
82
83 DefineOutput(1, TH1F::Class());
84 DefineOutput(2, TList::Class());
85
86}
87//__________________________________________________________
88AliAnalysisTaskCheckV0tenderII::~AliAnalysisTaskCheckV0tenderII(){
89 //
90 // Destructor
91 //
92
93 if (fOutput) delete fOutput;
94 if (fColl) delete fColl;
95 if (fCollMC) delete fCollMC;
96 if (fV0cuts) delete fV0cuts;
97 if (fPrimaryVertex) delete fPrimaryVertex;
98 if (fEvents) delete fEvents;
99}
100//__________________________________________________________
101void AliAnalysisTaskCheckV0tenderII::UserCreateOutputObjects(){
102 //
103 // prepare output objects
104 //
105
106 fOutput = new TList();
107 //fOutput->SetOwner();
108 // Counter for number of events
109 fEvents = new TH1I("nEvents", "NumberOfEvents", 1, 1, 2);
110
111 fColl = new AliHFEcollection("V0_QA", "tender V0s for data");
112 fCollMC = new AliHFEcollection("V0_MC_QA", "tender V0s for MC");
113
114 fV0cuts = new AliESDv0KineCuts();
115 if(!fV0cuts){
116 AliError("Failed to initialize AliESDv0KineCuts instance");
117 return;
118 }
119
120 //
121 // Data histos
122 //
123
124 // total number of tagged V0s
125 fColl->CreateTH1F("h_NumberOf_V0s", "Number of tagged V0s; type; counts", 4, -0.5, 3.5);
126 // pT spectra of the tagged V0s
127 fColl->CreateTH1F("h_Gamma_pt", "p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
128 fColl->CreateTH1F("h_K0_pt", "p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
129 fColl->CreateTH1F("h_Lambda_pt", "p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
130 fColl->CreateTH1F("h_ALambda_pt", "p_{T} spectrum of tagged A-Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
131 // invariant mass of the V0s
132 fColl->CreateTH1F("h_Gamma_mass", "Inv. Mass of the ", 100, 0., 0.1);
133 fColl->CreateTH1F("h_K0_mass", "Inv. Mass of the ", 100, 0.45, 0.55);
134 fColl->CreateTH1F("h_Lambda_mass", "Inv. Mass of the ", 100, 1.08, 1.14);
135 fColl->CreateTH1F("h_ALambda_mass", "Inv. Mass of the ", 100, 1.08, 1.14);
136
137 // total number of tagged daughter particles (should correlate with number of V0s !
138 fColl->CreateTH1F("h_NumberOfDaughters", "Number of tagged daughters; type; counts", 3, -0.5, 2.5);
139 // pT spectra of tagged daughter particles
140 fColl->CreateTH1F("h_Electron_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
141 fColl->CreateTH1F("h_Pion_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
142 fColl->CreateTH1F("h_Proton_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
143
144 //
145 // MC histos
146 //
147
148 // pT spectra of the tagged V0s
149 fCollMC->CreateTH1F("h_Gamma_pt_S", "MC-S: p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
150 fCollMC->CreateTH1F("h_K0_pt_S", "MC-S: p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
151 fCollMC->CreateTH1F("h_Lambda_pt_S", "MC-S: p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
152 fCollMC->CreateTH1F("h_ALambda_pt_S", "MC-S: p_{T} spectrum of tagged A-Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
153 fCollMC->CreateTH1F("h_Gamma_pt_B", "MC-B: p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
154 fCollMC->CreateTH1F("h_K0_pt_B", "MC-B: p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
155 fCollMC->CreateTH1F("h_Lambda_pt_B", "MC-B: p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
156 fCollMC->CreateTH1F("h_ALambda_pt_B", "MC-B: p_{T} spectrum of tagged A-Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
157 // invariant mass of the V0s
158 fCollMC->CreateTH1F("h_Gamma_mass_S", "MC-S: Inv. Mass of the gamma; m (GeV/c^{2}); counts", 100, 0., 0.1);
159 fCollMC->CreateTH1F("h_K0_mass_S", "MC-S: Inv. Mass of the K0; m (GeV/c^{2}); counts", 100, 0.45, 0.55);
160 fCollMC->CreateTH1F("h_Lambda_mass_S", "MC-S: Inv. Mass of the Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
161 fCollMC->CreateTH1F("h_ALambda_mass_S", "MC-S: Inv. Mass of the A-Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
162 fCollMC->CreateTH1F("h_Gamma_mass_B", "MC-B: Inv. Mass of the gamma; m (GeV/c^{2}); counts", 100, 0., 0.1);
163 fCollMC->CreateTH1F("h_K0_mass_B", "MC-B: Inv. Mass of the K0; m (GeV/c^{2}); counts", 100, 0.45, 0.55);
164 fCollMC->CreateTH1F("h_Lambda_mass_B", "MC-B: Inv. Mass of the Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
165 fCollMC->CreateTH1F("h_ALambda_mass_B", "MC-B: Inv. Mass of the A-Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
166 // pT spectra of tagged daughter particles
167 fCollMC->CreateTH1F("h_Electron_pt_S", "MC-S: p_{T} spectrum of tagged electrons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
168 fCollMC->CreateTH1F("h_Pion_pt_S", "MC-S: p_{T} spectrum of tagged pions; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
169 fCollMC->CreateTH1F("h_Proton_pt_S", "MC-S: p_{T} spectrum of tagged protons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
170 fCollMC->CreateTH1F("h_Electron_pt_B", "MC-B: p_{T} spectrum of tagged electrons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
171 fCollMC->CreateTH1F("h_Pion_pt_B", "MC-B: p_{T} spectrum of tagged pions; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
172 fCollMC->CreateTH1F("h_Proton_pt_B", "MC-B: p_{T} spectrum of tagged protons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
173
174
175 TList *tmp = fColl->GetList();
176 tmp->SetName(fColl->GetName());
177 fOutput->Add(tmp);
178 tmp = 0x0;
179 tmp = fCollMC->GetList();
180 tmp->SetName(fCollMC->GetName());
181 fOutput->Add(tmp);
182
183
184}
185//__________________________________________________________
186void AliAnalysisTaskCheckV0tenderII::UserExec(Option_t *){
187 //
188 // Event Loop
189 //
190 AliMCEventHandler* mcHandler = (dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()));
bf892a6a 191
192 //AliESDInputHandler *inh = dynamic_cast<AliESDInputHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
193 //AliESDpid *workingPID = NULL;
194 //if(inh && (workingPID = inh->GetESDpid())) workingPID = inh->GetESDpid();
195 //else workingPID = AliHFEtools::GetDefaultPID(mcHandler ? kTRUE : kFALSE);
3a72645a 196
197 // check the MC data
198 if(fMCEvent && !mcHandler ) return;
199 if(fMCEvent && !mcHandler->InitOk() ) return;
200 if(fMCEvent && !mcHandler->TreeK() ) return;
201 if(fMCEvent && !mcHandler->TreeTR() ) return;
202
203 fPrimaryVertex = new AliKFVertex(*(fInputEvent->GetPrimaryVertex()));
204 if(!fPrimaryVertex) return;
205
206 fV0cuts->SetEvent(fInputEvent);
207 fV0cuts->SetPrimaryVertex(fPrimaryVertex);
208
209 ProcessV0s();
210
211 fEvents->Fill(1.1);
212 PostData(1, fEvents);
213 PostData(2, fOutput);
214}
215//__________________________________________________________
216void AliAnalysisTaskCheckV0tenderII::Terminate(Option_t *){
217 //
218 // Do Post Processing
219 //
220}
221//__________________________________________________________
222void AliAnalysisTaskCheckV0tenderII::ProcessV0s(){
223 //
224 // loop over the V0s and extract the information about
225 // the V0s tagged by the V0 tender
226 //
227
228 const char * type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
229 char name[256] = "";
230
231 Int_t nV0s = fInputEvent->GetNumberOfV0s();
232 for(Int_t i=0; i<nV0s; ++i){
bf892a6a 233 AliESDv0 *esdV0 = (static_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
3a72645a 234 if(!esdV0) continue;
235 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
236
237 // New standalone V0 selection software
238 if( ! (fV0cuts->ProcessV0(esdV0, fpdgV0, fpdgP, fpdgN)) ) return;
239
240 Int_t pid = PDGtoPIDv0(fpdgV0);
241 //printf(" -D: pdg: %i, pid: %i\n", fpdgV0, pid);
242 if(pid <= -1) continue;
243
244 fColl->Fill("h_NumberOf_V0s", pid);
245 sprintf(name, "h_%s_pt", type[pid]);
246 Float_t pT = esdV0->Pt();
247 fColl->Fill(name, pT);
248 Float_t mass = MassV0(esdV0, pid);
249 sprintf(name, "h_%s_mass", type[pid]);
250 fColl->Fill(name, mass);
251
252 ProcessDaughters(esdV0);
253 if(fMCEvent){
254 ProcessV0sMC(esdV0);
255 ProcessDaughtersMC(esdV0);
256 }
257
258 }
259
260}
261//__________________________________________________________
262void AliAnalysisTaskCheckV0tenderII::ProcessDaughters(AliESDv0 * const v0){
263 //
264 // produce some check plots for V0 tender tagged single tracks
265 //
266
267 const char * type[3] = {"Electron", "Pion", "Proton"};
268 char name[256] = "";
269
270 if(!v0) return;
271
272 // daughter tracks
273 const Int_t nTracks = fInputEvent->GetNumberOfTracks();
274 AliESDtrack *d[2];
275 Int_t iN, iP;
276 iN = iP = -1;
277 iP = v0->GetPindex();
278 iN = v0->GetNindex();
279 if(iN < 0 || iP < 0) return;
280 if(iN >= nTracks || iP >= nTracks) return;
281 d[0] = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iP));
282 d[1] = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iN));
283 if(!d[0] || !d[1]) return;
284
285 for(Int_t i=0; i<2; ++i){
286 Int_t pid = (i == 0) ? PDGtoPID(fpdgP) : PDGtoPID(fpdgN);
287 if(pid < 0) continue;
288 fColl->Fill("h_NumberOfDaughters", pid*1.0);
289 Float_t pT = d[i]->Pt();
290 sprintf(name, "h_%s_pt", type[pid]);
291 fColl->Fill(name, pT);
292
293 }
294}
295//__________________________________________________________
296void AliAnalysisTaskCheckV0tenderII::ProcessV0sMC(AliESDv0 * const v0){
297 //
298 // check all V0tender selected V0 on their true identity
299 //
300
301 const char * type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
302 char name[256] = "";
303
304
305 Int_t pid = PDGtoPIDv0(fpdgV0);
306 if(pid < 0) return;
307
308 // true if fpdgV0 agrees with MC pdg of the mother
309 Bool_t id = kFALSE;
310 const Int_t nTracks = fInputEvent->GetNumberOfTracks();
311 // both ESD daughtr tracks
312 Int_t iN, iP;
313 iN = iP = -1;
314 iP = v0->GetPindex();
315 iN = v0->GetNindex();
316 if(iN < 0 || iP < 0) return;
317 if(iN >= nTracks || iP >= nTracks) return;
318 AliESDtrack *dP, *dN;
319 dP = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iP));
320 dN = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iN));
321 if(!dN || !dP) return;
322
323 // MC labels of the daughter tracks
324 Int_t lN, lP;
325 lN = dN->GetLabel();
326 lP = dP->GetLabel();
327 if(lN < 0 || lP < 0) return;
328
329 // MC daughter particles
330 AliMCParticle *mcP, *mcN;
331 mcP = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lP));
332 mcN = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lN));
333 if(!mcP || !mcN) return;
334
335 // labels of the mother particles
336 Int_t lPm, lNm;
337 lPm = mcP->GetMother();
338 lNm = mcN->GetMother();
339 AliMCParticle *m = 0x0;
340 // particles without mother particle are most probably
341 // primary particles
342 if(lPm >= 0){
343 m = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lPm));
344 if(!m) return;
345 }
346 if(m){
347 Int_t pdg = m->PdgCode();
348 //if(lPm == lNm) printf(" -D: pdg: %i, fpdgV0: %i \n", pdg, fpdgV0);
349 if((lPm == lNm) && (pdg == fpdgV0)) id = kTRUE;
350 }
351
352 if(id) sprintf(name, "h_%s_pt_S", type[pid]);
353 else sprintf(name, "h_%s_pt_B", type[pid]);
354 Float_t pT = v0->Pt();
355 fCollMC->Fill(name, pT);
356
357 if(id) sprintf(name, "h_%s_mass_S", type[pid]);
358 else sprintf(name, "h_%s_mass_B", type[pid]);
359 Float_t mass = MassV0(v0, pid);
360 fCollMC->Fill(name, mass);
361
362
363}
364//__________________________________________________________
365void AliAnalysisTaskCheckV0tenderII::ProcessDaughtersMC(AliESDv0 * const v0){
366 //
367 // check the identity of the V0tender selected V0 daughters
368 // !!! for positive check only the true identity plays a role here,
369 // not the true V0 mother identity (e.g. selected electron could come
bf892a6a 370 // from primary vertex or pion dalitz deca or true gamma conversion) !!!!
3a72645a 371 //
372
373 const char * type[3] = {"Electron", "Pion", "Proton"};
374 char name[256] = "";
375
376 if(!v0) return;
377
378 // daughter tracks
379 const Int_t nTracks = fInputEvent->GetNumberOfTracks();
380 AliESDtrack *d[2];
381 Int_t iN, iP;
382 iN = iP = -1;
383 iP = v0->GetPindex();
384 iN = v0->GetNindex();
385 if(iN < 0 || iP < 0) return;
386 if(iN >= nTracks || iP >= nTracks) return;
387 d[0] = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iP));
388 d[1] = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iN));
389 if(!d[0] || !d[1]) return;
390
391 //printf(" *** fpdgV0: %i, fpdgP: %i, fpdgN: %i \n", fpdgV0, fpdgP, fpdgN);
392
393 for(Int_t i=0; i<2; ++i){
394 Bool_t id = kFALSE;
395 Int_t pid = (i == 0) ? PDGtoPID(fpdgP) : PDGtoPID(fpdgN);
396 Int_t pdg = (i == 0) ? fpdgP : fpdgN;
397 if(pid < 0) continue;
398 Float_t pT = d[i]->Pt();
399 Int_t label = d[i]->GetLabel();
400 if(label < 0) continue;
401 AliMCParticle *mcp = 0x0;
402 mcp = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(label));
403 if(!mcp) continue;
404 Int_t pdgMC = mcp->PdgCode();
405 //printf(" * pid: %i, pdg: %i, pdgMC: %i \n", pid, pdg, pdgMC);
406 if(pdgMC == pdg) id = kTRUE;
407 if(id) sprintf(name, "h_%s_pt_S", type[pid]);
408 else sprintf(name, "h_%s_pt_B", type[pid]);
409 fCollMC->Fill(name, pT);
410 }
411}
412//__________________________________________________________
413Float_t AliAnalysisTaskCheckV0tenderII::MassV0(AliESDv0 * const v0, Int_t id){
414 //
415 // Get the V0 effective mass
416 //
417
418 Float_t mass = -0.1;
419 Bool_t sign = CheckSigns(v0);
420 if(0 == id){
421 mass = v0->GetEffMass(0, 0);
422 }
423 else if(1 == id){
424 mass = v0->GetEffMass(2, 2);
425 }
426 else if(2 == id){
427 mass = (sign) ? v0->GetEffMass(4, 2) : v0->GetEffMass(2, 4);
428 }
429 else if(3 == id){
430 mass = (sign) ? v0->GetEffMass(2, 4) : v0->GetEffMass(4, 2);
431 }
432 else{
433 AliWarning(Form("Unrecognized V0 id: %i", id));
434 }
435
436 return mass;
437
438}
439//__________________________________________________________
440Bool_t AliAnalysisTaskCheckV0tenderII::CheckSigns(AliESDv0 * const v0){
441 //
442 // check wheter the sign was correctly applied to
443 // V0 daughter tracks
444 // This function should become obsolete once the V0 finder will be updated (fixed)
445 //
446
447 Bool_t correct = kFALSE;
448
449 Int_t pIndex = 0, nIndex = 0;
450 pIndex = v0->GetPindex();
451 nIndex = v0->GetNindex();
452
453 AliESDtrack* d[2];
454 d[0] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(pIndex));
455 d[1] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(nIndex));
456
457 Int_t sign[2];
458 sign[0] = (int)d[0]->GetSign();
459 sign[1] = (int)d[1]->GetSign();
460
461 if(-1 == sign[0] && 1 == sign[1]){
462 correct = kFALSE;
463 //v0->SetIndex(0, pIndex); // set the index of the negative v0 track
464 //v0->SetIndex(1, nIndex); // set the index of the positive v0 track
465 }
466 else{
467 correct = kTRUE;
468 }
469
470 //pIndex = v0->GetPindex();
471 //nIndex = v0->GetNindex();
472 //printf("-D2: P: %i, N: %i\n", pIndex, nIndex);
473
474 return correct;
475}
476//__________________________________________________________
6555e2ad 477Int_t AliAnalysisTaskCheckV0tenderII::PDGtoPIDv0(Int_t pdgV0) const {
3a72645a 478 //
479 // convert thereconstructed V0 pdg to local pid
480 //
481
482 switch(pdgV0){
483 case 22: return 0; break;
484 case 310: return 1; break;
485 case 3122: return 2; break;
486 case -3122: return 3; break;
487 }
488
489 return -1;
490
491}
492//__________________________________________________________
6555e2ad 493Int_t AliAnalysisTaskCheckV0tenderII::PDGtoPID(Int_t pdg) const {
3a72645a 494 //
495 // convert daughter pdg code to local pid
496 //
497 switch(TMath::Abs(pdg)){
498 case 11: return 0; break;
499 case 211: return 1; break;
500 case 2212: return 2; break;
501 }
502 return -1;
503
504}