5b0668f2b9a48b796a566409b90eec20eb5f1143
[u/mrichter/AliRoot.git] / EVE / alice-macros / aod_HF.C
1 // $Id$
2 // Main author: Davide Caffarri 2009
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 class AliAODRecoDecayHF; 
11
12 void aod_hf_init_rectrack(TEveRecTrack& rt, AliExternalTrackParam* tp)
13 {
14   Double_t      pbuf[3], vbuf[3];
15   rt.fSign = tp->GetSign();
16   tp->GetXYZ(vbuf);     rt.fV.Set(vbuf);
17   tp->GetPxPyPz(pbuf);  rt.fP.Set(pbuf);
18   // Double_t ep = at->GetP(), mc = at->GetMass();
19   rt.fBeta = 1; // ep/TMath::Sqrt(ep*ep + mc*mc);
20 }
21
22
23 AliEveHF* aod_make_HF(TEveTrackPropagator* rnrStyle, AliAODVertex* primAODVtx,
24                       AliESDtrack* neg, AliESDtrack* pos, AliAODRecoDecayHF* rd, Int_t i)
25
26   TEveRecTrack  rcPos;
27   TEveRecTrack  rcNeg;
28   //TEveRecV0     rcV0;
29
30   /*Double_t p[3];
31   p[0]=rd->PxProng(0);  p[1]=rd->PyProng(0);  p[2]=rd->PzProng(0);
32   rcV0.fPPos.Set(p);
33   p[0]=rd->PxProng(1);  p[1]=rd->PyProng(1);  p[2]=rd->PzProng(1);
34   rcV0.fPNeg.Set(p);
35
36   p[0]=rd->Px();  p[1]=rd->Py();  p[2]=rd->Pz();
37   */
38  
39   Double_t primVtx[3]={primAODVtx->GetX(), primAODVtx->GetY(), primAODVtx->GetZ(),};
40   
41
42   Double_t v[3] = {rd->Xv(),rd->Yv(),rd->Zv()};
43   printf("vertex %f %f %f\n",v[0],v[1],v[2]);
44   
45   aod_hf_init_rectrack(rcNeg, neg);
46   //rcNeg.fIndex = v0->GetNindex();
47   aod_hf_init_rectrack(rcPos, pos);
48   //rcPos.fIndex = v0->GetPindex();
49
50   AliEveHF* myHF = new AliEveHF(&rcNeg, &rcPos, primVtx ,rd, v, rnrStyle);
51   myHF->SetElementName(Form("D0->Kpi %d", i));
52   myHF->SetElementTitle(Form("CosPointingAngle %f",
53                              rd->CosPointingAngle()));
54   myHF->SetAODIndex(i);
55   return myHF;
56 }
57
58
59 AliEveHFList* aod_HF()
60 { Bool_t useParFiles=kFALSE;
61   gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/LoadLibraries.C");
62   LoadLibraries(useParFiles);
63   
64   
65   AliAODEvent* aod = AliEveEventManager::AssertAOD();
66   AliESDEvent* esd = AliEveEventManager::AssertESD();
67
68  
69   /*gSystem->Load("libANALYSIS");
70   gSystem->Load("libANALYSISalice");
71   gSystem->Load("libCORRFW");
72   gSystem->Load("libPWG3base");
73   gSystem->Load("libPWG3vertexingHF");
74   */
75
76   // load MC particles
77   TClonesArray *mcArray = 
78     (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
79   if(!mcArray) {
80     printf("MC particles branch not found!\n");
81     return;
82   }
83
84
85   AliAODVertex* primVtx_aod = (AliAODVertex*) aod->GetPrimaryVertex();
86   // AliESDVertex *primVtx_esd = (AliESDVertex*) esd->GetPrimaryVertex();
87
88
89   AliEveHFList* cont = new AliEveHFList("AOD HF vertices");
90   cont->SetMainColor(2);
91   TEveTrackPropagator* rnrStyle = cont->GetPropagator();
92   rnrStyle->SetMagField( 0.1*aod->GetMagneticField() );
93
94   gEve->AddElement(cont);
95
96   TEvePointSet* pointsD0toKpi = new TEvePointSet("D0->Kpi vertex locations");
97
98   // load D0->Kpi candidates
99   TClonesArray *arrayD0toKpi = (TClonesArray*)aod->GetList()->FindObject("D0toKpi"); 
100      
101   // load 3prong candidates
102   // TClonesArray *array3Prong = 
103   // (TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); 
104
105   Int_t countD0 = 0;
106   for (Int_t iD0toKpi=0; iD0toKpi<(arrayD0toKpi->GetEntriesFast()); iD0toKpi++) {
107     AliAODRecoDecayHF2Prong *rd = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
108     Bool_t unsetvtx=kFALSE;
109     if(!rd->GetOwnPrimaryVtx()) {
110       rd->SetOwnPrimaryVtx(primVtx_aod);
111       unsetvtx=kTRUE;
112     }    
113     // REAL D0 particle. If you want to draw only real D0 un-comment these lines
114     //Int_t labD0 = rd->MatchToMC(421,mcArray);
115     //if(labD0<0) continue;
116
117     AliAODTrack* negAODTr = rd->GetDaughter(0);
118     AliAODTrack* posAODTr = rd->GetDaughter(1);
119     
120     AliVVertex *secv = rd->GetSecondaryVtx();
121
122     AliESDtrack *negTr = new AliESDtrack(negAODTr);
123     AliESDtrack *posTr = new AliESDtrack(posAODTr);
124
125     negTr->PropagateToDCA((AliAODVertex*)secv,aod->GetMagneticField(),100.);
126     posTr->PropagateToDCA((AliAODVertex*)secv,aod->GetMagneticField(),100.);
127
128     AliEveHF* myD0 = aod_make_HF(rnrStyle,primVtx_aod,negTr,posTr,rd,iD0toKpi);
129     if (myD0) {
130       gEve->AddElement(myD0,cont);
131       countD0++;
132     }
133
134     pointsD0toKpi->SetNextPoint(rd->Xv(),rd->Yv(),rd->Zv());
135     pointsD0toKpi->SetPointId(rd);
136
137     if(unsetvtx) {
138       rd->UnsetOwnPrimaryVtx();
139     }    
140
141   }
142
143   //cont->SetTitle("test");
144
145   cont->MakeHFs();
146   gEve->Redraw3D();
147
148   pointsD0toKpi->SetTitle(Form("N=%d",pointsD0toKpi->Size()));
149   pointsD0toKpi->SetMarkerStyle(4);
150   pointsD0toKpi->SetMarkerSize(1.5);
151   pointsD0toKpi->SetMarkerColor(kViolet);
152
153   gEve->AddElement(pointsD0toKpi);
154   gEve->Redraw3D();
155
156   return cont;
157 }
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173