User Tools

Site Tools


asc:tutorials:2014october28

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
asc:tutorials:2014october28 [2014/10/28 12:49]
asc created
asc:tutorials:2014october28 [2014/10/29 13:53]
asc old revision restored (2014/10/28 16:33)
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 /data/nfs/chakanau/tutorial_xAOD_long/valid2.117050.PowhegPythia_P2011C_ttbar.digit.AOD.e2657_s1933_s1964_r5534_tid01482225_00/AOD.01482225._000140.pool.root.1 +cp /data/nfs/chakanau/tutorial_xAOD_long/valid2.117050.PowhegPythia_P2011C_ttbar.digit.AOD.e2657_s1933_s1964_r5534_tid01482225_00/AOD.01482225._000140.pool.root.1  AOD.01482225._000140.pool.root
-AOD.01482225._000140.pool.root .+
 </code> </code>
  
Line 104: Line 103:
 localSetupFAX --rootVersion=current-SL6 localSetupFAX --rootVersion=current-SL6
 voms-proxy-init -voms atlas voms-proxy-init -voms atlas
-xrdcp $STORAGEPREFIX/atlas/rucio/valid2:AOD.01482225._000140.pool.root.1 AOD.01482225._000140.pool.root.1+xrdcp $STORAGEPREFIX/atlas/rucio/valid2:AOD.01482225._000140.pool.root.1 AOD.01482225._000140.pool.root
 </code> </code>
  
Line 120: Line 119:
 setMeUpData anl-oct2014 mydata setMeUpData anl-oct2014 mydata
 </code> </code>
-The file will appear in "mydata/tutorial/anl-oct2014/datase/" directory+The file will appear in "mydata/tutorial/anl-oct2014/database/" directory
  
  
Line 157: Line 156:
  
  
-<code python "xAODPythonMacro.py>+<code python xAODPythonMacro.py>
 #!/usr/bin/env python #!/usr/bin/env python
  
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 "el.trackParticle()"? You can print methods of this object as:
 +
 +<code python>
 +print dir(el.trackParticle())
 +</code>
  
 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:
 </code> </code>
  
-You will see a table with the names of the variables. 
  
-====== Lesson 3: Analysis program to read xAOD ======+<note warning> 
 +To run the next example, please start from a new terminal, run rcSetup. This is needed to avoid a conflict with asetup</note>
  
-Now we will create a C++/ROOT analysis program and run over this input xAOD file. Do not forget to run "kinit [email protected]".+ 
 +Now you can fill a histogram in this Python code. You should create a histogram before the event loop: 
 + 
 +<code python> 
 +from ROOT import * 
 +h1=TH1D("eta","eta",20,-4,4) 
 +</code> 
 + 
 +Then fill it in the event loop as  h1.Fill( el.trackParticle().eta() ). Then we will write this histogram in  a file as: 
 + 
 +<code python> 
 +hfile=TFile("test.root","RECREATE","ANL tutorial"
 +h1.Write() 
 +hfile.Close() 
 +</code> 
 + 
 +Here the code that write a ROOT histogram: 
 + 
 +<code python xAODPythonMacro_histo.py> 
 +#!/usr/bin/env python 
 + 
 +import ROOT 
 +ROOT.gROOT.Macro( '$ROOTCOREDIR/scripts/load_packages.C'
 + 
 +ROOT.xAOD.Init() # Initialize the xAOD infrastructure 
 + 
 +fileName="AOD.01482225._000140.pool.root" # Set up the input files 
 +treeName = "CollectionTree" # default when making transient tree anyway 
 + 
 +f = ROOT.TFile.Open(fileName) 
 +t = ROOT.xAOD.MakeTransientTree( f, treeName) # Make the "transient tree" 
 + 
 +from ROOT import * 
 +h1=TH1D("eta","eta",20, -4,4) 
 + 
 +# Print some information: 
 +print( "Number of input events: %s" % t.GetEntries() ) 
 +for entry in xrange( t.GetEntries() ): 
 +   t.GetEntry( entry ) 
 +   print( "Processing run #%i, event #%i" % ( t.EventInfo.runNumber(), t.EventInfo.eventNumber() ) ) 
 +   print( "Number of electrons: %i" % len( t.ElectronCollection ) ) 
 +   for el in t.ElectronCollection:  # loop over electron collection 
 +      h1.Fill( el.trackParticle().eta() ) 
 +      pass # end for loop over electron collection 
 + 
 +   pass # end loop over entries 
 + 
 +hfile=TFile("test.root","RECREATE","ANL tutorial"
 +h1.Write() 
 +f.Close() 
 +hfile.Close() 
 +</code> 
 + 
 +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 232: Line 293:
 python Make_input <directory with xAOD files> python Make_input <directory with xAOD files>
 </code> </code>
 +
 +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/atlas/rucio/valid2:AOD.01482225._000140.pool.root.1 .
 +xrdcp $STORAGEPREFIX/atlas/rucio/valid2:AOD.01482225._000141.pool.root.1 .
 +xrdcp $STORAGEPREFIX/atlas/rucio/valid2:AOD.01482225._000142.pool.root.1 .
 +</code>
 +
 +and run:
 +
 +<code>
 +cd ..
 +python Make_input data
 +</code>
 +Now inputdata.txt should pick up your xAOD files.
 +
 +
 Now the input file is ready and we run the example as: Now the input file is ready and we run the example as:
  
Line 250: Line 333:
 To do this we will need a number of changes: To do this we will need a number of changes:
  
-1) We need to link several ATLAS packages. +1) We need to link several ATLAS packages (it's done already, just look what is inside of the package prepared for this lesson)
  
 <code> <code>
Line 258: Line 341:
 in "cmt/Makefile.RootCore". We linked more packaged than needed to illustrate what can be linked.  Use "rc version" to check their versions. in "cmt/Makefile.RootCore". We linked more packaged than needed to illustrate what can be linked.  Use "rc version" to check their versions.
  
-2) Then we need to modify 2 places to put histograms +2) Then we need to modify 2 places to put histograms (it's done already in the example shown below)
  
 <code python> <code python>
Line 310: Line 393:
 TBrowser a TBrowser a
 </code> </code>
-and look at the histograms of jet and muon pT.+and look at the histograms with jet and muon pT.
  
  
asc/tutorials/2014october28.txt · Last modified: 2014/10/29 13:55 by asc