source: fact/tools/rootmacros/calscope.C@ 12198

Last change on this file since 12198 was 12171, checked in by kraehenb, 13 years ago
Changed wrong character
File size: 2.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#include "fits.h"
9#include "TPKplotevent.c"
10#include "FOpenDataFile.c"
11#include "FOpenCalibFile.c"
12
13int calscope(const char *name = "../raw/20110916_025.fits", const char *drsname = "../raw/20110916_024.drs.fits", size_t eventnr = 0, size_t pixelnr = 0)
14{
15//******************************************************************************
16//Read a datafile and plot the DRS-calibrated data
17//ATTENTION: only works for ROI=1024
18// (array indices of the calibration wrong otherwise)
19//Example call in ROOT:
20//root [74] .x calscope.C++("20110804_024.fits","20110804_023.drs.fits",10,1348)
21//T. Krähenbühl, August 2011, tpk@phys.ethz.ch
22//******************************************************************************
23
24 gROOT->SetStyle("Plain");
25
26//-------------------------------------------
27//Open the file
28//-------------------------------------------
29 fits datafile(name);
30 if (!datafile)
31 {
32 cout << "Couldn't properly open the datafile." << endl;
33 return 1;
34 }
35
36//-------------------------------------------
37//Get the data
38//-------------------------------------------
39 vector<int16_t> data;
40 vector<int16_t> data_offset;
41 unsigned int data_num;
42 size_t data_n;
43 UInt_t data_px;
44 UInt_t data_roi;
45 FOpenDataFile(datafile, data, data_offset, data_num, data_n, data_roi, data_px);
46
47//-------------------------------------------
48//Get the DRS calibration
49//-------------------------------------------
50 size_t drs_n;
51 vector<float> drs_basemean;
52 vector<float> drs_gainmean;
53 vector<float> drs_triggeroffsetmean;
54 FOpenCalibFile(drsname, drs_basemean, drs_gainmean, drs_triggeroffsetmean, drs_n);
55
56//-------------------------------------------
57//Check the sizes of the data columns
58//-------------------------------------------
59 if(drs_n!=data_n)
60 {
61 cout << "Data and DRS file incompatible (Px*ROI disagree)" << endl;
62 return 1;
63 }
64
65
66//-------------------------------------------
67//Create the title
68//-------------------------------------------
69 char title[500];
70 std::sprintf(title,"Data: %s, DRS: %s, Px %i Ev %i",name,drsname,pixelnr,eventnr);
71
72//-------------------------------------------
73//Get the event
74//-------------------------------------------
75 cout << "--------------------- Data --------------------" << endl;
76 datafile.GetRow(eventnr);
77 cout << "Event number: " << data_num << endl;
78
79//-------------------------------------------
80//Draw the data
81//-------------------------------------------
82 TPKplotevent(title, data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, pixelnr);
83 return 0;
84}
Note: See TracBrowser for help on using the repository browser.