L3 becomes HLT
[u/mrichter/AliRoot.git] / HLT / exa / binary.C
CommitLineData
086f41d8 1// $Id$
fd337011 2
3/**
240d63be 4 Macro for converting AliRoot digits into HLT RawData.
086f41d8 5 Binary creates for each patch its own file.
6 Singlepatch uses one file per slice (sp=kTRUE).
02f030e3 7 Use altro=kFALSE if you dont want to
8 filter out single timebins
9
10 Run with ALIROOT (not ROOT)
086f41d8 11*/
12
02f030e3 13binary(Char_t* inpath,Char_t *outpath,Int_t first,Int_t last,Int_t event,Bool_t sp=kFALSE,Bool_t altro=kTRUE){
3e87ef69 14
4aa41877 15 AliHLTTransform::Init(inpath,kTRUE);
086f41d8 16
17 if(sp) {
02f030e3 18 singlepatch(inpath,outpath,first,last,event,altro);
086f41d8 19 return;
20 }
fd337011 21
3e87ef69 22 Char_t name[256];
eb13caca 23 const Int_t npatch = 6;
3e87ef69 24
25 sprintf(name,"%s/digitfile.root",inpath);
4aa41877 26 AliHLTFileHandler *fFileHandler = new AliHLTFileHandler();
3e87ef69 27 fFileHandler->SetAliInput(name);
fd337011 28
3e87ef69 29 for(Int_t slice=first; slice<=last; slice++){
30 for(Int_t patch=0;patch<npatch;patch++){
31 cerr<<"reading slice: "<<slice<<" patch: "<<patch<<" and storing to: "<<outpath<<"/digits_"<<slice<<"_"<<patch<<".raw"<<endl;
058d766f 32 fFileHandler->Init(slice,patch);
3e87ef69 33 sprintf(name,"%s/digits_%d_%d_%d.raw",outpath,event,slice,patch);
f2793c29 34 fFileHandler->SetBinaryOutput(name);
02f030e3 35 fFileHandler->AliDigits2CompBinary(event,altro);
f2793c29 36 fFileHandler->CloseBinaryOutput();
cd234d8a 37 fFileHandler->Free();
f2793c29 38 cerr<<" done"<<endl;
39 }
40 }
41 fFileHandler->CloseAliInput();
42}
cd234d8a 43
02f030e3 44void singlepatch(Char_t* inpath,Char_t *outpath,Int_t first=0, Int_t last=0,Int_t event=0,Bool_t altro=kTRUE)
45{
46
47 Char_t name[256];
4aa41877 48 AliHLTFileHandler *fFileHandler = new AliHLTFileHandler();
02f030e3 49 sprintf(name,"%s/digitfile.root",inpath);
50 fFileHandler->SetAliInput(name);
51
52 Int_t patch=-1;
53 for(Int_t slice=first; slice<=last; slice++)
54 {
55 cerr<<"reading slice: "<<slice;
56 fFileHandler->Free();
57 fFileHandler->Init(slice,patch);
58 sprintf(name,"%s/digits_%d_%d_%d.raw",outpath,event,slice,patch);
59 fFileHandler->SetBinaryOutput(name);
60 fFileHandler->AliDigits2CompBinary(event,altro);
61 fFileHandler->CloseBinaryOutput();
62 cerr<<" done"<<endl;
63 }
64 fFileHandler->CloseAliInput();
65
66}
67
3e87ef69 68void write2rootfile(Char_t *in,Int_t first,Int_t last,Char_t *path)
cd234d8a 69{
70 //Write new rootfile, using data from the binary files.
71
4aa41877 72 AliHLTTransform::Init(path);
cd234d8a 73 char filename[1024];
74 sprintf(filename,"%s/digitfile.root",path);
75 file = TFile::Open(filename,"READ");
76 if(file->IsOpen())
77 {
78 cout<<"Delete file "<<filename<<endl;
79 return;
80 }
3e87ef69 81 for(Int_t slice=first; slice<=last; slice++)
cd234d8a 82 {
3e87ef69 83 for(Int_t patch=0; patch<=5; patch++)
cd234d8a 84 {
4aa41877 85 c = new AliHLTCompress(slice,patch,path);
cd234d8a 86 c->WriteRootFile(filename,in);
87 delete c;
88 }
89 }
90
91}
c864fdd1 92
a740d2c6 93void make_init_file(Char_t *f,Char_t *path="./"){
4aa41877 94 AliHLTTransform::MakeInitFile(f,path);
e0dcd0b5 95}