This shows you the differences between two versions of the page.
snowmass2013:analyse_d3 [2013/06/01 02:51] asc [How to analyze in Java] |
snowmass2013:analyse_d3 [2014/04/24 01:51] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[snowmass2013: | ||
- | |||
- | ==== How to analyze in C++ ==== | ||
- | |||
- | This example shows how to run a program over all files in a certain directory, fill histograms (pT and jet mass) and | ||
- | save histograms in an output ROOT file. | ||
- | |||
- | Look at the workbook of Delphes3 [[https:// | ||
- | To get started, install Delphes. You should see the library " | ||
- | |||
- | <code C> | ||
- | gSystem-> | ||
- | TFile:: | ||
- | Delphes-> | ||
- | TBrowser browser; | ||
- | </ | ||
- | |||
- | |||
- | ==== Advanced C++ example | ||
- | |||
- | This assumes that Delphes3 is already installed. You have the directory " | ||
- | |||
- | Get the analysis file: {{: | ||
- | |||
- | <code bash> | ||
- | tar -zvxf antup.tgz | ||
- | cd antup | ||
- | </ | ||
- | |||
- | So you will see 2 directories: | ||
- | <code bash> | ||
- | delphes3 | ||
- | antup | ||
- | </ | ||
- | |||
- | |||
- | Now go to the directory " | ||
- | |||
- | <code bash> | ||
- | ln -s ../ | ||
- | </ | ||
- | |||
- | In my case, it will look as: | ||
- | |||
- | <code bash> | ||
- | analysis.h | ||
- | A_RUN_TEST | ||
- | data.in | ||
- | delphes -> ../ | ||
- | main.cxx | ||
- | Make_input | ||
- | out | ||
- | </ | ||
- | |||
- | Check that you see the shared Delphes3 file | ||
- | |||
- | <code bash> | ||
- | ls -l delphes/*so | ||
- | </ | ||
- | |||
- | You should see " | ||
- | |||
- | |||
- | The main file which fills histograms is " | ||
- | |||
- | To run the code, run " | ||
- | But before you do this, you will need to set " | ||
- | |||
- | ==== How to analyze in PyROOT ==== | ||
- | |||
- | If ROOT was compiled using " | ||
- | |||
- | <code python test.py> | ||
- | # | ||
- | # Based on P.Onyisi example | ||
- | import sys, | ||
- | if len(sys.argv)< | ||
- | print " | ||
- | print " | ||
- | sys.exit() | ||
- | from ROOT import * | ||
- | TH1D.SetDefaultSumw2() | ||
- | gSystem.Load(' | ||
- | |||
- | f=TFile(sys.argv[1]) | ||
- | t=f.Delphes # extract the tree | ||
- | h=TH1D(' | ||
- | c=TCanvas() # build a canvas | ||
- | |||
- | n=0 | ||
- | for e in t: # loop over all events | ||
- | if n%100==0: print " | ||
- | n=n+1 | ||
- | for electron in e.Electron: # loop over all electrons | ||
- | | ||
- | h.Draw() | ||
- | c1.Print(' | ||
- | if (raw_input(" | ||
- | c1.Close(); sys.exit(1); | ||
- | |||
- | </ | ||
- | |||
- | Run this code as: | ||
- | < | ||
- | python test.py file.root | ||
- | </ | ||
- | |||
- | ====How to analyze in Java==== | ||
- | |||
- | MC truth information and most of ROOT files with Delphes outputs | ||
- | are stored in the PROMC file format which can be analyzed on any platform. | ||
- | Read this [[snowmass2013: | ||
- | |||
- | --- // | ||
- | |||