]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/programs/read.cxx
Created cluster finder class that simulates the VHDL cluster finder on Altro data.
[u/mrichter/AliRoot.git] / HLT / programs / read.cxx
CommitLineData
2c7d4020 1/* $Id$
c2a88d53 2Author: Constantin Loizides <mailto: loizides@ikf.physik.uni-frankfurt.de
3*/
4
5#include <stream.h>
2c7d4020 6#include <libgen.h>
6f9dd32b 7#include "AliL3RootTypes.h"
8#include "AliL3Logger.h"
c2a88d53 9#include "AliL3MemHandler.h"
10#include "AliL3AltroMemHandler.h"
11#include "AliL3DigitData.h"
2c7d4020 12#include "AliL3Transform.h"
c2a88d53 13
14/**
15Example program how to open and read a raw datafile.
2c7d4020 16In addition it shows, how to store results in an Altro like
17data format.
c2a88d53 18*/
19
20int main(int argc,char **argv)
21{
6f9dd32b 22 Int_t slice=0;
23 Int_t patch=0;
c2a88d53 24 Bool_t altroout=kFALSE;
25 FILE *afile=0;
6f9dd32b 26
27 /*
28 AliL3Logger l;
29 l.Set(AliL3Logger::kAll);
30 //l.UseStdout();
31 l.UseStream();
32 */
2c7d4020 33
c2a88d53 34 if(argc<2)
35 {
6f9dd32b 36 cout<<"Usage: read datafile [slice] [patch] [altrodatfile]"<<endl;
c2a88d53 37 return -1;
38 }
39 if (argc>2) {
6f9dd32b 40 slice=atoi(argv[2]);
c2a88d53 41 }
42 if (argc>3) {
6f9dd32b 43 patch=atoi(argv[3]);
44 }
45 if (argc>4) {
c2a88d53 46 altroout=kTRUE;
6f9dd32b 47 afile=fopen(argv[4],"w");
c2a88d53 48 }
6f9dd32b 49
50 //Loading all specific aliroot version quantities, needed.
51 Char_t fname[1024];
52 strcpy(fname,argv[1]);
53 AliL3Transform::Init(dirname(fname));
54 strcpy(fname,argv[1]);
c2a88d53 55
56 //Filehandler object:
57 AliL3MemHandler file;
2c7d4020 58
6f9dd32b 59 //Give slice and patch information (see filename convention)
60 if((patch>=0)&&(patch<6)) file.Init(slice,patch);
61 else {
62 Int_t srows[2]={0,175};
63 file.Init(slice,0,srows);
64 }
65
c2a88d53 66 //Open the data file:
67 if(!file.SetBinaryInput(argv[1]))
68 {
69 cerr<<"Error opening file "<<argv[1]<<endl;
70 return -1;
71 }
2c7d4020 72
c2a88d53 73 //Create an RowData object to access the data
74 AliL3DigitRowData *digits=0;
6f9dd32b 75 UInt_t nrows=0;
c2a88d53 76
77 //Read the file, and store the data in memory. Return value is a pointer to the data.
6f9dd32b 78 digits = file.CompBinary2Memory(nrows);
c2a88d53 79
80 //Create an ALtroMemHandler object
81 AliL3AltroMemHandler altromem;
bbdff6bf 82 if(altroout) altroout=altromem.SetASCIIOutput(afile);
83
c2a88d53 84 UShort_t time,charge;
85 UChar_t pad;
6f9dd32b 86 Int_t row=file.GetRowMin()-1,crows=0,lrow=row;
87
88 for(UInt_t r=0; r<nrows; r++) //Loop over padrows
c2a88d53 89 {
90 //Get the data on this padrow:
91 AliL3DigitData *dataPt = (AliL3DigitData*)digits->fDigitData;
6f9dd32b 92 row++;
8c594a58 93 if(lrow+1==row) crows++;
c2a88d53 94
95 //Loop over all digits on this padrow:
2c7d4020 96 for(UInt_t ndig=0; ndig<digits->fNDigit; ndig++)
6f9dd32b 97 //for(UInt_t ndig=digits->fNDigit;ndig>0;ndig--)
c2a88d53 98 {
8c594a58 99 lrow=row;
c2a88d53 100 pad = dataPt[ndig].fPad;
101 time = dataPt[ndig].fTime;
102 charge = dataPt[ndig].fCharge;
103 cout << "Padrow " << row << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl;
104 if(altroout) altromem.Write(row,pad,charge,time);
105 }
106
107 //Move the pointer to the next padrow:
108 file.UpdateRowPointer(digits);
109 }
110
111 if(afile) {
112 altromem.WriteFinal();
113 fclose(afile);
114 }
8c594a58 115
6f9dd32b 116 //cerr << "Rows: " << (file.GetRowMax()-file.GetRowMin()+1) << " Consecutive: " << crows << endl;
c2a88d53 117 return 0;
118}
6f9dd32b 119
120