Avoid jumping of entries in data-selector window -- restore scrollbar position after...
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveKinkListEditor.cxx
CommitLineData
4711ad43 1// $Id$
2// Author: Paraskevi Ganoti: 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#include "AliEveKinkListEditor.h"
11#include "AliEveKink.h"
12
13#include "TEveGValuators.h"
14
15#include "TVirtualPad.h"
16#include "TColor.h"
17
18// Cleanup these includes:
19#include "TGLabel.h"
20#include "TGButton.h"
21#include "TGNumberEntry.h"
22#include "TGColorSelect.h"
23#include "TGDoubleSlider.h"
24#include "TGComboBox.h"
25#include "TGLabel.h"
26
27//______________________________________________________________________________
28// GUI editor for AliEveKinkList.
29//
30
31ClassImp(AliEveKinkListEditor)
32
33//______________________________________________________________________________
34AliEveKinkListEditor::AliEveKinkListEditor(const TGWindow *p, Int_t width, Int_t height,
35 UInt_t options, Pixel_t back) :
36 TGedFrame(p, width, height, options | kVerticalFrame, back),
37 fM(0),
38 fMinMaxRCut(0),
39 fMinMaxKinkAngleCut (0),
40 fMinMaxPt(0),
41 fMinMaxInvariantMass(0),
42 fDaughterSpecies(0),
43 fDaughterCheckMaxPidProbability(0),
44 fDaughterLevelPidProbability(0)
45{
46 // Constructor.
47
48 MakeTitle("AliEveKinkList");
49
50 fMinMaxRCut = new TEveGDoubleValuator(this,"Radius:", 130, 0);
51 fMinMaxRCut->SetNELength(5);
52 fMinMaxRCut->SetLabelWidth(74);
53 fMinMaxRCut->Build();
54 fMinMaxRCut->GetSlider()->SetWidth(200);
55 fMinMaxRCut->SetLimits(0, 250, TGNumberFormat::kNESRealOne);
56 fMinMaxRCut->Connect("ValueSet()", "AliEveKinkListEditor", this, "DoMinMaxRCut()");
57 AddFrame(fMinMaxRCut, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
58
59 fMinMaxKinkAngleCut = new TEveGDoubleValuator(this,"Kink Angle:", 130, 0);
60 fMinMaxKinkAngleCut->SetNELength(5);
61 fMinMaxKinkAngleCut->SetLabelWidth(74);
62 fMinMaxKinkAngleCut->Build();
63 fMinMaxKinkAngleCut->GetSlider()->SetWidth(200);
64 fMinMaxKinkAngleCut->SetLimits(0, 280, TGNumberFormat::kNESRealOne);
65 fMinMaxKinkAngleCut->Connect("ValueSet()", "AliEveKinkListEditor", this, "DoMinMaxKinkAngleCut()");
66 AddFrame(fMinMaxKinkAngleCut, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
67
68 fMinMaxPt = new TEveGDoubleValuator(this,"pT:", 80, 0);
69 fMinMaxPt->SetNELength(5);
70 fMinMaxPt->SetLabelWidth(74);
71 fMinMaxPt->Build();
72 fMinMaxPt->GetSlider()->SetWidth(200);
73 fMinMaxPt->SetLimits(0, 20, TGNumberFormat::kNESRealOne);
74 fMinMaxPt->Connect("ValueSet()", "AliEveKinkListEditor", this, "DoMinMaxPt()");
75 AddFrame(fMinMaxPt, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
76
77 fMinMaxInvariantMass = new TEveGDoubleValuator(this,"Inv. Mass:", 80, 0);
78 fMinMaxInvariantMass->SetNELength(5);
79 fMinMaxInvariantMass->SetLabelWidth(74);
80 fMinMaxInvariantMass->Build();
81 fMinMaxInvariantMass->GetSlider()->SetWidth(200);
82 fMinMaxInvariantMass->SetLimits(0, 1.0, TGNumberFormat::kNESRealThree);
83 fMinMaxInvariantMass->Connect("ValueSet()", "AliEveKinkListEditor", this, "DoMinMaxInvariantMass()");
84 AddFrame(fMinMaxInvariantMass, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
85
86 TGHorizontalFrame* fDaugFrame = new TGHorizontalFrame(this);
87 TGLabel* labDaug = new TGLabel(fDaugFrame, "Daug:");
88 fDaugFrame->AddFrame(labDaug, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1));
89 fDaughterSpecies = new TGComboBox(fDaugFrame);
90 fDaughterSpecies->AddEntry("e", 11);
91 fDaughterSpecies->AddEntry("mu", 13);
92 fDaughterSpecies->AddEntry("pi", 211);
93 TGListBox* lbaug = fDaughterSpecies->GetListBox();
94 lbaug->Resize(lbaug->GetWidth(), 2*18);
95 fDaughterSpecies->Resize(45, 20);
96 fDaughterSpecies->Connect("Selected(Int_t)", "AliEveKinkListEditor", this, "DoSelectDaugPid(Int_t)");
97 fDaugFrame->AddFrame(fDaughterSpecies, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
98 AddFrame(fDaugFrame);
99
100 fDaughterCheckMaxPidProbability = new TGCheckButton(fDaugFrame, "Check");
101 fDaugFrame->AddFrame(fDaughterCheckMaxPidProbability, new TGLayoutHints(kLHintsLeft, 0, 2, 1, 1));
102 fDaughterCheckMaxPidProbability->Connect("Toggled(Bool_t)", "AliEveKinkListEditor", this, "DoCheckDaugPid()");
103
104 fDaughterLevelPidProbability = new TGNumberEntry(fDaugFrame, 0.5, 3, -1, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative,TGNumberFormat::kNELLimitMinMax, 0, 1);
105 fDaughterLevelPidProbability->Resize(50,20);
106 fDaughterLevelPidProbability->Connect("ValueSet(Long_t)", "AliEveKinkListEditor", this, "DoSelectDaugProb()");
107 fDaugFrame->AddFrame(fDaughterLevelPidProbability, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 1, 1));
108}
109
110/******************************************************************************/
111
112//______________________________________________________________________________
113void AliEveKinkListEditor::SetModel(TObject* obj)
114{
115 // Set model object.
116
117 fM = dynamic_cast<AliEveKinkList*>(obj);
118
119 // Set values of widgets
120 // fXYZZ->SetValue(fM->GetXYZZ());
121
122 fMinMaxRCut->SetValues(fM->fMinRCut, fM->fMaxRCut);
123 fMinMaxKinkAngleCut->SetValues(fM->fMinKinkAngle, fM->fMaxKinkAngle);
124 fMinMaxPt->SetValues(fM->fMinPt, fM->fMaxPt);
125 fMinMaxInvariantMass->SetValues(fM->fMinInvariantMass, fM->fMaxInvariantMass);
126}
127
128/******************************************************************************/
129
130// Implements callback/slot methods
131
132//______________________________________________________________________________
133
134void AliEveKinkListEditor::DoMinMaxRCut()
135{
136 fM->FilterByRadius(fMinMaxRCut->GetMin(), fMinMaxRCut->GetMax());
137}
138
139void AliEveKinkListEditor::DoMinMaxKinkAngleCut()
140{
141 fM->FilterByKinkAngle(fMinMaxRCut->GetMin(), fMinMaxRCut->GetMax());
142}
143
144void AliEveKinkListEditor::DoMinMaxPt()
145{
146 fM->FilterByPt(fMinMaxPt->GetMin(), fMinMaxPt->GetMax());
147}
148
149void AliEveKinkListEditor::DoMinMaxInvariantMass()
150{
151 fM->FilterByInvariantMass(fMinMaxInvariantMass->GetMin(), fMinMaxInvariantMass->GetMax(),13);
152}
153
154void AliEveKinkListEditor::DoSelectDaugPid(Int_t rDaugPid)
155{
156 fM->SetDaugCheckedPid(rDaugPid);
157 Update();
158}
159
160void AliEveKinkListEditor::DoCheckDaugPid()
161{
162 Int_t lDaugPid = fM->GetDaugCheckedPid();
163 Float_t lDaugProb = fM->GetDaugCheckedProb();
164 if (lDaugPid) {
165 fM->FilterByCheckedPidMinProb(fDaughterCheckMaxPidProbability->IsOn(),lDaugPid,lDaugProb);
166 printf("Selection for daughter pid %d prob %.2f \n",lDaugPid,lDaugProb);
167 Update();
168 }
169}
170
171void AliEveKinkListEditor::DoSelectDaugProb()
172{
173 Float_t rMinDaugProb = (Float_t)fDaughterLevelPidProbability->GetNumber();
174 fM->SetDaugCheckedProb(rMinDaugProb);
175 Update();
176}