XAOD Tutorial
XAOD Tutorial
XAOD Tutorial
Aims:
Browse an xAOD with ROOT
Interactive Root & PyRoot with xAOD
Analysis using ROOT
Analysis in athena & TrigDecisionTool
12/11/2014
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
12/11/2014
Setup
export ALRB_TutorialData=/afs/cern.ch/atlas/project/PAT/tutorial/cern-oct2014/
12/11/2014
Once you have done MakeTransientTree can now click things in TBrowser by using root/Root
Memory/CollectionTree
12/11/2014
(chmod +x xAODPythonMacro.py)
./xAODPythonMacro.py
Should print some output about electrons and muons to the screen
12/11/2014
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_packages
rc compile
12/11/2014
12/11/2014
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();
Connect this member to out xAODRootAccess.
// 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
12/11/2014
12/11/2014
10
12/11/2014
11
12
12/11/2014
13
12/11/2014
14
Add includes
zero event counter
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 //--------------------------Increment event counter and print every 100
const xAOD::EventInfo* eventInfo = 0;
events
if( ! m_event->retrieve( eventInfo, "EventInfo").isSuccess() ){
Error("execute()", "Failed to retrieve event info collection. Exiting." );
Access eventInfo and check if data or MC
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 ) ){
you can copy
isMC = true; // can do something with this later
}
cp
rc find_packages
rc compile
12/11/2014
/afs/cern.ch/work/h/hartj/public/xAODTutorial/MyxAOD
Analysis_1.cxx MyxAODAnalysis.cxx
J.Kirk, UK-HLT Mini workshop, Sussex
15
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
12/11/2014
16
12/11/2014
Check twiki page for other objects and tools, e.g. jets, GRLTool:
https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialx
AODAnalysisInROOT
12/11/2014
18
Histograms
MyAnalysis/MyAnalysis/MyxAODAnalysis.h
at top:
#include <TH1.h>
Add a hist:
TH1 *h_muonPt; //!
In MyAnalysis/Root/MyxAODAnalysis.ccx, in histInitialize :
h_muonPt = new TH1F("h_muonPt", "h_muonPt", 100, 0, 100); // muon pt [GeV]
wk()->addOutput (h_muonPt);
In execute() :
h_muonPt->Fill( ( (*muon_itr)->pt()) * 0.001); // GeV
rc compile
testRun submitDir
12/11/2014
19
Histograms
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.
12/11/2014
20
TrigDecisionTool
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
12/11/2014
21
cd ../cmt
cp /afs/cern.ch/work/h/hartj/public/xAODTutorial/requirements .
gmake
cd ../../../..
mkdir run
cd run
cp /afs/cern.ch/work/h/hartj/public/xAODTutorial/TDTExampleJO.py .
athena.py TDTExampleJO.py > output.txt
12/11/2014
22