AliPhysics  b752f14 (b752f14)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskResolution.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Authors: Friederike Bock *
5  * Version 1.0 *
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 
17 //---------------------------------------------
18 // QA Task for V0 Reader V1
19 //---------------------------------------------
21 
23 #include "TChain.h"
24 #include "AliAnalysisManager.h"
25 #include "TParticle.h"
26 #include "TVectorF.h"
27 #include "AliPIDResponse.h"
28 #include "AliESDtrackCuts.h"
29 #include "AliAODEvent.h"
30 #include "TFile.h"
31 
32 class iostream;
33 
34 using namespace std;
35 
37 
38 //________________________________________________________________________
40  fV0Reader(NULL),
41  fV0ReaderName("V0ReaderV1"),
42  fConversionGammas(NULL),
43  fEventCuts(NULL),
44  fConversionCuts(NULL),
45  fTreeEvent(NULL),
46  fTreeResolution(NULL),
47  fPrimVtxZ(0.),
48  fNContrVtx(0),
49  fNESDtracksEta09(0),
50  fNESDtracksEta0914(0),
51  fNESDtracksEta14(0),
52  fGammaRecCoords(5),
53  fGammaMCCoords(5),
54  fChi2ndf(0),
55  fIsHeavyIon(0),
56  fIsMC(kFALSE),
57  fOutputList(NULL),
58  fEventList(NULL),
59  fResolutionList(NULL),
60  fESDEvent(NULL),
61  fMCEvent(NULL)
62 {
63 
64 
65 }
66 
67 //________________________________________________________________________
69  fV0Reader(NULL),
70  fV0ReaderName("V0ReaderV1"),
71  fConversionGammas(NULL),
72  fEventCuts(NULL),
73  fConversionCuts(NULL),
74  fTreeEvent(NULL),
75  fTreeResolution(NULL),
76  fPrimVtxZ(0.),
77  fNContrVtx(0),
78  fNESDtracksEta09(0),
79  fNESDtracksEta0914(0),
80  fNESDtracksEta14(0),
81  fGammaRecCoords(5),
82  fGammaMCCoords(5),
83  fChi2ndf(0),
84  fIsHeavyIon(0),
85  fIsMC(kFALSE),
86  fOutputList(NULL),
87  fEventList(NULL),
88  fResolutionList(NULL),
89  fESDEvent(NULL),
90  fMCEvent(NULL)
91 {
92  // Default constructor
93 
94  DefineInput(0, TChain::Class());
95  DefineOutput(1, TList::Class());
96 }
97 
98 //________________________________________________________________________
100 {
101  // default deconstructor
102 
103 }
104 //_____________________________________________________________________________
106 {
111  }
112  return kTRUE;
113 }
114 
115 //________________________________________________________________________
117 {
118  // Create User Output Objects
119 
120  if(fOutputList != NULL){
121  delete fOutputList;
122  fOutputList = NULL;
123  }
124  if(fOutputList == NULL){
125  fOutputList = new TList();
126  fOutputList->SetOwner(kTRUE);
127  }
128 
129  fEventList = new TList();
130  fEventList->SetName("EventList");
131  fEventList->SetOwner(kTRUE);
132  fOutputList->Add(fEventList);
133 
134  fTreeEvent = new TTree("Event","Event");
135  fTreeEvent->Branch("primVtxZ",&fPrimVtxZ,"fPrimVtxZ/F");
136  fTreeEvent->Branch("nContrVtx",&fNContrVtx,"fNContrVtx/I");
137  fTreeEvent->Branch("nGoodTracksEta09",&fNESDtracksEta09,"fNESDtracksEta09/I");
138  fTreeEvent->Branch("nGoodTracksEta14",&fNESDtracksEta14,"fNESDtracksEta14/I");
139  fEventList->Add(fTreeEvent);
140 
141  if (fIsMC){
142  fResolutionList = new TList();
143  fResolutionList->SetName("ResolutionList");
144  fResolutionList->SetOwner(kTRUE);
146 
147  fTreeResolution = new TTree("Resolution","Resolution");
148  fTreeResolution->Branch("nGoodTracksEta09",&fNESDtracksEta09,"fNESDtracksEta09/I");
149  fTreeResolution->Branch("RecCoords",&fGammaRecCoords);
150  fTreeResolution->Branch("MCCoords",&fGammaMCCoords);
151  fTreeResolution->Branch("chi2ndf",&fChi2ndf,"fChi2ndf/F");
153  }
154  PostData(1, fOutputList);
155 }
156 
157 //________________________________________________________________________
159 
160  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
161 
162  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
163  if(eventQuality != 0){// Event Not Accepted
164  return;
165  }
166  fESDEvent = (AliESDEvent*) InputEvent();
167  if (fESDEvent==NULL) return;
168  if(MCEvent()){
169  fMCEvent = MCEvent();
170  }
171 
172  if(MCEvent()){
173  // Process MC Particle
174  if(fEventCuts->GetSignalRejection() != 0){
175 // if(fESDEvent->IsA()==AliESDEvent::Class()){
178  fMCEvent);
179 // }
180 // else if(fInputEvent->IsA()==AliAODEvent::Class()){
181 // fEventCuts->GetNotRejectedParticles( fEventCuts->GetSignalRejection(),
182 // fEventCuts->GetAcceptedHeader(),
183 // fInputEvent);
184 // }
185  }
186  }
187 
188 
190  fNESDtracksEta09 = CountTracks09(); // Estimate Event Multiplicity
191  fNESDtracksEta0914 = CountTracks0914(); // Estimate Event Multiplicity
193  if(fESDEvent){
194  if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors()>0) {
195  fNContrVtx = fESDEvent->GetPrimaryVertexTracks()->GetNContributors();
196  } else {
197  fNContrVtx = 0;
198  }
199 // else if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors()<1) {
200 // if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
201 // fNContrVtx = fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
202 // } else if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()<1) {
203 // fNContrVtx = 0;
204 // }
205 // }
206  }
207  fPrimVtxZ = fESDEvent->GetPrimaryVertex()->GetZ();
208 
209 // if (fIsHeavyIon == 2){
210 // if (!(fNESDtracksEta09 > 20 && fNESDtracksEta09 < 80)) return;
211 // }
212 
213 
214  if (fTreeEvent){
215  fTreeEvent->Fill();
216  }
217 
219  ProcessPhotons();
220  PostData(1, fOutputList);
221 }
222 
223 
226 
227  // Fill Histograms for QA and MC
228  for(Int_t firstGammaIndex=0;firstGammaIndex<fConversionGammas->GetEntriesFast();firstGammaIndex++){
229  AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fConversionGammas->At(firstGammaIndex));
230  if (gamma ==NULL) continue;
231  if(!fConversionCuts->PhotonIsSelected(gamma,fESDEvent)) continue;
232  fNESDtracksEta09 = CountTracks09(); // Estimate Event Multiplicity
233  fGammaRecCoords(0) = gamma->GetPhotonPt();
234  fGammaRecCoords(1) = gamma->GetPhotonPhi();
235  fGammaRecCoords(2) = gamma->GetPhotonEta();
236  fGammaRecCoords(3) = gamma->GetConversionRadius();
237  fGammaRecCoords(4) = gamma->GetConversionZ();
238  fChi2ndf = gamma->GetChi2perNDF();
239  if(MCEvent()){
240 // cout << "generating MC stack"<< endl;
241  AliStack *fMCStack = fMCEvent->Stack();
242  if (!fMCStack) continue;
243  TParticle *posDaughter = gamma->GetPositiveMCDaughter(fMCStack);
244  TParticle *negDaughter = gamma->GetNegativeMCDaughter(fMCStack);
245 // cout << "generate Daughters: "<<posDaughter << "\t" << negDaughter << endl;
246  if(fMCStack && fEventCuts->GetSignalRejection() != 0){
247  Int_t isPosFromMBHeader = fEventCuts->IsParticleFromBGEvent(gamma->GetMCLabelPositive(), fMCStack, fESDEvent);
248  Int_t isNegFromMBHeader = fEventCuts->IsParticleFromBGEvent(gamma->GetMCLabelNegative(), fMCStack, fESDEvent);
249  if( (isNegFromMBHeader < 1) || (isPosFromMBHeader < 1)) continue;
250  }
251 
252  if(posDaughter == NULL || negDaughter == NULL){
253  continue;
254  } else if(posDaughter->GetMother(0) != negDaughter->GetMother(0) || (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1)){
255  continue;
256  } else {
257 // cout << "same mother" << endl;
258  Int_t pdgCodePos;
259  if (posDaughter->GetPdgCode()) pdgCodePos = posDaughter->GetPdgCode(); else continue;
260  Int_t pdgCodeNeg;
261  if (negDaughter->GetPdgCode()) pdgCodeNeg = negDaughter->GetPdgCode(); else continue;
262 // cout << "PDG codes daughters: " << pdgCodePos << "\t" << pdgCodeNeg << endl;
263  Int_t pdgCode;
264  if (gamma->GetMCParticle(fMCStack)->GetPdgCode()) pdgCode = gamma->GetMCParticle(fMCStack)->GetPdgCode(); else continue;
265 // cout << "PDG code: " << pdgCode << endl;
266  if(TMath::Abs(pdgCodePos)!=11 || TMath::Abs(pdgCodeNeg)!=11)
267  continue;
268  else if ( !(pdgCodeNeg==pdgCodePos)){
269  TParticle *truePhotonCanditate = gamma->GetMCParticle(fMCStack);
270  if(pdgCode == 111)
271  continue;
272  else if (pdgCode == 221)
273  continue;
274  else if (!(negDaughter->GetUniqueID() != 5 || posDaughter->GetUniqueID() !=5)){
275  if(pdgCode == 22){
276  fGammaMCCoords(0) = truePhotonCanditate->Pt();
277  fGammaMCCoords(1) = gamma->GetNegativeMCDaughter(fMCStack)->Phi();
278  fGammaMCCoords(2) = gamma->GetNegativeMCDaughter(fMCStack)->Eta();
279  fGammaMCCoords(3) = gamma->GetNegativeMCDaughter(fMCStack)->R();
280  fGammaMCCoords(4) = gamma->GetNegativeMCDaughter(fMCStack)->Vz();
281 
282  if (fTreeResolution){
283  fTreeResolution->Fill();
284  }
285  }
286  } else continue; //garbage
287  } else continue; //garbage
288  }
289  }
290  }
291 }
292 
293 //________________________________________________________________________
295  Int_t fNumberOfESDTracks = 0;
296  if(fInputEvent->IsA()==AliESDEvent::Class()){
297  // Using standard function for setting Cuts
298 
299  AliStack *fMCStack = NULL;
300  if (MCEvent()){
301  fMCStack= fMCEvent->Stack();
302  if (!fMCStack) return 0;
303  }
304 
305  Bool_t selectPrimaries=kTRUE;
306  AliESDtrackCuts *EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
307  EsdTrackCuts->SetMaxDCAToVertexZ(2);
308  EsdTrackCuts->SetEtaRange(-0.9, 0.9);
309  EsdTrackCuts->SetPtRange(0.15);
310 
311  for(Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++){
312  AliESDtrack* curTrack = (AliESDtrack*) fInputEvent->GetTrack(iTracks);
313  if(!curTrack) continue;
314  if(EsdTrackCuts->AcceptTrack(curTrack) ){
315  if (fMCEvent){
316  if(fMCStack && fEventCuts->GetSignalRejection() != 0){
317  Int_t isFromMBHeader = fEventCuts->IsParticleFromBGEvent(TMath::Abs(curTrack->GetLabel()), fMCStack, fESDEvent);
318  if( (isFromMBHeader < 1) ) continue;
319  }
320  }
321  fNumberOfESDTracks++;
322  }
323  }
324  delete EsdTrackCuts;
325  EsdTrackCuts=0x0;
326  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
327  for(Int_t iTracks = 0; iTracks<fInputEvent->GetNumberOfTracks(); iTracks++){
328  AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
329  if(!curTrack->IsPrimaryCandidate()) continue;
330  if(TMath::Abs(curTrack->Eta())>0.9) continue;
331  if(curTrack->Pt()<0.15) continue;
332  if(TMath::Abs(curTrack->ZAtDCA())>2) continue;
333  fNumberOfESDTracks++;
334  }
335  }
336 
337  return fNumberOfESDTracks;
338 }
339 
340 //________________________________________________________________________
342  Int_t fNumberOfESDTracks = 0;
343  if(fInputEvent->IsA()==AliESDEvent::Class()){
344  // Using standard function for setting Cuts
345 
346  AliStack *fMCStack = NULL;
347  if (MCEvent()){
348  fMCStack= fMCEvent->Stack();
349  if (!fMCStack) return 0;
350  }
351 
352  AliESDtrackCuts *EsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
353  EsdTrackCuts->SetMaxDCAToVertexZ(5);
354  EsdTrackCuts->SetEtaRange(0.9, 1.4);
355  EsdTrackCuts->SetPtRange(0.15);
356 
357  for(Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++){
358  AliESDtrack* curTrack = (AliESDtrack*) fInputEvent->GetTrack(iTracks);
359  if(!curTrack) continue;
360  if(EsdTrackCuts->AcceptTrack(curTrack) ){
361  if (fMCEvent){
362  if(fMCStack && fEventCuts->GetSignalRejection() != 0){
363  Int_t isFromMBHeader = fEventCuts->IsParticleFromBGEvent(TMath::Abs(curTrack->GetLabel()), fMCStack, fESDEvent);
364  if( (isFromMBHeader < 1) ) continue;
365  }
366  }
367  fNumberOfESDTracks++;
368  }
369  }
370  EsdTrackCuts->SetEtaRange(-1.4, -0.9);
371  for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
372  AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
373  if(!curTrack) continue;
374  if(EsdTrackCuts->AcceptTrack(curTrack) ){
375  if (fMCEvent){
376  if(fMCStack && fEventCuts->GetSignalRejection() != 0){
377  Int_t isFromMBHeader = fEventCuts->IsParticleFromBGEvent(TMath::Abs(curTrack->GetLabel()), fMCStack, fESDEvent);
378  if( (isFromMBHeader < 1) ) continue;
379  }
380  }
381  fNumberOfESDTracks++;
382  }
383  }
384  delete EsdTrackCuts;
385  EsdTrackCuts=0x0;
386  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
387  for(Int_t iTracks = 0; iTracks<fInputEvent->GetNumberOfTracks(); iTracks++){
388  AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
389  if(TMath::Abs(curTrack->Eta())<0.9 || TMath::Abs(curTrack->Eta())>1.4 ) continue;
390  if(curTrack->Pt()<0.15) continue;
391  if(TMath::Abs(curTrack->ZAtDCA())>5) continue;
392  fNumberOfESDTracks++;
393  }
394  }
395 
396  return fNumberOfESDTracks;
397 }
398 
399 //________________________________________________________________________
401 {
402 
403 }
void SetPeriodEnum(TString periodName)
TParticle * GetMCParticle(AliStack *fMCStack)
virtual Double_t GetPhotonPhi() const
AliConversionPhotonCuts * fConversionCuts
PeriodVar GetPeriodEnum()
void SetPeriodEnumExplicit(PeriodVar periodEnum)
void GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *MCEvent)
TString GetPeriodName()
ClassImp(AliAnalysisTaskResolution) AliAnalysisTaskResolution
Bool_t IsCentralitySelected(AliVEvent *fInputEvent, AliVEvent *fMCEvent=NULL)
virtual void UserExec(Option_t *option)
int Int_t
Definition: External.C:63
virtual void Terminate(Option_t *)
TParticle * GetPositiveMCDaughter(AliStack *fMCStack)
virtual Double_t GetPhotonEta() const
Int_t IsParticleFromBGEvent(Int_t index, AliStack *MCStack, AliVEvent *InputEvent=0x0)
Cut functions.
TClonesArray * GetReconstructedGammas() const
Definition: AliV0ReaderV1.h:76
virtual Double_t GetPhotonPt() const
TList * GetAcceptedHeader()
Class handling all kinds of selection cuts for Gamma Conversion analysis.
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:81
TParticle * GetNegativeMCDaughter(AliStack *fMCStack)
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
Double_t GetConversionRadius() const
Bool_t PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent *event)