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

Last change on this file since 3158 was 3148, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.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 TArrayI fLut; // Lookup tabel to lookup pixel by index
27 TClonesArray *fPixels; //-> FIXME: Change TClonesArray away from a pointer?
28
29public:
30 MCerPhotEvt(const char *name=NULL, const char *title=NULL);
31 ~MCerPhotEvt() { delete fPixels; }
32
33 UInt_t GetNumPixels() const { return fNumPixels; }
34 //void InitSize(UInt_t num) { fPixels->Expand(num); }
35
36 MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0)
37 {
38 //
39 // If this is too slow or takes to much space we might use
40 // MGeomApply and an InitSize member function instead.
41 //
42 if (idx>=fLut.GetSize())
43 {
44 const Int_t n = fLut.GetSize();
45 fLut.Set(idx+1);
46 for (int i=n; i<idx; i++)
47 fLut[i] = -1;
48 }
49
50 fLut[idx] = fNumPixels;
51 return new ((*fPixels)[fNumPixels++]) MCerPhotPix(idx, nph, er);
52 }
53
54 void FixSize();
55
56 Bool_t IsPixelExisting(Int_t id) const;
57 Bool_t IsPixelUsed (Int_t id) const;
58 Bool_t IsPixelCore (Int_t id) const;
59
60 Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const;
61 Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const;
62
63 Float_t GetRatioMin(const MGeomCam *geom=NULL) const;
64 Float_t GetRatioMax(const MGeomCam *geom=NULL) const;
65
66 Float_t GetErrorPhotMin(const MGeomCam *geom=NULL) const;
67 Float_t GetErrorPhotMax(const MGeomCam *geom=NULL) const;
68
69 MCerPhotPix &operator[](int i) { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
70 MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
71
72 void Scale(Double_t f) { fPixels->ForEach(MCerPhotPix, Scale)(f); }
73 void RemoveUnusedPixels();
74
75 MCerPhotPix *GetPixById(Int_t idx) const;
76
77 void Reset();
78
79 void Print(Option_t *opt=NULL) const;
80 void Clear(Option_t *opt=NULL) { Reset(); }
81
82 // class MCamEvent
83 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
84 void DrawPixelContent(Int_t num) const;
85
86 operator TIterator*() const;
87
88 ClassDef(MCerPhotEvt, 2) // class for an event containing cerenkov photons
89};
90
91class MCerPhotEvtIter : public TObjArrayIter
92{
93private:
94 Bool_t fUsedOnly;
95public:
96 MCerPhotEvtIter(const MCerPhotEvt *evt, Bool_t usedonly=kTRUE, Bool_t dir=kIterForward) : TObjArrayIter(evt->fPixels, dir), fUsedOnly(usedonly) { }
97 TObject *Next();
98 ClassDef(MCerPhotEvtIter, 0)
99};
100
101inline MCerPhotEvt::operator TIterator*() const { return new MCerPhotEvtIter(this); }
102
103#endif
Note: See TracBrowser for help on using the repository browser.