]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/macros/DumpClusterPointFile.C
Fix bug in tracklet reconstruction and add option to AliTRDfeeParam
[u/mrichter/AliRoot.git] / HLT / MUON / macros / DumpClusterPointFile.C
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Author: Artur Szostak
4 // Email:  artur@alice.phy.uct.ac.za | artursz@iafrica.com
5 //
6 ////////////////////////////////////////////////////////////////////////////////
7
8 #include "../src/Cluster.hpp"
9
10
11 // Formated printing of floating point numbers.
12 void Print(float value)
13 {
14         char buffer[1024];
15         char* str = &buffer[0];
16         sprintf(str, "%f", value);
17         int length = strlen(str);
18         if (str[0] == '-')
19         {
20                 cout << str;
21                 for (int i = length; i < 15; i++)
22                         cout << " ";
23         }
24         else
25         {
26                 cout << " " << str;
27                 for (int i = length+1; i < 15; i++)
28                         cout << " ";
29         };
30 };
31
32
33 // TODO: fix the endian encoding of the data format.
34
35 /* Reads the contents of a file generated with MakeClusterPointFiles.C
36    and prints the contents to screen.
37  */
38 void DumpClusterPointFile(const char* filename)
39 {
40         FILE* file = fopen(filename, "r");
41         if (file == NULL)
42         {
43                 Error("DumpClusterPointFile", "Could not open file: %s", filename);
44                 return;
45         };
46         
47         // Read the first 32 bits which is the size of the data structure in
48         // the file in 32bit words.
49         dHLT::UInt size;
50         fread(&size, sizeof(size), 1, file);
51         if (ferror(file))
52         {
53                 Error("DumpClusterPointFile", "Could not read from file: %s", filename);
54                 return;
55         };
56         cout << "Size of structure: " << size << " (4 byte) words." << endl;
57         
58         cout << " X              Y" << endl;
59         
60         // Go through all the records and dump them to screen.
61         UInt_t recordcount = size / (sizeof(dHLT::ClusterPoint) / 4);
62         for (UInt_t i = 0; i < recordcount; i++)
63         {
64                 dHLT::ClusterPoint point;
65                 fread(&point, sizeof(point), 1, file);
66                 if (ferror(file))
67                 {
68                         Error("DumpClusterPointFile", "Could not read from file: %s", filename);
69                         return;
70                 };
71                 
72                 Print(point.x);
73                 Print(point.y);
74                 cout << endl;
75         };
76         
77         fclose(file);
78 };
79