bfemApp
Introduction

Obtaining the code

Setup input parameters 
Number of Events 
Bad TKR strips 
Simulated data
I/O Files
No GUI

Running bfemApp
UserAlg

Output
Root ntuple
Root Recon Tree File

RootAnalysis

BFEM Analysis Tools

Introduction

Similar in purpose to pdrApp, bfemApp is a checkout package and application for running the reconstruction algorithms on balloon data stored in Root files.  The current release version of bfemApp is v1r10.  It runs on both Linux and Windows.

It should be noted that the same reconstruction routines are used for both PDR runs and BFEM runs.  This has been done, to insure that we are all using the same reconstruction algorithms for both full-flight PDR simulations and BFEM analysis.

Obtaining the code

The bfemApp package is available from the SLAC CVS repository.  There are 3 ways to obtain bfemApp and start using it:

  1. Use the linux version installed on the SLAC NFS space.
  2. Use the Windows versions installed on the UW Glast Windows server.
  3. Download bfemApp and all associated packages directly from CVS.

Using bfemApp on SLAC NFS

NOTE these directions have changed!!!! as of December 7, 2001

First of all - you must have a SLAC UNIX account.

  1. Be sure you have CMT and CVS setup by :
    Source the group.cshrc file located in /afs/slac/g/glast/ground/scripts/group.cshrc
    The easiest thing to do is to add this to your own .cshrc file.

  2. The local installation of bfemApp is located in
    /afs/slac.stanford.edu/g/glast/ground/releases

  3. Create a directory called bfemApp in your local space.
    And copy the *.txt files from /afs/slac.stanford.edu/g/glast/ground/releases/bfemApp_v1r10/bfemApp/v1r10/src/
    into your new local directory.

  4. Modify the jobOptions.txt file.

  5. Setup an environment variable called JOBOPTIONS that points to the directory containing your copy of the jobOptions.txt file, for example:
    setenv JOBOPTIONS $HOME/bfemApp/jobOptions.txt

  6. Now...to actually run bfemApp, there is script called bfemApp_v1r10.csh that will run the program - and uses the JOBOPTIONS environment variable to determine where your input files are located.  At your command line do:
    /afs/slac.stanford.edu/g/glast/ground/releases/bfemApp_v1r10.csh

Using bfemApp on the UW Glast Windows server

bfemApp is also currently installed on the UW Glast Windows server.
The code is main bfemApp package is available in the D:\common\bfemApp_v1r10 directory, you must add this path to your VCMT "CMT Setup" box.  In addition, please be sure that the following is also in your CMT path in the "CMT Setup" box:
D:\ground\gaudi_v7

You will need to checkout the bfemApp package into your own user space.  Using VCMT, you can do this by:
Add your own directory (D:/users/username) to the CMTPATH
Click the checkout button
under package name enter "bfemApp"
Under "cvs revision" enter "v1r10"
in directory, choose your own directory under d:/users/username/
leave the "cmt version" box blank
click the Ok button, and bfemApp will be downloaded from the CVS repository

Now to compile the code:
Highlight the bfemApp package name in the package list
Click the setup button
In the drop-down Project list, choose bfemApp-app
Choose "Release"
Click the make button

Next you have to modify the jobOptions.txt file as appropriate for the type of run you desire to process.  And finally, when running bfemApp on the UW Windows Terminal server - please do so from the command line - using the WinRun.bat file located in the bfemApp cmt directory.

Installing and compiling bfemApp yourself

It is a checkout package, meaning it can be used to obtain all of the related packages that bfemApp requires.  Please see the directions outlined on the GLAST software how-to page

Note you must use the bash shell to run bfemApp on linux!!!  
When you are ready to run bfemApp, do the following:

  1. Type:  
    bash

  2. Type:
    source setup.sh

  3. Enter your local bfemApp/v1r10/i386_linux22 directory

  4. Type:
    bfemApp.exe

Setup input parameters

Just like pdrApp (and all programs that use Gaudi), there is a jobOptions file that determines the input parameters for a partciular run (job).  The jobOptions file that comes with the bfemApp distribution contains the parameters necessary to run bfemApp.  The jobOptions file is located in the bfemApp src directory.  Here is an example of how this file may look.  Note that there are 2 lines:
#include "$BFEMAPPROOT/src/basic_tkrmods.txt"
#include "$BFEMAPPROOT/src/display.txt"

These lines, include the 2 named files, so that all of the parameters available in these 2 input files, will be used for bfemApp.  The file, basic_tkrmods.txt, sets up all of the necessary parameters for bfemApp to run, including calling the CAL recon twice once before and once after TkrRecon.  Another file, called basic.txt contains the same basic parameters - except that CalRecon is called only after TkrRecon.  So if for some reason, you do not wish to have CalRecon called twice, replace basic_tkrmods.txt with basic.txt.  The file, display.txt, sets up the GUI - so if you do not desire to run with the event display, comment this line out.

The jobOptions.txt file itself, is the file where users provide their own parameters - or override parameters already set up in the basic_tkrmods.txt and display.txt files.  Most parameters will remain unchanged, however, there are some that users will want to modify:
Bad strip processing is NOT the default.  If one desires to process bad strips, one must remove the "//" preceding one of the following lines:
//TkrBadStripsSvc.badStripsFile = "$(TKRRECONROOT)/src/test/gsfc_02-Jul-2001_v2.txt"; //TkrBadStripsSvc.badStripsFile = "$(TKRRECONROOT)/src/test/badchannellist_nsbf53_10sigma_recon.dat"; //TkrBadStripsSvc.badStripsFile = "$(TKRRECONROOT)/src/test/badchannellist_nsbf54_10sigma_recon.dat"; //TkrBadStripsSvc.badStripsFile = "$(TKRRECONROOT)/src/test/badchannellist_nsbf55_10sigma_recon.dat";
One should choose the bad strip file that is most appropriate for their particular data.

