]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 1 | // $Header$ |
2 | ||
3 | #include "TrackEditors.h" | |
4 | #include <Reve/Track.h> | |
5 | ||
a3912979 | 6 | #include <Reve/RGValuators.h> |
7 | ||
5a5a1232 | 8 | #include <TVirtualPad.h> |
9 | #include <TColor.h> | |
10 | ||
11 | #include <TGLabel.h> | |
12 | #include <TGButton.h> | |
13 | #include <TGNumberEntry.h> | |
14 | #include <TGColorSelect.h> | |
15 | #include <TGDoubleSlider.h> | |
c71edfe9 | 16 | #include <TGComboBox.h> |
17 | ||
18 | #include <TGMsgBox.h> | |
19 | #include <TH1F.h> | |
5a5a1232 | 20 | |
ae2ab848 | 21 | #include <TSystem.h> // File input/output for track-count status. |
22 | ||
5a5a1232 | 23 | using namespace Reve; |
24 | ||
25 | //______________________________________________________________________ | |
26 | // TrackListEditor | |
27 | // | |
28 | ||
29 | ClassImp(TrackListEditor) | |
30 | ||
22df2a83 | 31 | TrackListEditor::TrackListEditor(const TGWindow *p, |
32 | Int_t width, Int_t height, | |
33 | UInt_t options, Pixel_t back) : | |
34 | TGedFrame(p, width, height, options | kVerticalFrame, back), | |
35 | ||
36 | fTC (0), | |
37 | ||
38 | fMaxR(0), | |
39 | fMaxZ(0), | |
40 | fMaxOrbits(0), | |
41 | fMinAng(0), | |
42 | fDelta(0), | |
43 | ||
44 | fRnrTracks(0), | |
ec019a35 | 45 | fWidthCombo(0), |
46 | fStyleCombo(0), | |
47 | ||
22df2a83 | 48 | fRnrMarkers(0), |
49 | ||
50 | fPMFrame(0), | |
51 | fFitDaughters(0), | |
52 | fFitReferences(0), | |
53 | fFitDecay(0), | |
54 | fRnrDaughters(0), | |
55 | fRnrReferences(0), | |
56 | fRnrDecay(0), | |
57 | ||
f93070d3 | 58 | fPtRange(0), |
59 | fPRange(0) | |
5a5a1232 | 60 | { |
5a5a1232 | 61 | MakeTitle("TrackList"); |
f1d52824 | 62 | Int_t labelW = 67; |
63 | ||
64 | // --- Limits | |
65 | ||
66 | fMaxR = new RGValuator(this, "Max R:", 110, 0); | |
67 | fMaxR->SetLabelWidth(labelW); | |
68 | fMaxR->SetNELength(6); | |
69 | fMaxR->Build(); | |
70 | fMaxR->SetLimits(0.1, 1000, 100, TGNumberFormat::kNESRealOne); | |
71 | fMaxR->SetToolTip("Maximum radius to which the tracks will be drawn."); | |
72 | fMaxR->Connect("ValueSet(Double_t)", "Reve::TrackListEditor", this, "DoMaxR()"); | |
73 | AddFrame(fMaxR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
74 | ||
75 | fMaxZ = new RGValuator(this, "Max Z:", 110, 0); | |
76 | fMaxZ->SetLabelWidth(labelW); | |
77 | fMaxZ->SetNELength(6); | |
78 | fMaxZ->Build(); | |
79 | fMaxZ->SetLimits(0.1, 2000, 100, TGNumberFormat::kNESRealOne); | |
80 | fMaxZ->SetToolTip("Maximum z-coordinate to which the tracks will be drawn."); | |
81 | fMaxZ->Connect("ValueSet(Double_t)", "Reve::TrackListEditor", this, "DoMaxZ()"); | |
82 | AddFrame(fMaxZ, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
5a5a1232 | 83 | |
84 | { | |
85 | TGHorizontalFrame* f = new TGHorizontalFrame(this); | |
86 | TGLabel *l = new TGLabel(f, "Max Orbits:"); | |
87 | f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 0, 2, 1, 1)); | |
88 | fMaxOrbits = new TGNumberEntry(f, 0., 6, -1, | |
89 | TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive, | |
90 | TGNumberFormat::kNELLimitMinMax, 0.1, 100.0); | |
91 | fMaxOrbits->GetNumberEntry()->SetToolTipText("Maximal angular path of tracks' orbits (1 ~ 2Pi)."); | |
92 | f->AddFrame(fMaxOrbits, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1)); | |
93 | fMaxOrbits->Associate(f); | |
94 | fMaxOrbits->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoMaxOrbits()"); | |
95 | AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
96 | } | |
97 | ||
98 | { | |
99 | TGHorizontalFrame* f = new TGHorizontalFrame(this); | |
100 | TGLabel *l = new TGLabel(f, "Min Angle:"); | |
101 | f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 3, 2, 1, 1)); | |
102 | fMinAng = new TGNumberEntry(f, 0., 6, -1, | |
103 | TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive, | |
104 | TGNumberFormat::kNELLimitMinMax, 1, 180.0); | |
105 | fMinAng->GetNumberEntry()->SetToolTipText("Minimal angular step between two helix points."); | |
106 | f->AddFrame(fMinAng, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1)); | |
107 | fMinAng->Associate(f); | |
108 | fMinAng->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoMinAng()"); | |
109 | AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
110 | } | |
111 | ||
112 | { | |
113 | TGHorizontalFrame* f = new TGHorizontalFrame(this); | |
114 | TGLabel *l = new TGLabel(f, "Delta:"); | |
115 | f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 32, 2, 1, 1)); | |
116 | fDelta = new TGNumberEntry(f, 0., 6, -1, | |
694e6973 | 117 | TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAPositive, |
f1d52824 | 118 | TGNumberFormat::kNELLimitMinMax, 0.001, 100.0); |
5a5a1232 | 119 | fDelta->GetNumberEntry()->SetToolTipText("Maximal error at the mid-point of the line connecting to helix points."); |
120 | f->AddFrame(fDelta, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1)); | |
121 | fDelta->Associate(f); | |
122 | fDelta->Connect("ValueSet(Long_t)", "Reve::TrackListEditor", this, "DoDelta()"); | |
123 | AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
124 | } | |
125 | ||
511684d7 | 126 | // --- Selectors |
5a5a1232 | 127 | |
511684d7 | 128 | fPtRange = new RGDoubleValuator(this,"Pt Range", 200, 0); |
129 | fPtRange->SetNELength(6); | |
130 | fPtRange->Build(); | |
131 | fPtRange->GetSlider()->SetWidth(224); | |
22df2a83 | 132 | fPtRange->SetLimits(0, 10, TGNumberFormat::kNESRealTwo); |
511684d7 | 133 | fPtRange->Connect("ValueSet()", |
134 | "Reve::TrackListEditor", this, "DoPtRange()"); | |
135 | AddFrame(fPtRange, new TGLayoutHints(kLHintsTop, 1, 1, 4, 1)); | |
136 | ||
f93070d3 | 137 | fPRange = new RGDoubleValuator(this,"P Range", 200, 0); |
138 | fPRange->SetNELength(6); | |
139 | fPRange->Build(); | |
140 | fPRange->GetSlider()->SetWidth(224); | |
141 | fPRange->SetLimits(0, 100, TGNumberFormat::kNESRealTwo); | |
142 | fPRange->Connect("ValueSet()", | |
ec019a35 | 143 | "Reve::TrackListEditor", this, "DoPRange()"); |
f93070d3 | 144 | AddFrame(fPRange, new TGLayoutHints(kLHintsTop, 1, 1, 4, 1)); |
145 | ||
511684d7 | 146 | // --- Rendering control |
2074deef | 147 | { |
ec019a35 | 148 | TGHorizontalFrame* ft = new TGHorizontalFrame(this); |
149 | fRnrTracks = new TGCheckButton(ft, "Render tracks"); | |
150 | ft->AddFrame(fRnrTracks, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 0)); | |
2074deef | 151 | fRnrTracks->Connect |
152 | ("Toggled(Bool_t)", "Reve::TrackListEditor", this, "DoRnrTracks()"); | |
ec019a35 | 153 | AddFrame(ft, new TGLayoutHints(kLHintsTop, 1, 1, 3, 0)); |
154 | ||
155 | TGHorizontalFrame* f = new TGHorizontalFrame(this); | |
156 | TGLabel *wl = new TGLabel(f, "Width:"); | |
157 | f->AddFrame(wl, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 3, 2, 1, 1)); | |
2074deef | 158 | fWidthCombo = new TGLineWidthComboBox(f); |
ec019a35 | 159 | fWidthCombo->Resize(70, 18); |
2074deef | 160 | f->AddFrame(fWidthCombo, new TGLayoutHints(kLHintsLeft, 8, 1, 0, 0)); |
2074deef | 161 | fWidthCombo->Connect |
162 | ("Selected(Int_t)", "Reve::TrackListEditor", this, "DoLineWidth(Int_t)"); | |
ec019a35 | 163 | |
164 | TGLabel *sl = new TGLabel(f, "Style:"); | |
165 | f->AddFrame(sl, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 6, 2, 1, 1)); | |
166 | fStyleCombo = new TGLineStyleComboBox(f); | |
167 | fStyleCombo->Resize(70, 18); | |
168 | f->AddFrame(fStyleCombo, new TGLayoutHints(kLHintsLeft, 8, 1, 0, 0)); | |
169 | fStyleCombo->Connect | |
170 | ("Selected(Int_t)", "Reve::TrackListEditor", this, "DoLineStyle(Int_t)"); | |
171 | ||
172 | ||
2074deef | 173 | AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 3, 0)); |
174 | } | |
5a5a1232 | 175 | |
511684d7 | 176 | // --- Kinematics fitting |
177 | ||
178 | fPMFrame = new TGHorizontalFrame(this); | |
179 | { | |
180 | TGGroupFrame* fitPM = new TGGroupFrame(fPMFrame, "PathMarks:", kLHintsTop | kLHintsCenterX); | |
181 | fitPM->SetTitlePos(TGGroupFrame::kLeft); | |
182 | fPMFrame->AddFrame( fitPM, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3)); | |
183 | ||
184 | TGMatrixLayout *ml = new TGMatrixLayout(fitPM, 0,1,6); | |
185 | fitPM->SetLayoutManager(ml); | |
186 | ||
89083271 | 187 | fFitDaughters = new TGCheckButton(fitPM, "Fit Daughters", PathMark::Daughter); |
188 | fFitReferences = new TGCheckButton(fitPM, "Fit Refs", PathMark::Reference); | |
189 | fFitDecay = new TGCheckButton(fitPM, "Fit Decay", PathMark::Decay); | |
511684d7 | 190 | |
191 | fitPM->AddFrame(fFitDaughters); | |
192 | fitPM->AddFrame(fFitReferences); | |
193 | fitPM->AddFrame(fFitDecay); | |
194 | ||
195 | fFitDecay->Connect("Clicked()","Reve::TrackListEditor", this, "DoFitPM()"); | |
196 | fFitReferences->Connect("Clicked()","Reve::TrackListEditor", this, "DoFitPM()"); | |
197 | fFitDaughters->Connect("Clicked()","Reve::TrackListEditor", this, "DoFitPM()"); | |
198 | } | |
199 | { | |
200 | TGGroupFrame* rnrPM = new TGGroupFrame(fPMFrame, "PathMarks:", kLHintsTop | kLHintsCenterX); | |
201 | rnrPM->SetTitlePos(TGGroupFrame::kLeft); | |
202 | fPMFrame->AddFrame( rnrPM, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3)); | |
203 | ||
204 | TGMatrixLayout *ml = new TGMatrixLayout(rnrPM, 0,1,6); | |
205 | rnrPM->SetLayoutManager(ml); | |
206 | ||
207 | fRnrDaughters = new TGCheckButton(rnrPM, "Rnr Daughters", PathMark::Daughter); | |
208 | fRnrReferences = new TGCheckButton(rnrPM, "Rnr Refs", PathMark::Reference); | |
209 | fRnrDecay = new TGCheckButton(rnrPM, "Rnr Decay", PathMark::Decay); | |
210 | ||
211 | rnrPM->AddFrame(fRnrDaughters); | |
212 | rnrPM->AddFrame(fRnrReferences); | |
213 | rnrPM->AddFrame(fRnrDecay); | |
214 | ||
215 | fRnrDecay->Connect("Clicked()","Reve::TrackListEditor", this, "DoRnrPM()"); | |
216 | fRnrReferences->Connect("Clicked()","Reve::TrackListEditor", this, "DoRnrPM()"); | |
217 | fRnrDaughters->Connect("Clicked()","Reve::TrackListEditor", this, "DoRnrPM()"); | |
218 | } | |
219 | AddFrame(fPMFrame, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
220 | ||
5a5a1232 | 221 | fRnrMarkers = new TGCheckButton(this, "Render markers"); |
2074deef | 222 | AddFrame(fRnrMarkers, new TGLayoutHints(kLHintsTop, 3, 1, 2, 0)); |
5a5a1232 | 223 | fRnrMarkers->Connect |
224 | ("Toggled(Bool_t)", | |
225 | "Reve::TrackListEditor", this, "DoRnrMarkers()"); | |
226 | ||
5a5a1232 | 227 | } |
228 | ||
229 | TrackListEditor::~TrackListEditor() | |
230 | {} | |
231 | ||
232 | /**************************************************************************/ | |
233 | ||
a8600b56 | 234 | void TrackListEditor::SetModel(TObject* obj) |
5a5a1232 | 235 | { |
a8600b56 | 236 | fTC = dynamic_cast<TrackList*>(obj); |
5a5a1232 | 237 | |
f1d52824 | 238 | fMaxR->SetValue(fTC->GetMaxR()); |
239 | fMaxZ->SetValue(fTC->GetMaxZ()); | |
5a5a1232 | 240 | fMaxOrbits->SetNumber(fTC->GetMaxOrbs()); |
241 | fMinAng->SetNumber(fTC->GetMinAng()); | |
242 | fDelta->SetNumber(fTC->GetDelta()); | |
243 | ||
2074deef | 244 | fWidthCombo->Select(fTC->GetWidth()); |
ec019a35 | 245 | fStyleCombo->Select(fTC->GetStyle()); |
2074deef | 246 | |
5a5a1232 | 247 | fRnrTracks->SetState(fTC->GetRnrTracks() ? kButtonDown : kButtonUp); |
511684d7 | 248 | |
249 | if(fTC->GetEditPathMarks()) | |
250 | { | |
251 | HideFrame(fRnrMarkers); | |
252 | ShowFrame(fPMFrame); | |
253 | fRnrDaughters->SetState(fTC->GetRnrDaughters() ? kButtonDown : kButtonUp); | |
254 | fRnrReferences->SetState(fTC->GetRnrReferences() ? kButtonDown : kButtonUp); | |
255 | fRnrDecay->SetState(fTC->GetRnrDecay() ? kButtonDown : kButtonUp); | |
256 | ||
257 | fFitDaughters->SetState(fTC->GetFitDaughters() ? kButtonDown : kButtonUp); | |
258 | fFitReferences->SetState(fTC->GetFitReferences() ? kButtonDown : kButtonUp); | |
259 | fFitDecay->SetState(fTC->GetFitDecay() ? kButtonDown : kButtonUp); | |
260 | } | |
261 | else | |
262 | { | |
263 | HideFrame(fPMFrame); | |
264 | ShowFrame(fRnrMarkers); | |
265 | fRnrMarkers->SetState(fTC->GetRnrMarkers() ? kButtonDown : kButtonUp); | |
266 | } | |
22df2a83 | 267 | fPtRange->SetValues(fTC->GetMinPt(), fTC->GetMaxPt()); |
f93070d3 | 268 | fPRange->SetValues(fTC->GetMinP(), fTC->GetMaxP()); |
5a5a1232 | 269 | } |
270 | ||
271 | /**************************************************************************/ | |
272 | ||
273 | void TrackListEditor::DoMaxR() | |
274 | { | |
f1d52824 | 275 | fTC->SetMaxR(fMaxR->GetValue()); |
5a5a1232 | 276 | Update(); |
277 | } | |
278 | ||
279 | void TrackListEditor::DoMaxZ() | |
280 | { | |
f1d52824 | 281 | fTC->SetMaxZ(fMaxZ->GetValue()); |
5a5a1232 | 282 | Update(); |
283 | } | |
284 | ||
285 | void TrackListEditor::DoMaxOrbits() | |
286 | { | |
287 | fTC->SetMaxOrbs(fMaxOrbits->GetNumber()); | |
288 | Update(); | |
289 | } | |
290 | ||
291 | void TrackListEditor::DoMinAng() | |
292 | { | |
293 | fTC->SetMinAng(fMinAng->GetNumber()); | |
294 | Update(); | |
295 | } | |
296 | ||
297 | void TrackListEditor::DoDelta() | |
298 | { | |
299 | fTC->SetDelta(fDelta->GetNumber()); | |
300 | Update(); | |
301 | } | |
302 | ||
303 | /**************************************************************************/ | |
304 | ||
2074deef | 305 | void TrackListEditor::DoLineWidth(Int_t width) |
306 | { | |
307 | fTC->SetWidth(width); | |
308 | Update(); | |
309 | } | |
310 | ||
311 | /**************************************************************************/ | |
ec019a35 | 312 | |
313 | void TrackListEditor::DoLineStyle(Int_t style) | |
314 | { | |
315 | fTC->SetStyle(style); | |
316 | Update(); | |
317 | } | |
318 | ||
319 | /**************************************************************************/ | |
2074deef | 320 | |
5a5a1232 | 321 | void TrackListEditor::DoRnrTracks() |
322 | { | |
323 | fTC->SetRnrTracks(fRnrTracks->IsOn()); | |
324 | Update(); | |
325 | } | |
326 | ||
327 | void TrackListEditor::DoRnrMarkers() | |
328 | { | |
329 | fTC->SetRnrMarkers(fRnrMarkers->IsOn()); | |
330 | Update(); | |
331 | } | |
332 | ||
333 | /**************************************************************************/ | |
334 | ||
511684d7 | 335 | void TrackListEditor::DoFitPM() |
5a5a1232 | 336 | { |
511684d7 | 337 | TGButton* b = (TGButton *) gTQSender; |
338 | PathMark::Type_e type = PathMark::Type_e(b->WidgetId()); | |
339 | Bool_t on = b->IsOn(); | |
340 | ||
341 | switch(type) | |
342 | { | |
343 | case PathMark::Daughter: | |
344 | fTC->SetFitDaughters(on); | |
345 | break; | |
346 | case PathMark::Reference: | |
347 | fTC->SetFitReferences(on); | |
348 | break; | |
349 | case PathMark::Decay: | |
350 | fTC->SetFitDecay(on); | |
351 | break; | |
352 | default: | |
353 | break; | |
354 | } | |
5a5a1232 | 355 | Update(); |
356 | } | |
357 | ||
511684d7 | 358 | void TrackListEditor::DoRnrPM() |
5a5a1232 | 359 | { |
511684d7 | 360 | TGButton * b = (TGButton *) gTQSender; |
361 | PathMark::Type_e type = PathMark::Type_e(b->WidgetId()); | |
362 | Bool_t on = b->IsOn(); | |
363 | switch(type){ | |
364 | case PathMark::Daughter: | |
365 | fTC->SetRnrDaughters(on); | |
366 | break; | |
367 | case PathMark::Reference: | |
368 | fTC->SetRnrReferences(on); | |
369 | break; | |
370 | case PathMark::Decay: | |
371 | fTC->SetRnrDecay(on); | |
372 | break; | |
373 | ||
374 | default: | |
375 | break; | |
376 | ||
377 | } | |
5a5a1232 | 378 | Update(); |
379 | } | |
5a5a1232 | 380 | /**************************************************************************/ |
381 | ||
a3912979 | 382 | void TrackListEditor::DoPtRange() |
5a5a1232 | 383 | { |
511684d7 | 384 | |
a3912979 | 385 | fTC->SelectByPt(fPtRange->GetMin(), fPtRange->GetMax()); |
a8600b56 | 386 | Update(); |
5a5a1232 | 387 | } |
6bd69299 | 388 | |
389 | ||
f93070d3 | 390 | void TrackListEditor::DoPRange() |
391 | { | |
392 | ||
393 | fTC->SelectByP(fPRange->GetMin(), fPRange->GetMax()); | |
394 | Update(); | |
395 | } | |
396 | ||
397 | ||
6bd69299 | 398 | |
399 | /**************************************************************************/ | |
400 | /**************************************************************************/ | |
401 | /**************************************************************************/ | |
402 | ||
403 | #include <TCanvas.h> | |
404 | #include <TGLViewer.h> | |
405 | #include <Reve/RGTopFrame.h> | |
406 | ||
407 | //______________________________________________________________________ | |
408 | // TrackCounterEditor | |
409 | // | |
410 | ||
411 | ClassImp(TrackCounterEditor) | |
412 | ||
413 | TrackCounterEditor::TrackCounterEditor(const TGWindow *p, Int_t width, Int_t height, | |
414 | UInt_t options, Pixel_t back) : | |
415 | TGedFrame(p, width, height, options | kVerticalFrame, back), | |
416 | fM(0), | |
417 | fClickAction (0), | |
5ea94a5a | 418 | fInfoLabel (0), |
419 | fEventId (0) | |
6bd69299 | 420 | { |
421 | MakeTitle("TrackCounter"); | |
422 | ||
423 | Int_t labelW = 42; | |
424 | ||
425 | { // ClickAction | |
426 | TGHorizontalFrame* f = new TGHorizontalFrame(this); | |
427 | TGLabel* lab = new TGLabel(f, "Click:"); | |
428 | f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2)); | |
429 | fClickAction = new TGComboBox(f); | |
430 | fClickAction->AddEntry("Print", 0); | |
431 | fClickAction->AddEntry("Toggle", 1); | |
432 | TGListBox* lb = fClickAction->GetListBox(); | |
433 | lb->Resize(lb->GetWidth(), 2*16); | |
434 | fClickAction->Resize(70, 20); | |
435 | fClickAction->Connect("Selected(Int_t)", "Reve::TrackCounterEditor", this, | |
436 | "DoClickAction(Int_t)"); | |
437 | f->AddFrame(fClickAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1)); | |
438 | ||
439 | AddFrame(f); | |
440 | } | |
441 | ||
442 | { // Status | |
443 | TGHorizontalFrame* f = new TGHorizontalFrame(this); | |
444 | TGLabel* lab = new TGLabel(f, "Status:"); | |
445 | f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2)); | |
446 | ||
447 | fInfoLabel = new TGLabel(f); | |
448 | f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2)); | |
449 | ||
450 | AddFrame(f); | |
451 | } | |
452 | ||
453 | { | |
454 | TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth); | |
455 | ||
456 | TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth); | |
c71edfe9 | 457 | TGLabel* l = new TGLabel(g, "View:"); |
6bd69299 | 458 | g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0)); |
459 | f->AddFrame(g); | |
460 | ||
461 | TGTextButton* b; | |
462 | ||
463 | b = new TGTextButton(f, "Orto XY"); | |
464 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
465 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoOrtoXY()"); | |
466 | ||
467 | b = new TGTextButton(f, "Orto ZY"); | |
468 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
469 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoOrtoZY()"); | |
470 | ||
471 | b = new TGTextButton(f, "Persp"); | |
472 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
473 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoPersp()"); | |
474 | ||
475 | AddFrame(f); | |
476 | } | |
477 | ||
478 | { | |
479 | TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth); | |
480 | ||
481 | TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth); | |
c71edfe9 | 482 | TGLabel* l = new TGLabel(g, "Event:"); |
6bd69299 | 483 | g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0)); |
484 | f->AddFrame(g); | |
485 | ||
486 | TGTextButton* b; | |
487 | ||
488 | b = new TGTextButton(f, "Prev"); | |
489 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
490 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoPrev()"); | |
491 | ||
16100de8 | 492 | fEventId = new TGNumberEntry(f, 0, 3, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, |
5ea94a5a | 493 | TGNumberFormat::kNELLimitMinMax, 0, 1000); |
494 | f->AddFrame(fEventId, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
495 | fEventId->Connect("ValueSet(Long_t)", "Reve::TrackCounterEditor", this, "DoSetEvent()"); | |
496 | ||
6bd69299 | 497 | b = new TGTextButton(f, "Next"); |
498 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
499 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoNext()"); | |
500 | ||
501 | AddFrame(f); | |
502 | } | |
503 | ||
c71edfe9 | 504 | { |
505 | TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth); | |
506 | ||
507 | TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth); | |
508 | TGLabel* l = new TGLabel(g, "Report:"); | |
509 | g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0)); | |
510 | f->AddFrame(g); | |
511 | ||
512 | TGTextButton* b; | |
513 | ||
514 | b = new TGTextButton(f, "Print"); | |
515 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
516 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoPrintReport()"); | |
517 | ||
518 | b = new TGTextButton(f, "File"); | |
519 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
520 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoFileReport()"); | |
521 | ||
522 | AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0)); | |
523 | } | |
524 | { | |
525 | TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth); | |
526 | ||
527 | TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth); | |
528 | TGLabel* l = new TGLabel(g, "Histos:"); | |
529 | g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0)); | |
530 | f->AddFrame(g); | |
531 | ||
532 | TGTextButton* b; | |
533 | ||
534 | b = new TGTextButton(f, "Show"); | |
535 | f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
536 | b->Connect("Clicked()", "Reve::TrackCounterEditor", this, "DoShowHistos()"); | |
537 | ||
538 | AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); | |
539 | } | |
540 | ||
6bd69299 | 541 | } |
542 | ||
543 | TrackCounterEditor::~TrackCounterEditor() | |
544 | {} | |
545 | ||
546 | /**************************************************************************/ | |
547 | ||
548 | void TrackCounterEditor::SetModel(TObject* obj) | |
549 | { | |
550 | fM = dynamic_cast<TrackCounter*>(obj); | |
551 | ||
552 | fClickAction->Select(fM->fClickAction, kFALSE); | |
553 | fInfoLabel->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracks, fM->fGoodTracks)); | |
5ea94a5a | 554 | fEventId->SetNumber(fM->GetEventId()); |
6bd69299 | 555 | } |
556 | ||
557 | /**************************************************************************/ | |
558 | ||
6bd69299 | 559 | void TrackCounterEditor::DoOrtoXY() |
560 | { | |
ae2ab848 | 561 | gReve->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY) ; |
6bd69299 | 562 | } |
563 | ||
564 | void TrackCounterEditor::DoOrtoZY() | |
565 | { | |
ae2ab848 | 566 | gReve->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZOY) ; |
6bd69299 | 567 | } |
568 | ||
569 | void TrackCounterEditor::DoPersp() | |
570 | { | |
ae2ab848 | 571 | gReve->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ) ; |
6bd69299 | 572 | } |
573 | ||
574 | /**************************************************************************/ | |
575 | ||
576 | void TrackCounterEditor::DoPrev() | |
577 | { | |
578 | Reve::Macro("event_prev.C"); | |
579 | gReve->EditRenderElement(fM); | |
6bd69299 | 580 | } |
581 | ||
582 | void TrackCounterEditor::DoNext() | |
583 | { | |
584 | Reve::Macro("event_next.C"); | |
585 | gReve->EditRenderElement(fM); | |
c71edfe9 | 586 | } |
587 | ||
5ea94a5a | 588 | void TrackCounterEditor::DoSetEvent() |
589 | { | |
590 | Reve::LoadMacro("event_goto.C"); | |
591 | gROOT->ProcessLine(Form("event_goto(%d);", (Int_t) fEventId->GetNumber())); | |
592 | gReve->EditRenderElement(fM); | |
593 | } | |
594 | ||
c71edfe9 | 595 | /**************************************************************************/ |
6bd69299 | 596 | |
c71edfe9 | 597 | void TrackCounterEditor::DoPrintReport() |
598 | { | |
599 | fM->OutputEventTracks(); | |
600 | } | |
601 | ||
602 | void TrackCounterEditor::DoFileReport() | |
603 | { | |
604 | TString file(Form("ev-report-%03d.txt", fM->GetEventId())); | |
605 | if (gSystem->AccessPathName(file) == kFALSE) | |
606 | { | |
607 | Int_t ret; | |
608 | new TGMsgBox(fClient->GetRoot(), GetMainFrame(), | |
609 | "File Exist", | |
610 | Form("Event record for event %d already exist.\n Replace?", fM->GetEventId()), | |
611 | kMBIconQuestion, kMBYes | kMBNo, &ret); | |
612 | if (ret == kMBNo) | |
613 | return; | |
614 | } | |
615 | FILE* out = fopen(file, "w"); | |
616 | fM->OutputEventTracks(out); | |
617 | fclose(out); | |
6bd69299 | 618 | } |
619 | ||
c71edfe9 | 620 | void TrackCounterEditor::DoShowHistos() |
621 | { | |
622 | TH1F* hcnt = new TH1F("cnt", "Primeries per event", 41, -0.5, 40.5); | |
623 | TH1F* hchg = new TH1F("chg", "Primary charge", 3, -1.5, 1.5); | |
624 | TH1F* hpt = new TH1F("pt", "pT distribution", 40, 0.0, 8.0); | |
625 | TH1F* heta = new TH1F("eta", "eta distribution", 40, -1.0, 1.0); | |
626 | ||
627 | Int_t nn; // fscanf return value | |
628 | ||
629 | for (Int_t i=0; i<1000; ++i) | |
630 | { | |
631 | TString file(Form("ev-report-%03d.txt", i)); | |
632 | if (gSystem->AccessPathName(file) == kFALSE) | |
633 | { | |
634 | Int_t ev, ntr; | |
635 | FILE* f = fopen(file, "read"); | |
636 | nn = fscanf(f, "Event = %d Ntracks = %d", &ev, &ntr); | |
637 | if (nn != 2) { printf("SAFR1 %d\n", nn); fclose(f); return; } | |
638 | hcnt->Fill(ntr); | |
639 | for (Int_t t=0; t<ntr; ++t) | |
640 | { | |
641 | Int_t id, chg; | |
642 | Float_t pt, eta; | |
643 | nn = fscanf(f, "%d: chg=%d pt=%f eta=%f", &id, &chg, &pt, &eta); | |
644 | if (nn != 4) { printf("SAFR2 %d\n", nn); fclose(f); return; } | |
645 | hchg->Fill(chg); | |
646 | hpt ->Fill(pt); | |
647 | heta->Fill(eta); | |
648 | } | |
649 | fclose(f); | |
650 | } | |
651 | } | |
652 | ||
653 | TCanvas* c; | |
654 | if (gPad == 0 || gPad->GetCanvas()->IsEditable() == kFALSE) { | |
655 | c = new TCanvas("Scanwas", "Scanning Results", 800, 600); | |
656 | } else { | |
657 | c = gPad->GetCanvas(); | |
658 | c->Clear(); | |
659 | } | |
660 | c->Divide(2, 2); | |
661 | ||
662 | c->cd(1); hcnt->Draw(); | |
663 | c->cd(2); hchg->Draw(); | |
664 | c->cd(3); hpt ->Draw(); | |
665 | c->cd(4); heta->Draw(); | |
666 | ||
667 | c->Modified(); | |
668 | c->Update(); | |
669 | } | |
670 | ||
671 | ||
6bd69299 | 672 | /**************************************************************************/ |
673 | ||
674 | void TrackCounterEditor::DoClickAction(Int_t mode) | |
675 | { | |
676 | fM->SetClickAction(mode); | |
677 | } |