#include <LasGuiMeasurement.h>
This class represents a single measurement while performing several voltage scans across a silicon detector. For each measurement, the selected voltage and measured current (read from the KEITHLEY 2410 sourcemeter) are stored. Also, if the scope has been enabled (initialized), the information of the corresponding active scope channels is also stored in the TTree through this LasGuiMeasurement class.
A Makefile under /afs/ific.uv.es/user/s/silicio/laser_gui/gtklasgui/lib allows to create the library requested by ROOT to be able to access the tree. The resulting library, libLasGuiMeasurement.so, can be found in the previous directory, but has also been copied to /afs/ific.uv.es/user/silicio/lib and /l/silicio/usr/lib in silab11 PC.
A macro example ReadNtuple.C has been set under /afs/ific.uv.es/user/s/silicio/laser_gui/gtklasgui/macros to demonstrate how to read the resulting ntuple.root file containg a TTree filled with LasGuiMeasurement class objects.
NOTE: ROOT v5.10.0 has been installed in silab11, under /l/silicio/root/v5.10.00.
In order to use it please set ROOTSYS environment variable to that directory and add to ${ROOTSYS}/bin to your path variable.
This macro is shown below (please not the loading of the library libLasGuiMeasurement.so):
#include <iostream> #include <strstream> #include <iomanip> #include <fstream> #include <vector> #include <cstring> #include <string> #include <cstdio> #include <iomanip> #include "TROOT.h" #include "TTree.h" #include "TFile.h" #include "TControlBar.h" #include "TH2F.h" #include "TGraph.h" #include "TH1.h" #include "TH2.h" #include "TGraph.h" #include "TProfile.h" #include "TCanvas.h" #include "TStyle.h" #include "TPave.h" #include "TPaveText.h" #include "TLorentzVector.h" /***************************************************** Example of macro for dealing with TTree filled with LasGuiMeasurement class objects. Sergio Gonzalez Sevilla April 2006 *****************************************************/ void ReadNtuple(){ gROOT->Reset(); gStyle->SetCanvasBorderMode(0); gStyle->SetCanvasBorderSize(0); gStyle->SetPadBorderMode(0); gStyle->SetLabelFont(31,"X"); gStyle->SetLabelFont(31,"Y"); gStyle->SetLabelFont(31,"Z"); gStyle->SetOptFit(1111); gStyle->SetOptStat("nemruo"); gStyle->SetStatX(0.95); gStyle->SetStatY(0.99); gStyle->SetStatW(0.2); gStyle->SetStatH(0.1); gStyle->SetPalette(1); gStyle->SetFrameBorderMode(0); gROOT->ForceStyle(); gSystem->Load("../lib/libLasGuiMeasurement.so"); TFile *file = new TFile("ntuple.root"); TTree *tree = (TTree*)file->Get("tree"); LasGuiMeasurement *meas = new LasGuiMeasurement(); TBranch *brmeas = tree->GetBranch("lasguimeas"); brmeas->SetAddress(&meas); int nmeas = tree->GetEntries(); int print_level=1; if(print_level>0){ //--------------------------------------------------- // print detailed information about each measurement //--------------------------------------------------- for(int i=0; i<nmeas; i++){ brmeas->GetEntry(i); cout << endl << "Measurement " << i << " : " << endl << "================" << endl; cout << "MeasNumber = " << meas->GetMeasNumber() << endl << "MeasIndexInScan= " << meas->GetMeasIndexInScan() << endl << "ScanNumber = " << meas->GetScanNumber() << endl; // Source information cout << " o Voltage (V) = " << meas->GetVoltage() << " ; Current (A) = " << meas->GetCurrent() << endl; // Axis information for(int j=0; j<3; j++){ cout << " o Axis " << meas->GetAxisIndex(j) << " was enabled = " << meas->isAxisEnabled(j) << " ; position = " << meas->GetAxisPosition(j) << endl; } // Scope information for(int j=0; j<4; j++){ cout << " o Channel " << meas->GetChannelNumber(j) << " was active = " << meas->isChannelActive(j) << endl; if(meas->isChannelActive(j)==true){ cout << " - timescale (s) = " << meas->GetTimeScale(j) << endl; cout << " - channel_scale (V/div) = " << meas->GetChannelScale(j) << endl; cout << " - rise_time (s) = " << meas->GetRiseTime(j) << endl; cout << " - vamplitude (V) = " << meas->GetVamplitude(j) << endl; cout << " - vbase (V) = " << meas->GetVbase(j) << endl; cout << " - vmax (V) = " << meas->GetVmax(j) << endl; cout << " - vmin (V) = " << meas->GetVmin(j) << endl; cout << " - vpp (V) = " << meas->GetVpp(j) << endl; if(print_level>1){ double *wavetimes = meas->GetWaveTimes(j); double *wavevolts = meas->GetWaveVolts(j); for(int k=0; k<meas->GetNPoints(j); k++){ cout << k << " " << wavetimes[k] << " " << wavevolts[k] << endl; } } } } } // end loop in entries }// end print_level //--------------------------------------------------- // create some graphs //--------------------------------------------------- const int max_scans = 25; const int max_voltages_in_scan = 100; TGraph *gr[max_scans]; float voltage[max_scans][max_voltages_in_scan]; float current[max_scans][max_voltages_in_scan]; int nmeasures_in_scan[max_scans]; TGraph2D *gr2d = new TGraph2D(); // get total number of scans brmeas->GetEntry(nmeas-1); int totscans = meas->GetScanNumber() + 1; // initialize arrays for(int i=0; i<totscans; i++){ nmeasures_in_scan[i]=0; for(int j=0; j<max_voltages_in_scan; j++){ voltage[i][j]=0; current[i][j]=0; } } brmeas->GetEntry(0); int oldscanum=meas->GetScanNumber(); int nm=0, totpoints=0; // fill arrays for(int i=0; i<nmeas; i++){ brmeas->GetEntry(i); voltage[meas->GetScanNumber()][meas->GetMeasIndexInScan()] = meas->GetVoltage(); current[meas->GetScanNumber()][meas->GetMeasIndexInScan()] = 1e6*meas->GetCurrent(); if(meas->GetScanNumber() == oldscanum) nm++; else{ nmeasures_in_scan[oldscanum] = nm; oldscanum = meas->GetScanNumber(); nm = 1; } // do not forget last scan... if(i == (nmeas-1)) nmeasures_in_scan[totscans-1] = nm; // fill TGraph2D if(meas->GetScanNumber()==0){ for(int j=0; j<4; j++){ if(meas->isChannelActive(j)==true){ double *wavetimes = meas->GetWaveTimes(j); double *wavevolts = meas->GetWaveVolts(j); for(int k=0; k<meas->GetNPoints(j); k++){ gr2d->SetPoint(totpoints, 1e9*wavetimes[k], meas->GetVoltage(), wavevolts[k]); totpoints++; } } } } } // end loop in entries //--------------------------------------------------- // fill them //--------------------------------------------------- float x[max_voltages_in_scan]={0}, y[max_voltages_in_scan]={0}; for(int i=0; i<totscans; i++){ for(int j=0; j<nmeasures_in_scan[i]; j++){ x[j] = voltage[i][j]; y[j] = current[i][j]; } gr[i] = new TGraph(nmeasures_in_scan[i],x,y); gr[i]->SetMarkerStyle(20); gr[i]->SetMarkerSize(1.3); gr[i]->SetMarkerColor(i+1); gr[i]->SetLineColor(i+1); } //--------------------------------------------------- // drawing graphs //--------------------------------------------------- // create box for graphs TH2F *box0 = new TH2F("box0", "box0", 2, -110, 0, 2, -0.15, 0.04); box0->GetXaxis()->SetTitle("Voltage (V)"); box0->GetYaxis()->SetTitle("Current (#mu A)"); box0->SetTitle("Current vs bias voltage"); box0->SetStats(kFALSE); // create legend char title[100]; TLegend *leg0 = new TLegend(0.16, 0.72, 0.44, 0.87); for(int i=0; i<totscans; i++){ sprintf(title, "Scan # %d", i); leg0->AddEntry(gr[i], title, "L"); } gStyle->SetTitleXOffset(1.0); gStyle->SetTitleYOffset(1.0); TCanvas *c1 = new TCanvas("c1","c1"); c1->SetFillColor(0); c1->SetBorderMode(0); c1->Draw(); box0->Draw(); leg0->Draw(); for(int i=0; i<totscans; i++) gr[i]->Draw("PL"); c1->Update(); gStyle->SetTitleXOffset(1.5); gStyle->SetTitleYOffset(1.5); TCanvas *c2 = new TCanvas("c2","c2"); c2->SetFillColor(0); c2->SetBorderMode(0); c2->Draw(); gr2d->SetTitle("Scope pulse reconstruction"); gr2d->GetXaxis()->SetTitle("Time (ns)"); gr2d->GetXaxis()->SetLimits(-80, -10); gr2d->GetYaxis()->SetTitle("Bias Voltage (V)"); cout << "Drawing TGraph2D. Please wait...." << endl; c2->Draw(); gStyle->SetPalette(1); gr2d->Draw("tri1"); c2->Update(); }
The output should look like to something like:
Definition at line 49 of file LasGuiMeasurement.h.
Public Member Functions | |
| LasGuiMeasurement () | |
| void | SetMeasNumber (int i) |
| void | SetScanNumber (int i) |
| void | SetMeasIndexInScan (int i) |
| void | SetAxisEnabled (int ax, bool b) |
| void | SetAxisIndex (int ax, int i) |
| void | SetAxisPosition (int ax, float f) |
| void | SetVoltage (float f) |
| void | SetCurrent (float f) |
| void | SetChannelActive (int ch, bool b) |
| void | SetChannelNumber (int ch, int i) |
| void | SetTimeScale (int ch, float f) |
| void | SetChannelScale (int ch, float f) |
| void | SetRiseTime (int ch, float f) |
| void | SetVamplitude (int ch, float f) |
| void | SetVbase (int ch, float f) |
| void | SetVmax (int ch, float f) |
| void | SetVmin (int ch, float f) |
| void | SetVpp (int ch, float f) |
| void | SetNPoints (int ch, int i) |
| void | SetWaveTimes (int, double *, double) |
| void | SetWaveVolts (int, double *) |
| int | GetMeasNumber () const |
| int | GetScanNumber () const |
| int | GetMeasIndexInScan () const |
| bool | isAxisEnabled (int ax) const |
| int | GetAxisIndex (int ax) const |
| float | GetAxisPosition (int ax) const |
| float | GetVoltage () const |
| float | GetCurrent () const |
| bool | isChannelActive (int ch) const |
| int | GetChannelNumber (int ch) const |
| float | GetTimeScale (int ch) const |
| float | GetChannelScale (int ch) const |
| float | GetRiseTime (int ch) const |
| float | GetVamplitude (int ch) const |
| float | GetVbase (int ch) const |
| float | GetVmax (int ch) const |
| float | GetVmin (int ch) const |
| float | GetVpp (int ch) const |
| int | GetNPoints (int ch) const |
| double * | GetWaveTimes (int ch) |
| double * | GetWaveVolts (int ch) |
|
|
Constructor Definition at line 6 of file LasGuiMeasurement.cc.
00006 {
00007 meas_number = 0;
00008 scan_number = 0;
00009 meas_index_in_scan = 0;
00010
00011 for(int i=0; i<MAXAXIS; i++){
00012 axis_enabled[i]=false;
00013 axis_index[i]=i;
00014 axis_position[i]=0;
00015 }
00016
00017 for(int i=0; i<MAXCHANNELS; i++){
00018 channel_active[i]=false;
00019 channel_number[i]=i+1;
00020 timescale[i]=0;
00021 channel_scale[i]=0;
00022 rise_time[i]=0;
00023 vamplitude[i]=0;
00024 vbase[i]=0;
00025 vmax[i]=0;
00026 vmin[i]=0;
00027 vpp[i]=0;
00028 npoints[i]=0;
00029
00030 for(int j=0; j<MAXWAVEPOINTS; j++){
00031 wavetimes[i][j]=0;
00032 wavevolts[i][j]=0;
00033 }
00034 }
00035 }
|
|
|
Returns the axis index of the given input axis (possible values: 0, 1, 2). Definition at line 95 of file LasGuiMeasurement.h.
00095 { return axis_index[ax]; }
|
|
|
Returns the position in mm of the input axis. Definition at line 98 of file LasGuiMeasurement.h.
00098 { return axis_position[ax]; }
|
|
|
Returns the oscilloscope channel number (possible values: 1, 2, 3, 4). Definition at line 110 of file LasGuiMeasurement.h.
00110 { return channel_number[ch]; }
|
|
|
Returns the channel scale (in volts/division) of the recorded source waveform. Definition at line 116 of file LasGuiMeasurement.h.
00116 { return channel_scale[ch]; }
|
|
|
Returns the current value (in amperes) measured by the SourceMeter KEITHLEY 2410. Definition at line 104 of file LasGuiMeasurement.h.
00104 { return current; }
|
|
|
Returns the index of the measurement within the scan. Definition at line 89 of file LasGuiMeasurement.h.
00089 { return meas_index_in_scan; }
|
|
|
Returns the absolute index of the measurement, i.e, the absolute measurement number. Definition at line 81 of file LasGuiMeasurement.h.
00081 { return meas_number; }
|
|
|
Returns the number of points of the acquired waveform (actually fixed to 256). Definition at line 142 of file LasGuiMeasurement.h.
00142 { return npoints[ch]; }
|
|
|
Returns the rise time (in seconds) of the first displayed edge by measuring the time at the lower threshold of the rising edge, then calculating the rise time as: rise_time = (time at upper threshold point) - (time at lower threshold point) Definition at line 123 of file LasGuiMeasurement.h.
00123 { return rise_time[ch]; }
|
|
|
Returns the scan number this measurement belongs to. Definition at line 84 of file LasGuiMeasurement.h.
00084 { return scan_number; }
|
|
|
Returns the horizontal scale value displayed as time/div on the oscilloscope screen. Definition at line 113 of file LasGuiMeasurement.h.
00113 { return timescale[ch]; }
|
|
|
Returns the difference (in volts) between the top and base voltage of the specified source. Definition at line 126 of file LasGuiMeasurement.h.
00126 { return vamplitude[ch]; }
|
|
|
Returns the measured statistical base (in volts) of the waveform. Definition at line 129 of file LasGuiMeasurement.h.
00129 { return vbase[ch]; }
|
|
|
Returns the absolute maximum voltage (in volts) of the recorded source waveform. Definition at line 132 of file LasGuiMeasurement.h.
00132 { return vmax[ch]; }
|
|
|
Returns the absolute minimum voltage (in volts) of the recorded source waveform. Definition at line 135 of file LasGuiMeasurement.h.
00135 { return vmin[ch]; }
|
|
|
Returns the voltage value (in volts) measured by the SourceMeter KEITHLEY 2410. Definition at line 101 of file LasGuiMeasurement.h.
00101 { return voltage; }
|
|
|
Returns the peak-to-peak value (in volts) of the recorded waveform, calculated as the difference between the maximum and minimum voltages on the selected source. Definition at line 139 of file LasGuiMeasurement.h.
00139 { return vpp[ch]; }
|
|
|
Returns an array of doubles representing the time values of the acquired points of the waveform. Definition at line 149 of file LasGuiMeasurement.h.
00149 { return wavetimes[ch]; }
|
|
|
Returns an array of doubles representing the measured voltage values of the acquired points of the waveform. Definition at line 153 of file LasGuiMeasurement.h.
00153 { return wavevolts[ch]; }
|
|
|
Returns a bool value to know if the given input axis was enabled or not. Definition at line 92 of file LasGuiMeasurement.h.
00092 { return axis_enabled[ax]; }
|
|
|
Returns a bool value to know if the given input oscilloscope channel was enabled or not. Definition at line 107 of file LasGuiMeasurement.h.
00107 { return channel_active[ch]; }
|
1.3.5