AliPhysics  a3b326c (a3b326c)
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  TParticle *posDaughter = gamma->GetPositiveMCDaughter(fMCEvent);
241  TParticle *negDaughter = gamma->GetNegativeMCDaughter(fMCEvent);
242 // cout << "generate Daughters: "<<posDaughter << "\t" << negDaughter << endl;
243  if(fMCEvent && fEventCuts->GetSignalRejection() != 0){
246  if( (isNegFromMBHeader < 1) || (isPosFromMBHeader < 1)) continue;
247  }
248 
249  if(posDaughter == NULL || negDaughter == NULL){
250  continue;
251  } else if(posDaughter->GetMother(0) != negDaughter->GetMother(0) || (posDaughter->GetMother(0) == negDaughter->GetMother(0) && posDaughter->GetMother(0) ==-1)){
252  continue;
253  } else {
254 // cout << "same mother" << endl;
255  Int_t pdgCodePos;
256  if (posDaughter->GetPdgCode()) pdgCodePos = posDaughter->GetPdgCode(); else continue;
257  Int_t pdgCodeNeg;
258  if (negDaughter->GetPdgCode()) pdgCodeNeg = negDaughter->GetPdgCode(); else continue;
259 // cout << "PDG codes daughters: " << pdgCodePos << "\t" << pdgCodeNeg << endl;
260  Int_t pdgCode;
261  if (gamma->GetMCParticle(fMCEvent)->GetPdgCode()) pdgCode = gamma->GetMCParticle(fMCEvent)->GetPdgCode(); else continue;
262 // cout << "PDG code: " << pdgCode << endl;
263  if(TMath::Abs(pdgCodePos)!=11 || TMath::Abs(pdgCodeNeg)!=11)
264  continue;
265  else if ( !(pdgCodeNeg==pdgCodePos)){
266  TParticle *truePhotonCanditate = gamma->GetMCParticle(fMCEvent);
267  if(pdgCode == 111)
268  continue;
269  else if (pdgCode == 221)
270  continue;
271  else if (!(negDaughter->GetUniqueID() != 5 || posDaughter->GetUniqueID() !=5)){
272  if(pdgCode == 22){
273  fGammaMCCoords(0) = truePhotonCanditate->Pt();
274  fGammaMCCoords(1) = gamma->GetNegativeMCDaughter(fMCEvent)->Phi();
275  fGammaMCCoords(2) = gamma->GetNegativeMCDaughter(fMCEvent)->Eta();
277  fGammaMCCoords(4) = gamma->GetNegativeMCDaughter(fMCEvent)->Vz();
278 
279  if (fTreeResolution){
280  fTreeResolution->Fill();
281  }
282  }
283  } else continue; //garbage
284  } else continue; //garbage
285  }
286  }
287  }
288 }
289 
290 //________________________________________________________________________
292  Int_t fNumberOfESDTracks = 0;
293  if(fInputEvent->IsA()==AliESDEvent::Class()){
294  // Using standard function for setting Cuts
295 
296  Bool_t selectPrimaries=kTRUE;
297  AliESDtrackCuts *EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
298  EsdTrackCuts->SetMaxDCAToVertexZ(2);
299  EsdTrackCuts->SetEtaRange(-0.9, 0.9);
300  EsdTrackCuts->SetPtRange(0.15);
301 
302  for(Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++){
303  AliESDtrack* curTrack = (AliESDtrack*) fInputEvent->GetTrack(iTracks);
304  if(!curTrack) continue;
305  if(EsdTrackCuts->AcceptTrack(curTrack) ){
306  if (fMCEvent){
307  if(fEventCuts->GetSignalRejection() != 0){
308  Int_t isFromMBHeader = fEventCuts->IsParticleFromBGEvent(TMath::Abs(curTrack->GetLabel()), fMCEvent, fESDEvent);
309  if( (isFromMBHeader < 1) ) continue;
310  }
311  }
312  fNumberOfESDTracks++;
313  }
314  }
315  delete EsdTrackCuts;
316  EsdTrackCuts=0x0;
317  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
318  for(Int_t iTracks = 0; iTracks<fInputEvent->GetNumberOfTracks(); iTracks++){
319  AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
320  if(!curTrack->IsPrimaryCandidate()) continue;
321  if(TMath::Abs(curTrack->Eta())>0.9) continue;
322  if(curTrack->Pt()<0.15) continue;
323  if(TMath::Abs(curTrack->ZAtDCA())>2) continue;
324  fNumberOfESDTracks++;
325  }
326  }
327 
328  return fNumberOfESDTracks;
329 }
330 
331 //________________________________________________________________________
333  Int_t fNumberOfESDTracks = 0;
334  if(fInputEvent->IsA()==AliESDEvent::Class()){
335  // Using standard function for setting Cuts
336 
337  AliESDtrackCuts *EsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
338  EsdTrackCuts->SetMaxDCAToVertexZ(5);
339  EsdTrackCuts->SetEtaRange(0.9, 1.4);
340  EsdTrackCuts->SetPtRange(0.15);
341 
342  for(Int_t iTracks = 0; iTracks < fInputEvent->GetNumberOfTracks(); iTracks++){
343  AliESDtrack* curTrack = (AliESDtrack*) fInputEvent->GetTrack(iTracks);
344  if(!curTrack) continue;
345  if(EsdTrackCuts->AcceptTrack(curTrack) ){
346  if (fMCEvent){
347  if(fEventCuts->GetSignalRejection() != 0){
348  Int_t isFromMBHeader = fEventCuts->IsParticleFromBGEvent(TMath::Abs(curTrack->GetLabel()), fMCEvent, fESDEvent);
349  if( (isFromMBHeader < 1) ) continue;
350  }
351  }
352  fNumberOfESDTracks++;
353  }
354  }
355  EsdTrackCuts->SetEtaRange(-1.4, -0.9);
356  for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
357  AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
358  if(!curTrack) continue;
359  if(EsdTrackCuts->AcceptTrack(curTrack) ){
360  if (fMCEvent){
361  if(fEventCuts->GetSignalRejection() != 0){
362  Int_t isFromMBHeader = fEventCuts->IsParticleFromBGEvent(TMath::Abs(curTrack->GetLabel()), fMCEvent, fESDEvent);
363  if( (isFromMBHeader < 1) ) continue;
364  }
365  }
366  fNumberOfESDTracks++;
367  }
368  }
369  delete EsdTrackCuts;
370  EsdTrackCuts=0x0;
371  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
372  for(Int_t iTracks = 0; iTracks<fInputEvent->GetNumberOfTracks(); iTracks++){
373  AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
374  if(TMath::Abs(curTrack->Eta())<0.9 || TMath::Abs(curTrack->Eta())>1.4 ) continue;
375  if(curTrack->Pt()<0.15) continue;
376  if(TMath::Abs(curTrack->ZAtDCA())>5) continue;
377  fNumberOfESDTracks++;
378  }
379  }
380 
381  return fNumberOfESDTracks;
382 }
383 
384 //________________________________________________________________________
386 {
387 
388 }
TParticle * GetMCParticle(AliMCEvent *mcEvent)
void SetPeriodEnum(TString periodName)
virtual Double_t GetPhotonPhi() const
Int_t IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *event=0x0, Int_t debug=0)
Cut functions.
AliConversionPhotonCuts * fConversionCuts
PeriodVar GetPeriodEnum()
void SetPeriodEnumExplicit(PeriodVar periodEnum)
TString GetPeriodName()
TParticle * GetPositiveMCDaughter(AliMCEvent *mcEvent)
virtual void UserExec(Option_t *option)
TParticle * GetNegativeMCDaughter(AliMCEvent *mcEvent)
void GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event)
int Int_t
Definition: External.C:63
virtual void Terminate(Option_t *)
Bool_t IsCentralitySelected(AliVEvent *event, AliMCEvent *mcEvent)
virtual Double_t GetPhotonEta() const
TClonesArray * GetReconstructedGammas() const
Definition: AliV0ReaderV1.h:85
virtual Double_t GetPhotonPt() const
TList * GetAcceptedHeader()
Class handling all kinds of selection cuts for Gamma Conversion analysis.
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:90
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)