This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
asc:tutorials:2014october28 [2014/10/28 15:55] asc [Lesson 2: Using pyROOT to read xAOD] |
asc:tutorials:2014october28 [2014/10/28 20:42] asc [Lesson 3: C++/ROOT program to read xAOD] |
||
---|---|---|---|
Line 95: | Line 95: | ||
__Method 1. If you are at ANL, copy it__: | __Method 1. If you are at ANL, copy it__: | ||
<code bash> | <code bash> | ||
- | cp / | + | cp / |
- | AOD.01482225._000140.pool.root | + | |
</ | </ | ||
Line 104: | Line 103: | ||
localSetupFAX --rootVersion=current-SL6 | localSetupFAX --rootVersion=current-SL6 | ||
voms-proxy-init -voms atlas | voms-proxy-init -voms atlas | ||
- | xrdcp $STORAGEPREFIX/ | + | xrdcp $STORAGEPREFIX/ |
</ | </ | ||
Line 120: | Line 119: | ||
setMeUpData anl-oct2014 mydata | setMeUpData anl-oct2014 mydata | ||
</ | </ | ||
- | The file will appear in " | + | The file will appear in " |
Line 157: | Line 156: | ||
- | <code python | + | <code python xAODPythonMacro.py> |
# | # | ||
Line 196: | Line 195: | ||
Using this code, one can fill histograms. But the code runs slow. Below we will show how to use C++/ROOT compiled code to | Using this code, one can fill histograms. But the code runs slow. Below we will show how to use C++/ROOT compiled code to | ||
run over this file. | run over this file. | ||
+ | |||
+ | How do you know about methods of " | ||
+ | |||
+ | <code python> | ||
+ | print dir(el.trackParticle()) | ||
+ | </ | ||
How will you find xAOD variables without using ROOT TBrowser? Try this code: | How will you find xAOD variables without using ROOT TBrowser? Try this code: | ||
Line 204: | Line 209: | ||
</ | </ | ||
- | You will see a table with the names of the variables. | ||
- | Now you can fill a histogram in this Python code: | + | <note warning> |
+ | To run the next example, please start from a new terminal, run rcSetup. This is needed to avoid a conflict with asetup</ | ||
- | You should create a histogram before the event loop: | + | |
+ | Now you can fill a histogram in this Python code. You should create a histogram before the event loop: | ||
<code python> | <code python> | ||
from ROOT import * | from ROOT import * | ||
- | h1=TH1D(" | + | h1=TH1D(" |
</ | </ | ||
- | Then fill it in the event loop as h1.Fill( el.trackParticle().eta() ). | + | Then fill it in the event loop as h1.Fill( el.trackParticle().eta() ). Then we will write this histogram |
- | + | ||
- | Then we will write this histogram | + | |
- | at the end (after f.Close()) | + | |
<code python> | <code python> | ||
Line 225: | Line 228: | ||
hfile.Close() | hfile.Close() | ||
</ | </ | ||
- | ====== Lesson 3: Analysis program to read xAOD ====== | ||
- | Now we will create a C++/ROOT analysis program and run over this input xAOD file. Do not forget to run "kinit [email protected]" | + | Here the code that write a ROOT histogram: |
+ | |||
+ | <code python xAODPythonMacro_histo.py> | ||
+ | # | ||
+ | |||
+ | import ROOT | ||
+ | ROOT.gROOT.Macro( ' | ||
+ | |||
+ | ROOT.xAOD.Init() # Initialize the xAOD infrastructure | ||
+ | |||
+ | fileName=" | ||
+ | treeName = " | ||
+ | |||
+ | f = ROOT.TFile.Open(fileName) | ||
+ | t = ROOT.xAOD.MakeTransientTree( f, treeName) # Make the " | ||
+ | |||
+ | from ROOT import * | ||
+ | h1=TH1D(" | ||
+ | |||
+ | # Print some information: | ||
+ | print( " | ||
+ | for entry in xrange( t.GetEntries() ): | ||
+ | | ||
+ | | ||
+ | | ||
+ | for el in t.ElectronCollection: | ||
+ | h1.Fill( el.trackParticle().eta() ) | ||
+ | pass # end for loop over electron collection | ||
+ | |||
+ | pass # end loop over entries | ||
+ | |||
+ | hfile=TFile(" | ||
+ | h1.Write() | ||
+ | f.Close() | ||
+ | hfile.Close() | ||
+ | </ | ||
+ | |||
+ | Now open the root file and look at the histogram. | ||
+ | ====== Lesson 3: C++/ROOT program to read xAOD ====== | ||
+ | |||
+ | Now we will create a C++/ROOT analysis program and run over this input xAOD file. | ||
Use the same setup file as above. | Use the same setup file as above. | ||
Line 251: | Line 293: | ||
python Make_input < | python Make_input < | ||
</ | </ | ||
+ | |||
+ | In case if you need xAOD data, do this: | ||
+ | |||
+ | <code bash> | ||
+ | mkdir data | ||
+ | cd data | ||
+ | localSetupFAX --rootVersion=current-SL6 | ||
+ | voms-proxy-init -voms atlas | ||
+ | xrdcp $STORAGEPREFIX/ | ||
+ | xrdcp $STORAGEPREFIX/ | ||
+ | xrdcp $STORAGEPREFIX/ | ||
+ | </ | ||
+ | |||
+ | and run: | ||
+ | |||
+ | < | ||
+ | cd .. | ||
+ | python Make_input data | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
Now the input file is ready and we run the example as: | Now the input file is ready and we run the example as: | ||