]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/programs/ali2raw.cxx
Added support for NEWIO, merged cern-hlt tree, updated to latest track candidate...
[u/mrichter/AliRoot.git] / HLT / programs / ali2raw.cxx
CommitLineData
3e87ef69 1// $Id$
2
02f030e3 3// Author: Constantin Loizides <loizides@ikf.uni-frankfurt.de>
4//*-- Copyright &copy ALICE HLT Group
811f5ccd 5
6#ifndef use_aliroot
7BOMB THE COMPILE: USEPACKAGE=ALIROOT
8#endif
9
3e87ef69 10#include "AliL3StandardIncludes.h"
11
811f5ccd 12#include "AliL3RootTypes.h"
13#include "AliL3MemHandler.h"
14#include "AliL3FileHandler.h"
15#include "AliL3DigitData.h"
16#include "AliL3Transform.h"
17
3e87ef69 18#if GCCVERSION == 3
19using namespace std;
20#else
21#include <stream.h>
22#endif
23
811f5ccd 24/**
25 Converts from AliRoot Digits to L3-RawDigits
26 */
3e87ef69 27Int_t Make_Init(Char_t *file, Char_t *tofile);
811f5ccd 28
3e87ef69 29int main (Int_t argc, Char_t** argv)
811f5ccd 30{
3e87ef69 31 Int_t first=0;
32 Int_t last=0;
811f5ccd 33
34 if(argc<3)
35 {
36 cout<<"Usage: ali2raw datafile path [firstsector] [lastsector]"<<endl;
37 return -1;
38 }
39 if(argc<4) first=atoi(argv[3]);
40 if(argc<5) first=atoi(argv[4]);
41
3e87ef69 42 Char_t transname[1000];
811f5ccd 43 const Int_t npatch = 6;
44 Int_t row[npatch][2] = {{0,31},{32,63},{64,91},{92,119},{120,143},{144,175}};
45
46 strcpy(transname,argv[1]);
47 strcat(transname,"/.transform.config");
48 if(Make_Init(argv[1],transname)<0) exit(1);
49
50
51 /*
52 AliL3FileHandler *fFileHandler = new AliL3FileHandler();
53 fFileHandler->SetAliInput(in);
54 AliL3Transform *fTransformer = new AliL3Transform(path);
55
56
57 fFileHandler->Init(fTransformer);
58 for(int slice=first; slice<=last; slice++){
59 for(int patch=0;patch<npatch;patch++){
60 cerr<<"reading slice: "<<slice<<" patch: "<<patch;
61 fFileHandler->Free();
62 fFileHandler->Init(slice,patch,row[patch]);
63 sprintf(name,"%sdigits_%d_%d.raw",path,slice,patch);
64 fFileHandler->SetBinaryOutput(name);
65 fFileHandler->AliDigits2CompBinary();
66 fFileHandler->CloseBinaryOutput();
67 cerr<<" done"<<endl;
68 }
69 }
70 fFileHandler->CloseAliInput();
71 */
72}
73
74int Make_Init(char *file, char *tofile=NULL){
75
76 TFile *rootf = new TFile(file,"READ");
77
78 if(!rootf->IsOpen()){
79 cerr<<"could not open file: "<<file<<endl;
80 return -1;
81 }
82
83 AliTPCParam* par = (AliTPCParam*)rootf->Get("75x40_100x60");
84
85 if(!par){
86 cerr<<"no AliTPCParam 75x40_100x60 in file: "<<file<<endl;
87 return -2;
88 }
89
3e87ef69 90 Int_t fNTimeBins = par->GetMaxTBin()+1;
91 Int_t fNRowLow = par->GetNRowLow();
92 Int_t fNRowUp = par->GetNRowUp();
93 Int_t fNRow= fNRowLow + fNRowUp;
94 Int_t fNSectorLow = par->GetNInnerSector();
95 Int_t fNSectorUp = par->GetNOuterSector();
96 Int_t fNSector = fNSectorLow + fNSectorUp;
811f5ccd 97
3e87ef69 98 Char_t tofilename[1000];
811f5ccd 99 if(tofile){
100 strcpy(tofilename,tofile);
101 strcat(tofilename,".transform-config");
102 } else strcpy(tofilename,file);
103
104 FILE *f = fopen(tofilename,"w");
105 fprintf(f,"void AliL3Transform::Init(){\n");
106
107 fprintf(f," //sector:\n");
108 fprintf(f," fNTimeBins = %d ;\n",fNTimeBins);
109 fprintf(f," fNRowLow = %d ;\n",fNRowLow);
110 fprintf(f," fNRowUp = %d ;\n",fNRowUp);
111 fprintf(f," fNSectorLow = %d ;\n",fNSectorLow);
112 fprintf(f," fNSectorUp = %d ;\n",fNSectorUp);
113 fprintf(f," fNSector = %d ;\n",fNSector);
114 fprintf(f," fPadPitchWidthLow = %f ;\n",par->GetPadPitchWidth(0));
115 fprintf(f," fPadPitchWidthUp = %f ;\n",par->GetPadPitchWidth(fNSectorLow));
116 fprintf(f," fZWidth = %.20f ;\n",par->GetZWidth());
117 fprintf(f," fZSigma = %.20f ;\n",par->GetZSigma());
118
119 fprintf(f,"\n //slices:\n");
120 fprintf(f," fNSlice = %d ;\n",fNSectorLow);
121 fprintf(f," fNRow = %d ;\n",fNRow);
122
123 //rotation shift put in by hand -> Constantin
124 fprintf(f," fNRotShift = 0.5 ;\n");
125
126 fprintf(f," fPi = %.15f ;\n",TMath::Pi());
127 fprintf(f," for(Int_t i=0;i<36;i++){\n");
128 fprintf(f," fCos[i] = cos(2*fPi/9*(i+0.5));\n");
129 fprintf(f," fSin[i] = sin(2*fPi/9*(i+0.5));\n");
130 fprintf(f," }\n\n");
131
132 for(Int_t i=0;i<fNRow;i++){
133 int sec,row;
134 if( i < fNRowLow){sec =0;row =i;}
135 else{sec = fNSectorLow;row =i-fNRowLow;}
136 fprintf(f," fX[%d] = %3.15f ;\n",i,par->GetPadRowRadii(sec,row));
137 }
138 for(Int_t i=0;i<fNRow;i++){
139 int sec,row;
140 if( i < fNRowLow){sec =0;row =i;}
141 else{sec = fNSectorLow;row =i-fNRowLow;}
142 fprintf(f," fNPads[%d] = %d ;\n",i,par->GetNPads(sec,row));
143 }
144
145 fprintf(f,"}\n");
146 fclose(f);
147 return 0;
148}
149
150
151
152#if 0
3e87ef69 153void singlepatch(Char_t* in,Int_t first, Int_t last,Char_t *path="",Int_t event=0)
811f5ccd 154{
155 AliL3Logger l;
156 //l.UnSet(AliL3Logger::kDebug);
157 //l.UnSet(AliL3Logger::kAll);
158 //l.Set(AliL3Logger::kInformational);
159 //l.UseStdout();
160 l.UseStream();
161
3e87ef69 162 Char_t fname[100];
811f5ccd 163 sprintf(fname,"%sevent_%d/",path,event);
3e87ef69 164 Char_t name[256];
811f5ccd 165 AliL3FileHandler *fFileHandler = new AliL3FileHandler();
166 fFileHandler->SetAliInput(in);
167 Int_t srow[2] = {0,175};
3e87ef69 168 Int_t patch=0;
169 for(Int_t slice=first; slice<=last; slice++)
811f5ccd 170 {
171 cerr<<"reading slice: "<<slice;
172 fFileHandler->Free();
173 fFileHandler->Init(slice,patch,srow);
174 sprintf(name,"%sdigits_%d_%d.raw",fname,slice,patch);
175 fFileHandler->SetBinaryOutput(name);
176 fFileHandler->AliDigits2CompBinary(event);
177 fFileHandler->CloseBinaryOutput();
178 cerr<<" done"<<endl;
179 }
180 fFileHandler->CloseAliInput();
181
182}
183#endif
184
185
186
187
188
189
190