The following ROOT macro plots the input, output and reconstructed signals of a single GET channel:
#include "TestCore.H"
void TestChannel ( )
{
u_int n = 256;
double dt = 0.02;
double flin = 10.0L;
double flout = 2.0L;
double fcut = 2.5L;
double twid = 0.25L;
double peak = 0.40L;
double tmin = -0.5*dt;
double tmax = (n-0.5)*dt;
double df = 0.5L/(dt*n);
double fmin = - 0.5*df;
double fmax = 0.5L/dt + 0.5*df;
double resp_fact = 20.L;
double filt_fact = 10.L;
double fref_fact = 2000.L;
Color_t col_in0 = kRed+1;
Color_t col_in = kOrange-3;
Color_t col_out0 = kGreen+3;
Color_t col_out1 = kGreen+2;
Color_t col_out = kGreen+1;
Color_t col_rec = kRed;
Color_t col_resp = kBlue+1;
Color_t col_filt = 1;
cerr << endl;
cerr << "* Creating GET channel" << endl;
cerr << " - response function" << endl;
double SinPar[5] = { 10., 5., 1.5, 2.0, twid };
cerr << " - setting pure input signal" << endl;
input0.SetFunctionData ( FctGaus2, SinPar );
cerr << " N = " << input0.GetDimension() << endl;
cerr << " dT = " << input0.GetTimeStep() << endl;
cerr << " T[0] = " << input0.GetTimeMin() << endl;
cerr << " T[N] = " << input0.GetTimeEnd() << endl;
cerr << " dF = " << input0.GetFrequencyStep() << endl;
cerr << " Fc = " << input0.GetCriticalFrequency() << endl;
cerr << " - generating pure output signal" << endl;
cerr << " - input noise generator" << endl;
cerr << " fluctuation FWHM = " << flin << " uA" << endl;
cerr << " - generating channel input with noise" << endl;
cerr <<
" fct(In) = " << channel.
TstSample().IsFunctionSet() << endl;
cerr <<
" FFT(In) = " << channel.
TstSample().IsTransformSet() << endl;
cerr << " - generating output signal with input noise" << endl;
cerr << " - output noise generator" << endl;
cerr << " fluctuation FWHM = " << flout << " uA" << endl;
cerr << " - processing filter" << endl;
cerr << " - output signal" << endl;
cerr <<
" fct(In) = " << channel.
TstSample().IsFunctionSet() << endl;
cerr <<
" FFT(In) = " << channel.
TstSample().IsTransformSet() << endl;
cerr <<
" fct(Out) = " << channel.
OutSample().IsFunctionSet() << endl;
cerr <<
" FFT(Out) = " << channel.
OutSample().IsTransformSet() << endl;
cerr << " - reconstructed signal" << endl;
cerr << endl;
cerr << "* Creating graphs" << endl;
TGraph * SrespGr = resp.
GetResponse().CreateFunctionGraph(resp_fact);
TGraph * PrespGr = resp.
GetResponse().CreatePowerGraph(resp_fact);
SrespGr->SetLineColor ( col_resp );
SrespGr->SetLineStyle ( 1 );
SrespGr->SetLineWidth ( 2 );
PrespGr->SetLineColor ( col_resp );
PrespGr->SetLineStyle ( 1 );
PrespGr->SetLineWidth ( 2 );
TGraph * SfiltGr = filt.
GetFilter().CreateFunctionGraph(filt_fact);
TGraph * PfiltGr = filt.
GetFilter().CreatePowerGraph(filt_fact);
SfiltGr->SetLineColor ( col_filt );
SfiltGr->SetLineStyle ( 1 );
SfiltGr->SetLineWidth ( 2 );
PfiltGr->SetLineColor ( col_filt );
PfiltGr->SetLineStyle ( 1 );
PfiltGr->SetLineWidth ( 2 );
TGraph * Sin0Gr = input0.CreateFunctionGraph();
TGraph * Pin0Gr = input0.CreatePowerGraph();
Sin0Gr->SetLineColor ( col_in0 );
Sin0Gr->SetLineStyle ( 2 );
Sin0Gr->SetLineWidth ( 3 );
Pin0Gr->SetLineColor ( col_in0 );
Pin0Gr->SetLineStyle ( 2 );
Pin0Gr->SetLineWidth ( 3 );
TGraph * SinGr = channel.
TstSample().CreateFunctionGraph();
TGraph * PinGr = channel.
TstSample().CreatePowerGraph();
SinGr->SetLineColor ( col_in );
SinGr->SetLineStyle ( 1 );
SinGr->SetLineWidth ( 2 );
PinGr->SetLineColor ( col_in );
PinGr->SetLineStyle ( 1 );
PinGr->SetLineWidth ( 2 );
TGraph * Sout0Gr = output0.CreateFunctionGraph();
TGraph * Pout0Gr = output0.CreatePowerGraph();
Sout0Gr->SetLineColor ( col_out0 );
Sout0Gr->SetLineStyle ( 2 );
Sout0Gr->SetLineWidth ( 3 );
Pout0Gr->SetLineColor ( col_out0 );
Pout0Gr->SetLineStyle ( 2 );
Pout0Gr->SetLineWidth ( 3 );
TGraph * Sout1Gr = output1.CreateFunctionGraph();
TGraph * Pout1Gr = output1.CreatePowerGraph();
Sout1Gr->SetLineColor ( col_out1 );
Sout1Gr->SetLineStyle ( 1 );
Sout1Gr->SetLineWidth ( 2 );
Pout1Gr->SetLineColor ( col_out1 );
Pout1Gr->SetLineStyle ( 1 );
Pout1Gr->SetLineWidth ( 2 );
TGraph * SoutGr = output2.CreateFunctionGraph();
TGraph * PoutGr = output2.CreatePowerGraph();
SoutGr->SetLineColor ( col_out );
SoutGr->SetLineStyle ( 1 );
SoutGr->SetLineWidth ( 2 );
PoutGr->SetLineColor ( col_out );
PoutGr->SetLineStyle ( 1 );
PoutGr->SetLineWidth ( 2 );
TGraph * SrecGr = channel.
RecSample().CreateFunctionGraph();
TGraph * PrecGr = channel.
RecSample().CreatePowerGraph();
SrecGr->SetLineColor ( col_rec );
SrecGr->SetLineStyle ( 1 );
SrecGr->SetLineWidth ( 2 );
PrecGr->SetLineColor ( col_rec );
PrecGr->SetLineStyle ( 1 );
PrecGr->SetLineWidth ( 2 );
cerr << endl;
cerr << "* Creating Plots" << endl;
gStyle->SetPadLeftMargin (0.07);
gStyle->SetPadRightMargin (0.03);
gStyle->SetPadTopMargin (0.04);
gStyle->SetPadBottomMargin(0.12);
TCanvas * canvas = new TCanvas ( "TestChannel", "TestChannel", 1200, 900 );
canvas->Divide ( 1, 2 );
canvas->cd ( 1 );
TH1D * hsig = new TH1D ( "SignalFrame", "", n, tmin, tmax );
hsig->SetMinimum ( -9. );
hsig->SetMaximum ( 59. );
hsig->SetLineColor ( 0 );
hsig->SetLineWidth ( 0 );
hsig->GetXaxis()->SetTitle ( "time (#mus)" );
hsig->GetYaxis()->SetTitle ( "amplitude (fC/#mus = nA)" );
hsig->GetXaxis()->CenterTitle ( );
hsig->GetYaxis()->CenterTitle ( );
hsig->GetYaxis()->SetTitleOffset ( 0.6 );
hsig->GetXaxis()->SetTitleSize ( 0.05 );
hsig->GetYaxis()->SetTitleSize ( 0.05 );
hsig->GetYaxis()->SetTickLength ( 0.015 );
hsig->DrawCopy();
TLine * line = new TLine ( tmin, 0., tmax, 0. );
line->SetLineWidth(1);
line->SetLineColor(1);
line->SetLineStyle(1);
line->Draw();
SrespGr->Draw("L");
SfiltGr->Draw("L");
Sin0Gr->Draw("L");
SinGr->Draw("L");
Sout0Gr->Draw("L");
Sout1Gr->Draw("L");
SoutGr->Draw("L");
SrecGr->Draw("L");
canvas->cd ( 2 )->SetLogy();
TH1D * hpsd = new TH1D ( "PowerFrame", "", n, fmin, fmax );
hpsd->SetMinimum ( 5.e-10 );
hpsd->SetMaximum ( 2.e4 );
hpsd->SetLineColor ( 0 );
hpsd->SetLineWidth ( 0 );
hpsd->GetXaxis()->SetTitle ( "frequency (MHz)" );
hpsd->GetYaxis()->SetTitle ( "power spectral density" );
hpsd->GetXaxis()->CenterTitle ( );
hpsd->GetYaxis()->CenterTitle ( );
hpsd->GetYaxis()->SetTitleOffset ( 0.6 );
hpsd->GetXaxis()->SetTitleSize ( 0.05 );
hpsd->GetYaxis()->SetTitleSize ( 0.05 );
hpsd->GetYaxis()->SetNdivisions ( 7 );
hpsd->GetYaxis()->SetTickLength ( 0.015 );
hpsd->DrawCopy();
PrespGr->Draw("L");
PfiltGr->Draw("L");
Pin0Gr->Draw("L");
PinGr->Draw("L");
Pout0Gr->Draw("L");
Pout1Gr->Draw("L");
PoutGr->Draw("L");
PrecGr->Draw("L");
canvas->cd(1);
double leg_x = 0.68;
double leg_dy = 0.06;
TLegend * legend = new TLegend ( leg_x, 0.92-8*leg_dy, 0.95, 0.92 );
legend->SetFillColor(0);
legend->SetFillStyle(0);
legend->SetShadowColor(0);
legend->SetBorderSize(0);
legend->SetLineWidth(2);
legend->AddEntry ( PrespGr, ("AGet response function (x" + GGetString(resp_fact) + ")").c_str(), "l" );
legend->AddEntry ( PfiltGr, ("Filter (x" + GGetString(filt_fact) + ")").c_str(), "l" );
legend->AddEntry ( Pin0Gr, "Input signal (clean)", "l" );
legend->AddEntry ( PinGr, "Input signal (noisy)", "l" );
legend->AddEntry ( Pout0Gr, "Output signal (clean)", "l" );
legend->AddEntry ( Pout1Gr, "Output signal (input noise)", "l" );
legend->AddEntry ( PoutGr, "Output signal (in/out noise)", "l" );
legend->AddEntry ( PrecGr, "Reconstructed signal", "l" );
legend->Draw();
canvas->cd(1)->SaveAs("plots/TestChannelSignal.eps");
canvas->cd(2)->SaveAs("plots/TestChannelPower.eps");
delete hsig;
delete hpsd;
}