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

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