]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSspdTestBeam.h
Bug fix - It should compile also on 64bit systems, however this code must be revised...
[u/mrichter/AliRoot.git] / ITS / AliITSspdTestBeam.h
1 #ifndef ALIITSSPDTESTBEAM_H
2 #define ALIITSSPDTESTBEAM_H
3
4 /* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //
10 // Class for the reading of the SPD 
11 // Test beam data
12 // More information on this class will follow
13 // 
14
15 #include <Rtypes.h>
16 #include <TTask.h>
17
18 class AliITS;
19 class AliITSspdTestBeamHeader;
20 class AliITSspdTestBeamTail;
21 class AliITSspdTestBeamBurst;
22 class AliITSspdTestBeamData;
23
24 class AliITSspdTestBeam : public TTask
25 {
26 public:
27     AliITSspdTestBeam();
28     AliITSspdTestBeam(const Char_t *filename,const Char_t *opt="2002",
29                       AliITS *its=0);
30     virtual ~AliITSspdTestBeam();
31     //
32     virtual Int_t OpenInputFile(const Char_t *filename,Int_t start=0,
33                                 Int_t end=-1);
34     virtual Int_t Read(Int_t i=0);
35     virtual Int_t Read(const char *name) {return TObject::Read(name);}
36     virtual Int_t Decode();
37     virtual Int_t GetNumberOfPilots()const{return 3;}
38 private:
39     AliITSspdTestBeam(const AliITSspdTestBeam &);
40     AliITSspdTestBeam & operator=(const AliITSspdTestBeam &);
41     void SetTerminationWord(){fTermination=0xffffd9f0;}
42     //
43     AliITSspdTestBeamHeader  *fRH;    //! Run Header
44     AliITSspdTestBeamTail    *fRT;    //! Run Trailer
45     Int_t                     fNBrst; //! Number of burts (size of array).
46     //orig    Int_t                   **fBrstSize; //! Size of each burst for each pilot
47     UInt_t                 ***fBrstSize; //! Size of each burst for each pilot
48     AliITSspdTestBeamBurst  **fBrst;  //! Array of bursts.
49     Int_t                   **fNData; //! array of the number of data points
50     AliITSspdTestBeamData  ***fData;  //! Data
51     AliITSspdTestBeamData  ***fHData; //! pointer to headers
52     AliITSspdTestBeamData  ***fTData; //! pointer to Tail and Aborts
53     UInt_t     fTermination;  //! Termination word
54     Int_t      fNEvents;      // Number of events in file
55     Int_t      fBuffSize;     // Read Buffere Size
56     UChar_t   *fBuff;         // Read buffer
57     AliITS    *fITS;          // Pointer to the ITS.
58     Int_t      fNfiles;       // Number of input files to read from
59     Int_t      fMaxFiles;     // The size of the pointer array fFiles.
60     ifstream **fFiles;        //! Array of Pointer to the input streams
61     Int_t     *fNeventsStart; // Starting event number for each file
62     Int_t     *fNeventsEnd;   // Ending number of events for each file.
63
64     ClassDef(AliITSspdTestBeam,1) // Task to read SPD test beam data
65 };
66 #endif
67 //======================================================================
68 #ifndef ALIITSTESTBEAMDATA_H
69 #define ALIITSTESTBEAMDATA_H
70
71 /* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
72  * See cxx source for full Copyright notice                               */
73
74 /*
75   $Id$
76  */
77
78 // Pure virtual class, no data
79 class AliITSTestBeamData{
80   public:
81     AliITSTestBeamData(){};
82     virtual ~AliITSTestBeamData(){};
83     virtual Int_t SizeOf()const{return 0;}
84     enum {kData,kHead,kTail,kAbort,kFail};
85   private:
86 };
87
88 #endif
89 //======================================================================
90 #ifndef ALIITSSPDTESTBEAMHEADER_H
91 #define ALIITSSPDTESTBEAMHEADER_H
92
93 /* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
94  * See cxx source for full Copyright notice                               */
95
96 #include <Riostream.h>
97
98 class AliITSspdTestBeamHeader : public AliITSTestBeamData{
99   public:
100     AliITSspdTestBeamHeader(){};
101     virtual ~AliITSspdTestBeamHeader(){};
102     virtual void Print(ostream *os)const;
103     virtual Int_t GetNumberOfEvents()const{return fUnion.fHead.fNEvents;};
104     virtual Int_t GetBurstSize(Int_t i=0)const{return fUnion.fHead.fBuffSize[i];};
105     virtual Int_t SizeOf()const{return sizeof(AliITSspdTestBeamHeader);};
106   private:
107     union headder{
108          struct {
109             // Double_t must be 8 bytes long, Char_t 1 byte long,
110             // Int_t 4 bytes long. 8*1+4*26+1*(2*12+3*20+3*44+3*8192)=24904 by
111             Double_t fVersion; // Version number
112             Char_t   fDate[12];// Date Field
113             Char_t   fTime[12];// Time Field
114             UInt_t   fBuffSize[3]; // Buffer Sizes
115             UInt_t   fTestPulse;   // Test Pulse flag
116             UInt_t   fTrigger[3];  // Array of triggers
117             UInt_t   fTriggerMode; // Trigger mode flag
118             UInt_t   fBurstSize;   // Burst Size
119             UInt_t   fNEvents;     // Number of event to write
120             UInt_t   fRes[16];            // not sure
121             UChar_t  fMBDACS[3][20];      // not sure
122             UChar_t  fA1DACS[3][44];      // not sure
123             UChar_t  fA12Matrix[3][8192]; // not sure
124         } fHead;
125         UChar_t fBuf[24904]; // Equivalent char buffer
126     } fUnion;
127 };
128 ostream &operator<<(ostream &os,AliITSspdTestBeamHeader &source);
129 #endif
130 //----------------------------------------------------------------------
131 #ifndef ALIITSSPDTESTBEAMTAIL_H
132 #define ALIITSSPDTESTBEAMTAIL_H
133
134 /* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
135  * See cxx source for full Copyright notice                               */
136
137 #include <Riostream.h>
138
139 class AliITSspdTestBeamTail : public AliITSTestBeamData{
140   public:
141     AliITSspdTestBeamTail(){};
142     virtual ~AliITSspdTestBeamTail(){};
143     virtual Int_t SizeOf()const{return sizeof(AliITSspdTestBeamTail);}
144     virtual void Print(ostream *os)const;
145   private:
146     union tail{
147         struct {
148             // Char_t 1 byte long,
149             // UInt_t 4 bytes long. size = 4+4+12*1+12*1 = 32 bytes
150             UInt_t   fEvents;  // number of events written
151             UInt_t   fTermMode;// Termination flag
152             Char_t   fDate[12];// Date Field
153             Char_t   fTime[12];// Time Field
154         } fTail;
155         UChar_t fBuf[32]; //Equivalent char buffer
156     } fUnion;
157 };
158 ostream &operator<<(ostream &os,AliITSspdTestBeamTail &source);
159 #endif
160 //----------------------------------------------------------------------
161 #ifndef ALIITSSPDTESTBEAMBURST_H
162 #define ALIITSSPDTESTBEAMBURST_H
163
164 /* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
165  * See cxx source for full Copyright notice                               */
166
167 #include <Riostream.h>
168
169 class AliITSspdTestBeamBurst : public AliITSTestBeamData{
170   public:
171     AliITSspdTestBeamBurst(){};
172     virtual ~AliITSspdTestBeamBurst(){};
173     virtual Int_t SizeOf()const{return sizeof(AliITSspdTestBeamBurst);}
174     virtual void Print(ostream *os)const;
175   private:
176     union tail{
177         struct {
178             // UInt_t 4 bytes long.
179             UInt_t   fNumber;   // Burst Number
180             UInt_t   fTransfers;// Number of Transfers
181         } fBrst;
182         ULong64_t fBuf;  // a strictly 64 bit long unsinged int
183     } fUnion;
184 };
185 ostream &operator<<(ostream &os,AliITSspdTestBeamBurst &source);
186 #endif
187 //----------------------------------------------------------------------
188 #ifndef ALIITSSPDTESTBEAMDATA_H
189 #define ALIITSSPDTESTBEAMDATA_H
190
191 /* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
192  * See cxx source for full Copyright notice                               */
193
194 #include <Riostream.h>
195
196 //class ostream;
197
198 class AliITSspdTestBeamData : public AliITSTestBeamData {
199   public:
200     //
201     AliITSspdTestBeamData(){};
202     //AliITSspdTestBeamData(UInt_t *i){SetAddress(i);}
203     virtual Int_t SizeOf()const{return sizeof(AliITSspdTestBeamData);}
204     virtual ~AliITSspdTestBeamData(){};
205     //
206     virtual Bool_t IsHeader()const{return (fUnion.fDataH.fFlag==2||fUnion.fDataH.fFlag==3);}
207     virtual Bool_t IsData()const{return (fUnion.fDataD.fFlag>3)&&(fUnion.fDataD.fFlag<8);}
208     virtual Bool_t IsTrailer()const{return (fUnion.fDataT.fFlag==0);}
209     virtual Bool_t IsAbort()const{return (fUnion.fDataA.fFlag==1);}
210     virtual Int_t  Mode()const{if(IsData()) return kData;else if(IsHeader()) return kHead;else if(IsTrailer()) return kTail;else if(IsAbort()) return kAbort;else return kFail;}
211     virtual Int_t  TransWordCount()const{if(IsTrailer()||IsAbort()) return fUnion.fDataT.fTrans;else return -1;}
212     virtual Int_t  EventCounter()const{if(IsHeader()) return fUnion.fDataH.fEventSync;else return -1;}
213     virtual Int_t Chip()const{if(IsData()) return fUnion.fDataD.fChip;else return -1;}
214     virtual Int_t Row() const{if(IsData()) return fUnion.fDataD.fRow; else return -1;}
215     virtual Int_t Colm()const{if(IsData()) return fUnion.fDataD.fColm;else return -1;}
216     virtual void  Dataconst(Int_t &ch,Int_t &rw,Int_t &cl)const{ch=Chip();rw=Row();cl=Colm();}
217     virtual void Print(ostream *os)const;
218   private:
219     union data{
220         struct {
221             unsigned fDate:12;    // Not Used
222             unsigned fEventSync:6;// Event syncronization counter
223             unsigned fFlag:3;     // =2or3 Header
224             unsigned fPadding:12; // Not used
225         } fDataH;
226         struct {
227             unsigned fColm:5;     // Pixel (Hit) Column Address
228             unsigned fRow:8;      // Pixel Row Adress
229             unsigned fChip:4;     // Pixel Chip Address
230             unsigned fFlag:3;     // =4or5or6or7 Data
231             unsigned fPadding:12; // Not used
232         } fDataD;
233         struct {
234             unsigned fTrans:17;   // Transmitted word count
235             unsigned fFlag:3;     // =0 Trialer
236             unsigned fPadding:12; // Not used
237         } fDataT;
238         struct {
239             unsigned fTrans:17;   // Transmitted word count
240             unsigned fFlag:3;     // =1 Abort
241             unsigned fPadding:12; // Not used
242         } fDataA;
243         UChar_t fBuf[4]; // Equivalent char buffer
244     } fUnion;
245 };
246 ostream &operator<<(ostream &os,AliITSspdTestBeamData &source);
247 #endif