GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GPSIConverter.h
Go to the documentation of this file.
1 /********************************************************************************************/
2 #ifndef GW_GPSICONVERTER_H
3 #define GW_GPSICONVERTER_H
4 
5 #ifndef GW_HISTODB_H
6 #include "HistoDB.h"
7 #endif
8 
9 #define MAX_SP 254
10 
11 /*
12 Base class to read gpsi files.
13 
14 Currently only reading of gpsi files is implemented to be able to get old spectra. The type
15 for this format is gpsi. So to open a gpsi file via HistoDB: \n
16  - HistoDB hdb; hdb.Open("onegpsi","gpsi:toto.s");
17 
18 You can browse it with hdb.ls() to get a full list of spectra in this file. You can load
19 single spectrum one by one or use the THStack to load several spectra in one operation. To
20 do this, just give a name to the THStack that is a pattern of the spectra you want. Suppose
21 you want to load only the spectra with a name starting with P1, then use HistoDB as following:
22  - THstack hs; hs.SetName("P1*"); hdb >> hs;
23 
24 The THStack in not cleared by HistoDB, to be able to use it in adding mode. \n
25 The converter try to guess on which operating system the file has been created
26 (little or big endian). So in principle, there no need to worry about where the file
27 has been created. It also somehow checks if the given file is likely to be a gpsi file.
28 Those operations may produce a error when trying to read a spectrum.
29 
30 \author Christophe Theisen & Olivier Stezowski
31 */
32 
33 using namespace Gw;
34 
36 {
37 private:
38  std::ifstream fStreamIN; // stream used to read the gpsi file
39 
41  struct Header {
42  short fNbSpectra; // number of spectrum in xxx.s
43  short fFileSize; // filesize ( unit 512 Ko)
44  short fWhere[MAX_SP]; // position to read/write spectrum
45  } fHeader ;
46 
48  struct Label {
49  char fSpName[12]; // name of the spectrum
50  int fNx; // dimension x
51  int fNy; // dimension y
52  } fLabel[MAX_SP] ;
53 
55  bool ReadHeaders();
56 
57 
58 public:
59  GPSIConverter();
60  GPSIConverter(const char *name);
61  virtual ~GPSIConverter();
62 
63  virtual TH1 *Get(int);
64  virtual TH1 *Get(const char *);
65 
66  virtual bool Read(TH1 &);
67  virtual bool Write(const TH1 &);
68 
69  virtual bool Read(TH2 &);
70  virtual bool Write(const TH2 &);
71 
72  virtual bool Read(THStack &);
73  virtual bool Write(const THStack &);
74 
75  virtual HistoConverter *NewDB(const char *) const;
76 
77  virtual const char *GetType() const { return fType.Data(); }
78 
79  virtual void ls(Option_t *) const ;
80 
81  virtual void CheckDirectory(const char *name);
82 };
83 
84 
85 #endif
header file for the HistoDB facility
virtual const char * GetType() const
to know what type of HistoConverter system it is
Definition: GPSIConverter.h:77
#define MAX_SP
Definition: GPSIConverter.h:9