]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/binary.C
Added function that writes new rootfile with digits from the
[u/mrichter/AliRoot.git] / HLT / exa / binary.C
1 // $Id$
2
3 /**
4    Macro for converting AliRoot digits into L3 RawData. 
5    Binary creates for each patch its own file. 
6    Singlepatch uses one file per slice (sp=kTRUE). 
7 */
8
9 binary(char* in,int first, int last,char *path=".",Bool_t sp=kFALSE){
10
11   AliL3Transform::Init(path);
12   
13   if(sp) {
14     singlepatch(in,first,last,path);
15     return;
16   }
17
18   char name[256];
19   const Int_t npatch = 6;
20   
21   //read init file
22   
23
24   AliL3FileHandler *fFileHandler = new AliL3FileHandler(); 
25   fFileHandler->SetAliInput(in);
26
27   for(int slice=first; slice<=last; slice++){
28     for(int patch=0;patch<npatch;patch++){
29       cerr<<"reading slice: "<<slice<<" patch: "<<patch<<" and storing to: "<<path<<"/digits_"<<slice<<"_"<<patch<<".raw"<<endl;
30       fFileHandler->Init(slice,patch);      
31       sprintf(name,"%s/digits_%d_%d.raw",path,slice,patch);
32       fFileHandler->SetBinaryOutput(name);
33       fFileHandler->AliDigits2CompBinary();
34       fFileHandler->CloseBinaryOutput();      
35       fFileHandler->Free();
36       cerr<<" done"<<endl;
37     }      
38   }
39   fFileHandler->CloseAliInput();
40 }
41
42 void write2rootfile(char *in,int first,int last,char *path)
43 {
44   //Write new rootfile, using data from the binary files. 
45
46   AliL3Transform::Init(path);
47   char filename[1024];
48   sprintf(filename,"%s/digitfile.root",path);
49   file = TFile::Open(filename,"READ");
50   if(file->IsOpen())
51     {
52       cout<<"Delete file "<<filename<<endl;
53       return;
54     }
55   for(int slice=first; slice<=last; slice++)
56     {
57       for(int patch=0; patch<=5; patch++)
58         {
59           c = new AliL3Compress(slice,patch,path);
60           c->WriteRootFile(filename,in);
61           delete c;
62         }
63     }
64   
65 }
66  
67 void singlepatch(char* in,int first=0, int last=0,char *path=".",int event=0)
68 {
69   AliL3Logger l;
70   //l.UnSet(AliL3Logger::kDebug);
71   //l.UnSet(AliL3Logger::kAll);
72   //l.Set(AliL3Logger::kInformational);
73   l.UseStderr();
74   //l.UseStream();
75   
76   char name[256];
77   AliL3FileHandler *fFileHandler = new AliL3FileHandler(); 
78   fFileHandler->SetAliInput(in);
79
80   Int_t srow[2] = {0,175};
81   int patch=0;
82   for(int slice=first; slice<=last; slice++)
83     {
84       cerr<<"reading slice: "<<slice;
85       fFileHandler->Free();
86       fFileHandler->Init(slice,patch,srow);
87       sprintf(name,"%s/digits_%d_%d.raw",path,slice,patch);
88       fFileHandler->SetBinaryOutput(name);
89       fFileHandler->AliDigits2CompBinary(event);
90       fFileHandler->CloseBinaryOutput();      
91       cerr<<" done"<<endl;
92     }
93   fFileHandler->CloseAliInput();
94   
95 }
96
97 void make_init_file(Char_t *f,Char_t *path="./"){
98   AliL3Transform::MakeInitFile(f,path);
99 }