Dashboard > NanoBPM > ... > Data Acquisition and Software > Using libNano
  NanoBPM Log In View a printable version of the current page.  
  Using libNano
Added by Mark Slater, last edited by Mark Slater on Dec 08, 2006  (view change)
Labels: 
(None)

NOTE: This is a carbon copy of my ELOG entry. For the most up-to-date version, look at:

http://pcfj.hep.phy.cam.ac.uk:8080/slater/22

General Use

The main part of the libNano library (used to produce the root data) is the TPulse class. This is a wrapper for a flat NTuple that contains all the data we are curerntly interested in. The root files themselves contain a single TTree called 'pulses'. To access the data in the intepreter, simply load the file:

slater@ma49-190 ~$ root -l

root 0 TFile f("NanoBPM_Data/RUN270.root")

root 1 pulses->Draw("PosnDDC21")

<TCanvas::MakeDefCanvas>: created default TCanvas with name c1

root 2

To use the data in the TPulse structure, do something similar to the following:

{ gSystem->Load("/usr/local/lib/libNano.so");  
TChain c("pulses"); 
c.Add("NanoBPM_Data/RUN270.root");  
TPulse *pulse = new TPulse; 
pulse->SetBranchAddresses( &c );  // pulse now points to the data  
c.GetEntry(10);  // Get event 10  
std::cout << "Position recorded in BPM 2Y for event 10:  " << pulse->PosnDDC[2][1] << std::endl; 
}

Data Structure

Most of the variables in TPulse refer to each individual BPM access. Consequently, they have two indices, BPM # and direction, where 0 is X and 1 is Y. For the BINP system, the mapping is:

Trigger: [0][0]
Ref: [0][1]
X1: [1][0]
Y1: [1][1]
X2: [2][0]
Y2: [2][1]
X3: [3][0]
Y3: [3][1]

There are static functions available that can convert from straight channel number to BPM/Dir number and back:

static int BPMNumber( int chan );  // Return the BPM number given a channel
static int DirNumber( int chan );  // Return the direction number given a channel
static int ChanNumber( int BPM, int Dir );  // Return the channel number given a BPM and Direction

In some cases, two types of the same variable are available, e.g. Posn, PosnDDC. The 'DDC' version is for the DDC and is almost always filled. The non-DDC version is for the fit is unlikely to be available at present.

The other variables can be examined within root using a TBrowser and are fairly self explanatory. The only other variable that requires some explanation is the ATFBPM array. The first index is the ATF BPM number (0-344) and the second refers to the following:

0 - x
1 - y
2 - intensity

Other Routines

Currently, only the following routines are implemented in the library:

void AnalyseMotmov( const char\* cfname, TPulse\* pulse );
TPulse\* CalibrateTripletIQPhase( char*\* files, int num_files );
TPulse\* CalibrateTripletScale( char*\* files, int num_files, double\* IQPhase, double\* IQPhaseDDC );
TPulse\* CalibrateTripletScalePrime( char*\* files, int num_files, double\* IQPhase, double\* IQPhaseDDC );
void PerformFit( int \*wf, int num_samples, int num_bits, double t0,
double omega, double gamma, double \*amp, double \*phi, double \*chi2perndf,
double \*fit_omega, double \*fit_gamma);

as time goes on, I will hopefully add more useful routines. These are mostly used in calibration.

Example Files

Attached are some of my more useful routines that show how to use the library and data. NOTE: They are currently set up to run on my machine/data. A few minor hanges may be needed!

SVDCalc.cpp - Perform the SVD to gain resolutions based on run numbers
SVDCalc_no_run.cpp - As above but based on number of events rather than run numbers
ViewWaveforms.cpp - View the raw waveform data
MeasurePhaseNoise.cpp - Measure the phase noise using power sweep data
CompareExtLine.cpp - Compare the extraction line orbit between two runs
ViewExtLineOrbit.cpp - View the extraction line orbit

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.8 Build:#814 Oct 02, 2007) - Bug/feature request - Contact Administrators