If we follow the AnalysisBase tutorial idea of accessing the jet container in our algorithm, changes need to be made to your CMake setup.
Include the jet container header in your source code (MyAnalysis/Root/MyxAODAnalysis.cxx
):
#include <xAODJet/JetContainer.h>
And also add the following to your MyxAODAnalysis::execute()
// loop over the jets in the container
const xAOD::JetContainer* jets = nullptr;
ANA_CHECK (evtStore()->retrieve (jets, "AntiKt4EMPFlowJets"));
for (const xAOD::Jet* jet : *jets) {
ANA_MSG_INFO ("execute(): jet pt = " << (jet->pt() * 0.001) << " GeV");
} // end for loop over jets
If you now recompile in your build directory you will see the following because your package does not know about xAODJet and has not listed it as a dependency…
fatal error: xAODJet/JetContainer.h: No such file or directory
#include <xAODJet/JetContainer.h>
^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In your MyAnalysis/CMakeLists.txt
link your package shared library to the xAODJet library within atlas_add_library
like so
# where [...] is any other package dependencies you may already have included.
LINK_LIBRARIES [...] xAODJet
If we rerun cmake
the way we have done previously and then compile, it should now compile fine, same as you have done previously with the xAOD Analysis
Next step, we can use the JetSelectionHelper package you added from the previous ‘Git for Analysis’ tutorial. However, if you are starting fresh you can just clone the dummy package JetSelectionHelper into your source directory, notice JetSelectionHelper has its own CMakeLists.txt
.
Include the header into your MyxAODAnalysis.cxx
:
#include <JetSelectionHelper/JetSelectionHelper.h>
Modify your MyxAODAnalysis::execute() and jet loop to use the JetSelectionHelper
// Add jet selection helper
JetSelectionHelper jet_selector; //<-----------------
// loop over the jets in the container
const xAOD::JetContainer* jets = nullptr;
ANA_CHECK (evtStore()->retrieve (jets, "AntiKt4EMPFlowJets"));
for (const xAOD::Jet* jet : *jets) {
if ( !jet_selector.isJetGood(jet) ) continue; //<------------
ANA_MSG_INFO ("execute(): jet pt = " << (jet->pt() * 0.001) << " GeV");
} // end for loop over jets
Exercise
Again, this will produce an error when trying to compile, try modify MyAnalysis/CMakeLists.txt
to include JetSelectionHelper
and make your code compile.
Hint: the library name usually matches the package name or has an added lib
on the end. Check the JetSelectionHelper CMakeLists.txt
file for the name.
If you got this to work, you have now applied some basic jet selection criteria to your xAOD analysis.