GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeakCreator.h
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  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef Gw_PeakCreator
24 #define Gw_PeakCreator
25 
26 #include "GwLogMessage.h"
27 #include "Peak1D.h"
28 
29 #include "TF1.h"
30 #include "TGraph.h"
31 
32 class TSeqCollection;
33 class TList;
34 class TCanvas;
35 class TH1;
36 class TFormula;
37 class TVirtualPad;
38 
39 namespace Gw {
40 
44 class PeakCreator : public TObject
45 {
46 private:
48  static TList gPeakCreatorList;
50  static TF1 *gDefaultFWHM;
51 
52 private:
53  TGraph *fEfficiencyGraph;
54  TF1 *fEfficiencyFunc;
55 
56  Float_t fRefArea;
57  Float_t fRefAreaError;
58  Float_t fEffRelError; //Relative error on afficiency curves
59 
60 public:
61  void SetRefArea(Float_t a, Float_t ea){fRefArea = a; fRefAreaError = ea;}
62 
63 public:
64  TGraph *GetEfficicencyGraph(){return fEfficiencyGraph;}
65  void SetEfficiencyGraph(TGraph *gr, Float_t EffRelError = 0.1){fEfficiencyGraph = gr;fEffRelError = EffRelError;}
66 
67  TF1 *GetEfficicencyFunc(){return fEfficiencyFunc;}
68  void SetEfficiencyFunc(TF1 *f, Float_t EffRelError = 0.1){fEfficiencyFunc = f;fEffRelError = EffRelError;}
69 
70 private:
72  Peak1D *fDefaultPeak1D;
74  Bool_t fIsCollecting;
76  Bool_t fIsGate;
77 
78 private:
80  TF1 *fDefaultPeakFWHM;
81 
82 private:
84  TCanvas *fCanvas;
85 
86 private:
87  Int_t fLastX; // last x event position
88  Int_t fLastY; // last y event position
89  Int_t fLastMouseX; // last x mouse position
90  Int_t fLastMouseY; // last y mouse position
91 
92 private:
93  bool fIsHelpsPrintActive;
94 public:
95  virtual void SetHelpsPrintActive(bool on) {fIsHelpsPrintActive = on;}
96  virtual bool IsHelpsPrintActive() {return fIsHelpsPrintActive;}
97 
98  virtual void AddCreatorToList() { gPeakCreatorList.Add(this);}
99 
101  virtual Int_t GetLastX() const
102  {return fLastX;}
103  virtual Int_t GetLastY() const
104  {return fLastY;}
105  virtual void SetLastXY(Int_t lastX, Int_t lastY)
106  {fLastX = lastX; fLastY = lastY;}
107 
108 protected:
109  mutable LogMessage fLog; // log message
110 
111 protected:
113 
116  virtual void AddPointToPolyline(Double_t x, Double_t y, TVirtualPad *pad = 0x0);
118 
121  static TVirtualPad *PadforAction(TVirtualPad *pad = 0x0);
122 
123 private:
124  PeakCreator(TCanvas *);
125 
126 public:
127  // change the global formula
128  // static void SetGlobalPeakFWHM(const TF1 *);
129  // to get the global formula
130  static const TF1 *GetConstGlobalPeakFWHM();
131  static TF1 *GetGlobalPeakFWHM();
132 
133 public:
134  PeakCreator();
135  virtual ~PeakCreator();
136 
137  virtual void Connect();
138  virtual void Disconnect();
139 
140 
142  void SetGateMode(Bool_t ngate = true); //*TOGGLE* *GETTER=IsGate
143  Bool_t IsGate() const
144  { return fDefaultPeak1D->GetDrawAs() == Peak1D::kGate; }
145 
147  void Collect(Bool_t do_collect = true); //*TOGGLE* *GETTER=IsCollect
148  Bool_t IsCollect()
149  { return fIsCollecting; }
150 
153  {return fDefaultPeak1D;}
154 
156  //const TF1 *GetPeakFWHM();
157 
160  { return fDefaultPeakFWHM; }
162  { return fDefaultPeakFWHM; }
163 
164  // to change the definition of the formula for the width
169  void SetDefaultPeakFWHM( const char * fname = "PCG_FWHM" ) ; //*MENU*
170 
171  const TCanvas *GetCanvas() const
172  { return fCanvas; }
173 
175  static PeakCreator *AddPeakCreator(TVirtualPad *pad = 0x0);
176 
178  static PeakCreator *IsPeakCreator(TVirtualPad *pad = 0x0);
179 
181 
186  virtual BasePeak* CreatePeak(const TH1* h, Double_t x, Option_t *opt = "");
187 
189 
192  virtual BasePeak* CreatePeak(Double_t x, Option_t *opt = "", TVirtualPad *pad = 0x0);
193 
195  // virtual TH1* CreateBackground(const TH1* h, TPolyLine *pline = 0x0);
196 
198  virtual void Delete(Option_t *opt = "")
199  { TObject::Delete(opt); }
200 
202  virtual void Clear(Option_t* = "");
203 
205  void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* select);
206 
208  static void HandleRefresh(TCanvas *canvas = 0x0);
209 
210  ClassDef(PeakCreator, 0); // To creat peak/gates in a Pad
211 };
212 
213 } // end namespace
214 
215 #endif
void SetDefaultPeakFWHM(const char *fname="PCG_FWHM")
BasePeak * DefaultPeak()
access to the peak used to create other peaks (through the Clone method)
Definition: PeakCreator.h:152
virtual void Delete(Option_t *opt="")
It creates a peak at position x,y for the spectrum.
Definition: PeakCreator.h:198
const TF1 * GetConstDefaultPeakFWHM()
to get the current global FWHM definition
Definition: PeakCreator.h:159
virtual EDrawAs GetDrawAs() const
to know the current display mode
Definition: Peak1D.h:228
void SetEfficiencyGraph(TGraph *gr, Float_t EffRelError=0.1)
Definition: PeakCreator.h:65
virtual void AddCreatorToList()
Definition: PeakCreator.h:98
void SetEfficiencyFunc(TF1 *f, Float_t EffRelError=0.1)
Definition: PeakCreator.h:68
TF1 * GetDefaultPeakFWHM()
Definition: PeakCreator.h:161
void SetRefArea(Float_t a, Float_t ea)
Definition: PeakCreator.h:61
Base class for a Log message.
Definition: GwLogMessage.h:94
static PeakCreator * AddPeakCreator(TVirtualPad *pad=0x0)
add a peak creator to the given pad. Current pad if argument is 0x0
static void HandleRefresh(TCanvas *canvas=0x0)
Handle modification of the range of the pad.
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *select)
Handle Movement.
header file for GwLogMessage.cpp
virtual void Connect()
virtual void SetHelpsPrintActive(bool on)
Definition: PeakCreator.h:95
Bool_t IsCollect()
Definition: PeakCreator.h:148
virtual Int_t GetLastY() const
Definition: PeakCreator.h:103
virtual ~PeakCreator()
const TCanvas * GetCanvas() const
Definition: PeakCreator.h:171
static const TF1 * GetConstGlobalPeakFWHM()
static TVirtualPad * PadforAction(TVirtualPad *pad=0x0)
Get Pad.
LogMessage fLog
Definition: PeakCreator.h:109
void SetGateMode(Bool_t ngate=true)
if true, peak are collected on key board actions (type h for help)
void Collect(Bool_t do_collect=true)
if true, peak are collected on key board actions (type h for help)
TF1 * GetEfficicencyFunc()
Definition: PeakCreator.h:67
Bool_t IsGate() const
Definition: PeakCreator.h:143
virtual void SetLastXY(Int_t lastX, Int_t lastY)
Definition: PeakCreator.h:105
header file for a general 1D peak
virtual void Clear(Option_t *="")
Clear: delete all peaks in canvas/pad depending on PadManager.
virtual Int_t GetLastX() const
set/get fLastX/fLastY
Definition: PeakCreator.h:101
A BasePeak is defined by a height, intensity and a dimension of the peak.
Definition: BasePeak.h:19
static PeakCreator * IsPeakCreator(TVirtualPad *pad=0x0)
Check whether or not a PeakCreator is in this canvas.
TGraph * GetEfficicencyGraph()
Definition: PeakCreator.h:64
virtual void Disconnect()
virtual bool IsHelpsPrintActive()
Definition: PeakCreator.h:96
A graphical interface for placing schematic peak onto a 1D histogram with a given position...
Definition: Peak1D.h:79
static TF1 * GetGlobalPeakFWHM()
ClassDef(PeakCreator, 0)
virtual void AddPointToPolyline(Double_t x, Double_t y, TVirtualPad *pad=0x0)
It adds a point to the polyline at position x,y in the current pad.
virtual BasePeak * CreatePeak(const TH1 *h, Double_t x, Option_t *opt="")
It creates a peak at position x for the 1D spectra.