coding conventions, eff C++, formatting, AliHLTConsumerDescriptor moved from AliHLTDa...
[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     int ofile;
14    
15     
16     char * mappingpath="@TPC_PAD_MAPPING_PATH@/";
17     char * mappingfiles[6]= {"@TPC_PAD_MAPPING_PATH@/Patch0.data",
18                              "@TPC_PAD_MAPPING_PATH@/Patch1.data",
19                              "@TPC_PAD_MAPPING_PATH@/Patch2.data",
20                              "@TPC_PAD_MAPPING_PATH@/Patch3.data",
21                              "@TPC_PAD_MAPPING_PATH@/Patch4.data",
22                              "@TPC_PAD_MAPPING_PATH@/Patch5.data"};
23
24     int numberOfChannels[6];
25     int maxHWAddress[6];
26
27     outFile.open("mapping_array_out.inc");
28
29     outFile << "// **** WARNING: This file is generated automatically. DO NOT EDIT" << endl << endl;
30     
31
32     for (int ii = 0; ii< 6; ii++) {
33       
34       //for (int ii = 1; ii< 2; ii++) {
35         
36         inFile[ii].open(mappingfiles[ii]);
37         inFile[ii].seekg (0, ios::beg);
38
39         int* tmpPad;
40         int* tmpRow;
41
42         inFile[ii] >> numberOfChannels[ii] >> maxHWAddress[ii];
43
44         cout << numberOfChannels[ii] << "  "<< maxHWAddress[ii]<< endl;
45         
46         outFile << "Int_t AliHLTTPCDigitReaderRaw::fgMapping"<< ii << "["<< maxHWAddress[ii]+1 << "][2] = { " << endl;
47         tmpPad = new int[maxHWAddress[ii]+1];
48         tmpRow = new int[maxHWAddress[ii]+1];
49
50         for (int jj = 0; jj <= maxHWAddress[ii]; jj++){
51             tmpPad[jj] = -1;
52             tmpRow[jj] = -1;
53         }
54             
55         while (1) {
56             int address,row,pad;
57             
58             inFile[ii] >> address >> row >>  pad;
59             tmpPad[address] = pad;
60             tmpRow[address] = row;
61
62             if (!inFile[ii].good()) break;
63         }
64
65         for (int jj = 0; jj <= maxHWAddress[ii]; jj++)
66           {
67 //          if ( tmpRow[jj]==-1 )
68 //            printf( "Found -1 (%d)\n", jj );
69             outFile <<  "{" << tmpRow[jj] << "," << tmpPad[jj] << "},"<< endl;
70           }
71
72
73         cout << " ---------------" << ii << endl;
74         
75         inFile[ii].close();
76         outFile << "};\n" << endl;
77     }
78
79     outFile << "unsigned AliHLTTPCDigitReaderRaw::fgMaxHWA[6]= {";
80     for ( int ii=0; ii<6; ii++ )
81       {
82         outFile << maxHWAddress[ii];
83         if ( ii<5 )
84           outFile << ",";
85       }
86     outFile << "};" << endl;
87
88     
89         outFile.close();
90
91   
92    
93     return 0;
94 }