3d94b490 |
1 | // $Id$ |
2 | // Author: Stefano Carrazza 2010 |
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 "AliEveLegoEditor.h" |
11 | #include "AliEveLego.h" |
12 | |
13 | #include "TVirtualPad.h" |
14 | #include "TColor.h" |
15 | |
16 | #include "TGLabel.h" |
17 | #include "TGButton.h" |
18 | #include "TGNumberEntry.h" |
19 | #include "TGColorSelect.h" |
20 | #include "TGDoubleSlider.h" |
21 | #include "TGButtonGroup.h" |
22 | #include "TGString.h" |
23 | #include "TGComboBox.h" |
24 | #include "TGFrame.h" |
25 | |
26 | //______________________________________________________________________________ |
27 | // GUI editor for AliEveLego. |
28 | // |
29 | |
30 | ClassImp(AliEveLegoEditor) |
31 | |
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), |
36 | fM(0), |
3d94b490 |
37 | fAllEventsButton(0), |
38 | fParticlesBG(0), |
39 | fTrackSelection(0), |
6e994a7b |
40 | fPosCharged(0), |
41 | fNegCharged(0), |
42 | fElectrons(0), |
43 | fMuons(0), |
44 | fPions(0), |
45 | fKaons(0), |
46 | fProtons(0), |
3d94b490 |
47 | fLabel(0), |
48 | fLabel1(0), |
49 | fThreshold(0), |
50 | fMaxPt(0), |
51 | fSelect(0), |
6e994a7b |
52 | fParticlesBGAE(0), |
3d94b490 |
53 | fTrackSelectionAE(0), |
6e994a7b |
54 | fPosChargedAE(0), |
55 | fNegChargedAE(0), |
56 | fElectronsAE(0), |
57 | fMuonsAE(0), |
58 | fPionsAE(0), |
59 | fKaonsAE(0), |
60 | fProtonsAE(0), |
61 | fApplyChanges(0), |
3d94b490 |
62 | fLabelAE(0), |
63 | fLabel1AE(0), |
64 | fThresholdAE(0), |
65 | fMaxPtAE(0), |
6e994a7b |
66 | fEventControl(0), |
67 | fIsMC(kFALSE), |
68 | fCollisionCandidatesOnly(0) |
3d94b490 |
69 | { |
70 | // Constructor. |
71 | MakeTitle("AliEveLego"); |
72 | |
73 | // Create widgets |
74 | fAllEventsButton = new TGTextButton(this, "Create lego of all events"); |
75 | AddFrame(fAllEventsButton, new TGLayoutHints(kLHintsExpandX)); |
76 | fAllEventsButton->Connect("Clicked()", "AliEveLegoEditor", this, "DoAllEvents()"); |
77 | |
6e994a7b |
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")); |
86 | |
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); |
94 | |
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()"); |
102 | |
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)); |
111 | |
3d94b490 |
112 | AddFrame(fParticlesBG, new TGLayoutHints(kLHintsExpandX)); |
3d94b490 |
113 | |
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)"); |
120 | |
121 | //************** |
122 | |
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)); |
127 | |
128 | fMaxPt = new TGNumberEntry(horz, 10000, 7, -1, |
129 | TGNumberFormat::kNESRealOne, |
130 | TGNumberFormat::kNEANonNegative, |
131 | TGNumberFormat::kNELLimitMinMax, |
132 | 0, 10000); |
133 | |
134 | fMaxPt->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPt()"); |
135 | |
136 | horz->AddFrame( fMaxPt, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY)); |
137 | |
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)); |
142 | |
143 | fThreshold = new TGNumberEntry(horz1, 0, 7, -1, |
144 | TGNumberFormat::kNESRealOne, |
145 | TGNumberFormat::kNEANonNegative, |
146 | TGNumberFormat::kNELLimitMinMax, |
147 | 0, 10000); |
148 | |
149 | fThreshold->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThreshold()"); |
150 | horz1->AddFrame( fThreshold, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY)); |
151 | |
152 | |
6e994a7b |
153 | } |
3d94b490 |
154 | |
6e994a7b |
155 | /******************************************************************************/ |
3d94b490 |
156 | |
6e994a7b |
157 | //______________________________________________________________________________ |
158 | void AliEveLegoEditor::SetModel(TObject* obj) |
159 | { |
160 | fM = dynamic_cast<AliEveLego*>(obj); |
161 | } |
3d94b490 |
162 | |
6e994a7b |
163 | //______________________________________________________________________________ |
164 | void AliEveLegoEditor::DoAllEvents() |
165 | { |
166 | fAllEventsButton->SetEnabled(kFALSE); |
167 | CreateAllEventsEditor(); |
168 | fM->LoadAllEvents(); |
169 | } |
3d94b490 |
170 | |
6e994a7b |
171 | //______________________________________________________________________________ |
172 | void AliEveLegoEditor::ShowPosCharge() |
173 | { |
174 | fM->SetParticleType(0); |
175 | } |
3d94b490 |
176 | |
6e994a7b |
177 | //______________________________________________________________________________ |
178 | void AliEveLegoEditor::ShowNegCharge() |
179 | { |
180 | fM->SetParticleType(1); |
181 | } |
3d94b490 |
182 | |
6e994a7b |
183 | //______________________________________________________________________________ |
184 | void AliEveLegoEditor::ShowElectrons() |
185 | { |
186 | fM->SetParticleType(2); |
187 | } |
3d94b490 |
188 | |
6e994a7b |
189 | //______________________________________________________________________________ |
190 | void AliEveLegoEditor::ShowMuons() |
191 | { |
192 | fM->SetParticleType(3); |
193 | } |
3d94b490 |
194 | |
6e994a7b |
195 | //______________________________________________________________________________ |
196 | void AliEveLegoEditor::ShowPions() |
197 | { |
198 | fM->SetParticleType(4); |
3d94b490 |
199 | } |
200 | |
6e994a7b |
201 | //______________________________________________________________________________ |
202 | void AliEveLegoEditor::ShowKaons() |
203 | { |
204 | fM->SetParticleType(5); |
205 | } |
3d94b490 |
206 | |
207 | //______________________________________________________________________________ |
6e994a7b |
208 | void AliEveLegoEditor::ShowProtons() |
3d94b490 |
209 | { |
6e994a7b |
210 | fM->SetParticleType(6); |
3d94b490 |
211 | } |
212 | |
6e994a7b |
213 | //______________________________________________________________________________ |
214 | void AliEveLegoEditor::ShowPosChargeAE() |
215 | { |
216 | fM->SetParticleTypeAE(0); |
217 | } |
3d94b490 |
218 | |
6e994a7b |
219 | //______________________________________________________________________________ |
220 | void AliEveLegoEditor::ShowNegChargeAE() |
221 | { |
222 | fM->SetParticleTypeAE(1); |
223 | } |
3d94b490 |
224 | |
225 | //______________________________________________________________________________ |
6e994a7b |
226 | void AliEveLegoEditor::ShowElectronsAE() |
227 | { |
228 | fM->SetParticleTypeAE(2); |
229 | } |
3d94b490 |
230 | |
231 | //______________________________________________________________________________ |
6e994a7b |
232 | void AliEveLegoEditor::ShowMuonsAE() |
3d94b490 |
233 | { |
6e994a7b |
234 | fM->SetParticleTypeAE(3); |
235 | } |
3d94b490 |
236 | |
6e994a7b |
237 | //______________________________________________________________________________ |
238 | void AliEveLegoEditor::ShowPionsAE() |
239 | { |
240 | fM->SetParticleTypeAE(4); |
3d94b490 |
241 | } |
242 | |
243 | //______________________________________________________________________________ |
6e994a7b |
244 | void AliEveLegoEditor::ShowKaonsAE() |
245 | { |
246 | fM->SetParticleTypeAE(5); |
3d94b490 |
247 | } |
248 | |
249 | //______________________________________________________________________________ |
6e994a7b |
250 | void AliEveLegoEditor::ShowProtonsAE() |
3d94b490 |
251 | { |
6e994a7b |
252 | fM->SetParticleTypeAE(6); |
3d94b490 |
253 | } |
254 | |
255 | //______________________________________________________________________________ |
256 | void AliEveLegoEditor::SetMaxPt() |
257 | { |
258 | fM->SetMaxPt(fMaxPt->GetNumber()); |
259 | } |
260 | |
261 | //______________________________________________________________________________ |
262 | void AliEveLegoEditor::SetMaxPtAE() |
263 | { |
264 | fM->SetMaxPtAE(fMaxPtAE->GetNumber()); |
265 | } |
266 | |
267 | //______________________________________________________________________________ |
268 | void AliEveLegoEditor::SetThreshold() |
269 | { |
270 | fM->SetThreshold(fThreshold->GetNumber()); |
271 | } |
272 | |
273 | //______________________________________________________________________________ |
274 | void AliEveLegoEditor::SetThresholdAE() |
275 | { |
276 | fM->SetThresholdAE(fThresholdAE->GetNumber()); |
277 | } |
278 | |
279 | //______________________________________________________________________________ |
280 | void AliEveLegoEditor::ShowByTracks(Int_t id) |
281 | { |
282 | fM->SetTracks(id); |
283 | } |
284 | |
285 | //______________________________________________________________________________ |
286 | void AliEveLegoEditor::ShowByTracksAE(Int_t id) |
287 | { |
288 | fM->SetTracksAE(id); |
289 | } |
290 | |
3d94b490 |
291 | //______________________________________________________________________________ |
292 | void AliEveLegoEditor::CreateAllEventsEditor() |
293 | { |
4171aa4e |
294 | // create the GUI of all events |
3d94b490 |
295 | TGVerticalFrame *this2 = this->CreateEditorTabSubFrame("All events style"); |
296 | |
6e994a7b |
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")); |
300 | |
301 | fIsMC->SetState(kButtonUp); |
302 | fCollisionCandidatesOnly->SetState(kButtonUp); |
303 | |
304 | fIsMC->Connect("Clicked()", "AliEveLegoEditor", this, "DataIsMC()"); |
305 | fCollisionCandidatesOnly->Connect("Clicked()", "AliEveLegoEditor", this, "CollisionCandidatesOnly()"); |
306 | this2->AddFrame(fEventControl, new TGLayoutHints(kLHintsExpandX)); |
307 | |
308 | fParticlesBGAE = new TGButtonGroup(this2, "Particle selection:", kVerticalFrame); |
309 | |
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")); |
317 | |
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); |
325 | |
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()"); |
3d94b490 |
333 | |
3d94b490 |
334 | this2->AddFrame(fParticlesBGAE, new TGLayoutHints(kLHintsExpandX)); |
335 | |
6e994a7b |
336 | fApplyChanges = new TGTextButton(this2, "Apply particle selection"); |
337 | this2->AddFrame(fApplyChanges, new TGLayoutHints(kLHintsExpandX)); |
338 | fApplyChanges->Connect("Clicked()", "AliEveLegoEditor", this, "ApplyChanges()"); |
3d94b490 |
339 | |
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)"); |
346 | |
347 | //************** |
348 | |
349 | TGHorizontalFrame *horzAE = new TGHorizontalFrame(this2); |
350 | |
351 | fLabelAE = new TGLabel(horzAE, "Tracks maximum Pt (GeV): "); |
352 | horzAE->AddFrame(fLabelAE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); |
353 | |
354 | fMaxPtAE = new TGNumberEntry(horzAE, 10000, 7, -1, |
355 | TGNumberFormat::kNESRealOne, |
356 | TGNumberFormat::kNEANonNegative, |
357 | TGNumberFormat::kNELLimitMinMax, |
358 | 0, 10000); |
359 | |
360 | fMaxPtAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPtAE()"); |
361 | |
362 | horzAE->AddFrame( fMaxPtAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY)); |
363 | this2->AddFrame(horzAE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY)); |
364 | |
365 | TGHorizontalFrame *horz1AE = new TGHorizontalFrame(this2); |
366 | |
367 | fLabel1AE = new TGLabel(horz1AE, "Tracks threshold (GeV): "); |
368 | horz1AE->AddFrame(fLabel1AE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); |
369 | |
370 | fThresholdAE = new TGNumberEntry(horz1AE, 0, 7, -1, |
371 | TGNumberFormat::kNESRealOne, |
372 | TGNumberFormat::kNEANonNegative, |
373 | TGNumberFormat::kNELLimitMinMax, |
374 | 0, 10000); |
375 | |
376 | fThresholdAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThresholdAE()"); |
377 | horz1AE->AddFrame( fThresholdAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY)); |
378 | |
379 | this2->AddFrame(horz1AE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY)); |
380 | |
6e994a7b |
381 | |
3d94b490 |
382 | } |
383 | |
384 | //______________________________________________________________________________ |
6e994a7b |
385 | void AliEveLegoEditor::ApplyChanges() |
3d94b490 |
386 | { |
6e994a7b |
387 | fM->ApplyParticleTypeSelectionAE(); |
3d94b490 |
388 | } |
389 | |
390 | //______________________________________________________________________________ |
6e994a7b |
391 | void AliEveLegoEditor::DataIsMC() |
3d94b490 |
392 | { |
6e994a7b |
393 | fM->SwitchDataType(); |
3d94b490 |
394 | } |
395 | |
6e994a7b |
396 | //______________________________________________________________________________ |
397 | void AliEveLegoEditor::CollisionCandidatesOnly() |
398 | { |
399 | fM->SetCollisionCandidatesOnly(); |
400 | } |