1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | ///////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MRawEvtPixelIter
|
---|
28 | //
|
---|
29 | // class to iterate over all pixels of one event.
|
---|
30 | // The calling is similar to a root iterator:
|
---|
31 | //
|
---|
32 | // MRawEvtData *evtdata; // must be filled with data from somewhere
|
---|
33 | // MRawEvtPixelIter pixel(evtdata); // evtdata: ptr to event you want to iterate
|
---|
34 | //
|
---|
35 | // while (pixel.Next())
|
---|
36 | // {
|
---|
37 | // // here you can access the actual time slices by using
|
---|
38 | // // pixel.GetPixelId();
|
---|
39 | // // pixel.GetHiGainFadcSamples()[i]; // i is the number of the slice
|
---|
40 | // // pixel.HasLoGain(); // check if pixel has
|
---|
41 | // // pixel.GetLoGainFadcSamples()[i]; // i is the number of the slice
|
---|
42 | //
|
---|
43 | // // WARNING: Don't acces more time slices than available.
|
---|
44 | // // Get the numbers by calling: evtdata->GetNum[Lo,Hi]GainSamples()
|
---|
45 | // // This number is constant for one event
|
---|
46 | // }
|
---|
47 | //
|
---|
48 | ///////////////////////////////////////////////////////////////////////////////
|
---|
49 | #include "MRawEvtPixelIter.h"
|
---|
50 |
|
---|
51 | #include "MRawEvtData.h"
|
---|
52 |
|
---|
53 | #include "MArrayS.h"
|
---|
54 | #include "MArrayB.h"
|
---|
55 |
|
---|
56 | ClassImp(MRawEvtPixelIter);
|
---|
57 |
|
---|
58 | MRawEvtPixelIter::MRawEvtPixelIter(MRawEvtData *dat) : fData(dat)
|
---|
59 | {
|
---|
60 | fNumHiGainSamples = dat->GetNumHiGainSamples();
|
---|
61 | fNumLoGainSamples = dat->GetNumLoGainSamples();
|
---|
62 |
|
---|
63 | Reset();
|
---|
64 | }
|
---|
65 |
|
---|
66 | // --------------------------------------------------------------------------
|
---|
67 | //
|
---|
68 | // Return the number of stored pixels
|
---|
69 | //
|
---|
70 | Byte_t MRawEvtPixelIter::GetNumPixels() const
|
---|
71 | {
|
---|
72 | return fData->GetNumPixels();
|
---|
73 | }
|
---|
74 |
|
---|
75 | // --------------------------------------------------------------------------
|
---|
76 | //
|
---|
77 | // It steps to the next pixel. If there is no next pixel NULL is returned.
|
---|
78 | // If a next pixel where found, a pointer to the primary given (constructor)
|
---|
79 | // data structur is returned.
|
---|
80 | //
|
---|
81 | MRawEvtData *MRawEvtPixelIter::Next()
|
---|
82 | {
|
---|
83 | //
|
---|
84 | // if we are already at the last entry there is no 'next' entry anymore
|
---|
85 | //
|
---|
86 | if (fNumHiGainEntry==fData->fHiGainPixId->GetSize())
|
---|
87 | return NULL;
|
---|
88 |
|
---|
89 | //
|
---|
90 | // if we are already at the last entry there is no 'next' entry anymore
|
---|
91 | //
|
---|
92 | if (fNumLoGainEntry != fData->fLoGainPixId->GetSize())
|
---|
93 | if (*fHiGainId == *fLoGainId)
|
---|
94 | {
|
---|
95 | //
|
---|
96 | // if higainpixid and logainpixid of the actual pixel are
|
---|
97 | // identical then we have to move the pointer to the next
|
---|
98 | // entry in the lo gains
|
---|
99 | //
|
---|
100 | fNumLoGainEntry++;
|
---|
101 | fLoGainId++;
|
---|
102 | fLoGainPos += fNumLoGainSamples;
|
---|
103 | }
|
---|
104 |
|
---|
105 | //
|
---|
106 | // here we have to move the pointer to the next entry in the hi gains
|
---|
107 | //
|
---|
108 | fNumHiGainEntry++;
|
---|
109 | fHiGainId++;
|
---|
110 | fHiGainPos += fNumHiGainSamples;
|
---|
111 |
|
---|
112 | //
|
---|
113 | // return a pointer to the 'source' class if we succeed
|
---|
114 | //
|
---|
115 | return fData;
|
---|
116 | }
|
---|
117 |
|
---|
118 | // --------------------------------------------------------------------------
|
---|
119 | //
|
---|
120 | // Reset the iteration. Jump to the first pixel.
|
---|
121 | //
|
---|
122 | void MRawEvtPixelIter::Reset()
|
---|
123 | {
|
---|
124 | //
|
---|
125 | // set counter to zero
|
---|
126 | //
|
---|
127 | fNumLoGainEntry = 0;
|
---|
128 | fNumHiGainEntry = 0;
|
---|
129 |
|
---|
130 | //
|
---|
131 | // set pointer to first entry of arrays
|
---|
132 | //
|
---|
133 | fHiGainId = fData->fHiGainPixId->GetArray()-1;
|
---|
134 | fLoGainId = fData->fLoGainPixId->GetArray()-1;
|
---|
135 | fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fNumHiGainSamples;
|
---|
136 | fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fNumLoGainSamples;
|
---|
137 | }
|
---|
138 |
|
---|
139 | // --------------------------------------------------------------------------
|
---|
140 | //
|
---|
141 | // Calls the draw-function of the actual pixel (see MRawEvtData::Draw)
|
---|
142 | //
|
---|
143 | void MRawEvtPixelIter::Draw(Option_t *t)
|
---|
144 | {
|
---|
145 | char *txt = new char[6+strlen(t)];
|
---|
146 | sprintf(txt, "%s%d", t, *fHiGainId);
|
---|
147 | fData->Draw(txt);
|
---|
148 | delete txt;
|
---|
149 | }
|
---|
150 |
|
---|
151 | // --------------------------------------------------------------------------
|
---|
152 | //
|
---|
153 | // returns the sum of all hi gain fadc samples of the actual pixel
|
---|
154 | //
|
---|
155 | ULong_t MRawEvtPixelIter::GetSumHiGainSamples() const
|
---|
156 | {
|
---|
157 | //
|
---|
158 | // return the sum of the hi gain samples of the present pixel
|
---|
159 | //
|
---|
160 | Byte_t *ptr = fHiGainPos;
|
---|
161 | const Byte_t *end = ptr + fNumHiGainSamples;
|
---|
162 |
|
---|
163 | ULong_t sum=0;
|
---|
164 |
|
---|
165 | do sum += *ptr++;
|
---|
166 | while (ptr != end);
|
---|
167 |
|
---|
168 | return sum;
|
---|
169 | }
|
---|
170 |
|
---|
171 | // --------------------------------------------------------------------------
|
---|
172 | //
|
---|
173 | // returns the sum of all lo gain fadc samples of the actual pixel.
|
---|
174 | // if no lo gain information is available 0 is returned.
|
---|
175 | //
|
---|
176 | ULong_t MRawEvtPixelIter::GetSumLoGainSamples() const
|
---|
177 | {
|
---|
178 | //
|
---|
179 | // return the sum of the lo gain samples of the present pixel
|
---|
180 | //
|
---|
181 | if (!HasLoGain())
|
---|
182 | return 0;
|
---|
183 |
|
---|
184 | Byte_t *ptr = fLoGainPos;
|
---|
185 | const Byte_t *end = ptr + fNumLoGainSamples;
|
---|
186 |
|
---|
187 | ULong_t sum=0;
|
---|
188 |
|
---|
189 | do sum += *ptr++;
|
---|
190 | while (ptr != end);
|
---|
191 |
|
---|
192 | return sum;
|
---|
193 | }
|
---|