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 |
|
---|
12 | int plotevent(
|
---|
13 | char *title,
|
---|
14 | vector<int16_t> &data,
|
---|
15 | UInt_t data_roi,
|
---|
16 | size_t pixelnr);
|
---|
17 |
|
---|
18 |
|
---|
19 | int 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 |
|
---|
64 | int 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 | }
|
---|