Changes between Initial Version and Version 1 of UserManual


Ignore:
Timestamp:
Nov 9, 2010, 11:13:12 AM (14 years ago)
Author:
cp3-support
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UserManual

    v1 v1  
     1== Introductory remarks ==
     2
     3!ExRootAnalysis is a package designed to simplify ROOT tree production and
     4analysis. The purpose of this tutorial is to present current functionality of
     5this software.
     6
     7
     8== Quick start with !ExRootAnalysis ==
     9
     10Make sure that ROOT is installed and ROOTSYS, PATH, LD_LIBRARY_PATH,
     11DYLD_LIBRARY_PATH are configured correctly.
     12
     13Command to unpack the source code:
     14{{{
     15   tar -zxf ExRootAnalysis.tar.gz
     16}}}
     17Commands to create shared library for interactive ROOT session:
     18{{{
     19   cd ExRootAnalysis
     20
     21   make
     22}}}
     23
     24
     25== Simple analysis using TTree::Draw ==
     26
     27
     28Now we can start ROOT and look at the data stored in the ROOT tree.
     29
     30Start ROOT and load shared library:
     31{{{
     32   root
     33   gSystem->Load("lib/libExRootAnalysis.so");
     34}}}
     35Open ROOT tree file and do some basic analysis using Draw or TBrowser:
     36{{{
     37   TFile::Open("pgs_events.root");
     38   LHCO->Draw("Electron.PT");
     39   TBrowser browser;
     40}}}
     41Note 1: LHCO - tree name, it can be learnt e.g. from TBrowser
     42
     43Note 2: Electron - branch name; PT - variable (leaf) of this branch
     44
     45Complete description of all branches can be found in
     46{{{
     47   ExRootAnalysis/doc/RootTreeDescription.html
     48}}}
     49
     50
     51== Macro-based analysis ==
     52
     53
     54Analysis macro consists of histogram booking, event loop (histogram filling),
     55histogram display
     56
     57Basic analysis macro:
     58{{{
     59{
     60  // Load shared library
     61  gSystem->Load("lib/libExRootAnalysis.so");
     62  gSystem->Load("libPhysics");
     63
     64  // Create chain of root trees
     65  TChain chain("LHCO");
     66  chain.Add("pgs_events.root");
     67 
     68  // Create object of class ExRootTreeReader
     69  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
     70  Long64_t numberOfEntries = treeReader->GetEntries();
     71 
     72  // Get pointers to branches used in this analysis
     73  TClonesArray *branchJet = treeReader->UseBranch("Jet");
     74  TClonesArray *branchElectron = treeReader->UseBranch("Electron");
     75 
     76  // Book histograms
     77  TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0);
     78  TH1 *histMass = new TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0);
     79
     80  // Loop over all events
     81  for(Int_t entry = 0; entry < numberOfEntries; ++entry) {
     82
     83    // Load selected branches with data from specified event
     84    treeReader->ReadEntry(entry);
     85 
     86    // If event contains at least 1 jet
     87    if(branchJet->GetEntries() > 0) {
     88
     89      // Take first jet
     90      TRootJet *jet = (TRootJet*) branchJet->At(0);
     91     
     92      // Plot jet transverse momentum
     93      histJetPT->Fill(jet->PT);
     94     
     95      // Print jet transverse momentum
     96      cout << jet->PT << endl;
     97    }
     98
     99    TRootElectron *elec1, *elec2;
     100    TLorentzVector vec1, vec2;
     101
     102    // If event contains at least 2 electrons
     103    if(branchElectron->GetEntries() > 1) {
     104
     105      // Take first two electrons
     106      elec1 = (TRootElectron *) branchElectron->At(0);
     107      elec2 = (TRootElectron *) branchElectron->At(1);
     108
     109      // Create two 4-vectors for the electrons
     110      vec1.SetPtEtaPhiM(elec1->PT, elec1->Eta, elec1->Phi, 0.0);
     111      vec2.SetPtEtaPhiM(elec2->PT, elec2->Eta, elec2->Phi, 0.0);
     112
     113      // Plot their invariant mass
     114      histMass->Fill((vec1 + vec2).M());
     115    }
     116  }
     117
     118  // Show resulting histograms
     119  histJetPT->Draw();
     120  histMass->Draw();
     121}
     122}}}
     123
     124
     125== More advanced macro-based analysis ==
     126
     127!ExRootAnalysis/test contains macro Example.C using class !ExRootTreeReader to
     128access data and class !ExRootResult to manage histograms booking and output
     129
     130Here are commands to run this macro:
     131{{{
     132   cd ExRootAnalysis/test
     133   $EDITOR test.list
     134   root
     135   gSystem->Load("../lib/libExRootAnalysis.so");
     136   .X Example.C("test.list");
     137}}}
     138Note: file test.list should contain list of root files that you would like to
     139analyse (one root file per line)