AraDisplay/AraFFTGraph.cxx
00001 #include "AraFFTGraph.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(AraFFTGraph); 00014 00015 AraFFTGraph::AraFFTGraph() 00016 00017 : TGraph(),fNewCanvas(0),fNumInAverage(1) 00018 00019 { 00020 this->SetEditable(kFALSE); 00021 00022 } 00023 00024 00025 AraFFTGraph::AraFFTGraph(int N, const Int_t *x, const Int_t *y) 00026 00027 : TGraph(N,x,y),fNewCanvas(0),fNumInAverage(1) 00028 { 00029 this->SetEditable(kFALSE); 00030 } 00031 00032 AraFFTGraph::AraFFTGraph(int N, const Float_t *x, const Float_t *y) 00033 00034 : TGraph(N,x,y),fNewCanvas(0),fNumInAverage(1) 00035 { 00036 this->SetEditable(kFALSE); 00037 } 00038 00039 AraFFTGraph::AraFFTGraph(int N, const Double_t *x, const Double_t *y) 00040 00041 : TGraph(N,x,y),fNewCanvas(0),fNumInAverage(1) 00042 { 00043 this->SetEditable(kFALSE); 00044 } 00045 00046 AraFFTGraph::~AraFFTGraph() 00047 { 00048 // std::cout << "~AraFFTGraph" << std::endl; 00049 } 00050 00051 void AraFFTGraph::ExecuteEvent(Int_t event, Int_t px, Int_t py) 00052 { 00053 switch (event) { 00054 case kButtonPress: 00055 // cout << "kButtonPress" << endl; 00056 break; 00057 00058 case kButtonDoubleClick: 00059 // std::cout << "kButtonDoubleClick" << std::endl; 00060 new TCanvas(); 00061 break; 00062 00063 case kButton1Down: 00064 // std::cout << "kButton1Down" << std::endl; 00065 if(!fNewCanvas) drawInNewCanvas(); 00066 else this->TGraph::ExecuteEvent(event,px,py); 00067 break; 00068 00069 default: 00070 this->TGraph::ExecuteEvent(event,px,py); 00071 break; 00072 } 00073 } 00074 00075 void AraFFTGraph::drawInNewCanvas() 00076 { 00077 char graphTitle[180]; 00078 gStyle->SetTitleH(0.1); 00079 gStyle->SetOptTitle(1); 00080 gStyle->SetPadLeftMargin(0.15); 00081 gStyle->SetPadRightMargin(0.1); 00082 gStyle->SetPadTopMargin(0.1); 00083 gStyle->SetPadBottomMargin(0.1); 00084 gStyle->SetCanvasDefW(600); 00085 gStyle->SetCanvasDefH(400); 00086 // gROOT->ForceStyle(); 00087 AraFFTGraph *thisCopy = (AraFFTGraph*)this->Clone(); 00088 thisCopy->GetXaxis()->SetLabelSize(0.06); 00089 thisCopy->GetXaxis()->SetTitleSize(0.06); 00090 thisCopy->GetYaxis()->SetLabelSize(0.06); 00091 thisCopy->GetYaxis()->SetTitleSize(0.06); 00092 thisCopy->GetXaxis()->SetTitle("Frequency (MHz)"); 00093 thisCopy->GetYaxis()->SetTitle("dB (m maybe)"); 00094 // sprintf(graphTitle,"Ant %d%c (%s Ring -- Phi %d -- SURF %d -- Chan %d)", 00095 // fAnt+1,AnitaPol::polAsChar(fPol),AnitaRing::ringAsString(fRing), 00096 // fPhi+1,fSurf+1,fChan+1); 00097 thisCopy->SetTitle(graphTitle); 00098 TCanvas *can = new TCanvas(); 00099 can->SetLeftMargin(0.15); 00100 can->SetBottomMargin(0.15); 00101 can->SetTopMargin(0.1); 00102 can->SetRightMargin(0.1); 00103 thisCopy->Draw("al"); 00104 // fNewCanvas=1; 00105 } 00106 00107 Int_t AraFFTGraph::AddFFT(AraFFTGraph *otherGraph) 00108 { 00109 if(otherGraph->GetN()!=this->GetN()) { 00110 std::cerr << "Trying to add AraFFTGraph with different number of points " << otherGraph->GetN() << " instead of " << this->GetN() << "\n"; 00111 return -1; 00112 } 00113 Double_t *newY=otherGraph->GetY(); 00114 for(int bin=0;bin<fNpoints;bin++) { 00115 fY[bin]=(fY[bin]*fNumInAverage + newY[bin])/Double_t(fNumInAverage+1); 00116 } 00117 fNumInAverage++; 00118 return fNumInAverage; 00119 } 00120
Generated on Mon Jun 3 16:10:04 2013 for ARA ROOT v3.9 Software by
