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