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>
28 #include "AliAnalysisManager.h"
29 #include "AliMCEventHandler.h"
30 #include "AliESDInputHandler.h"
32 #include "AliESDtrack.h"
33 #include "AliMCParticle.h"
34 #include "AliMCEvent.h"
36 #include "AliHFEtools.h"
37 #include "AliHFEcollection.h"
39 #include "AliAnalysisTaskCheckV0tender.h"
41 ClassImp(AliAnalysisTaskCheckV0tender)
43 //__________________________________________________________
44 AliAnalysisTaskCheckV0tender::AliAnalysisTaskCheckV0tender():
45 AliAnalysisTaskSE("CheckV0tenderTask")
52 // Default Constructor
55 //__________________________________________________________
56 AliAnalysisTaskCheckV0tender::AliAnalysisTaskCheckV0tender(const Char_t *name):
57 AliAnalysisTaskSE(name)
64 // Default Constructor
66 DefineOutput(1, TH1F::Class());
67 DefineOutput(2, TList::Class());
70 //__________________________________________________________
71 AliAnalysisTaskCheckV0tender::~AliAnalysisTaskCheckV0tender(){
76 if (fOutput) delete fOutput;
77 //if (fColl) delete fColl;
78 //if (fCollMC) delete fCollMC;
79 if (fEvents) delete fEvents;
81 //__________________________________________________________
82 void AliAnalysisTaskCheckV0tender::UserCreateOutputObjects(){
84 // prepare output objects
87 fOutput = new TList();
89 // Counter for number of events
90 fEvents = new TH1I("nEvents", "NumberOfEvents", 1, 1, 2);
92 fColl = new AliHFEcollection("V0_QA", "tender V0s for data");
93 fCollMC = new AliHFEcollection("V0_MC_QA", "tender V0s for MC");
99 // total number of tagged V0s
100 fColl->CreateTH1F("h_NumberOf_V0s", "Number of tagged V0s; type; counts", 4, -0.5, 3.5);
101 // pT spectra of the tagged V0s
102 fColl->CreateTH1F("h_Gamma_pt", "p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
103 fColl->CreateTH1F("h_K0_pt", "p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
104 fColl->CreateTH1F("h_Lambda_pt", "p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
105 fColl->CreateTH1F("h_ALambda_pt", "p_{T} spectrum of tagged A-Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
106 // invariant mass of the V0s
107 fColl->CreateTH1F("h_Gamma_mass", "Inv. Mass of the ", 100, 0., 0.1);
108 fColl->CreateTH1F("h_K0_mass", "Inv. Mass of the ", 100, 0.45, 0.55);
109 fColl->CreateTH1F("h_Lambda_mass", "Inv. Mass of the ", 100, 1.08, 1.14);
110 fColl->CreateTH1F("h_ALambda_mass", "Inv. Mass of the ", 100, 1.08, 1.14);
112 // total number of tagged daughter particles (should correlate with number of V0s !
113 fColl->CreateTH1F("h_NumberOfDaughters", "Number of tagged daughters; type; counts", 3, -0.5, 2.5);
114 // pT spectra of tagged daughter particles
115 fColl->CreateTH1F("h_Electron_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
116 fColl->CreateTH1F("h_Pion_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
117 fColl->CreateTH1F("h_Proton_pt", "p_{T} spectrum of tagged; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
123 // pT spectra of the tagged V0s
124 fCollMC->CreateTH1F("h_Gamma_pt_S", "MC-S: p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
125 fCollMC->CreateTH1F("h_K0_pt_S", "MC-S: p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
126 fCollMC->CreateTH1F("h_Lambda_pt_S", "MC-S: p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
127 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);
128 fCollMC->CreateTH1F("h_Gamma_pt_B", "MC-B: p_{T} spectrum of tagged gammas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
129 fCollMC->CreateTH1F("h_K0_pt_B", "MC-B: p_{T} spectrum of tagged K0s; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
130 fCollMC->CreateTH1F("h_Lambda_pt_B", "MC-B: p_{T} spectrum of tagged Lambdas; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
131 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);
132 // invariant mass of the V0s
133 fCollMC->CreateTH1F("h_Gamma_mass_S", "MC-S: Inv. Mass of the gamma; m (GeV/c^{2}); counts", 100, 0., 0.1);
134 fCollMC->CreateTH1F("h_K0_mass_S", "MC-S: Inv. Mass of the K0; m (GeV/c^{2}); counts", 100, 0.45, 0.55);
135 fCollMC->CreateTH1F("h_Lambda_mass_S", "MC-S: Inv. Mass of the Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
136 fCollMC->CreateTH1F("h_ALambda_mass_S", "MC-S: Inv. Mass of the A-Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
137 fCollMC->CreateTH1F("h_Gamma_mass_B", "MC-B: Inv. Mass of the gamma; m (GeV/c^{2}); counts", 100, 0., 0.1);
138 fCollMC->CreateTH1F("h_K0_mass_B", "MC-B: Inv. Mass of the K0; m (GeV/c^{2}); counts", 100, 0.45, 0.55);
139 fCollMC->CreateTH1F("h_Lambda_mass_B", "MC-B: Inv. Mass of the Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
140 fCollMC->CreateTH1F("h_ALambda_mass_B", "MC-B: Inv. Mass of the A-Lambda; m (GeV/c^{2}); counts", 100, 1.08, 1.14);
141 // pT spectra of tagged daughter particles
142 fCollMC->CreateTH1F("h_Electron_pt_S", "MC-S: p_{T} spectrum of tagged electrons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
143 fCollMC->CreateTH1F("h_Pion_pt_S", "MC-S: p_{T} spectrum of tagged pions; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
144 fCollMC->CreateTH1F("h_Proton_pt_S", "MC-S: p_{T} spectrum of tagged protons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
145 fCollMC->CreateTH1F("h_Electron_pt_B", "MC-B: p_{T} spectrum of tagged electrons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
146 fCollMC->CreateTH1F("h_Pion_pt_B", "MC-B: p_{T} spectrum of tagged pions; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
147 fCollMC->CreateTH1F("h_Proton_pt_B", "MC-B: p_{T} spectrum of tagged protons; p_{T} (GeV/c); counts", 20, 0.1, 20, 0);
150 TList *tmp = fColl->GetList();
151 tmp->SetName(fColl->GetName());
154 tmp = fCollMC->GetList();
155 tmp->SetName(fCollMC->GetName());
160 //__________________________________________________________
161 void AliAnalysisTaskCheckV0tender::UserExec(Option_t *){
166 AliMCEventHandler* mcHandler = (dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()));
167 //AliESDInputHandler *inh = dynamic_cast<AliESDInputHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
168 //AliESDpid *workingPID = NULL;
169 //if(inh && (workingPID = inh->GetESDpid())) workingPID = inh->GetESDpid();
170 //else workingPID = AliHFEtools::GetDefaultPID(mcHandler ? kTRUE : kFALSE);
173 if(fMCEvent && !mcHandler ) return;
174 if(fMCEvent && !mcHandler->InitOk() ) return;
175 if(fMCEvent && !mcHandler->TreeK() ) return;
176 if(fMCEvent && !mcHandler->TreeTR() ) return;
183 ProcessDaughtersMC();
187 PostData(1, fEvents);
188 PostData(2, fOutput);
190 //__________________________________________________________
191 void AliAnalysisTaskCheckV0tender::Terminate(Option_t *){
193 // Do Post Processing
196 //__________________________________________________________
197 void AliAnalysisTaskCheckV0tender::ProcessV0s(){
199 // loop over the V0s and extract the information about
200 // the V0s tagged by the V0 tender
203 const TString type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
206 Int_t nV0s = fInputEvent->GetNumberOfV0s();
207 for(Int_t i=0; i<nV0s; ++i){
208 AliESDv0 *esdV0 = (static_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
210 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
211 Int_t pid = GetTenderPidV0(esdV0);
212 //if(pid < 0) continue;
214 fColl->Fill("h_NumberOf_V0s", pid);
215 Float_t pT = esdV0->Pt();
216 name = "h_" + type[pid] + "_pt";
217 fColl->Fill(name, pT);
218 Float_t mass = MassV0(esdV0, pid);
219 name = "h_" + type[pid] + "_mass";
220 //printf(" -D: name: %s \n", name.Data());
221 fColl->Fill(name, mass);
225 //__________________________________________________________
226 void AliAnalysisTaskCheckV0tender::ProcessDaughters(){
228 // produce some check plots for V0 tender tagged single tracks
231 const TString type[3] = {"Electron", "Pion", "Proton"};
234 Int_t nTracks = fInputEvent->GetNumberOfTracks();
235 for(Int_t i=0; i<nTracks; ++i){
236 AliESDtrack *track = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(i));
238 Int_t pid = GetTenderPidDaughter(track);
239 if(pid < 0) continue;
240 fColl->Fill("h_NumberOfDaughters", pid*1.0);
241 Float_t pT = track->Pt();
242 name = "h_" + type[pid] + "_pt";
243 fColl->Fill(name, pT);
247 //__________________________________________________________
248 void AliAnalysisTaskCheckV0tender::ProcessV0sMC(){
250 // check all V0tender selected V0 on their true identity
253 const Int_t pid2pdg[4] = {22, 310, 3122, -3122};
254 const TString type[4] = {"Gamma", "K0", "Lambda", "ALambda"};
256 Int_t nV0s = fInputEvent->GetNumberOfV0s();
258 Int_t nTracks = fInputEvent->GetNumberOfTracks();
261 for(Int_t i=0; i<nV0s; ++i){
263 AliESDv0 *esdV0 = (static_cast<AliESDEvent *>(fInputEvent))->GetV0(i);
265 if(!esdV0->GetOnFlyStatus()) continue; // Take only V0s from the On-the-fly v0 finder
266 Int_t pid = GetTenderPidV0(esdV0);
267 if(pid < 0) continue;
269 // both ESD daughtr tracks
272 iP = esdV0->GetPindex();
273 iN = esdV0->GetNindex();
274 if(iN < 0 || iP < 0) continue;
275 if(iN >= nTracks || iP >= nTracks) continue;
276 AliESDtrack *dP, *dN;
277 dP = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iP));
278 dN = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(iN));
279 if(!dN || !dP) continue;
281 // MC labels of the daughter tracks
285 if(lN < 0 || lP < 0) continue;
287 // MC daughter particles
288 AliMCParticle *mcP, *mcN;
289 mcP = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lP));
290 mcN = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lN));
291 if(!mcP || !mcN) continue;
293 // labels of the mother particles
295 lPm = mcP->GetMother();
296 lNm = mcN->GetMother();
297 if(lPm < 0) continue;
298 AliMCParticle *m = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(lPm));
300 Int_t pdg = m->PdgCode();
301 if((lPm == lNm) && (pdg == pid2pdg[pid])) id = kTRUE;
303 if(id) name = "h_" + type[pid] + "_pt_S";
304 else name = "h_" + type[pid] + "_pt_B";
305 Float_t pT = esdV0->Pt();
306 fCollMC->Fill(name, pT);
308 if(id) name = "h_" + type[pid] + "_mass_S";
309 else name = "h_" + type[pid] + "_mass_B";
310 Float_t mass = MassV0(esdV0, pid);
311 fCollMC->Fill(name, mass);
315 //__________________________________________________________
316 void AliAnalysisTaskCheckV0tender::ProcessDaughtersMC(){
318 // check the identity of the V0tender selected V0 daughters
319 // !!! for positive check only the true identity plays a role here,
320 // not the true V0 mother identity (e.g. selected electron could come
321 // from primary vertex or pion dalitz deca or true gamma conversion) !!!
324 const Int_t pid2pdg [3] = {11, 211, 2212};
325 const TString type[3] = {"Electron", "Pion", "Proton"};
329 Int_t nTracks = fInputEvent->GetNumberOfTracks();
330 for(Int_t i=0; i<nTracks; ++i){
332 AliESDtrack *track = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(i));
334 Int_t pid = GetTenderPidDaughter(track);
335 if(pid < 0) continue;
336 Float_t pT = track->Pt();
337 Int_t label = track->GetLabel();
338 if(label < 0) continue;
339 AliMCParticle *mcp = 0x0;
340 mcp = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(label));
342 Int_t pdg = TMath::Abs(mcp->PdgCode());
343 if(pdg == pid2pdg[pid]) id = kTRUE;
344 if(id) name = "h_" + type[pid] + "_pt_S";
345 else name = "h_" + type[pid] + "_pt_B";
346 fCollMC->Fill(name, pT);
349 //__________________________________________________________
350 Int_t AliAnalysisTaskCheckV0tender::GetTenderPidV0(AliESDv0 * const v0){
352 // retrieve the PID nformation stored in the status flags by the train tender
359 if(v0->TestBit(BIT(14))){
363 if(v0->TestBit(BIT(15))){
367 if(v0->TestBit(BIT(16))){
371 if(v0->TestBit(BIT(17))){
376 AliWarning("V0 track labeled multiple times by the V0 tender");
380 //printf(" -D: pid: %i \n", pid);
384 //__________________________________________________________
385 Int_t AliAnalysisTaskCheckV0tender::GetTenderPidDaughter(AliESDtrack * const track){
387 // retrieve the PID nformation stored in the status flags by the train tender
395 if(track->TestBit(BIT(14))){
399 if(track->TestBit(BIT(15))){
403 if(track->TestBit(BIT(16))){
408 AliWarning("V0 track labeled multiple times by the V0 tender");
413 //__________________________________________________________
414 Float_t AliAnalysisTaskCheckV0tender::MassV0(AliESDv0 * const v0, Int_t id){
416 // Get the V0 effective mass
420 Bool_t sign = CheckSigns(v0);
422 mass = v0->GetEffMass(0, 0);
425 mass = v0->GetEffMass(2, 2);
428 mass = (sign) ? v0->GetEffMass(4, 2) : v0->GetEffMass(2, 4);
431 mass = (sign) ? v0->GetEffMass(2, 4) : v0->GetEffMass(4, 2);
434 AliWarning(Form("Unrecognized V0 id: %i", id));
440 //__________________________________________________________
441 Bool_t AliAnalysisTaskCheckV0tender::CheckSigns(AliESDv0 * const v0){
443 // check wheter the sign was correctly applied to
444 // V0 daughter tracks
445 // This function should become obsolete once the V0 finder will be updated (fixed)
448 Bool_t correct = kFALSE;
450 Int_t pIndex = 0, nIndex = 0;
451 pIndex = v0->GetPindex();
452 nIndex = v0->GetNindex();
455 d[0] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(pIndex));
456 d[1] = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(nIndex));
459 sign[0] = (int)d[0]->GetSign();
460 sign[1] = (int)d[1]->GetSign();
462 if(-1 == sign[0] && 1 == sign[1]){
464 //v0->SetIndex(0, pIndex); // set the index of the negative v0 track
465 //v0->SetIndex(1, nIndex); // set the index of the positive v0 track
471 //pIndex = v0->GetPindex();
472 //nIndex = v0->GetNindex();
473 //printf("-D2: P: %i, N: %i\n", pIndex, nIndex);