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