GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatPlayer.h
Go to the documentation of this file.
1 //
2 //
3 // MatPlayer Version 0.1
4 // MatPlayer is used to analyse a 2D histogram by putting gates interactively.
5 //
6 // A MatPlayer object must be connected to a TCanvas and a TH2D histogram. It is done by using SetCanvas & SetMatrix.
7 // Once a canvas and a matrix has been linked, any key pressed on the defined canvas gives a gate (TBox) that can be
8 // modify graphically. The gates on the current canvas are use to
9 //
10 // Olivier Stezowski -
11 //
12 //
13 //
14 
15 #ifndef GW_MATPLAYER_H
16 #define GW_MATPLAYER_H
17 
18 #ifndef ROOT_TNamed
19 #include "TNamed.h"
20 #endif
21 
22 #ifndef ROOT_TBox
23 #include "TBox.h"
24 #endif
25 
26 #ifndef ROOT_TList
27 #include "TList.h"
28 #endif
29 
30 #ifndef ROOT_TFormula
31 #include "TFormula.h"
32 #endif
33 
34 #ifndef ROOT_TH1
35 #include "TH1.h"
36 #endif
37 
38 #ifndef ROOT_TH2
39 #include "TH2.h"
40 #endif
41 
42 #include <iostream>
43 #include <utility>
44 
45 #include <RQ_OBJECT.h>
46 
47 namespace Gw {
48 
55 class MatPlayer : public TNamed
56 {
57  RQ_OBJECT("MatPlayer")
58 
59 private:
60  static Int_t fLastX, fLastY;
61  static TList *fgPlayers;
62 
63 private:
65  TBox fBoxX; // Use to draw X-gates on the current pad
66  TBox fBoxY; // Use to draw Y-gates on the current pad
67  TBox fBoxBX; // Use to draw BX-gates on the current pad
68  TBox fBoxBY; // Use to draw BY-gates on the current pad
69 
71  std::pair<TFormula *, TFormula *> fWidthGate;
72 
74  std::pair<Float_t,Float_t> fStep;
75 
76  TList fLastGates; // to keep a copy of the last gates list
77  // TList fGatesY; // to keep a current copy the gates list
78  // TList fGatesBX; // to keep a current copy the gates list
79  // TList fGatesBY; // to keep a current copy the gates list
80 
81 private:
82  TH2 *fMat;
83 
84  TH1D *fPx;
85  TH1D *fPy;
86  TH1D *fBx;
87  TH1D *fBy;
88  TH1D *fTotx;
89  TH1D *fToty;
90 
91 private:
93  void SetMatrix(TH2 *);
95  virtual void Clear(const Option_t *opt="");
96 
98  bool IsBox(const TBox *, const TBox *) const;
99 
100  static void SubstractBG_RAD(TH2 *);
101  static void SubstractBG_SNIP(TH2 *);
102 
103 protected:
105 
111  void SetGateX(Option_t *opt = "Gx");
112  Int_t InitGating(Option_t *opt = "Gx");
113 
114 public:
115  MatPlayer();
116  virtual ~MatPlayer();
117 
119  static TList *GetListOfPlayers() { return fgPlayers; }
120 
122  static void SubstractBG(const char *, Option_t *);
123 
125  void SetCanvas();
126 
128 
138  void SetMatrix(const char *);
139 
141  void Reset();
143  void ShowGates(Option_t *o = "BGx");
144 
145 // void SetGate(const Char_t *filename ="MatPlayer.Gx", Option_t *opt = "Gx"); // to set gates for a formated file
146 // void SetGate2D(Double_t, Double_t, Option_t *); // to set a gate a position x1 and X2
147 
149  Double_t GetWidthGate(Double_t pos, Option_t *opt = "Gx");
151  void SetWidthGate(Double_t wx = 2.5, Double_t wy = 2.5) { fWidthGate.first->SetParameter(0,wx); fWidthGate.second->SetParameter(0,wy); }
152 
154  void ProjectionY(Option_t *option);
155 
157  void XEventAction(Int_t event, Int_t px, Int_t py, TObject *obj);
158 
160  ClassDef(MatPlayer,0); // MatPlayer
161 };
162 
163 } // namespace
164 
165 #endif
void SetCanvas()
set current canvas as the mother of the current pad
Definition: MatPlayer.cpp:118
virtual ~MatPlayer()
Definition: MatPlayer.cpp:101
Int_t InitGating(Option_t *opt="Gx")
Definition: MatPlayer.cpp:275
static void SubstractBG(const char *, Option_t *)
Generic method to substract background of the current matrix.
Definition: MatPlayer.cpp:565
Double_t GetWidthGate(Double_t pos, Option_t *opt="Gx")
get width for gate at position pos
Definition: MatPlayer.cpp:206
ClassDef(MatPlayer, 0)
rootcint dictionary
void ShowGates(Option_t *o="BGx")
to show the gates used for the last gating
Definition: MatPlayer.cpp:388
void SetGateX(Option_t *opt="Gx")
set a gate using the last mouse position
Definition: MatPlayer.cpp:213
void Reset()
to reset the conditions of gating in the current pad
Definition: MatPlayer.cpp:419
void SetWidthGate(Double_t wx=2.5, Double_t wy=2.5)
set default width for gates
Definition: MatPlayer.h:151
void ProjectionY(Option_t *option)
to project
Definition: MatPlayer.cpp:439
MatPlayer is a tool to play with 2D matrices.
Definition: MatPlayer.h:55
static TList * GetListOfPlayers()
To get the list of all open MatPlayers.
Definition: MatPlayer.h:119
void XEventAction(Int_t event, Int_t px, Int_t py, TObject *obj)
slots
Definition: MatPlayer.cpp:489