Example of a ROOT macro that computes the average samples and the RMS for all channels, from aTPC demonstrator run file.
The processing is done in the macro itself, from channels output content.
void PlotDemonstrator_RMS1 ( const string & data_file,
u_short cobo_id,
u_short asad_id,
u_short aget_id,
u_short chan_id )
{
GSetVerboseLevel(3);
u_short ncobo = 2;
u_int n = 512;
double dt = 0.01;
cout << endl
<< "Computing averages" << endl;
u_int nr = 0;
{
nr++;
for ( u_short ic = 0; ic < ncobo; ++ic )
{
for ( u_short ia = 0; ia < 4; ++ia )
{
for ( u_short ig = 0; ig < 4; ++ig )
{
for ( u_short ich = 0; ich < 68; ++ich )
{
gDemMean[ic][ia][ig][ich].OutSample() += gDem[ic][ia][ig][ich].OutSample();
}
}
}
}
}
cout << " - Number of events read: " << nr << endl
<< endl;
if (nr > 0)
{
for ( u_int i = 0; i < nch_tot; ++i )
{
}
cout << "Computing RMS" << endl
<< endl;
nr = 0;
{
nr++;
for ( u_int i = 0; i < nch_tot; ++i )
{
}
}
for ( u_int i = 0; i < nch_tot; ++i )
{
double * data = rms.GetFunctionData(false);
for ( u_short j = 0; j < n; ++j )
{
double val = data[j];
rms.SetFunctionValue ( j, sqrt(val/(nr-1.)) );
}
rms.FunctionSet ( true );
}
GETSample sample_mean = gDemMean[cobo_id][asad_id][aget_id][chan_id].OutSample();;
GETSample sample_rms = gDemRMS [cobo_id][asad_id][aget_id][chan_id].OutSample();;
GETSample sample_inf = sample_mean - sample_rms;
GETSample sample_sup = sample_mean + sample_rms;
TGraph * gr_mean = sample_mean.CreateFunctionGraph ( );
gr_mean->SetTitle ( "Average + RMS channel output" );
gr_mean->SetLineColor ( kRed+1 );
gr_mean->SetLineWidth ( 2 );
gr_mean->SetLineStyle ( 1 );
gr_mean->GetXaxis()->SetRangeUser ( 0., (n-1)*dt );
TGraph * gr_inf = sample_inf.CreateFunctionGraph ( );
gr_inf->SetLineColor ( kGreen+1 );
gr_inf->SetLineWidth ( 1 );
gr_inf->SetLineStyle ( 1 );
TGraph * gr_sup = sample_sup.CreateFunctionGraph ( );
gr_sup->SetLineColor ( kGreen+1 );
gr_sup->SetLineWidth ( 1 );
gr_sup->SetLineStyle ( 1 );
TCanvas * canvas = new TCanvas ( "PlotRMS", "PLOTRMS", 800, 400 );
gr_mean->Draw ( "AL" );
gr_inf->Draw ( "L" );
gr_sup->Draw ( "L" );
gSystem->mkdir ( "plots", kTRUE );
canvas->SaveAs ( "plots/Demonstrator_RMS1.eps" );
}
}