source: trunk/MagicSoft/Mars/msim/MPhotonEvent.h@ 9235

Last change on this file since 9235 was 9232, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.4 KB
Line 
1#ifndef MARS_MPhotonEvent
2#define MARS_MPhotonEvent
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7/*
8#ifndef MARS_MCamEvent
9#include "MCamEvent.h"
10#endif
11*/
12#ifndef ROOT_TClonesArray
13#include <TClonesArray.h>
14#endif
15
16// gcc 3.2
17//class ifstream;
18#include <iosfwd>
19
20/*
21class TH1;
22class TH2;
23class TH3;
24*/
25
26class MPhotonData;
27class MCorsikaRunHeader;
28
29class MyClonesArray : public TClonesArray
30{
31public:
32 TObject **FirstRef() { return fCont; }
33
34 void FastRemove(Int_t idx1, Int_t idx2)
35 {
36 // Remove object at index idx.
37
38 //if (!BoundsOk("RemoveAt", idx1)) return 0;
39 //if (!BoundsOk("RemoveAt", idx2)) return 0;
40
41 Long_t dtoronly = TObject::GetDtorOnly();
42
43 idx1 -= fLowerBound;
44 idx2 -= fLowerBound;
45
46 for (TObject **obj=fCont+idx1; obj<=fCont+idx2; obj++)
47 {
48 if (!*obj)
49 continue;
50
51 if ((*obj)->TestBit(kNotDeleted)) {
52 // Tell custom operator delete() not to delete space when
53 // object fCont[i] is deleted. Only destructors are called
54 // for this object.
55 TObject::SetDtorOnly(*obj);
56 delete *obj;
57 }
58
59 *obj = 0;
60 // recalculate array size
61 }
62 TObject::SetDtorOnly((void*)dtoronly);
63
64 if (idx1<=fLast && fLast<=idx2)
65 {
66 do {
67 fLast--;
68 } while (fLast >= 0 && fCont[fLast] == 0);
69 }
70
71 Changed();
72 }
73};
74
75class MPhotonEvent : public MParContainer//, public MCamEvent
76{
77private:
78 TClonesArray fData;
79
80public:
81 MPhotonEvent(const char *name=NULL, const char *title=NULL);
82
83 //void Clear(Option_t * = NULL);
84 void Print(Option_t * = NULL) const;
85
86 const char *GetClassName() const;
87
88 TClonesArray &GetArray() { return fData; }
89 const TClonesArray &GetArray() const { return fData; }
90 void Remove(TObject *o) { fData.Remove(o); }
91
92 MPhotonData &Add(Int_t n);
93 MPhotonData &Add();
94
95 MPhotonData &operator[](UInt_t idx);
96 const MPhotonData &operator[](UInt_t idx) const;
97
98 Int_t Shrink(Int_t n)
99 {
100 // The number of object written by the streamer is defined by
101 // GetEntriesFast(), i.e. this number must be shrinked to
102 // the real array size. We use RemoveAt instead of ExpandCreate
103 // because RemoveAt doesn't free memory. Thus in the next
104 // iteration it can be reused and doesn't need to be reallocated.
105 // Do not change this. It is optimized for execution speed
106 // for (int i=fData.GetSize()-1; i>=n; i--)
107 // fData.RemoveAt(i);
108 static_cast<MyClonesArray&>(fData).FastRemove(n, fData.GetSize()-1);
109
110 return fData.GetEntriesFast();
111 }
112/*
113 void Expand(Int_t n)
114 {
115 for (int i=fData.GetSize(); i<n; i++)
116 fData.New(i);
117 }
118 */
119 Int_t ReadCorsikaEvt(istream &fin);
120 Int_t ReadRflEvt(istream &fin);
121
122 Int_t GetNumPhotons() const { return fData.GetEntriesFast(); }
123/*
124 void FillRad(TH1 &hist, Float_t scale=1) const;
125 void FillRad(TH2 &hist, Double_t x, Float_t scale=1) const;
126 void Fill(TH2 &hist, Float_t scale=1) const;
127 void Fill(TH3 &hist, Double_t z, Float_t scale=1) const;
128 */
129 void Paint(Option_t *o="");
130
131// Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
132// void DrawPixelContent(Int_t num) const;
133
134 void Sort() { fData.Sort(); }
135
136 ClassDef(MPhotonEvent, 1) //Container to store the raw Event Data
137};
138
139// FIXME: Should we merge this into MPhotonEvent?
140class MPhotonStatistics : public MParContainer
141{
142private:
143 Float_t fTimeFirst;
144 Float_t fTimeLast;
145
146// Float_t fOffset;
147// Float_t fWindow;
148
149 Int_t fMaxIndex;
150
151public:
152 MPhotonStatistics(const char *name=NULL, const char *title=NULL) : fMaxIndex(-1)
153 {
154 fName = name ? name : "MPhotonStatistics";
155 fTitle = title ? title : "Corsika Event Data Information";
156 }
157
158 void SetTime(Float_t first, Float_t last) { fTimeFirst=first; fTimeLast=last; }
159 void SetMaxIndex(UInt_t idx) { fMaxIndex=idx; }
160
161// Float_t GetRawTimeFirst() const { return fTimeFirst; }
162// Float_t GetRawTimeLast() const { return fTimeLast; }
163
164 Float_t GetTimeFirst() const { return fTimeFirst; }
165 Float_t GetTimeLast() const { return fTimeLast; }
166
167 Int_t GetMaxIndex() const { return fMaxIndex; }
168
169 Bool_t IsValid() const { return fTimeLast>=fTimeFirst; }
170
171 ClassDef(MPhotonStatistics, 1)
172};
173#endif
Note: See TracBrowser for help on using the repository browser.