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