WaveformGraph.cxx
00001 #include "WaveformGraph.h" 00002 #include "TButton.h" 00003 #include "TList.h" 00004 #include "TCanvas.h" 00005 #include "TStyle.h" 00006 #include "TAxis.h" 00007 #include <iostream> 00008 using namespace std; 00009 00010 #include "FFTtools.h" 00011 00012 00013 ClassImp(WaveformGraph); 00014 00015 WaveformGraph::WaveformGraph(TGraph *gr) 00016 : TGraph(*gr),fNewCanvas(0) 00017 { 00018 this->SetEditable(kFALSE); 00019 } 00020 00021 00022 WaveformGraph::WaveformGraph() 00023 : TGraph(),fNewCanvas(0) 00024 00025 { 00026 this->SetEditable(kFALSE); 00027 } 00028 00029 00030 WaveformGraph::WaveformGraph(int N, const Int_t *x, const Int_t *y) 00031 00032 : TGraph(N,x,y),fNewCanvas(0) 00033 { 00034 this->SetEditable(kFALSE); 00035 } 00036 00037 WaveformGraph::WaveformGraph(int N, const Float_t *x, const Float_t *y) 00038 00039 : TGraph(N,x,y),fNewCanvas(0) 00040 { 00041 this->SetEditable(kFALSE); 00042 } 00043 00044 WaveformGraph::WaveformGraph(int N, const Double_t *x, const Double_t *y) 00045 00046 : TGraph(N,x,y),fNewCanvas(0) 00047 { 00048 this->SetEditable(kFALSE); 00049 } 00050 00051 WaveformGraph::~WaveformGraph() 00052 { 00053 // std::cout << "~WaveformGraph" << std::endl; 00054 } 00055 00056 void WaveformGraph::ExecuteEvent(Int_t event, Int_t px, Int_t py) 00057 { 00058 switch (event) { 00059 case kButtonPress: 00060 // cout << "kButtonPress" << endl; 00061 break; 00062 00063 case kButtonDoubleClick: 00064 // std::cout << "kButtonDoubleClick" << std::endl; 00065 new TCanvas(); 00066 break; 00067 00068 case kButton1Down: 00069 // std::cout << "kButton1Down" << std::endl; 00070 if(!fNewCanvas) drawInNewCanvas(); 00071 else this->TGraph::ExecuteEvent(event,px,py); 00072 break; 00073 00074 default: 00075 this->TGraph::ExecuteEvent(event,px,py); 00076 break; 00077 } 00078 } 00079 00080 void WaveformGraph::drawInNewCanvas() 00081 { 00082 char graphTitle[180]; 00083 gStyle->SetTitleH(0.1); 00084 gStyle->SetOptTitle(1); 00085 gStyle->SetPadLeftMargin(0.15); 00086 gStyle->SetPadRightMargin(0.1); 00087 gStyle->SetPadTopMargin(0.1); 00088 gStyle->SetPadBottomMargin(0.1); 00089 gStyle->SetCanvasDefW(600); 00090 gStyle->SetCanvasDefH(400); 00091 // gROOT->ForceStyle(); 00092 WaveformGraph *thisCopy = (WaveformGraph*)this->Clone(); 00093 thisCopy->GetXaxis()->SetLabelSize(0.06); 00094 thisCopy->GetXaxis()->SetTitleSize(0.06); 00095 thisCopy->GetYaxis()->SetLabelSize(0.06); 00096 thisCopy->GetYaxis()->SetTitleSize(0.06); 00097 thisCopy->GetXaxis()->SetTitle("Time (ns)"); 00098 thisCopy->GetYaxis()->SetTitle("Voltage (mV-ish)"); 00099 sprintf(graphTitle,"Channel %d",fChan+1); 00100 thisCopy->SetTitle(graphTitle); 00101 TCanvas *can = new TCanvas(); 00102 can->SetLeftMargin(0.15); 00103 can->SetBottomMargin(0.15); 00104 can->SetTopMargin(0.1); 00105 can->SetRightMargin(0.1); 00106 thisCopy->Draw("al"); 00107 // fNewCanvas=1; 00108 00109 } 00110 00111 //______________________________________________________________________________ 00112 void WaveformGraph::DrawFFT() 00113 { 00114 char graphTitle[180]; 00115 gStyle->SetTitleH(0.1); 00116 gStyle->SetLabelSize(0.1,"xy"); 00117 gStyle->SetTitleSize(0.1,"xy"); 00118 gStyle->SetTitleOffset(0.5,"y"); 00119 gStyle->SetOptTitle(1); 00120 gStyle->SetCanvasDefW(600); 00121 gStyle->SetCanvasDefH(400); 00122 // gROOT->ForceStyle(); 00123 00124 TCanvas *can = new TCanvas(); 00125 can->SetLeftMargin(0.15); 00126 can->SetBottomMargin(0.15); 00127 can->SetTopMargin(0.1); 00128 can->SetRightMargin(0.1); 00129 00130 TGraph *grFFT = this->getFFT(); 00131 grFFT->GetXaxis()->SetLabelSize(0.06); 00132 grFFT->GetXaxis()->SetTitleSize(0.06); 00133 grFFT->GetYaxis()->SetLabelSize(0.06); 00134 grFFT->GetYaxis()->SetTitleSize(0.06); 00135 grFFT->GetXaxis()->SetTitle("Frequency (MHz)"); 00136 grFFT->GetYaxis()->SetTitle("dB (m maybe)"); 00137 sprintf(graphTitle,"Channel %d",fChan+1); 00138 grFFT->SetTitle(graphTitle); 00139 grFFT->Draw("al"); 00140 00141 // printf("WaveformGraph::DrawFFT: not yet implemented\n"); 00142 } 00143 00144 TGraph *WaveformGraph::getFFT() 00145 { 00146 TGraph *grFFT = FFTtools::makePowerSpectrumMilliVoltsNanoSecondsdB(this); 00147 return grFFT; 00148 }
Generated on Tue Nov 24 19:05:00 2009 for CREAM TEA -- MCP/TARGET Readout by
1.3.9.1