source: trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h@ 650

Last change on this file since 650 was 650, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 2.8 KB
Line 
1#ifndef MRAWEVTPIXELITER_H
2#define MRAWEVTPIXELITER_H
3///////////////////////////////////////////////////////////////////////////////
4//
5// MRawEvtPixelIter
6//
7// class to iterate over all pixels of one event.
8//
9///////////////////////////////////////////////////////////////////////////////
10#ifndef MAGIC_H
11#include "MAGIC.h"
12#endif
13
14class MRawEvtData;
15
16class MRawEvtPixelIter
17{
18private:
19 UShort_t fNumHiGainEntry; //! actual number of entry in fHiGainPixId
20 UShort_t fNumLoGainEntry; //! actual number of entry in fLoGainPixId
21
22 UShort_t *fHiGainId; //! actual entry of fHiGainPixId
23 UShort_t *fLoGainId; //! actual entry of fLoGainPixId
24
25 Byte_t *fHiGainPos; //! pointer to hi-gain samples of actual pixel
26 Byte_t *fLoGainPos; //! pointer to lo-gain samples of actual pixel
27
28 MRawEvtData *fData; //! pointer to object which we are iterating
29
30public:
31 MRawEvtPixelIter(MRawEvtData *dat) : fData(dat)
32 {
33 Reset();
34 }
35
36 MRawEvtData *Next();
37
38 UShort_t GetPixelId() const
39 {
40 //
41 // return Id of actual pixel
42 //
43 return *fHiGainId;
44 }
45
46 Byte_t *GetHiGainFadcSamples() const
47 {
48 //
49 // return a pointer to the fadc samples of the hi gains
50 // WARNING: Don't forget to get the number of valid entries
51 // (GetNumSamples) to know how many entries of the array
52 // belong to the actual pixel
53 //
54 return fHiGainPos;
55 }
56
57 ULong_t GetSumHiGainFadcSamples() const
58 {
59 //
60 // return the sum of the hi gain samples of the present pixel
61 //
62 Byte_t *ptr = fHiGainPos;
63 const Byte_t *end = ptr + fData->GetNumHiGainSamples();
64
65 ULong_t sum=0;
66
67 do sum += *ptr++;
68 while (ptr != end);
69
70 return sum;
71 }
72
73 Bool_t IsLoGain() const
74 {
75 //
76 // return kTRUE the lo gains exist for the actual pixel, else return kFALSE
77 //
78 return *fHiGainId==*fLoGainId;
79 }
80
81 Byte_t *GetLoGainFadcSamples() const
82 {
83 //
84 // return a pointer to the fadc samples of the lo gains if they exist
85 // for the actual pixel, else return zero
86 //
87 return IsLoGain() ? fLoGainPos : NULL;
88 }
89
90 ULong_t GetSumLoGainFadcSamples() const
91 {
92 //
93 // return the sum of the lo gain samples of the present pixel
94 //
95 if (!IsLoGain())
96 return 0;
97
98 Byte_t *ptr = fLoGainPos;
99 const Byte_t *end = ptr + fData->GetNumLoGainSamples();
100
101 ULong_t sum=0;
102
103 do sum += *ptr++;
104 while (ptr != end);
105
106 return sum;
107 }
108
109 void Reset();
110
111 void Draw(Option_t *t="GRAPH");
112
113 ClassDef(MRawEvtPixelIter, 1) // iterates over all pixels of one MRawEvtData object
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.