]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/scripts/ShowRaw.C
New RAW I/O. I rolled my own, because I wasn't happy with the old
[u/mrichter/AliRoot.git] / FMD / scripts / ShowRaw.C
CommitLineData
d389af40 1//
a1f80595 2// $Id$
3//
d389af40 4// Script to read a raw data file, and dump it to std::cout
5//
6#include <iomanip>
7
8void
9ShowRaw(Int_t det=2, bool verbose=false, Int_t event=0)
10{
1e8f773e 11 TString file(Form("raw%d/FMD_%d.ddl", event,
12 AliFMDParameters::kBaseDDL + det - 1));
d389af40 13
14 std::cout << "Reading raw data file " << file << std::endl;
15
824466d5 16 TH1* h = new TH1F("rawData", "Raw Data", 128, 0, 1024);
d389af40 17
18
19 // This method creates a text file containing the same information
20 // stored in an Altro file. The information in the text file is
21 // organized pad by pad and and for each pad it consists in a
22 // sequence of bunches (Bunch length +2, Time bin of the last
23 // amplitude sample in the bunch, amplitude values) It is used
24 // mainly //for debugging
25
26 AliAltroBuffer buff(file.Data(),0);
27 Int_t numWords,padNum,rowNum,secNum=0;
28 Int_t value = 0;
29 Int_t zero = 0;
1e8f773e 30 if (!buff.ReadDataHeader()) {
31 std::cout<< file << " isn't a valid data file!" << std::endl;
32 }
d389af40 33
34 while(buff.ReadTrailerBackward(numWords,padNum,rowNum,secNum)){
35 if (verbose)
36 std::cout << "Ring: " << (secNum == 0 ? 'I' : 'O')
37 << " Sector: " << std::setw(2) << rowNum
38 << " Strip: " << std::setw(3) << padNum
39 << " Words: " << std::setw(4) << numWords << std::endl;
40 if (numWords == 0) zero++;
41 if (numWords % 4){
42 if (verbose)
43 std::cout << "Skipping trailer of "
44 << (4 - numWords % 4) << " words" << std::endl;
45 for(Int_t j = 0; j < (4 - numWords % 4); j++)
46 value=buff.GetNextBackWord();
47 }//end if
48 for(Int_t i = 0; i <numWords; i++) {
49 value=buff.GetNextBackWord();
50 if (verbose) {
51 std::cout << std::setw(5) << value << std::flush;
52 if (i % 16 == 15) std::cout << std::endl;
53 }
54 h->Fill(value);
55 }//end for
56 if (verbose)
57 std::cout << std::endl;
58 if (zero > 1) {
59 std::cout << "Error: Read zero channels - should not happen"
60 << std::endl;
61 break;
62 }
63 }//end while
824466d5 64
65 TCanvas* c = new TCanvas("raw", "Raw Data");
66 c->SetFillColor(0);
67 c->SetLogy();
68 c->SetBorderMode(0);
d389af40 69 h->Draw();
70 return;
71}
a1f80595 72//____________________________________________________________________
73//
74// EOF
75//