FFTGraph.cxx
1 #include "FFTGraph.h"
2 #include "TButton.h"
3 #include "TList.h"
4 #include "TCanvas.h"
5 #include "TStyle.h"
6 #include "TAxis.h"
7 #include <iostream>
8 using namespace std;
9 
10 #include "FFTtools.h"
11 
12 
13 ClassImp(FFTGraph);
14 
16 
17  : TGraph(),fNewCanvas(0),fNumInAverage(1)
18 
19 {
20  this->SetEditable(kFALSE);
21 
22 }
23 
24 
25 FFTGraph::FFTGraph(int N, const Int_t *x, const Int_t *y)
26 
27  : TGraph(N,x,y),fNewCanvas(0),fNumInAverage(1)
28 {
29  this->SetEditable(kFALSE);
30 }
31 
32 FFTGraph::FFTGraph(int N, const Float_t *x, const Float_t *y)
33 
34  : TGraph(N,x,y),fNewCanvas(0),fNumInAverage(1)
35 {
36  this->SetEditable(kFALSE);
37 }
38 
39 FFTGraph::FFTGraph(int N, const Double_t *x, const Double_t *y)
40 
41  : TGraph(N,x,y),fNewCanvas(0),fNumInAverage(1)
42 {
43  this->SetEditable(kFALSE);
44 }
45 
47 {
48  // std::cout << "~FFTGraph" << std::endl;
49 }
50 
51 void FFTGraph::ExecuteEvent(Int_t event, Int_t px, Int_t py)
52 {
53  switch (event) {
54  case kButtonPress:
55  // cout << "kButtonPress" << endl;
56  break;
57 
58  case kButtonDoubleClick:
59  // std::cout << "kButtonDoubleClick" << std::endl;
60  new TCanvas();
61  break;
62 
63  case kButton1Down:
64  // std::cout << "kButton1Down" << std::endl;
65  if(!fNewCanvas) drawInNewCanvas();
66  else this->TGraph::ExecuteEvent(event,px,py);
67  break;
68 
69  default:
70  this->TGraph::ExecuteEvent(event,px,py);
71  break;
72  }
73 }
74 
75 void FFTGraph::drawInNewCanvas()
76 {
77  char graphTitle[180];
78  gStyle->SetTitleH(0.1);
79  gStyle->SetOptTitle(1);
80  gStyle->SetPadLeftMargin(0.15);
81  gStyle->SetPadRightMargin(0.1);
82  gStyle->SetPadTopMargin(0.1);
83  gStyle->SetPadBottomMargin(0.1);
84  gStyle->SetCanvasDefW(600);
85  gStyle->SetCanvasDefH(400);
86  // gROOT->ForceStyle();
87  FFTGraph *thisCopy = (FFTGraph*)this->Clone();
88  thisCopy->GetXaxis()->SetLabelSize(0.06);
89  thisCopy->GetXaxis()->SetTitleSize(0.06);
90  thisCopy->GetYaxis()->SetLabelSize(0.06);
91  thisCopy->GetYaxis()->SetTitleSize(0.06);
92  thisCopy->GetXaxis()->SetTitle("Frequency (MHz)");
93  thisCopy->GetYaxis()->SetTitle("dB (m maybe)");
94 
95  sprintf(graphTitle,"Ant %d%c%c (%s Ring -- Phi %d -- SURF %d -- Chan %d)",
96  fPhi+1,AnitaRing::ringAsChar(fRing),AnitaPol::polAsChar(fPol),AnitaRing::ringAsString(fRing),fPhi+1,fSurf+1,fChan+1);
97  thisCopy->SetTitle(graphTitle);
98  TCanvas *can = new TCanvas();
99  can->SetLeftMargin(0.15);
100  can->SetBottomMargin(0.15);
101  can->SetTopMargin(0.1);
102  can->SetRightMargin(0.1);
103  thisCopy->Draw("al");
104  can->Modified();
105  can->Update();
106  // fNewCanvas=1;
107 }
108 
109 Int_t FFTGraph::AddFFT(FFTGraph *otherGraph)
110 {
111  if(otherGraph->GetN()!=this->GetN()) {
112  std::cerr << "Trying to add FFTGraph with different number of points " << otherGraph->GetN() << " instead of " << this->GetN() << "\n";
113  return -1;
114  }
115  Double_t *newY=otherGraph->GetY();
116  for(int bin=0;bin<fNpoints;bin++) {
117  fY[bin]=(fY[bin]*fNumInAverage + newY[bin])/Double_t(fNumInAverage+1);
118  }
119  fNumInAverage++;
120  return fNumInAverage;
121 }
122 
FFTGraph()
Constructor.
Definition: FFTGraph.cxx:15
char ringAsChar(AnitaRing::AnitaRing_t ring)
Returns the ring as a character string.
STL namespace.
const char * ringAsString(AnitaRing::AnitaRing_t ring)
Returns the ring as a character string.
The PSD display graph class that inherits from ROOT&#39;s TGraph.
Definition: FFTGraph.h:14
char polAsChar(AnitaPol::AnitaPol_t pol)
Returns the polarisation as a character string.
int AddFFT(FFTGraph *otherGraph)
Adds an FFT to an average.
Definition: FFTGraph.cxx:109
virtual ~FFTGraph()
Destructor.
Definition: FFTGraph.cxx:46