2 // Author: Stefano Carrazza 2010, CERN, stefano.carrazza@cern.ch
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 "AliEveLego.h"
11 #include "AliEveLegoEditor.h"
15 #include "TGButtonGroup.h"
16 #include "TGColorSelect.h"
17 #include "TGComboBox.h"
18 #include "TGDoubleSlider.h"
21 #include "TGNumberEntry.h"
23 #include "TVirtualPad.h"
25 //______________________________________________________________________________
26 // This is the GUI editor for AliEveLego.
29 ClassImp(AliEveLegoEditor)
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),
67 fCollisionCandidatesOnly(0)
70 MakeTitle("AliEveLego");
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()");
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"));
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);
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()");
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));
114 AddFrame(fParticlesBG, new TGLayoutHints(kLHintsExpandX));
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)");
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));
130 fMaxPt = new TGNumberEntry(horz, 10000, 7, -1,
131 TGNumberFormat::kNESRealOne,
132 TGNumberFormat::kNEANonNegative,
133 TGNumberFormat::kNELLimitMinMax,
136 fMaxPt->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPt()");
138 horz->AddFrame( fMaxPt, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
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));
145 fThreshold = new TGNumberEntry(horz1, 0, 7, -1,
146 TGNumberFormat::kNESRealOne,
147 TGNumberFormat::kNEANonNegative,
148 TGNumberFormat::kNELLimitMinMax,
151 fThreshold->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThreshold()");
152 horz1->AddFrame( fThreshold, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
157 //______________________________________________________________________________
158 void AliEveLegoEditor::SetModel(TObject* obj)
160 // Calls the associated AliEveLego object
161 fM = dynamic_cast<AliEveLego*>(obj);
164 //______________________________________________________________________________
165 void AliEveLegoEditor::DoAllEvents()
167 // Creates the all events editor
168 fAllEventsButton->SetEnabled(kFALSE);
169 CreateAllEventsEditor();
173 //______________________________________________________________________________
174 void AliEveLegoEditor::ShowPosCharge()
176 // Send particle type to main class
177 fM->SetParticleType(0, fPosCharged->IsOn());
180 //______________________________________________________________________________
181 void AliEveLegoEditor::ShowNegCharge()
183 // Send particle type to main class
184 fM->SetParticleType(1, fNegCharged->IsOn());
187 //______________________________________________________________________________
188 void AliEveLegoEditor::ShowElectrons()
190 // Send particle type to main class
191 fM->SetParticleType(2, fElectrons->IsOn());
194 //______________________________________________________________________________
195 void AliEveLegoEditor::ShowMuons()
197 // Send particle type to main class
198 fM->SetParticleType(3, fMuons->IsOn());
201 //______________________________________________________________________________
202 void AliEveLegoEditor::ShowPions()
204 // Send particle type to main class
205 fM->SetParticleType(4, fPions->IsOn());
208 //______________________________________________________________________________
209 void AliEveLegoEditor::ShowKaons()
211 // Send particle type to main class
212 fM->SetParticleType(5, fKaons->IsOn());
215 //______________________________________________________________________________
216 void AliEveLegoEditor::ShowProtons()
218 // Send particle type to main class
219 fM->SetParticleType(6, fProtons->IsOn());
222 //______________________________________________________________________________
223 void AliEveLegoEditor::ShowPosChargeAE()
225 // Send particle type to main class
226 fM->SetParticleTypeAE(0, fPosChargedAE->IsOn());
229 //______________________________________________________________________________
230 void AliEveLegoEditor::ShowNegChargeAE()
232 // Send particle type to main class
233 fM->SetParticleTypeAE(1, fNegChargedAE->IsOn());
236 //______________________________________________________________________________
237 void AliEveLegoEditor::ShowElectronsAE()
239 // Send particle type to main class
240 fM->SetParticleTypeAE(2, fElectronsAE->IsOn());
243 //______________________________________________________________________________
244 void AliEveLegoEditor::ShowMuonsAE()
246 // Send particle type to main class
247 fM->SetParticleTypeAE(3, fMuonsAE->IsOn());
250 //______________________________________________________________________________
251 void AliEveLegoEditor::ShowPionsAE()
253 // Send particle type to main class
254 fM->SetParticleTypeAE(4, fPionsAE->IsOn());
257 //______________________________________________________________________________
258 void AliEveLegoEditor::ShowKaonsAE()
260 // Send particle type to main class
261 fM->SetParticleTypeAE(5, fKaonsAE->IsOn());
264 //______________________________________________________________________________
265 void AliEveLegoEditor::ShowProtonsAE()
267 // Send particle type to main class
268 fM->SetParticleTypeAE(6, fProtonsAE->IsOn());
271 //______________________________________________________________________________
272 void AliEveLegoEditor::SetMaxPt()
274 // Send particle type to main class
275 fM->SetMaxPt(fMaxPt->GetNumber());
278 //______________________________________________________________________________
279 void AliEveLegoEditor::SetMaxPtAE()
281 // Send particle type to main class
282 fM->SetMaxPtAE(fMaxPtAE->GetNumber());
285 //______________________________________________________________________________
286 void AliEveLegoEditor::SetThreshold()
288 // Send particle type to main class
289 fM->SetThreshold(fThreshold->GetNumber());
292 //______________________________________________________________________________
293 void AliEveLegoEditor::SetThresholdAE()
295 // Send particle type to main class
296 fM->SetThresholdAE(fThresholdAE->GetNumber());
299 //______________________________________________________________________________
300 void AliEveLegoEditor::ShowByTracks(Int_t id)
302 // Send particle type to main class
306 //______________________________________________________________________________
307 void AliEveLegoEditor::ShowByTracksAE(Int_t id)
309 // Send particle type to main class
313 //______________________________________________________________________________
314 void AliEveLegoEditor::CreateAllEventsEditor()
316 // Create the GUI of all events
317 TGVerticalFrame *this2 = this->CreateEditorTabSubFrame("All events style");
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"));
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));
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"));
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);
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()");
357 this2->AddFrame(fParticlesBGAE, new TGLayoutHints(kLHintsExpandX));
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));
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));
372 //------ Threshold setup ------
373 TGHorizontalFrame *horzAE = new TGHorizontalFrame(this2);
375 fLabelAE = new TGLabel(horzAE, "Tracks maximum Pt (GeV): ");
376 horzAE->AddFrame(fLabelAE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
378 fMaxPtAE = new TGNumberEntry(horzAE, 10000, 7, -1,
379 TGNumberFormat::kNESRealOne,
380 TGNumberFormat::kNEANonNegative,
381 TGNumberFormat::kNELLimitMinMax,
384 fMaxPtAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPtAE()");
386 horzAE->AddFrame( fMaxPtAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
387 this2->AddFrame(horzAE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
389 TGHorizontalFrame *horz1AE = new TGHorizontalFrame(this2);
391 fLabel1AE = new TGLabel(horz1AE, "Tracks threshold (GeV): ");
392 horz1AE->AddFrame(fLabel1AE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
394 fThresholdAE = new TGNumberEntry(horz1AE, 0, 7, -1,
395 TGNumberFormat::kNESRealOne,
396 TGNumberFormat::kNEANonNegative,
397 TGNumberFormat::kNELLimitMinMax,
400 fThresholdAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThresholdAE()");
401 horz1AE->AddFrame( fThresholdAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
403 this2->AddFrame(horz1AE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
406 //______________________________________________________________________________
407 void AliEveLegoEditor::ApplyChanges()
409 // Apply particle selection for all events
410 fM->ApplyParticleTypeSelectionAE();
413 //______________________________________________________________________________
414 void AliEveLegoEditor::DataIsMC()
417 fM->SwitchDataType(fIsMC->IsOn());
420 //______________________________________________________________________________
421 void AliEveLegoEditor::CollisionCandidatesOnly()
423 // Activate collision candidates only
424 fM->SetCollisionCandidatesOnly();