2 // Author: Stefano Carrazza 2010
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 **************************************************************************/
10 #include "AliEveLegoEditor.h"
11 #include "AliEveLego.h"
13 #include "TVirtualPad.h"
18 #include "TGNumberEntry.h"
19 #include "TGColorSelect.h"
20 #include "TGDoubleSlider.h"
21 #include "TGButtonGroup.h"
23 #include "TGComboBox.h"
26 //______________________________________________________________________________
27 // GUI editor for AliEveLego.
30 ClassImp(AliEveLegoEditor)
32 //______________________________________________________________________________
33 AliEveLegoEditor::AliEveLegoEditor(const TGWindow *p, Int_t width, Int_t height,
34 UInt_t options, Pixel_t back) :
35 TGedFrame(p, width, height, options | kVerticalFrame, back),
68 fCollisionCandidatesOnly(0)
71 MakeTitle("AliEveLego");
74 fAllEventsButton = new TGTextButton(this, "Create lego of all events");
75 AddFrame(fAllEventsButton, new TGLayoutHints(kLHintsExpandX));
76 fAllEventsButton->Connect("Clicked()", "AliEveLegoEditor", this, "DoAllEvents()");
78 fParticlesBG = new TGGroupFrame(this, "Particle selection:", kVerticalFrame);
79 fPosCharged = new TGCheckButton(fParticlesBG, new TGHotString("&Positive charged"));
80 fNegCharged = new TGCheckButton(fParticlesBG, new TGHotString("&Negative charged"));
81 fElectrons = new TGCheckButton(fParticlesBG, new TGHotString("&Electrons"));
82 fMuons = new TGCheckButton(fParticlesBG, new TGHotString("&Muons"));
83 fPions = new TGCheckButton(fParticlesBG, new TGHotString("&Pions"));
84 fKaons = new TGCheckButton(fParticlesBG, new TGHotString("&Kaons"));
85 fProtons = new TGCheckButton(fParticlesBG, new TGHotString("&Protons"));
87 fPosCharged->SetState(kButtonDown);
88 fNegCharged->SetState(kButtonDown);
89 fElectrons->SetState(kButtonUp);
90 fMuons->SetState(kButtonUp);
91 fPions->SetState(kButtonUp);
92 fKaons->SetState(kButtonUp);
93 fProtons->SetState(kButtonUp);
95 fPosCharged->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPosCharge()");
96 fNegCharged->Connect("Clicked()", "AliEveLegoEditor", this, "ShowNegCharge()");
97 fElectrons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowElectrons()");
98 fMuons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowMuons()");
99 fPions->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPions()");
100 fKaons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowKaons()");
101 fProtons->Connect("Clicked()", "AliEveLegoEditor", this, "ShowProtons()");
103 fParticlesBG->AddFrame(fPosCharged, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
104 fParticlesBG->AddFrame(fNegCharged, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
105 fParticlesBG->AddFrame(fElectrons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
106 fParticlesBG->AddFrame(fMuons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
107 fParticlesBG->AddFrame(fPions, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
108 fParticlesBG->AddFrame(fKaons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
109 fParticlesBG->AddFrame(fProtons, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
110 fParticlesBG->SetLayoutManager(new TGVerticalLayout(fParticlesBG));
112 AddFrame(fParticlesBG, new TGLayoutHints(kLHintsExpandX));
114 fTrackSelection = new TGButtonGroup(this, "Track selection:", kHorizontalFrame);
115 fRtracks[0] = new TGRadioButton(fTrackSelection, new TGHotString("&All tracks "));
116 fRtracks[1] = new TGRadioButton(fTrackSelection, new TGHotString("&Primary tracks"));
117 fRtracks[0]->SetState(kButtonDown);
118 AddFrame(fTrackSelection, new TGLayoutHints(kLHintsExpandX));
119 fTrackSelection->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByTracks(Int_t)");
123 TGHorizontalFrame *horz = new TGHorizontalFrame(this);
124 AddFrame(horz, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
125 fLabel = new TGLabel(horz, "Tracks maximum Pt (GeV): ");
126 horz->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
128 fMaxPt = new TGNumberEntry(horz, 10000, 7, -1,
129 TGNumberFormat::kNESRealOne,
130 TGNumberFormat::kNEANonNegative,
131 TGNumberFormat::kNELLimitMinMax,
134 fMaxPt->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPt()");
136 horz->AddFrame( fMaxPt, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
138 TGHorizontalFrame *horz1 = new TGHorizontalFrame(this);
139 AddFrame(horz1, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
140 fLabel1 = new TGLabel(horz1, "Tracks threshold (GeV): ");
141 horz1->AddFrame(fLabel1, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
143 fThreshold = new TGNumberEntry(horz1, 0, 7, -1,
144 TGNumberFormat::kNESRealOne,
145 TGNumberFormat::kNEANonNegative,
146 TGNumberFormat::kNELLimitMinMax,
149 fThreshold->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThreshold()");
150 horz1->AddFrame( fThreshold, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
155 /******************************************************************************/
157 //______________________________________________________________________________
158 void AliEveLegoEditor::SetModel(TObject* obj)
160 fM = dynamic_cast<AliEveLego*>(obj);
163 //______________________________________________________________________________
164 void AliEveLegoEditor::DoAllEvents()
166 fAllEventsButton->SetEnabled(kFALSE);
167 CreateAllEventsEditor();
171 //______________________________________________________________________________
172 void AliEveLegoEditor::ShowPosCharge()
174 fM->SetParticleType(0);
177 //______________________________________________________________________________
178 void AliEveLegoEditor::ShowNegCharge()
180 fM->SetParticleType(1);
183 //______________________________________________________________________________
184 void AliEveLegoEditor::ShowElectrons()
186 fM->SetParticleType(2);
189 //______________________________________________________________________________
190 void AliEveLegoEditor::ShowMuons()
192 fM->SetParticleType(3);
195 //______________________________________________________________________________
196 void AliEveLegoEditor::ShowPions()
198 fM->SetParticleType(4);
201 //______________________________________________________________________________
202 void AliEveLegoEditor::ShowKaons()
204 fM->SetParticleType(5);
207 //______________________________________________________________________________
208 void AliEveLegoEditor::ShowProtons()
210 fM->SetParticleType(6);
213 //______________________________________________________________________________
214 void AliEveLegoEditor::ShowPosChargeAE()
216 fM->SetParticleTypeAE(0);
219 //______________________________________________________________________________
220 void AliEveLegoEditor::ShowNegChargeAE()
222 fM->SetParticleTypeAE(1);
225 //______________________________________________________________________________
226 void AliEveLegoEditor::ShowElectronsAE()
228 fM->SetParticleTypeAE(2);
231 //______________________________________________________________________________
232 void AliEveLegoEditor::ShowMuonsAE()
234 fM->SetParticleTypeAE(3);
237 //______________________________________________________________________________
238 void AliEveLegoEditor::ShowPionsAE()
240 fM->SetParticleTypeAE(4);
243 //______________________________________________________________________________
244 void AliEveLegoEditor::ShowKaonsAE()
246 fM->SetParticleTypeAE(5);
249 //______________________________________________________________________________
250 void AliEveLegoEditor::ShowProtonsAE()
252 fM->SetParticleTypeAE(6);
255 //______________________________________________________________________________
256 void AliEveLegoEditor::SetMaxPt()
258 fM->SetMaxPt(fMaxPt->GetNumber());
261 //______________________________________________________________________________
262 void AliEveLegoEditor::SetMaxPtAE()
264 fM->SetMaxPtAE(fMaxPtAE->GetNumber());
267 //______________________________________________________________________________
268 void AliEveLegoEditor::SetThreshold()
270 fM->SetThreshold(fThreshold->GetNumber());
273 //______________________________________________________________________________
274 void AliEveLegoEditor::SetThresholdAE()
276 fM->SetThresholdAE(fThresholdAE->GetNumber());
279 //______________________________________________________________________________
280 void AliEveLegoEditor::ShowByTracks(Int_t id)
285 //______________________________________________________________________________
286 void AliEveLegoEditor::ShowByTracksAE(Int_t id)
291 //______________________________________________________________________________
292 void AliEveLegoEditor::CreateAllEventsEditor()
294 // create the GUI of all events
295 TGVerticalFrame *this2 = this->CreateEditorTabSubFrame("All events style");
297 fEventControl = new TGButtonGroup(this2, "Event control:", kVerticalFrame);
298 fIsMC = new TGCheckButton(fEventControl, new TGHotString("&Data is from simulation (MC)"));
299 fCollisionCandidatesOnly = new TGCheckButton(fEventControl, new TGHotString("&Only collision candidates events"));
301 fIsMC->SetState(kButtonUp);
302 fCollisionCandidatesOnly->SetState(kButtonUp);
304 fIsMC->Connect("Clicked()", "AliEveLegoEditor", this, "DataIsMC()");
305 fCollisionCandidatesOnly->Connect("Clicked()", "AliEveLegoEditor", this, "CollisionCandidatesOnly()");
306 this2->AddFrame(fEventControl, new TGLayoutHints(kLHintsExpandX));
308 fParticlesBGAE = new TGButtonGroup(this2, "Particle selection:", kVerticalFrame);
310 fPosChargedAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Positive charged"));
311 fNegChargedAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Negative charged"));
312 fElectronsAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Electrons"));
313 fMuonsAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Muons"));
314 fPionsAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Pions"));
315 fKaonsAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Kaons"));
316 fProtonsAE = new TGCheckButton(fParticlesBGAE, new TGHotString("&Protons"));
318 fPosChargedAE->SetState(kButtonDown);
319 fNegChargedAE->SetState(kButtonDown);
320 fElectronsAE->SetState(kButtonUp);
321 fMuonsAE->SetState(kButtonUp);
322 fPionsAE->SetState(kButtonUp);
323 fKaonsAE->SetState(kButtonUp);
324 fProtonsAE->SetState(kButtonUp);
326 fPosChargedAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPosChargeAE()");
327 fNegChargedAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowNegChargeAE()");
328 fElectronsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowElectronsAE()");
329 fMuonsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowMuonsAE()");
330 fPionsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPionsAE()");
331 fKaonsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowKaonsAE()");
332 fProtonsAE->Connect("Clicked()", "AliEveLegoEditor", this, "ShowProtonsAE()");
334 this2->AddFrame(fParticlesBGAE, new TGLayoutHints(kLHintsExpandX));
336 fApplyChanges = new TGTextButton(this2, "Apply particle selection");
337 this2->AddFrame(fApplyChanges, new TGLayoutHints(kLHintsExpandX));
338 fApplyChanges->Connect("Clicked()", "AliEveLegoEditor", this, "ApplyChanges()");
340 fTrackSelectionAE = new TGButtonGroup(this2, "Track selection:", kHorizontalFrame);
341 fRtracksAE[0] = new TGRadioButton(fTrackSelectionAE, new TGHotString("&All tracks "));
342 fRtracksAE[1] = new TGRadioButton(fTrackSelectionAE, new TGHotString("&Primary tracks"));
343 fRtracksAE[0]->SetState(kButtonDown);
344 this2->AddFrame(fTrackSelectionAE, new TGLayoutHints(kLHintsExpandX));
345 fTrackSelectionAE->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByTracksAE(Int_t)");
349 TGHorizontalFrame *horzAE = new TGHorizontalFrame(this2);
351 fLabelAE = new TGLabel(horzAE, "Tracks maximum Pt (GeV): ");
352 horzAE->AddFrame(fLabelAE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
354 fMaxPtAE = new TGNumberEntry(horzAE, 10000, 7, -1,
355 TGNumberFormat::kNESRealOne,
356 TGNumberFormat::kNEANonNegative,
357 TGNumberFormat::kNELLimitMinMax,
360 fMaxPtAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPtAE()");
362 horzAE->AddFrame( fMaxPtAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
363 this2->AddFrame(horzAE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
365 TGHorizontalFrame *horz1AE = new TGHorizontalFrame(this2);
367 fLabel1AE = new TGLabel(horz1AE, "Tracks threshold (GeV): ");
368 horz1AE->AddFrame(fLabel1AE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
370 fThresholdAE = new TGNumberEntry(horz1AE, 0, 7, -1,
371 TGNumberFormat::kNESRealOne,
372 TGNumberFormat::kNEANonNegative,
373 TGNumberFormat::kNELLimitMinMax,
376 fThresholdAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThresholdAE()");
377 horz1AE->AddFrame( fThresholdAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
379 this2->AddFrame(horz1AE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
384 //______________________________________________________________________________
385 void AliEveLegoEditor::ApplyChanges()
387 fM->ApplyParticleTypeSelectionAE();
390 //______________________________________________________________________________
391 void AliEveLegoEditor::DataIsMC()
393 fM->SwitchDataType();
396 //______________________________________________________________________________
397 void AliEveLegoEditor::CollisionCandidatesOnly()
399 fM->SetCollisionCandidatesOnly();