]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveLegoEditor.cxx
aec0041092b4fbd14889d05bd0f4fb3afc276573
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveLegoEditor.cxx
1 // $Id$
2 // Author: Stefano Carrazza 2010, CERN, stefano.carrazza@cern.ch
3
4 /**************************************************************************
5  * Copyright(c) 1998-2009, 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 "AliEveLego.h"
11 #include "AliEveLegoEditor.h"
12
13 #include "TColor.h"
14 #include "TGButton.h"
15 #include "TGButtonGroup.h"
16 #include "TGColorSelect.h"
17 #include "TGComboBox.h"
18 #include "TGDoubleSlider.h"
19 #include "TGFrame.h"
20 #include "TGLabel.h"
21 #include "TGNumberEntry.h"
22 #include "TGString.h"
23 #include "TVirtualPad.h"
24
25 //______________________________________________________________________________
26 // This is the GUI editor for AliEveLego.
27 //
28
29 ClassImp(AliEveLegoEditor)
30
31 //______________________________________________________________________________
32 AliEveLegoEditor::AliEveLegoEditor(const TGWindow *p, Int_t width, Int_t height,
33              UInt_t options, Pixel_t back) :
34   TGedFrame(p, width, height, options | kVerticalFrame, back),
35   fM(0),
36   fAllEventsButton(0),
37   fParticlesBG(0),
38   fTrackSelection(0),
39   fPosCharged(0),
40   fNegCharged(0),
41   fElectrons(0),
42   fMuons(0),
43   fPions(0),
44   fKaons(0),
45   fProtons(0),
46   fLabel(0),
47   fLabel1(0),
48   fThreshold(0),
49   fMaxPt(0),
50   fSelect(0),
51   fParticlesBGAE(0),  
52   fTrackSelectionAE(0),
53   fPosChargedAE(0),
54   fNegChargedAE(0),
55   fElectronsAE(0),
56   fMuonsAE(0),
57   fPionsAE(0),
58   fKaonsAE(0),
59   fProtonsAE(0),
60   fApplyChanges(0),
61   fLabelAE(0),
62   fLabel1AE(0),
63   fThresholdAE(0),
64   fMaxPtAE(0),
65   fEventControl(0),
66   fIsMC(kFALSE),
67   fCollisionCandidatesOnly(0)
68 {
69   // Constructor.
70   MakeTitle("AliEveLego");
71
72   // Create widgets
73
74   //------ AllEventsButton ------
75   fAllEventsButton = new TGTextButton(this, "Create lego of all events");
76   AddFrame(fAllEventsButton, new TGLayoutHints(kLHintsExpandX));
77   fAllEventsButton->Connect("Clicked()", "AliEveLegoEditor", this, "DoAllEvents()");
78
79   //------ Particle Selection ------
80   fParticlesBG = new TGGroupFrame(this, "Particle selection:", kVerticalFrame);
81   fPosCharged  = new TGCheckButton(fParticlesBG, new TGHotString("&Positive charged"));
82   fNegCharged  = new TGCheckButton(fParticlesBG, new TGHotString("&Negative charged"));
83   fElectrons   = new TGCheckButton(fParticlesBG, new TGHotString("&Electrons"));
84   fMuons       = new TGCheckButton(fParticlesBG, new TGHotString("&Muons"));
85   fPions       = new TGCheckButton(fParticlesBG, new TGHotString("&Pions"));
86   fKaons       = new TGCheckButton(fParticlesBG, new TGHotString("&Kaons"));
87   fProtons     = new TGCheckButton(fParticlesBG, new TGHotString("&Protons"));
88
89   fPosCharged->SetState(kButtonDown);
90   fNegCharged->SetState(kButtonDown);
91   fElectrons->SetState(kButtonUp);
92   fMuons->SetState(kButtonUp);
93   fPions->SetState(kButtonUp);
94   fKaons->SetState(kButtonUp);
95   fProtons->SetState(kButtonUp);
96
97   fPosCharged->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPosCharge()");
98   fNegCharged->Connect("Clicked()", "AliEveLegoEditor", this, "ShowNegCharge()");
99   fElectrons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowElectrons()");
100   fMuons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowMuons()");
101   fPions->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPions()");
102   fKaons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowKaons()");
103   fProtons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowProtons()");
104
105   fParticlesBG->AddFrame(fPosCharged, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
106   fParticlesBG->AddFrame(fNegCharged, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
107   fParticlesBG->AddFrame(fElectrons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
108   fParticlesBG->AddFrame(fMuons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
109   fParticlesBG->AddFrame(fPions, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
110   fParticlesBG->AddFrame(fKaons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
111   fParticlesBG->AddFrame(fProtons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
112   fParticlesBG->SetLayoutManager(new TGVerticalLayout(fParticlesBG));
113
114   AddFrame(fParticlesBG, new TGLayoutHints(kLHintsExpandX));
115
116   //------ Track selection ------
117   fTrackSelection = new TGButtonGroup(this, "Track selection:", kHorizontalFrame);
118   fRtracks[0] = new TGRadioButton(fTrackSelection, new TGHotString("&All tracks  "));
119   fRtracks[1] = new TGRadioButton(fTrackSelection, new TGHotString("&Primary tracks"));
120   fRtracks[0]->SetState(kButtonDown);
121   AddFrame(fTrackSelection, new TGLayoutHints(kLHintsExpandX));
122   fTrackSelection->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByTracks(Int_t)");
123
124   //------ Track threshold ------
125   TGHorizontalFrame *horz = new TGHorizontalFrame(this);
126   AddFrame(horz, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
127   fLabel = new TGLabel(horz, "Tracks maximum Pt (GeV): ");
128   horz->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
129
130   fMaxPt = new TGNumberEntry(horz, 10000, 7, -1,
131                                  TGNumberFormat::kNESRealOne,
132                                  TGNumberFormat::kNEANonNegative,
133                                  TGNumberFormat::kNELLimitMinMax,
134                                  0, 10000);
135
136   fMaxPt->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPt()");
137
138   horz->AddFrame( fMaxPt, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
139
140   TGHorizontalFrame *horz1 = new TGHorizontalFrame(this);
141   AddFrame(horz1, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
142   fLabel1 = new TGLabel(horz1, "Tracks threshold (GeV): ");
143   horz1->AddFrame(fLabel1, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
144
145   fThreshold = new TGNumberEntry(horz1, 0, 7, -1,
146                                  TGNumberFormat::kNESRealOne,
147                                  TGNumberFormat::kNEANonNegative,
148                                  TGNumberFormat::kNELLimitMinMax,
149                                  0, 10000);
150
151   fThreshold->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThreshold()");
152   horz1->AddFrame( fThreshold, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
153
154
155 }
156
157 //______________________________________________________________________________
158 void AliEveLegoEditor::SetModel(TObject* obj)
159 {
160   // Calls the associated AliEveLego object
161   fM = dynamic_cast<AliEveLego*>(obj);
162 }
163
164 //______________________________________________________________________________
165 void AliEveLegoEditor::DoAllEvents()
166 {
167   // Creates the all events editor
168   fAllEventsButton->SetEnabled(kFALSE);
169   CreateAllEventsEditor();
170   fM->LoadAllEvents();
171 }
172
173 //______________________________________________________________________________
174 void AliEveLegoEditor::ShowPosCharge()
175 {   
176   // Send particle type to main class
177   fM->SetParticleType(0, fPosCharged->IsOn());
178 }
179
180 //______________________________________________________________________________
181 void AliEveLegoEditor::ShowNegCharge()
182 {
183   // Send particle type to main class
184   fM->SetParticleType(1, fNegCharged->IsOn());
185 }
186
187 //______________________________________________________________________________
188 void AliEveLegoEditor::ShowElectrons()
189 {
190   // Send particle type to main class
191   fM->SetParticleType(2, fElectrons->IsOn());
192 }
193
194 //______________________________________________________________________________
195 void AliEveLegoEditor::ShowMuons()
196 {
197   // Send particle type to main class
198   fM->SetParticleType(3, fMuons->IsOn());
199 }
200
201 //______________________________________________________________________________
202 void AliEveLegoEditor::ShowPions()
203 {
204   // Send particle type to main class
205   fM->SetParticleType(4, fPions->IsOn());
206 }
207
208 //______________________________________________________________________________
209 void AliEveLegoEditor::ShowKaons()
210 {
211   // Send particle type to main class
212   fM->SetParticleType(5, fKaons->IsOn());
213 }
214
215 //______________________________________________________________________________
216 void AliEveLegoEditor::ShowProtons()
217 {
218   // Send particle type to main class
219   fM->SetParticleType(6, fProtons->IsOn());
220 }
221
222 //______________________________________________________________________________
223 void AliEveLegoEditor::ShowPosChargeAE()
224 {
225   // Send particle type to main class
226   fM->SetParticleTypeAE(0, fPosChargedAE->IsOn());
227 }
228
229 //______________________________________________________________________________
230 void AliEveLegoEditor::ShowNegChargeAE()
231 {
232   // Send particle type to main class
233   fM->SetParticleTypeAE(1, fNegChargedAE->IsOn());
234 }
235
236 //______________________________________________________________________________
237 void AliEveLegoEditor::ShowElectronsAE()
238 {
239   // Send particle type to main class
240   fM->SetParticleTypeAE(2, fElectronsAE->IsOn());
241 }
242
243 //______________________________________________________________________________
244 void AliEveLegoEditor::ShowMuonsAE()
245 {
246   // Send particle type to main class
247   fM->SetParticleTypeAE(3, fMuonsAE->IsOn());
248 }
249
250 //______________________________________________________________________________
251 void AliEveLegoEditor::ShowPionsAE()
252 {
253   // Send particle type to main class
254   fM->SetParticleTypeAE(4, fPionsAE->IsOn());
255 }
256
257 //______________________________________________________________________________
258 void AliEveLegoEditor::ShowKaonsAE()
259 {
260   // Send particle type to main class
261   fM->SetParticleTypeAE(5, fKaonsAE->IsOn());
262 }
263
264 //______________________________________________________________________________
265 void AliEveLegoEditor::ShowProtonsAE()
266 {
267   // Send particle type to main class
268   fM->SetParticleTypeAE(6, fProtonsAE->IsOn());
269 }
270
271 //______________________________________________________________________________
272 void AliEveLegoEditor::SetMaxPt()
273 {
274   // Send particle type to main class
275   fM->SetMaxPt(fMaxPt->GetNumber());
276 }
277
278 //______________________________________________________________________________
279 void AliEveLegoEditor::SetMaxPtAE()
280 {
281   // Send particle type to main class
282   fM->SetMaxPtAE(fMaxPtAE->GetNumber());
283 }
284
285 //______________________________________________________________________________
286 void AliEveLegoEditor::SetThreshold()
287 {
288   // Send particle type to main class
289   fM->SetThreshold(fThreshold->GetNumber());
290 }
291
292 //______________________________________________________________________________
293 void AliEveLegoEditor::SetThresholdAE()
294 {
295   // Send particle type to main class
296   fM->SetThresholdAE(fThresholdAE->GetNumber());
297 }
298
299 //______________________________________________________________________________
300 void AliEveLegoEditor::ShowByTracks(Int_t id)
301 {
302   // Send particle type to main class
303   fM->SetTracks(id);
304 }
305
306 //______________________________________________________________________________
307 void AliEveLegoEditor::ShowByTracksAE(Int_t id)
308 {
309   // Send particle type to main class
310   fM->SetTracksAE(id);
311 }
312
313 //______________________________________________________________________________
314 void AliEveLegoEditor::CreateAllEventsEditor()
315 {
316    // Create the GUI of all events
317    TGVerticalFrame *this2 = this->CreateEditorTabSubFrame("All events style");
318
319    //------ Event control ------
320    fEventControl = new TGButtonGroup(this2, "Event control:", kVerticalFrame);
321    fIsMC = new TGCheckButton(fEventControl, new TGHotString("&Data is from simulation (MC)"));
322    fCollisionCandidatesOnly = new TGCheckButton(fEventControl, new TGHotString("&Only collision candidates events"));
323
324    //------ Simulation checkbox ------
325    fIsMC->SetState(kButtonUp);
326    fCollisionCandidatesOnly->SetState(kButtonUp);
327    fIsMC->Connect("Clicked()", "AliEveLegoEditor", this, "DataIsMC()");
328    fCollisionCandidatesOnly->Connect("Clicked()", "AliEveLegoEditor", this, "CollisionCandidatesOnly()");
329    this2->AddFrame(fEventControl, new TGLayoutHints(kLHintsExpandX));
330
331    //------ Particle selection ------
332    fParticlesBGAE = new TGButtonGroup(this2, "Particle selection:", kVerticalFrame);
333    fPosChargedAE  = new TGCheckButton(fParticlesBGAE, new TGHotString("&Positive charged"));
334    fNegChargedAE  = new TGCheckButton(fParticlesBGAE, new TGHotString("&Negative charged"));
335    fElectronsAE   = new TGCheckButton(fParticlesBGAE, new TGHotString("&Electrons"));
336    fMuonsAE       = new TGCheckButton(fParticlesBGAE, new TGHotString("&Muons"));
337    fPionsAE       = new TGCheckButton(fParticlesBGAE, new TGHotString("&Pions"));
338    fKaonsAE       = new TGCheckButton(fParticlesBGAE, new TGHotString("&Kaons"));
339    fProtonsAE     = new TGCheckButton(fParticlesBGAE, new TGHotString("&Protons"));
340
341    fPosChargedAE->SetState(kButtonDown);
342    fNegChargedAE->SetState(kButtonDown);
343    fElectronsAE->SetState(kButtonUp);
344    fMuonsAE->SetState(kButtonUp);
345    fPionsAE->SetState(kButtonUp);
346    fKaonsAE->SetState(kButtonUp);
347    fProtonsAE->SetState(kButtonUp);
348
349    fPosChargedAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPosChargeAE()");
350    fNegChargedAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowNegChargeAE()");
351    fElectronsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowElectronsAE()");
352    fMuonsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowMuonsAE()");
353    fPionsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPionsAE()");
354    fKaonsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowKaonsAE()");
355    fProtonsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowProtonsAE()");
356
357    this2->AddFrame(fParticlesBGAE, new TGLayoutHints(kLHintsExpandX));
358
359    //------ Apply particle selection criteria ------
360    fApplyChanges = new TGTextButton(this2, "Apply particle selection");
361    fApplyChanges->Connect("Clicked()", "AliEveLegoEditor", this, "ApplyChanges()");
362    this2->AddFrame(fApplyChanges, new TGLayoutHints(kLHintsExpandX));
363
364    //------ Track selection ------
365    fTrackSelectionAE = new TGButtonGroup(this2, "Track selection:", kHorizontalFrame);
366    fRtracksAE[0] = new TGRadioButton(fTrackSelectionAE, new TGHotString("&All tracks  "));
367    fRtracksAE[1] = new TGRadioButton(fTrackSelectionAE, new TGHotString("&Primary tracks"));
368    fRtracksAE[0]->SetState(kButtonDown);   
369    fTrackSelectionAE->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByTracksAE(Int_t)");
370    this2->AddFrame(fTrackSelectionAE, new TGLayoutHints(kLHintsExpandX));
371
372    //------ Threshold setup ------
373    TGHorizontalFrame *horzAE = new TGHorizontalFrame(this2);
374
375    fLabelAE = new TGLabel(horzAE, "Tracks maximum Pt (GeV): ");
376    horzAE->AddFrame(fLabelAE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
377
378    fMaxPtAE = new TGNumberEntry(horzAE, 10000, 7, -1,
379                                   TGNumberFormat::kNESRealOne,
380                                   TGNumberFormat::kNEANonNegative,
381                                   TGNumberFormat::kNELLimitMinMax,
382                                   0, 10000);
383
384    fMaxPtAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPtAE()");
385
386    horzAE->AddFrame( fMaxPtAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
387    this2->AddFrame(horzAE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
388
389    TGHorizontalFrame *horz1AE = new TGHorizontalFrame(this2);
390
391    fLabel1AE = new TGLabel(horz1AE, "Tracks threshold (GeV): ");
392    horz1AE->AddFrame(fLabel1AE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
393
394    fThresholdAE = new TGNumberEntry(horz1AE, 0, 7, -1,
395                                   TGNumberFormat::kNESRealOne,
396                                   TGNumberFormat::kNEANonNegative,
397                                   TGNumberFormat::kNELLimitMinMax,
398                                   0, 10000);
399
400    fThresholdAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThresholdAE()");
401    horz1AE->AddFrame( fThresholdAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
402
403    this2->AddFrame(horz1AE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
404 }
405
406 //______________________________________________________________________________
407 void AliEveLegoEditor::ApplyChanges()
408 {
409   // Apply particle selection for all events
410   fM->ApplyParticleTypeSelectionAE();
411 }
412
413 //______________________________________________________________________________
414 void AliEveLegoEditor::DataIsMC()
415 {
416   // Set data type
417   fM->SwitchDataType(fIsMC->IsOn());
418 }
419
420 //______________________________________________________________________________
421 void AliEveLegoEditor::CollisionCandidatesOnly()
422 {
423   // Activate collision candidates only
424   fM->SetCollisionCandidatesOnly();
425 }