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