source: branches/MarsMoreSimulationTruth/mtemp/mifae/library/MGainFluctuationCam.h@ 20115

Last change on this file since 20115 was 6192, checked in by blanch, 20 years ago
*** empty log message ***
File size: 2.9 KB
Line 
1#ifndef MARS_MGainFluctuationCam
2#define MARS_MGainFluctuationCam
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_MGainFluctuationPix
14#include "MGainFluctuationPix.h"
15#endif
16
17class MGeomCam;
18class MGainFluctuationPix;
19class MGainFluctuationCamIter;
20
21class MGainFluctuationCam : public MParContainer, public MCamEvent
22{
23 friend class MGainFluctuationCamIter;
24private:
25 UInt_t fNumPixels;
26 Int_t fMaxIndex;
27 TArrayI fLut; // Lookup tabel to lookup pixel by index
28 TClonesArray *fPixels; //-> FIXME: Change TClonesArray away from a pointer?
29
30 void RebuildLut()
31 {
32 // Resize Lut
33 fLut.Set(fMaxIndex+1);
34
35 // Reset Lut
36 fLut.Reset(-1);
37
38 // Rebuild Lut
39 for (UInt_t i=0; i<GetNumPixels(); i++)
40 {
41 const MGainFluctuationPix &pix = (*this)[i];
42 fLut[pix.GetPixId()] = i;
43 }
44 }
45
46public:
47 MGainFluctuationCam(const char *name=NULL, const char *title=NULL);
48 ~MGainFluctuationCam() { delete fPixels; }
49
50 // Setter function to fill pixels
51 MGainFluctuationPix *AddPixel(Int_t idx, Float_t gain);
52 void FixSize();
53
54 // Getter functions
55 UInt_t GetNumPixels() const { return fNumPixels; }
56 Float_t GetGain(int i) const;
57
58 Float_t GetGainMin(const MGeomCam *geom=NULL) const;
59 Float_t GetGainMax(const MGeomCam *geom=NULL) const;
60
61 // Getter functions to access single pixels
62 MGainFluctuationPix &operator[](int i) { return *(MGainFluctuationPix*)(fPixels->UncheckedAt(i)); }
63 MGainFluctuationPix &operator[](int i) const { return *(MGainFluctuationPix*)(fPixels->UncheckedAt(i)); }
64
65 MGainFluctuationPix *GetPixById(Int_t idx) const;
66
67 void Sort(Int_t upto = kMaxInt)
68 {
69 // Sort pixels by index
70 fPixels->Sort(upto);
71 RebuildLut();
72 } // For convinience: Sort pixels by index
73
74 // class MParContainer
75 void Reset();
76
77 // class TObject
78 void Print(Option_t *opt=NULL) const;
79 void Clear(Option_t *opt=NULL) { Reset(); }
80
81 // class MCamEvent
82 Bool_t GetPixelContent(Double_t &val, Int_t idx,const MGeomCam&, Int_t type=1) const;
83 void DrawPixelContent(Int_t num) const;
84
85 // To build an iterator for this class
86 operator TIterator*() const;
87
88 ClassDef(MGainFluctuationCam, 1) // class for an event containing cerenkov photons
89};
90
91class MGainFluctuationCamIter : public TObjArrayIter
92{
93private:
94 Bool_t fUsedOnly;
95public:
96 MGainFluctuationCamIter(const MGainFluctuationCam *evt, Bool_t usedonly=kTRUE, Bool_t dir=kIterForward) : TObjArrayIter(evt->fPixels, dir), fUsedOnly(usedonly) { }
97 TObject *Next();
98 TIterator &operator=(const TIterator &) { return *this; }
99 ClassDef(MGainFluctuationCamIter, 0)
100};
101
102inline MGainFluctuationCam::operator TIterator*() const { return new MGainFluctuationCamIter(this); }
103
104#endif
Note: See TracBrowser for help on using the repository browser.