Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveTrackPropagatorEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
13 #include "TEveTrackPropagator.h"
14 // #include <TEveTrack.h>
15 
16 #include "TEveGValuators.h"
17 #include "TEveManager.h"
18 
19 #include "TVirtualPad.h"
20 #include "TColor.h"
21 
22 #include "TGLabel.h"
23 #include "TG3DLine.h"
24 #include "TGButton.h"
25 #include "TGNumberEntry.h"
26 #include "TGColorSelect.h"
27 #include "TGComboBox.h"
28 #include "TGDoubleSlider.h"
29 #include "TGComboBox.h"
30 #include "TAttMarkerEditor.h"
31 
32 /** \class TEveTrackPropagatorSubEditor
33 \ingroup TEve
34 Sub-editor for TEveTrackPropagator class.
35 */
36 
37 ClassImp(TEveTrackPropagatorSubEditor);
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Constructor.
41 
42 TEveTrackPropagatorSubEditor::TEveTrackPropagatorSubEditor(const TGWindow *p):
43  TGVerticalFrame(p),
44  fM (0),
45 
46  fMaxR(0), fMaxZ(0), fMaxOrbits(0), fMaxAng(0), fDelta(0),
47 
48  fRefsCont(0), fPMFrame(0),
49  fFitDaughters(0), fFitReferences(0),
50  fFitDecay(0),
51  fFitCluster2Ds(0), fFitLineSegments(0),
52  fRnrDaughters(0), fRnrReferences(0),
53  fRnrDecay(0), fRnrCluster2Ds(0),
54  fRnrFV(0),
55  fPMAtt(0), fFVAtt(0),
56  fProjTrackBreaking(0), fRnrPTBMarkers(0), fPTBAtt(0)
57 {
58  Int_t labelW = 51;
59 
60  // --- Limits
61  fMaxR = new TEveGValuator(this, "Max R:", 90, 0);
62  fMaxR->SetLabelWidth(labelW);
63  fMaxR->SetNELength(6);
64  fMaxR->Build();
65  fMaxR->SetLimits(0.1, TEveTrackPropagator::fgEditorMaxR, 101, TGNumberFormat::kNESRealOne);
66  fMaxR->SetToolTip("Maximum radius to which the tracks will be drawn.");
67  fMaxR->Connect("ValueSet(Double_t)", "TEveTrackPropagatorSubEditor", this, "DoMaxR()");
68  AddFrame(fMaxR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
69 
70  fMaxZ = new TEveGValuator(this, "Max Z:", 90, 0);
71  fMaxZ->SetLabelWidth(labelW);
72  fMaxZ->SetNELength(6);
73  fMaxZ->Build();
74  fMaxZ->SetLimits(0.1, TEveTrackPropagator::fgEditorMaxZ, 101, TGNumberFormat::kNESRealOne);
75  fMaxZ->SetToolTip("Maximum z-coordinate to which the tracks will be drawn.");
76  fMaxZ->Connect("ValueSet(Double_t)", "TEveTrackPropagatorSubEditor", this, "DoMaxZ()");
77  AddFrame(fMaxZ, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
78 
79  fMaxOrbits = new TEveGValuator(this, "Orbits:", 90, 0);
80  fMaxOrbits->SetLabelWidth(labelW);
81  fMaxOrbits->SetNELength(6);
82  fMaxOrbits->Build();
83  fMaxOrbits->SetLimits(0.1, 10, 101, TGNumberFormat::kNESRealOne);
84  fMaxOrbits->SetToolTip("Maximal angular path of tracks' orbits (1 ~ 2Pi).");
85  fMaxOrbits->Connect("ValueSet(Double_t)", "TEveTrackPropagatorSubEditor", this, "DoMaxOrbits()");
86  AddFrame(fMaxOrbits, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
87 
88  fMaxAng = new TEveGValuator(this, "Angle:", 90, 0);
89  fMaxAng->SetLabelWidth(labelW);
90  fMaxAng->SetNELength(6);
91  fMaxAng->Build();
92  fMaxAng->SetLimits(1, 160, 81, TGNumberFormat::kNESRealOne);
93  fMaxAng->SetToolTip("Maximal angular step between two helix points.");
94  fMaxAng->Connect("ValueSet(Double_t)", "TEveTrackPropagatorSubEditor", this, "DoMaxAng()");
95  AddFrame(fMaxAng, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
96 
97  fDelta = new TEveGValuator(this, "Delta:", 90, 0);
98  fDelta->SetLabelWidth(labelW);
99  fDelta->SetNELength(6);
100  fDelta->Build();
101  fDelta->SetLimits(0.001, 10, 101, TGNumberFormat::kNESRealThree);
102  fDelta->SetToolTip("Maximal error at the mid-point of the line connecting to helix points.");
103  fDelta->Connect("ValueSet(Double_t)", "TEveTrackPropagatorSubEditor", this, "DoDelta()");
104  AddFrame(fDelta, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
105 }
106 
107 ////////////////////////////////////////////////////////////////////////////////
108 /// Create a frame containing track-reference controls under parent frame p.
109 
110 void TEveTrackPropagatorSubEditor::CreateRefsContainer(TGVerticalFrame* p)
111 {
112  fRefsCont = new TGCompositeFrame(p, 80, 20, kVerticalFrame);
113  fPMFrame = new TGVerticalFrame(fRefsCont);
114  // Rendering control.
115  {
116  TGGroupFrame* fitPM = new TGGroupFrame(fPMFrame, "PathMarks:", kLHintsTop | kLHintsCenterX);
117  fitPM->SetTitlePos(TGGroupFrame::kLeft);
118  fPMFrame->AddFrame( fitPM, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
119 
120  TGMatrixLayout *ml = new TGMatrixLayout(fitPM, 0,1,6);
121  fitPM->SetLayoutManager(ml);
122 
123  fFitDaughters = new TGCheckButton(fitPM, "Fit Daughters", TEvePathMark::kDaughter);
124  fFitReferences = new TGCheckButton(fitPM, "Fit Refs", TEvePathMark::kReference);
125  fFitDecay = new TGCheckButton(fitPM, "Fit Decay", TEvePathMark::kDecay);
126  fFitCluster2Ds = new TGCheckButton(fitPM, "Fit 2D Clusters", TEvePathMark::kCluster2D);
127  fFitLineSegments = new TGCheckButton(fitPM, "Fit Line Segments", TEvePathMark::kLineSegment);
128 
129  fitPM->AddFrame(fFitDaughters);
130  fitPM->AddFrame(fFitReferences);
131  fitPM->AddFrame(fFitDecay);
132  fitPM->AddFrame(fFitCluster2Ds);
133  fitPM->AddFrame(fFitLineSegments);
134 
135  fFitDecay ->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoFitPM()");
136  fFitReferences ->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoFitPM()");
137  fFitDaughters ->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoFitPM()");
138  fFitCluster2Ds ->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoFitPM()");
139  fFitLineSegments->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoFitPM()");
140  }
141  // Kinematics fitting.
142  {
143  TGGroupFrame* rnrPM = new TGGroupFrame(fPMFrame, "PathMarks:", kLHintsTop | kLHintsCenterX);
144  rnrPM->SetTitlePos(TGGroupFrame::kLeft);
145  fPMFrame->AddFrame( rnrPM, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
146 
147  TGMatrixLayout *ml = new TGMatrixLayout(rnrPM, 0, 1, 6);
148  rnrPM->SetLayoutManager(ml);
149 
150  fRnrDaughters = new TGCheckButton(rnrPM, "Rnr Daughters", TEvePathMark::kDaughter);
151  fRnrReferences = new TGCheckButton(rnrPM, "Rnr Refs", TEvePathMark::kReference);
152  fRnrDecay = new TGCheckButton(rnrPM, "Rnr Decay", TEvePathMark::kDecay);
153  fRnrCluster2Ds = new TGCheckButton(rnrPM, "Rnr 2D Clusters", TEvePathMark::kCluster2D);
154 
155  rnrPM->AddFrame(fRnrDaughters);
156  rnrPM->AddFrame(fRnrReferences);
157  rnrPM->AddFrame(fRnrDecay);
158  rnrPM->AddFrame(fRnrCluster2Ds);
159 
160  fRnrDecay ->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoRnrPM()");
161  fRnrReferences->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoRnrPM()");
162  fRnrDaughters ->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoRnrPM()");
163  fRnrCluster2Ds->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoRnrPM()");
164 
165  fRefsCont->AddFrame(fPMFrame, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
166  }
167  // Marker attributes.
168  {
169  fPMAtt = new TAttMarkerEditor(fRefsCont);
170  TGFrameElement *el = (TGFrameElement*) fPMAtt->GetList()->First();
171  TGFrame *f = el->fFrame; fPMAtt->RemoveFrame(f);
172  f->DestroyWindow(); delete f;
173  fRefsCont->AddFrame(fPMAtt, new TGLayoutHints(kLHintsTop, 1, 1, 3, 1));
174  }
175  // First vertex.
176  {
177  TGCompositeFrame *vf = new TGCompositeFrame
178  (fRefsCont, 145, 10, kHorizontalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
179  vf->AddFrame(new TGLabel(vf, "FirstVertex"),
180  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
181  vf->AddFrame(new TGHorizontal3DLine(vf),
182  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5));
183  fRefsCont->AddFrame(vf, new TGLayoutHints(kLHintsTop, 0, 0, 4, 0));
184 
185  fRnrFV = new TGCheckButton(fRefsCont, "Rnr");
186  fRnrFV->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoRnrFV()");
187  fRefsCont->AddFrame(fRnrFV, new TGLayoutHints(kLHintsTop, 5, 1, 2, 0));
188  {
189  fFVAtt = new TAttMarkerEditor(fRefsCont);
190  TGFrameElement *el = (TGFrameElement*) fFVAtt->GetList()->First();
191  TGFrame *f = el->fFrame; fFVAtt->RemoveFrame(f);
192  f->DestroyWindow(); delete f;
193  fRefsCont->AddFrame(fFVAtt, new TGLayoutHints(kLHintsTop, 1, 1, 3, 1));
194  }
195  }
196  // Break-points of projected tracks
197  {
198  TGCompositeFrame *vf = new TGCompositeFrame
199  (fRefsCont, 145, 10, kHorizontalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
200  vf->AddFrame(new TGLabel(vf, "BreakPoints"),
201  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
202  vf->AddFrame(new TGHorizontal3DLine(vf),
203  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5));
204  fRefsCont->AddFrame(vf, new TGLayoutHints(kLHintsTop, 0, 0, 4, 0));
205 
206  {
207  UInt_t labelW = 40;
208  UInt_t labelH = 20;
209  TGHorizontalFrame* hf = new TGHorizontalFrame(fRefsCont);
210  // label
211  TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
212  TGLabel* label = new TGLabel(labfr, "Mode:");
213  labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
214  hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
215  // combo
216  fProjTrackBreaking = new TGComboBox(hf);
217  fProjTrackBreaking->AddEntry("Break tracks", TEveTrackPropagator::kPTB_Break);
218  fProjTrackBreaking->AddEntry("First point position", TEveTrackPropagator::kPTB_UseFirstPointPos);
219  fProjTrackBreaking->AddEntry("Last point position", TEveTrackPropagator::kPTB_UseLastPointPos);
220  fProjTrackBreaking->Connect("Selected(Int_t)", "TEveTrackPropagatorSubEditor", this, "DoModePTB(UChar_t)");
221  fProjTrackBreaking->Resize(140, labelH);
222  hf->AddFrame(fProjTrackBreaking, new TGLayoutHints(kLHintsLeft, 0,0,2,0));
223  fRefsCont->AddFrame(hf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
224  }
225 
226  fRnrPTBMarkers = new TGCheckButton(fRefsCont, "Rnr");
227  fRnrPTBMarkers->Connect("Clicked()","TEveTrackPropagatorSubEditor", this, "DoRnrPTB()");
228  fRefsCont->AddFrame(fRnrPTBMarkers, new TGLayoutHints(kLHintsTop, 5, 1, 2, 0));
229  {
230  fPTBAtt = new TAttMarkerEditor(fRefsCont);
231  TGFrameElement *el = (TGFrameElement*) fPTBAtt->GetList()->First();
232  TGFrame *f = el->fFrame; fPTBAtt->RemoveFrame(f);
233  f->DestroyWindow(); delete f;
234  fRefsCont->AddFrame(fPTBAtt, new TGLayoutHints(kLHintsTop, 1, 1, 3, 1));
235  }
236  }
237 
238  p->AddFrame(fRefsCont, new TGLayoutHints(kLHintsTop| kLHintsExpandX));
239 }
240 
241 ////////////////////////////////////////////////////////////////////////////////
242 /// Set model object.
243 
244 void TEveTrackPropagatorSubEditor::SetModel(TEveTrackPropagator* m)
245 {
246  fM = m;
247 
248  fMaxR->SetValue(fM->fMaxR);
249  fMaxZ->SetValue(fM->fMaxZ);
250  fMaxOrbits->SetValue(fM->fMaxOrbs);
251  fMaxAng->SetValue(fM->GetMaxAng());
252  fDelta->SetValue(fM->GetDelta());
253 
254  if(fM->fEditPathMarks)
255  {
256  ShowFrame(fPMFrame);
257  fRnrDaughters->SetState(fM->fRnrDaughters ? kButtonDown : kButtonUp);
258  fRnrReferences->SetState(fM->fRnrReferences ? kButtonDown : kButtonUp);
259  fRnrDecay->SetState(fM->fRnrDecay ? kButtonDown : kButtonUp);
260  fRnrCluster2Ds->SetState(fM->fRnrCluster2Ds ? kButtonDown : kButtonUp);
261 
262  fFitDaughters->SetState(fM->fFitDaughters ? kButtonDown : kButtonUp);
263  fFitReferences->SetState(fM->fFitReferences ? kButtonDown : kButtonUp);
264  fFitDecay->SetState(fM->fFitDecay ? kButtonDown : kButtonUp);
265  fFitCluster2Ds->SetState(fM->fFitCluster2Ds ? kButtonDown : kButtonUp);
266  fFitLineSegments->SetState(fM->fFitLineSegments ? kButtonDown : kButtonUp);
267 
268  fPMAtt->SetModel(&fM->fPMAtt);
269  }
270  else
271  {
272  fRefsCont->HideFrame(fPMFrame);
273  }
274 
275  fRnrFV->SetState(fM->fRnrFV ? kButtonDown : kButtonUp);
276  fFVAtt->SetModel(&fM->fFVAtt);
277 
278  fProjTrackBreaking->Select(fM->fProjTrackBreaking, kFALSE);
279  fRnrPTBMarkers->SetState(fM->fRnrPTBMarkers ? kButtonDown : kButtonUp);
280  fPTBAtt->SetModel(&fM->fPTBAtt);
281 }
282 
283 ////////////////////////////////////////////////////////////////////////////////
284 /// Emit "Changed()" signal.
285 
286 void TEveTrackPropagatorSubEditor::Changed()
287 {
288  Emit("Changed()");
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Slot for MaxR.
293 
294 void TEveTrackPropagatorSubEditor::DoMaxR()
295 {
296  fM->SetMaxR(fMaxR->GetValue());
297  Changed();
298 }
299 
300 ////////////////////////////////////////////////////////////////////////////////
301 /// Slot for MaxZ.
302 
303 void TEveTrackPropagatorSubEditor::DoMaxZ()
304 {
305  fM->SetMaxZ(fMaxZ->GetValue());
306  Changed();
307 }
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Slot for MaxOrbits.
311 
312 void TEveTrackPropagatorSubEditor::DoMaxOrbits()
313 {
314  fM->SetMaxOrbs(fMaxOrbits->GetValue());
315  Changed();
316 }
317 
318 ////////////////////////////////////////////////////////////////////////////////
319 /// Slot for MaxAng.
320 
321 void TEveTrackPropagatorSubEditor::DoMaxAng()
322 {
323  fM->SetMaxAng(fMaxAng->GetValue());
324  Changed();
325 }
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 /// Slot for Delta.
329 
330 void TEveTrackPropagatorSubEditor::DoDelta()
331 {
332  fM->SetDelta(fDelta->GetValue());
333  Changed();
334 }
335 
336 ////////////////////////////////////////////////////////////////////////////////
337 /// Slot for FitPM.
338 
339 void TEveTrackPropagatorSubEditor::DoFitPM()
340 {
341  TGButton* b = (TGButton *) gTQSender;
342  TEvePathMark::EType_e type = TEvePathMark::EType_e(b->WidgetId());
343  Bool_t on = b->IsOn();
344 
345  switch(type)
346  {
347  case TEvePathMark::kDaughter:
348  fM->SetFitDaughters(on);
349  break;
350  case TEvePathMark::kReference:
351  fM->SetFitReferences(on);
352  break;
353  case TEvePathMark::kDecay:
354  fM->SetFitDecay(on);
355  break;
356  case TEvePathMark::kCluster2D:
357  fM->SetFitCluster2Ds(on);
358  break;
359  case TEvePathMark::kLineSegment:
360  fM->SetFitLineSegments(on);
361  break;
362 
363  default:
364  break;
365  }
366  Changed();
367 }
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Slot for RnrPM.
371 
372 void TEveTrackPropagatorSubEditor::DoRnrPM()
373 {
374  TGButton * b = (TGButton *) gTQSender;
375  TEvePathMark::EType_e type = TEvePathMark::EType_e(b->WidgetId());
376  Bool_t on = b->IsOn();
377  switch(type){
378  case TEvePathMark::kDaughter:
379  fM->SetRnrDaughters(on);
380  break;
381  case TEvePathMark::kReference:
382  fM->SetRnrReferences(on);
383  break;
384  case TEvePathMark::kDecay:
385  fM->SetRnrDecay(on);
386  break;
387  case TEvePathMark::kCluster2D:
388  fM->SetRnrCluster2Ds(on);
389  break;
390  default:
391  break;
392  }
393  Changed();
394 }
395 
396 ////////////////////////////////////////////////////////////////////////////////
397 /// Slot for RnrFV.
398 
399 void TEveTrackPropagatorSubEditor::DoRnrFV()
400 {
401  fM->SetRnrFV(fRnrFV->IsOn());
402  Changed();
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 /// Slot for PTBMode.
407 
408 void TEveTrackPropagatorSubEditor::DoModePTB(UChar_t mode)
409 {
410  fM->SetProjTrackBreaking(mode);
411  Changed();
412 }
413 
414 ////////////////////////////////////////////////////////////////////////////////
415 /// Slot for RnrPTBMarkers.
416 
417 void TEveTrackPropagatorSubEditor::DoRnrPTB()
418 {
419  fM->SetRnrPTBMarkers(fRnrPTBMarkers->IsOn());
420  Changed();
421 }
422 
423 /** \class TEveTrackPropagatorEditor
424 \ingroup TEve
425 GUI editor for TEveTrackPropagator.
426 It's only a wrapper around a TEveTrackPropagatorSubEditor that holds actual
427 widgets.
428 */
429 
430 ClassImp(TEveTrackPropagatorEditor);
431 
432 ////////////////////////////////////////////////////////////////////////////////
433 /// Constructor.
434 
435 TEveTrackPropagatorEditor::TEveTrackPropagatorEditor(const TGWindow *p,
436  Int_t width, Int_t height,
437  UInt_t options, Pixel_t back) :
438  TGedFrame(p, width, height, options | kVerticalFrame, back),
439  fM(0),
440  fRSSubEditor(0)
441 {
442  MakeTitle("RenderStyle");
443 
444  fRSSubEditor = new TEveTrackPropagatorSubEditor(this);
445  fRSSubEditor->Connect("Changed()", "TEveTrackPropagatorEditor", this, "Update()");
446  AddFrame(fRSSubEditor, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0,0,0));
447 
448  TGVerticalFrame* refsFrame = CreateEditorTabSubFrame("Refs");
449  {
450  TGCompositeFrame *cf = new TGCompositeFrame
451  (refsFrame, 145, 10, kHorizontalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
452  cf->AddFrame(new TGLabel(cf, "PathMarks"),
453  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
454  cf->AddFrame(new TGHorizontal3DLine(cf),
455  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
456  refsFrame->AddFrame(cf, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
457  }
458 
459  // path marks
460  fRSSubEditor->CreateRefsContainer(refsFrame);
461  fRSSubEditor->fPMAtt->SetGedEditor((TGedEditor*)gEve->GetEditor());
462  fRSSubEditor->fFVAtt->SetGedEditor((TGedEditor*)gEve->GetEditor());
463 
464  fRSSubEditor->Connect("Changed()", "TEveTrackPropagatorEditor", this, "Update()");
465 }
466 
467 ////////////////////////////////////////////////////////////////////////////////
468 /// Set model object.
469 
470 void TEveTrackPropagatorEditor::SetModel(TObject* obj)
471 {
472  fM = dynamic_cast<TEveTrackPropagator*>(obj);
473  fRSSubEditor->SetModel(fM);
474 }