source: branches/Mars_MC/mfileio/MFitsArray.h@ 17832

Last change on this file since 17832 was 14935, checked in by tbretz, 12 years ago
Add changes necessary to remove fits completely from namespace std in MARS.
File size: 3.2 KB
Line 
1#ifndef MARS_MFitsArray
2#define MARS_MFitsArray
3
4//#include "astroroot.h"
5//#include "fitsio.h"
6#ifndef MARS_fits
7#include "fits.h"
8#endif
9
10#ifndef MARS_ofits
11#include "ofits.h"
12#endif
13
14class TClonesArray;
15class MLog;
16
17///////////////////////////////////////////////////////////////////////////////
18// A base class for arrays, which has to be written into their own FITS table
19class MArrayHelperBase
20{
21protected:
22
23 // the FITS table to which the data are written
24 ofits* fFitsTable;
25
26 // number of elements in fClonesArray / MArrayX / TArrayX during
27 // one write operation. This number is written into a column of
28 // the parent FITS table.
29 UInt_t fArraySize;
30
31public:
32 ofits* GetFitsTable() {return fFitsTable;}
33 UInt_t * GetArraySizePtr() {return &fArraySize;}
34
35 Bool_t OpenFitsTable(const char * baseFileName, const char * dataName,
36 const char * option, MLog * log);
37
38 virtual void InitCol() {}
39
40 virtual Int_t Read() = 0;
41 virtual void Write() = 0;
42
43};
44
45///////////////////////////////////////////////////////////////////////////////
46// A class to write data of one TClonesArray into one FITS table.
47class MClonesArrayHelper : public MArrayHelperBase
48{
49 // data of this TClonesArray are written to fFitsTable
50 TClonesArray * fClonesArray;
51
52
53
54 // fFitsTable writes during one fFitsTable.Write() call data which
55 // are currently stored in this buffer. That means the data pointers
56 // of fFitsTable for each column point to this data buffer.
57 Byte_t * fDataBuffer;
58
59 // the size of fDataBufferer.
60 Int_t fDataBufferSize;
61
62 // the first used byte in fDataBuffer
63 Int_t fStartOfData;
64
65public:
66 MClonesArrayHelper(TClonesArray * clonesArray, MLog * log, Bool_t & status);
67 MClonesArrayHelper(const MClonesArrayHelper & clHelper);
68
69 ~MClonesArrayHelper() {delete [] fDataBuffer;}
70
71 void * GetDataBuffer() {return fDataBuffer;}
72
73 Int_t Read();
74 void Write();
75
76};
77
78///////////////////////////////////////////////////////////////////////////////
79// Classes to write and read data of MArray* classes
80template<class BaseT, class ClassT>
81 class MArrayHelper : public MArrayHelperBase
82{
83 ClassT * fArrayClass;
84
85 BaseT fDataBuffer;
86 char fDataType[10];
87
88public:
89 MArrayHelper(ClassT * arrayClass, const char * dataType)
90 {fArrayClass = arrayClass;
91 strcpy(fDataType, dataType);}
92
93 void InitCol()
94 {
95 //FIXME ETIENNE HERE
96// fFitsTable.InitCol("Data", fDataType, &fDataBuffer);
97// fFitsTable->AddColumn(
98// fFitsTables[tableName]->AddColumn(count, typeChar, truncatedName, unit, truncatedComment);
99
100 }
101
102 Int_t Read() { return 0;}
103 void Write()
104 {
105 fArraySize = fArrayClass->GetSize();
106 for (UInt_t idx = 0; idx < fArraySize; idx++)
107 {
108 fDataBuffer = (*fArrayClass)[idx];
109//FIXME ETIENNE HERE
110 // fFitsTable.Write();
111 }
112 }
113
114
115};
116
117#endif
118
Note: See TracBrowser for help on using the repository browser.