Simulated versus Flight Data
There are some subtle differences in running bfemApp with ROOT files generated from IRF (simulated) data.  Note that the Calorimeter ADC values do not include pedestals - as the ROOTWriter is unaware of CAL calibration data for the BFEM.  As was done for the BTEM - when processing simulated data through bfemApp, a different set of calibration files should be used.  In the CalRecon package, there is a calibration directory that contains files with names of the form *_sim.txt. fC_to_MeV_sim.txt, intlin_sim.txt, mu_slopes_sim.txt, pedestal_sim.txt.  So if processing simulated data, add the following lines to your jobOptions.txt file:  (Or modify basic_tkr_mods.txt if this file is included in your jobOptions file)

CalRecLogsAlg.PedFile = "$(CALRECONROOT)/calibration/pedstal_sim.txt";
CalRecLogsAlg.GainFile = "$(CALRECONROOT)/calibration/fC_to_MeV_sim.txt";
CalRecLogsAlg.IntlinFile = "$(CALRECONROOT)/calibration/intlin_sim.txt";
CalRecLogsAlg.SlopeFile = "$(CALRECONROOT)/calibration/mu_slopes_sim.txt";

Next add the following:
CalRecLogsAlg.MuPeaksFile = "";
CalRecLogsAlg.ChargePeaksFile = "";
This will cause these files to be ignored.

To determine the number of events to process:
ApplicationMgr.EvtMax = 10;

Input and Output files:
// Input raw/digi ROOT file
digiRootReaderAlg.rawRootFile = "$(GLASTROOTIOROOT)/src/test/bfem_muons_5_gev_normal-raw.root"; 
// Output Recon Tree ROOT file
reconRootWriterAlg.reconRootFile = "$(BFEMAPPROOT)/bfem_muons_5_gev_normal-rec.root"; 
// Output Summary Ntuple ROOT file
NTupleSvc.Output = { "BFEM DATAFILE='$(BFEMAPPROOT)/bfem-ntuple.root' OPT='NEW'"};

Reducing the amount of text output to the screen.

This is handled by one parameter in the jobOptions file.  This is common to ALL applications that run using Gaudi.  Please see the pdrApp FAQ for more information.

Running bfemApp with no GUI - for batch processing

To run a batch job, requires shutting off the GUI.  To do this, one must modify the jobOptions file.  The default jobOptions file, uses the GUI.  To prevent the GUI, comment out the following line in the jobOptions.txt file:
#include "$BFEMAPPROOT/src/display.txt"

Running bfemApp

To run the bfemApp application, follow the directions provided on the GLAST software how-to page.

Also, note that as with all applications, it is possible to run bfemApp from the command line on Windows as well.  To do so:

  1. Start a Command (DOS) window.

  2. Enter the bfemApp cmt directory.

  3. Run WinRun.bat  - this will automatically startup bfemApp using the Release version of the code - and will use the bfemApp/v1r10/src/jobOptions.txt file for the input parameters.

UserAlg

This is an algorithm that is available with bfemApp.  It is located in the bfemApp/src directory.  Users may modify this algorithm and use it to create their own ntuple elements.  As a Gaudi algorithm, this routine has full access to all data available on the Gaudi Transient Data Store (TDS).

The main routine users will modify is the UserAlg::execute method.  This function is called at the end of each event.

Special Features:
The default UserAlg, is setup to automatically pause the event display on events specified in the jobOptions.txt file. Here is an excerpt from the default jobOptions.txt file: 

ApplicationMgr.TopAlg += { "UserAlg" };
UserAlg.tupleName = "BFEM";
// User specifed event List of the form "runNum_eventId"
// The GUI will be paused for those events in the event list
UserAlg.eventList = { "0_0", "0_1", "0_5", "0_6" };

The parameter, UserAlg.eventList, is a list of event identifiers that you want to look at more closely in the bfemApp event display.  The format for specifying the event id is:
runNumber_eventId
Where runNumber and eventId are those values specified in the input raw/digi ROOT file.

Output

The Root output from bfemApp consists of 2 files:
1.) ROOT ntuple - containing the ntuple elements that were in use during the AO.
2.) ROOT Recon Tree file - containing more detailed reconstruction data, as was available during the 1999-2000 SLAC Test Beam.

ROOT Summary Ntuple

Contents of the ROOT ntuple

Here is a description of the current contents of the ROOT Ntuple.

Reading the ROOT ntuple within ROOT

Here is a simple example:  An introduction to accessing the ROOT ntuple.

A new Root macro has been created called NtupleAnalysis.  This macro is designed so that users can customize the macro to apply their own cuts on the ntuple data.

Running merit on the ROOT ntuple

merit is a program that we used during the AO to analyze the ASCII ntuples - producing text output that summarizes the result of applying standard cuts on the output data, as well as calculating a PSF and the effective area for the run.

For an example of how to run merit, please see the PDR FAQ.

NOTE:  merit applies standard cuts on the data that were optimized for the full flight geometry.  Most likely, these same cuts will not produce optimal results when using balloon data.

ROOT Recon Tree File

This ROOT file has the same structure as was used for the 1999-2000 SLAC Test Beam, except the addition of storing the run number.  The structure is determined by the reconRootData package, which contains the ROOT classes used to fill the Recon ROOT file.