]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveHF.cxx
* AliEveEventManager - make sure each AOD friend is only registered
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveHF.cxx
1 // $Id$
2 // Main author: Davide Caffarri 2009
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * ee http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveHF.h"
11 #include "AliAODRecoDecay.h"
12
13 #include <TEveTrack.h>
14 #include <TEveTrackPropagator.h>
15 #include <TEveManager.h>
16
17 #include <TPolyLine3D.h>
18 #include <TPolyMarker3D.h>
19 #include <TColor.h>
20
21 #include <TDatabasePDG.h>
22 #include <TParticlePDG.h>
23
24 #include <vector>
25
26
27 /***********************************************************************
28 *
29 *  AliEveHF class
30 *
31 ************************************************************************/
32
33
34 ClassImp(AliEveHF)
35
36 //______________________________________________________________________________
37 AliEveHF::AliEveHF():
38   TEvePointSet(),
39
40   fAODobj(0x0),
41   fRecBirthHF(0,0,0),
42   fRecDecayHF(0,0,0),
43   fRecDecayP_HF(0,0,0),
44   fPointingAngleHF(0),
45
46   fNegTrack(0),
47   fPosTrack(0),
48   fRnrStyle(0),
49   fPointingLine(0),
50
51   fnProng(0),
52   fAODIndex(-1),
53   fChi2SecondVtx(-1),
54
55   fProngDCA(0x0),
56   fProngd0(0x0),
57   fProngMaxProbPdg(0x0),
58   fProngMaxProbPid(0x0),
59   fInvariantMassPart(0),
60   fInvariantMassAntiPart(0),
61   fDecay(0)
62
63 {
64   // Default constructor.
65
66   // Override from TEveElement.
67   fPickable = kTRUE;
68   fMainColorPtr = &fMarkerColor;
69 }
70
71 //______________________________________________________________________________
72 AliEveHF::AliEveHF(TEveRecTrack* tNeg, TEveRecTrack* tPos, Double_t primVtx[3], AliAODRecoDecay* aodObj, Double_t /*firstPointTrack*/[3], TEveTrackPropagator* rs) :
73
74   TEvePointSet(),
75
76   fAODobj(aodObj),
77   fRecBirthHF(primVtx[0], primVtx[1], primVtx[2]),
78   fRecDecayHF(aodObj->GetSecVtxX(), aodObj->GetSecVtxY(), aodObj->GetSecVtxZ()),
79   fRecDecayP_HF(aodObj->Px(),aodObj->Py(),aodObj->Pz()),
80   fPointingAngleHF(aodObj->CosPointingAngle(primVtx)),
81
82   fNegTrack(new TEveTrack(tNeg, rs)),
83   fPosTrack(new TEveTrack(tPos, rs)),
84   fRnrStyle(rs),
85   fPointingLine(new TEveLine("Pointing line")),
86
87   fnProng(aodObj->GetNProngs()),
88   fAODIndex(-1),
89   fChi2SecondVtx(aodObj->GetReducedChi2()),
90
91   fProngDCA(0),
92   fProngd0(0),
93   fProngMaxProbPdg(0),
94   fProngMaxProbPid(0),
95   fInvariantMassPart(0),
96   fInvariantMassAntiPart(0),
97   fDecay(0)
98 {
99
100   // Constructor with full HF specification.
101   // Override from TEveElement.
102   fPickable = kTRUE;
103   fMainColorPtr = &fMarkerColor;
104
105   fMarkerStyle = 2;
106   fMarkerColor = kSpring + 6;
107   fMarkerSize  = 0.3;
108
109   fPointingLine->SetLineColor(fMarkerColor);
110   fPointingLine->SetLineWidth(2);
111   fPointingLine->IncDenyDestroy();
112   AddElement(fPointingLine);
113
114   fPosTrack->SetLineColor(2);  // red
115   fPosTrack->SetStdTitle();
116   fNegTrack->SetLineColor(7);  // light blue
117   fNegTrack->SetStdTitle();
118
119   fNegTrack->IncDenyDestroy();
120   AddElement(fNegTrack);
121   fPosTrack->IncDenyDestroy();
122   AddElement(fPosTrack);
123 }
124
125 //______________________________________________________________________________
126 AliEveHF::~AliEveHF()
127 {
128   // Destructor. Dereferences pos/neg tracks and pointing-line objects.
129
130   fNegTrack->DecDenyDestroy();
131   fPosTrack->DecDenyDestroy();
132   fPointingLine->DecDenyDestroy();
133 }
134
135 //_____________________________________________________________________________
136 void AliEveHF::SetProngDCA() const
137 {
138   for(Int_t ip=0; ip<fnProng; ip++)
139     fProngDCA[ip] = fAODobj->GetDCA(ip);
140 }
141
142 //______________________________________________________________________________
143 void AliEveHF::Setd0Prong() const
144 {
145   for(Int_t ip=0; ip<fnProng; ip++)
146     fProngd0[ip] = fAODobj->Getd0Prong(ip);
147 }
148
149
150 //______________________________________________________________________________
151 void AliEveHF::SetMaxProbPdgPid()
152 {
153   // Sets the maximum probability Pdg value and Pid for one daughter
154   // Should be moved to TEveTrack property eventually (or AliEveTrack creation)
155   Double_t pid[5];
156   Int_t    pos = -1;
157
158   for (Int_t ip=0; ip<fnProng; ip++){
159     fAODobj->GetPIDProng(ip, pid);
160
161     fProngMaxProbPid[ip]=pid[0]; //lascio cosi perchè mi da errore se lo uso come puntatore
162     for (Int_t pp=1; pp<5; pp++)
163       if (pid[pp]>pid[pp-1]) {
164         fProngMaxProbPid[ip]=pid[pp];
165         pos = pp;}
166     switch (pos)
167       {
168       case 0:
169         fProngMaxProbPdg[ip] = -11;
170       case 1:
171         fProngMaxProbPdg[ip] = -13;
172       case 2:
173         fProngMaxProbPdg[ip] = 211;
174       case 3:
175         fProngMaxProbPdg[ip] = 321;
176       case 4:
177         fProngMaxProbPdg[ip] = 2212;
178       }
179   }
180
181 }
182
183 //________________________________________________________________________________________
184 void AliEveHF::CalculateInvMass(Int_t decay)
185 {
186   UInt_t   pdg2[2];
187   Double_t mPDG,minv;
188
189   switch (decay)
190     {
191     case 0:                  // D0->Kpi
192       pdg2[0]=211; pdg2[1]=321;
193       mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
194       minv = fAODobj->InvMass(fnProng,pdg2);
195       fInvariantMassPart=minv;
196
197       pdg2[0]=321; pdg2[1]=211;
198       minv = fAODobj->InvMass(fnProng,pdg2);
199       fInvariantMassAntiPart=minv;
200       break;
201     }
202
203 }
204
205 //______________________________________________________________________________
206 Bool_t AliEveHF::SelectInvMass(Int_t decay, Float_t decayCuts)
207 {
208   UInt_t   pdg2[2];
209   Double_t mPDG,minv;
210
211   Bool_t retval=kFALSE;
212   switch (decay)
213     {
214     case 0:                  // D0->Kpi
215       pdg2[0]=211; pdg2[1]=321;
216       mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
217       minv = fAODobj->InvMass(fnProng,pdg2);
218       fInvariantMassPart=minv;
219       if(TMath::Abs(minv-mPDG)<decayCuts) retval=kTRUE;
220       pdg2[0]=321; pdg2[1]=211;
221       minv = fAODobj->InvMass(fnProng,pdg2);
222       fInvariantMassAntiPart=minv;
223       if(TMath::Abs(minv-mPDG)<decayCuts) retval=kTRUE;
224       break;
225     }
226   return retval;
227
228 }
229
230
231 //______________________________________________________________________________
232 void AliEveHF::MakeHF()
233 {
234   // Set all dependant components for drawing.
235
236   SetPoint(0, fRecDecayHF.fX, fRecDecayHF.fY, fRecDecayHF.fZ);
237
238   fNegTrack->MakeTrack();
239   fPosTrack->MakeTrack();
240
241   fPointingLine->SetPoint(0, fRecBirthHF.fX, fRecBirthHF.fY, fRecBirthHF.fZ);
242   fPointingLine->SetPoint(1, fRecDecayHF.fX, fRecDecayHF.fY, fRecDecayHF.fZ);
243 }
244
245 /***********************************************************************
246 *
247 *  AliEveHFList class
248 *
249 ************************************************************************/
250
251 ClassImp(AliEveHFList)
252
253 //______________________________________________________________________________
254 AliEveHFList::AliEveHFList() :
255   TEveElementList(),
256   fTitle(),
257   fRnrStyle(0),
258   fRnrDaughters(kTRUE),
259   fRnrHFvtx(kTRUE),
260   fRnrHFpath(kTRUE),
261   fProngColor(0),
262   fMinRCut(0),
263   fMaxRCut(250),
264   fMinDaughterDCA(0),
265   fMaxDaughterDCA(1),
266   fMinPt(0),
267   fMaxPt(20),
268   fMinCosPointingAngle(0),
269   fMaxCosPointingAngle(1),
270   fMind0(-3),
271   fMaxd0(3),
272   fProngCheckedPid(0x0),
273   fProngCheckedProb(0x0),
274   fDeltaInvariantMass(0),
275   fDecay(0)
276 {
277   // Default constructor.
278
279   fChildClass = AliEveHF::Class(); // override member from base TEveElementList
280 }
281
282 //______________________________________________________________________________
283 AliEveHFList::AliEveHFList(TEveTrackPropagator* rs) :
284   TEveElementList(),
285   fTitle(),
286   fRnrStyle(rs),
287   fRnrDaughters(kTRUE),
288   fRnrHFvtx(kTRUE),
289   fRnrHFpath(kTRUE),
290   fProngColor(0),
291   fMinRCut(0),
292   fMaxRCut(250),
293   fMinDaughterDCA(0),
294   fMaxDaughterDCA(1),
295   fMinPt(0),
296   fMaxPt(20),
297   fMinCosPointingAngle(0),
298   fMaxCosPointingAngle(1),
299   fMind0(-3),
300   fMaxd0(3),
301   fProngCheckedPid(0x0),
302   fProngCheckedProb(0x0),
303   fDeltaInvariantMass(1),
304   fDecay(0)
305 {
306   // Constructor with given track-propagator..
307
308   fChildClass = AliEveHF::Class(); // override member from base TEveElementList
309
310   Init();
311 }
312
313 //______________________________________________________________________________
314 AliEveHFList::AliEveHFList(const Text_t* name, TEveTrackPropagator* rs) :
315   TEveElementList(),
316   fTitle(),
317   fRnrStyle(rs),
318   fRnrDaughters(kTRUE),
319   fRnrHFvtx(kTRUE),
320   fRnrHFpath(kTRUE),
321   fProngColor(0),
322   fMinRCut(0),
323   fMaxRCut(100),
324   fMinDaughterDCA(0),
325   fMaxDaughterDCA(1),
326   fMinPt(0),
327   fMaxPt(20),
328   fMinCosPointingAngle(0),
329   fMaxCosPointingAngle(1),
330   fMind0(-3),
331   fMaxd0(3),
332   fProngCheckedPid(0x0),
333   fProngCheckedProb(0x0),
334   fDeltaInvariantMass(1),
335   fDecay(0)
336 {
337   // Standard constructor.
338
339   fChildClass = AliEveHF::Class(); // override member from base TEveElementList
340
341   Init();
342   SetName(name);
343 }
344
345 //______________________________________________________________________________
346 void AliEveHFList::Init()
347 {
348   // Initialize members needed for drawing operations.
349
350   if (fRnrStyle== 0) fRnrStyle = new TEveTrackPropagator;
351 }
352
353 /******************************************************************************/
354
355 //______________________________________________________________________________
356 void AliEveHFList::MakeHFs()
357 {
358   // Call MakeHF() for all elements.
359
360   for(List_i i=fChildren.begin(); i!=fChildren.end(); i++) {
361     ((AliEveHF*)(*i))->MakeHF();
362   }
363   gEve->Redraw3D();
364 }
365
366 /******************************************************************************/
367
368
369 //______________________________________________________________________________
370 void AliEveHFList::FilterByPt(Float_t minPt, Float_t maxPt)
371 {
372
373
374   fMinPt = minPt;
375   fMaxPt = maxPt;
376
377   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)//lista gli HF!!!
378     {
379       AliEveHF *hf = (AliEveHF*) *i;
380       Float_t  pt  = hf->GetPt();
381       Bool_t  show = ((pt >= fMinPt) && (pt <= fMaxPt));
382       hf->SetRnrState(show);
383     }
384   ElementChanged();
385   gEve->Redraw3D();
386 }
387 //______________________________________________________________________________
388 void AliEveHFList::FilterByRadius(Float_t minR, Float_t maxR)
389 {
390   // Select visibility of elements based on their axial radius.
391
392   fMinRCut = minR;
393   fMaxRCut = maxR;
394
395   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)//lista gli HF!!!
396     {
397       AliEveHF *hf = (AliEveHF*) *i;
398       Float_t  rad = hf->GetRadius();
399       Bool_t  show = rad >= fMinRCut && rad <= fMaxRCut;
400       hf->SetRnrState(show);
401     }
402   ElementChanged();
403   gEve->Redraw3D();
404 }
405
406 /******************************************************************************/
407
408
409 //______________________________________________________________________________
410 void AliEveHFList::FilterByCosPointingAngle(Float_t minCosPointingAngle, Float_t maxCosPointingAngle)
411 {
412   // Select visibility of elements based on the V0 pt.
413
414   fMinCosPointingAngle = minCosPointingAngle;
415   fMaxCosPointingAngle = maxCosPointingAngle;
416
417
418   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)//lista gli HF!!!
419     {
420       AliEveHF *hf = (AliEveHF*) *i;
421       Float_t  cosPointingAngle = hf->GetCosPointingAngle();
422       Bool_t  show = cosPointingAngle >= fMinCosPointingAngle && cosPointingAngle <= fMaxCosPointingAngle;
423       hf->SetRnrState(show);
424
425       ElementChanged();
426       gEve->Redraw3D();
427     }
428 }
429 //______________________________________________________________________________
430 void AliEveHFList::FilterByd0(Float_t mind0, Float_t maxd0)
431 {
432   // Select visibility of elements based on the V0 pt.
433
434   fMind0 = mind0;
435   fMaxd0 = maxd0;
436
437   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
438     {
439       AliEveHF *hf = (AliEveHF*) *i;
440       Int_t nProng=(Int_t)hf->GetAODobj()->GetNProngs();
441       for(Int_t ip = 1; ip < nProng; ++ip) {
442         Double_t  d0 = hf->Getd0Prong(ip);
443         Bool_t  show = d0 >= fMind0 && d0 <= fMaxd0;
444         hf->SetRnrState(show);
445       }
446       ElementChanged();
447       gEve->Redraw3D();
448     }
449 }
450
451
452  //______________________________________________________________________________
453 void AliEveHFList::FilterByDCA(Float_t minDaughterDCA, Float_t maxDaughterDCA)
454 {
455   // Select visibility of elements based on the DCA between daughters.
456
457   fMinDaughterDCA = minDaughterDCA;
458   fMaxDaughterDCA = maxDaughterDCA;
459
460   Double_t dca;
461   AliEveHF *hf();
462
463
464   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
465   {
466     AliEveHF* hf = (AliEveHF*) *i;
467     Int_t nProng=(Int_t)hf->GetAODobj()->GetNProngs();
468     for(Int_t ip = 1; ip < nProng; ++ip) {
469       dca = hf->GetProngDCA(ip);
470       Bool_t  show = dca >= fMinDaughterDCA && dca <= fMaxDaughterDCA;
471       hf->SetRnrState(show);
472     }
473   }
474   ElementChanged();
475   gEve->Redraw3D();
476 }
477
478 /******************************************************************************/
479 //______________________________________________________________________________
480 /*void AliEveHFList::FilterByCheckedPidMinProb(Int_t rFlag,Int_t rDaughter, Int_t rPid, Float_t rProb)
481 {
482
483    if (!rDaughter){
484     fNegCheckedPid  = rPid;
485     fNegCheckedProb = rProb;
486   }
487   else {
488     fPosCheckedPid  = rPid;
489     fPosCheckedProb = rProb;
490   }
491
492   // Select visibility of elements based on one of the V0 daughters PID
493   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
494   {
495     AliEveHF* hf = (AliEveHF*) *i;
496     Int_t   pid = 0;
497     Float_t prob = 0.0;
498     Bool_t  show = 0;
499     if     (!rDaughter) {// Negative daughter checked
500       pid  = hf->GetNegMaxProbPdg();
501       prob = hf->GetNegMaxProbPid();
502       show = (pid == fNegCheckedPid && prob > fNegCheckedProb) || !rFlag ;
503     }
504     else if (rDaughter) {// Positive daughter checked
505       pid = hf->GetPosMaxProbPdg();
506       prob = hf->GetPosMaxProbPid();
507       show = (pid == fPosCheckedPid && prob > fPosCheckedProb) || !rFlag ;
508     }
509     hf->SetRnrState(show);
510 exit  }
511   ElementChanged();
512   gEve->Redraw3D();
513   }*/
514
515 //______________________________________________________________________________
516
517 void AliEveHFList::FilterByInvariantMass(Int_t decay, Float_t deltaInvariantMass)
518 {
519   // Select visibility of elements based on the HF  invariant mass.
520
521   fDeltaInvariantMass = deltaInvariantMass;
522   fDecay = decay;
523
524   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
525   {
526     AliEveHF* hf = (AliEveHF*) *i;
527     Bool_t show  = hf->SelectInvMass(decay, fDeltaInvariantMass);
528     // if (show) show = (invMass >= (fInvariantMass-fDeltaInvariantMass)) && (invMass <= (fInvariantMass+fDeltaInvariantMass));
529     hf->SetRnrState(show);
530   }
531   ElementChanged();
532   gEve->Redraw3D();
533 }