NIKHEF PAT workshop Oct2006

From Atlas Wiki
Jump to navigation Jump to search

Pre-Tutorial

  • This pre-Tutorial is copy of the one gave by Ketevi A. Assamagan, adapted to work in 12.0.2
  • here is a link to other Tutorials by Ketevi, and other usful PAT links:

PAT

  • Please follow the following pre-Tutorial before the date of the Workshop. It is a very straight forward, tutorial and will help to set up the athena enviroment for the workshop, so we can focus our time in more interested things

Pre-Tutorial link

Event Selection

First we're going to generate a new AAN that we'll use later for selection.

cd ~scratch0/Workshop/
source setup.sh -tag=12.0.2,opt
cd 12.0.2/PhysicsAnalysis/AnalysisCommon/UserAnalysis
cp ~ordonez/public/Workshop_files/src/AnalysisSkeleton.cxx src/.
cp ~ordonez/public/Workshop_files/UserAnalysis/AnalysisSkeleton.h UserAnalysis/.
cd cmt
gamke
cd ..
mkdir run2
cd run2
cp ~ordonez/public/Workshop_files/run2/AnalysisSkeleton_jobOptions.py .
cp ~ordonez/public/Workshop_files/data2/PoolFileCatalog.xml .
cp ~ordonez/public/Workshop_files/data2/mc11.004202.ZmumuJimmy.recon.AOD.v11000401.py .
athena AnalysisSkeleton_jobOptions.py | tee athenaOut_AnalysisSkeleton.log

This will generate the file AnalysisSkeleton.aan.root.

Event Selection using TAG

  • First we generate our own TAG.
  • Still in the new Run directory:
cp ~ordonez/public/Workshop_files/run2/Main_topOptions.py .
  • Edit Main_topOptions.py and uncomment the line
### Create TAG file
doWriteTAG=True
athena Main_topOptions.py | tee athenaOut.log
  • This will generate the file called ZmumuOnAOD_TAG.root
  • Now we are ready to run our algorithms with a TAG selection on the fly. Edit Main_topOptions.py again comment out:
#doWriteTAG=True 
  • and uncomment
doRunAODwithSelection=True

and

useTag=True
  • Copy:
cp ~ordonez/public/Workshop_files/run2/ZmumuOnAOD_new_jobOptions.py .
  • And run again. Note that only will run the events that satisfy the query:

EventSelector.Query = "NLooseMuon>0 && NLooseMuon<3 && abs(LooseMuonEta1)<2.5 && abs(LooseMuonEta2)<2.5 && LooseMuonPt2>10000 && LooseMuonPt2>10000"


athena Main_topOptions.py | tee athenaOut.log
  • As an output you have ZmumuOnAOD_withTAGSelection.aan.root. You can have a look at it in root to make sure that the query has been satisfied
  • Now we'll rewrite our own AOD containeing only the events selected. We'll do it for only 50 events to gain some time
  • Edit again Main_topOptions.py and change:
TheApp.EvtMax = 500

to

TheApp.EvtMax = 50
  • Comment out
#doRunAODwithSelection=True
  • uncomment:
doRewriteAOD=True

and run once more

athena Main_topOptions.py | tee athenaOut.log

You'll see a new Zmumu_new_AOD.root file has been created

Event Selection using AAN

  • Follow as in the previous section but useANN=True instead of useTAG=True. In the end you should have the following two files:


Interactive Analysis in ATHENA

  • In this exercise, we will see how to do interactive analysis in ATHENA, how to browse the Raw Data in the AOD. Proceed as follows:
get_files Interactive_topO.py
  • Edit Interactive_topO.py and replace this line
EventSelector.InputCollections = [ "AOD.pool.root" ]
  • with this line:
include ( "mc11.004202.ZmumuJimmy.recon.AOD.v11000401.py" )
  • run
athena -i Interactive_topO.py
  • Initialize application manager
athena> theApp.initialize()
  • Run 1 event
athena> theApp.nextEvent()
  • Retrieve Muons from AOD
athena> mcon = PyParticleTools.getMuons("MuidMuonCollection")
  • Number of Muons
athena> econ.size()
  • Get the first muon
athena> m = mcon[0]
  • Get a list of methods
athena> dir(m)
  • See pT
athena> m.pt()
  • Get TrackParticle via ElementLink
athena> tp = m.track()
athena> dir(tp)
  • Retrieve the MC Truth
athena> mcc = PyTruthTools.getMcEvents("TruthEvent")
athena> mc = mcc[0]
athena> mc.alphaQCD()
  • Dump Data Store
athena> dumpSG()
  • Run your own Python script
athena> emacs test.py
  • put your python code:
x = (1234*GeV, 3456*GeV)
import math
xx = math.sqrt(x[0])

it  = mc.particles_begin()
itE = mc.particles_end()
while (it != itE):
    p = it.next()
    print p.pdg_id()
    
