]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnMiniParticle.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnMiniParticle.cxx
1 //
2 // This object is used as lightweight temporary container
3 // of all information needed from any input object and
4 // useful for resonance analysis.
5 // Lists of such objects are stored in a buffer, in order
6 // to allow an event mixing.
7 //
8
9 #include <TDatabasePDG.h>
10 #include <TParticlePDG.h>
11
12 #include "AliAODEvent.h"
13 #include "AliRsnEvent.h"
14 #include "AliRsnMiniEvent.h"
15 #include "AliRsnMiniParticle.h"
16
17 ClassImp(AliRsnMiniParticle)
18
19 //__________________________________________________________________________________________________
20 void AliRsnMiniParticle::CopyDaughter(AliRsnDaughter *daughter)
21 {
22 //
23 // Sets data members from the passed object
24 //
25
26    // reset what could not be initialized
27    fDCA = 0.0;  //typically used for D0 analysis
28    fPDG = 0;
29    fMother = -1;
30    fMotherPDG = 0;
31    fNTotSisters = -1;
32    fCutBits = 0x0;
33    fPsim[0] = fPrec[0] = fPmother[0] = fPsim[1] = fPrec[1] = fPmother[1] = fPsim[2] = fPrec[2] = fPmother[2] = 0.0;
34
35    // charge
36    if (daughter->IsPos())
37       fCharge = '+';
38    else if (daughter->IsNeg())
39       fCharge = '-';
40    else
41       fCharge = '0';
42
43    // rec info
44    if (daughter->GetRef()) {
45       fPrec[0] = daughter->GetRef()->Px();
46       fPrec[1] = daughter->GetRef()->Py();
47       fPrec[2] = daughter->GetRef()->Pz();
48    }
49
50    // MC info
51    if (daughter->GetRefMC()) {
52       fPsim[0] = daughter->GetRefMC()->Px();
53       fPsim[1] = daughter->GetRefMC()->Py();
54       fPsim[2] = daughter->GetRefMC()->Pz();
55       fPDG = daughter->GetPDG();
56       fMother = daughter->GetMother();
57       fMotherPDG = daughter->GetMotherPDG();
58    }
59    
60    AliRsnEvent *event = (AliRsnEvent *) daughter->GetOwnerEvent();
61    if (!event) {
62      AliWarning("Invalid reference event: cannot copy DCA nor Nsisters.");
63      return;
64    }
65    if (event->IsAOD()){
66      // DCA to Primary Vertex for AOD
67      AliAODTrack *track = (AliAODTrack*) daughter->Ref2AODtrack();   
68      AliAODEvent *aodEvent = (AliAODEvent*) event->GetRefAOD();
69      if (track && aodEvent) {
70        AliVVertex *vertex = (AliVVertex*) aodEvent->GetPrimaryVertex();
71        Double_t b[2], cov[3]; 
72        if (vertex) {
73          if ( !((track->GetStatus() & AliESDtrack::kTPCin) == 0) && !((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) && !((track->GetStatus() & AliESDtrack::kITSrefit) == 0) ){
74            if (track->PropagateToDCA(vertex, aodEvent->GetMagneticField(), kVeryBig, b, cov))
75              fDCA = b[0];
76          }
77        }
78      }
79      // Number of Daughters from MC and Momentum of the Mother
80      if (event->GetRefMC()) {
81        TClonesArray * list = event->GetAODList();
82        AliAODMCParticle *part = (AliAODMCParticle *)list->At(fMother);
83        if (part) {
84          fNTotSisters = part->GetNDaughters();
85          fPmother[0]  = part->Px();
86          fPmother[1]  = part->Py();
87          fPmother[2]  = part->Pz();
88        }
89      }
90    } else {
91      if (event->IsESD()){
92        //DCA to Primary Vertex for ESD
93        AliESDtrack *track = (AliESDtrack*) daughter->Ref2ESDtrack();   
94        AliESDEvent *esdEvent = (AliESDEvent*) event->GetRefESD();
95        if (track && esdEvent) {
96          AliVVertex *vertex = (AliVVertex*) esdEvent->GetPrimaryVertex();
97          Double_t b[2], cov[3]; 
98          if (vertex) {
99            if ( !((track->GetStatus() & AliESDtrack::kTPCin) == 0) && !((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) && !((track->GetStatus() & AliESDtrack::kITSrefit) == 0) ){
100              if (track->PropagateToDCA(vertex, esdEvent->GetMagneticField(), kVeryBig, b, cov))
101                fDCA = b[0];
102            }
103          }
104        }
105        // Number of Daughters from MC and Momentum of the Mother
106        if (event->GetRefMC()) {
107          AliMCParticle *part = (AliMCParticle *)event->GetRefMC()->GetTrack(fMother);
108          if(part){
109            fNTotSisters = part->Particle()->GetNDaughters();
110            fPmother[0]  = part->Px();
111            fPmother[1]  = part->Py();
112            fPmother[2]  = part->Pz();
113          }
114        }
115      }
116    }
117 }
118
119 //__________________________________________________________________________________________________
120 Double_t AliRsnMiniParticle::Mass()
121 {
122    //
123    // return mass of particle
124    //
125
126    TDatabasePDG *db   = TDatabasePDG::Instance();
127    TParticlePDG *part = db->GetParticle(PDG());
128    return part->Mass();
129 }
130
131 //__________________________________________________________________________________________________
132 void AliRsnMiniParticle::Set4Vector(TLorentzVector &v, Float_t mass, Bool_t mc)
133 {
134    //
135    // return 4 vector of particle
136    //
137
138    if (mass<0.0) mass = Mass();
139    v.SetXYZM(Px(mc), Py(mc), Pz(mc),mass);
140 }