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