]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/GammaConv/ConvCorrelations/AliAnalysisTaskGammaJet.cxx
Updating conv correlation software
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / ConvCorrelations / AliAnalysisTaskGammaJet.cxx
CommitLineData
811b0806 1
fc7e3b59 2/**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Primary Author: Svein Lindal <slindal@fys.uio.no> *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/// @file AliAnalysisTaskGammaJet.cxx
18/// @author Svein Lindal
19/// @brief Class used to run conversion gamma/pion - hadron/jet analysis
20
21
22#include <iostream>
23#include "TChain.h"
24#include "TTree.h"
25#include "TH1F.h"
26#include "TCanvas.h"
27#include "TString.h"
28#include "TObjArray.h"
29
30
811b0806 31#include "TH2F.h"
32
fc7e3b59 33#include "AliAnalysisTask.h"
34#include "AliAnalysisManager.h"
35#include "AliAnalysisTaskGammaJet.h"
36
37#include "AliESDEvent.h"
38#include "AliESDCaloCluster.h"
39#include "AliESDInputHandler.h"
40
41#include "AliAODPWG4ParticleCorrelation.h"
42#include "AliAODEvent.h"
43#include "AliAODHandler.h"
44#include "AliAODCaloCluster.h"
45#include "AliGammaConversionAODObject.h"
46#include "AliAODConversionParticle.h"
47#include "AliAODJet.h"
48
49#include "AliAODInputHandler.h"
50
51#include "AliAnaConvIsolation.h"
52
53#include "AliAnaConvCorrPhoton.h"
54#include "AliAnaConvCorrPhotonJet.h"
811b0806 55#include "AliAnaConvCorrPionJet.h"
fc7e3b59 56#include "AliAnaConvCorrPion.h"
811b0806 57
58#include "AliAODTrack.h"
59
fc7e3b59 60// Gamma - jet correlation analysis task
61// Authors: Svein Lindal
62
63
64using namespace std;
65
66ClassImp(AliAnalysisTaskGammaJet)
67
68//________________________________________________________________________
69AliAnalysisTaskGammaJet::AliAnalysisTaskGammaJet() :
70AliAnalysisTaskSE(),
71 fOutputList(NULL),
811b0806 72 fEtaLimit(0.8),
fc7e3b59 73 fDeltaAODFileName("AliAODGammaConversion.root"),
811b0806 74 fGammaCutString("GammaConv"),
75 fPionCutString("GammaConv"),
fc7e3b59 76 fAnaIsolation(NULL),
77 fAnaIsolationArray(NULL),
78 fAnaPionArray(NULL),
79 fAnaPhotonArray(NULL),
80 fAnaPhotonJetArray(NULL),
811b0806 81 fAnaPionJetArray(NULL),
82 fMinPt(1.0),
fc7e3b59 83 fMinNTracks(20)
84{
85 // Dummy Constructor
86}
87
88//________________________________________________________________________________
89AliAnalysisTaskGammaJet::~AliAnalysisTaskGammaJet() {
90 //Destructor
91}
92
93
94//________________________________________________________________________
95AliAnalysisTaskGammaJet::AliAnalysisTaskGammaJet(const char *name) :
96 AliAnalysisTaskSE(name),
97 fOutputList(0),
811b0806 98 fEtaLimit(0.8),
fc7e3b59 99 fDeltaAODFileName("AliAODGammaConversion.root"),
811b0806 100 fGammaCutString("GammaConv"),
101 fPionCutString("GammaConv"),
fc7e3b59 102 fAnaIsolation(NULL),
103 fAnaIsolationArray(NULL),
104 fAnaPionArray(NULL),
105 fAnaPhotonArray(NULL),
106 fAnaPhotonJetArray(NULL),
811b0806 107 fAnaPionJetArray(NULL),
108 fMinPt(1.0),
fc7e3b59 109 fMinNTracks(20)
110{
111 // Constructor
112 // Output slot #1 writes into a TList container
113 DefineOutput(1, TList::Class());
114
115 fAnaIsolation = new AliAnaConvIsolation();
116
117 fAnaPionArray = new TObjArray();
118 fAnaPionArray->SetOwner(kTRUE);
119
120 fAnaPhotonArray = new TObjArray();
121 fAnaPhotonArray->SetOwner(kTRUE);
122
123 fAnaPhotonJetArray = new TObjArray();
124 fAnaPhotonJetArray->SetOwner(kTRUE);
125
811b0806 126 fAnaPionJetArray = new TObjArray();
127 fAnaPionJetArray->SetOwner(kTRUE);
128
fc7e3b59 129 fAnaIsolationArray = new TObjArray();
130 fAnaIsolationArray->SetOwner(kTRUE);
131
132}
133
811b0806 134//________________________________________________________________________
135void AliAnalysisTaskGammaJet::UserExec(Option_t *)
136{
137 //Inherited from AliAnalysisTaskSE
138
139 ///Get AOD event
140 AliAODEvent * aodEvent = GetAODEvent();
141 if(!aodEvent) {
142 cout << "No AOD event!!" << endl;
143 return;
144 }
145
146 TClonesArray * photons = GetConversionGammas(aodEvent);
147 if(!photons) {
148 cout << "No Conversion gamma!!" << endl;
149 return;
150 }
151
152 TClonesArray * pions = GetConversionPions(aodEvent);
153 if(!pions) {
154 cout << "No Conversion pion branch!!" << endl;
155 return;
156 }
157
158 TClonesArray * tracks = aodEvent->GetTracks();
159 if(!tracks) {
160 cout << "Can't get tracks!!" << endl;
161 return;
162 }
163
164 if(!((Entry() )%10000)) {
165 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
166 AliInfo(Form("%d %d", photons->GetEntriesFast(), pions->GetEntriesFast()));
167 }
168
169
170 if(pions->GetEntriesFast() > photons->GetEntriesFast() ) {
171 cout << "WTF!!!!"<<endl;
172 }
173
174 // if( (photons->GetEntriesFast() > 0) ) {
175 // cout << "Neext evetn !!!!!!!!!!!!!!!!" << Entry() << endl;
176 // } else {
177 // cout << "____________________________"<<endl;
178 // }
179
180
181 if(aodEvent->GetNumberOfTracks() < 2 && photons->GetEntriesFast() > 0 ) {
182 cout << "we have a photon but less than 2 tracks" << endl;
183 return;
184 }
185
186 if(aodEvent->GetNumberOfTracks() < fMinNTracks) return;
187
188 if( (photons->GetEntriesFast() > 0) ) {
189 ProcessConvGamma(photons, pions, tracks);
190 ProcessPions(pions, photons, tracks);
191 }
192
193
194
195 TClonesArray * jets = aodEvent->GetJets();
196 if(jets && jets->GetEntriesFast() > 0) {
197 for(int i = 0; i < fAnaPhotonJetArray->GetEntriesFast(); i++) {
198 AliAnaConvCorrPhotonJet * jetAna = dynamic_cast<AliAnaConvCorrPhotonJet*>(fAnaPhotonJetArray->At(i));
199 if(jetAna) {
200 for(Int_t iJet = 0; iJet < jets->GetEntriesFast(); iJet++) {
201 AliAODJet * jet = dynamic_cast<AliAODJet*>(jets->At(iJet));
202 if(jet) {
203 jetAna->DoJetAnalysisGamma(jet, photons, pions);
204 }
205 }
206 }
207 }
208 }
209 PostData(1, fOutputList);
210
211}
212
213
214
fc7e3b59 215//________________________________________________________________________
216void AliAnalysisTaskGammaJet::UserCreateOutputObjects()
217{
218 //Create histograms add, to outputlist
219 fOutputList = new TList();
220 fOutputList->SetOwner(kTRUE);
221
811b0806 222
223 fhTracksMissingPt[0] = new TH2F("hpttracksmissing", "hpttracksmissing",200, 0, 200, 200, 0, 200);
224 fOutputList->Add(fhTracksMissingPt[0]);
225 fhTracksMissingPt[1] = new TH2F("hpttrackpresent", "hptbothtrackspresent" ,200, 0, 200, 200, 0, 200);
226 fOutputList->Add(fhTracksMissingPt[1]);
227
fc7e3b59 228 fAnaIsolation->CreateHistograms();
229 fOutputList->Add(fAnaIsolation->GetHistograms());
230
231 for(int i = 0; i < fAnaIsolationArray->GetEntriesFast(); i++) {
232 AliAnaConvIsolation * isoAna = dynamic_cast<AliAnaConvIsolation*>(fAnaIsolationArray->At(i));
233 if(isoAna) {
234 isoAna->CreateHistograms();
235 fOutputList->Add(isoAna->GetHistograms());
236 } else {
237 AliError("problem getting ana pointer!!!");
238 cout << i << endl;
239 }
240 }
241
242 for(int i = 0; i < fAnaPhotonArray->GetEntriesFast(); i++) {
243 AliAnaConvCorrPhoton * photonAna = dynamic_cast<AliAnaConvCorrPhoton*>(fAnaPhotonArray->At(i));
244 if(photonAna) {
245 photonAna->CreateHistograms();
246 fOutputList->Add(photonAna->GetHistograms());
247 } else {
248 AliError("problem getting ana pointer!!!");
249 }
250 }
251
252
253 for(int i = 0; i < fAnaPionArray->GetEntriesFast(); i++) {
254 AliAnaConvCorrPion * pionAna = dynamic_cast<AliAnaConvCorrPion*>(fAnaPionArray->At(i));
255 if(pionAna) {
256 pionAna->CreateHistograms();
257 fOutputList->Add(pionAna->GetHistograms());
258 } else {
259 AliError("problem getting ana pointer!!!");
260 }
261 }
262
263 for(int i = 0; i < fAnaPhotonJetArray->GetEntriesFast(); i++) {
264 AliAnaConvCorrPhotonJet * jetAna = dynamic_cast<AliAnaConvCorrPhotonJet*>(fAnaPhotonJetArray->At(i));
265 if(jetAna) {
266 jetAna->CreateHistograms();
267 fOutputList->Add(jetAna->GetHistograms());
268 } else {
269 AliError("problem getting jet ana pointer!!!");
270 }
271 }
fc7e3b59 272
811b0806 273 for(int i = 0; i < fAnaPionJetArray->GetEntriesFast(); i++) {
274 AliAnaConvCorrPionJet * jetAna = dynamic_cast<AliAnaConvCorrPionJet*>(fAnaPionJetArray->At(i));
275 if(jetAna) {
276 jetAna->CreateHistograms();
277 fOutputList->Add(jetAna->GetHistograms());
278 } else {
279 AliError("problem getting jet ana pointer!!!");
280 }
fc7e3b59 281 }
282
811b0806 283
fc7e3b59 284
fc7e3b59 285 PostData(1, fOutputList);
286
811b0806 287
fc7e3b59 288}
289
290
291
292
811b0806 293
fc7e3b59 294//______________________________________________________________________________________________
295void AliAnalysisTaskGammaJet::ProcessCalorimeters( const AliAODEvent * const aodEvent ) {
296 //See header file for documentation
297 TClonesArray * clusters = aodEvent->GetCaloClusters();
298
299
300 for(int ic = 0; ic < clusters->GetEntriesFast(); ic++) {
301 AliAODCaloCluster * cluster = dynamic_cast<AliAODCaloCluster*>(clusters->At(ic));
302 if (!cluster) {
303 AliError(Form("Error getting cluster"));
304 continue;
305 }
306
307
308 if (cluster->GetNCells() < 6) continue;
309 if (cluster->GetEmcCpvDistance() < 15) continue;
310
311 TLorentzVector tlvec;
312
313 AliAODVertex * vertex = aodEvent->GetPrimaryVertex();
314 Double_t vertexPosition[3];
315 vertex->GetXYZ(vertexPosition);
316 cluster->GetMomentum(tlvec, vertexPosition);
317 //if (tlvec.Pt() < GetMinPt()) continue;
318
319 }
320
321}
322
811b0806 323//______________________________________________________________________________________________
324Bool_t AliAnalysisTaskGammaJet::EventIsSynced(const TClonesArray * const tracks, const TClonesArray * const convGamma, const TClonesArray * const pions) {
325 //See header file for documentation
326
327 for (Int_t iPhot = 0; iPhot < convGamma->GetEntriesFast(); iPhot++) {
328 AliAODConversionParticle * photon = dynamic_cast<AliAODConversionParticle*>(convGamma->At(iPhot));
329 if(photon) {
330 AliAODTrack * track1 = NULL;
331 AliAODTrack * track2 = NULL;
332 for(Int_t i = 0; i < tracks->GetEntriesFast(); i++) {
333 AliAODTrack * track = dynamic_cast<AliAODTrack*>(tracks->At(i));
334 if(track->GetID() == photon->GetLabel1()) track1 = track;
335 else if (track->GetID() == photon->GetLabel2()) track2 = track;
336 if(track1 && track2) break;
337 }
338
339 if(track1 && track2) {
340 Float_t totE = track1->E() + track2->E();
341 if(TMath::Abs(totE - photon->E()) > 1.0) {
342 cout << "BALLE BALLE "<<TMath::Abs(totE - photon->P()) << endl;
343
344 cout << track2->Px() << " "
345 << track2->Py() << " "
346 << track2->Pz() << " "
347 << track2->P() << " "
348 << track2->E() << endl;
349
350 cout << track1->Px() << " "
351 << track1->Py() << " "
352 << track1->Pz() << " "
353 << track1->P() << " "
354 << track1->E() << endl;
355
356
357 cout << track1->Px() + track2->Px() << " "
358 << track1->Py() + track2->Py() << " "
359 << track1->Pz() + track2->Pz() << " "
360 << track1->P() + track2->P() << " "
361 << track1->E() + track2->E() << endl;
362
363 cout << photon->Px() << " " << photon->Py() << " " << photon->Pz() << " " << photon->P() << " " << photon->E() << endl;
364 return kFALSE;
365 }
366 } else {
367 cout << Entry() << " " << convGamma->GetEntriesFast() << " " << photon->GetLabel1() << " " << photon->GetLabel2() << endl;
368 cout << "Could not get both tracks!!! " <<endl;
369 return kFALSE;
370 }
371 }
372 }
373
374 //cout <<"insync"<<endl;
375 return kTRUE;
376}
377
378
379//______________________________________________________________________________________________
380Bool_t AliAnalysisTaskGammaJet::BothTracksPresent(const AliAODConversionParticle * const photon, const TClonesArray * const tracks) const {
381
382 AliAODTrack * track1 = NULL;
383 AliAODTrack * track2 = NULL;
384 for(Int_t i = 0; i < tracks->GetEntriesFast(); i++) {
385 AliAODTrack * track = dynamic_cast<AliAODTrack*>(tracks->At(i));
386 if(track->GetID() == photon->GetLabel1()) track1 = track;
387 else if (track->GetID() == photon->GetLabel2()) track2 = track;
388 if(track1 && track2) break;
389 }
390
391 if(track1 && track2) {
392 return kTRUE;
393 }
394 cout << "Could not get both tracks!!! labels " << photon->GetLabel1() << " " << photon->GetLabel2() <<endl;
395 return kFALSE;
396
397
398}
399
400//______________________________________________________________________________________________
401Bool_t AliAnalysisTaskGammaJet::BothGammaPresent(const AliAODConversionParticle * const pion, const TClonesArray * const photons, const TClonesArray * const tracks) const {
402
403 AliAODConversionParticle * photon1 = dynamic_cast<AliAODConversionParticle*>(photons->At(pion->GetLabel1()));
404 AliAODConversionParticle * photon2 = dynamic_cast<AliAODConversionParticle*>(photons->At(pion->GetLabel2()));
405
406 if(photon1 && photon2) {
407 if( BothTracksPresent(photon1, tracks) && BothTracksPresent(photon1, tracks)) {
408 return kTRUE;
409 }
410 } else {
411 cout << "can't find both photons "<< endl;
412 }
413
414 return kFALSE;
415}
416
417
418
419
fc7e3b59 420//___________________________________________________________________________________________
421void AliAnalysisTaskGammaJet::ProcessConvGamma( const TClonesArray * convGamma, const TClonesArray * const pions, const TClonesArray * tracks ) {
422 //See header file for documentation
811b0806 423
fc7e3b59 424
425 for (Int_t iPhot = 0; iPhot < convGamma->GetEntriesFast(); iPhot++) {
426 Bool_t delP = kFALSE;
427 AliAODConversionParticle * photon = dynamic_cast<AliAODConversionParticle*>(convGamma->At(iPhot));
428 if(!photon) {
429 AliGammaConversionAODObject * aodO = dynamic_cast<AliGammaConversionAODObject*>(convGamma->At(iPhot));
430 if (!aodO) {
431 AliError(Form("ERROR: Could not receive ga %d\n", iPhot));
432 continue;
433 }
434
435 photon = new AliAODConversionParticle(aodO);
436 delP = kTRUE;
437 }
438
811b0806 439 Bool_t btp = BothTracksPresent(photon, tracks);
440 fhTracksMissingPt[btp]->Fill(photon->Pt(), tracks->GetEntriesFast());
441 if(!btp || photon->Pt() < fMinPt || TMath::Abs(photon->Eta()) > fEtaLimit) {
fc7e3b59 442 if(delP) delete photon;
443 continue;
444 }
445
446 Bool_t leading = kTRUE;
447 Bool_t decayPion = IsDecayPion(iPhot, pions);
448
449 for(Int_t i = 0; i < fAnaIsolationArray->GetEntriesFast(); i ++) {
450 AliAnaConvIsolation * isoAna = dynamic_cast<AliAnaConvIsolation*>(fAnaIsolationArray->At(i));
4574af57 451 if(isoAna) isoAna->IsIsolated(photon, tracks, leading);
fc7e3b59 452 }
453
454 Bool_t isolated = fAnaIsolation->IsIsolated(photon, tracks, leading);
455 if(leading) {
456 for(Int_t i = 0; i < fAnaPhotonArray->GetEntriesFast(); i ++) {
457 AliAnaConvCorrPhoton * ana = static_cast<AliAnaConvCorrPhoton*>(fAnaPhotonArray->At(i));
4574af57 458 if(ana) {
fc7e3b59 459 ana->CorrelateWithHadrons(photon, tracks, isolated, decayPion);
460 }
461 }
462
463 TClonesArray * jets = GetAODEvent()->GetJets();
464 if(jets) {
465 for(Int_t i = 0; i < fAnaPhotonJetArray->GetEntriesFast(); i ++) {
466 AliAnaConvCorrPhotonJet * ana = static_cast<AliAnaConvCorrPhotonJet*>(fAnaPhotonJetArray->At(i));
4574af57 467 if(ana) {
fc7e3b59 468 ana->CorrelateWithHadrons(photon, jets, isolated);
469 }
470 }
471 } else {
472 cout << "No jets "<<endl;
473 }
474 }
4574af57 475 if (delP) delete photon;
fc7e3b59 476 } //
477}
478
479///______________________________________________________________________________________________
480void AliAnalysisTaskGammaJet::ProcessPions( const TClonesArray * const pions, const TClonesArray * const photons, const TClonesArray * const tracks) {
481 //See header file for documentation
482
811b0806 483
fc7e3b59 484 for (Int_t iPi = 0; iPi < pions->GetEntriesFast(); iPi++) {
485 Bool_t delP = kFALSE;
486 AliAODConversionParticle * pion = dynamic_cast<AliAODConversionParticle*>(pions->At(iPi));
487 if(!pion) {
488 AliGammaConversionAODObject * aodO = dynamic_cast<AliGammaConversionAODObject*>(pions->At(iPi));
489 if (!aodO) {
811b0806 490 AliError(Form("ERROR: Could not receive ga %d\n", iPi));
491 continue;
fc7e3b59 492 }
493
494 pion = new AliAODConversionParticle(aodO);
495 delP = kTRUE;
496 }
497
811b0806 498 if (!BothGammaPresent(pion, photons, tracks) || pion->Pt() < fMinPt || TMath::Abs(pion->Eta()) > fEtaLimit ) {
fc7e3b59 499 if(delP) delete pion;
811b0806 500 return;
fc7e3b59 501 }
502
503
504 Int_t trackLabels[4] = {-1, -1, -1, -1};
505 GetPionGrandChildren(pion, photons, trackLabels);
506 Bool_t leading = kTRUE;
507
508 for(Int_t i = 0; i < fAnaIsolationArray->GetEntriesFast(); i ++) {
509 AliAnaConvIsolation * isoAna = dynamic_cast<AliAnaConvIsolation*>(fAnaIsolationArray->At(i));
4574af57 510 if(isoAna) isoAna->IsIsolated(pion, tracks, 4, trackLabels, leading);
fc7e3b59 511 }
512
513 Bool_t isolated = fAnaIsolation->IsIsolated(pion, tracks, 4, trackLabels, leading);
514 if(leading) {
515 for(Int_t i = 0; i < fAnaPionArray->GetEntriesFast(); i ++) {
811b0806 516 AliAnaConvCorrPion * ana = dynamic_cast<AliAnaConvCorrPion*>(fAnaPionArray->At(i));
517 if(ana) ana->CorrelateWithHadrons(pion, tracks, isolated, 4, trackLabels );
518 }
519
520
521 TClonesArray * jets = GetAODEvent()->GetJets();
522 if(jets) {
523 for(Int_t i = 0; i < fAnaPionJetArray->GetEntriesFast(); i ++) {
524 AliAnaConvCorrPionJet * ana = static_cast<AliAnaConvCorrPionJet*>(fAnaPionJetArray->At(i));
525 if(ana) {
526 ana->CorrelateWithHadrons(pion, jets, isolated);
527 }
528 }
529 } else {
530 cout << "No jets "<<endl;
fc7e3b59 531 }
811b0806 532
533
fc7e3b59 534 }
535 if (delP) delete pion;
536 } //
811b0806 537
fc7e3b59 538
811b0806 539
540 // for (Int_t iPhot = 0; iPhot < photons->GetEntriesFast(); iPhot++) {
541 // AliAODConversionParticle * photon = dynamic_cast<AliAODConversionParticle*>(photons->At(iPhot));
542 // if(photon) {
543 // for (Int_t iPhot2 = iPhot+1; iPhot2 < photons->GetEntriesFast(); iPhot2++) {
544 // AliAODConversionParticle * photon2 = dynamic_cast<AliAODConversionParticle*>(photons->At(iPhot2));
545 // if(photon2) {
546 // Int_t trackLabels[4] = {photon->GetTrackLabel(0), photon->GetTrackLabel(1), photon2->GetTrackLabel(0), photon2->GetTrackLabel(1)};
547 // AliAODConversionParticle * pion = new AliAODConversionParticle(photon, photon2);
548 // Bool_t leading = kTRUE;
549 // Bool_t isolated = fAnaIsolation->IsIsolated(pion, tracks, 4, trackLabels, leading);
550 // if(leading) {
551 // for(Int_t i = 0; i < fAnaPionArray->GetEntriesFast(); i ++) {
552 // AliAnaConvCorrPion * ana = dynamic_cast<AliAnaConvCorrPion*>(fAnaPionArray->At(i));
553 // if(ana) ana->CorrelateWithHadrons(pion, tracks, isolated, 4, trackLabels );
554 // }
555 // delete pion;
556 // }
557 // }
558 // }
559 // }
560 // }
fc7e3b59 561}
562
563///_______________________________________________________________________________________________
564Bool_t AliAnalysisTaskGammaJet::IsDecayPion(Int_t iPhot, const TClonesArray * const pions) {
565 //See header file for documentation
566
567 for(int ip = 0; ip < pions->GetEntriesFast(); ip++) {
568 AliAODConversionParticle * pion = dynamic_cast<AliAODConversionParticle*>(pions->At(ip));
569 if(pion) {
570 if(pion->GetLabel1() == iPhot || pion->GetLabel2() == iPhot)
571
572 return kTRUE;
573 } else {
574 AliGammaConversionAODObject * aodPion = dynamic_cast<AliGammaConversionAODObject*>(pions->At(ip));
575 if(aodPion) {
576 if(aodPion->GetLabel1() == iPhot || aodPion->GetLabel2() == iPhot)
577 return kTRUE;
578 } else {
579 AliError("pion corrupted!");
580 }
581 }
582 }
583
584 return kFALSE;
585}
586
587
588///_______________________________________________________________________________
589Bool_t AliAnalysisTaskGammaJet::UserNotify() {
590 //See header file for documentation
591
592 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
593
811b0806 594 // AliAnaConvCorrPhoton * phJetAna = dynamic_cast<AliAnaConvCorrPhoton*>(fAnaPhotonArray->At(0));
595 // phJetAna->PrintStatistics();
fc7e3b59 596
597 return kTRUE;
598
599}
600
601///_______________________________________________________________________________
602void AliAnalysisTaskGammaJet::NotifyRun() {
603 //See header file for documentation
604
605 AliInfo(Form("we have a new run: %d", fCurrentRunNumber));
606 cout << Form("we have a new run: %d", fCurrentRunNumber) << endl;
607
608}
609
610///_______________________________________________________________________________
611void AliAnalysisTaskGammaJet::GetPionGrandChildren(const AliAODConversionParticle * pion, const TClonesArray * photons, Int_t* trackLabels) {
612 ///Get the track labels of the electrons reconstructed as gamma forming the pion
613
614 for(Int_t i = 0; i< 2; i++) {
615 AliAODConversionParticle * gamma = dynamic_cast<AliAODConversionParticle*>(photons->At(pion->GetTrackLabel(i)));
616
617 if(gamma) {
618 for(Int_t j = 0; j< 2; j++) {
619 trackLabels[ i*2+ j] = gamma->GetTrackLabel(j);
620 }
621
622 } else {
623 AliGammaConversionAODObject * aodO = dynamic_cast<AliGammaConversionAODObject*>(photons->At(pion->GetTrackLabel(i)));
624 if(aodO) {
625 trackLabels[i*2] = aodO->GetLabel1();
626 trackLabels[i*2 + 1] = aodO->GetLabel2();
627 } else {
628 cout << "AliAnaConvCorrPion::GetTrackLabels() :: Not good!!!"<<endl;
629 }
630 }
631 }
632}
633
634
635
636
637//_____________________________________________________________________
638void AliAnalysisTaskGammaJet::Terminate(Option_t *) {
639 // Draw result to the screen
640 // Called once at the end of the query
641}
642
643//_____________________________________________________________________
644AliAODEvent * AliAnalysisTaskGammaJet::GetAODEvent() {
645 //Get the AOD event from whereever it might be
646 AliAODEvent * aodEvent = dynamic_cast<AliAODEvent*>(InputEvent());
811b0806 647
648
fc7e3b59 649 if(!aodEvent) {
811b0806 650 cout << "!!!!!!!!!!!!!!!!!!!!!!!!Getting AODEvent();" << endl;
fc7e3b59 651 aodEvent = AODEvent();
811b0806 652 } else {
653 //cout << "got aod from input event1" << endl;
fc7e3b59 654 }
fc7e3b59 655 return aodEvent;
656
657}
658
659//_____________________________________________________________________
660TClonesArray * AliAnalysisTaskGammaJet::GetConversionGammas(const AliAODEvent * aodEvent) {
661
662 //Get Conversion gamma branch of AOD. First try standard AOD
811b0806 663 TClonesArray * convGamma = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(Form("%s_gamma", fGammaCutString.Data())));
fc7e3b59 664
665 //If it's there, send it back
811b0806 666 if(convGamma) {
667 //cout << "found conv gamma branch in aod event!!!"<<endl;
668 return convGamma;
669 }else {
670 cout << "did NOT !!! find conv gamma branch in aod event!!!"<<endl;
671 }
fc7e3b59 672
673 //If AOD not in standard file have to locate it in delta AOD
674 if( !(fDeltaAODFileName.Length() > 0) ) return NULL;
675
676 AliAODHandler * aodHandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
677 if(aodHandler) {
678 AliAODExtension * gExt = dynamic_cast<AliAODExtension*>(aodHandler->GetExtensions()->FindObject(fDeltaAODFileName));
679 if(gExt) {
680 AliAODEvent * gcEvent = gExt->GetAOD();
811b0806 681 return dynamic_cast<TClonesArray*>(gcEvent->FindListObject(Form("%s_gamma", fGammaCutString.Data())));
fc7e3b59 682 }
683 }
684
811b0806 685 cout << "could not find branch " << Form("%s_gamma", fPionCutString.Data()) << endl;
fc7e3b59 686 return NULL;
687}
688
689
690
691///_____________________________________________________________________
692TClonesArray * AliAnalysisTaskGammaJet::GetConversionPions(const AliAODEvent * aodEvent) {
693
694 //Get Conversion pion branch of AOD. First try standard AOD
811b0806 695 TClonesArray * convGamma = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(Form("%s_Pi0", fPionCutString.Data()) ));
fc7e3b59 696
697 //If it's there, send it back
698 if(convGamma) return convGamma;
699
700
701 //If AOD not in standard file have to locate it in delta AOD
702 if( !(fDeltaAODFileName.Length() > 0) ) return NULL;
703
704 AliAODHandler * aodHandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
705 if(aodHandler) {
706 AliAODExtension * gExt = dynamic_cast<AliAODExtension*>(aodHandler->GetExtensions()->FindObject(fDeltaAODFileName));
707 if(gExt) {
708 AliAODEvent * gcEvent = gExt->GetAOD();
811b0806 709 return dynamic_cast<TClonesArray*>(gcEvent->FindListObject(Form("%s_Pi0", fPionCutString.Data())));
fc7e3b59 710 }
711 }
712 return NULL;
713}