3 // Author: Constantin Loizides <loizides@ikf.uni-frankfurt.de
4 //*-- Copyright © ALICE HLT Group
7 #include "AliL3StandardIncludes.h"
9 #include "AliL3RootTypes.h"
10 #include "AliL3Logging.h"
11 #include "AliL3Logger.h"
12 #include "AliL3MemHandler.h"
13 #include "AliL3AltroMemHandler.h"
14 #include "AliL3DigitData.h"
15 #include "AliL3Transform.h"
27 Example program how to open and read a raw datafile.
28 In addition it shows, how to store (and read) the
29 digits in an Altro like data format.
32 int main(Int_t argc,Char_t **argv)
36 Bool_t altroout=kFALSE;
40 l.Set(AliL3Logger::kAll);
47 cout<<"Usage: read datafile [slice] [patch] [altrodatfile]"<<endl;
58 afile=fopen(argv[4],"w");
61 //Loading all specific aliroot version quantities, needed.
63 strcpy(fname,argv[1]);
64 AliL3Transform::Init(dirname(fname));
65 strcpy(fname,argv[1]);
70 //Give slice and patch information (see filename convention)
71 if((patch>=0)&&(patch<6)) file.Init(slice,patch);
73 Int_t srows[2]={0,175};
75 file.Init(slice,patch,srows);
79 if(!file.SetBinaryInput(argv[1]))
81 cerr<<"Error opening file "<<argv[1]<<endl;
85 //Create an RowData object to access the data
86 AliL3DigitRowData *digits=0;
89 //Read the file, and store the data in memory. Return value is a pointer to the data.
90 digits = file.CompBinary2Memory(nrows);
92 //Create an ALtroMemHandler object
93 AliL3AltroMemHandler altromem;
94 if(altroout) altroout=altromem.SetASCIIOutput(afile);
98 Int_t row=file.GetRowMin()-1,crows=0,lrow=row;
100 for(UInt_t r=0; r<nrows; r++) //Loop over padrows
102 //Get the data on this padrow:
103 AliL3DigitData *dataPt = (AliL3DigitData*)digits->fDigitData;
105 if(lrow+1==row) crows++;
107 //Loop over all digits on this padrow:
108 for(UInt_t ndig=0; ndig<digits->fNDigit; ndig++)
111 pad = dataPt[ndig].fPad;
112 time = dataPt[ndig].fTime;
113 charge = dataPt[ndig].fCharge;
114 cout << "Padrow " << r << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl;
115 //cout << "Padrow " << row << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl;
116 if(altroout) altromem.Write(r,pad,time,charge);
119 //Move the pointer to the next padrow:
120 file.UpdateRowPointer(digits);
124 altromem.WriteFinal();
129 UShort_t rrow=0,rtime=0,rcharge=0;
131 afile=fopen(argv[4],"r");
132 altromem.SetASCIIInput(afile);
133 while(altromem.Read(rrow,rpad,rtime,rcharge)){
134 cout << "Padrow " << (int)rrow << " pad " << (int)rpad << " time " <<(int)rtime << " charge " << (int)rcharge << endl;
139 //test Altro read sequence
140 UShort_t rrow=0,rtime=0;
141 UChar_t rpad=0,n=100,i=100;
142 UShort_t *charges=new UShort_t[100];
143 afile=fopen(argv[4],"r");
144 altromem.SetASCIIInput(afile);
145 while(altromem.ReadSequence(rrow,rpad,rtime,i,&charges)){
146 cout << "Padrow " << (int)rrow << " pad " << (int)rpad << " time " <<(int)rtime << " charges ";
147 for(UChar_t ii=0;ii<i;ii++) cout << (int)charges[ii] << " ";
155 //cerr << "Rows: " << (file.GetRowMax()-file.GetRowMin()+1) << " Consecutive: " << crows << endl;