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 | // --------------------------------------------------------------------------
|
---|
59 | //
|
---|
60 | // Return the number of stored pixels
|
---|
61 | //
|
---|
62 | Byte_t MRawEvtPixelIter::GetNumPixels() const
|
---|
63 | {
|
---|
64 | return fData->GetNumPixels();
|
---|
65 | }
|
---|
66 |
|
---|
67 | // --------------------------------------------------------------------------
|
---|
68 | //
|
---|
69 | // It steps to the next pixel. If there is no next pixel NULL is returned.
|
---|
70 | // If a next pixel where found, a pointer to the primary given (constructor)
|
---|
71 | // data structur is returned.
|
---|
72 | //
|
---|
73 | MRawEvtData *MRawEvtPixelIter::Next()
|
---|
74 | {
|
---|
75 | //
|
---|
76 | // if we are already at the last entry there is no 'next' entry anymore
|
---|
77 | //
|
---|
78 | if (fNumHiGainEntry==fData->fHiGainPixId->GetSize())
|
---|
79 | return NULL;
|
---|
80 |
|
---|
81 | //
|
---|
82 | // if we are already at the last entry there is no 'next' entry anymore
|
---|
83 | //
|
---|
84 | if (fNumLoGainEntry != fData->fLoGainPixId->GetSize())
|
---|
85 | if (*fHiGainId == *fLoGainId)
|
---|
86 | {
|
---|
87 | //
|
---|
88 | // if higainpixid and logainpixid of the actual pixel are
|
---|
89 | // identical then we have to move the pointer to the next
|
---|
90 | // entry in the lo gains
|
---|
91 | //
|
---|
92 | fNumLoGainEntry++;
|
---|
93 | fLoGainId++;
|
---|
94 | fLoGainPos += fData->GetNumLoGainSamples();
|
---|
95 | }
|
---|
96 |
|
---|
97 | //
|
---|
98 | // here we have to move the pointer to the next entry in the hi gains
|
---|
99 | //
|
---|
100 | fNumHiGainEntry++;
|
---|
101 | fHiGainId++;
|
---|
102 | fHiGainPos += fData->GetNumHiGainSamples();
|
---|
103 |
|
---|
104 | //
|
---|
105 | // return a pointer to the 'source' class if we succeed
|
---|
106 | //
|
---|
107 | return fData;
|
---|
108 | }
|
---|
109 |
|
---|
110 | // --------------------------------------------------------------------------
|
---|
111 | //
|
---|
112 | // Reset the iteration. Jump to the first pixel.
|
---|
113 | //
|
---|
114 | void MRawEvtPixelIter::Reset()
|
---|
115 | {
|
---|
116 | //
|
---|
117 | // set counter to zero
|
---|
118 | //
|
---|
119 | fNumLoGainEntry = 0;
|
---|
120 | fNumHiGainEntry = 0;
|
---|
121 |
|
---|
122 | //
|
---|
123 | // set pointer to first entry of arrays
|
---|
124 | //
|
---|
125 | fHiGainId = fData->fHiGainPixId->GetArray()-1;
|
---|
126 | fLoGainId = fData->fLoGainPixId->GetArray()-1;
|
---|
127 | fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fData->GetNumHiGainSamples();
|
---|
128 | fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fData->GetNumLoGainSamples();
|
---|
129 | }
|
---|
130 |
|
---|
131 | // --------------------------------------------------------------------------
|
---|
132 | //
|
---|
133 | // Calls the draw-function of the actual pixel (see MRawEvtData::Draw)
|
---|
134 | //
|
---|
135 | void MRawEvtPixelIter::Draw(Option_t *t)
|
---|
136 | {
|
---|
137 | char *txt = new char[6+strlen(t)];
|
---|
138 | sprintf(txt, "%s%d", t, *fHiGainId);
|
---|
139 | fData->Draw(txt);
|
---|
140 | delete txt;
|
---|
141 | }
|
---|
142 |
|
---|
143 | // --------------------------------------------------------------------------
|
---|
144 | //
|
---|
145 | // returns the sum of all hi gain fadc samples of the actual pixel
|
---|
146 | //
|
---|
147 | ULong_t MRawEvtPixelIter::GetSumHiGainFadcSamples() const
|
---|
148 | {
|
---|
149 | //
|
---|
150 | // return the sum of the hi gain samples of the present pixel
|
---|
151 | //
|
---|
152 | Byte_t *ptr = fHiGainPos;
|
---|
153 | const Byte_t *end = ptr + fData->GetNumHiGainSamples();
|
---|
154 |
|
---|
155 | ULong_t sum=0;
|
---|
156 |
|
---|
157 | do sum += *ptr++;
|
---|
158 | while (ptr != end);
|
---|
159 |
|
---|
160 | return sum;
|
---|
161 | }
|
---|
162 |
|
---|
163 | // --------------------------------------------------------------------------
|
---|
164 | //
|
---|
165 | // returns the sum of all lo gain fadc samples of the actual pixel.
|
---|
166 | // if no lo gain information is available 0 is returned.
|
---|
167 | //
|
---|
168 | ULong_t MRawEvtPixelIter::GetSumLoGainFadcSamples() const
|
---|
169 | {
|
---|
170 | //
|
---|
171 | // return the sum of the lo gain samples of the present pixel
|
---|
172 | //
|
---|
173 | if (!HasLoGain())
|
---|
174 | return 0;
|
---|
175 |
|
---|
176 | Byte_t *ptr = fLoGainPos;
|
---|
177 | const Byte_t *end = ptr + fData->GetNumLoGainSamples();
|
---|
178 |
|
---|
179 | ULong_t sum=0;
|
---|
180 |
|
---|
181 | do sum += *ptr++;
|
---|
182 | while (ptr != end);
|
---|
183 |
|
---|
184 | return sum;
|
---|
185 | }
|
---|