* AliEveEventManager - make sure each AOD friend is only registered
[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   /*
31     Double_t p[3];
32     p[0]=rd->PxProng(0);  p[1]=rd->PyProng(0);  p[2]=rd->PzProng(0);
33     rcV0.fPPos.Set(p);
34     p[0]=rd->PxProng(1);  p[1]=rd->PyProng(1);  p[2]=rd->PzProng(1);
35     rcV0.fPNeg.Set(p);
36
37     p[0]=rd->Px();  p[1]=rd->Py();  p[2]=rd->Pz();
38   */
39
40   Double_t primVtx[3]={primAODVtx->GetX(), primAODVtx->GetY(), primAODVtx->GetZ()};
41
42
43   Double_t v[3] = {rd->Xv(),rd->Yv(),rd->Zv()};
44   printf("vertex %f %f %f\n",v[0],v[1],v[2]);
45
46   aod_hf_init_rectrack(rcNeg, neg);
47   //rcNeg.fIndex = v0->GetNindex();
48   aod_hf_init_rectrack(rcPos, pos);
49   //rcPos.fIndex = v0->GetPindex();
50
51   AliEveHF* myHF = new AliEveHF(&rcNeg, &rcPos, primVtx ,rd, v, rnrStyle);
52   myHF->SetElementName(Form("D0->Kpi %d", i));
53   myHF->SetElementTitle(Form("CosPointingAngle %f", rd->CosPointingAngle()));
54   myHF->SetAODIndex(i);
55   return myHF;
56 }
57
58
59 AliEveHFList* aod_HF()
60 {
61   Bool_t useParFiles=kFALSE;
62   gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/LoadLibraries.C");
63   LoadLibraries(useParFiles);
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->FindListObject(AliAODMCParticle::StdBranchName());
79   if (!mcArray) {
80     printf("MC particles branch not found!\n");
81     return;
82   }
83
84   AliAODVertex* primVtx_aod = (AliAODVertex*) aod->GetPrimaryVertex();
85   // AliESDVertex *primVtx_esd = (AliESDVertex*) esd->GetPrimaryVertex();
86
87   AliEveHFList* cont = new AliEveHFList("AOD HF vertices");
88   cont->SetMainColor(2);
89   TEveTrackPropagator* rnrStyle = cont->GetPropagator();
90   rnrStyle->SetMagField( 0.1*aod->GetMagneticField() );
91
92   gEve->AddElement(cont);
93
94   TEvePointSet* pointsD0toKpi = new TEvePointSet("D0->Kpi vertex locations");
95
96   // load D0->Kpi candidates
97   TClonesArray *arrayD0toKpi = (TClonesArray*) aod->FindListObject("D0toKpi");
98
99   // load 3prong candidates
100   // TClonesArray *array3Prong =
101   // (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
102
103   Int_t countD0 = 0;
104   for (Int_t iD0toKpi=0; iD0toKpi<arrayD0toKpi->GetEntriesFast(); iD0toKpi++)
105   {
106     AliAODRecoDecayHF2Prong *rd = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
107     Bool_t unsetvtx=kFALSE;
108     if (!rd->GetOwnPrimaryVtx()) {
109       rd->SetOwnPrimaryVtx(primVtx_aod);
110       unsetvtx=kTRUE;
111     }
112     // REAL D0 particle. If you want to draw only real D0 un-comment these lines
113     //Int_t labD0 = rd->MatchToMC(421,mcArray);
114     //if(labD0<0) continue;
115
116     AliAODTrack *negAODTr = rd->GetDaughter(0);
117     AliAODTrack *posAODTr = rd->GetDaughter(1);
118
119     AliVVertex  *secv = rd->GetSecondaryVtx();
120
121     AliESDtrack *negTr = new AliESDtrack(negAODTr);
122     AliESDtrack *posTr = new AliESDtrack(posAODTr);
123
124     negTr->PropagateToDCA((AliAODVertex*)secv,aod->GetMagneticField(),100.);
125     posTr->PropagateToDCA((AliAODVertex*)secv,aod->GetMagneticField(),100.);
126
127     AliEveHF* myD0 = aod_make_HF(rnrStyle,primVtx_aod,negTr,posTr,rd,iD0toKpi);
128     if (myD0) {
129       gEve->AddElement(myD0,cont);
130       countD0++;
131     }
132
133     pointsD0toKpi->SetNextPoint(rd->Xv(),rd->Yv(),rd->Zv());
134     pointsD0toKpi->SetPointId(rd);
135
136     if(unsetvtx) {
137       rd->UnsetOwnPrimaryVtx();
138     }
139   }
140
141   //cont->SetTitle("test");
142
143   cont->MakeHFs();
144   gEve->Redraw3D();
145
146   pointsD0toKpi->SetTitle(Form("N=%d", pointsD0toKpi->Size()));
147   pointsD0toKpi->SetMarkerStyle(4);
148   pointsD0toKpi->SetMarkerSize(1.5);
149   pointsD0toKpi->SetMarkerColor(kViolet);
150
151   gEve->AddElement(pointsD0toKpi);
152   gEve->Redraw3D();
153
154   return cont;
155 }