Using ExRootAnalysis for TTree Analysis

 

Introduction

ExRootAnalysis is a user-extendable package to produce a general purpose Root file with all the objects needed for physical analysis. In the default case, i. e., without user extension, this includes

For details on how to extend the list of objects available, see the CERN tutorial here.

Each of the object types known to ExRootAnalysis may appear in multiple forms. For example, for muons, there are

For all the details on what is available, refer to the full Root tree description found here.

 

The ExRootAnalysis Reader

To analyze the Root ntuple (more properly, the Root TTree), it is convenient to use the ExRootAnalysisReader package that provides:

Note that all of this is optional. The output from ExRootAnalysis jobs you have already run is a regular Root TTree, viewable with the standard TBrowser and can be analyzed using the MakeClass facility. In what follows below, we will mostly be using the class dictionary.

While we will do the exercises in the cms uaf environment, it is important to note that everything can just as well be done in a stand-alone mode on any machine where Root has been installed.

 

Setting Up The CMS Environment And Building The ExRootAnalysisReader Library

If you haven't already setup the CMS UAF environment, then do it now as follows:
  source /afs/fnal.gov/files/code/cms/setup/cshrc uaf
  setenv SCRAM_ARCH slc3_ia32_gcc323
  setenv CVSROOT :pserver:anonymous@cdcvs.fnal.gov:/cvs/lpc
  cvs login
    (password is lpc)

All of this has already been discussed in the Getting Started With SCRAM note so we don't need to dwell on it again here.

To build the libraries:

  cd some-work-directory
  scram project ORCA ORCA_8_7_3
  cd ORCA_8_7_3/src
  eval ` scram runtime -csh`
  rehash
  cmscvsroot ORCA
  cvs co -r Tutorial_872 Examples/ExRootAnalysis
  cvs co -r Tutorial_872 Examples/ExRootAnalysisReader
  cd Examples/ExRootAnalysisReader
  scram b shared
  eval `scram runtime -csh`
  rehash

 

Note that we select the CVS tag Tutorial_872 even though we are using ORCA release 8_7_3. This is not a typo.

There will be a substantial flurry of activity when you issue the scram b shared command and, when the smoke settles, you will have built a shared library named libExRootAnalysisReader.so. We will use that library in the Root analysis session to follow. First, there are some bookkeeping details to attend to.

 

Preparing And Running Some Examples

At this point, you need to make a small tactical decision. Recall that you have previously generated and processed some events of your own. Because of time constraints, we suggested you process about 100 events - 10 events in each of 10 processes. Your choice now is to analyze these same events, just to convince yourself you have done "good things" or to analyze a much larger sample of events that have been generated previously. If you choose to analyze the large samples, the next few paragraphs do not apply and you should skip down to here. Otherwise continue as follows. For our purposes here, we choose to analyze the bigger samples.

Among the things that appeared in your newtutorial directory after you checked out the starting tutorial kit was a file named gather.sh. Move that file into your output data area and then go there with

 

  cp $TUTORIAL/gather.sh $PNFS_PATH
cd $PNFS_PATH

 

Depending on which set of physics channels you chose to generate events, you should find subdirectories with names like

there. Assuming you chose the h300eemm channel (among others), issue the commands

 

  ./gather.sh h300eemm
cd h300eemm/ExRootanalysis
ls

 

You should find all the*.root files from the h300eemm_exrootdigis_* jobs you ran earlier gathered together in this directory. If you chose another physics channel, the command sequence is

 

  ./gather.sh <channel-name>
cd <channel-name>/ExRootanalysis
ls

 

Please note that the gather.sh script assumes you submitted your production jobs to the batch system requesting 10 processes with process numbers starting at 1000. If you chose a different number of processes or a different starting process number, you will need to edit the script accordingly.

Start with the very straightforward task of plotting the reconstructed track pt. For this, we use the Root script file pl_pttr.C. Examining that script reveals that it begins by declaring a TChain object, which is a logical collection of TTree objects which, in turn, may be distributed over multiple files. In the version of the pl_pttr.C that you got from cvs, there is only one file, taken from a run that Hans Wenzel did earlier and you may procede with it if you wish. On the other hand, you may prefer to analyze the data you generated yourself earlier in this session. In that case, you need to edit the line

 

  chain.Add("/uscms_data/d1/wenzel/.../ExRootanalysis/digis_h300eemm_1001.root");

to say

  chain.Add("/uscms_data/d1/<$USER>/Tutorial/data/h300eemm/ExRootanalysis/*.root");

 

The use of a "wild card" file specification here explains why it was convenient to use the gather.sh script. It moves all the needed Root files into a single directory which allows the use of a wild card. Otherwise, you would have had to add the individual files to the TChain one-by-one.

All of this applies to many of the other scripts in $ANALYSIS so you will need to make the same choice with each of them as well.

If you choose to run the analysis examples on the files that Hans has already prepared, there is no need to bother with the gather.sh script at all. In either case, procede as follows:

 cd $ANALYSIS
root.exe -l
gSystem->Load("libExRootAnalysisReader");
.x pl_pttr.C
.q

sequence of commands makes a pass over the defined chain of TTree objects, uses the code in the ExRootAnalysisReader library we built to fill some histograms and, finally, writes them out into a Root file named a1.root. We can then examine those histograms in a separate Root session such as

 root.exe -l a1.root
ntr->Draw();
pttr->Draw();
.q

where we plotted the number of tracks and their pt. Those plots should look like the two below.


and


For something a bit more interesting, we can use these zprime700_ee data to "discover" the Z'(700). To do that,

 root.exe -l
gSystem->Load("libExRootAnalysisReader");
gSystem->Load("libPhysics");
.x plzpee_invmass.C
.q

In the same way as before, this set of commands provokes a pass over the ensemble of output files, computes the e+e- invariant mass, histograms it and writes that histogram out in a file named aee.root. To examine that histogram,

  root.exe -l aee.root
mee->Draw();
.q

The resulting mass plot should look like:


Of course, we could just as well have done this with either the zprime700_mumu sample or the zprime700_jj sample. Had we used the zprime700_mumu channel, for instance, the resulting mass plot should look like:


Finally, for something even more interesting, let's "discover" the H(300) via its decay into two Z0's. (Eat your heart out, CDF and D0!)

 root.exe -l
gSystem->Load("libExRootAnalysisReader");
gSystem->Load("libPhysics");
.x pl_invmass.C
.q

This set of commands provokes a pass over the ensemble of h300eemm output files, computes several invariant mass combinations, histograms them and writes those histograms out to a file named ah.root. To examine those histograms,

 root.exe -l ah.root
mee->Draw();
mmumu->Draw();
mhiggs->Draw();
.q

These three histograms should look like:


and


and, finally,


Lastly, sit patiently by the telephone and wait for a call from Stockholm.


Last updated: July 13, 2005.
This document is maintained by Hans Wenzel (wenzel@fnal.gov) and John Marraffino (marafino@fnal.gov)