Page History
The myana user guide already has a lot of examples linked in! And here are a few more...
Table of Contents |
---|
This page holds a few example code-snippets for use in myana analysis. This analysis is written in C++ and the examples here use root for plotting. Compare with Pyana user examples to see how the same things can be done using the pyana analysis framework.
...
This method is good for any waveform data from the Acqiris digitizers, just replace the source name (here AmoITof for the AMO Ion Time of flight detector) with some other Acqiris waveform detector.
Include and global variable definitions:
Code Block |
---|
#include <TProfile.h>
static int numChannelsITof;
static int numSamplesITof;
static double sampleIntervalITof;
static TProfile* profileITof = NULL;
|
In beginjob()
, read configuration data and book a profile histogram (for each sample interval (x-axis), draw the average number of samples (y-axis), i.e. the average waveform of all events).
Code Block |
---|
int fail = getAcqConfig( AmoITof, numChannelsITof, numSamplesITof, sampleIntervalITof);
if ( fail != 0 )
printf( "begin(): getAcqConfig() failed, code = %d\n", fail );
profileITof = new TProfile("avg","avg",numSamplesITof,0.0,sampleIntervalITof,"");
profileITof->SetYTitle("Volts"); //optional
profileITof->SetXTitle("Seconds"); //optional
|
In the event()
function, get the Acqiris value for this event and add it to the histogram. The getAcqValue
function will point timeITof
and voltageITof
to arrays of readout values.
Code Block |
---|
double* timeITof; // array: sample interval
double* voltageITof; // array: readout values
int channel = 0;
int fail = getAcqValue( AmoITof, channel, timeITof, voltageITof);
if ( fail != 0 )
{
printf( "event(): getAcqValue() failed, code = %d\n", fail );
}
else
{
for (i=0;i<numSamplesITof;i=i+1)
{
double t = timeITof[i];
double v = voltageITof[i];
profileITof->Fill(t,v);
}
}
|
The resulting histogram can be drawn in a root session and would look something like this:
Beamline data (Bld)
...