GET library
Demonstrator_Noise.C

Example of a ROOT macro that computes the average fluctuations over time buckets, for all channels.

Demonstrator_Noise.png
* [ROOT] .L Demonstrator_Noise.C
* [ROOT] PlotDemonstrator_Noise ( "../../data/Demonstrator/run_baseline.dat", 0, 0, 1, 17 );
*

The processing is done by the functions from the GETRoot library for the channels mean and RMS samples, and then by the macro for averaging the RMS over time buckets.

//======================================================================
// ROOT macros for TPC Demonstrator system
// - read a test baseline file (2 CoBo modules / 8 AsAd)
// - compute RMS sample for all channels
// - for each channel, compute the average RMS and its standard
// deviation -> average nois for the channel
//
//======================================================================
/*
These macros require to load the GET libraries
gROOT->Macro ( (getenv("GET_BASE")+string("/root/GETRootLibs.C")).c_str() );
To execute the macro
.L Demonstrator_Noise.C
PlotDemonstrator_Noise ( "../../data/Demonstrator/run_baseline.dat" );
*/
//----------------------------------------------------------------------
// This function reads all events from a TPC demonstrator run file
// (a baseline run).
// For all channels, it creates the average samples for each channel,
// then the RMS samples.
//
// Then for each channel, the average value of the RMS sample is computed
// (averaging over time buckets), and its variation.
// This is plotted for all channels
void PlotDemonstrator_Noise ( const string & data_file )
{
GSetVerboseLevel(3);
getProcessedInfoCount = 5;
gStyle->SetPadLeftMargin ( 0.06 );
gStyle->SetPadRightMargin ( 0.02 );
gStyle->SetTitleOffset ( 1.0, "X" );
gStyle->SetTitleOffset ( 0.5, "Y" );
gStyle->SetTitleSize ( 0.05, "XYZ" );
gStyle->SetLabelSize ( 0.05, "XY" );
gStyle->SetLabelSize ( 0.04, "Z" );
gStyle->SetLabelOffset ( 0.005, "Z" );
// create the GET system
u_short ncobo = 2; // 2 CoBo modules (TPC demonstrator)
u_int n = 512; // 512 samples / channel
double dt = 0.01; // 0.01 us sampling time
GETSystem gDem(ncobo,n,dt);
//------------------------------------------------------------
// Compute the average / RMS for all channels
cout << endl
<< "Computing RMS samples" << endl;
u_int nr = GETSystemMean ( gDem, data_file, 0, false );
cout << "Number of events read: " << nr << endl
<< endl;
if (nr > 0)
{
// call GET/ROOT function to build RMS samples, with respect
// to current content of the channels (mean values)
GETSystemStdDeviation ( gDem, data_file, 0, false );
//------------------------------------------------------------
// For each channel, compute the mean RMS over time buckets
u_int nch = gDem.GetTotalChannelCount();
TGraphErrors * gr_noise = new TGraphErrors ( nch );
TGraph * gr_pts = new TGraphErrors ( nch );
for ( u_int k = 0; k < nch; ++k )
{
GETSample * out = &(gDem.GetTotalChannel(k)->OutSample());
double rms = out->GetMean ( ); // average fluctuation over time buckets
double sig = out->GetRMS ( );
gr_pts->SetPoint ( k, k, rms );
gr_noise->SetPoint ( k, k, rms );
gr_noise->SetPointError ( k, 0., sig );
}
gr_noise->SetTitle ( "Average channels noise" );
gr_noise->SetLineColor ( kRed+1 );
gr_noise->SetLineWidth ( 1 );
gr_noise->SetLineStyle ( 1 );
gr_noise->SetMarkerColor ( kRed+1 );
gr_noise->SetMarkerStyle ( 20 );
gr_noise->SetMarkerSize ( 0.3 );
gr_pts->SetMarkerColor ( 1 );
gr_pts->SetMarkerStyle ( 20 );
gr_pts->SetMarkerSize ( 0.5 );
gr_noise->GetXaxis()->SetRangeUser ( -1., nch );
gr_noise->GetXaxis()->SetTitle ( "channel index" );
gr_noise->GetYaxis()->SetTitle ( "noise (coder units)" );
gr_noise->GetXaxis()->CenterTitle ( );
gr_noise->GetYaxis()->CenterTitle ( );
TCanvas * canvas = new TCanvas ( "PlotNoiseSummary", "PlotNoiseSummary", 1500, 400 );
gr_noise->Draw ( "AP" );
gr_pts->Draw ( "P" );
canvas->Update();
// create an EPS file
gSystem->mkdir ( "plots", kTRUE );
canvas->SaveAs ( "plots/Demonstrator_Noise.eps" );
}
}