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 |
|
---|
81 | TClonesArray &GetArray() { return fData; }
|
---|
82 | const TClonesArray &GetArray() const { return fData; }
|
---|
83 |
|
---|
84 | MPhotonData &Add(Int_t n);
|
---|
85 | MPhotonData &Add();
|
---|
86 |
|
---|
87 | MPhotonData *GetFirst() const;
|
---|
88 | MPhotonData *GetLast() const;
|
---|
89 |
|
---|
90 | MPhotonData &operator[](UInt_t idx);
|
---|
91 | const MPhotonData &operator[](UInt_t idx) const;
|
---|
92 |
|
---|
93 | Int_t Shrink(Int_t n)
|
---|
94 | {
|
---|
95 | // The number of object written by the streamer is defined by
|
---|
96 | // GetEntriesFast(), i.e. this number must be shrinked to
|
---|
97 | // the real array size. We use RemoveAt instead of ExpandCreate
|
---|
98 | // because RemoveAt doesn't free memory. Thus in the next
|
---|
99 | // iteration it can be reused and doesn't need to be reallocated.
|
---|
100 | // Do not change this. It is optimized for execution speed
|
---|
101 | // for (int i=fData.GetSize()-1; i>=n; i--)
|
---|
102 | // fData.RemoveAt(i);
|
---|
103 | const Bool_t sorted = fData.IsSorted();
|
---|
104 |
|
---|
105 | MyClonesArray &loc = static_cast<MyClonesArray&>(fData);
|
---|
106 |
|
---|
107 | loc.FastRemove(n, fData.GetSize()-1);
|
---|
108 |
|
---|
109 | // If it was sorted before it is also sorted now.
|
---|
110 | if (sorted)
|
---|
111 | loc.SetSorted();
|
---|
112 |
|
---|
113 | return fData.GetEntriesFast();
|
---|
114 | }
|
---|
115 |
|
---|
116 | // I/O
|
---|
117 | Int_t ReadCorsikaEvt(istream &fin);
|
---|
118 | Int_t ReadRflEvt(istream &fin);
|
---|
119 |
|
---|
120 | // TObject
|
---|
121 | void Paint(Option_t *o="");
|
---|
122 | void Print(Option_t * = NULL) const;
|
---|
123 | //void Clear(Option_t * = NULL);
|
---|
124 |
|
---|
125 | ClassDef(MPhotonEvent, 1) //Container to store the raw Event Data
|
---|
126 | };
|
---|
127 |
|
---|
128 | // FIXME: Should we merge this into MPhotonEvent?
|
---|
129 | class MPhotonStatistics : public MParContainer
|
---|
130 | {
|
---|
131 | private:
|
---|
132 | Float_t fTimeFirst;
|
---|
133 | Float_t fTimeLast;
|
---|
134 |
|
---|
135 | // Float_t fOffset;
|
---|
136 | // Float_t fWindow;
|
---|
137 |
|
---|
138 | Int_t fMaxIndex;
|
---|
139 |
|
---|
140 | public:
|
---|
141 | MPhotonStatistics(const char *name=NULL, const char *title=NULL) : fMaxIndex(-1)
|
---|
142 | {
|
---|
143 | fName = name ? name : "MPhotonStatistics";
|
---|
144 | fTitle = title ? title : "Corsika Event Data Information";
|
---|
145 | }
|
---|
146 |
|
---|
147 | void SetTime(Float_t first, Float_t last) { fTimeFirst=first; fTimeLast=last; }
|
---|
148 | void SetMaxIndex(UInt_t idx) { fMaxIndex=idx; }
|
---|
149 |
|
---|
150 | // Float_t GetRawTimeFirst() const { return fTimeFirst; }
|
---|
151 | // Float_t GetRawTimeLast() const { return fTimeLast; }
|
---|
152 |
|
---|
153 | Float_t GetTimeFirst() const { return fTimeFirst; }
|
---|
154 | Float_t GetTimeLast() const { return fTimeLast; }
|
---|
155 |
|
---|
156 | Int_t GetMaxIndex() const { return fMaxIndex; }
|
---|
157 |
|
---|
158 | Bool_t IsValid() const { return fTimeLast>=fTimeFirst; }
|
---|
159 |
|
---|
160 | ClassDef(MPhotonStatistics, 1)
|
---|
161 | };
|
---|
162 | #endif
|
---|