]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/misc/AliL3TPCMapping.cxx
New version of SPD raw-data reconstruction. The format now correponds to the actual...
[u/mrichter/AliRoot.git] / HLT / misc / AliL3TPCMapping.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
2
3// Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4//*-- Copyright &copy ALICE HLT Group
5
6#include "AliL3StandardIncludes.h"
7#include "AliL3Logging.h"
8#include "AliL3Transform.h"
9#include "AliL3TPCMapping.h"
10
5929c18d 11#if __GNUC__ >= 3
3e87ef69 12using namespace std;
13#endif
14
15//generated from Ulis txt file with read-roc.sh
16#include "AliL3TPCMapping-iroc.generated"
17#include "AliL3TPCMapping-oroc.generated"
18
19
20Int_t AliL3TPCMapping::GetRealNPads(Int_t slicerow)
54b54089 21{
22 //see tpc numbering doc
3e87ef69 23
24 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
25 LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealNPads","Slicerow")
26 <<"Wrong slicerow "<<slicerow<<ENDLOG;
27 return -1;
28 }
29
30 const Float_t k1=0.293878;// == 10/6*tan(10)
31 const Float_t k2=0.440817;// == 15/6*tan(10)
54b54089 32 const Int_t knRowLow=AliL3Transform::GetNRowLow();
33 const Int_t knRowUp1=AliL3Transform::GetNRowUp1();
3e87ef69 34
35 if(slicerow==0) return 68;
54b54089 36 else if(slicerow<knRowLow){
3e87ef69 37 Double_t dummy=slicerow/3+33.67;
38 return (2*Int_t(dummy));
39 }
40
54b54089 41 Int_t rowup=slicerow-knRowLow;
42 if(rowup<knRowUp1){
3e87ef69 43 Double_t dummy=k1*rowup+37.75;
44 return (2*Int_t(dummy));
45 }
46 else
47 {
54b54089 48 Double_t dummy=k2*(rowup-knRowUp1+56.66);
3e87ef69 49 return (2*Int_t(dummy));
50 }
51}
52
53Double_t AliL3TPCMapping::GetRealX(Int_t slicerow)
54b54089 54{
55 //see tpc numbering doc
3e87ef69 56 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
57 LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealX","Slicerow")
58 <<"Wrong slicerow "<<slicerow<<ENDLOG;
59 return -1;
60 }
61
54b54089 62 const Int_t knRowLow=AliL3Transform::GetNRowLow();
63 const Int_t knRowUp1=AliL3Transform::GetNRowUp1();
3e87ef69 64
54b54089 65 if(slicerow<knRowLow){
3e87ef69 66 return (85.225+0.75*slicerow);
67 }
68
54b54089 69 Int_t rowup=slicerow-knRowLow;
70 if(rowup<knRowUp1){
3e87ef69 71 return (rowup+135.1);
72 }
73 else
74 {
54b54089 75 return (1.5*(rowup-knRowUp1)+199.35);
3e87ef69 76 }
77}
78
79Double_t AliL3TPCMapping::GetRealY(Int_t slicerow, Int_t pad)
54b54089 80{
81 //see tpc numbering doc
3e87ef69 82 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
83 LOG(AliL3Log::kError,"AliL3Transform::GetRealY","Slicerow")
84 <<"Wrong slicerow "<<slicerow<<ENDLOG;
85 return -1;
86 }
87
88 Int_t npads=GetRealNPads(slicerow);
89 if(pad<0 || pad >= npads){
90 LOG(AliL3Log::kError,"AliL3Transform::GetRealY","pad")
91 <<"Wrong pad "<<pad<<" npads " <<npads<<ENDLOG;
92 return 0.;
93 }
94
54b54089 95 const Int_t knRowLow=AliL3Transform::GetNRowLow();
3e87ef69 96
54b54089 97 if(slicerow<knRowLow){
3e87ef69 98 return (0.4*pad+0.2-0.2*npads);
99 //== (pad-0.5*(npads-1))*fPadPitchWidthLow;
100 }
101 else
102 {
103 return (0.6*pad+0.3-0.3*npads);
104 // == (pad-0.5*(npads-1))*fPadPitchWidthUp;
105 }
106}
107
108
109#if __old__
110#include "TPCMapping.h"
111
112TPCMapping::TPCMapping(char* file){
54b54089 113 // constructor
3e87ef69 114 fin = new ifstream();
115 ffile = file;
116 kreadfile = 0;
117}
118
119TPCMapping::~TPCMapping(){
54b54089 120 // destructor
3e87ef69 121 fin->close();
122 delete fin;
123}
124void TPCMapping::open(){
54b54089 125 // opens file
3e87ef69 126 fin->open(ffile);
127}
128void TPCMapping::isOpen(){
54b54089 129 // dummy
3e87ef69 130}
131void TPCMapping::read(){
54b54089 132 // reads the RORC
3e87ef69 133 for(int i = 0; i < 5504 ; i++){
134 for(int j = 0 ; j < 8 ; j++){
135 *fin >> fIRORC[i][j];
136 }
137 }
138 fsizeoffIRORC = 5504;
139 kreadfile = 1;
140}
141void TPCMapping::read(int* listofRCUs, int numofRCU){
54b54089 142 // reads (?)
3e87ef69 143 int pos = 0;
144 for(int i = 0; i < 5504 ; i++){
145 for(int j = 0 ; j < 8 ; j++){
146 *fin >> fIRORC[pos][j];
147 }
148 for(int j = 0 ; j < numofRCU ; j++){
149 if( fIRORC[pos][5] == listofRCUs[j]){
150 pos++;
151 }
152 }
153 }
154 fsizeoffIRORC = pos;
155 kreadfile = 1;
156}
157
158void TPCMapping::print(){
54b54089 159 // debug printout
3e87ef69 160 cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
161 for(int i = 0; i < fsizeoffIRORC ; i++){
162 print(i);
163 }
164}
165void TPCMapping::print(int start, int end){
54b54089 166 // debug printout
3e87ef69 167 cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
168 for(int i = start; i <= end ; i++){
169 print(i);
170 }
171}
172void TPCMapping::print(int index){
54b54089 173 // debug printout
3e87ef69 174 cout <<
175 getIndex(index) << "\t|" <<
176 getPadrow(index) << "\t|" <<
177 getPad(index) << "\t|" <<
178 getConnector(index) << "\t|" <<
179 getPin(index) << "\t|" <<
180 getFEC(index) << "\t|" <<
181 getFECchannel(index) << "\t|" <<
182 getFECconnector(index) << "\t|" <<
183 getAltroChannel(index) << "\t|" <<
184 getAltro(index) << "\t|" << endl;
185}
186int TPCMapping::getIndex(int index){
187 //COLUMN 0 -> INDEX (0 - 9983)
188 int retval;
189 if(kreadfile == 1)
190 retval = fIRORC[index][0];
191 else{
192 retval = 0;
193 cout << "ERROR: Array Empty!" << endl;
194 }
195 return retval;
196}
197int TPCMapping::getPadrow(int index){
198 //COLUMN 1 -> PADROW (0 - 95)
199 int retval;
200 if(kreadfile == 1)
201 retval = fIRORC[index][1];
202 else{
203 retval = 0;
204 cout << "ERROR: Array Empty!" << endl;
205 }
206 return retval;
207}
208int TPCMapping::getPad(int index){
209 //COLUMN 2 -> PAD (0 - (Np-1))
210 int retval;
211 if(kreadfile == 1)
212 retval = fIRORC[index][2];
213 else{
214 retval = 0;
215 cout << "ERROR: Array Empty!" << endl;
216 }
217 return retval;
218}
219int TPCMapping::getConnector(int index){
220 //COLUMN 3 -> Connector (1 - 468)
221 int retval;
222 if(kreadfile == 1)
223 retval = fIRORC[index][3];
224 else{
225 retval = 0;
226 cout << "ERROR: Array Empty!" << endl;
227 }
228 return retval;
229}
230int TPCMapping::getPin(int index){
231 //COLUMN 4 -> Pin (0 - 22)
232 int retval;
233 if(kreadfile == 1)
234 retval = fIRORC[index][4];
235 else{
236 retval = 0;
237 cout << "ERROR: Array Empty!" << endl;
238 }
239 return retval;
240}
241int TPCMapping::getFEC(int index){
242 //COLUMN 5 -> FEC (0 - 77)
243 int retval;
244 if(kreadfile == 1)
245 retval = fIRORC[index][5];
246 else{
247 retval = 0;
248 cout << "ERROR: Array Empty!" << endl;
249 }
250 return retval;
251}
252int TPCMapping::getFECchannel(int index){
253 //COLUMN 6 -> FEC Channel (0 - 127)
254 int retval;
255 if(kreadfile == 1)
256 retval = fIRORC[index][6];
257 else{
258 retval = 0;
259 cout << "ERROR: Array Empty!" << endl;
260 }
261 return retval;
262}
263int TPCMapping::getFECconnector(int index){
264 //COLUMN 7 -> FEC Connector (0 - 5)
265 int retval;
266 if(kreadfile == 1)
267 retval = fIRORC[index][7];
268 else{
269 retval = 0;
270 cout << "ERROR: Array Empty!" << endl;
271 }
272 return retval;
273}
274
275int TPCMapping::getAltroChannel(int index){
276// every the channel to Altro ordering is 0,1,2,3,4,5,6,7,16,15,14,13,12,11,10,9,8
277 int retval;
278 int channel = getFECchannel(index);
279 if(kreadfile == 1){
280 if( (channel/8)%2 == 0 ){ //every even block hast to be changed
281 retval = channel;
282 }else{
283 retval = (channel/8)*8 + 7-channel%8; //Blocknumber + reversed internel Number
284 }
285 if( (channel/16)%2 != 0){
286// retval = 999;
287 if( (channel/8)%2 == 0 )
288 retval += 8;
289 else
290 retval -= 8;
291 }
292 }else{
293 retval = 0;
294 cout << "ERROR: Array Empty!" << endl;
295 }
296 return retval;
297}
298int TPCMapping::getAltro(int index){
54b54089 299 // gets Altro
3e87ef69 300 int retval;
301 int channel = getFECchannel(index);
302 if(kreadfile == 1)
303 retval = channel/16;
304 else{
305 retval = 0;
306 cout << "ERROR: Array Empty!" << endl;
307 }
308 return retval;
309}
310
311int TPCMapping::getPadsperRow(int row){
312 //IRORC Formula !!!!!!!!!!!!!!!!!!!!!!!!!
313 int retval;
314 if(row == 0){
315 retval = 68;
316 }else{
317 retval = 2*((int)(row/3.0+33.67));
318 }
319 return retval;
320}
321void TPCMapping::myprint(){
54b54089 322 // debug printout
3e87ef69 323 int FEC = 0;
324 int channel = 0;
325 cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
326
327 for(int j = 0; j < 512 ; j++){
328// cout << "j: " << j << " fec " << (j/128+29) << " channel: " << j%128 << endl;
329 FEC = (32-j/128);
330 channel = (j%128);
331 for(int i = 0; i < fsizeoffIRORC ; i++){
332 if((getFEC(i) == FEC) && (getAltroChannel(i) == channel)) {
333 cout << j << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" <<
334 getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" <<
335 getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" <<
336 getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl;
337 }
338 }
339 }
340}
341void TPCMapping::myprint1(){
54b54089 342 // debug printout
3e87ef69 343 int FEC = 0;
344 int channel = 0;
345 cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
346
347 for(int j = 0; j < 95 ; j++){
348 for(int k = 0; k < getPadsperRow(j) ; k++){
349 for(int i = 0; i < fsizeoffIRORC ; i++){
350 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) {
351 cout << j << "\t" << k << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" <<
352 getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" <<
353 getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" <<
354 getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl;
355 }
356 }
357 }
358 }
359}
360void TPCMapping::myprint2(){
54b54089 361 // debug printout
3e87ef69 362 int FEC = 0;
363 int channel = 0;
364 int rownum = 0;
365
366 for(int j = 0; j < 95 ; j++){
367 for(int i = 0; i < fsizeoffIRORC ; i++){
368 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) ){
369 rownum++;
370 }
371 }
372 if(rownum != 0){
373 cout << rownum << "\t" << j << "\t";
374 for(int k = 0; k < getPadsperRow(j) ; k++){
375 for(int i = 0; i < fsizeoffIRORC ; i++){
376 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) {
377 cout << getAltroChannel(i)+(32-getFEC(i))*128 << "\t";
378// cout << getAltroChannel(i) << "\t";
379 }
380 }
381 }
382 cout << endl;
383 }
384 rownum = 0;
385 }
386}
387
388#endif