]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveV0.cxx
From Pawel Debski.
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveV0.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 #include "AliEveV0.h"
11
12 #include <TEveTrackPropagator.h>
13 #include <TEveManager.h>
14
15 #include <TPolyLine3D.h>
16 #include <TColor.h>
17
18 #include <TDatabasePDG.h>
19 #include <TParticlePDG.h>
20
21 #include <vector>
22
23 //______________________________________________________________________________
24 // Representation of a reconstructed V0.
25
26 ClassImp(AliEveV0)
27
28 //______________________________________________________________________________
29 AliEveV0::AliEveV0() :
30   TEvePointSet(),
31
32   fRecBirthV(),
33   fRecDecayV(),
34   fRecDecayP(),
35   fNegTrack(0),
36   fPosTrack(0),
37   fRnrStyle(0),
38   fPointingLine(0),
39   fESDIndex(-1),
40   fOnFlyStatus(kFALSE),
41   fDaughterDCA(999),
42   fChi2V0(-1),
43   fNegMaxProbPdg(0),
44   fPosMaxProbPdg(0),
45   fNegMaxProbPid(0),
46   fPosMaxProbPid(0)
47 {
48   // Default constructor.
49
50   // Override from TEveElement.
51   fPickable = kTRUE;
52   fMainColorPtr = &fMarkerColor;
53 }
54
55 //______________________________________________________________________________
56 AliEveV0::AliEveV0(TEveRecTrack* tNeg, TEveRecTrack* tPos,
57                    TEveRecV0* v0, TEveTrackPropagator* rs) :
58   TEvePointSet(),
59
60   fRecBirthV(v0->fV0Birth),
61   fRecDecayV(v0->fVCa),
62   fRecDecayP(v0->fPNeg + v0->fPPos),
63
64   fNegTrack(new AliEveTrack(tNeg, rs)),
65   fPosTrack(new AliEveTrack(tPos, rs)),
66
67   fRnrStyle(rs),
68   fPointingLine(new TEveLine("Pointing line")),
69   fESDIndex(-1),
70   fOnFlyStatus(kFALSE),
71   fDaughterDCA(999),
72   fChi2V0(-1),
73   fNegMaxProbPdg(0),
74   fPosMaxProbPdg(0),
75   fNegMaxProbPid(0),
76   fPosMaxProbPid(0)
77 {
78   // Constructor with full V0 specification.
79
80   // Override from TEveElement.
81   fPickable = kTRUE;
82   fMainColorPtr = &fMarkerColor;
83
84   fMarkerStyle = 2;
85   fMarkerColor = kSpring + 6;
86   fMarkerSize  = 1;
87
88   fPointingLine->SetLineColor(fMarkerColor);
89   fPointingLine->SetLineWidth(2);
90   fPointingLine->IncDenyDestroy();
91   AddElement(fPointingLine);
92
93   fPosTrack->SetLineColor(2);  // red
94   fPosTrack->SetStdTitle();
95   fNegTrack->SetLineColor(7);  // light blue
96   fNegTrack->SetStdTitle();
97
98   fNegTrack->IncDenyDestroy();
99   AddElement(fNegTrack);
100   fPosTrack->IncDenyDestroy();
101   AddElement(fPosTrack);
102 }
103
104 //______________________________________________________________________________
105 AliEveV0::~AliEveV0()
106 {
107   // Destructor. Dereferences pos/neg tracks and pointing-line objects.
108
109   fNegTrack->DecDenyDestroy();
110   fPosTrack->DecDenyDestroy();
111   fPointingLine->DecDenyDestroy();
112 }
113
114 //______________________________________________________________________________
115 void AliEveV0::SetMaxProbPdgPid(Int_t iDaughter, Int_t rPdg, Float_t rPid)
116 {
117   // Sets the maximum probability Pdg value and Pid for one daughter
118   // Should be moved to AliEveTrack property eventually (or AliEveTrack creation)
119
120   if(iDaughter==0){
121     fNegMaxProbPdg = rPdg;
122     fNegMaxProbPid = rPid;
123   }
124   else if (iDaughter==1){
125     fPosMaxProbPdg = rPdg;
126     fPosMaxProbPid = rPid;
127   }
128
129 }
130 //______________________________________________________________________________
131 Float_t AliEveV0::GetInvMass(Int_t nPdgCode, Int_t pPdgCode) const
132 {
133   // Returns Invariant Mass assuming the masses of the daughter particles
134   TEveVector lNegMomentum = fNegTrack->GetMomentum();
135   // Does not work properly because momenta at the primary vertex !!!!!!!
136   TEveVector lPosMomentum = fPosTrack->GetMomentum();
137   Double_t nMass=TDatabasePDG::Instance()->GetParticle(nPdgCode)->Mass();
138   Double_t pMass=TDatabasePDG::Instance()->GetParticle(pPdgCode)->Mass();
139
140   printf("\n check the mass of the particle negative %.5f positive %.5f \n",nMass,pMass);
141
142   Double_t eNeg = TMath::Sqrt(nMass*nMass + lNegMomentum.Mag2());
143   Double_t ePos = TMath::Sqrt(pMass*pMass + lPosMomentum.Mag2());
144
145   return TMath::Sqrt( (eNeg+ePos)*(eNeg+ePos) - fRecDecayP.Mag2() );
146 }
147
148 //______________________________________________________________________________
149 void AliEveV0::MakeV0()
150 {
151   // Set all dependant components for drawing.
152
153   SetPoint(0, fRecDecayV.fX, fRecDecayV.fY, fRecDecayV.fZ);
154
155   fNegTrack->MakeTrack();
156   fPosTrack->MakeTrack();
157
158   fPointingLine->SetPoint(0, fRecBirthV.fX, fRecBirthV.fY, fRecBirthV.fZ);
159   fPointingLine->SetPoint(1, fRecDecayV.fX, fRecDecayV.fY, fRecDecayV.fZ);
160 }
161
162
163 //==============================================================================
164 //==============================================================================
165
166 //______________________________________________________________________________
167 //
168 // Container for AliEveV0s.
169 //
170 // Allows runtime selection by pT and DCA of daughters, radius of V0
171 // creation and PID priobabilities
172
173 ClassImp(AliEveV0List)
174
175 //______________________________________________________________________________
176 AliEveV0List::AliEveV0List() :
177   TEveElementList(),
178   fTitle(),
179   fRnrStyle(0),
180   fRnrDaughters(kTRUE),
181   fRnrV0vtx(kTRUE),
182   fRnrV0path(kTRUE),
183   fNegColor(0),
184   fPosColor(0),
185   fMinRCut(0),
186   fMaxRCut(250),
187   fMinDaughterDCA(0),
188   fMaxDaughterDCA(1),
189   fMinPt(0),
190   fMaxPt(20),
191   fNegCheckedPid(211),
192   fPosCheckedPid(211),
193   fNegCheckedProb(0.5),
194   fPosCheckedProb(0.5),
195   fMinInvariantMass(0),
196   fMaxInvariantMass(1.2)
197 {
198   // Default constructor.
199
200   fChildClass = AliEveV0::Class(); // override member from base TEveElementList
201 }
202
203 //______________________________________________________________________________
204 AliEveV0List::AliEveV0List(TEveTrackPropagator* rs) :
205   TEveElementList(),
206   fTitle(),
207   fRnrStyle(rs),
208   fRnrDaughters(kTRUE),
209   fRnrV0vtx(kTRUE),
210   fRnrV0path(kTRUE),
211   fNegColor(0),
212   fPosColor(0),
213   fMinRCut(0),
214   fMaxRCut(250),
215   fMinDaughterDCA(0),
216   fMaxDaughterDCA(1),
217   fMinPt(0),
218   fMaxPt(20),
219   fNegCheckedPid(211),
220   fPosCheckedPid(211),
221   fNegCheckedProb(0.5),
222   fPosCheckedProb(0.5),
223   fMinInvariantMass(0),
224   fMaxInvariantMass(1.2)
225 {
226   // Constructor with given track-propagator..
227
228   fChildClass = AliEveV0::Class(); // override member from base TEveElementList
229
230   Init();
231 }
232
233 //______________________________________________________________________________
234 AliEveV0List::AliEveV0List(const Text_t* name, TEveTrackPropagator* rs) :
235   TEveElementList(),
236   fTitle(),
237   fRnrStyle(rs),
238   fRnrDaughters(kTRUE),
239   fRnrV0vtx(kTRUE),
240   fRnrV0path(kTRUE),
241   fNegColor(0),
242   fPosColor(0),
243   fMinRCut(0),
244   fMaxRCut(100),
245   fMinDaughterDCA(0),
246   fMaxDaughterDCA(1),
247   fMinPt(0),
248   fMaxPt(20),
249   fNegCheckedPid(211),
250   fPosCheckedPid(211),
251   fNegCheckedProb(0.5),
252   fPosCheckedProb(0.5),
253   fMinInvariantMass(0),
254   fMaxInvariantMass(1.2)
255 {
256   // Standard constructor.
257
258   fChildClass = AliEveV0::Class(); // override member from base TEveElementList
259
260   Init();
261   SetName(name);
262 }
263
264 //______________________________________________________________________________
265 void AliEveV0List::Init()
266 {
267   // Initialize members needed for drawing operations.
268
269   if (fRnrStyle== 0) fRnrStyle = new TEveTrackPropagator;
270 }
271
272 /******************************************************************************/
273
274 //______________________________________________________________________________
275 void AliEveV0List::MakeV0s()
276 {
277   // Call MakeV0() for all elements.
278
279   for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
280     ((AliEveV0*)(*i))->MakeV0();
281   }
282   gEve->Redraw3D();
283 }
284
285 /******************************************************************************/
286
287 //______________________________________________________________________________
288 void AliEveV0List::FilterByRadius(Float_t minR, Float_t maxR)
289 {
290   // Select visibility of elements based on their axial radius.
291
292   fMinRCut = minR;
293   fMaxRCut = maxR;
294
295   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
296   {
297     AliEveV0* v0 = (AliEveV0*) *i;
298     Float_t  rad = v0->GetRadius();
299     Bool_t  show = rad >= fMinRCut && rad <= fMaxRCut;
300     v0->SetRnrState(show);
301   }
302   ElementChanged();
303   gEve->Redraw3D();
304 }
305
306 /******************************************************************************/
307
308 //______________________________________________________________________________
309 void AliEveV0List::FilterByDaughterDCA(Float_t minDaughterDCA, Float_t maxDaughterDCA)
310 {
311   // Select visibility of elements based on the DCA between daughters.
312
313   fMinDaughterDCA = minDaughterDCA;
314   fMaxDaughterDCA = maxDaughterDCA;
315
316   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
317   {
318     AliEveV0* v0 = (AliEveV0*) *i;
319     Float_t  dca = v0->GetDaughterDCA();
320     Bool_t  show = dca >= fMinDaughterDCA && dca <= fMaxDaughterDCA;
321     v0->SetRnrState(show);
322   }
323   ElementChanged();
324   gEve->Redraw3D();
325 }
326
327 /******************************************************************************/
328
329 //______________________________________________________________________________
330 void AliEveV0List::FilterByPt(Float_t minPt, Float_t maxPt)
331 {
332   // Select visibility of elements based on the V0 pt.
333
334   fMinPt = minPt;
335   fMaxPt = maxPt;
336
337   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
338   {
339     AliEveV0* v0 = (AliEveV0*) *i;
340     Float_t  pt = v0->GetPt();
341     Bool_t  show = pt >= fMinPt && pt <= fMaxPt;
342     v0->SetRnrState(show);
343   }
344   ElementChanged();
345   gEve->Redraw3D();
346 }
347
348 //______________________________________________________________________________
349 void AliEveV0List::FilterByCheckedPidMinProb(Int_t rFlag,Int_t rDaughter, Int_t rPid, Float_t rProb)
350 {
351   // Select visibility of elements based on one of the V0 daughters PID
352
353   if (!rDaughter){
354     fNegCheckedPid  = rPid;
355     fNegCheckedProb = rProb;
356   }
357   else {
358     fPosCheckedPid  = rPid;
359     fPosCheckedProb = rProb;
360   }
361
362   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
363   {
364     AliEveV0* v0 = (AliEveV0*) *i;
365     Int_t   pid = 0;
366     Float_t prob = 0.0;
367     Bool_t  show = 0;
368     if     (!rDaughter) {// Negative daughter checked
369       pid  = v0->GetNegMaxProbPdg();
370       prob = v0->GetNegMaxProbPid();
371       show = (pid == fNegCheckedPid && prob > fNegCheckedProb) || !rFlag ; 
372     }
373     else if (rDaughter) {// Positive daughter checked
374       pid = v0->GetPosMaxProbPdg();
375       prob = v0->GetPosMaxProbPid();
376       show = (pid == fPosCheckedPid && prob > fPosCheckedProb) || !rFlag ; 
377     }
378     v0->SetRnrState(show);
379   }
380   ElementChanged();
381   gEve->Redraw3D();
382 }
383
384 //______________________________________________________________________________
385 void AliEveV0List::FilterByInvariantMass(Float_t minInvariantMass, Float_t maxInvariantMass, Int_t nPdgCode, Int_t pPdgCode)
386 {
387   // Select visibility of elements based on the V0 invariant mass.
388
389   fMinInvariantMass = minInvariantMass;
390   fMaxInvariantMass = maxInvariantMass;
391
392   for(List_i i = fChildren.begin(); i != fChildren.end(); ++i)
393   {
394     AliEveV0* v0 = (AliEveV0*) *i;
395     Float_t  invMass = v0->GetInvMass(nPdgCode, pPdgCode);
396     Bool_t  show = invMass >= fMinInvariantMass && invMass <= fMaxInvariantMass;
397     v0->SetRnrState(show);
398   }
399   ElementChanged();
400   gEve->Redraw3D();
401 }