1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
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 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // Class used to do analysis on conversion pairs
19 //---------------------------------------------
20 ////////////////////////////////////////////////
26 #include "AliAnalysisTaskGammaConversion.h"
29 #include "AliESDtrackCuts.h"
31 //#include "AliCFManager.h" // for CF
32 //#include "AliCFContainer.h" // for CF
33 #include "AliGammaConversionAODObject.h"
34 #include "AliGammaConversionBGHandler.h"
43 class AliMCEventHandler;
44 class AliESDInputHandler;
45 class AliAnalysisManager;
52 ClassImp(AliAnalysisTaskGammaConversion)
55 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
59 fMCTruth(NULL), // for CF
60 fGCMCEvent(NULL), // for CF
62 fOutputContainer(NULL),
63 fCFManager(0x0), // for CF
65 fTriggerCINT1B(kFALSE),
67 fDoNeutralMeson(kFALSE),
70 fKFReconstructedGammasTClone(NULL),
71 fCurrentEventPosElectronTClone(NULL),
72 fCurrentEventNegElectronTClone(NULL),
73 fKFReconstructedGammasCutTClone(NULL),
74 fPreviousEventTLVNegElectronTClone(NULL),
75 fPreviousEventTLVPosElectronTClone(NULL),
76 // fKFReconstructedGammas(),
79 // fCurrentEventPosElectron(),
80 // fCurrentEventNegElectron(),
81 // fKFReconstructedGammasCut(),
82 // fPreviousEventTLVNegElectron(),
83 // fPreviousEventTLVPosElectron(),
91 fMinOpeningAngleGhostCut(0.),
93 fCalculateBackground(kFALSE),
96 fNeutralMesonNtuple(NULL),
97 fTotalNumberOfAddedNtupleEntries(0),
98 fChargedParticles(NULL),
99 fChargedParticlesId(),
101 fMinPtForGammaJet(1.),
102 fMinIsoConeSize(0.2),
104 fMinPtGamChargedCorr(0.5),
106 fLeadingChargedIndex(-1),
111 fAODBranchName("GammaConv")//,
114 // Default constructor
116 /* Kenneth: the default constructor should not have any define input/output or the call to SetESDtrackCuts
117 // Common I/O in slot 0
118 DefineInput (0, TChain::Class());
119 DefineOutput(0, TTree::Class());
121 // Your private output
122 DefineOutput(1, TList::Class());
124 // Define standard ESD track cuts for Gamma-hadron correlation
129 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
130 AliAnalysisTaskSE(name),
133 fMCTruth(NULL), // for CF
134 fGCMCEvent(NULL), // for CF
136 fOutputContainer(0x0),
137 fCFManager(0x0), // for CF
139 fTriggerCINT1B(kFALSE),
141 fDoNeutralMeson(kFALSE),
144 fKFReconstructedGammasTClone(NULL),
145 fCurrentEventPosElectronTClone(NULL),
146 fCurrentEventNegElectronTClone(NULL),
147 fKFReconstructedGammasCutTClone(NULL),
148 fPreviousEventTLVNegElectronTClone(NULL),
149 fPreviousEventTLVPosElectronTClone(NULL),
150 // fKFReconstructedGammas(),
153 // fCurrentEventPosElectron(),
154 // fCurrentEventNegElectron(),
155 // fKFReconstructedGammasCut(),
156 // fPreviousEventTLVNegElectron(),
157 // fPreviousEventTLVPosElectron(),
165 fMinOpeningAngleGhostCut(0.),
167 fCalculateBackground(kFALSE),
168 fWriteNtuple(kFALSE),
170 fNeutralMesonNtuple(NULL),
171 fTotalNumberOfAddedNtupleEntries(0),
172 fChargedParticles(NULL),
173 fChargedParticlesId(),
175 fMinPtForGammaJet(1.),
176 fMinIsoConeSize(0.2),
178 fMinPtGamChargedCorr(0.5),
180 fLeadingChargedIndex(-1),
185 fAODBranchName("GammaConv")//,
188 // Common I/O in slot 0
189 DefineInput (0, TChain::Class());
190 DefineOutput(0, TTree::Class());
192 // Your private output
193 DefineOutput(1, TList::Class());
194 DefineOutput(2, AliCFContainer::Class()); // for CF
197 // Define standard ESD track cuts for Gamma-hadron correlation
201 AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
203 // Remove all pointers
205 if(fOutputContainer){
206 fOutputContainer->Clear() ;
207 delete fOutputContainer ;
222 delete fEsdTrackCuts;
232 void AliAnalysisTaskGammaConversion::Init()
235 // AliLog::SetGlobalLogLevel(AliLog::kError);
237 void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
240 if (fEsdTrackCuts!=NULL){
241 delete fEsdTrackCuts;
243 fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
244 //standard cuts from:
245 //http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
246 //fEsdTrackCuts->SetMinNClustersTPC(50);
247 //fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
248 //fEsdTrackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
249 fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
250 fEsdTrackCuts->SetRequireITSRefit(kTRUE);
251 fEsdTrackCuts->SetMaxNsigmaToVertex(3);
252 fEsdTrackCuts->SetRequireSigmaToVertex(kTRUE);
253 // fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
257 void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
259 // Execute analysis for current event
260 ConnectInputData("");
262 //Each event needs an empty branch
263 // fAODBranch->Clear();
264 fAODBranch->Delete();
266 if(fKFReconstructedGammasTClone == NULL){
267 fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
269 if(fCurrentEventPosElectronTClone == NULL){
270 fCurrentEventPosElectronTClone = new TClonesArray("AliESDtrack",0);
272 if(fCurrentEventNegElectronTClone == NULL){
273 fCurrentEventNegElectronTClone = new TClonesArray("AliESDtrack",0);
275 if(fKFReconstructedGammasCutTClone == NULL){
276 fKFReconstructedGammasCutTClone = new TClonesArray("AliKFParticle",0);
278 if(fPreviousEventTLVNegElectronTClone == NULL){
279 fPreviousEventTLVNegElectronTClone = new TClonesArray("TLorentzVector",0);
281 if(fPreviousEventTLVPosElectronTClone == NULL){
282 fPreviousEventTLVPosElectronTClone = new TClonesArray("TLorentzVector",0);
284 if(fChargedParticles == NULL){
285 fChargedParticles = new TClonesArray("AliESDtrack",0);
289 fKFReconstructedGammasTClone->Delete();
290 fCurrentEventPosElectronTClone->Delete();
291 fCurrentEventNegElectronTClone->Delete();
292 fKFReconstructedGammasCutTClone->Delete();
293 fPreviousEventTLVNegElectronTClone->Delete();
294 fPreviousEventTLVPosElectronTClone->Delete();
300 fChargedParticles->Delete();
302 fChargedParticlesId.clear();
304 //Clear the data in the v0Reader
305 // fV0Reader->UpdateEventByEventData();
307 //Take Only events with proper trigger
310 if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
314 // Process the MC information
319 //Process the v0 information with no cuts
322 // Process the v0 information
327 FillAODWithConversionGammas() ;
329 // Process reconstructed gammas
330 if(fDoNeutralMeson == kTRUE){
331 ProcessGammasForNeutralMesonAnalysis();
334 if(fDoMCTruth == kTRUE){
337 //Process reconstructed gammas electrons for Chi_c Analysis
338 if(fDoChic == kTRUE){
339 ProcessGammaElectronsForChicAnalysis();
341 // Process reconstructed gammas for gamma Jet/hadron correlations
343 ProcessGammasForGammaJetAnalysis();
346 //calculate background if flag is set
347 if(fCalculateBackground){
348 CalculateBackground();
351 //Clear the data in the v0Reader
352 fV0Reader->UpdateEventByEventData();
354 PostData(1, fOutputContainer);
355 PostData(2, fCFManager->GetParticleContainer()); // for CF
359 void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
360 // see header file for documentation
362 AliAnalysisTaskSE::ConnectInputData(option);
364 if(fV0Reader == NULL){
365 // Write warning here cuts and so on are default if this ever happens
367 fV0Reader->Initialize();
368 fDoMCTruth = fV0Reader->GetDoMCTruth();
373 void AliAnalysisTaskGammaConversion::ProcessMCData(){
374 // see header file for documentation
376 fStack = fV0Reader->GetMCStack();
377 fMCTruth = fV0Reader->GetMCTruth(); // for CF
378 fGCMCEvent = fV0Reader->GetMCEvent(); // for CF
382 Double_t containerInput[3];
384 if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
385 fCFManager->SetEventInfo(fGCMCEvent);
390 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
391 return; // aborts if the primary vertex does not have contributors.
394 for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
395 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
402 ///////////////////////Begin Chic Analysis/////////////////////////////
404 if(particle->GetPdgCode() == 443){//Is JPsi
405 if(particle->GetNDaughters()==2){
406 if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&
407 TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){
408 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
409 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
410 if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)
411 fHistograms->FillTable("Table_Electrons",3);//e+ e- from J/Psi inside acceptance
413 if( TMath::Abs(daug0->Eta()) < 0.9){
414 if(daug0->GetPdgCode() == -11)
415 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
417 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
420 if(TMath::Abs(daug1->Eta()) < 0.9){
421 if(daug1->GetPdgCode() == -11)
422 fHistograms->FillTable("Table_Electrons",1);//e+ from J/Psi inside acceptance
424 fHistograms->FillTable("Table_Electrons",2);//e- from J/Psi inside acceptance
429 // const int CHI_C0 = 10441;
430 // const int CHI_C1 = 20443;
431 // const int CHI_C2 = 445
432 if(particle->GetPdgCode() == 22){//gamma from JPsi
433 if(particle->GetMother(0) > -1){
434 if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||
435 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||
436 fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){
437 if(TMath::Abs(particle->Eta()) < 1.2)
438 fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance
442 if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){
443 if( particle->GetNDaughters() == 2){
444 TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
445 TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
447 if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){
448 if( daug0->GetPdgCode() == 443){
449 TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());
450 TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());
451 if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
452 fHistograms->FillTable("Table_Electrons",18);
455 else if (daug1->GetPdgCode() == 443){
456 TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());
457 TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());
458 if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
459 fHistograms->FillTable("Table_Electrons",18);
466 /////////////////////End Chic Analysis////////////////////////////
469 if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() ) continue;
471 if(particle->R()>fV0Reader->GetMaxRCut()) continue; // cuts on distance from collision point
473 Double_t tmpPhi=particle->Phi();
475 if(particle->Phi()> TMath::Pi()){
476 tmpPhi = particle->Phi()-(2*TMath::Pi());
480 if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
484 rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
488 if (particle->GetPdgCode() == 22){
491 if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
492 continue; // no photon as mothers!
495 if(particle->GetMother(0) >= fStack->GetNprimary()){
496 continue; // the gamma has a mother, and it is not a primary particle
499 fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
500 fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
501 fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
502 fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
503 fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
507 containerInput[0] = particle->Pt();
508 containerInput[1] = particle->Eta();
509 if(particle->GetMother(0) >=0){
510 containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
513 containerInput[2]=-1;
516 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); // generated gamma
518 if(particle->GetMother(0) < 0){ // direct gamma
519 fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
520 fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
521 fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());
522 fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);
523 fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);
526 // looking for conversion (electron + positron from pairbuilding (= 5) )
527 TParticle* ePos = NULL;
528 TParticle* eNeg = NULL;
530 if(particle->GetNDaughters() >= 2){
531 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
532 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
533 if(tmpDaughter->GetUniqueID() == 5){
534 if(tmpDaughter->GetPdgCode() == 11){
537 else if(tmpDaughter->GetPdgCode() == -11){
545 if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
550 Double_t ePosPhi = ePos->Phi();
551 if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
553 Double_t eNegPhi = eNeg->Phi();
554 if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
557 if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
558 continue; // no reconstruction below the Pt cut
561 if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
565 if(ePos->R()>fV0Reader->GetMaxRCut()){
566 continue; // cuts on distance from collision point
569 if(TMath::Abs(ePos->Vz()) > fV0Reader->GetMaxZCut()){
570 continue; // outside material
574 if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() > ePos->R()){
575 continue; // line cut to exclude regions where we do not reconstruct
581 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable); // reconstructable gamma
583 fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
584 fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
585 fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
586 fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);
587 fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);
588 fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());
590 fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());
591 fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());
592 fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());
593 fHistograms->FillHistogram("MC_E_Phi", eNegPhi);
595 fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());
596 fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());
597 fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());
598 fHistograms->FillHistogram("MC_P_Phi", ePosPhi);
602 Int_t rBin = fHistograms->GetRBin(ePos->R());
603 Int_t zBin = fHistograms->GetZBin(ePos->Vz());
604 Int_t phiBin = fHistograms->GetPhiBin(particle->Phi());
606 TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());
608 TString nameMCMappingPhiR="";
609 nameMCMappingPhiR.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
610 fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
612 TString nameMCMappingPhi="";
613 nameMCMappingPhi.Form("MC_Conversion_Mapping_Phi%02d",phiBin);
614 // fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
615 fHistograms->FillHistogram(nameMCMappingPhi, ePos->Vz(), particle->Eta());
617 TString nameMCMappingR="";
618 nameMCMappingR.Form("MC_Conversion_Mapping_R%02d",rBin);
619 // fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
620 fHistograms->FillHistogram(nameMCMappingR,ePos->Vz(), particle->Eta());
622 TString nameMCMappingPhiInR="";
623 nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",rBin);
624 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
625 fHistograms->FillHistogram(nameMCMappingPhiInR, vtxPos.Phi());
627 TString nameMCMappingZInR="";
628 nameMCMappingZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",rBin);
629 fHistograms->FillHistogram(nameMCMappingZInR,ePos->Vz() );
632 TString nameMCMappingPhiInZ="";
633 nameMCMappingPhiInZ.Form("MC_Conversion_Mapping_Phi_in_Z_%02d",zBin);
634 // fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
635 fHistograms->FillHistogram(nameMCMappingPhiInZ, vtxPos.Phi());
637 TString nameMCMappingRInZ="";
638 nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
639 fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
641 if(particle->Pt() > fLowPtMapping && particle->Pt()< fHighPtMapping){
642 TString nameMCMappingMidPtPhiInR="";
643 nameMCMappingMidPtPhiInR.Form("MC_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
644 fHistograms->FillHistogram(nameMCMappingMidPtPhiInR, vtxPos.Phi());
646 TString nameMCMappingMidPtZInR="";
647 nameMCMappingMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
648 fHistograms->FillHistogram(nameMCMappingMidPtZInR,ePos->Vz() );
651 TString nameMCMappingMidPtPhiInZ="";
652 nameMCMappingMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
653 fHistograms->FillHistogram(nameMCMappingMidPtPhiInZ, vtxPos.Phi());
655 TString nameMCMappingMidPtRInZ="";
656 nameMCMappingMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
657 fHistograms->FillHistogram(nameMCMappingMidPtRInZ,ePos->R() );
663 fHistograms->FillHistogram("MC_Conversion_R",ePos->R());
664 fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());
665 fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());
666 fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));
667 fHistograms->FillHistogram("MC_ConvGamma_E_AsymmetryP",particle->P(),eNeg->P()/particle->P());
668 fHistograms->FillHistogram("MC_ConvGamma_P_AsymmetryP",particle->P(),ePos->P()/particle->P());
671 if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted
672 fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());
673 fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());
674 fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());
675 fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);
676 fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);
678 } // end direct gamma
679 else{ // mother exits
680 /* if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0
681 fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
682 fStack->Particle(particle->GetMother(0))->GetPdgCode()==445 //chic2
684 fMCGammaChic.push_back(particle);
687 } // end if mother exits
688 } // end if particle is a photon
692 // process motherparticles (2 gammas as daughters)
693 // the motherparticle had already to pass the R and the eta cut, but no line cut.
694 // the line cut is just valid for the conversions!
696 if(particle->GetNDaughters() == 2){
698 TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
699 TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
701 if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
703 // Check the acceptance for both gammas
704 Bool_t gammaEtaCut = kTRUE;
705 if(TMath::Abs(daughter0->Eta()) > fV0Reader->GetEtaCut() || TMath::Abs(daughter1->Eta()) > fV0Reader->GetEtaCut() ) gammaEtaCut = kFALSE;
706 Bool_t gammaRCut = kTRUE;
707 if(daughter0->R() > fV0Reader->GetMaxRCut() || daughter1->R() > fV0Reader->GetMaxRCut() ) gammaRCut = kFALSE;
711 // check for conversions now -> have to pass eta, R and line cut!
712 Bool_t daughter0Electron = kFALSE;
713 Bool_t daughter0Positron = kFALSE;
714 Bool_t daughter1Electron = kFALSE;
715 Bool_t daughter1Positron = kFALSE;
717 if(daughter0->GetNDaughters() >= 2){ // first gamma
718 for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){
719 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
720 if(tmpDaughter->GetUniqueID() == 5){
721 if(tmpDaughter->GetPdgCode() == 11){
722 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
723 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
724 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
725 daughter0Electron = kTRUE;
731 else if(tmpDaughter->GetPdgCode() == -11){
732 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
733 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
734 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
735 daughter0Positron = kTRUE;
745 if(daughter1->GetNDaughters() >= 2){ // second gamma
746 for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){
747 TParticle *tmpDaughter = fStack->Particle(TrackIndex);
748 if(tmpDaughter->GetUniqueID() == 5){
749 if(tmpDaughter->GetPdgCode() == 11){
750 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
751 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
752 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
753 daughter1Electron = kTRUE;
759 else if(tmpDaughter->GetPdgCode() == -11){
760 if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
761 if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue() < tmpDaughter->R() ){
762 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
763 daughter1Positron = kTRUE;
777 if(particle->GetPdgCode()==111){ //Pi0
778 if( iTracks >= fStack->GetNprimary()){
779 fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());
780 fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);
781 fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);
782 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());
783 fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());
784 fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());
785 fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());
786 fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
787 fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling
789 if(gammaEtaCut && gammaRCut){
790 //if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
791 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
792 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
793 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
794 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
795 fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
800 fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());
801 fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);
802 fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);
803 fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());
804 fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());
805 fHistograms->FillHistogram("MC_Pi0_R", particle->R());
806 fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());
807 fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
808 fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
810 if(gammaEtaCut && gammaRCut){
811 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
812 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
813 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
814 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
815 fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
816 fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
817 fHistograms->FillHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
823 if(particle->GetPdgCode()==221){ //Eta
824 fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());
825 fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);
826 fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);
827 fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());
828 fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());
829 fHistograms->FillHistogram("MC_Eta_R", particle->R());
830 fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());
831 fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
832 fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
834 if(gammaEtaCut && gammaRCut){
835 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
836 fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
837 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
838 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
839 fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
840 fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
841 fHistograms->FillHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
848 // all motherparticles with 2 gammas as daughters
849 fHistograms->FillHistogram("MC_Mother_R", particle->R());
850 fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());
851 fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());
852 fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());
853 fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
854 fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());
855 fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());
856 fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());
857 fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);
858 fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);
859 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());
861 if(gammaEtaCut && gammaRCut){
862 // if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
863 fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
864 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
865 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());
866 if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
867 fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
868 fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
869 fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());
874 } // end passed R and eta cut
876 } // end if(particle->GetNDaughters() == 2)
878 }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
880 } // end ProcessMCData
884 void AliAnalysisTaskGammaConversion::FillNtuple(){
885 //Fills the ntuple with the different values
887 if(fGammaNtuple == NULL){
890 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
891 for(Int_t i=0;i<numberOfV0s;i++){
892 Float_t values[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
893 AliESDv0 * cV0 = fV0Reader->GetV0(i);
896 fV0Reader->GetPIDProbability(negPID,posPID);
897 values[0]=cV0->GetOnFlyStatus();
898 values[1]=fV0Reader->CheckForPrimaryVertex();
901 values[4]=fV0Reader->GetX();
902 values[5]=fV0Reader->GetY();
903 values[6]=fV0Reader->GetZ();
904 values[7]=fV0Reader->GetXYRadius();
905 values[8]=fV0Reader->GetMotherCandidateNDF();
906 values[9]=fV0Reader->GetMotherCandidateChi2();
907 values[10]=fV0Reader->GetMotherCandidateEnergy();
908 values[11]=fV0Reader->GetMotherCandidateEta();
909 values[12]=fV0Reader->GetMotherCandidatePt();
910 values[13]=fV0Reader->GetMotherCandidateMass();
911 values[14]=fV0Reader->GetMotherCandidateWidth();
912 // values[15]=fV0Reader->GetMotherMCParticle()->Pt(); MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array
913 values[16]=fV0Reader->GetOpeningAngle();
914 values[17]=fV0Reader->GetNegativeTrackEnergy();
915 values[18]=fV0Reader->GetNegativeTrackPt();
916 values[19]=fV0Reader->GetNegativeTrackEta();
917 values[20]=fV0Reader->GetNegativeTrackPhi();
918 values[21]=fV0Reader->GetPositiveTrackEnergy();
919 values[22]=fV0Reader->GetPositiveTrackPt();
920 values[23]=fV0Reader->GetPositiveTrackEta();
921 values[24]=fV0Reader->GetPositiveTrackPhi();
922 values[25]=fV0Reader->HasSameMCMother();
924 values[26]=fV0Reader->GetMotherMCParticlePDGCode();
925 values[15]=fV0Reader->GetMotherMCParticle()->Pt();
927 fTotalNumberOfAddedNtupleEntries++;
928 fGammaNtuple->Fill(values);
930 fV0Reader->ResetV0IndexNumber();
934 void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
935 // Process all the V0's without applying any cuts to it
937 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
938 for(Int_t i=0;i<numberOfV0s;i++){
939 /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
941 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
945 // if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
946 if( !fV0Reader->CheckV0FinderStatus(i)){
951 if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ||
952 !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
958 if(fV0Reader->HasSameMCMother() == kFALSE){
962 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
963 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
965 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
968 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
972 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){
976 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
978 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
979 fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
980 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
981 fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
982 fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
983 fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
984 fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
985 fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
986 fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
987 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
989 fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
990 fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
992 fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
993 fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
994 fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
995 fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
996 fHistograms->FillHistogram("ESD_NoCutConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
997 fHistograms->FillHistogram("ESD_NoCutConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
998 fHistograms->FillHistogram("ESD_NoCutConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
999 fHistograms->FillHistogram("ESD_NoCutConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1001 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1002 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1003 fHistograms->FillHistogram("ESD_NoCutConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1004 fHistograms->FillHistogram("ESD_NoCutConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1006 //store MCTruth properties
1007 fHistograms->FillHistogram("ESD_NoCutConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1008 fHistograms->FillHistogram("ESD_NoCutConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1009 fHistograms->FillHistogram("ESD_NoCutConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1013 fV0Reader->ResetV0IndexNumber();
1016 void AliAnalysisTaskGammaConversion::ProcessV0s(){
1017 // see header file for documentation
1019 if(fWriteNtuple == kTRUE){
1023 Int_t nSurvivingV0s=0;
1024 while(fV0Reader->NextV0()){
1028 //-------------------------- filling v0 information -------------------------------------
1029 fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());
1030 fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1031 fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1032 fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1034 fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());
1035 fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());
1036 fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());
1037 fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());
1039 fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());
1040 fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());
1041 fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());
1042 fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());
1044 fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1045 fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1046 fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1047 fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1048 fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1049 fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1050 fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1051 fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1052 fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1053 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1055 fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1056 fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1058 fHistograms->FillHistogram("ESD_ConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1059 fHistograms->FillHistogram("ESD_ConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1060 fHistograms->FillHistogram("ESD_ConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1061 fHistograms->FillHistogram("ESD_ConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1063 fHistograms->FillHistogram("ESD_ConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1064 fHistograms->FillHistogram("ESD_ConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1065 fHistograms->FillHistogram("ESD_ConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1066 fHistograms->FillHistogram("ESD_ConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1071 Int_t rBin = fHistograms->GetRBin(fV0Reader->GetXYRadius());
1072 Int_t zBin = fHistograms->GetZBin(fV0Reader->GetZ());
1073 Int_t phiBin = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
1074 TVector3 vtxConv(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
1076 Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
1078 TString nameESDMappingPhiR="";
1079 nameESDMappingPhiR.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phiBin,rBin);
1080 fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
1082 TString nameESDMappingPhi="";
1083 nameESDMappingPhi.Form("ESD_Conversion_Mapping_Phi%02d",phiBin);
1084 fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
1086 TString nameESDMappingR="";
1087 nameESDMappingR.Form("ESD_Conversion_Mapping_R%02d",rBin);
1088 fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);
1090 TString nameESDMappingPhiInR="";
1091 nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",rBin);
1092 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1093 fHistograms->FillHistogram(nameESDMappingPhiInR, vtxConv.Phi());
1095 TString nameESDMappingZInR="";
1096 nameESDMappingZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",rBin);
1097 fHistograms->FillHistogram(nameESDMappingZInR, fV0Reader->GetZ());
1099 TString nameESDMappingPhiInZ="";
1100 nameESDMappingPhiInZ.Form("ESD_Conversion_Mapping_Phi_in_Z_%02d",zBin);
1101 // fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
1102 fHistograms->FillHistogram(nameESDMappingPhiInZ, vtxConv.Phi());
1104 TString nameESDMappingRInZ="";
1105 nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
1106 fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
1108 if(fV0Reader->GetMotherCandidatePt() > fLowPtMapping && fV0Reader->GetMotherCandidatePt()< fHighPtMapping){
1109 TString nameESDMappingMidPtPhiInR="";
1110 nameESDMappingMidPtPhiInR.Form("ESD_Conversion_Mapping_MidPt_Phi_in_R_%02d",rBin);
1111 fHistograms->FillHistogram(nameESDMappingMidPtPhiInR, vtxConv.Phi());
1113 TString nameESDMappingMidPtZInR="";
1114 nameESDMappingMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",rBin);
1115 fHistograms->FillHistogram(nameESDMappingMidPtZInR, fV0Reader->GetZ());
1117 TString nameESDMappingMidPtPhiInZ="";
1118 nameESDMappingMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",zBin);
1119 fHistograms->FillHistogram(nameESDMappingMidPtPhiInZ, vtxConv.Phi());
1121 TString nameESDMappingMidPtRInZ="";
1122 nameESDMappingMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",zBin);
1123 fHistograms->FillHistogram(nameESDMappingMidPtRInZ, fV0Reader->GetXYRadius());
1130 new((*fKFReconstructedGammasTClone)[fKFReconstructedGammasTClone->GetEntriesFast()]) AliKFParticle(*fV0Reader->GetMotherCandidateKFCombination());
1132 // fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
1133 fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
1134 fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
1136 //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
1139 if(fV0Reader->HasSameMCMother() == kFALSE){
1142 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1143 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1145 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1149 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1153 if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){// check if the daughters come from a conversion
1157 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1159 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
1160 fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
1161 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
1162 fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
1163 fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
1164 fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
1165 fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
1166 fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
1167 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
1168 fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
1169 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());
1170 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());
1171 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1172 fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());
1174 fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
1175 fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
1178 fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
1179 fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());
1180 fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
1181 fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
1183 fHistograms->FillHistogram("ESD_TrueConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
1184 fHistograms->FillHistogram("ESD_TrueConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
1185 fHistograms->FillHistogram("ESD_TrueConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
1186 fHistograms->FillHistogram("ESD_TrueConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
1188 fHistograms->FillHistogram("ESD_TrueConvGamma_E_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetNegativeTrackP()/fV0Reader->GetMotherCandidateP());
1189 fHistograms->FillHistogram("ESD_TrueConvGamma_P_AsymmetryP",fV0Reader->GetMotherCandidateP(),fV0Reader->GetPositiveTrackP()/fV0Reader->GetMotherCandidateP());
1190 fHistograms->FillHistogram("ESD_TrueConvGamma_E_dEdxP",fV0Reader->GetNegativeTrackP(),fV0Reader->GetNegativeTrackTPCdEdx());
1191 fHistograms->FillHistogram("ESD_TrueConvGamma_P_dEdxP",fV0Reader->GetPositiveTrackP(),fV0Reader->GetPositiveTrackTPCdEdx());
1195 //store MCTruth properties
1196 fHistograms->FillHistogram("ESD_TrueConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
1197 fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
1198 fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
1201 Double_t mcpt = fV0Reader->GetMotherMCParticle()->Pt();
1202 Double_t esdpt = fV0Reader->GetMotherCandidatePt();
1203 Double_t resdPt = 0;
1205 resdPt = ((esdpt - mcpt)/mcpt)*100;
1208 cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl;
1211 fHistograms->FillHistogram("Resolution_dPt", mcpt, resdPt);
1212 fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
1213 fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
1216 if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
1217 resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100;
1220 fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
1221 fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());
1222 fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());
1225 if(fV0Reader->GetNegativeMCParticle()->R() != 0){
1226 resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100;
1229 fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
1230 fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());
1231 fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());
1232 fHistograms->FillHistogram("Resolution_dR_dPt", resdR, resdPt);
1233 }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
1235 }//while(fV0Reader->NextV0)
1236 fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
1237 fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
1238 fHistograms->FillHistogram("ESD_NumberOfContributorsVtx", fV0Reader->GetNumberOfContributorsVtx());
1240 fV0Reader->ResetV0IndexNumber();
1244 void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
1245 // Fill AOD with reconstructed Gamma
1247 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
1248 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
1249 //Create AOD particle object from AliKFParticle
1251 /* AliKFParticle * gammakf = &fKFReconstructedGammas[gammaIndex];
1252 //You could add directly AliKFParticle objects to the AOD, avoiding dependences with PartCorr
1253 //but this means that I have to work a little bit more in my side.
1254 //AODPWG4Particle objects are simpler and lighter, I think
1255 AliAODPWG4Particle gamma = AliAODPWG4Particle(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
1256 gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
1257 gamma.SetCaloLabel(-1,-1); //How to get the MC label of the 2 electrons that form the gamma?
1258 gamma.SetDetector("CTS"); //tag the gamma as reconstructed in the central barrel
1259 gamma.SetPdg(AliCaloPID::kPhotonConv); //photon id
1260 gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
1262 //Add it to the aod list
1263 Int_t i = fAODBranch->GetEntriesFast();
1264 new((*fAODBranch)[i]) AliAODPWG4Particle(gamma);
1266 // AliKFParticle * gammakf = &fKFReconstructedGammas[gammaIndex];
1267 AliKFParticle * gammakf = (AliKFParticle *)fKFReconstructedGammasTClone->At(gammaIndex);
1268 AliGammaConversionAODObject aodObject;
1269 aodObject.SetPx(gammakf->GetPx());
1270 aodObject.SetPy(gammakf->GetPy());
1271 aodObject.SetPz(gammakf->GetPz());
1272 aodObject.SetLabel1(fElectronv1[gammaIndex]);
1273 aodObject.SetLabel2(fElectronv2[gammaIndex]);
1274 Int_t i = fAODBranch->GetEntriesFast();
1275 new((*fAODBranch)[i]) AliGammaConversionAODObject(aodObject);
1281 void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
1282 // see header file for documentation
1284 // for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
1285 // for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
1286 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
1287 for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();secondGammaIndex++){
1289 // AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
1290 // AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
1292 AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFReconstructedGammasTClone->At(firstGammaIndex);
1293 AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFReconstructedGammasTClone->At(secondGammaIndex);
1295 if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
1298 if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
1302 AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
1304 Double_t massTwoGammaCandidate = 0.;
1305 Double_t widthTwoGammaCandidate = 0.;
1306 Double_t chi2TwoGammaCandidate =10000.;
1307 twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
1308 if(twoGammaCandidate->GetNDF()>0){
1309 chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
1311 if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()){
1313 TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
1314 TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
1316 Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);
1318 if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() == 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() == 0){
1322 rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
1325 if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
1326 delete twoGammaCandidate;
1327 continue; // minimum opening angle to avoid using ghosttracks
1330 fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
1331 fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
1332 fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
1333 fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
1334 fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);
1335 fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
1336 fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
1337 fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt()); // Pt in Space == R!!!
1338 fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
1339 fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
1340 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1341 fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
1343 if ( TMath::Abs(twoGammaDecayCandidateDaughter0->GetEta())<0.9 && TMath::Abs(twoGammaDecayCandidateDaughter1->GetEta())<0.9 ){
1344 fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt_Fiducial",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
1345 fHistograms->FillHistogram("ESD_Mother_InvMass_Fiducial",massTwoGammaCandidate);
1349 delete twoGammaCandidate;
1354 void AliAnalysisTaskGammaConversion::CalculateBackground(){
1355 // see header file for documentation
1358 TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
1360 for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
1361 AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
1362 for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
1363 AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent));
1364 for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1365 AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
1367 AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
1369 Double_t massBG =0.;
1370 Double_t widthBG = 0.;
1371 Double_t chi2BG =10000.;
1372 backgroundCandidate->GetMass(massBG,widthBG);
1373 if(backgroundCandidate->GetNDF()>0){
1374 chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
1375 if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){
1377 TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
1378 TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
1380 Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
1383 if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
1384 else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
1389 if(openingAngleBG < fMinOpeningAngleGhostCut ){
1390 delete backgroundCandidate;
1391 continue; // minimum opening angle to avoid using ghosttracks
1394 fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
1395 fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
1396 fHistograms->FillHistogram("ESD_Background_Pt", momentumVectorbackgroundCandidate.Pt());
1397 fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
1398 fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
1399 fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
1400 fHistograms->FillHistogram("ESD_Background_Mass", massBG);
1401 fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt()); // Pt in Space == R!!!!
1402 fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
1403 fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
1404 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
1405 fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
1407 if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 && TMath::Abs(previousGoodV0.GetEta())<0.9 ){
1408 fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
1409 fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
1414 delete backgroundCandidate;
1421 void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
1422 //ProcessGammasForGammaJetAnalysis
1424 Double_t distIsoMin;
1426 CreateListOfChargedParticles();
1429 // for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
1430 for(Int_t gammaIndex=0;gammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();gammaIndex++){
1431 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
1432 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
1434 if( momentumVectorCurrentGamma.Pt()> fMinPtForGammaJet){
1435 distIsoMin=GetMinimumDistanceToCharge(gammaIndex);
1437 if (distIsoMin > fMinIsoConeSize && fLeadingChargedIndex>=0){
1438 CalculateJetCone(gammaIndex);
1444 void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
1445 // CreateListOfChargedParticles
1447 fESDEvent = fV0Reader->GetESDEvent();
1448 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
1449 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
1455 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
1456 new((*fChargedParticles)[fChargedParticles->GetEntriesFast()]) AliESDtrack(*curTrack);
1457 // fChargedParticles.push_back(curTrack);
1458 fChargedParticlesId.push_back(iTracks);
1462 void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex){
1466 Double_t coneSize=0.3;
1469 // AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
1470 AliKFParticle * currentGamma = (AliKFParticle*)fKFReconstructedGammasTClone->At(gammaIndex);
1472 TVector3 momentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
1474 AliESDtrack* leadingCharged = (AliESDtrack*)(fChargedParticles->At(fLeadingChargedIndex));
1476 Double_t momLeadingCharged[3];
1477 leadingCharged->GetConstrainedPxPyPz(momLeadingCharged);
1479 TVector3 momentumVectorLeadingCharged(momLeadingCharged[0],momLeadingCharged[1],momLeadingCharged[2]);
1481 Double_t phi1=momentumVectorLeadingCharged.Phi();
1482 Double_t eta1=momentumVectorLeadingCharged.Eta();
1483 Double_t phi3=momentumVectorCurrentGamma.Phi();
1485 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
1486 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
1487 Int_t chId = fChargedParticlesId[iCh];
1488 if(fLeadingChargedIndex==chId || fLeadingChargedIndex==chId) continue;
1490 curTrack->GetConstrainedPxPyPz(mom);
1491 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
1492 Double_t phi2=momentumVectorChargedParticle.Phi();
1493 Double_t eta2=momentumVectorChargedParticle.Eta();
1497 if( TMath::Abs(phi2 - phi1) <= ( TMath::TwoPi()-coneSize) ){
1498 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-phi1),2) );
1500 if( (phi2 - phi1)> TMath::TwoPi()-coneSize ){
1501 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-TMath::TwoPi()-phi1),2) );
1503 if( (phi2 - phi1)< -(TMath::TwoPi()-coneSize) ){
1504 cone = TMath::Sqrt( TMath::Power((eta2-eta1),2)+ TMath::Power((phi2+TMath::TwoPi()-phi1),2) );
1508 if(cone <coneSize&& momentumVectorChargedParticle.Pt()>fMinPtJetCone ){
1509 ptJet+= momentumVectorChargedParticle.Pt();
1510 Double_t ffzHdrGam = momentumVectorChargedParticle.Pt()/momentumVectorCurrentGamma.Pt();
1511 Double_t imbalanceHdrGam=-momentumVectorChargedParticle.Dot(momentumVectorCurrentGamma)/momentumVectorCurrentGamma.Mag2();
1512 fHistograms->FillHistogram("ESD_FFzHdrGam",ffzHdrGam);
1513 fHistograms->FillHistogram("ESD_ImbalanceHdrGam",imbalanceHdrGam);
1517 Double_t dphiHdrGam=phi3-phi2;
1518 if ( dphiHdrGam < (-TMath::PiOver2())){
1519 dphiHdrGam+=(TMath::TwoPi());
1522 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
1523 dphiHdrGam-=(TMath::TwoPi());
1526 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
1527 fHistograms->FillHistogram("ESD_dphiHdrGamIsolated",dphiHdrGam);
1534 Double_t AliAnalysisTaskGammaConversion::GetMinimumDistanceToCharge(Int_t indexHighestPtGamma){
1535 // GetMinimumDistanceToCharge
1537 Double_t fIsoMin=100.;
1538 Double_t ptLeadingCharged=-1.;
1540 fLeadingChargedIndex=-1;
1542 AliKFParticle * gammaHighestPt = (AliKFParticle*)fKFReconstructedGammasTClone->At(indexHighestPtGamma);
1543 TVector3 momentumVectorgammaHighestPt(gammaHighestPt->GetPx(),gammaHighestPt->GetPy(),gammaHighestPt->GetPz());
1545 Double_t phi1=momentumVectorgammaHighestPt.Phi();
1546 Double_t eta1=momentumVectorgammaHighestPt.Eta();
1548 for(Int_t iCh=0;iCh<fChargedParticles->GetEntriesFast();iCh++){
1549 AliESDtrack* curTrack = (AliESDtrack*)(fChargedParticles->At(iCh));
1550 Int_t chId = fChargedParticlesId[iCh];
1551 if(fElectronv1[indexHighestPtGamma]==chId || fElectronv2[indexHighestPtGamma]==chId) continue;
1553 curTrack->GetConstrainedPxPyPz(mom);
1554 TVector3 momentumVectorChargedParticle(mom[0],mom[1],mom[2]);
1555 Double_t phi2=momentumVectorChargedParticle.Phi();
1556 Double_t eta2=momentumVectorChargedParticle.Eta();
1557 Double_t iso=pow( (pow( (eta1-eta2),2)+ pow((phi1-phi2),2)),0.5 );
1559 if(momentumVectorChargedParticle.Pt()>fMinPtIsoCone ){
1565 Double_t dphiHdrGam=phi1-phi2;
1566 if ( dphiHdrGam < (-TMath::PiOver2())){
1567 dphiHdrGam+=(TMath::TwoPi());
1570 if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
1571 dphiHdrGam-=(TMath::TwoPi());
1573 if (momentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
1574 fHistograms->FillHistogram("ESD_dphiHdrGam",dphiHdrGam);
1577 if (dphiHdrGam>0.9*TMath::Pi() && dphiHdrGam<1.1*TMath::Pi()){
1578 if (momentumVectorChargedParticle.Pt()> ptLeadingCharged && momentumVectorChargedParticle.Pt()>0.1*momentumVectorgammaHighestPt.Pt()){
1579 ptLeadingCharged=momentumVectorChargedParticle.Pt();
1580 fLeadingChargedIndex=iCh;
1585 fHistograms->FillHistogram("ESD_MinimumIsoDistance",fIsoMin);
1590 Int_t AliAnalysisTaskGammaConversion::GetIndexHighestPtGamma(){
1591 //GetIndexHighestPtGamma
1593 Int_t indexHighestPtGamma=-1;
1595 fGammaPtHighest = -100.;
1597 for(Int_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammasTClone->GetEntriesFast();firstGammaIndex++){
1598 AliKFParticle * gammaHighestPtCandidate = (AliKFParticle*)fKFReconstructedGammasTClone->At(firstGammaIndex);
1599 TVector3 momentumVectorgammaHighestPtCandidate(gammaHighestPtCandidate->GetPx(),gammaHighestPtCandidate->GetPy(),gammaHighestPtCandidate->GetPz());
1600 if (momentumVectorgammaHighestPtCandidate.Pt() > fGammaPtHighest){
1601 fGammaPtHighest=momentumVectorgammaHighestPtCandidate.Pt();
1602 //gammaHighestPt = gammaHighestPtCandidate;
1603 indexHighestPtGamma=firstGammaIndex;
1607 return indexHighestPtGamma;
1612 void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
1614 // Terminate analysis
1616 AliDebug(1,"Do nothing in Terminate");
1619 void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
1622 if(fAODBranch==NULL){
1623 fAODBranch = new TClonesArray("AliGammaConversionAODObject", 0);
1625 fAODBranch->Delete();
1626 fAODBranch->SetName(fAODBranchName);
1627 AddAODBranch("TClonesArray", &fAODBranch);
1629 // Create the output container
1630 if(fOutputContainer != NULL){
1631 delete fOutputContainer;
1632 fOutputContainer = NULL;
1634 if(fOutputContainer == NULL){
1635 fOutputContainer = new TList();
1636 fOutputContainer->SetOwner(kTRUE);
1639 //Adding the histograms to the output container
1640 fHistograms->GetOutputContainer(fOutputContainer);
1644 if(fGammaNtuple == NULL){
1645 fGammaNtuple = new TNtuple("V0ntuple","V0ntuple","OnTheFly:HasVertex:NegPIDProb:PosPIDProb:X:Y:Z:R:MotherCandidateNDF:MotherCandidateChi2:MotherCandidateEnergy:MotherCandidateEta:MotherCandidatePt:MotherCandidateMass:MotherCandidateWidth:MCMotherCandidatePT:EPOpeningAngle:ElectronEnergy:ElectronPt:ElectronEta:ElectronPhi:PositronEnergy:PositronPt:PositronEta:PositronPhi:HasSameMCMother:MotherMCParticlePIDCode",50000);
1647 if(fNeutralMesonNtuple == NULL){
1648 fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");
1650 TList * ntupleTList = new TList();
1651 ntupleTList->SetOwner(kTRUE);
1652 ntupleTList->SetName("Ntuple");
1653 ntupleTList->Add((TNtuple*)fGammaNtuple);
1654 fOutputContainer->Add(ntupleTList);
1657 fOutputContainer->SetName(GetName());
1660 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* const daughter0, TParticle* const daughter1) const{
1662 TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());
1663 TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());
1664 return v3D0.Angle(v3D1);
1667 void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
1668 // see header file for documentation
1670 vector<Int_t> indexOfGammaParticle;
1672 fStack = fV0Reader->GetMCStack();
1674 if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
1675 return; // aborts if the primary vertex does not have contributors.
1678 for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
1679 TParticle* particle = (TParticle *)fStack->Particle(iTracks);
1680 if(particle->GetPdgCode()==22){ //Gamma
1681 if(particle->GetNDaughters() >= 2){
1682 TParticle* electron=NULL;
1683 TParticle* positron=NULL;
1684 for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
1685 TParticle *tmpDaughter = fStack->Particle(daughterIndex);
1686 if(tmpDaughter->GetUniqueID() == 5){
1687 if(tmpDaughter->GetPdgCode() == 11){
1688 electron = tmpDaughter;
1690 else if(tmpDaughter->GetPdgCode() == -11){
1691 positron = tmpDaughter;
1695 if(electron!=NULL && positron!=0){
1696 if(electron->R()<160){
1697 indexOfGammaParticle.push_back(iTracks);
1704 Int_t nFoundGammas=0;
1705 Int_t nNotFoundGammas=0;
1707 Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
1708 for(Int_t i=0;i<numberOfV0s;i++){
1709 fV0Reader->GetV0(i);
1711 if(fV0Reader->HasSameMCMother() == kFALSE){
1715 TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
1716 TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
1718 if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
1721 if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
1725 if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
1726 //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();
1727 for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){
1728 if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){
1740 void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
1741 // see header file for documantation
1743 fESDEvent = fV0Reader->GetESDEvent();
1746 TClonesArray * vESDeNegTemp = new TClonesArray("AliESDtrack",0);
1747 TClonesArray * vESDePosTemp = new TClonesArray("AliESDtrack",0);
1748 TClonesArray * vESDxNegTemp = new TClonesArray("AliESDtrack",0);
1749 TClonesArray * vESDxPosTemp = new TClonesArray("AliESDtrack",0);
1750 TClonesArray * vESDeNegNoJPsi = new TClonesArray("AliESDtrack",0);
1751 TClonesArray * vESDePosNoJPsi = new TClonesArray("AliESDtrack",0);
1754 vector <AliESDtrack*> vESDeNegTemp(0);
1755 vector <AliESDtrack*> vESDePosTemp(0);
1756 vector <AliESDtrack*> vESDxNegTemp(0);
1757 vector <AliESDtrack*> vESDxPosTemp(0);
1758 vector <AliESDtrack*> vESDeNegNoJPsi(0);
1759 vector <AliESDtrack*> vESDePosNoJPsi(0);
1763 fHistograms->FillTable("Table_Electrons",0);//Count number of Events
1765 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
1766 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
1769 //print warning here
1773 double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;
1774 double r[3];curTrack->GetConstrainedXYZ(r);
1778 fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks
1780 Bool_t flagKink = kTRUE;
1781 Bool_t flagTPCrefit = kTRUE;
1782 Bool_t flagTRDrefit = kTRUE;
1783 Bool_t flagITSrefit = kTRUE;
1784 Bool_t flagTRDout = kTRUE;
1785 Bool_t flagVertex = kTRUE;
1788 //Cuts ---------------------------------------------------------------
1790 if(curTrack->GetKinkIndex(0) > 0){
1791 fHistograms->FillHistogram("Table_Electrons",5);//Count kink
1795 ULong_t trkStatus = curTrack->GetStatus();
1797 ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);
1800 fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit
1801 flagTPCrefit = kFALSE;
1804 ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);
1806 fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit
1807 flagITSrefit = kFALSE;
1810 ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);
1813 fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit
1814 flagTRDrefit = kFALSE;
1817 ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);
1820 fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout
1821 flagTRDout = kFALSE;
1824 double nsigmaToVxt = GetSigmaToVertex(curTrack);
1826 if(nsigmaToVxt > 3){
1827 fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3
1828 flagVertex = kFALSE;
1831 if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;
1832 fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts
1836 GetPID(curTrack, pid, weight);
1839 fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0
1843 fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0
1851 TLorentzVector curElec;
1852 curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);
1856 Int_t labelMC = TMath::Abs(curTrack->GetLabel());
1857 TParticle* curParticle = fStack->Particle(labelMC);
1858 if(curTrack->GetSign() > 0){
1860 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
1861 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
1864 fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
1865 fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
1871 if(curTrack->GetSign() > 0){
1873 // vESDxPosTemp.push_back(curTrack);
1874 new((*vESDxPosTemp)[vESDxPosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
1878 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
1879 fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());
1880 // fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
1881 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
1882 // fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
1883 // vESDePosTemp.push_back(curTrack);
1884 new((*vESDePosTemp)[vESDePosTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
1891 new((*vESDxNegTemp)[vESDxNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
1895 fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
1896 fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
1897 fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
1898 new((*vESDeNegTemp)[vESDeNegTemp->GetEntriesFast()]) AliESDtrack(*curTrack);
1907 Bool_t ePosJPsi = kFALSE;
1908 Bool_t eNegJPsi = kFALSE;
1909 Bool_t ePosPi0 = kFALSE;
1910 Bool_t eNegPi0 = kFALSE;
1912 UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;
1914 for(Int_t iNeg=0; iNeg < vESDeNegTemp->GetEntriesFast(); iNeg++){
1915 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetPdgCode() == 11)
1916 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0) > -1){
1917 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(iNeg)))->GetLabel()))->GetMother(0);
1918 TParticle* partMother = fStack ->Particle(labelMother);
1919 if (partMother->GetPdgCode() == 111){
1923 if(partMother->GetPdgCode() == 443){ //Mother JPsi
1924 fHistograms->FillTable("Table_Electrons",14);
1929 // vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);
1930 new((*vESDeNegNoJPsi)[vESDeNegNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDeNegTemp->At(iNeg)));
1931 // cout<<"ESD No Positivo JPsi "<<endl;
1937 for(Int_t iPos=0; iPos < vESDePosTemp->GetEntriesFast(); iPos++){
1938 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetPdgCode() == -11)
1939 if(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0) > -1){
1940 Int_t labelMother = fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iPos)))->GetLabel()))->GetMother(0);
1941 TParticle* partMother = fStack ->Particle(labelMother);
1942 if (partMother->GetPdgCode() == 111){
1946 if(partMother->GetPdgCode() == 443){ //Mother JPsi
1947 fHistograms->FillTable("Table_Electrons",15);
1952 // vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);
1953 new((*vESDePosNoJPsi)[vESDePosNoJPsi->GetEntriesFast()]) AliESDtrack(*(AliESDtrack*)(vESDePosTemp->At(iPos)));
1954 // cout<<"ESD No Negativo JPsi "<<endl;
1960 if( eNegJPsi && ePosJPsi ){
1961 TVector3 tempeNegV,tempePosV;
1962 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->Pz());
1963 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->Pz());
1964 fHistograms->FillTable("Table_Electrons",16);
1965 fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));
1966 fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegJPsi)))->GetLabel())),
1967 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosJPsi)))->GetLabel()))));
1970 if( eNegPi0 && ePosPi0 ){
1971 TVector3 tempeNegV,tempePosV;
1972 tempeNegV.SetXYZ(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Px(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Py(),((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->Pz());
1973 tempePosV.SetXYZ(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Px(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Py(),((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->Pz());
1974 fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));
1975 fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDeNegTemp->At(ieNegPi0)))->GetLabel())),
1976 fStack->Particle(TMath::Abs(((AliESDtrack*)(vESDePosTemp->At(iePosPi0)))->GetLabel()))));
1980 FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));
1982 CleanWithAngleCuts(*vESDeNegTemp,*vESDePosTemp,*fKFReconstructedGammasTClone);
1984 // vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);
1985 // vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);
1987 TClonesArray vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectronTClone);
1988 TClonesArray vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectronTClone);
1991 FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);
1996 //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);
1999 FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);
2000 FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));
2004 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",*fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
2006 FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",
2007 *fKFReconstructedGammasCutTClone,vCurrentTLVeNeg,vCurrentTLVePos);
2012 ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);
2013 ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);
2014 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);
2015 ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);
2017 // Like Sign e+e- no JPsi
2018 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));
2019 ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));
2023 if( fCurrentEventPosElectronTClone->GetEntriesFast() > 0 && fCurrentEventNegElectronTClone->GetEntriesFast() > 0 && fKFReconstructedGammasCutTClone->GetEntriesFast() > 0 ){
2024 FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",
2025 *fKFReconstructedGammasCutTClone,*fPreviousEventTLVNegElectronTClone,*fPreviousEventTLVPosElectronTClone);
2026 *fPreviousEventTLVNegElectronTClone = vCurrentTLVeNeg;
2027 *fPreviousEventTLVPosElectronTClone = vCurrentTLVePos;
2034 vtx[0]=0;vtx[1]=0;vtx[2]=0;
2035 for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){
2037 // if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;
2041 Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();
2042 // cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;
2044 // cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;
2046 if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )
2048 fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());
2057 vESDeNegTemp->Delete();
2058 vESDePosTemp->Delete();
2059 vESDxNegTemp->Delete();
2060 vESDxPosTemp->Delete();
2061 vESDeNegNoJPsi->Delete();
2062 vESDePosNoJPsi->Delete();
2064 delete vESDeNegTemp;
2065 delete vESDePosTemp;
2066 delete vESDxNegTemp;
2067 delete vESDxPosTemp;
2068 delete vESDeNegNoJPsi;
2069 delete vESDePosNoJPsi;
2073 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){
2074 //see header file for documentation
2075 for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){
2076 for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
2077 fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));
2082 void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos){
2083 //see header file for documentation
2084 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++){
2085 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
2086 fHistograms->FillHistogram(histoName.Data(),((TLorentzVector*)(tlVeNeg.At(iNeg)))->Vect().Angle(((TLorentzVector*)(tlVePos.At(iPos)))->Vect()));
2090 void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, TClonesArray const eNeg, TClonesArray const ePos){
2091 //see header file for documentation
2092 for( Int_t n=0; n < eNeg.GetEntriesFast(); n++){
2093 TLorentzVector en = (*(TLorentzVector*)(eNeg.At(n)));
2094 for (Int_t p=0; p < ePos.GetEntriesFast(); p++){
2095 TLorentzVector ep = (*(TLorentzVector*)(ePos.At(p)));
2096 TLorentzVector np = ep + en;
2097 fHistograms->FillHistogram(histoName.Data(),np.M());
2102 void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,TClonesArray const fKFGammas,
2103 TClonesArray const tlVeNeg,TClonesArray const tlVePos)
2105 //see header file for documentation
2107 for( Int_t iNeg=0; iNeg < tlVeNeg.GetEntriesFast(); iNeg++ ){
2109 for (Int_t iPos=0; iPos < tlVePos.GetEntriesFast(); iPos++){
2111 TLorentzVector xy = *((TLorentzVector *)(tlVePos.At(iPos))) + *((TLorentzVector *)(tlVeNeg.At(iNeg)));
2113 for (Int_t iGam=0; iGam < fKFGammas.GetEntriesFast(); iGam++){
2115 // AliKFParticle * gammaCandidate = &fKFGammas[iGam];
2116 AliKFParticle * gammaCandidate = (AliKFParticle *)(fKFGammas.At(iGam));
2119 g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);
2120 TLorentzVector xyg = xy + g;
2121 fHistograms->FillHistogram(histoMass.Data(),xyg.M());
2122 fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));
2128 void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, TClonesArray e)
2130 // see header file for documentation
2131 for(Int_t i=0; i < e.GetEntriesFast(); i++)
2133 for (Int_t j=i+1; j < e.GetEntriesFast(); j++)
2135 TLorentzVector ee = (*(TLorentzVector*)(e.At(i))) + (*(TLorentzVector*)(e.At(j)));
2137 fHistograms->FillHistogram(hBg.Data(),ee.M());
2143 void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(TClonesArray const negativeElectrons,
2144 TClonesArray const positiveElectrons,
2145 TClonesArray const gammas){
2146 // see header file for documentation
2148 UInt_t sizeN = negativeElectrons.GetEntriesFast();
2149 UInt_t sizeP = positiveElectrons.GetEntriesFast();
2150 UInt_t sizeG = gammas.GetEntriesFast();
2154 vector <Bool_t> xNegBand(sizeN);
2155 vector <Bool_t> xPosBand(sizeP);
2156 vector <Bool_t> gammaBand(sizeG);
2159 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;
2160 for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;
2161 for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;
2164 for(UInt_t iPos=0; iPos < sizeP; iPos++){
2167 ((AliESDtrack*)(positiveElectrons.At(iPos)))->GetConstrainedPxPyPz(aP);
2169 TVector3 ePosV(aP[0],aP[1],aP[2]);
2171 for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){
2174 ((AliESDtrack*)(negativeElectrons.At(iNeg)))->GetConstrainedPxPyPz(aN);
2175 TVector3 eNegV(aN[0],aN[1],aN[2]);
2177 if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma
2178 xPosBand[iPos]=kFALSE;
2179 xNegBand[iNeg]=kFALSE;
2182 for(UInt_t iGam=0; iGam < sizeG; iGam++){
2183 AliKFParticle* gammaCandidate = (AliKFParticle*)gammas.At(iGam);
2184 TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());
2185 if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)
2186 gammaBand[iGam]=kFALSE;
2194 for(UInt_t iPos=0; iPos < sizeP; iPos++){
2196 new((*fCurrentEventPosElectronTClone)[fCurrentEventPosElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(positiveElectrons.At(iPos))));
2197 // fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);
2200 for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){
2202 new((*fCurrentEventNegElectronTClone)[fCurrentEventNegElectronTClone->GetEntriesFast()]) AliESDtrack((*(AliESDtrack*)(negativeElectrons.At(iNeg))));
2203 // fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);
2206 for(UInt_t iGam=0; iGam < sizeG; iGam++){
2207 if(gammaBand[iGam]){
2208 new((*fKFReconstructedGammasCutTClone)[fKFReconstructedGammasCutTClone->GetEntriesFast()]) AliKFParticle((*(AliKFParticle*)(gammas.At(iGam))));
2209 //fKFReconstructedGammasCut.push_back(*(AliKFParticle*)gammas->At(iGam));
2215 void AliAnalysisTaskGammaConversion::GetPID(AliESDtrack *track, Stat_t &pid, Stat_t &weight)
2217 // see header file for documentation
2222 double wpartbayes[5];
2224 //get probability of the diffenrent particle types
2225 track->GetESDpid(wpart);
2227 // Tentative particle type "concentrations"
2228 double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};
2232 for (int i = 0; i < 5; i++)
2234 rcc+=(c[i] * wpart[i]);
2239 for (int i=0; i<5; i++) {
2240 if( rcc>0 || rcc<0){//Kenneth: not sure if the rcc<0 should be there, this is from fixing a coding violation where we are not allowed to say: rcc!=0 (RC19)
2241 wpartbayes[i] = c[i] * wpart[i] / rcc;
2249 //find most probable particle in ESD pid
2250 //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton
2251 for (int i = 0; i < 5; i++)
2253 if (wpartbayes[i] > max)
2256 max = wpartbayes[i];
2263 double AliAnalysisTaskGammaConversion::GetSigmaToVertex(AliESDtrack* t)
2265 // Calculates the number of sigma to the vertex.
2270 t->GetImpactParameters(b,bCov);
2271 if (bCov[0]<=0 || bCov[2]<=0) {
2272 AliDebug(1, "Estimated b resolution lower or equal zero!");
2273 bCov[0]=0; bCov[2]=0;
2275 bRes[0] = TMath::Sqrt(bCov[0]);
2276 bRes[1] = TMath::Sqrt(bCov[2]);
2278 // -----------------------------------
2279 // How to get to a n-sigma cut?
2281 // The accumulated statistics from 0 to d is
2283 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
2284 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
2286 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
2287 // Can this be expressed in a different way?
2289 if (bRes[0] == 0 || bRes[1] ==0)
2292 double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
2294 // stupid rounding problem screws up everything:
2295 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
2296 if (TMath::Exp(-d * d / 2) < 1e-10)
2300 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
2304 //vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){
2305 TClonesArray AliAnalysisTaskGammaConversion::GetTLorentzVector(TClonesArray *const esdTrack){
2306 //Return TLoresntz vector of track?
2307 // vector <TLorentzVector> tlVtrack(0);
2308 TClonesArray array("TLorentzVector",0);
2310 for(Int_t itrack=0; itrack < esdTrack->GetEntriesFast(); itrack++){
2312 //esdTrack[itrack]->GetConstrainedPxPyPz(p);
2313 ((AliESDtrack*)(esdTrack->At(itrack)))->GetConstrainedPxPyPz(p);
2314 TLorentzVector currentTrack;
2315 currentTrack.SetXYZM(p[0],p[1],p[2],fElectronMass);
2316 new((array)[array.GetEntriesFast()]) TLorentzVector(currentTrack);
2317 // tlVtrack.push_back(currentTrack);