3 // Author: Constantin Loizides <mailto: loizides@ikf.physik.uni-frankfurt.de
8 #include "AliL3RootTypes.h"
9 #include "AliL3Logger.h"
10 #include "AliL3MemHandler.h"
11 #include "AliL3AltroMemHandler.h"
12 #include "AliL3DigitData.h"
13 #include "AliL3Transform.h"
14 #include "AliL3Logging.h"
15 #include "AliL3Logger.h"
18 Example program how to open and read a raw datafile.
19 In addition it shows, how to store (and read) the
20 digits in an Altro like data format.
23 int main(int argc,char **argv)
27 Bool_t altroout=kFALSE;
31 l.Set(AliL3Logger::kAll);
38 cout<<"Usage: read datafile [slice] [patch] [altrodatfile]"<<endl;
49 afile=fopen(argv[4],"w");
52 //Loading all specific aliroot version quantities, needed.
54 strcpy(fname,argv[1]);
55 AliL3Transform::Init(dirname(fname));
56 strcpy(fname,argv[1]);
61 //Give slice and patch information (see filename convention)
62 if((patch>=0)&&(patch<6)) file.Init(slice,patch);
64 Int_t srows[2]={0,175};
66 file.Init(slice,patch,srows);
70 if(!file.SetBinaryInput(argv[1]))
72 cerr<<"Error opening file "<<argv[1]<<endl;
76 //Create an RowData object to access the data
77 AliL3DigitRowData *digits=0;
80 //Read the file, and store the data in memory. Return value is a pointer to the data.
81 digits = file.CompBinary2Memory(nrows);
83 //Create an ALtroMemHandler object
84 AliL3AltroMemHandler altromem;
85 if(altroout) altroout=altromem.SetASCIIOutput(afile);
89 Int_t row=file.GetRowMin()-1,crows=0,lrow=row;
91 for(UInt_t r=0; r<nrows; r++) //Loop over padrows
93 //Get the data on this padrow:
94 AliL3DigitData *dataPt = (AliL3DigitData*)digits->fDigitData;
96 if(lrow+1==row) crows++;
98 //Loop over all digits on this padrow:
99 for(UInt_t ndig=0; ndig<digits->fNDigit; ndig++)
102 pad = dataPt[ndig].fPad;
103 time = dataPt[ndig].fTime;
104 charge = dataPt[ndig].fCharge;
105 cout << "Padrow " << r << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl;
106 // cout << "Padrow " << row << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl;
107 if(altroout) altromem.Write(row,pad,time,charge);
110 //Move the pointer to the next padrow:
111 file.UpdateRowPointer(digits);
115 altromem.WriteFinal();
120 UShort_t rrow=0,rtime=0,rcharge=0;
122 afile=fopen(argv[4],"r");
123 altromem.SetASCIIInput(afile);
124 while(altromem.Read(rrow,rpad,rtime,rcharge)){
125 cout << "Padrow " << (int)rrow << " pad " << (int)rpad << " time " <<(int)rtime << " charge " << (int)rcharge << endl;
130 //test Altro read sequence
131 UShort_t rrow=0,rtime=0;
132 UChar_t rpad=0,n=100,i=100;
133 UShort_t *charges=new UShort_t[100];
134 afile=fopen(argv[4],"r");
135 altromem.SetASCIIInput(afile);
136 while(altromem.ReadSequence(rrow,rpad,rtime,i,&charges)){
137 cout << "Padrow " << (int)rrow << " pad " << (int)rpad << " time " <<(int)rtime << " charges ";
138 for(UChar_t ii=0;ii<i;ii++) cout << (int)charges[ii] << " ";
146 //cerr << "Rows: " << (file.GetRowMax()-file.GetRowMin()+1) << " Consecutive: " << crows << endl;