]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/AliAnalysisEtSelector.cxx
Changing method names to be more intuitive
[u/mrichter/AliRoot.git] / PWGLF / totEt / AliAnalysisEtSelector.cxx
1 //_________________________________________________________________________
2 //  Utility Class for transverse energy studies
3 //  Selector Base class 
4 //  -  
5 // implementation file
6 //
7 //*-- Authors: Oystein Djuvsland (Bergen)
8 //_________________________________________________________________________
9 #include "AliAnalysisEtSelector.h"
10 #include "AliAnalysisEtCuts.h"
11 #include "AliESDCaloCluster.h"
12 #include "AliStack.h"
13 #include "TParticle.h"
14 #include "TParticlePDG.h"
15 #include "AliAnalysisEtCommon.h"
16 #include <iostream>
17
18 ClassImp(AliAnalysisEtSelector);
19
20 AliAnalysisEtSelector::AliAnalysisEtSelector(AliAnalysisEtCuts *cuts) : AliAnalysisEtCommon()
21 ,fEvent(0)
22 ,fClusterArray(0)
23 ,fCuts(cuts)
24 ,fRunNumber(0)
25 {
26 }
27
28 AliAnalysisEtSelector::~AliAnalysisEtSelector()
29 { // dtor
30   if(fClusterArray)
31   {
32     delete fClusterArray;
33   }
34 }
35 void AliAnalysisEtSelector::SetEvent(const AliESDEvent* event)
36 {
37     fEvent = event;
38     if(!fInitialized) Init(event);
39 }
40
41 Bool_t AliAnalysisEtSelector::IsNeutralMcParticle(Int_t pIdx, AliStack& s, const TParticlePDG& pdg) const
42 {
43   return s.IsPhysicalPrimary(pIdx) &&(TMath::Abs(TMath::Abs(pdg.Charge()) - fCuts->GetMonteCarloNeutralParticle())<1e-3);
44 }
45
46 Bool_t AliAnalysisEtSelector::IsEmEtParticle(const Int_t pdgCode) const
47 {
48   return pdgCode == fgGammaCode || pdgCode == fgPi0Code || pdgCode == fgEtaCode || pdgCode == fgEPlusCode || pdgCode == fgEMinusCode;
49 }
50
51
52 Bool_t AliAnalysisEtSelector::PrimaryIsEmEtParticle(const Int_t pIdx, AliStack& stack) const
53 {
54   return IsEmEtParticle(stack.Particle(GetPrimary(pIdx, stack))->GetPdgCode());
55 }
56 Int_t AliAnalysisEtSelector::GetPrimary(const Int_t partIdx, AliStack& stack) const
57 { // get primary
58   if(partIdx >= 0) 
59   {
60     Int_t mothIdx = stack.Particle(partIdx)->GetMother(0);
61     if(mothIdx < 0) return -1;
62     TParticle *mother = stack.Particle(mothIdx);
63     if(mother)
64     {
65       if(stack.IsPhysicalPrimary(mothIdx)) return mothIdx;
66       else return GetPrimary(mothIdx, stack);
67     }
68     else 
69     {
70       std::cout << "WAT!" << std::endl;
71       return -1;
72     }
73   }
74   return -1;
75 }
76 Bool_t AliAnalysisEtSelector::FromSecondaryInteraction(const TParticle& part, AliStack &stack) const
77 {
78 //   Bool_t partVtxSecondary = (
79 //                            TMath::Sqrt(part.Vx()*part.Vx() + part.Vy()*part.Vy()) > fCuts->GetPrimaryVertexCutXY() 
80 //                            || TMath::Abs(part.Vz()) > fCuts->GetPrimaryVertexCutZ()
81 //                          )
82 //                          && TMath::Sqrt(part.Vx()*part.Vx()+part.Vy()*part.Vy() + part.Vz()*part.Vz())<(fCuts->GetGeometryPhosDetectorRadius()-10);
83   
84   //Let's find suspect decay (typical for secondary interaction)...
85   
86   return SuspeciousDecayInChain(211, 111, part, stack);
87   
88                             
89   
90   
91 }
92
93 Bool_t AliAnalysisEtSelector::SuspeciousDecayInChain(const UInt_t suspectMotherPdg, const UInt_t suspectDaughterPdg, const TParticle &part, AliStack& stack) const
94 {
95   UInt_t partPdg = TMath::Abs(part.GetPdgCode());
96   if(part.GetFirstMother() == -1)
97   {
98     return kFALSE;
99   }
100   TParticle *mother = stack.Particle(part.GetFirstMother()); 
101   UInt_t motherPdg = TMath::Abs(mother->GetPdgCode());
102   if((suspectDaughterPdg==partPdg || 2112 == partPdg )&& suspectMotherPdg == motherPdg)
103   {
104     return kTRUE;
105   }
106   return SuspeciousDecayInChain(suspectMotherPdg, suspectDaughterPdg, *mother, stack);
107 }