NIKHEF PAT workshop Oct2006 pre-Tutorial

From Atlas Wiki
Jump to navigation Jump to search

Note

We'll work using lxplus machines at cern. So make sure you have an ATLAS AFS computer account and scratch0 space.

What will you learn

  • Set up the Athena enviroment
  • Run the UserAnalys package creating AANT (AthenaAware NTuples)
  • Add new algorithms to the package
  • How to access AOD/ESD different containers (Muon, Electron, TrackParticles...) via StoreGate. And the use of the AlgTool AnalysisTools to manipulate their objects.

Set up CMT

  • Login to lxplus at CERN and create a working directory called "Workshop". We will use the release 12.0.2 this tutorial:
ssh lxplus.cern.ch
cd scratch0
mkdir Workshop
cd Workshop
mkdir 12.0.2
  • Create a file called "requirements" and setup CMT. My requirements file looks like this where my working area for 12.0.2 is ${HOME}/scratch0/Workshop/12.0.2:
set   CMTSITE  CERN
set   SITEROOT /afs/cern.ch
macro ATLAS_DIST_AREA ${SITEROOT}/atlas/software/dist
                      
macro ATLAS_GROUP_AREA "/afs/cern.ch/atlas/groups/PAT/Workshop"
 
macro ATLAS_TEST_AREA "" \
        12.0.2 "${HOME}/scratch0/Workshop/12.0.2"
 
 
apply_tag oneTest
 
use AtlasLogin AtlasLogin-* $(ATLAS_DIST_AREA)
  • Then do the following:
source /afs/cern.ch/sw/contrib/CMT/v1r18p20060606/mgr/setup.sh
cmt config

Setup for the release 12.0.2

  • Do the following:
source setup.sh -tag=12.0.2,opt
  • Check that the CMT path is correct by doing this
echo $CMTPATH
  • Stuff like this should be printed to your screen:
/afs/cern.ch/user/o/ordonez/scratch0/Workshop/12.0.2:
/afs/cern.ch/atlas/software/builds/AtlasOffline/12.0.2
  • You see that the path to your working directory, the path to the release directory and the external are set correctly - do not proceed unless this is done correctly.

Run Time Setup

  • Go to your working area and check out the follow package:
cd 12.0.2
cmt co -r UserAnalysis-00-08-05 PhysicsAnalysis/AnalysisCommon/UserAnalysis
  • Now compile everything as follows:
cd PhysicsAnalysis/AnalysisCommon/UserAnalysis/cmt
cmt config; source setup.sh; cmt br gmake
cd ../run
  • To test that everything has been done correctly, do:
get_files HelloWorldOptions.py
athena.py HelloWorldOptions.py | tee athenaOut.log
  • Stuff like this should be printed to the screen:
HelloWorld           INFO execute()
HelloWorld           INFO An INFO message
HelloWorld           WARNING A WARNING message
HelloWorld           ERROR An ERROR message
HelloWorld           FATAL A FATAL error message
AthenaEventLoopMgr   INFO   ===>>>  end of event 9    <<<===
HistorySvc           INFO Service finalised successfully
ChronoStatSvc.f...   INFO  Service finalized succesfully
ToolSvc              INFO Removing all tools created by ToolSvc
ApplicationMgr       INFO Application Manager Finalized successfully
ApplicationMgr       INFO Application Manager Terminated successfully

The Next Time You Login

  • The next time you login, just do the following:
cd ${HOME}/scratch0/Workshop
source setup.sh -tag=12.0.2
cd 12.0.2/PhysicsAnalysis/AnalysisCommon/UserAnalysis/cmt
source setup.sh
cd ../run

Get The Necessary Files

  • We will use inclusive Z to mumu events (sample 4202), digitized in 11.0.41 but the ESD and AOD produced in the release 12.0.1. Copy the PoolFileCatalog.xml for the AOD, ESD and Raw Data (RDO) into your UserAnalysis "run" directory:
