source: trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc@ 651

Last change on this file since 651 was 651, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 3.4 KB
Line 
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.IsLoGain(); // 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
32ClassImp(MRawEvtPixelIter)
33
34MRawEvtData *MRawEvtPixelIter::Next()
35{
36 //
37 // if we are already at the last entry there is no 'next' entry anymore
38 //
39 if (fNumHiGainEntry==fData->fHiGainPixId->GetSize())
40 return NULL;
41
42 //
43 // if we are already at the last entry there is no 'next' entry anymore
44 //
45 if (fNumLoGainEntry != fData->fLoGainPixId->GetSize())
46 if (*fHiGainId == *fLoGainId)
47 {
48 //
49 // if higainpixid and logainpixid of the actual pixel are
50 // identical then we have to move the pointer to the next
51 // entry in the lo gains
52 //
53 fNumLoGainEntry++;
54 fLoGainId++;
55 fLoGainPos += fData->GetNumLoGainSamples();
56 }
57
58 //
59 // here we have to move the pointer to the next entry in the hi gains
60 //
61 fNumHiGainEntry++;
62 fHiGainId++;
63 fHiGainPos += fData->GetNumHiGainSamples();
64
65 //
66 // return a pointer to the 'source' class if we succeed
67 //
68 return fData;
69}
70
71void MRawEvtPixelIter::Reset()
72{
73 //
74 // set counter to zero
75 //
76 fNumLoGainEntry = 0;
77 fNumHiGainEntry = 0;
78
79 //
80 // set pointer to first entry of arrays
81 //
82 fHiGainId = fData->fHiGainPixId->GetArray()-1;
83 fLoGainId = fData->fLoGainPixId->GetArray()-1;
84 fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fData->GetNumHiGainSamples();
85 fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fData->GetNumLoGainSamples();
86}
87
88void MRawEvtPixelIter::Draw(Option_t *t)
89{
90 //
91 // Draw the actual pixel (for options see: MRawEvtData::Draw)
92 //
93 char *txt = new char[6+strlen(t)];
94 sprintf(txt, "%s%d", t, *fHiGainId);
95 fData->Draw(txt);
96 delete txt;
97}
98
99ULong_t MRawEvtPixelIter::GetSumHiGainFadcSamples() const
100{
101 //
102 // return the sum of the hi gain samples of the present pixel
103 //
104 Byte_t *ptr = fHiGainPos;
105 const Byte_t *end = ptr + fData->GetNumHiGainSamples();
106
107 ULong_t sum=0;
108
109 do sum += *ptr++;
110 while (ptr != end);
111
112 return sum;
113}
114
115ULong_t MRawEvtPixelIter::GetSumLoGainFadcSamples() const
116{
117 //
118 // return the sum of the lo gain samples of the present pixel
119 //
120 if (!IsLoGain())
121 return 0;
122
123 Byte_t *ptr = fLoGainPos;
124 const Byte_t *end = ptr + fData->GetNumLoGainSamples();
125
126 ULong_t sum=0;
127
128 do sum += *ptr++;
129 while (ptr != end);
130
131 return sum;
132}
133
Note: See TracBrowser for help on using the repository browser.