source: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h@ 6555

Last change on this file since 6555 was 6489, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.0 KB
Line 
1#ifndef MARS_MCerPhotEvt
2#define MARS_MCerPhotEvt
3
4#ifndef ROOT_TClonesArray
5#include <TClonesArray.h>
6#endif
7#ifndef ROOT_TArrayI
8#include <TArrayI.h>
9#endif
10#ifndef MARS_MCamEvent
11#include "MCamEvent.h"
12#endif
13#ifndef MARS_MCerPhotPix
14#include "MCerPhotPix.h"
15#endif
16
17class MGeomCam;
18class MCerPhotPix;
19class MCerPhotEvtIter;
20
21class MCerPhotEvt : public MParContainer, public MCamEvent
22{
23 friend class MCerPhotEvtIter;
24private:
25 UInt_t fNumPixels;
26 Short_t fNumIslands;
27 Short_t fNumSinglePixels;
28 Float_t fSizeSinglePixels;
29 Float_t fSizeSubIslands;
30 Float_t fSizeMainIsland;
31 Int_t fMaxIndex;
32 TArrayI fLut; // Lookup tabel to lookup pixel by index
33 TClonesArray *fPixels; //-> FIXME: Change TClonesArray away from a pointer?
34
35 void RebuildLut()
36 {
37 // Resize Lut
38 fLut.Set(fMaxIndex+1);
39
40 // Reset Lut
41 fLut.Reset(-1);
42
43 // Rebuild Lut
44 for (UInt_t i=0; i<GetNumPixels(); i++)
45 {
46 const MCerPhotPix &pix = (*this)[i];
47 fLut[pix.GetPixId()] = i;
48 }
49 }
50
51 Double_t CalcIsland(const MGeomCam &geom, Int_t idx, Int_t num);
52
53public:
54 MCerPhotEvt(const char *name=NULL, const char *title=NULL);
55 ~MCerPhotEvt() { delete fPixels; }
56
57 // Setter function to fill pixels
58 MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0);
59 void FixSize();
60
61 // Getter functions
62 UInt_t GetNumPixels() const { return fNumPixels; }
63 Short_t GetNumIslands() const { return fNumIslands; };
64 Short_t GetNumSinglePixels() const { return fNumSinglePixels; }
65 Float_t GetSizeSinglePixels() const { return fSizeSinglePixels; }
66 Float_t GetSizeSubIslands() const { return fSizeSubIslands; }
67 Float_t GetSizeMainIsland() const { return fSizeMainIsland; }
68
69 // Setter functions for use in image cleaning classes only
70 void SetSinglePixels(Short_t num, Float_t size) { fNumSinglePixels=num; fSizeSinglePixels=size; }
71
72 Bool_t IsPixelExisting(Int_t id) const;
73 Bool_t IsPixelUsed (Int_t id) const;
74 Bool_t IsPixelCore (Int_t id) const;
75
76 Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const;
77 Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const;
78
79 Float_t GetRatioMin(const MGeomCam *geom=NULL) const;
80 Float_t GetRatioMax(const MGeomCam *geom=NULL) const;
81
82 Float_t GetErrorPhotMin(const MGeomCam *geom=NULL) const;
83 Float_t GetErrorPhotMax(const MGeomCam *geom=NULL) const;
84
85 // Getter functions to access single pixels
86 MCerPhotPix &operator[](int i) { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
87 MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
88
89 MCerPhotPix *GetPixById(Int_t idx) const;
90
91 // Functions to change the contained data
92 void Scale(Double_t f) { fPixels->ForEach(MCerPhotPix, Scale)(f); }
93 void RemoveUnusedPixels();
94 Int_t CalcIslands(const MGeomCam &geom);
95 void Sort(Int_t upto = kMaxInt)
96 {
97 // Sort pixels by index
98 fPixels->Sort(upto);
99 RebuildLut();
100 } // For convinience: Sort pixels by index
101
102 // class MParContainer
103 void Reset();
104
105 // class TObject
106 void Print(Option_t *opt=NULL) const;
107 void Clear(Option_t *opt=NULL) { Reset(); }
108
109 // class MCamEvent
110 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
111 void DrawPixelContent(Int_t num) const;
112
113 // To build an iterator for this class
114 operator TIterator*() const;
115
116 ClassDef(MCerPhotEvt, 4) // class for an event containing cerenkov photons
117};
118
119class MCerPhotEvtIter : public TObjArrayIter
120{
121private:
122 Bool_t fUsedOnly;
123public:
124 MCerPhotEvtIter(const MCerPhotEvt *evt, Bool_t usedonly=kTRUE, Bool_t dir=kIterForward) : TObjArrayIter(evt->fPixels, dir), fUsedOnly(usedonly) { }
125 TObject *Next();
126 TIterator &operator=(const TIterator &) { return *this; }
127 ClassDef(MCerPhotEvtIter, 0)
128};
129
130inline MCerPhotEvt::operator TIterator*() const { return new MCerPhotEvtIter(this); }
131
132#endif
Note: See TracBrowser for help on using the repository browser.