Analysis  version 7.0 - august 2014
GanilBuffer.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GanilBuffer.hh
3  *
4  * Déclaration des méthodes de la classe GanilBuffer qui gère les
5  * buffers de l'acquisition GANIL.
6  */
7 //======================================================================
8 
9 #ifndef GANIL_BUFFER_HH
10 #define GANIL_BUFFER_HH
11 
12 #include "GanilCommon.hh"
13 #include "GanilEventBufferInfo.hh"
14 
15 #define GANIL_BUFFER_DEFAULT_SIZE 16384 ///< Taille par défaut des buffers GANIL
16 #define GANIL_BUFFER_TYPE_NUMBER 11 ///< Nombre de types de buffers GANIL
17 
18 
19 class GanilRun;
20 
21 //======================================================================
22 /*! \class GanilBuffer
23  *
24  * Classe qui gère les buffers d'acquisition GANIL.
25  */
27 {
28  friend class GanilRun;
29  friend class GanilScaler;
30 
31  /// Types de buffers de l'acquisition GANIL
33  {
34  bufferTypeUnknown = 0, // Numero d'identification de buffer de type inconnu
35  bufferTypeFileh = 1, // Numero d'identification de buffer de type FILEH
36  bufferTypeEventh = 2, // Numero d'identification de buffer de type EVENTH
37  bufferTypeComment = 3, // Numero d'identification de buffer de type COMMENT
38  bufferTypeParam = 4, // Numero d'identification de buffer de type PARAM
39  bufferTypeScaler = 5, // Numero d'identification de buffer de type SCALER
40  bufferTypeEventdb = 6, // Numero d'identification de buffer de type EVENTDB
41  bufferTypeEbyedat = 7, // Numero d'identification de buffer de type EBYEDAT
42  bufferTypeSpecth = 8, // Numero d'identification de buffer de type SPECTH
43  bufferTypeSpectd = 9, // Numero d'identification de buffer de type SPECTD
44  bufferTypeEndrun = 10 // Numero d'identification de buffer de type ENDRUN
45  };
46 
47  ///flags d'information (bits 16 a 31: specifique type d'analyse)
49  {
50  bufferFlagFileh = 0x00010000, // Bit d'état indiquant la lecture de buffers FILEH
51  bufferFlagEventh = 0x00020000, // Bit d'état indiquant la lecture de buffers EVENTH
52  bufferFlagComment = 0x00040000, // Bit d'état indiquant la lecture de buffers COMMENT
53  bufferFlagParam = 0x00080000, // Bit d'état indiquant la lecture de buffers PARAM
54  bufferFlagScaler = 0x00100000, // Bit d'état indiquant la lecture de buffers SCALER
55  bufferFlagEventdb = 0x00200000, // Bit d'état indiquant la lecture de buffers EVENTDB
56  bufferFlagEbyedat = 0x00400000, // Bit d'état indiquant la lecture de buffers EBYEDAT
57  bufferFlagSpecth = 0x00800000, // Bit d'état indiquant la lecture de buffers SPECTH
58  bufferFlagSpectd = 0x01000000, // Bit d'état indiquant la lecture de buffers SPECTD
59  bufferFlagEndrun = 0x02000000, // Bit d'état indiquant la lecture de buffers ENDRUN
60 
61  bufferFlagHeader = 0x000F0000, // Masque sur les bits d'état des buffers d'entête
62  bufferFlagEvent = 0x00600000 // Masque sur les bits d'état des buffers d'événement
63  };
64 
65 //----------------------------------------------------------------------
66  /*! \object_doc */
68 //----------------------------------------------------------------------
69 
70  protected:
71  u_int size; ///< taille du buffer
72  u_int cursor; ///< position dans le buffer
73  bool eob; ///< test de la fin de buffer
74  u_int type; ///< type de buffer
75  string id; ///< chaîne d'identification du type de buffer
76  u_int number; ///< numéro de buffer
77  u_int event_num; ///< numéro d'événement (acq. GANIL)
78  GanilRun * run_base; ///< pointeur sur le gestinnaire du run
79 
80  /// table des statistiques de types de buffer
82 
83 #ifndef __MAKECINT__
84  byte * buffer; ///< pointeur sur la table du buffer
85 #endif
86 
87 
88  GanilEventBufferInfo buffer_info; ///< Information des buffers de type EBYEDAT
89 
90  public:
91 
92  // constructeur
93  GanilBuffer ( GanilRun *ptr = NULL, const u_int s = GANIL_BUFFER_DEFAULT_SIZE );
94 
95  // constructeur de recopie
96  GanilBuffer ( const GanilBuffer & );
97 
98  // opérateur d'affectation
99  virtual GanilBuffer & operator = ( const GanilBuffer &original );
100 
101  // destructeur
102  virtual ~GanilBuffer ( );
103 
104 //----------------------------------------------------------------------
105 
106  protected:
107  // détermine le type de buffer
108  void SetType ( );
109 
110  // saisie des infos d'un buffer EBYEDAT
111  void SetEbyedatInfo ( );
112 
113  // saisie des infos d'un buffer EVENTDB
114  void SetEventDBInfo ( );
115 
116 //----------------------------------------------------------------------
117  public:
118  GanilRun * GetRunBase ( ) const;
119  u_int Size ( ) const;
120  u_int GetType ( ) const;
121  string GetId ( ) const;
122  u_int GetNumber ( ) const;
123  u_int GetEventNumber ( ) const;
124  bool EndOfBuffer ( ) const;
125 
126  u_int GetBufferStat ( const u_int t ) const;
127 
128  protected:
129  void SetEOB ( const bool b = true );
130 
131  // lecture d'un buffer
132  int Read ( FILE * );
133 
134  public:
135  // Extraction de données du buffer
136  string ExtractString ( const char end );
137  string ExtractString ( const u_int len );
138  Int2 ExtractInt2 ( );
139  Int4 ExtractInt4 ( );
140  U_Int2 ExtractUInt2 ( );
141  U_Int4 ExtractUInt4 ( );
142 
143  // Passe n caratères du buffer, pour des parties de buffer à ignorer.
144  void Skip ( const u_int n );
145 
146 //----------------------------------------------------------------------
147 
148  protected:
149 
150  // Initialisation d'un buffer
151  void Reset ( );
152 
153  // Lecture d'un événement
154  int ReadEvent ( GanilRun * );
155 
156  // Lecture d'un événement EVENTDB
157  int ReadEventDB ( GanilRun * );
158 
159  // Lecture d'un événement EBYEDAT
160  int ReadEbyedat ( GanilRun * );
161 
162 
163 //----------------------------------------------------------------------
164 // pour ROOT...
165  public:
166  /*! Définition à usage de ROOT... */
168 } ;
169 
170 
171 //======================================================================
172 // METHODES INLINE
173 //======================================================================
174 
175 /*! Retourne le pointeur sur le gestinnaire de run.*/
177  { return (run_base); }
178 
179 /*! Retourne la taille de buffer.*/
180 inline u_int GanilBuffer::Size() const
181  { return (size); }
182 
183 /*! Retourne le type de buffer.*/
184 inline u_int GanilBuffer::GetType() const
185  { return (type); }
186 
187 /*! Retourne l'identifiant du type de buffer.*/
188 inline string GanilBuffer::GetId() const
189  { return (id); }
190 
191 /*! Retourne le numéro de buffer.*/
192 inline u_int GanilBuffer::GetNumber() const
193  { return (number); }
194 
195 /*! Retourne le numéro d'événement GANIL.*/
196 inline u_int GanilBuffer::GetEventNumber() const
197  { return (event_num); }
198 
199 /*! Retourne vrai si le buffer est traité complètement.*/
200 inline bool GanilBuffer::EndOfBuffer() const
201  { return (eob); }
202 
203 /*! Positionne l'indication de fin de buffer.
204  * \param b état de l'indicateur
205  */
206 inline void GanilBuffer::SetEOB ( const bool b )
207  { eob = b; if (eob) cursor = size; }
208 
209 /*! Retourne le nombre de buffers d'un type donné. * \param t type de buffers */ inline u_int GanilBuffer::GetBufferStat ( const u_int t ) const { return ((t < GANIL_BUFFER_TYPE_NUMBER) ? stat[t] : 0); } /*! Passe \b n caratères du buffer, pour des parties de buffer * à ignorer. * \param n nombre d'octets à passer */ inline void GanilBuffer::Skip ( const u_int n ) { if (cursor+n < size) cursor += n; } //====================================================================== #endif
210  * \param t type de buffers
211  */
212 inline u_int GanilBuffer::GetBufferStat ( const u_int t ) const
213  { return ((t < GANIL_BUFFER_TYPE_NUMBER) ? stat[t] : 0); }
214 
215 
216 /*! Passe \b n caratères du buffer, pour des parties de buffer
217  * à ignorer.
218  * \param n nombre d'octets à passer
219  */
220 inline void GanilBuffer::Skip ( const u_int n )
221  { if (cursor+n < size) cursor += n; }
222 
223 
224 
225 //======================================================================
226 #endif
void Reset()
Definition: GanilBuffer.cpp:120
u_int GetNumber() const
Definition: GanilBuffer.hh:192
GanilEventBufferInfo buffer_info
Information des buffers de type EBYEDAT.
Definition: GanilBuffer.hh:88
#define GANIL_BUFFER_DEFAULT_SIZE
Taille par défaut des buffers GANIL.
Definition: GanilBuffer.hh:15
u_int GetType() const
Definition: GanilBuffer.hh:184
u_int number
numéro de buffer
Definition: GanilBuffer.hh:76
int ReadEvent(GanilRun *)
Definition: GanilBuffer.cpp:416
GanilBufferFlags
flags d&#39;information (bits 16 a 31: specifique type d&#39;analyse)
Definition: GanilBuffer.hh:48
GanilBuffer(GanilRun *ptr=NULL, const u_int s=16384)
Definition: GanilBuffer.cpp:22
Definition: GanilRun.hh:39
virtual GanilBuffer & operator=(const GanilBuffer &original)
Definition: GanilBuffer.cpp:74
U_Int4 ExtractUInt4()
Definition: GanilBuffer.cpp:384
void Skip(const u_int n)
Definition: GanilBuffer.hh:220
Int2 ExtractInt2()
Definition: GanilBuffer.cpp:327
u_int event_num
numéro d&#39;événement (acq. GANIL)
Definition: GanilBuffer.hh:77
void SetEventDBInfo()
Definition: GanilBuffer.cpp:195
unsigned short U_Int2
Définition du type entier 16 bits non signé
Definition: EventCommon.hh:32
#define GANIL_BUFFER_TYPE_NUMBER
Nombre de types de buffers GANIL.
Definition: GanilBuffer.hh:16
void SetEOB(const bool b=true)
Definition: GanilBuffer.hh:206
string id
chaîne d&#39;identification du type de buffer
Definition: GanilBuffer.hh:75
bool EndOfBuffer() const
Definition: GanilBuffer.hh:200
string GetId() const
Definition: GanilBuffer.hh:188
short Int2
Définition du type entier 16 bits.
Definition: EventCommon.hh:26
virtual ~GanilBuffer()
Definition: GanilBuffer.cpp:108
int ReadEventDB(GanilRun *)
Definition: GanilBuffer.cpp:443
u_int Size() const
Definition: GanilBuffer.hh:180
U_Int2 ExtractUInt2()
Definition: GanilBuffer.cpp:343
Definition: GanilEventBufferInfo.hh:21
int ReadEbyedat(GanilRun *)
Definition: GanilBuffer.cpp:599
GanilRun * run_base
pointeur sur le gestinnaire du run
Definition: GanilBuffer.hh:78
void SetEbyedatInfo()
Definition: GanilBuffer.cpp:180
Definition: GanilBuffer.hh:26
u_int cursor
position dans le buffer
Definition: GanilBuffer.hh:72
GanilRun * GetRunBase() const
Definition: GanilBuffer.hh:176
int Read(FILE *)
Definition: GanilBuffer.cpp:212
u_int stat[11]
table des statistiques de types de buffer
Definition: GanilBuffer.hh:81
string ExtractString(const char end)
Definition: GanilBuffer.cpp:285
GanilBufferTypes
Types de buffers de l&#39;acquisition GANIL.
Definition: GanilBuffer.hh:32
Definition: GanilScaler.hh:54
byte * buffer
pointeur sur la table du buffer
Definition: GanilBuffer.hh:84
int Int4
Définition du type entier 32 bits.
Definition: EventCommon.hh:38
GObject(GanilBuffer)
ClassDef(GanilBuffer, 0)
unsigned int U_Int4
Définition du type entier 32 bits non signé
Definition: EventCommon.hh:44
u_int type
type de buffer
Definition: GanilBuffer.hh:74
u_int GetEventNumber() const
Definition: GanilBuffer.hh:196
u_int size
taille du buffer
Definition: GanilBuffer.hh:71
void SetType()
Definition: GanilBuffer.cpp:136
Int4 ExtractInt4()
Definition: GanilBuffer.cpp:361
u_int GetBufferStat(const u_int t) const
Definition: GanilBuffer.hh:212
bool eob
test de la fin de buffer
Definition: GanilBuffer.hh:73