source: trunk/Mars/mraw/MRawEvtData.h@ 14348

Last change on this file since 14348 was 11555, checked in by tbretz, 13 years ago
added fIsSigned; adapted GetSample; added GetMin; changed code in GetMax
File size: 3.8 KB
Line 
1#ifndef MARS_MRawEvtData
2#define MARS_MRawEvtData
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7#ifndef MARS_MCamEvent
8#include "MCamEvent.h"
9#endif
10
11// gcc 3.2
12//class ifstream;
13#include <iosfwd>
14
15class MRawRunHeader;
16class MRawCrateArray;
17
18class TArrayC;
19class MArrayS;
20class MArrayB;
21class MArrayI;
22
23class MRawEvtData : public MParContainer, public MCamEvent
24{
25 friend class MRawEvtPixelIter;
26private:
27 MRawRunHeader *fRunHeader; //! provides information about numbers
28
29 // FIXME: COMMENT ABOUT ORDERING
30
31 MArrayS *fHiGainPixId; //-> list of pixel IDs of hi gain channel
32 MArrayB *fHiGainFadcSamples; //-> list of hi gain samples of all pixels (ordering: see fHiGainPixId)
33
34 MArrayS *fLoGainPixId; //-> list of pixel IDs of lo gain channel
35 MArrayB *fLoGainFadcSamples; //-> list of lo gain samples of all pixels (ordering: see fLoGainPixId)
36
37 MArrayB *fABFlags; //-> A information about the exact trigger position
38 MArrayS *fStartCells; //
39
40 UShort_t fNumBytesPerSample;
41
42 Bool_t fIsSigned;
43
44 Int_t fConnectedPixels; //!
45
46 void InitArrays(UShort_t numconnected=0, UShort_t maxid=0);
47 void DeleteArrays();
48
49 Int_t GetNumBytes() const;
50
51 Long_t GetSample(const void *ptr, Int_t n) // Helper for Draw
52 {
53 fIsSigned = kTRUE;
54 switch (fNumBytesPerSample)
55 {
56 case 1: return fIsSigned ? (Long_t)reinterpret_cast<const Char_t*>(ptr)[n] : (Long_t)reinterpret_cast<const Byte_t*>(ptr)[n];
57 case 2: return fIsSigned ? (Long_t)reinterpret_cast<const Short_t*>(ptr)[n] : (Long_t)reinterpret_cast<const UShort_t*>(ptr)[n];
58 case 4: return fIsSigned ? (Long_t)reinterpret_cast<const Int_t*>(ptr)[n] : (Long_t)reinterpret_cast<const UInt_t*>(ptr)[n];
59 }
60 return 0;
61 }
62
63
64public:
65 MRawEvtData(const char *name=NULL, const char *title=NULL);
66 ~MRawEvtData();
67
68 void InitRead(MRawRunHeader *rh)
69 {
70 //
71 // you have to set this before you can read information
72 // from a magic binary file
73 //
74 fRunHeader = rh;
75 }
76
77 void Clear(Option_t * = NULL);
78 void Print(Option_t * = NULL) const;
79 void Draw (Option_t * = NULL);
80
81 void ResetPixels();
82 void ResetPixels(UShort_t npix, UShort_t maxid);
83 void InitStartCells();
84 void AddPixel(UShort_t nOfPixel, const TArrayC &data);
85 void Set(const MArrayI &data);
86 void SetIndices(const MArrayS &idx);
87 void SetIndices();
88
89 UShort_t GetNumHiGainSamples() const;
90 UShort_t GetNumLoGainSamples() const;
91 UInt_t GetNumSamples() const { return GetNumHiGainSamples()+GetNumLoGainSamples(); }
92 UShort_t GetNumPixels() const;
93
94 UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; }
95 UInt_t GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
96 Long_t GetMin() const { return fIsSigned ? -GetMax()-1 : 0; }
97 Long_t GetMax() const {
98 switch (fNumBytesPerSample)
99 {
100 case 1: return fIsSigned ? 0x7f : 0xff;
101 case 2: return fIsSigned ? 0x7fff : 0xffff;
102 case 4: return fIsSigned ? 0x7fffffff : 0xffffffff;
103 }
104 return 0;
105 }
106 Byte_t *GetSamples() const;
107 UShort_t *GetStartCells() const;
108 UShort_t *GetPixelIds() const;
109
110 Bool_t HasStartCells() const;
111
112 void ReadPixel(istream &fin, Int_t npix);
113 void SetABFlag(Int_t npix, Bool_t ab);
114 void SkipEvt(istream &fin);
115
116 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
117 void DrawPixelContent(Int_t num) const
118 {
119 TString s("HIST");
120 s += num;
121 const_cast<MRawEvtData*>(this)->Draw(s);
122 }
123
124 void Copy(TObject &named)
125#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
126 const
127#endif
128 ;
129
130 ClassDef(MRawEvtData, 8) //Container to store the raw Event Data
131};
132
133#endif
Note: See TracBrowser for help on using the repository browser.