source: trunk/Mars/mfileio/MFitsArray.h@ 14932

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