| 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 <mailto: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 | fData->Draw(Form("%s%d", t, *fHiGainId));
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | // --------------------------------------------------------------------------
|
|---|
| 149 | //
|
|---|
| 150 | // returns the sum of all hi gain fadc samples of the actual pixel
|
|---|
| 151 | //
|
|---|
| 152 | ULong_t MRawEvtPixelIter::GetSumHiGainSamples() const
|
|---|
| 153 | {
|
|---|
| 154 | //
|
|---|
| 155 | // return the sum of the hi gain samples of the present pixel
|
|---|
| 156 | //
|
|---|
| 157 | Byte_t *ptr = fHiGainPos;
|
|---|
| 158 | const Byte_t *end = ptr + fNumHiGainSamples;
|
|---|
| 159 |
|
|---|
| 160 | ULong_t sum=0;
|
|---|
| 161 |
|
|---|
| 162 | do sum += *ptr++;
|
|---|
| 163 | while (ptr != end);
|
|---|
| 164 |
|
|---|
| 165 | return sum;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | // --------------------------------------------------------------------------
|
|---|
| 169 | //
|
|---|
| 170 | // returns the sum of all lo gain fadc samples of the actual pixel.
|
|---|
| 171 | // if no lo gain information is available 0 is returned.
|
|---|
| 172 | //
|
|---|
| 173 | ULong_t MRawEvtPixelIter::GetSumLoGainSamples() const
|
|---|
| 174 | {
|
|---|
| 175 | //
|
|---|
| 176 | // return the sum of the lo gain samples of the present pixel
|
|---|
| 177 | //
|
|---|
| 178 | if (!HasLoGain())
|
|---|
| 179 | return 0;
|
|---|
| 180 |
|
|---|
| 181 | Byte_t *ptr = fLoGainPos;
|
|---|
| 182 | const Byte_t *end = ptr + fNumLoGainSamples;
|
|---|
| 183 |
|
|---|
| 184 | ULong_t sum=0;
|
|---|
| 185 |
|
|---|
| 186 | do sum += *ptr++;
|
|---|
| 187 | while (ptr != end);
|
|---|
| 188 |
|
|---|
| 189 | return sum;
|
|---|
| 190 | }
|
|---|