1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // Task fir checking the performance of the V0 tender
20 // Matus Kalisky <matus.kalisky@cern.ch>
26 #include "AliAnalysisManager.h"
27 #include "AliMCEventHandler.h"
28 #include "AliESDInputHandler.h"
30 #include "AliESDtrack.h"
31 #include "AliMCParticle.h"
32 #include "AliMCEvent.h"
34 #include "AliHFEtools.h"
35 #include "AliHFEcollection.h"
37 #include "AliAnalysisTaskCheckV0tender.h"
39 ClassImp(AliAnalysisTaskCheckV0tender)
41 //__________________________________________________________
42 AliAnalysisTaskCheckV0tender::AliAnalysisTaskCheckV0tender():
43 AliAnalysisTaskSE("CheckV0tenderTask")
50 // Default Constructor
53 //__________________________________________________________
54 AliAnalysisTaskCheckV0tender::AliAnalysisTaskCheckV0tender(const Char_t *name):
55 AliAnalysisTaskSE(name)
62 // Default Constructor
64 DefineOutput(1, TH1F::Class());
65 DefineOutput(2, TList::Class());
68 //__________________________________________________________
69 AliAnalysisTaskCheckV0tender::~AliAnalysisTaskCheckV0tender(){
74 if (fOutput) delete fOutput;
75 if (fColl) delete fColl;
76 if (fCollMC) delete fCollMC;
77 if (fEvents) delete fEvents;
79 //__________________________________________________________
80 void AliAnalysisTaskCheckV0tender::UserCreateOutputObjects(){
82 // prepare output objects
85 fOutput = new TList();
87 // Counter for number of events
88 fEvents = new TH1I("nEvents", "NumberOfEvents", 1, 1, 2);
90 fColl = new AliHFEcollection("V0_QA", "tender V0s for data");
91 fCollMC = new AliHFEcollection("V0_MC_QA", "tender V0s for MC");
97 // total number of tagged V0s
98 fColl->CreateTH1F("h_NumberOf_V0s", "Number of tagged V0s; type; counts", 4, -0.5, 3.5);
99 // pT spectra of the tagged V0s
100 fColl->CreateTH1F("h_Gamma_pt", "p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
101 fColl->CreateTH1F("h_K0_pt", "p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
102 fColl->CreateTH1F("h_Lambda_pt", "p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
103 fColl->CreateTH1F("h_ALambda_pt", "p_{T} spectrum of tagged A-Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
104 // invariant mass of the V0s
105 fColl->CreateTH1F("h_Gamma_mass", "Inv. Mass of the ", 100, 0., 0.1);
106 fColl->CreateTH1F("h_K0_mass", "Inv. Mass of the ", 100, 0.45, 0.55);
107 fColl->CreateTH1F("h_Lambda_mass", "Inv. Mass of the ", 100, 1.08, 1.14);
108 fColl->CreateTH1F("h_ALambda_mass", "Inv. Mass of the ", 100, 1.08, 1.14);
110 // total number of tagged daughter particles (should correlate with number of V0s !
111 fColl->CreateTH1F("h_NumberOfDaughters", "Number of tagged daughters; type; counts", 3, -0.5, 2.5);
112 // pT spectra of tagged daughter particles
113 fColl->CreateTH1F("h_Electron_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
114 fColl->CreateTH1F("h_Pion_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
115 fColl->CreateTH1F("h_Proton_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
121 // pT spectra of the tagged V0s
122 fCollMC->CreateTH1F("h_Gamma_pt_S", "MC-S: p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
123 fCollMC->CreateTH1F("h_K0_pt_S", "MC-S: p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
124 fCollMC->CreateTH1F("h_Lambda_pt_S", "MC-S: p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
125 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);
126 fCollMC->CreateTH1F("h_Gamma_pt_B", "MC-B: p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
127 fCollMC->CreateTH1F("h_K0_pt_B", "MC-B: p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
128 fCollMC->CreateTH1F("h_Lambda_pt_B", "MC-B: p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
129 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);
130 // invariant mass of the V0s
131 fCollMC->CreateTH1F("h_Gamma_mass_S", "MC-S: Inv. Mass of the gamma; m (GeV/c^{2}); counts", 100, 0., 0.1);
132 fCollMC->CreateTH1F("h_K0_mass_S", "MC-S: Inv. Mass of the K0; m (GeV/c^{2}); counts", 100, 0.45, 0.55);
133 fCollMC->CreateTH1F("h_Lambda_mass_S", "MC-S: Inv. Mass of the Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
134 fCollMC->CreateTH1F("h_ALambda_mass_S", "MC-S: Inv. Mass of the A-Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
135 fCollMC->CreateTH1F("h_Gamma_mass_B", "MC-B: Inv. Mass of the gamma; m (GeV/c^{2}); counts", 100, 0., 0.1);
136 fCollMC->CreateTH1F("h_K0_mass_B", "MC-B: Inv. Mass of the K0; m (GeV/c^{2}); counts", 100, 0.45, 0.55);
137 fCollMC->CreateTH1F("h_Lambda_mass_B", "MC-B: Inv. Mass of the Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
138 fCollMC->CreateTH1F("h_ALambda_mass_B", "MC-B: Inv. Mass of the A-Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
139 // pT spectra of tagged daughter particles
140 fCollMC->CreateTH1F("h_Electron_pt_S", "MC-S: p_{T} spectrum of tagged electrons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
141 fCollMC->CreateTH1F("h_Pion_pt_S", "MC-S: p_{T} spectrum of tagged pions; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
142 fCollMC->CreateTH1F("h_Proton_pt_S", "MC-S: p_{T} spectrum of tagged protons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
143 fCollMC->CreateTH1F("h_Electron_pt_B", "MC-B: p_{T} spectrum of tagged electrons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
144 fCollMC->CreateTH1F("h_Pion_pt_B", "MC-B: p_{T} spectrum of tagged pions; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
145 fCollMC->CreateTH1F("h_Proton_pt_B", "MC-B: p_{T} spectrum of tagged protons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
148 TList *tmp = fColl->GetList();
149 tmp->SetName(fColl->GetName());
152 tmp = fCollMC->GetList();
153 tmp->SetName(fCollMC->GetName());
158 //__________________________________________________________
159 void AliAnalysisTaskCheckV0tender::UserExec(Option_t *){
164 AliMCEventHandler* mcHandler = (dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()));
165 //AliESDInputHandler *inh = dynamic_cast<AliESDInputHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
166 //AliESDpid *workingPID = NULL;
167 //if(inh && (workingPID = inh->GetESDpid())) workingPID = inh->GetESDpid();
168 //else workingPID = AliHFEtools::GetDefaultPID(mcHandler ? kTRUE : kFALSE);
171 if(fMCEvent && !mcHandler ) return;
172 if(fMCEvent && !mcHandler->InitOk() ) return;
173 if(fMCEvent && !mcHandler->TreeK() ) return;
174 if(fMCEvent && !mcHandler->TreeTR() ) return;
181 ProcessDaughtersMC();
185 PostData(1, fEvents);
186 PostData(2, fOutput);
188 //__________________________________________________________
189 void AliAnalysisTaskCheckV0tender::Terminate(Option_t *){
191 // Do Post Processing
194 //__________________________________________________________
195 void AliAnalysisTaskCheckV0tender::ProcessV0s(){
197 // loop over the V0s and extract the information about
198 // the V0s tagged by the V0 tender
201 const char * type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
204 Int_t nV0s = fInputEvent->GetNumberOfV0s();
205 for(Int_t i=0; i<nV0s; ++i){
206 AliESDv0 *esdV0 = (static_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
208 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
209 Int_t pid = GetTenderPidV0(esdV0);
210 if(pid < 0) continue;
211 fColl->Fill("h_NumberOf_V0s", pid);
212 sprintf(name, "h_%s_pt", type[pid]);
213 Float_t pT = esdV0->Pt();
214 fColl->Fill(name, pT);
215 Float_t mass = MassV0(esdV0, pid);
216 sprintf(name, "h_%s_mass", type[pid]);
217 fColl->Fill(name, mass);
221 //__________________________________________________________
222 void AliAnalysisTaskCheckV0tender::ProcessDaughters(){
224 // produce some check plots for V0 tender tagged single tracks
227 const char * type[3] = {"Electron", "Pion", "Proton"};
230 Int_t nTracks = fInputEvent->GetNumberOfTracks();
231 for(Int_t i=0; i<nTracks; ++i){
232 AliESDtrack *track = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(i));
234 Int_t pid = GetTenderPidDaughter(track);
235 if(pid < 0) continue;
236 fColl->Fill("h_NumberOfDaughters", pid*1.0);
237 Float_t pT = track->Pt();
238 sprintf(name, "h_%s_pt", type[pid]);
239 fColl->Fill(name, pT);
243 //__________________________________________________________
244 void AliAnalysisTaskCheckV0tender::ProcessV0sMC(){
246 // check all V0tender selected V0 on their true identity
249 const Int_t pid2pdg[4] = {22, 310, 3122, -3122};
250 const char * type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
252 Int_t nV0s = fInputEvent->GetNumberOfV0s();
254 Int_t nTracks = fInputEvent->GetNumberOfTracks();
257 for(Int_t i=0; i<nV0s; ++i){
259 AliESDv0 *esdV0 = (static_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
261 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
262 Int_t pid = GetTenderPidV0(esdV0);
263 if(pid < 0) continue;
265 // both ESD daughtr tracks
268 iP = esdV0->GetPindex();
269 iN = esdV0->GetNindex();
270 if(iN < 0 || iP < 0) continue;
271 if(iN >= nTracks || iP >= nTracks) continue;
272 AliESDtrack *dP, *dN;
273 dP = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iP));
274 dN = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iN));
275 if(!dN || !dP) continue;
277 // MC labels of the daughter tracks
281 if(lN < 0 || lP < 0) continue;
283 // MC daughter particles
284 AliMCParticle *mcP, *mcN;
285 mcP = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lP));
286 mcN = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lN));
287 if(!mcP || !mcN) continue;
289 // labels of the mother particles
291 lPm = mcP->GetMother();
292 lNm = mcN->GetMother();
293 if(lPm < 0) continue;
294 AliMCParticle *m = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lPm));
296 Int_t pdg = m->PdgCode();
297 if((lPm == lNm) && (pdg == pid2pdg[pid])) id = kTRUE;
299 if(id) sprintf(name, "h_%s_pt_S", type[pid]);
300 else sprintf(name, "h_%s_pt_B", type[pid]);
301 Float_t pT = esdV0->Pt();
302 fCollMC->Fill(name, pT);
304 if(id) sprintf(name, "h_%s_mass_S", type[pid]);
305 else sprintf(name, "h_%s_mass_B", type[pid]);
306 Float_t mass = MassV0(esdV0, pid);
307 fCollMC->Fill(name, mass);
311 //__________________________________________________________
312 void AliAnalysisTaskCheckV0tender::ProcessDaughtersMC(){
314 // check the identity of the V0tender selected V0 daughters
315 // !!! for positive check only the true identity plays a role here,
316 // not the true V0 mother identity (e.g. selected electron could come
317 // from primary vertex or pion dalitz deca or true gamma conversion) !!!
320 const Int_t pid2pdg [3] = {11, 211, 2212};
321 const char * type[3] = {"Electron", "Pion", "Proton"};
325 Int_t nTracks = fInputEvent->GetNumberOfTracks();
326 for(Int_t i=0; i<nTracks; ++i){
328 AliESDtrack *track = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(i));
330 Int_t pid = GetTenderPidDaughter(track);
331 if(pid < 0) continue;
332 Float_t pT = track->Pt();
333 Int_t label = track->GetLabel();
334 if(label < 0) continue;
335 AliMCParticle *mcp = 0x0;
336 mcp = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(label));
338 Int_t pdg = TMath::Abs(mcp->PdgCode());
339 if(pdg == pid2pdg[pid]) id = kTRUE;
340 if(id) sprintf(name, "h_%s_pt_S", type[pid]);
341 else sprintf(name, "h_%s_pt_B", type[pid]);
342 fCollMC->Fill(name, pT);
345 //__________________________________________________________
346 Int_t AliAnalysisTaskCheckV0tender::GetTenderPidV0(AliESDv0 * const v0){
348 // retrieve the PID nformation stored in the status flags by the train tender
355 if(v0->TestBit(BIT(14))){
359 if(v0->TestBit(BIT(15))){
363 if(v0->TestBit(BIT(16))){
367 if(v0->TestBit(BIT(17))){
372 AliWarning("V0 track labeled multiple times by the V0 tender");
376 //printf(" -D: pid: %i \n", pid);
380 //__________________________________________________________
381 Int_t AliAnalysisTaskCheckV0tender::GetTenderPidDaughter(AliESDtrack * const track){
383 // retrieve the PID nformation stored in the status flags by the train tender
391 if(track->TestBit(BIT(14))){
395 if(track->TestBit(BIT(15))){
399 if(track->TestBit(BIT(16))){
404 AliWarning("V0 track labeled multiple times by the V0 tender");
409 //__________________________________________________________
410 Float_t AliAnalysisTaskCheckV0tender::MassV0(AliESDv0 * const v0, Int_t id){
412 // Get the V0 effective mass
416 Bool_t sign = CheckSigns(v0);
418 mass = v0->GetEffMass(0, 0);
421 mass = v0->GetEffMass(2, 2);
424 mass = (sign) ? v0->GetEffMass(4, 2) : v0->GetEffMass(2, 4);
427 mass = (sign) ? v0->GetEffMass(2, 4) : v0->GetEffMass(4, 2);
430 AliWarning(Form("Unrecognized V0 id: %i", id));
436 //__________________________________________________________
437 Bool_t AliAnalysisTaskCheckV0tender::CheckSigns(AliESDv0 * const v0){
439 // check wheter the sign was correctly applied to
440 // V0 daughter tracks
441 // This function should become obsolete once the V0 finder will be updated (fixed)
444 Bool_t correct = kFALSE;
446 Int_t pIndex = 0, nIndex = 0;
447 pIndex = v0->GetPindex();
448 nIndex = v0->GetNindex();
451 d[0] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(pIndex));
452 d[1] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(nIndex));
455 sign[0] = (int)d[0]->GetSign();
456 sign[1] = (int)d[1]->GetSign();
458 if(-1 == sign[0] && 1 == sign[1]){
460 //v0->SetIndex(0, pIndex); // set the index of the negative v0 track
461 //v0->SetIndex(1, nIndex); // set the index of the positive v0 track
467 //pIndex = v0->GetPindex();
468 //nIndex = v0->GetNindex();
469 //printf("-D2: P: %i, N: %i\n", pIndex, nIndex);