]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveHF.cxx
Coverity
[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   fRecDecayMomHF(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, 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   fRecDecayMomHF(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]; 
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         break;
171       case 1:
172         fProngMaxProbPdg[ip] = -13;
173     break;
174       case 2:
175         fProngMaxProbPdg[ip] = 211;
176     break;
177       case 3:
178         fProngMaxProbPdg[ip] = 321;
179     break;
180       case 4:
181         fProngMaxProbPdg[ip] = 2212;
182     break;
183       }
184   }
185
186 }
187
188 //________________________________________________________________________________________
189 void AliEveHF::CalculateInvMass(Int_t decay)
190 {
191
192   //Method to calculate the invariant mass of the particle and the antiparticle. 
193   UInt_t   pdg2[2];
194   Double_t mPDG,minv;
195
196   switch (decay)
197     {
198     case 0:                  // D0->Kpi
199       pdg2[0]=211; pdg2[1]=321;
200       mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
201       minv = fAODobj->InvMass(fnProng,pdg2);
202       fInvariantMassPart=minv;
203
204       pdg2[0]=321; pdg2[1]=211;
205       minv = fAODobj->InvMass(fnProng,pdg2);
206       fInvariantMassAntiPart=minv;
207       break;
208     }
209
210 }
211
212 //______________________________________________________________________________
213 Bool_t AliEveHF::SelectInvMass(Int_t decay, Float_t decayCuts)
214 {
215
216   //Member fuction to select particles using the invariant mass cuts. 
217   UInt_t   pdg2[2];
218   Double_t mPDG,minv;
219
220   Bool_t retval=kFALSE;
221   switch (decay)
222     {
223     case 0:                  // D0->Kpi
224       pdg2[0]=211; pdg2[1]=321;
225       mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
226       minv = fAODobj->InvMass(fnProng,pdg2);
227       fInvariantMassPart=minv;
228       if(TMath::Abs(minv-mPDG)<decayCuts) retval=kTRUE;
229       pdg2[0]=321; pdg2[1]=211;
230       minv = fAODobj->InvMass(fnProng,pdg2);
231       fInvariantMassAntiPart=minv;
232       if(TMath::Abs(minv-mPDG)<decayCuts) retval=kTRUE;
233       break;
234     }
235   return retval;
236
237 }
238
239
240 //______________________________________________________________________________
241 void AliEveHF::MakeHF()
242 {
243   // Set all dependant components for drawing.
244
245   SetPoint(0, fRecDecayHF.fX, fRecDecayHF.fY, fRecDecayHF.fZ);
246
247   fNegTrack->MakeTrack();
248   fPosTrack->MakeTrack();
249
250   fPointingLine->SetPoint(0, fRecBirthHF.fX, fRecBirthHF.fY, fRecBirthHF.fZ);
251   fPointingLine->SetPoint(1, fRecDecayHF.fX, fRecDecayHF.fY, fRecDecayHF.fZ);
252 }
253
254 /***********************************************************************
255 *
256 *  AliEveHFList class
257 *
258 ************************************************************************/
259
260 ClassImp(AliEveHFList)
261
262 //______________________________________________________________________________
263 AliEveHFList::AliEveHFList() :
264   TEveElementList(),
265   fTitle(),
266   fRnrStyle(0),
267   fRnrDaughters(kTRUE),
268   fRnrHFvtx(kTRUE),
269   fRnrHFpath(kTRUE),
270   fProngColor(0),
271   fMinRCut(0),
272   fMaxRCut(250),
273   fMinDaughterDCA(0),
274   fMaxDaughterDCA(1),
275   fMinPt(0),
276   fMaxPt(20),
277   fMinCosPointingAngle(0),
278   fMaxCosPointingAngle(1),
279   fMind0(-3),
280   fMaxd0(3),
281   fProngCheckedPid(0x0),
282   fProngCheckedProb(0x0),
283   fDeltaInvariantMass(0),
284   fDecay(0)
285 {
286   // Default constructor.
287
288   fChildClass = AliEveHF::Class(); // override member from base TEveElementList
289 }
290
291 //______________________________________________________________________________
292 AliEveHFList::AliEveHFList(TEveTrackPropagator* rs) :
293   TEveElementList(),
294   fTitle(),
295   fRnrStyle(rs),
296   fRnrDaughters(kTRUE),
297   fRnrHFvtx(kTRUE),
298   fRnrHFpath(kTRUE),
299   fProngColor(0),
300   fMinRCut(0),
301   fMaxRCut(250),
302   fMinDaughterDCA(0),
303   fMaxDaughterDCA(1),
304   fMinPt(0),
305   fMaxPt(20),
306   fMinCosPointingAngle(0),
307   fMaxCosPointingAngle(1),
308   fMind0(-3),
309   fMaxd0(3),
310   fProngCheckedPid(0x0),
311   fProngCheckedProb(0x0),
312   fDeltaInvariantMass(1),
313   fDecay(0)
314 {
315   // Constructor with given track-propagator..
316
317   fChildClass = AliEveHF::Class(); // override member from base TEveElementList
318
319   Init();
320 }
321
322 //______________________________________________________________________________
323 AliEveHFList::AliEveHFList(const Text_t* name, TEveTrackPropagator* rs) :
324   TEveElementList(),
325   fTitle(),
326   fRnrStyle(rs),
327   fRnrDaughters(kTRUE),
328   fRnrHFvtx(kTRUE),
329   fRnrHFpath(kTRUE),
330   fProngColor(0),
331   fMinRCut(0),
332   fMaxRCut(100),
333   fMinDaughterDCA(0),
334   fMaxDaughterDCA(1),
335   fMinPt(0),
336   fMaxPt(20),
337   fMinCosPointingAngle(0),
338   fMaxCosPointingAngle(1),
339   fMind0(-3),
340   fMaxd0(3),
341   fProngCheckedPid(0x0),
342   fProngCheckedProb(0x0),
343   fDeltaInvariantMass(1),
344   fDecay(0)
345 {
346   // Standard constructor.
347
348   fChildClass = AliEveHF::Class(); // override member from base TEveElementList
349
350   Init();
351   SetName(name);
352 }
353
354 //______________________________________________________________________________
355 void AliEveHFList::Init()
356 {
357   // Initialize members needed for drawing operations.
358
359   if (fRnrStyle== 0) fRnrStyle = new TEveTrackPropagator;
360 }
361
362 /******************************************************************************/
363
364 //______________________________________________________________________________
365 void AliEveHFList::MakeHFs()
366 {
367   // Call MakeHF() for all elements.
368
369   for(List_i i=fChildren.begin(); i!=fChildren.end(); i++) {
370     ((AliEveHF*)(*i))->MakeHF();
371   }
372   gEve->Redraw3D();
373 }
374
375 /******************************************************************************/
376
377
378 //______________________________________________________________________________
379 void AliEveHFList::FilterByPt(Float_t minPt, Float_t maxPt)
380 {
381
382   //Select visibility of elements based on their Pt
383
384   fMinPt = minPt;
385   fMaxPt = maxPt;
386
387   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
388     {
389       AliEveHF *hf = (AliEveHF*) *i;
390       Float_t  pt  = hf->GetPt();
391       Bool_t  show = ((pt >= fMinPt) && (pt <= fMaxPt));
392       hf->SetRnrState(show);
393     }
394   ElementChanged();
395   gEve->Redraw3D();
396 }
397 //______________________________________________________________________________
398 void AliEveHFList::FilterByRadius(Float_t minR, Float_t maxR)
399 {
400   // Select visibility of elements based on their axial radius.
401
402   fMinRCut = minR;
403   fMaxRCut = maxR;
404
405   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
406     {
407       AliEveHF *hf = (AliEveHF*) *i;
408       Float_t  rad = hf->GetRadius();
409       Bool_t  show = rad >= fMinRCut && rad <= fMaxRCut;
410       hf->SetRnrState(show);
411     }
412   ElementChanged();
413   gEve->Redraw3D();
414 }
415
416 /******************************************************************************/
417
418
419 //______________________________________________________________________________
420 void AliEveHFList::FilterByCosPointingAngle(Float_t minCosPointingAngle, Float_t maxCosPointingAngle)
421 {
422   // Select visibility of elements based on the HF cosine of the pointing angle
423
424   fMinCosPointingAngle = minCosPointingAngle;
425   fMaxCosPointingAngle = maxCosPointingAngle;
426
427
428   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
429     {
430       AliEveHF *hf = (AliEveHF*) *i;
431       Float_t  cosPointingAngle = hf->GetCosPointingAngle();
432       Bool_t  show = cosPointingAngle >= fMinCosPointingAngle && cosPointingAngle <= fMaxCosPointingAngle;
433       hf->SetRnrState(show);
434
435       ElementChanged();
436       gEve->Redraw3D();
437     }
438 }
439 //______________________________________________________________________________
440 void AliEveHFList::FilterByd0(Float_t mind0, Float_t maxd0)
441 {
442   // Select visibility of elements based on the HF impact parameter.
443
444   fMind0 = mind0;
445   fMaxd0 = maxd0;
446
447   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
448     {
449       AliEveHF *hf = (AliEveHF*) *i;
450       Int_t nProng=(Int_t)hf->GetAODobj()->GetNProngs();
451       for(Int_t ip = 1; ip < nProng; ++ip) {
452         Double_t  d0 = hf->Getd0Prong(ip);
453         Bool_t  show = d0 >= fMind0 && d0 <= fMaxd0;
454         hf->SetRnrState(show);
455       }
456       ElementChanged();
457       gEve->Redraw3D();
458     }
459 }
460
461
462  //______________________________________________________________________________
463 void AliEveHFList::FilterByDCA(Float_t minDaughterDCA, Float_t maxDaughterDCA)
464 {
465   // Select visibility of elements based on the DCA between daughters.
466
467   fMinDaughterDCA = minDaughterDCA;
468   fMaxDaughterDCA = maxDaughterDCA;
469
470   Double_t dca;
471   AliEveHF *hf();
472
473
474   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
475   {
476     AliEveHF* hf = (AliEveHF*) *i;
477     Int_t nProng=(Int_t)hf->GetAODobj()->GetNProngs();
478     for(Int_t ip = 1; ip < nProng; ++ip) {
479       dca = hf->GetProngDCA(ip);
480       Bool_t  show = dca >= fMinDaughterDCA && dca <= fMaxDaughterDCA;
481       hf->SetRnrState(show);
482     }
483   }
484   ElementChanged();
485   gEve->Redraw3D();
486 }
487
488 /******************************************************************************/
489 //______________________________________________________________________________
490 /*void AliEveHFList::FilterByCheckedPidMinProb(Int_t rFlag,Int_t rDaughter, Int_t rPid, Float_t rProb)
491 {
492
493    if (!rDaughter){
494     fNegCheckedPid  = rPid;
495     fNegCheckedProb = rProb;
496   }
497   else {
498     fPosCheckedPid  = rPid;
499     fPosCheckedProb = rProb;
500   }
501
502   // Select visibility of elements based on one of the V0 daughters PID
503   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
504   {
505     AliEveHF* hf = (AliEveHF*) *i;
506     Int_t   pid = 0;
507     Float_t prob = 0.0;
508     Bool_t  show = 0;
509     if     (!rDaughter) {// Negative daughter checked
510       pid  = hf->GetNegMaxProbPdg();
511       prob = hf->GetNegMaxProbPid();
512       show = (pid == fNegCheckedPid && prob > fNegCheckedProb) || !rFlag ;
513     }
514     else if (rDaughter) {// Positive daughter checked
515       pid = hf->GetPosMaxProbPdg();
516       prob = hf->GetPosMaxProbPid();
517       show = (pid == fPosCheckedPid && prob > fPosCheckedProb) || !rFlag ;
518     }
519     hf->SetRnrState(show);
520 exit  }
521   ElementChanged();
522   gEve->Redraw3D();
523   }*/
524
525 //______________________________________________________________________________
526
527 void AliEveHFList::FilterByInvariantMass(Int_t decay, Float_t deltaInvariantMass)
528 {
529   // Select visibility of elements based on the HF  invariant mass.
530
531   fDeltaInvariantMass = deltaInvariantMass;
532   fDecay = decay;
533
534   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
535   {
536     AliEveHF* hf = (AliEveHF*) *i;
537     Bool_t show  = hf->SelectInvMass(decay, fDeltaInvariantMass);
538     // if (show) show = (invMass >= (fInvariantMass-fDeltaInvariantMass)) && (invMass <= (fInvariantMass+fDeltaInvariantMass));
539     hf->SetRnrState(show);
540   }
541   ElementChanged();
542   gEve->Redraw3D();
543 }