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