Upload
anonymous-n7ojuklc
View
213
Download
0
Embed Size (px)
Citation preview
8/20/2019 XAOD Tutorial
1/22
xAOD Tutorial
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 1
Aims:
Browse an xAOD with ROOT Interactive Root & PyRoot with xAOD
Analysis using ROOT
Analysis in athena & TrigDecisionTool
8/20/2019 XAOD Tutorial
2/22
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 2
Disclaimer
I am NOT an expert. Just trying to give a flavour of what is possible.
Usual ATLAS software tutorial is a week and xAOD mini-tutorial is 2 days.Most recent ones:
https://indico.cern.ch/event/329880/other-view?view=standard
https://indico.cern.ch/event/330324/other-view?view=standard
Useful Links:
https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODEDM
https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOT
https://twiki.cern.ch/twiki/bin/view/AtlasComputing/SoftwareTutorialxAODAnalysisInAthena
https://indico.cern.ch/event/329880/other-view?view=standardhttps://indico.cern.ch/event/330324/other-view?view=standardhttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODEDMhttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOThttps://twiki.cern.ch/twiki/bin/view/AtlasComputing/SoftwareTutorialxAODAnalysisInAthenahttps://twiki.cern.ch/twiki/bin/view/AtlasComputing/SoftwareTutorialxAODAnalysisInAthenahttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOThttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODEDMhttps://indico.cern.ch/event/330324/other-view?view=standardhttps://indico.cern.ch/event/330324/other-view?view=standardhttps://indico.cern.ch/event/330324/other-view?view=standardhttps://indico.cern.ch/event/330324/other-view?view=standardhttps://indico.cern.ch/event/329880/other-view?view=standardhttps://indico.cern.ch/event/329880/other-view?view=standardhttps://indico.cern.ch/event/329880/other-view?view=standardhttps://indico.cern.ch/event/329880/other-view?view=standard
8/20/2019 XAOD Tutorial
3/22
Setup
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 3
setupATLAS
mkdir xAODTutorial
cd xAODTutorial
rcSetup Base,2.0.10
export ALRB_TutorialData=/afs/cern.ch/atlas/project/PAT/tutorial/cern-oct2014/
Standard atlas setup – gives access to softw
Setup the release we want to use
Pointer to some data
8/20/2019 XAOD Tutorial
4/22
Browse an xAOD with ROOT
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 4
root
$ALRB_TutorialData/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5
591_tid01494882_00/AOD.01494882._113691.pool.root.1
root[0] TBrowser b;
The TTree containing the variables is called CollectionTree.
You can look through and “double-click” to see some of the variables.
Have split the interface to objects and how the payload is stored (“aux” containers). In code user interacts with
the interface NOT with the auxilliary storage.
For fun we can look at a run1 AOD:
root root[0] TFile *f =
TFile::Open("$ALRB_TutorialData/mc12_14TeV.105200.McAtNloJimmy_CT10_ttbar_LeptonFilter.recon.AOD.e15
65_s1499_s1504_r4033_tid01014997_00/AOD.01014997._000081.pool.root.2");
This is already a very good thing about xAOD.
8/20/2019 XAOD Tutorial
5/22
Interactive ROOT with the xAOD
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 5
root [0] gROOT->Macro( "$ROOTCOREDIR/scripts/load_packages.C" );
root [1] xAOD::Init();
root [2] f = TFile::Open(
"$ALRB_TutorialData/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s191
1_r5591_tid01494882_00/AOD.01494882._113691.pool.root.1", "READ" );
root [3] t = xAOD::MakeTransientTree( f )
root [4] t->Draw( "ElectronCollection.pt() - ElectronCollection.trackParticle().pt()" );root [5] t->Draw( "Muons.pt()");
Once you have done “MakeTransientTree” can now click things in TBrowser by using root/Root
Memory/CollectionTree
8/20/2019 XAOD Tutorial
6/22
PyROOT with the xAOD
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 6
PyROOT is very handy when you want to run a quick macro
cp /afs/cern.ch/work/h/hartj/public/xAODTutorial/xAODPythonMacro.py .
(chmod +x xAODPythonMacro.py)
./xAODPythonMacro.py
Should print some output about electrons and muons to the screen
8/20/2019 XAOD Tutorial
7/22
Analysis using ROOT
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 7
Create a new Analysis package:
rc make_skeleton MyAnalysis
rc find_packages
rc compile
We will use the standard “EventLoop” package for looping over events.
The EventLoop package provides a script to create the skeleton of the class for you inside the
package you specify
$ROOTCOREBIN/user_scripts/EventLoop/make_skeleton MyAnalysis MyxAODAnalysis
rc find_packagesrc compile
These 3 lines create a new package
and then asks RootCore to pick it up.
8/20/2019 XAOD Tutorial
8/22
Accessing the xAOD quantities from our analysis code
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 8
In MyAnalysis/cmt/Makefile.RootCore add
PACKAGE_DEP = EventLoop xAODRootAccess
at top of MyAnalysis/MyAnalysis/MyxAODAnalysis.h add:
// Infrastructure include(s):
#include "xAODRootAccess/Init.h"
#include "xAODRootAccess/TEvent.h"
Add as public:
xAOD::TEvent *m_event; //!
“//!” is important!!!!!
Update the package dependencies,
EventLoop should already be there
To do any sort of real analysis you will access the xAOD objects using a package called xAODRootAccess. The most important class is the xAOD::TEvent class, which acts similar to the D3PDReader.
We will also use the xAOD::Init class to handle any xAOD access magic that will happen behind the scenes to the
user.
Add header files and a new data member
https://svnweb.cern.ch/trac/atlasoff/browser/Control/xAODRootAccesshttps://svnweb.cern.ch/trac/atlasoff/browser/Control/xAODRootAccess
8/20/2019 XAOD Tutorial
9/22
Accessing the xAOD quantities from our analysis code (2)
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 9
In MyAnalysis/Root/MyxAODAnalysis.ccx
In setupJob() add:
job.useXAOD ();
// let's initialize the algorithm to use the xAODRootAccess package
xAOD::Init(
"MyxAODAnalysis" ).ignore();
// call before opening first file
In initialize() add:
m_event = wk()->xaodEvent();
// as a check, let's see the number of events in our xAOD
Info("initialize()", "Number of events = %lli", m_event->getEntries() ); // print long long int
Now remake the package:
rc find_packages
rc compile
Tell EventLoop that we actually want to use the
xAODRootAccess in our job.
Ignore return code (failure, success, and
recoverable)
Connect this member to out xAODRootAccess.
updated our package dependencies, so from our
working directory we have to rerun rc find_packages
before compiling:
8/20/2019 XAOD Tutorial
10/22
Running our algorithm
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 10
mkdir run
cd run
cp /afs/cern.ch/work/h/hartj/public/xAODTutorial/ATestRun.cxx .
This uses a standard tool SampleHandler to manage sample management.To execute it:
root -l 'ATestRun.cxx ("submitDir")'
submitDir is the directory where the output of
your job is stored. If you want to run again, you
either have to remove that directory or pass a
different name into ATestRun.cxx.
8/20/2019 XAOD Tutorial
11/22
Running our algorithm - alternative
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 11
In order to debug problems with the code, it is often not practical to run the job from ROOT's interpreter. So,
if you encounter any problems, you should create a directory like MyAnalysis/util/, and in there put an
executable source file like MyAnalysis/util/testRun.cxx
cp /afs/cern.ch/work/h/hartj/public/xAODTutorial/testRun.cxx .
In working directory
rc compile
Then from run:
testRun submitDir
8/20/2019 XAOD Tutorial
12/22
Finding out what is on the xAOD
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 12
One question everyone will have is: how do I know what information/variables are actually stored
in my xAOD for each container type?
Need to know the container type and the container key name.
We can use checkSG.py in Athena.
Setup a new lxplus session:
% setupATLAS
% asetup 19.0.3.1,slc6,gcc47,64,here
% export ALRB_TutorialData=/afs/cern.ch/atlas/project/PAT/tutorial/cern-oct2014/
% checkSG.py
$ALRB_TutorialData/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5
591_tid01494882_00/AOD.01494882._113691.pool.root.1
You usually need to know the container type on left (for example xAOD::CaloClusterContainer) and the key
name for the particular instance of that container you are interested in which is on the right (for example
"egClusterCollection").
% checkSG.py
/afs/cern.ch/work/h/hartj/public/valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r
5856_tid01600225_00/AOD.01600225._000084.pool.root.1
8/20/2019 XAOD Tutorial
13/22
Finding out what is on the xAOD (2)
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 13
To know what variables are associated to this container, the trick I use at the moment (again maybe something
official will come along...) is to use interactive ROOT.
root -l
$ALRB_TutorialData/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5
591_tid01494882_00/AOD.01494882._113691.pool.root.1
root [1] CollectionTree->Print("egClusterCollection*")
You will get a printout of all variables you can access from that container
egClusterCollectionAux.rawEta : vector
So in your analysis code (after setting up the TEvent and interface magic), you can access this variable from the
xAOD::CaloCluster object by calling rawEta.
8/20/2019 XAOD Tutorial
14/22
Now lets look at some objects….
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 14
In MyAnalysis/cmt/Makefile.RootCore add
PACKAGE_DEP = EventLoop xAODRootAccess xAODEventInfo
In MyAnalysis/MyAnalysis/MyxAODAnalysis.h add as public:
int m_eventCounter; //!
remember the //! is important!!!!!
First some event information
8/20/2019 XAOD Tutorial
15/22
Now lets look at some objects….
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 15
In MyAnalysis/Root/MyxAODAnalysis.ccx
Near the top:
// EDM includes:
#include "xAODEventInfo/EventInfo.h"
In initialize() add:
// count number of events
m_eventCounter = 0;
In execute() :
// print every 100 events, so we know where we are:
if ( (m_eventCounter % 100) ==0 ) Info("execute()", "Event number = %i", m_eventCounter );m_eventCounter++;
//---------------------------- // Event information //---------------------------
const xAOD::EventInfo* eventInfo = 0;
if ( ! m_event->retrieve( eventInfo, "EventInfo").isSuccess() ){
Error("execute()", "Failed to retrieve event info collection. Exiting." );
return EL::StatusCode::FAILURE;
}
// check if the event is data or MC
// (many tools are applied either to data or MC)bool isMC = false;
// check if the event is MC
if (eventInfo->eventType( xAOD::EventInfo::IS_SIMULATION ) ){
isMC = true; // can do something with this later
}
rc find_packages
rc compile
you can copy
cp
/afs/cern.ch/work/h/hartj/public/xAODTutorial/MyxAOD
Analysis_1.cxx MyxAODAnalysis.cxx
Add includes
zero event counter
Increment event counter and print every 100
events
Access eventInfo and check if data or MC
8/20/2019 XAOD Tutorial
16/22
Now lets look at some objects….
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 16
In MyAnalysis/cmt/Makefile.RootCore add
PACKAGE_DEP = EventLoop xAODRootAccess xAODEventInfo xAODMuon
in MyAnalysis/Root/MyxAODAnalysis.ccx #include "xAODMuon/MuonContainer.h"
In execute()://------------
// MUONS
//------------
// get muon container of interest
const xAOD::MuonContainer* muons = 0;
if ( !m_event->retrieve( muons, "Muons" ).isSuccess() ){ // retrieve arguments: container type, container key
Error("execute()", "Failed to retrieve Muons container. Exiting." );
return EL::StatusCode::FAILURE;
}
// loop over the muons in the container
xAOD::MuonContainer::const_iterator muon_itr = muons->begin();
xAOD::MuonContainer::const_iterator muon_end = muons->end();
for( ; muon_itr != muon_end; ++muon_itr ) {
Info("execute()", " original muon pt = %.2f GeV", ((*muon_itr)->pt() * 0.001)); // just to print out something
} // end for loop over muons
Offline muons:
8/20/2019 XAOD Tutorial
17/22
Now lets look at some objects….
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 17
Remember when we looked at the xAOD objects trigger muons were stored a xAODMuon with a different
key:
HLT_xAOD__MuonContainer_MuonEFInfo
in MyAnalysis/Root/MyxAODAnalysis.ccx in execute()://------------
// TRIGGER MUONS//------------
// get muon container of interest
const xAOD::MuonContainer* trmuons = 0;
if ( !m_event->retrieve( trmuons, "HLT_xAOD__MuonContainer_MuonEFInfo" ).isSuccess() ){ // retrieve arguments:
container type, container key
Error("execute()", "Failed to retrieve Muons container. Exiting." );
return EL::StatusCode::FAILURE;
}
// loop over the muons in the container
xAOD::MuonContainer::const_iterator trmuon_itr = trmuons->begin();
xAOD::MuonContainer::const_iterator trmuon_end = trmuons->end();
for( ; trmuon_itr != trmuon_end; ++trmuon_itr ) {
Info("execute()", " trigger muon pt = %.2f GeV", ((*trmuon_itr)->pt() * 0.001)); // just to print out something
} // end for loop over trigger muons
Trigger muons:
you can copy
/afs/cern.ch/work/h/hartj/public/xAODTutorial/MyxAOD
Analysis_2.h and .cxx
8/20/2019 XAOD Tutorial
18/22
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 18
Check twiki page for other objects and tools, e.g. jets, GRLTool:
https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialx
AODAnalysisInROOT
https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOThttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOThttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOThttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOThttps://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOT
8/20/2019 XAOD Tutorial
19/22
8/20/2019 XAOD Tutorial
20/22
histograms are in root file:
submitDir/hist-valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5856_tid01600225_00.root
also in hist/valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5856_tid01600225_00.root so you can
access them with SampleHandler:
Add to ATestRun.cxx
// Fetch and plot our histogram - will pop up window for interactive running
SH::SampleHandler sh_hist;
sh_hist.load (submitDir + "/hist");
TH1 *hist = sh_hist.get (“valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5856_tid01600225_00")-
>readHist ("h_muonPt");
hist->Draw ();
Then:
root -l 'ATestRun.cxx ("submitDir")'
and you should get a up a canvas popped up with your plot.
Histograms
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 20
8/20/2019 XAOD Tutorial
21/22
TrigDecisionTool
12/11/2014 J.Kirk, UK-HLT Mini workshop, Sussex 21
Link to trigger talk in ATLAS software tutorial:
https://indico.cern.ch/event/329880/session/6/contribution/21/material/slides/0.pdf
Will look at accessing muon chains. Good place to check other signatures here:
https://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/tru
nk/src/TrigDecisionChecker.cxx
https://indico.cern.ch/event/329880/session/6/contribution/21/material/slides/0.pdfhttps://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/trunk/src/TrigDecisionChecker.cxxhttps://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/trunk/src/TrigDecisionChecker.cxxhttps://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/trunk/src/TrigDecisionChecker.cxxhttps://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/trunk/src/TrigDecisionChecker.cxxhttps://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/trunk/src/TrigDecisionChecker.cxxhttps://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigValidation/TrigValAlgs/trunk/src/TrigDecisionChecker.cxxhttps://indico.cern.ch/event/329880/session/6/contribution/21/material/slides/0.pdfhttps://indico.cern.ch/event/329880/session/6/contribution/21/material/slides/0.pdf
8/20/2019 XAOD Tutorial
22/22