Examples Analyzing Full GLAST ROOT Trees

Prerequisites

To use analyze the full ROOT trees, you will need:

1.  ROOT set up for use to run stand-alone as an analysis tool, please see the GLAST Offline User Workbook under the ROOT menu on the red navigation bar.

2.  A copy of RootTreeAnalysis available in the RootAnalysis package and also distributed with EngineeringModel checkout package, a current copy as presented in this tutorial is available here for download: 
RootTreeAnalysis.h  RootTreeAnalysis.cxx

3.  The GLAST ROOT Offline libraries:  commonRootData, mcRootData, digiRootData, reconRootData
are required for reading the full ROOT trees.  Currently, the libraries for linux and windows are available for download at:
ftp://ftp-glast.slac.stanford.edu/glast.u05/rootlibs/

Note:  Be sure to download and use the version of the libraries that were used to create the data you are analyzing.  Due to the reorganization of the TkrRecon data, not all ROOT files are readable by all versions of the libraries.

4.  Full documentation of the GLAST ROOT data classes available at:
http://confluence.slac.stanford.edu/display/WB/mcRootData

http://confluence.slac.stanford.edu/display/WB/digiRootData

http://confluence.slac.stanford.edu/display/WB/reconRootData

5. And you need some data!  See the Finding ROOT Data Files, GLAST Offline user Workbook

Introduction

Besides the summary ntuple, four full ROOT trees are potentially available as output:  monte carlo, digitization, reconstruction, relation tables.  Analyzing the data in these files is more complex due to the more complicated GLAST-defined data structures in use to store the data.  Often it is possible to merely use the summary ntuple for simple analysis, however, if one is interested in details of an event, it may be necessary to look at the full ROOT trees.

GLAST Offline provides RootTreeAnalysis as an example ROOT macro that can be used to read Digitization, Reconstruction, and/or Monte Carlo GLAST ROOT files.  Output is a new ROOT file, named Histograms.root by default, which contains a series of user defined histograms.  User can provide individual ROOT files as input, or TChains of files for multi-file processing.

Defining histograms, ntuples and accessing those objects to fill them.

Event processing is done by calling RootTreeAnalysis::Go(Int_t numEvents);  This causes the next numEvents in the files to be processed - filling the defined histograms. 

Note:  This does not cause the histograms to be saved automatically!!  The user must call RootTreeAnalysis::WriteHist() to save the histograms.

The actual analysis is performed in a series of routines called by Go( ).  The methods that handle the digitization data are called:  DigiTkr( ), DigiCal( ), and DigiAcd( ).  Similarly, the reconstruction methods are:  ReconTkr( ), ReconCal( ).  When adding your own analysis - you may add it directly to the Go( ) method - or you may prefer to create your own new method that specifically handles the type of data you desire to access.  In addition, you may use the pre-defined histograms provided or modify/add/remove histograms.  Users define their histograms in the HistDefine methods, located in the RootTreeAnalysis.cxx file. 

What follows is a description of accessing data from four specific categories:

TKR digitization

TKR reconstruction

CAL digitization

CAL reconstruction

 

Example Usage of RootTreeAnalysis reading in single mc, digi, and/or recon ROOT files:

First get some example ROOT files, for this example - we will use the ROOT files, mc.root, digi.root, and recon.root available from:
ftp://ftp-glast.slac.stanford.edu/glast.u07/mcenery/systests/GlastRelease/v6r2p8/VerticalGamma10GeV/linux/
 

Start up ROOT  
Load the GLAST ROOT libraries:  commonRootData, mcRootData, digiRootData, reconRootData

Note:  It is recommended that libcommonRootData.so be loaded first, since it is required by the other GLAST ROOT libraries, otherwise you will receive a warning message about undefined classes.

Note:  This example uses the Linux naming of the GLAST ROOT libraries:  libcommonRootData.so, libmcRootData.so..etc, rather than the Windows convention of commonRootData.dll.

Load the RootTreeAnalysis macro and create a new instance of it that includes the files you wish to analyze.
Loop over 500 events.
Save the Histograms to a file.

Note:  By default this file is named Histograms.root

Start up a TBrowser
View the TKRSTRIPSLYR5 histogram using the TBrowser window.

 

Example Usage of RootTreeAnalysis reading in a TChain of mc, digi, and/or recon ROOT files:

Start up ROOT  
Load the GLAST ROOT libraries:  commonRootData, mcRootData, digiRootData, reconRootData

Note:  It is recommended that libcommonRootData.so be loaded first, since it is required by the other GLAST ROOT libraries, otherwise you will receive a warning message about undefined classes.

Note:  This example uses the Linux naming of the GLAST ROOT libraries:  libcommonRootData.so, libmcRootData.so..etc, rather than the Windows convention of commonRootData.dll.

 

Create a TChain of ROOT files for each type of ROOT file; one TChain for mc, another for digi, and a separate one for recon. 

Note:  When creating the TChain, you pass in as a parameter the name of the TTree, in this case it will be one of the following:  "Mc", "Digi", or "Recon".

Add the desired files to each TChain.

Note:  When calling TChain::Add, one can use wildcards to add more than one ROOT file to the chain.

Load the RootTreeAnalysis macro and create a new instance of it that includes the chains of files you wish to analyze.
Loop over six events.

Save the Histograms to a file.

Note:  By default this file is named Histograms.root

 

Start up a TBrowser.

View some histograms using the TBrowser window.

   

 

References:

Root User Guide

Root Forum and RootTalk available from the ROOT home page.