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

Last change on this file since 16405 was 12381, checked in by neise, 13 years ago
adjusted to the new OpenDataFile() method
  • Property svn:executable set to *
File size: 1.7 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
11#include "FOpenDataFile.h"
12#include "FOpenDataFile.c"
13
14int plotevent(
15 char *title,
16 vector<int16_t> &data,
17 UInt_t data_roi,
18 size_t pixelnr);
19
20
21int plotraw(const char *name = "../raw/20110916_025.fits", size_t eventnr = 0, size_t pixelnr = 0)
22{
23 gROOT->SetStyle("Plain");
24 vector<int16_t> data;
25 vector<int16_t> data_offset;
26 unsigned int data_num;
27 size_t data_n;
28 UInt_t data_px;
29 UInt_t data_roi;
30 size_t rc_open;
31
32 fits * datafile;
33 rc_open = OpenDataFile( name, &datafile, data, data_offset, data_num, data_roi, data_px, data_n, 0);
34
35 if (rc_open == 0){
36 cout << "some error occured during file opening ... aborting." << endl;
37 return 1;
38 }
39
40
41//-------------------------------------------
42//Create the title
43//-------------------------------------------
44 char title[500];
45 std::sprintf(title,"Data: %s, Px %i Ev %i",name,pixelnr,eventnr);
46
47 if (datafile == NULL){
48 cout << "Error: FOpenDataFile was ok, but now datafile pointer not vaild... abort." << endl;
49 return 1;
50 }
51 datafile->GetRow(eventnr);
52 cout << "Event number: " << data_num << endl;
53 plotevent(title, data, data_roi, pixelnr);
54
55 delete datafile;
56 return 0;
57}
58
59
60
61int plotevent(
62 char *title,
63 vector<int16_t> &data,
64 UInt_t data_roi,
65 size_t pixelnr)
66{
67 TCanvas *canv = new TCanvas( "canv", "Mean values of the first event", 100, 10, 700, 500 );
68 TProfile *pix = new TProfile("pix", title, 1024, -0.5, 1023.5);
69
70 for (UInt_t k=0; k<data_roi; k++)
71 {
72 float sample = (data[pixelnr*data_roi+k]);
73 pix->Fill(k,sample);
74 }
75 pix->Draw();
76 canv->Modified();
77 canv->Update();
78
79 return 0;
80}
81
Note: See TracBrowser for help on using the repository browser.