#include #include #include #include #include #define HAVE_ZLIB #include "fits.h" #include "FOpenDataFile.c" #include "FOpenCalibFile.c" #include "FCalibrateEvent.c" int calscope(const char *name, const char *drsname, size_t eventnr, size_t pixelnr) { //****************************************************************************** //Read a datafile and plot the DRS-calibrated data //ATTENTION: only works for ROI=1024 // (array indices of the calibration wrong otherwise) //Example call in ROOT: //root [74] .x calscope.C++("20110804_024.fits","20110804_023.drs.fits",10,1348) //T. Kr�henb�hl, August 2011, tpk@phys.ethz.ch //****************************************************************************** gROOT->SetStyle("Plain"); //------------------------------------------- //Open the file //------------------------------------------- fits datafile(name); if (!datafile) { cout << "Couldn't properly open the datafile." << endl; return 1; } //------------------------------------------- //Get the data //------------------------------------------- vector data; vector data_offset; unsigned int data_num; size_t data_n; UInt_t data_px; UInt_t data_roi; FOpenDataFile(datafile, data, data_offset, data_num, data_n, data_roi, data_px); //------------------------------------------- //Get the DRS calibration //------------------------------------------- size_t drs_n; vector drs_basemean; vector drs_gainmean; vector drs_triggeroffsetmean; FOpenCalibFile(drsname, drs_basemean, drs_gainmean, drs_triggeroffsetmean, drs_n); //------------------------------------------- //Check the sizes of the data columns //------------------------------------------- if(drs_n!=data_n) { cout << "Data and DRS file incompatible (Px*ROI disagree)" << endl; return 1; } //------------------------------------------- //Create the title //------------------------------------------- char title[500]; std::sprintf(title,"Data: %s, DRS: %s, Px %i Ev %i",name,drsname,pixelnr,eventnr); //------------------------------------------- //Get the calibrated event //------------------------------------------- vector calevent(data_px*data_roi); //Vector for the calibrated event cout << "--------------------- Data --------------------" << endl; datafile.GetRow(eventnr); cout << "Event number: " << data_num << endl; FCalibrateEvent(data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, calevent, data_px, data_roi); //------------------------------------------- //Draw the data //------------------------------------------- TCanvas *canv = new TCanvas( "canv", "Mean values of the first event", 100, 10, 700, 500 ); TProfile *pix = new TProfile("pix", title, 1024, -0.5, 1023.5); for (UInt_t k=0; kFill(k,calevent[pixelnr*data_roi+k]); } pix->Draw(); canv->Modified(); canv->Update(); return 0; }