GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AgataTrackDisplayEditor.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * FreAgataTrackDisplayEditore Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef Gw_AgataTrackDisplayEditor
25 #endif
26 
27 #ifndef Gw_AgataTrackDisplay
28 #include "AgataTrackDisplay.h"
29 #endif
30 
31 #ifndef ROOT_TG3DLine
32 #include "TG3DLine.h"
33 #endif
34 
35 #ifndef ROOT_TGLabel
36 #include "TGLabel.h"
37 #endif
38 
39 #ifndef ROOT_TGButton
40 #include "TGButton.h"
41 #endif
42 
43 #ifndef ROOT_TGWindow
44 #include "TGWindow.h"
45 #endif
46 
47 #ifndef ROOT_TH1F
48 #include "TH1F.h"
49 #endif
50 
51 #ifndef ROOT_TPad
52 #include "TPad.h"
53 #endif
54 
55 #ifndef ROOT_TStyle
56 #include "TStyle.h"
57 #endif
58 
59 using namespace Gw;
60 
61 //
63 
64 //__________________________________________________________
65 AgataTrackDisplayEditor::AgataTrackDisplayEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
66 : TGedFrame(p, width, height, options| kVerticalFrame, back),
67  fM(0x0),
69 {
70  // default constructor
71 
72  TGVerticalFrame* infoFrame = CreateEditorTabSubFrame("Info");
73 
74  TGCompositeFrame *title = new TGCompositeFrame(infoFrame, 180, 10, kHorizontalFrame | kLHintsExpandX |
75  kFixedWidth | kOwnBackground);
76 
77  title->AddFrame(new TGLabel(title, "AgataTrackDisplay Info"),
78  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
79  title->AddFrame(new TGHorizontal3DLine(title),
80  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
81  infoFrame->AddFrame(title, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
82 
83  TGHorizontalFrame* histoButtFrame = new TGHorizontalFrame(infoFrame);
84  TGTextButton* b = 0x0;
85  b = new TGTextButton(histoButtFrame, "Histo");
86  b->SetToolTipText("Show histogram of track total energy");
87  histoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
88  b->Connect("Clicked()", "Gw::AgataTrackDisplayEditor", this, "DoHisto()");
89 
90  b = new TGTextButton(histoButtFrame, "Range Histo");
91  b->SetToolTipText("Show histogram of track total energy, given range");
92  histoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
93  b->Connect("Clicked()", "Gw::AgataTrackDisplayEditor", this, "DoRangeHisto()");
94 
95  infoFrame->AddFrame(histoButtFrame, new TGLayoutHints(kLHintsExpandX, 1, 1, 2, 5));
96 }
97 
98 //__________________________________________________________
100 {
101  // default destructor
102 }
103 
104 //__________________________________________________________
106 {
107  fM = dynamic_cast<Gw::AgataTrackDisplay*>(obj);
108 }
109 
110 //__________________________________________________________
112 {
113  Int_t min, max;
114  if (fM->GetPalette()) {
115  min = fM->GetPalette()->GetLowLimit();
116  max = fM->GetPalette()->GetHighLimit();
117  } else {
118  fM->ScanMinMaxValues(min, max);
119  }
120 
121  PlotHisto(min, max);
122 }
123 
124 //__________________________________________________________
126 {
127  Int_t min, max;
128  if (fM->GetPalette()) {
129  min = fM->GetPalette()->GetMinVal();
130  max = fM->GetPalette()->GetMaxVal();
131  } else {
132  fM->ScanMinMaxValues(min, max);
133  }
134 
135  PlotHisto(min, max);
136 }
137 
138 //__________________________________________________________
139 void AgataTrackDisplayEditor::PlotHisto(Int_t min, Int_t max)
140 {
141  Int_t nbins = max - min + 1;
142 
143  TH1F* h = new TH1F(Form("%s%s",fM->GetName(), " Energy"), fM->GetTitle(), nbins, min-0.5, max+0.5);
144  h->SetDirectory(0);
145  h->SetBit(kCanDelete);
146 
147  Int_t energy;
148  fM->FirstEnergy(); // first create iterator !
149  while ( (energy = fM->NextEnergy()) != -1) {
150  h->Fill(energy);
151  }
152 
153  gStyle->SetOptStat(1111111);
154  h->Draw();
155  gPad->Modified();
156  gPad->Update();
157 }
Int_t NextEnergy()
return next total energy
TBrowser * b
virtual void SetModel(TObject *obj)
Set model (->AgataTrackDisplay)
AgataTrackDisplay a class to display tracks on event.
void FirstEnergy()
return first total energy
ClassImp(AgataTrackDisplayEditor) AgataTrackDisplayEditor
virtual void DoRangeHisto()
Do histo for total energy of the track (for a given range)
virtual void PlotHisto(Int_t min, Int_t max)
Plot histo.
virtual void DoHisto()
Do histo for total energy of the track.