~ordonez/public/Workshop_files/data/PoolFileCatalog.xml .
cp ~ordonez/public/Workshop_files/data/*.py .

Run the AnalysisSkeleton for 500 Events

  • get the necessary job options file from the release:
get_files AnalysisSkeleton_jobOptions.py
  • Edit AnalysisSkeleton_jobOptions.py and specify the input data to be the AOD files that you just copied in the previous step: to do this, replace these lines
EventSelector.InputCollections = [ "AOD.pool.root"]
  • with this line
include( "mc11.004201.ZeeJimmy.recon.AOD.v11000401.py" )
  • Check that in AnalysisSkeleton_jobOptions.py, the number of events to run is set to 500:
# Number of Events to process
theApp.EvtMax = 500
  • Now run the AnalysisSkeleton_jobOptions.py. It should produce a file called AnalysisSkeleton.aan.root which contains some ROOT histograms and an AthenaAwareNTuple:
athena.py AnalysisSkeleton_jobOptions.py | tee athenaOut_AnalysisSkeleton.log
  • You've just produced the AthenaAwareNTuple in a standalone way, directly on the AOD, or the ESD or even on the RDO. For Further details on how to produce the AthenaAwareNTuple in this way, follow this link: AthenaAwareNTuple.
  • Now, you may look at the the ../UserAnalysis/AnalysisSkeleton.h, the ../src/AnalysisSkeleton.cxx and ../run/AnalysisSkeleton_jobOptions.py to see how the ROOT histograms and the AthenaAwareNTuple of the output file AnalysisSkeleton.aan.root are defined, filled and saved: Follow this link to the AnalysisSkeleton. For further details on how to produces ROOT histograms and Tuples in ATHENA, look at the THistSvc.
  • You should open the output file AnalysisSkeleton.aan.root in ROOT and browse the histograms and the AthenaAwareNTuple:
root -l AnalysisSkeleton.aan.root
new TBrowser
  • You will notice that beside the user-defined NTuple, the AthenaAwareNTuple tools add references to the AOD, ESD and Raw Data, in addition the RunNumber and the EventNumber.

More Information

Z to mumu on AOD

  • In this exercise, we will do Z to mumu reconstruction on AOD: we will use the association objects Analysis::Muon and its associated TrackParticle. Proceed as follows: copy the code from my area, compiling and running it, then we go through it:
cd ../src
cp ~ordonez/public/Workshop_files/src/ZmumuOnAOD.cxx .
cd ../UserAnalysis
cp ~ordonez/public/Workshop_files/UserAnalysis/ZmumuOnAOD.h .
cd ../run
cp ~ordonez/public/Workshop_files/run/ZmumuOnAOD_jobOptions.py .
  • Now, you want to go the src/components directory and declare this new algorithm ZmumuOnAOD.
cd ../src/components
  • Edit UserAnalysis_entries.cxx and add these lines - follow the example that is already in there for the AnalysisSkeleton:
  • NOTE: Don't copy directly the lines, but follow the example!
#include "UserAnalysis/ZmumuOnAOD.h"

DECLARE_ALGORITHM_FACTORY( ZmumuOnAOD )

  DECLARE_ALGORITHM( ZmumuOnAOD )
  • Save UserAnalysis_entries.cxx and go back the cmt directory and compile:
cd ../../cmt
cp ~ordonez/public/Workshop_files/cmt/requirements .
cmt config
cmt broadcast gmake
cd ../run
  • Now you may run the ZmumuOnAOD algorithm as follows:
athena.py ZmumuOnAOD_jobOptions.py | tee AthenaOut_ZmumuOnAOD.log
  • This should produce an AthenaAwareNTuple file, ZmumuOnAOD.aan.root. While Athena is running, let's go through the code by following this link: ZmumuOnAOD for the details of the algorithm and the selection cuts.
  • Now, open this file in ROOT and browse the AthenaAwareNTuple:
root -l
TFile *f = TFile::Open("ZmumuOnAOD.aan.root")
new TBrowser
TTree * zmumuOnAOD=(TTree*) gDirectory->Get("CollectionTree");
zmumuOnAOD->SetMarkerStyle(20)
zmumuOnAOD->SetMarkerSize(0.5)
zmumuOnAOD->SetMarkerColor(2)
zmumuOnAOD->SetLineColor(4)
zmumuOnAOD->SetLineWidth(2)
zmumuOnAOD->Draw("ZmmMass")
  • By default, we used the Muonboy/STACO/MuTag association objects in the AOD and the associated TrackParticles. But you may change it in the job options ZmumuOnAOD_jobOptions.py: the StoreGate keys for the various objects in the AOD are listed here: StoregateKeysForAOD.
  • Exercise: add a piece code to access the number of hits in the various stations of the Inner Detector and the Muon Spectrometer. Recompile, and run. Then in ROOT look at the NTuple in ROOT and check that the distributions look OK.

Z to ee on AOD

  • In this exercise, we will do Z to ee reconstruction on AOD: we will use the association objects Electron/Photon and its associated Electron TrackParticle. Proceed as follows: copy the code from my area, compiling and running it, then we go through it:
cd ../src
cp ~ordonez/public/Workshop_files/ZeeOnAOD.cxx .
cd ../UserAnalysis
cp ~ordonez/public/Workshop_files/UserAnalysis/ZeeOnAOD.h .
cd ../run
cp ~ordonez/public/Workshop_files/run/ZeeOnAOD_jobOptions.py .
  • Now, you want to go the src/components directory and declare this new algorithm ZeeOnAOD.
cd ../src/components
  • Edit UserAnalysis_entries.cxx and add these lines - follow the example that is already in there for the AnalysisSkeleton:
#include "UserAnalysis/ZeeOnAOD.h"

DECLARE_ALGORITHM_FACTORY( ZeeOnAOD )

  DECLARE_ALGORITHM( ZeeOnAOD )
  • Save UserAnalysis_entries.cxx and go back the cmt directory and compile:
cd ../../cmt
cmt config
cmt broadcast gmake
cd ../run
  • Now you may run the ZeeOnAOD algorithm as follows:
athena.py ZeeOnAOD_jobOptions.py| tee AthenaOut_ZeeOnAOD.log
  • This should produce an AthenaAwareNTuple file, ZeeOnAOD.aan.root. While Athena is running, let's go through the code by following this link: ZeeOnAOD for the details of the algorithm and the selection cuts.
  • Now, open this file in ROOT and browse the AthenaAwareNTuple:
root -l
TFile *_file0 = TFile::Open("ZeeOnAOD.aan.root")
new TBrowser
TTree * zeeOnAOD=(TTree*) gDirectory->Get("CollectionTree");
zeeOnAOD->SetMarkerStyle(20)
zeeOnAOD->SetMarkerSize(0.5)
zeeOnAOD->SetMarkerColor(2)
zeeOnAOD->SetLineColor(4)
zeeOnAOD->SetLineWidth(2)
zeeOnAOD->Draw("ZeeMass")
zeeOnAOD->Draw("ElectronIsEM")
  • The StoreGate keys for the various objects in the AOD are listed here: StoregateKeysForAOD.
  • Exercise: add 2 branches to you ZeeOnAOD NTuple to save the Electron cluster energy and TrackParticle momentum. Recompile and run. Then in ROOT check your NTuple that these variables are filled correctly.

The TrackParticle

  • In this exercise, we will access the a collection of TrackParticles directly from the AOD. Note that from the association objects, Analysis::Muon or Electron, you can access the access the various associated TrackParticles, e.g., look in AnalysisMuon.cxx. But in this exercise, we will use one collection of TrackParticles in the AOD. You may proceed as follows, then we go through the code:
cd ../src
cp ~ordonez/public/Workshop_files/src/TrackExample.cxx .
cd ../UserAnalysis
cp ~ordonez/public/Workshop_files/UserAnalysis/TrackExample.h .
cd ../run
cp ~ordonez/public/Workshop_files/run/TrackExample_jobOptions.py .
  • Now, you want to go the src/components directory and declare this new algorithm TrackExample.
cd ../src/components
  • edit UserAnalysis_entries.cxx and add these lines

(follow the example that is already in there for the AnalysisSkeleton and AnalysisMuon):

#include "UserAnalysis/TrackExample.h"

DECLARE_ALGORITHM_FACTORY( TrackExample )

  DECLARE_ALGORITHM( TrackExample )
  • Save UserAnalysis_entries.cxx and go back the cmt directory and compile:
cd ../../cmt
cmt config
cmt broadcast gmake
cd ../run
  • Now you may run the TrackExample algorithm as follows:
athena.py TrackExample_jobOptions.py | tee AthenaOut_TrackExample.log
  • You should have an AthenaAwareNTuple file, TrackExample.aan.root. While Athena is running, let's go through the code by following this link: KeteviAnalysis. Note the log output to the screen: you will see that the perigee information and the track summary information are being printed to the screen. Look at TrackExample.cxx in details to see how to access this information and more from the TrackParticle.
  • Now, open this file in ROOT and browse the AthenaAwareNTuple:
root -l
TFile *_file0 = TFile::Open("TrackExample.aan.root")
new TBrowser
TTree * trackExample=(TTree*) gDirectory->Get("CollectionTree");
trackExample->SetMarkerStyle(20)
trackExample->SetMarkerSize(0.5)
trackExample->SetMarkerColor(2)
trackExample->SetLineColor(4)
trackExample->SetLineWidth(2)
trackExample->Draw("TrackPEta")
trackExample->Draw("TrackPD0")
trackExample->Draw("TrackPZ0:TrackPD0")
  • In this example, we used the Inner Detector collection of TrackParticle in AOD, with StoreGate key "TrackParticleCandidate": follow this link for the AOD content and the keys for various objects/containers int the AOD - StoregateKeysForAOD.

Z to mumu on the ESD

  • In this exercise, we will use the ESD muon association objects, CombinedMuon and its associated TrackParticle and Trk::Track to repeat the Z to mumu reconstruction entirely on ESD and compare to the results of the AOD above. Proceed as you've done above by copying the code from my area, compiling and running it, then we go through it:
cd ../src
cp ~ordonez/public/Workshop_files/src/ZmumuOnESD.cxx .
cd ../UserAnalysis
cp ~ordonez/public/Workshop_files/UserAnalysis/ZmumuOnESD.h .
cd ../run
cp ~ordonez/public/Workshop_files/run/ZmumuOnESD_jobOptions.py .
  • Now, you want to go the src/components directory and declare this new algorithm ZmumuOnESD.
cd ../src/components
  • edit UserAnalysis_entries.cxx and add these lines

(follow the example that is already in there for the AnalysisSkeleton, AnalysisMuon and TrackExample):

#include "UserAnalysis/ZmumuOnESD.h"

DECLARE_ALGORITHM_FACTORY( ZmumuOnESD )

  DECLARE_ALGORITHM( ZmumuOnESD )

Save UserAnalysis_entries.cxx and go back the cmt directory and compile:

cd ../../cmt
cmt config
cmt broadcast gmake
cd ../run
  • Now you may run the ZmumuOnESD algorithm as follows:
athena.py ZmumuOnESD_jobOptions.py | tee athenaOut_ZmumuOnESD.log
  • This should produce an AthenaAwareNTuple file, ZmumuOnESD.aan.root. While Athena is running, let's go through the code by following this link: ZmumuOnESD.cxx for the details of the algorithm and the selection cuts.
  • Now, open this file in ROOT and browse the AthenaAwareNTuple:
root -l
TFile *_file0 = TFile::Open("ZmumuOnESD.aan.root")
new TBrowser
TTree * zmumuOnESD=(TTree*) gDirectory->Get("CollectionTree");
zmumuOnESD->SetMarkerStyle(20)
zmumuOnESD->SetMarkerSize(0.5)
zmumuOnESD->SetMarkerColor(2)
zmumuOnESD->SetLineColor(4)
zmumuOnESD->SetLineWidth(2)
zmumuOnESD->Draw("ESDZmmMass")
zmumuOnESD->Draw("ESDZmmDeltaR")
  • By default, we used the Muonboy/STACO/MuTag association objects in the ESD and the associated TrackParticles and Trk::Track. But you may change it in the job options ZmumuOnESD_jobOptions.py: the StoreGate keys for the various objects in the ESD are listed here: StoregateKeysForESD. You will notice that in ZmumuOnESD_jobOptions.py, the input data is the ESD, and we are using the CombinedMuonContainer with StoreGate key "StacoCombinedMuonContainer" and from each CombinedMuon object, you can access the associated TrackParticles and Trk::Track.
  • Plot the mumu invariant mass obtained on the ESD and compare it to the one obtained on the AOD above - there may be some differences that I will leave up to you to figure out.

Z to ee on the ESD

  • In this exercise, we will use the ESD Electron/Photon association objects, egamma and its associated TrackParticle and CaloCluster to repeat the Z to ee reconstruction entirely on ESD and compare to the results of the AOD above. Proceed as you've done above by copying the code from my area, compiling and running it, then we go through it:
cd ../src
cp ~ordonez/public/Workshop_files/src/ZeeOnESD.cxx .
cd ../UserAnalysis
cp ~ordonez/public/Workshop_files/UserAnalysis/ZeeOnESD.h .
cd ../run
cp ~ordonez/public/Workshop_files/run/ZeeOnESD_jobOptions.py .
  • Now, you want to go the src/components directory and declare this new algorithm ZeeOnESD.
cd ../src/components
  • edit UserAnalysis_entries.cxx and add these lines

(follow the example that is already in there for the AnalysisSkeleton, AnalysisMuon and TrackExample):

#include "UserAnalysis/ZeeOnESD.h"

DECLARE_ALGORITHM_FACTORY( ZeeOnESD )

  DECLARE_ALGORITHM( ZeeOnESD )
  • Save UserAnalysis_entries.cxx and go back the cmt directory and compile:
cd ../../cmt
cmt config
cmt broadcast gmake
cd ../run
  • Now you may run the ZeeOnESD algorithm as follows:
athena.py ZeeOnESD_jobOptions.py | tee athenaOut_ZeeOnESD.log
  • This should produce an AthenaAwareNTuple file, ZeeOnESD.aan.root. While Athena is running, let's go through the code by following this link: ZeeOnESD.cxx for the details of the algorithm and the selection cuts.
  • Now, open this file in ROOT and browse the AthenaAwareNTuple:
root -l
TFile *_file0 = TFile::Open("ZeeOnESD.aan.root")
new TBrowser
TTree * zeeOnESD=(TTree*) gDirectory->Get("CollectionTree");
zeeOnESD->SetMarkerStyle(20)
zeeOnESD->SetMarkerSize(0.5)
zeeOnESD->SetMarkerColor(2)
zeeOnESD->SetLineColor(4)
zeeOnESD->SetLineWidth(2)
zeeOnESD->Draw("EgammaPt")
zeeOnESD->Draw("EgammaEta")
zeeOnESD->Draw("EgammaEoverP")
zeeOnESD->Draw("EgammaIsEM")
zeeOnESD->Draw("EgammaZeeMass")
zeeOnESD->Draw("EgammaTrackP")
zeeOnESD->Draw("EgammaClusterE")
  • The StoreGate keys for the various objects in the ESD are listed here: StoregateKeysForESD. You will notice that in ZeeOnESD_jobOptions.py, the input data is the ESD, and we are using the egammaContainer with StoreGate key "egammaCollection" and from each egamma object, you can access the associated TrackParticles and CaloCluster.
  • Plot the ee invariant mass obtained on the ESD and compare it to the one obtained on the AOD above - there may be some differences that I will leave up to you to figure out.
  • For further details of the Electron/Photon reconstruction, see egammaRec.