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 *){
163 AliMCEventHandler* mcHandler = (dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()));
164 AliESDInputHandler *inh = dynamic_cast<AliESDInputHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
165 AliESDpid *workingPID = NULL;
166 if(inh && (workingPID = inh->GetESDpid())) workingPID = inh->GetESDpid();
167 else workingPID = AliHFEtools::GetDefaultPID(mcHandler ? kTRUE : kFALSE);
170 if(fMCEvent && !mcHandler ) return;
171 if(fMCEvent && !mcHandler->InitOk() ) return;
172 if(fMCEvent && !mcHandler->TreeK() ) return;
173 if(fMCEvent && !mcHandler->TreeTR() ) return;
180 ProcessDaughtersMC();
184 PostData(1, fEvents);
185 PostData(2, fOutput);
187 //__________________________________________________________
188 void AliAnalysisTaskCheckV0tender::Terminate(Option_t *){
190 // Do Post Processing
193 //__________________________________________________________
194 void AliAnalysisTaskCheckV0tender::ProcessV0s(){
196 // loop over the V0s and extract the information about
197 // the V0s tagged by the V0 tender
200 const char * type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
203 Int_t nV0s = fInputEvent->GetNumberOfV0s();
204 for(Int_t i=0; i<nV0s; ++i){
205 AliESDv0 *esdV0 = (dynamic_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
207 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
208 Int_t pid = GetTenderPidV0(esdV0);
209 if(pid < 0) continue;
210 fColl->Fill("h_NumberOf_V0s", pid);
211 sprintf(name, "h_%s_pt", type[pid]);
212 Float_t pT = esdV0->Pt();
213 fColl->Fill(name, pT);
214 Float_t mass = MassV0(esdV0, pid);
215 sprintf(name, "h_%s_mass", type[pid]);
216 fColl->Fill(name, mass);
220 //__________________________________________________________
221 void AliAnalysisTaskCheckV0tender::ProcessDaughters(){
223 // produce some check plots for V0 tender tagged single tracks
226 const char * type[3] = {"Electron", "Pion", "Proton"};
229 Int_t nTracks = fInputEvent->GetNumberOfTracks();
230 for(Int_t i=0; i<nTracks; ++i){
231 AliESDtrack *track = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(i));
233 Int_t pid = GetTenderPidDaughter(track);
234 if(pid < 0) continue;
235 fColl->Fill("h_NumberOfDaughters", pid*1.0);
236 Float_t pT = track->Pt();
237 sprintf(name, "h_%s_pt", type[pid]);
238 fColl->Fill(name, pT);
242 //__________________________________________________________
243 void AliAnalysisTaskCheckV0tender::ProcessV0sMC(){
245 // check all V0tender selected V0 on their true identity
248 const Int_t pid2pdg[4] = {22, 310, 3122, -3122};
249 const char * type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
251 Int_t nV0s = fInputEvent->GetNumberOfV0s();
253 Int_t nTracks = fInputEvent->GetNumberOfTracks();
256 for(Int_t i=0; i<nV0s; ++i){
258 AliESDv0 *esdV0 = (dynamic_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
260 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
261 Int_t pid = GetTenderPidV0(esdV0);
262 if(pid < 0) continue;
264 // both ESD daughtr tracks
267 iP = esdV0->GetPindex();
268 iN = esdV0->GetNindex();
269 if(iN < 0 || iP < 0) continue;
270 if(iN >= nTracks || iP >= nTracks) continue;
271 AliESDtrack *dP, *dN;
272 dP = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iP));
273 dN = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iN));
274 if(!dN || !dP) continue;
276 // MC labels of the daughter tracks
280 if(lN < 0 || lP < 0) continue;
282 // MC daughter particles
283 AliMCParticle *mcP, *mcN;
284 mcP = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lP));
285 mcN = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lN));
286 if(!mcP || !mcN) continue;
288 // labels of the mother particles
290 lPm = mcP->GetMother();
291 lNm = mcN->GetMother();
292 if(lPm < 0) continue;
293 AliMCParticle *m = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lPm));
295 Int_t pdg = m->PdgCode();
296 if((lPm == lNm) && (pdg == pid2pdg[pid])) id = kTRUE;
298 if(id) sprintf(name, "h_%s_pt_S", type[pid]);
299 else sprintf(name, "h_%s_pt_B", type[pid]);
300 Float_t pT = esdV0->Pt();
301 fCollMC->Fill(name, pT);
303 if(id) sprintf(name, "h_%s_mass_S", type[pid]);
304 else sprintf(name, "h_%s_mass_B", type[pid]);
305 Float_t mass = MassV0(esdV0, pid);
306 fCollMC->Fill(name, mass);
310 //__________________________________________________________
311 void AliAnalysisTaskCheckV0tender::ProcessDaughtersMC(){
313 // check the identity of the V0tender selected V0 daughters
314 // !!! for positive check only the true identity plays a role here,
315 // not the true V0 mother identity (e.g. selected electron could come
316 // from primary vertex or pion dalitz deca or true gamma conversion) !!!
319 const Int_t pid2pdg [3] = {11, 211, 2212};
320 const char * type[3] = {"Electron", "Pion", "Proton"};
324 Int_t nTracks = fInputEvent->GetNumberOfTracks();
325 for(Int_t i=0; i<nTracks; ++i){
327 AliESDtrack *track = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(i));
329 Int_t pid = GetTenderPidDaughter(track);
330 if(pid < 0) continue;
331 Float_t pT = track->Pt();
332 Int_t label = track->GetLabel();
333 if(label < 0) continue;
334 AliMCParticle *mcp = 0x0;
335 mcp = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(label));
337 Int_t pdg = TMath::Abs(mcp->PdgCode());
338 if(pdg == pid2pdg[pid]) id = kTRUE;
339 if(id) sprintf(name, "h_%s_pt_S", type[pid]);
340 else sprintf(name, "h_%s_pt_B", type[pid]);
341 fCollMC->Fill(name, pT);
344 //__________________________________________________________
345 Int_t AliAnalysisTaskCheckV0tender::GetTenderPidV0(AliESDv0 * const v0){
347 // retrieve the PID nformation stored in the status flags by the train tender
354 if(v0->TestBit(BIT(14))){
358 if(v0->TestBit(BIT(15))){
362 if(v0->TestBit(BIT(16))){
366 if(v0->TestBit(BIT(17))){
371 AliWarning("V0 track labeled multiple times by the V0 tender");
375 //printf(" -D: pid: %i \n", pid);
379 //__________________________________________________________
380 Int_t AliAnalysisTaskCheckV0tender::GetTenderPidDaughter(AliESDtrack * const track){
382 // retrieve the PID nformation stored in the status flags by the train tender
390 if(track->TestBit(BIT(14))){
394 if(track->TestBit(BIT(15))){
398 if(track->TestBit(BIT(16))){
403 AliWarning("V0 track labeled multiple times by the V0 tender");
408 //__________________________________________________________
409 Float_t AliAnalysisTaskCheckV0tender::MassV0(AliESDv0 * const v0, Int_t id){
411 // Get the V0 effective mass
415 Bool_t sign = CheckSigns(v0);
417 mass = v0->GetEffMass(0, 0);
420 mass = v0->GetEffMass(2, 2);
423 mass = (sign) ? v0->GetEffMass(4, 2) : v0->GetEffMass(2, 4);
426 mass = (sign) ? v0->GetEffMass(2, 4) : v0->GetEffMass(4, 2);
429 AliWarning(Form("Unrecognized V0 id: %i", id));
435 //__________________________________________________________
436 Bool_t AliAnalysisTaskCheckV0tender::CheckSigns(AliESDv0 * const v0){
438 // check wheter the sign was correctly applied to
439 // V0 daughter tracks
440 // This function should become obsolete once the V0 finder will be updated (fixed)
443 Bool_t correct = kFALSE;
445 Int_t pIndex = 0, nIndex = 0;
446 pIndex = v0->GetPindex();
447 nIndex = v0->GetNindex();
450 d[0] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(pIndex));
451 d[1] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(nIndex));
454 sign[0] = (int)d[0]->GetSign();
455 sign[1] = (int)d[1]->GetSign();
457 if(-1 == sign[0] && 1 == sign[1]){
459 //v0->SetIndex(0, pIndex); // set the index of the negative v0 track
460 //v0->SetIndex(1, nIndex); // set the index of the positive v0 track
466 //pIndex = v0->GetPindex();
467 //nIndex = v0->GetNindex();
468 //printf("-D2: P: %i, N: %i\n", pIndex, nIndex);