GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseSpectrumPlayer.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_BaseSpectrumPlayer
24 #define Gw_BaseSpectrumPlayer
25 
26 #include "GwLogMessage.h"
27 
28 #ifndef ROOT_TNamed
29 #include "TNamed.h"
30 #endif
31 
32 #ifndef ROOT_TParameter
33 #include "TParameter.h"
34 #endif
35 
36 #ifndef ROOT_TVector3
37 #include "TVector3.h"
38 #endif
39 
40 
41 #ifndef Gw_PadManager
42 #include "PadManager.h"
43 #endif
44 
45 #ifndef Gw_PeakCreator
46 #include "PeakCreator.h"
47 #endif
48 
49 class TSeqCollection;
50 class TList;
51 class TCanvas;
52 class TH1;
53 class TFormula;
54 class TContextMenu;
55 
56 namespace Gw {
57 
58 class BasePeak;
59 
66 class BaseSpectrumPlayer : public TNamed
67 {
68 protected:
71 
72 private:
74  TSeqCollection *fPeakList;
76  TList *fInnerPeakList;
77 
78 private:
79  Int_t fLastX; // last x event position
80  Int_t fLastY; // last y event position
81 
82 private:
83  bool fIsHelpsPrintActive;
84 public:
85  virtual void SetHelpsPrintActive(bool on) {fIsHelpsPrintActive = on;}
86 
87 protected:
89  Int_t GetLastX()
90  {return fLastX;}
91  Int_t GetLastY()
92  {return fLastY;}
93  void SetLastXY(Int_t lastX, Int_t lastY)
94  {fLastX = lastX; fLastY = lastY;}
96  Bool_t IsInRange(TH1*h, BasePeak* peak);
97 
98 protected:
100  TContextMenu *fContextMenu;
101 
102 protected:
104  mutable LogMessage fLog;
105 
106 protected:
109 
110 public:
111  virtual ~BaseSpectrumPlayer();
112 
114 
117  Bool_t Connect(TCanvas *c = 0x0);
118 
120 
123  Bool_t Disconnect(TCanvas *c = 0x0);
124 
125  virtual PeakCreator *GetPeakCreator() {return fCreator;}
126 
128  virtual const TF1* GetDefaultPeakWidth() const
129  { return fCreator->GetDefaultPeakFWHM(); }
130 
132  void SetDefaultPeakFWHM( const char * = "PCG_FWHM" );
133 
135 
138  virtual TSeqCollection* GetPeakList() const
139  { return fPeakList; }
140 
142  virtual void ShowPeakList() const;
143 
145 
148  virtual void SetPeakList(TSeqCollection *col = 0x0);
149 
151  virtual void AddPeak(BasePeak* peak);
152 
154  virtual Bool_t RenamePeak(const Char_t* baseName = "Peak", Bool_t force = false);
155 
157  virtual void FitAll(const char* nameFunc = "DTGaus", Option_t* optFit = "RN", Option_t* optBkg = "Step"); //*MENU*
158 
160  virtual void PopupFitMenu();
161 
163  virtual Int_t FindPeaks(Option_t* opt = "");
164 
166  virtual Int_t FindPeaks(TH1 *histo, Option_t* opt = "") = 0;
167 
169  virtual void SortPeakList(const Char_t* parName = "Position", Bool_t sortDes = false);
170 
172  virtual TH1 *Background(const TH1 */*histo*/, Option_t* /*opt = ""*/) { return 0x0; }
173 
175  virtual TH1 *Background(Option_t* opt = "");
176 
178  virtual void DoBackground(TH1 *histo, Option_t* opt = "");
179 
181  virtual void DoBackground(Option_t *opt = "")
183 
185  virtual Bool_t SetParameter(const char* /*name*/, Double_t /*value*/) { return false; }
186  virtual Bool_t SetParameter(const char* /*name*/, Int_t /*value*/) { return false; }
187  virtual Bool_t SetParameter(const char* name, const TObject* value);
188 
190  virtual TParameter<Int_t> GetIntParameter(TString /*Name*/) { return TParameter<Int_t>(); }
191  virtual TParameter<Double_t> GetDoubleParameter(TString /*Name*/){ return TParameter<Double_t>(); }
192 
194 
197  virtual Int_t CollectPeaks(Option_t* opt = "");
198 
200  virtual void Print(Option_t* opt = "") const;
201 
203  void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject*);
204 
205  ClassDef(BaseSpectrumPlayer, 1); // Base class for facilities to play with spectra
206 };
207 
208 } // end namespace
209 
210 #endif
void SetDefaultPeakFWHM(const char *="PCG_FWHM")
to change the definition of the formula for the width
header file for PeakCreator.cpp
ClassDef(BaseSpectrumPlayer, 1)
virtual void SortPeakList(const Char_t *parName="Position", Bool_t sortDes=false)
sort peak list
header file for PadManager.cpp
virtual void DoBackground(TH1 *histo, Option_t *opt="")
Apply background substraction for that histogram.
virtual Bool_t RenamePeak(const Char_t *baseName="Peak", Bool_t force=false)
Sort all peaks and rename them.
BaseSpectrumPlayer to work on spectra.
LogMessage fLog
log message
BaseSpectrumPlayer()
default constructor
TF1 * GetDefaultPeakFWHM()
Definition: PeakCreator.h:161
void SetLastXY(Int_t lastX, Int_t lastY)
virtual Bool_t SetParameter(const char *, Int_t)
Bool_t Disconnect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
Base class for a Log message.
Definition: GwLogMessage.h:94
UInt_t value[MaxValue]
Definition: ReadDaqAlone.C:29
TH1F * histo[MaxValue]
Definition: ReadDaqAlone.C:31
header file for GwLogMessage.cpp
virtual Int_t FindPeaks(Option_t *opt="")
Find peaks from the histo in the current pad and store them in the current collection.
virtual void SetHelpsPrintActive(bool on)
virtual void PopupFitMenu()
Popup AddLink menu.
virtual PeakCreator * GetPeakCreator()
PeakCreator * fCreator
default PeakCreator
TContextMenu * fContextMenu
context menu in canvas
virtual void DoBackground(Option_t *opt="")
Apply background substraction for current histogram in pad.
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *)
Handle Movement.
Bool_t IsInRange(TH1 *h, BasePeak *peak)
check if peak is in range of drawn spectrum
virtual const TF1 * GetDefaultPeakWidth() const
Get formula that gives the with as a function of energy.
Int_t GetLastX()
set/get fLastX/fLastY
virtual void SetPeakList(TSeqCollection *col=0x0)
set collection
virtual void Print(Option_t *opt="") const
Print out informations concerning the parameters of that player.
virtual TSeqCollection * GetPeakList() const
Return the current collection of peaks.
virtual void AddPeak(BasePeak *peak)
Add a peak to the current collection (at the end)
virtual Int_t CollectPeaks(Option_t *opt="")
Collect the peaks from the current pad.
A BasePeak is defined by a height, intensity and a dimension of the peak.
Definition: BasePeak.h:19
virtual TParameter< Double_t > GetDoubleParameter(TString)
virtual void FitAll(const char *nameFunc="DTGaus", Option_t *optFit="RN", Option_t *optBkg="Step")
Fit all peaks using the spectrum in the current pad.
virtual void ShowPeakList() const
Show the list of peaks on the current pad.
static TH1 * GetHisto(TVirtualPad *pad=0x0, Option_t *op="")
look for an histogram into the pad
Definition: PadManager.cpp:67
virtual TH1 * Background(const TH1 *, Option_t *)
Compute the background for that histogram.
virtual TParameter< Int_t > GetIntParameter(TString)
To get the parameters.
virtual Bool_t SetParameter(const char *, Double_t)
To change the parameters for that algorithm.
Bool_t Connect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.