source: fact/tools/rootmacros/plotraw.C@ 12325

Last change on this file since 12325 was 12260, checked in by neise, 13 years ago
I case you want to see real raw data
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#include <TROOT.h>
2#include <TCanvas.h>
3#include <TProfile.h>
4
5#include <stdint.h>
6#include <cstdio>
7
8#define HAVE_ZLIB
9#include "fits.h"
10#include "FOpenDataFile.c"
11
12int plotevent(
13 char *title,
14 vector<int16_t> &data,
15 UInt_t data_roi,
16 size_t pixelnr);
17
18
19int plotraw(const char *name = "../raw/20110916_025.fits", size_t eventnr = 0, size_t pixelnr = 0)
20{
21 gROOT->SetStyle("Plain");
22
23 fits datafile(name);
24 if (!datafile)
25 {
26 cout << "Couldn't properly open the datafile." << endl;
27 return 1;
28 }
29
30//-------------------------------------------
31//Get the data
32//-------------------------------------------
33 vector<int16_t> data;
34 vector<int16_t> data_offset;
35 unsigned int data_num;
36 size_t data_n;
37 UInt_t data_px;
38 UInt_t data_roi;
39 FOpenDataFile(datafile, data, data_offset, data_num, data_n, data_roi, data_px);
40
41
42//-------------------------------------------
43//Create the title
44//-------------------------------------------
45 char title[500];
46 std::sprintf(title,"Data: %s, Px %i Ev %i",name,pixelnr,eventnr);
47
48//-------------------------------------------
49//Get the event
50//-------------------------------------------
51 cout << "--------------------- Data --------------------" << endl;
52 datafile.GetRow(eventnr);
53 cout << "Event number: " << data_num << endl;
54
55//-------------------------------------------
56//Draw the data
57//-------------------------------------------
58 plotevent(title, data, data_roi, pixelnr);
59 return 0;
60}
61
62
63
64int plotevent(
65 char *title,
66 vector<int16_t> &data,
67 UInt_t data_roi,
68 size_t pixelnr)
69{
70 TCanvas *canv = new TCanvas( "canv", "Mean values of the first event", 100, 10, 700, 500 );
71 TProfile *pix = new TProfile("pix", title, 1024, -0.5, 1023.5);
72
73 for (UInt_t k=0; k<data_roi; k++)
74 {
75 float sample = (data[pixelnr*data_roi+k]);
76 pix->Fill(k,sample);
77 }
78 pix->Draw();
79 canv->Modified();
80 canv->Update();
81
82 return 0;
83}
Note: See TracBrowser for help on using the repository browser.