removing old CF configurations, ids redirected to HWCF; global tracking option enable...
[u/mrichter/AliRoot.git] / HLT / TPCLib / mapping2array.cxx.in
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <iostream>
4 #include <fstream>
5 #include <stdlib.h>
6 #include <iomanip>
7
8 using namespace std;
9
10 int main(){
11     ifstream inFile[6];
12     ofstream outFile;
13     
14     //char * mappingpath="@TPC_PAD_MAPPING_PATH@/";
15     char * mappingfiles[6]= {"@TPC_PAD_MAPPING_PATH@/Patch0.data",
16                              "@TPC_PAD_MAPPING_PATH@/Patch1.data",
17                              "@TPC_PAD_MAPPING_PATH@/Patch2.data",
18                              "@TPC_PAD_MAPPING_PATH@/Patch3.data",
19                              "@TPC_PAD_MAPPING_PATH@/Patch4.data",
20                              "@TPC_PAD_MAPPING_PATH@/Patch5.data"};
21
22     int numberOfChannels[6];
23     int maxHWAddress[6];
24
25     outFile.open("mapping_array_out.inc");
26
27     outFile << "// **** WARNING: This file is generated automatically. DO NOT EDIT" << endl << endl;
28     
29
30     for (int ii = 0; ii< 6; ii++) {
31       
32       //for (int ii = 1; ii< 2; ii++) {
33         
34         inFile[ii].open(mappingfiles[ii]);
35         inFile[ii].seekg (0, ios::beg);
36
37         int* tmpPad;
38         int* tmpRow;
39
40         inFile[ii] >> numberOfChannels[ii] >> maxHWAddress[ii];
41
42         cout << numberOfChannels[ii] << "  "<< maxHWAddress[ii]<< endl;
43         
44         outFile << "Int_t AliHLTTPCDigitReaderRaw::fgMapping"<< ii << "["<< maxHWAddress[ii]+1 << "][2] = { " << endl;
45         tmpPad = new int[maxHWAddress[ii]+1];
46         tmpRow = new int[maxHWAddress[ii]+1];
47
48         for (int jj = 0; jj <= maxHWAddress[ii]; jj++){
49             tmpPad[jj] = -1;
50             tmpRow[jj] = -1;
51         }
52             
53         while (1) {
54             int address,row,pad;
55             
56             inFile[ii] >> address >> row >>  pad;
57             tmpPad[address] = pad;
58             tmpRow[address] = row;
59
60             if (!inFile[ii].good()) break;
61         }
62
63         for (int jj = 0; jj <= maxHWAddress[ii]; jj++)
64           {
65 //          if ( tmpRow[jj]==-1 )
66 //            printf( "Found -1 (%d)\n", jj );
67             outFile <<  "{" << tmpRow[jj] << "," << tmpPad[jj] << "},"<< endl;
68           }
69
70
71         cout << " ---------------" << ii << endl;
72         
73         inFile[ii].close();
74         outFile << "};\n" << endl;
75     }
76
77     outFile << "unsigned AliHLTTPCDigitReaderRaw::fgMaxHWA[6]= {";
78     for ( int ii=0; ii<6; ii++ )
79       {
80         outFile << maxHWAddress[ii];
81         if ( ii<5 )
82           outFile << ",";
83       }
84     outFile << "};" << endl;
85
86     
87         outFile.close();
88
89   
90    
91     return 0;
92 }