Fix enums as reported by coverity
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveV0.cxx
CommitLineData
b594a020 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
b594a020 10#include "AliEveV0.h"
11
b594a020 12#include <TEveTrackPropagator.h>
13#include <TEveManager.h>
14
15#include <TPolyLine3D.h>
b594a020 16#include <TColor.h>
17
d4dbbb43 18#include <TDatabasePDG.h>
19#include <TParticlePDG.h>
20
b594a020 21#include <vector>
22
ea47a1d6 23//______________________________________________________________________________
24// Representation of a reconstructed V0.
b594a020 25
26ClassImp(AliEveV0)
27
e6e8b28b 28//______________________________________________________________________________
b594a020 29AliEveV0::AliEveV0() :
30 TEvePointSet(),
31
32 fRecBirthV(),
33 fRecDecayV(),
34 fRecDecayP(),
35 fNegTrack(0),
36 fPosTrack(0),
37 fRnrStyle(0),
e6e8b28b 38 fPointingLine(0),
b594a020 39 fESDIndex(-1),
ca8a6926 40 fOnFlyStatus(kFALSE),
b594a020 41 fDaughterDCA(999),
2c7d7ac0 42 fChi2V0(-1),
43 fNegMaxProbPdg(0),
44 fPosMaxProbPdg(0),
45 fNegMaxProbPid(0),
46 fPosMaxProbPid(0)
ca8a6926 47{
48 // Default constructor.
b594a020 49
ca8a6926 50 // Override from TEveElement.
51 fPickable = kTRUE;
e6e8b28b 52 fMainColorPtr = &fMarkerColor;
ca8a6926 53}
b594a020 54
e6e8b28b 55//______________________________________________________________________________
b594a020 56AliEveV0::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
0e33c639 64 fNegTrack(new AliEveTrack(tNeg, rs)),
65 fPosTrack(new AliEveTrack(tPos, rs)),
b594a020 66
67 fRnrStyle(rs),
e6e8b28b 68 fPointingLine(new TEveLine("Pointing line")),
b594a020 69 fESDIndex(-1),
ca8a6926 70 fOnFlyStatus(kFALSE),
b594a020 71 fDaughterDCA(999),
2c7d7ac0 72 fChi2V0(-1),
73 fNegMaxProbPdg(0),
74 fPosMaxProbPdg(0),
75 fNegMaxProbPid(0),
76 fPosMaxProbPid(0)
b594a020 77{
e6e8b28b 78 // Constructor with full V0 specification.
79
ca8a6926 80 // Override from TEveElement.
81 fPickable = kTRUE;
e6e8b28b 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);
ca8a6926 92
b594a020 93 fPosTrack->SetLineColor(2); // red
e6e8b28b 94 fPosTrack->SetStdTitle();
b594a020 95 fNegTrack->SetLineColor(7); // light blue
e6e8b28b 96 fNegTrack->SetStdTitle();
b594a020 97
e6e8b28b 98 fNegTrack->IncDenyDestroy();
b594a020 99 AddElement(fNegTrack);
e6e8b28b 100 fPosTrack->IncDenyDestroy();
b594a020 101 AddElement(fPosTrack);
102}
103
e6e8b28b 104//______________________________________________________________________________
b594a020 105AliEveV0::~AliEveV0()
b594a020 106{
e6e8b28b 107 // Destructor. Dereferences pos/neg tracks and pointing-line objects.
b594a020 108
e6e8b28b 109 fNegTrack->DecDenyDestroy();
110 fPosTrack->DecDenyDestroy();
111 fPointingLine->DecDenyDestroy();
b594a020 112}
113
b594a020 114//______________________________________________________________________________
2c7d7ac0 115void AliEveV0::SetMaxProbPdgPid(Int_t iDaughter, Int_t rPdg, Float_t rPid)
116{
117 // Sets the maximum probability Pdg value and Pid for one daughter
0e33c639 118 // Should be moved to AliEveTrack property eventually (or AliEveTrack creation)
2c7d7ac0 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//______________________________________________________________________________
131Float_t AliEveV0::GetInvMass(Int_t nPdgCode, Int_t pPdgCode) const
d4dbbb43 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//______________________________________________________________________________
b594a020 149void AliEveV0::MakeV0()
150{
e6e8b28b 151 // Set all dependant components for drawing.
152
b594a020 153 SetPoint(0, fRecDecayV.fX, fRecDecayV.fY, fRecDecayV.fZ);
154
155 fNegTrack->MakeTrack();
156 fPosTrack->MakeTrack();
e6e8b28b 157
158 fPointingLine->SetPoint(0, fRecBirthV.fX, fRecBirthV.fY, fRecBirthV.fZ);
159 fPointingLine->SetPoint(1, fRecDecayV.fX, fRecDecayV.fY, fRecDecayV.fZ);
b594a020 160}
161
162
ea47a1d6 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
b594a020 172
173ClassImp(AliEveV0List)
174
175//______________________________________________________________________________
176AliEveV0List::AliEveV0List() :
177 TEveElementList(),
178 fTitle(),
179 fRnrStyle(0),
180 fRnrDaughters(kTRUE),
181 fRnrV0vtx(kTRUE),
182 fRnrV0path(kTRUE),
183 fNegColor(0),
ca8a6926 184 fPosColor(0),
185 fMinRCut(0),
e1bb28b4 186 fMaxRCut(250),
187 fMinDaughterDCA(0),
188 fMaxDaughterDCA(1),
189 fMinPt(0),
2c7d7ac0 190 fMaxPt(20),
191 fNegCheckedPid(211),
192 fPosCheckedPid(211),
193 fNegCheckedProb(0.5),
194 fPosCheckedProb(0.5),
195 fMinInvariantMass(0),
196 fMaxInvariantMass(1.2)
b594a020 197{
e6e8b28b 198 // Default constructor.
199
b594a020 200 fChildClass = AliEveV0::Class(); // override member from base TEveElementList
201}
202
203//______________________________________________________________________________
204AliEveV0List::AliEveV0List(TEveTrackPropagator* rs) :
205 TEveElementList(),
206 fTitle(),
207 fRnrStyle(rs),
208 fRnrDaughters(kTRUE),
209 fRnrV0vtx(kTRUE),
210 fRnrV0path(kTRUE),
211 fNegColor(0),
ca8a6926 212 fPosColor(0),
213 fMinRCut(0),
e1bb28b4 214 fMaxRCut(250),
215 fMinDaughterDCA(0),
216 fMaxDaughterDCA(1),
217 fMinPt(0),
2c7d7ac0 218 fMaxPt(20),
219 fNegCheckedPid(211),
220 fPosCheckedPid(211),
221 fNegCheckedProb(0.5),
222 fPosCheckedProb(0.5),
223 fMinInvariantMass(0),
224 fMaxInvariantMass(1.2)
b594a020 225{
e6e8b28b 226 // Constructor with given track-propagator..
227
b594a020 228 fChildClass = AliEveV0::Class(); // override member from base TEveElementList
229
230 Init();
231}
232
233//______________________________________________________________________________
234AliEveV0List::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),
ca8a6926 242 fPosColor(0),
243 fMinRCut(0),
e1bb28b4 244 fMaxRCut(100),
245 fMinDaughterDCA(0),
246 fMaxDaughterDCA(1),
247 fMinPt(0),
2c7d7ac0 248 fMaxPt(20),
249 fNegCheckedPid(211),
250 fPosCheckedPid(211),
251 fNegCheckedProb(0.5),
252 fPosCheckedProb(0.5),
253 fMinInvariantMass(0),
254 fMaxInvariantMass(1.2)
b594a020 255{
e6e8b28b 256 // Standard constructor.
257
b594a020 258 fChildClass = AliEveV0::Class(); // override member from base TEveElementList
259
260 Init();
261 SetName(name);
262}
263
264//______________________________________________________________________________
265void AliEveV0List::Init()
266{
e6e8b28b 267 // Initialize members needed for drawing operations.
b594a020 268
e6e8b28b 269 if (fRnrStyle== 0) fRnrStyle = new TEveTrackPropagator;
b594a020 270}
271
ca8a6926 272/******************************************************************************/
b594a020 273
e6e8b28b 274//______________________________________________________________________________
b594a020 275void AliEveV0List::MakeV0s()
276{
e6e8b28b 277 // Call MakeV0() for all elements.
278
b594a020 279 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
280 ((AliEveV0*)(*i))->MakeV0();
281 }
282 gEve->Redraw3D();
283}
284
ca8a6926 285/******************************************************************************/
286
e6e8b28b 287//______________________________________________________________________________
ca8a6926 288void AliEveV0List::FilterByRadius(Float_t minR, Float_t maxR)
289{
e6e8b28b 290 // Select visibility of elements based on their axial radius.
291
ca8a6926 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}
e1bb28b4 305
306/******************************************************************************/
307
308//______________________________________________________________________________
309void 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//______________________________________________________________________________
330void 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}
2c7d7ac0 347
348//______________________________________________________________________________
349void AliEveV0List::FilterByCheckedPidMinProb(Int_t rFlag,Int_t rDaughter, Int_t rPid, Float_t rProb)
350{
ea47a1d6 351 // Select visibility of elements based on one of the V0 daughters PID
2c7d7ac0 352
353 if (!rDaughter){
354 fNegCheckedPid = rPid;
355 fNegCheckedProb = rProb;
356 }
357 else {
358 fPosCheckedPid = rPid;
359 fPosCheckedProb = rProb;
360 }
361
2c7d7ac0 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//______________________________________________________________________________
385void 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}