]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/read.C
- check for AliRoot features/libs/files and corresponding conditional
[u/mrichter/AliRoot.git] / HLT / exa / read.C
1 // $Id$
2
3 /* Different small routines for reading and testing 
4    the data.*/
5
6
7 #ifndef __CINT__
8 #include "AliL3FileHandler.h"
9 #include "AliL3DigitData.h"
10 #include "AliL3Transform.h"
11 #include "AliL3Logger.h"
12 #include <stdio.h>
13 #include <iostream.h>
14 #endif
15
16
17 void read(Char_t *path="./",Int_t min=0,Int_t max=35)
18 {
19   AliL3Transform::Init(path);
20
21   for(Int_t slice=0; slice<35; slice++)
22     {
23       Char_t fname[256];
24       sprintf(fname,"%s/digits_%d_0.raw",path,slice);
25       AliL3FileHandler *file = new AliL3FileHandler();
26       if(!file->SetBinaryInput(fname))
27         {
28           cerr<<"Error opening file "<<fname<<endl;
29           return;
30         }
31
32       Int_t row[2]={0,175};
33       file->Init(slice,0,row);
34
35       UInt_t size;
36       AliL3DigitRowData *data = file->CompBinary2Memory(size);
37       
38       for(Int_t r=0; r<175; r++)
39         {
40           UInt_t padrow=data->fRow;
41           AliL3DigitData *dPt = (AliL3DigitData*)data->fDigitData;
42           cout<<"padrow "<<padrow<<" ndigits "<<data->fNDigit<<endl;
43           
44           for(Int_t d=0; d<(Int_t)data->fNDigit; d++)
45             {
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;
49             }
50           
51           file->UpdateRowPointer(data);
52         }
53       
54       file->CloseBinaryInput();
55       delete file;
56     }
57 }
58
59 void read_ali(Char_t *fname, Int_t sl=0, Int_t sh=35)
60 {
61   //need galice file or alirunfile.root link
62   if(AliL3Transform::Init(fname,kTRUE))
63   {
64     cout << "created temp init file!" << endl;
65   }
66
67   AliL3FileHandler *fileHandler = new AliL3FileHandler();
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++){
79     for(Int_t patch=0;patch<AliL3Transform::GetNPatches();patch++){
80
81       cerr<<"reading slice: "<<slice<<" patch: "<<patch<<endl;
82
83       fileHandler->Free();
84       fileHandler->Init(slice,patch);      
85       AliL3DigitRowData *data=fileHandler->AliDigits2Memory(nrow,event);
86       if(!data) cerr << "Obscure error while reading data." << endl;
87       cerr<<" found "<< nrow << " rows" <<endl;
88     }      
89   }
90   fileHandler->CloseAliInput();
91 }
92
93 void read_pp(Char_t *path="./",Int_t min=0,Int_t max=35,Int_t ev=0)
94 {
95   AliL3Transform::Init(path);
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);
101       AliL3FileHandler *file = new AliL3FileHandler();
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;
111       AliL3DigitRowData *data;
112       data=(AliL3DigitRowData*)file->Allocate(); //size from binary input
113       file->Binary2Memory(size,data);
114
115       for(Int_t r=AliL3Transform::GetFirstRow(-1); r<AliL3Transform::GetLastRow(-1); r++)
116         {
117
118           UInt_t padrow=data->fRow;
119           AliL3DigitData *dPt = (AliL3DigitData*)data->fDigitData;
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
137 void read_event_tree(Char_t *rootfile,Int_t startev=0)
138 {
139   AliL3FileHandler *handler = new AliL3FileHandler();
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 }