]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/TestRawIO.C
Bug fix: corrected file name (Levente)
[u/mrichter/AliRoot.git] / FMD / scripts / TestRawIO.C
1 //____________________________________________________________________
2 //
3 // $Id$
4 //
5 // Test of AliFMDAltro{Reader,Writer}
6 //
7 /** @ingroup simple_script
8  */
9 void
10 TestRawIO()
11 {
12   std::ofstream ofile("foo.dat");
13   AliFMDAltroWriter w(ofile);
14   for (size_t i = 0; i < 16; i++) 
15     w.AddSignal((i << 4)  + i);
16   w.AddChannelTrailer(0xabe);
17   w.Close();
18   ofile.close();
19
20   std::ifstream ifile("foo.dat");
21   AliRawDataHeader h;
22   ifile.read((char*)&h, sizeof(h));
23   AliFMDAltroReader r(ifile);
24   UShort_t hwaddr, last;
25   UShort_t data[1024];
26   int ret = r.ReadChannel(hwaddr, last, data);
27   printf("Read returned %d, w/addr=0x%x, last=%d\n", ret, hwaddr, last);
28   if (ret < 0) return;
29   for (size_t i = 0; i < last; i++)
30     std::cout << i << "\t0x" << std::hex << data[i] << std::endl;
31 }
32 //____________________________________________________________________
33 //
34 // EOF
35 //