print "Done"
  • e.g., test.py. Then Ctrl+XC to close emacs
  • Run next event
athena> theApp.nextEvent()

Rewind event counter

athena> theApp.seek(0)


  • See pT distribution of muons

athena> plot("MuonContainer#MuidMuonCollection","$x.pt()",nEvent=5)

Monte Carlo Truth Tools on AOD

  • In this exercise, we will look MC Truth Tools on AOD. Follow the link below, but skip the configuration part since it pertains to the release 11.0.5 while we are using the release 12.0.1 here and we have already done the configuration for 12.0.1 in the Introduction above. You will also need to make the following changes for 12.0.1: everywhere where application, replace the following
#include "TruthParticleAlgs/McVtxFilterTool.h"
#include "TruthParticleAlgs/TruthParticleCnvTool.h"
#include "AnalysisUtils/McVtxFilter.h"
#include "ParticleEvent/TruthParticle.h"
#include "ParticleEvent/TruthParticleContainer.h"
  • with the following:
#include "McParticleTools/McVtxFilterTool.h"
#include "McParticleTools/TruthParticleCnvTool.h"
#include "McParticleUtils/McVtxFilter.h"
#include "McParticleEvent/TruthParticle.h"
#include "McParticleEvent/TruthParticleContainer.h"
  • Also in your requirements file, you may need to add the following lines and redo cmt config and gmake:
cmt co -r McParticleTools     McParticleTools-00-*      PhysicsAnalysis/TruthParticleID
cmt co -r McParticleUtils       McParticleUtils-00-*       PhysicsAnalysis/TruthParticleID
cmt co -r McParticleEvent     McParticleEvent-00-*     PhysicsAnalysis/TruthParticleID
  • Now follow this link, McTrtuh on AOD, make sure that you make the above modifications before running.

Analysis with the EventView

  • Follow this link: EventView. However, I would suggest that you do the specific exercises above on ESD/AOD/TAG first: that provides the background for understanding the ESD/AOD/TAG before proceeding to the EventView.

Analysis on the GRID

  • In the following examples we'll run on Zmumu datasets.
  • This will be a brief introduction to GRID tools for those of you who already went through the trouble of getting a GRID certificate.
  • First we should set up DQ2 tools:
source /afs/usatlas.bnl.gov/Grid/Don-Quijote/dq2_user_client/setup.csh.CERN

PANDA/PATHENA

  • For further details visit panda wiki
  • Setup PATHENA :
cd ~/scratch0/Workshop/12.0.2/PhysicsAnalysis/AnalysisCommon/UserAnalysis
cvs update -r UserAnalysis-00-08-13 -A python
cvs update -r UserAnalysis-00-08-13 -A share/pathena
cvs update -r UserAnalysis-00-08-13 -A share/pathena_util
cvs update -r UserAnalysis-00-08-13 -A share/ConfigExtractor.py
cd cmt
source setup.sh
gmake
cd ../run
  • run pathena

Note: change user.GustavoOrdonezSanz.00008.AAN.root with an appropiate name!!

pathena ZmumuOnAOD_jobOptions.py --inDS 'csc11.005145.PythiaZmumu.recon.AOD.v11004103' --outDS \
'user.GustavoOrdonezSanz.00008.AAN.root'

GANGA

  • For further details vistit ganga wiki
  • A very simple example of how to use panda move to your ${HOME} directory and do:
export PATH=$PATH:/afs/cern.ch/sw/ganga/install/slc3_gcc323/4.2.0-beta7/bin/

or 

setenv PATH /afs/cern.ch/sw/ganga/install/slc3_gcc323/4.2.0-beta7/bin/:${PATH}
  • Generate a ${HOME}/.gangarc with
ganga -g
  • Edit $HOME/.gangarc as follows:

1. In the section labelled [Configuration] add the line:

      RUNTIME_PATH = GangaAtlas

2. In the section labelled [LCG] add the line:

      VirtualOrganisation = atlas
  • Now move to the run directory again and try this:
ganga
  • Inside the Python interpreter:
j = Job()
j.application=Athena()
j.application.prepare()
j.application.option_file='$HOME/scratch0/Workshop/12.0.2/PhysicsAnalysis/AnalysisCommon/UserAnalysis/run/ZmumuOnAOD_jobOptions.py'
j.inputdata=DQ2Dataset()
j.inputdata.type='DQ2_LOCAL'
j.inputdata.dataset='csc11.005145.PythiaZmumu.recon.AOD.v11004103'
j.outputdata=DQ2OutputDataset()
j.outputdata.outputdata=['ZmumuOnAOD.aan.root']
j.backend=LCG()
j.submit()

DQ2 Tools

  • For furhter details visit DQ2 wiki
  • This tools make your life easier when working on the GRID
dq2_ls *Zmumu*AOD*
  • change user.GustavoOrdonezSanz.00008.AAN.root for your own
dq2_get -rv -d . user.GustavoOrdonezSanz.00008.AAN.root