]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/exa/read.C
L3 becomes HLT
[u/mrichter/AliRoot.git] / HLT / exa / read.C
CommitLineData
086f41d8 1// $Id$
2
3e87ef69 3/* Different small routines for reading and testing
4 the data.*/
5
6
7#ifndef __CINT__
4aa41877 8#include "AliHLTFileHandler.h"
9#include "AliHLTDigitData.h"
10#include "AliHLTTransform.h"
11#include "AliHLTLogger.h"
3e87ef69 12#include <stdio.h>
13#include <iostream.h>
14#endif
15
16
10d756ae 17void read(Char_t *path="./",Int_t min=0,Int_t max=35)
114013a3 18{
4aa41877 19 AliHLTTransform::Init(path);
114013a3 20
3e87ef69 21 for(Int_t slice=0; slice<35; slice++)
114013a3 22 {
3e87ef69 23 Char_t fname[256];
10d756ae 24 sprintf(fname,"%s/digits_%d_0.raw",path,slice);
4aa41877 25 AliHLTFileHandler *file = new AliHLTFileHandler();
114013a3 26 if(!file->SetBinaryInput(fname))
27 {
28 cerr<<"Error opening file "<<fname<<endl;
29 return;
30 }
10d756ae 31
3e87ef69 32 Int_t row[2]={0,175};
114013a3 33 file->Init(slice,0,row);
10d756ae 34
114013a3 35 UInt_t size;
4aa41877 36 AliHLTDigitRowData *data = file->CompBinary2Memory(size);
114013a3 37
38 for(Int_t r=0; r<175; r++)
39 {
40 UInt_t padrow=data->fRow;
4aa41877 41 AliHLTDigitData *dPt = (AliHLTDigitData*)data->fDigitData;
114013a3 42 cout<<"padrow "<<padrow<<" ndigits "<<data->fNDigit<<endl;
43
3e87ef69 44 for(Int_t d=0; d<(Int_t)data->fNDigit; d++)
114013a3 45 {
3e87ef69 46 if(d>0 && dPt[d].fPad == dPt[d-1].fPad && dPt[d].fTime == dPt[d-1].fTime)
47 cout<<"Slice "<<slice<<" padrow "<<padrow<<" pad "<<(int)dPt[d].fPad<<" time "
48 <<(int)dPt[d].fTime<<" charge "<<(int)dPt[d].fCharge<<endl;
114013a3 49 }
50
51 file->UpdateRowPointer(data);
52 }
53
54 file->CloseBinaryInput();
55 delete file;
56 }
57}
10d756ae 58
59void read_ali(Char_t *fname, Int_t sl=0, Int_t sh=35)
60{
10d756ae 61 //need galice file or alirunfile.root link
4aa41877 62 if(AliHLTTransform::Init(fname,kTRUE))
10d756ae 63 {
64 cout << "created temp init file!" << endl;
65 }
10d756ae 66
4aa41877 67 AliHLTFileHandler *fileHandler = new AliHLTFileHandler();
10d756ae 68
69 if(!fileHandler->SetAliInput(fname))
70 {
71 cerr<<"Error opening file "<<fname<<endl;
72 return;
73 }
74
75 Int_t event=0;
76 UInt_t nrow=0;
77
78 for(Int_t slice=sl; slice<=sl; slice++){
4aa41877 79 for(Int_t patch=0;patch<AliHLTTransform::GetNPatches();patch++){
10d756ae 80
81 cerr<<"reading slice: "<<slice<<" patch: "<<patch<<endl;
82
83 fileHandler->Free();
84 fileHandler->Init(slice,patch);
4aa41877 85 AliHLTDigitRowData *data=fileHandler->AliDigits2Memory(nrow,event);
3e87ef69 86 if(!data) cerr << "Obscure error while reading data." << endl;
10d756ae 87 cerr<<" found "<< nrow << " rows" <<endl;
88 }
89 }
90 fileHandler->CloseAliInput();
91}
3e87ef69 92
93void read_pp(Char_t *path="./",Int_t min=0,Int_t max=35,Int_t ev=0)
94{
4aa41877 95 AliHLTTransform::Init(path);
3e87ef69 96
97 for(Int_t slice=min; slice<max; slice++)
98 {
99 Char_t fname[256];
100 sprintf(fname,"%s/digits_%d_%d_-1.raw",path,ev,slice);
4aa41877 101 AliHLTFileHandler *file = new AliHLTFileHandler();
3e87ef69 102 if(!file->SetBinaryInput(fname))
103 {
104 cerr<<"Error opening file "<<fname<<endl;
105 return;
106 }
107
108 file->Init(slice,-1);
109
110 UInt_t size;
4aa41877 111 AliHLTDigitRowData *data;
112 data=(AliHLTDigitRowData*)file->Allocate(); //size from binary input
3e87ef69 113 file->Binary2Memory(size,data);
114
4aa41877 115 for(Int_t r=AliHLTTransform::GetFirstRow(-1); r<AliHLTTransform::GetLastRow(-1); r++)
3e87ef69 116 {
117
118 UInt_t padrow=data->fRow;
4aa41877 119 AliHLTDigitData *dPt = (AliHLTDigitData*)data->fDigitData;
3e87ef69 120 cout<<r<<" "<<"padrow "<<padrow<<" ndigits "<<data->fNDigit<<endl;
121
122 for(Int_t d=0; d<(Int_t)data->fNDigit; d++)
123 {
124 //if((int)dPt[d]->fTime>1023)
125 cout<<"Slice "<<slice<<" padrow "<<padrow<<" pad "<<(int)dPt[d].fPad<<" time "
126 <<(int)dPt[d].fTime<<" charge "<<(int)dPt[d].fCharge<<" mc "<<(int)dPt[d].fTrackID[0]<<endl;
127 }
128
129 file->UpdateRowPointer(data);
130 }
131
132 file->CloseBinaryInput();
133 delete file;
134 }
135}
136
137void read_event_tree(Char_t *rootfile,Int_t startev=0)
138{
4aa41877 139 AliHLTFileHandler *handler = new AliHLTFileHandler();
3e87ef69 140 if(!handler->SetAliInput(rootfile)){
141 cerr<<" Error opening file: "<<rootfile<<endl;
142 return;
143 }
144
145 //Looping over slices and the over events
146 Int_t ev=startev;
147 UInt_t size=0;
148 Bool_t cont=kTRUE;
149 while(cont){
150 cout<<"\nEvent " << ev << " Loading slices "<<flush;
151 for(Int_t slice=0 ; slice<1 ; slice++){
152 handler->Init(slice,-1);
153 if(!handler->AliAltroDigits2Memory(size,ev)){
154 cout << " not a valid event, breaking!!!" <<endl;
155 cont=kFALSE;
156 break;
157 }
158 cout << "."<<flush;
159 }
160 if(cont){
161 handler->Free();
162 handler->FreeDigitsTree();
163 cout<<" done"<<endl;
164 ev++;
165 }
166 }
167
168 delete handler;
169}