source: trunk/MagicSoft/Mars/mhist/MHCamera.h@ 3195

Last change on this file since 3195 was 3142, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 15.8 KB
Line 
1#ifndef MARS_MHCamera
2#define MARS_MHCamera
3
4#ifndef MARS_MAGIC
5#include "MAGIC.h"
6#endif
7#ifndef ROOT_TArrayC
8#include <TArrayC.h>
9#endif
10#ifndef ROOT_TArrayI
11#include <TArrayI.h>
12#endif
13#ifndef ROOT_TClonesArray
14#include <TClonesArray.h>
15#endif
16#ifndef ROOT_TH1
17#include <TH1.h>
18#endif
19
20class TPaveStats;
21
22class MGeomCam;
23class MCamEvent;
24class MRflEvtData;
25class MCerPhotEvt;
26class MImgCleanStd;
27
28class MHCamera : public TH1D
29{
30public:
31 enum {
32 kProfile = BIT(18), // FIXME: When changing change max/min!
33 kFreezed = BIT(19),
34 kNoLegend = BIT(20),
35 kVariance = BIT(21)
36 };
37private:
38 MGeomCam *fGeomCam; // pointer to camera geometry (y-axis)
39 TArrayC fUsed; // array containing flags
40
41 TArrayI fColors; //! Color conversion table
42 TList *fNotify; //!
43
44 Bool_t fFreezed; //! Just a dummy!!!! ([Set,Is]Freezed)
45
46 //Int_t fOptStat;
47 //TGStatusBar *fStatusBar;
48
49 void Init();
50
51 Stat_t Profile(Stat_t val) const
52 {
53 if (!TestBit(kProfile))
54 return val;
55
56 const Stat_t n = TH1D::GetEntries();
57 return n>0 ? val/n : val;
58 }
59
60 Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog);
61
62 void PaintIndices(Int_t type);
63 void Update(Bool_t islog, Bool_t isbox, Bool_t iscol);
64 void UpdateLegend(Float_t min, Float_t max, Bool_t islog);
65 void SetRange();
66
67 TPaveStats *GetStatisticBox();
68
69 Int_t GetPixelIndex(Int_t px, Int_t py) const;
70
71 void PaintAxisTitle();
72
73 enum {
74 kIsUsed = BIT(1)
75 };
76
77 void SetUsed(Int_t idx) { SETBIT(fUsed[idx], kIsUsed); }
78 void ResetUsed(Int_t idx) { CLRBIT(fUsed[idx], kIsUsed); }
79
80 // This is a trick to remove TH1 entries from the context menu
81 TH1 *Rebin(Int_t ngroup=2, const char*newname="") { return this; }
82 void DrawPanel() {}
83
84 Int_t Fill(Axis_t x);
85 Int_t Fill(Axis_t x, Stat_t w);
86 Int_t Fill(const char *name, Stat_t w) { return -1; }
87 void FillN(Int_t ntimes, const Axis_t *x, const Double_t *w, Int_t stride=1) {}
88 void FillN(Int_t, const Axis_t *, const Axis_t *, const Double_t *, Int_t) {}
89
90public:
91 MHCamera();
92 MHCamera(const MGeomCam &geom, const char *name="", const char *title="");
93 ~MHCamera();
94
95 void SetGeometry(const MGeomCam &geom, const char *name="", const char *title="");
96 const MGeomCam* GetGeometry() const { return fGeomCam; }
97
98 Bool_t IsUsed(Int_t idx) const { return TESTBIT(const_cast<TArrayC&>(fUsed)[idx], kIsUsed); }
99
100 Int_t Fill(Axis_t x, Axis_t y, Stat_t w);
101
102 //void AddPixContent(Int_t idx) const { AddBinContent(idx+1); }
103 //void AddPixContent(Int_t idx, Stat_t w) const { AddBinContent(idx+1, w); }
104
105 // This is a trick to remove TH1 entries from the context menu
106 /*
107 void Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) { TH1::Add(h1, h2, c1, c2); }
108 void Add(TF1 *h1, Double_t c1=1) { TH1::Add(h1, c1); }
109 void Add(const TH1 *h1, Double_t c1=1) { TH1::Add(h1, c1); }
110 void Divide(TF1 *f1, Double_t c1=1) { TH1::Divide(f1, c1); }
111 void Divide(const TH1 *h1) { TH1::Divide(h1); }
112 void Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") { TH1::Divide(h1, h2, c1, c2, option); }
113 void Multiply(TF1 *h1, Double_t c1=1) { TH1::Multiply(h1, c1); }
114 void Multiply(const TH1 *h1) { TH1::Multiply(h1); }
115 void Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") { TH1::Multiply(h1, h2, c1, c2, option); }
116 */
117
118 void FitPanel() { TH1::FitPanel(); }
119
120 virtual Double_t GetPixContent(Int_t idx) const { return GetBinContent(idx+1); }
121 virtual void AddCamContent(const MCamEvent &evt, Int_t type=0);
122 virtual void AddCamContent(const MHCamera &evt, Int_t type=0);
123 virtual void AddCamContent(const TArrayD &arr, const TArrayC *used=NULL);
124 virtual void SetCamContent(const MCamEvent &evt, Int_t type=0) { Reset(); AddCamContent(evt, type); }
125 virtual void SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
126 virtual void SetCamContent(const MHCamera &d, Int_t type=0) { Reset(); AddCamContent(d, type); fEntries=d.fEntries; }
127
128 virtual void SetCamError(const MCamEvent &evt, Int_t type=0);
129
130 virtual void CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
131 virtual void CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
132
133 Stat_t GetBinContent(Int_t bin) const { return Profile(TH1D::GetBinContent(bin)); }
134 Stat_t GetBinContent(Int_t binx, Int_t biny) const { return GetBinContent(binx); }
135 Stat_t GetBinContent(Int_t binx, Int_t biny, Int_t binz) const { return GetBinContent(binx); }
136 Stat_t GetBinError(Int_t bin) const;
137 Stat_t GetBinError(Int_t binx, Int_t biny) const { return GetBinError(binx); }
138 Stat_t GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); }
139
140 Double_t GetMinimum(Bool_t all) const;
141 Double_t GetMaximum(Bool_t all) const;
142
143 Double_t GetMinimum() const { return GetMinimum(0/*kTRUE*/); }
144 Double_t GetMaximum() const { return GetMaximum(0/*kTRUE*/); }
145
146 void SetLevels(const TArrayF &arr);
147
148 void FillRandom(const char *fname, Int_t ntimes=5000) { TH1::FillRandom(fname, ntimes); }
149 void FillRandom(TH1 *h, Int_t ntimes=5000) { TH1::FillRandom(h, ntimes); }
150 void FillRandom();
151
152 void PrintInfo() const { Print(""); } // *MENU*
153 void Reset(Option_t *);
154 void Reset() { Reset(""); } // *MENU*
155 TH1 *DrawCopy() const/* { gPad=NULL; return TH1D::DrawCopy(); }*/; // *MENU*
156 TH1 *DrawCopy(Option_t *o) const { return TH1D::DrawCopy(o); }
157
158 void Print(Option_t *) const;
159 void Paint(Option_t *option="");
160 void Draw(Option_t *option="");
161 TObject *DrawClone(Option_t *option="") const;
162 void SavePrimitive(ofstream &out, Option_t *);
163 Int_t DistancetoPrimitive(Int_t px, Int_t py);
164 char *GetObjectInfo(Int_t px, Int_t py) const;
165 void ExecuteEvent(Int_t event, Int_t px, Int_t py);
166
167 void SetPalette(Int_t ncolors, Int_t *colors);
168
169 void SetPrettyPalette(); // *MENU*
170 void SetDeepBlueSeaPalette(); // *MENU*
171 void SetInvDeepBlueSeaPalette(); // *MENU*
172
173 void SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU*
174 void DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU*
175 void DisplayAsCamera() { SetDrawOption(""); } // *MENU*
176
177 void SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE*
178 Bool_t IsFreezed() const { return TestBit(kFreezed); }
179 //void SetOptStat(Int_t os=-1) { fOptStat = os; } // *MENU*
180
181 void AddNotify(TObject *event);
182
183 Stat_t GetMean(Int_t axis=-1) const;
184 Stat_t GetRMS(Int_t axis=-1) const;
185
186 UInt_t GetNumPixels() const;
187
188 TH1D *Projection(const char *name="_py") const;
189
190 const MGeomCam &GetGeomCam() const { return *fGeomCam; }
191
192 ClassDef(MHCamera, 1) // Displays the magic camera
193};
194
195#endif
196
197/* ------------ OK ---------------
198 virtual void Browse(TBrowser *b);
199 virtual void FillRandom(const char *fname, Int_t ntimes=5000);
200 virtual void FillRandom(TH1 *h, Int_t ntimes=5000);
201
202 virtual Int_t GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum=0);
203 virtual Axis_t GetRandom();
204 virtual void GetStats(Stat_t *stats) const;
205 virtual Stat_t GetSumOfWeights() const;
206 virtual Int_t GetSumw2N() const {return fSumw2.fN;}
207 virtual Stat_t GetRMS(Int_t axis=1) const;
208
209 virtual Int_t GetNbinsX() const {return fXaxis.GetNbins();}
210 virtual Int_t GetNbinsY() const {return fYaxis.GetNbins();}
211 virtual Int_t GetNbinsZ() const {return fZaxis.GetNbins();}
212
213 // ------------- to check -------------------
214
215 virtual Double_t ComputeIntegral();
216 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
217 virtual void Draw(Option_t *option="");
218 virtual TH1 *DrawCopy(Option_t *option="") const;
219 virtual TH1 *DrawNormalized(Option_t *option="", Double_t norm=1) const;
220 virtual Int_t BufferEmpty(Bool_t deleteBuffer=kFALSE);
221 virtual void Eval(TF1 *f1, Option_t *option="");
222 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
223 virtual void FillN(Int_t ntimes, const Axis_t *x, const Double_t *w, Int_t stride=1);
224 virtual void FillN(Int_t, const Axis_t *, const Axis_t *, const Double_t *, Int_t) {;}
225 virtual Int_t FindBin(Axis_t x, Axis_t y=0, Axis_t z=0);
226 virtual TObject *FindObject(const char *name) const;
227 virtual TObject *FindObject(const TObject *obj) const;
228 virtual Int_t Fit(const char *formula ,Option_t *option="" ,Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0); // *MENU*
229 virtual Int_t Fit(TF1 *f1 ,Option_t *option="" ,Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0);
230 virtual void FitPanel(); // *MENU*
231 TH1 *GetAsymmetry(TH1* h2, Double_t c2=1, Double_t dc2=0);
232 Int_t GetBufferLength() const {return (Int_t)fBuffer[0];}
233 Int_t GetBufferSize () const {return fBufferSize;}
234 const Double_t *GetBuffer() const {return fBuffer;}
235 static Int_t GetDefaultBufferSize();
236 virtual Double_t *GetIntegral() {return fIntegral;}
237
238 TList *GetListOfFunctions() const { return fFunctions; }
239
240 virtual Int_t GetNdivisions(Option_t *axis="X") const;
241 virtual Color_t GetAxisColor(Option_t *axis="X") const;
242 virtual Color_t GetLabelColor(Option_t *axis="X") const;
243 virtual Style_t GetLabelFont(Option_t *axis="X") const;
244 virtual Float_t GetLabelOffset(Option_t *axis="X") const;
245 virtual Float_t GetLabelSize(Option_t *axis="X") const;
246 virtual Float_t GetTitleOffset(Option_t *axis="X") const;
247 virtual Float_t GetTitleSize(Option_t *axis="X") const;
248 virtual Float_t GetTickLength(Option_t *axis="X") const;
249 virtual Float_t GetBarOffset() const {return Float_t(0.001*Float_t(fBarOffset));}
250 virtual Float_t GetBarWidth() const {return Float_t(0.001*Float_t(fBarWidth));}
251 virtual Int_t GetContour(Double_t *levels=0);
252 virtual Double_t GetContourLevel(Int_t level) const;
253 virtual Double_t GetContourLevelPad(Int_t level) const;
254
255 virtual void GetCenter(Axis_t *center) const {fXaxis.GetCenter(center);}
256 TDirectory *GetDirectory() const {return fDirectory;}
257 virtual Stat_t GetEntries() const;
258 virtual TF1 *GetFunction(const char *name) const;
259 virtual Int_t GetDimension() const { return fDimension; }
260 virtual void GetLowEdge(Axis_t *edge) const {fXaxis.GetLowEdge(edge);}
261 virtual Double_t GetMaximum() const;
262 virtual Int_t GetMaximumBin() const;
263 virtual Int_t GetMaximumBin(Int_t &locmax, Int_t &locmay, Int_t &locmaz) const;
264 virtual Double_t GetMaximumStored() const {return fMaximum;}
265 virtual Double_t GetMinimum() const;
266 virtual Int_t GetMinimumBin() const;
267 virtual Int_t GetMinimumBin(Int_t &locmix, Int_t &locmiy, Int_t &locmiz) const;
268 virtual Double_t GetMinimumStored() const {return fMinimum;}
269 virtual Stat_t GetMean(Int_t axis=1) const;
270 virtual Double_t GetNormFactor() const {return fNormFactor;}
271 virtual char *GetObjectInfo(Int_t px, Int_t py) const;
272 Option_t *GetOption() const {return fOption.Data();}
273
274 TVirtualHistPainter *GetPainter();
275
276 TAxis *GetXaxis() const;
277 TAxis *GetYaxis() const;
278 TAxis *GetZaxis() const;
279 virtual Stat_t Integral(Option_t *option="") const;
280 virtual Stat_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const;
281 virtual Stat_t Integral(Int_t, Int_t, Int_t, Int_t, Option_t * ="") const {return 0;}
282 virtual Stat_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t * ="" ) const {return 0;}
283 virtual Double_t KolmogorovTest(TH1 *h2, Option_t *option="") const;
284 virtual void LabelsDeflate(Option_t *axis="X");
285 virtual void LabelsInflate(Option_t *axis="X");
286 virtual void LabelsOption(Option_t *option="h", Option_t *axis="X");
287 virtual Int_t Merge(TCollection *list);
288 virtual void Multiply(TF1 *h1, Double_t c1=1);
289 virtual void Multiply(const TH1 *h1);
290 virtual void Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
291 virtual void Paint(Option_t *option="");
292 virtual void Print(Option_t *option="") const;
293 virtual void PutStats(Stat_t *stats);
294 virtual TH1 *Rebin(Int_t ngroup=2, const char*newname=""); // *MENU*
295 virtual void RebinAxis(Axis_t x, Option_t *axis="X");
296 virtual void Rebuild(Option_t *option="");
297 virtual void RecursiveRemove(TObject *obj);
298 virtual void Reset(Option_t *option="");
299 virtual void SavePrimitive(ofstream &out, Option_t *option);
300 virtual void Scale(Double_t c1=1);
301 virtual void SetAxisColor(Color_t color=1, Option_t *axis="X");
302 virtual void SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t *axis="X");
303 virtual void SetBarOffset(Float_t offset=0.25) {fBarOffset = Short_t(1000*offset);}
304 virtual void SetBarWidth(Float_t width=0.5) {fBarWidth = Short_t(1000*width);}
305 virtual void SetBinContent(Int_t bin, Stat_t content);
306 virtual void SetBinContent(Int_t binx, Int_t biny, Stat_t content);
307 virtual void SetBinContent(Int_t binx, Int_t biny, Int_t binz, Stat_t content);
308 virtual void SetBinError(Int_t bin, Stat_t error);
309 virtual void SetBinError(Int_t binx, Int_t biny, Stat_t error);
310 virtual void SetBinError(Int_t binx, Int_t biny, Int_t binz, Stat_t error);
311 virtual void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax);
312 virtual void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax);
313 virtual void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax,
314 Int_t nz, Axis_t zmin, Axis_t zmax);
315 virtual void SetBinsLength(Int_t = -1) { } //refefined in derived classes
316 virtual void SetBuffer(Int_t buffersize, Option_t *option="");
317 virtual void SetCellContent(Int_t binx, Int_t biny, Stat_t content);
318 virtual void SetCellError(Int_t binx, Int_t biny, Stat_t content);
319 virtual void SetContent(const Stat_t *content);
320 virtual void SetContour(Int_t nlevels, const Double_t *levels=0);
321 virtual void SetContourLevel(Int_t level, Double_t value);
322 static void SetDefaultBufferSize(Int_t buffersize=1000);
323 virtual void SetDirectory(TDirectory *dir);
324 virtual void SetEntries(Stat_t n) {fEntries = n;};
325 virtual void SetError(const Stat_t *error);
326 virtual void SetLabelColor(Color_t color=1, Option_t *axis="X");
327 virtual void SetLabelFont(Style_t font=62, Option_t *axis="X");
328 virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X");
329 virtual void SetLabelSize(Float_t size=0.02, Option_t *axis="X");
330
331 virtual void SetMaximum(Double_t maximum=-1111); // *MENU*
332 virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
333 virtual void SetName(const char *name); // *MENU*
334 virtual void SetNameTitle(const char *name, const char *title);
335 virtual void SetNdivisions(Int_t n=510, Option_t *axis="X");
336 virtual void SetNormFactor(Double_t factor=1) {fNormFactor = factor;}
337 virtual void SetStats(Bool_t stats=kTRUE);
338 virtual void SetOption(Option_t *option=" ") {fOption = option;}
339 virtual void SetTickLength(Float_t length=0.02, Option_t *axis="X");
340 virtual void SetTitleOffset(Float_t offset=1, Option_t *axis="X");
341 virtual void SetTitleSize(Float_t size=0.02, Option_t *axis="X");
342 virtual void SetTitle(const char *title);
343 virtual void SetXTitle(const char *title) {fXaxis.SetTitle(title);}
344 virtual void SetYTitle(const char *title) {fYaxis.SetTitle(title);}
345 virtual void SetZTitle(const char *title) {fZaxis.SetTitle(title);}
346 virtual void Smooth(Int_t ntimes=1); // *MENU*
347 static void SmoothArray(Int_t NN, Double_t *XX, Int_t ntimes=1);
348 static Double_t SmoothMedian(Int_t n, Double_t *a);
349 virtual void Sumw2();
350 void UseCurrentStyle();
351
352 ClassDef(TH1,4) //1-Dim histogram base class
353};
354
355*/
Note: See TracBrowser for help on using the repository browser.