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

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