| 1 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // MRawEvtPixelIter
|
|---|
| 4 | //
|
|---|
| 5 | // class to iterate over all pixels of one event.
|
|---|
| 6 | // The calling is similar to a root iterator:
|
|---|
| 7 | //
|
|---|
| 8 | // MRawEvtData *evtdata; // must be filled with data from somewhere
|
|---|
| 9 | // MRawEvtPixelIter pixel(evtdata); // evtdata: ptr to event you want to iterate
|
|---|
| 10 | //
|
|---|
| 11 | // while (pixel.Next())
|
|---|
| 12 | // {
|
|---|
| 13 | // // here you can access the actual time slices by using
|
|---|
| 14 | // // pixel.GetPixelId();
|
|---|
| 15 | // // pixel.GetHiGainFadcSamples()[i]; // i is the number of the slice
|
|---|
| 16 | // // pixel.HasLoGain(); // check if pixel has
|
|---|
| 17 | // // pixel.GetLoGainFadcSamples()[i]; // i is the number of the slice
|
|---|
| 18 | //
|
|---|
| 19 | // // WARNING: Don't acces more time slices than available.
|
|---|
| 20 | // // Get the numbers by calling: evtdata->GetNum[Lo,Hi]GainSamples()
|
|---|
| 21 | // // This number is constant for one event
|
|---|
| 22 | // }
|
|---|
| 23 | //
|
|---|
| 24 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 25 | #include "MRawEvtPixelIter.h"
|
|---|
| 26 |
|
|---|
| 27 | #include "MRawEvtData.h"
|
|---|
| 28 |
|
|---|
| 29 | #include "MArrayS.h"
|
|---|
| 30 | #include "MArrayB.h"
|
|---|
| 31 |
|
|---|
| 32 | ClassImp(MRawEvtPixelIter)
|
|---|
| 33 |
|
|---|
| 34 | Byte_t MRawEvtPixelIter::GetNumPixels() const
|
|---|
| 35 | {
|
|---|
| 36 | return fData->GetNumPixels();
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | MRawEvtData *MRawEvtPixelIter::Next()
|
|---|
| 40 | {
|
|---|
| 41 | //
|
|---|
| 42 | // if we are already at the last entry there is no 'next' entry anymore
|
|---|
| 43 | //
|
|---|
| 44 | if (fNumHiGainEntry==fData->fHiGainPixId->GetSize())
|
|---|
| 45 | return NULL;
|
|---|
| 46 |
|
|---|
| 47 | //
|
|---|
| 48 | // if we are already at the last entry there is no 'next' entry anymore
|
|---|
| 49 | //
|
|---|
| 50 | if (fNumLoGainEntry != fData->fLoGainPixId->GetSize())
|
|---|
| 51 | if (*fHiGainId == *fLoGainId)
|
|---|
| 52 | {
|
|---|
| 53 | //
|
|---|
| 54 | // if higainpixid and logainpixid of the actual pixel are
|
|---|
| 55 | // identical then we have to move the pointer to the next
|
|---|
| 56 | // entry in the lo gains
|
|---|
| 57 | //
|
|---|
| 58 | fNumLoGainEntry++;
|
|---|
| 59 | fLoGainId++;
|
|---|
| 60 | fLoGainPos += fData->GetNumLoGainSamples();
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | //
|
|---|
| 64 | // here we have to move the pointer to the next entry in the hi gains
|
|---|
| 65 | //
|
|---|
| 66 | fNumHiGainEntry++;
|
|---|
| 67 | fHiGainId++;
|
|---|
| 68 | fHiGainPos += fData->GetNumHiGainSamples();
|
|---|
| 69 |
|
|---|
| 70 | //
|
|---|
| 71 | // return a pointer to the 'source' class if we succeed
|
|---|
| 72 | //
|
|---|
| 73 | return fData;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | void MRawEvtPixelIter::Reset()
|
|---|
| 77 | {
|
|---|
| 78 | //
|
|---|
| 79 | // set counter to zero
|
|---|
| 80 | //
|
|---|
| 81 | fNumLoGainEntry = 0;
|
|---|
| 82 | fNumHiGainEntry = 0;
|
|---|
| 83 |
|
|---|
| 84 | //
|
|---|
| 85 | // set pointer to first entry of arrays
|
|---|
| 86 | //
|
|---|
| 87 | fHiGainId = fData->fHiGainPixId->GetArray()-1;
|
|---|
| 88 | fLoGainId = fData->fLoGainPixId->GetArray()-1;
|
|---|
| 89 | fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fData->GetNumHiGainSamples();
|
|---|
| 90 | fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fData->GetNumLoGainSamples();
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | void MRawEvtPixelIter::Draw(Option_t *t)
|
|---|
| 94 | {
|
|---|
| 95 | //
|
|---|
| 96 | // Draw the actual pixel (for options see: MRawEvtData::Draw)
|
|---|
| 97 | //
|
|---|
| 98 | char *txt = new char[6+strlen(t)];
|
|---|
| 99 | sprintf(txt, "%s%d", t, *fHiGainId);
|
|---|
| 100 | fData->Draw(txt);
|
|---|
| 101 | delete txt;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | ULong_t MRawEvtPixelIter::GetSumHiGainFadcSamples() const
|
|---|
| 105 | {
|
|---|
| 106 | //
|
|---|
| 107 | // return the sum of the hi gain samples of the present pixel
|
|---|
| 108 | //
|
|---|
| 109 | Byte_t *ptr = fHiGainPos;
|
|---|
| 110 | const Byte_t *end = ptr + fData->GetNumHiGainSamples();
|
|---|
| 111 |
|
|---|
| 112 | ULong_t sum=0;
|
|---|
| 113 |
|
|---|
| 114 | do sum += *ptr++;
|
|---|
| 115 | while (ptr != end);
|
|---|
| 116 |
|
|---|
| 117 | return sum;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | ULong_t MRawEvtPixelIter::GetSumLoGainFadcSamples() const
|
|---|
| 121 | {
|
|---|
| 122 | //
|
|---|
| 123 | // return the sum of the lo gain samples of the present pixel
|
|---|
| 124 | //
|
|---|
| 125 | if (!HasLoGain())
|
|---|
| 126 | return 0;
|
|---|
| 127 |
|
|---|
| 128 | Byte_t *ptr = fLoGainPos;
|
|---|
| 129 | const Byte_t *end = ptr + fData->GetNumLoGainSamples();
|
|---|
| 130 |
|
|---|
| 131 | ULong_t sum=0;
|
|---|
| 132 |
|
|---|
| 133 | do sum += *ptr++;
|
|---|
| 134 | while (ptr != end);
|
|---|
| 135 |
|
|---|
| 136 | return sum;
|
|---|
| 137 | }
|
|---|