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