r29 - 23 Mar 2011 - 15:33:24 - Main.FRYou are here: TWiki >  Atlas Web  > ARATopQuarkAnalysis

Given we moved to the official Top D3PD, which now support MC as well, this package is not maintained anymore

Relevant tags:


For release TopPhys?-15.6.13.3.2, the latest stable tag to use is: ARATopQuarkAnalysis-15-01-30-branch
For release AtlasProduction?-16.0.X.Y, the latest stable tag to use is ARATopQuarkAnalysis-00-01-31, or the head. See the ChangeLog?

Both releases have same variable naming conventions.

see this link: https://svnweb.cern.ch/cern/wsvn/atlasgrp/Institutes/LPC/LPCAT/ARATopQuarkAnalysis/trunk/ChangeLog

Introduction

The ARATopQuarkAnalysis approach is meant to be simple, easy to use and to understand for a non software expert. It implements a set of algorithms for particle selection, W, top particle like reconstruction and particle analysis with both ATHENA and ROOT (using the PYROOT interface for loading the C++ compiled modules) This approach was successfully tested with the FDR exercise and will be continued for the coming 10/14 TeV? first data for analysing top like events. In the following sections, we describe in details the package structure, its installation, its use for DPD creation and for DPD analysis with the pyroot interface.

Known issues with tcsh, bring us to use bash as shell. This is fully supported and avoids errors like e.g. word too long. So move to bash if you did not do this already.

Package structure

Introduction

the ARATopQuarkAnalysis implements a set of Modules to perform a detailled DPD top physics analysis which can be run with either ATHENA or ARA. The package structure is the following:
  • ARATopQuarkAnalysis: contains all header files
  • src: contains all .cxx file source code: all files starting with prefix ARA are in principle working on both ARA/ATHENA. As an example: the ParticleJetHandler.cxx is an ATHENA algorithm, which implements ARAParticleJet as a private member and gives it all the required input parameters from StoreGate? and ARAParticleJet.cxx
  • cmt: requirements for CMT to build the ATHENA/ARA libraries
  • grid: set of scripts which allow us to use GANGA for GRID submission
  • scripts: set of scripts which allow us to use the LSF batch system at CERN
  • macros: set of useful macros to run analysis within a ROOT session
  • python: ATHENA specific flags
  • run: directory where tests should be done
  • share:contains the python interface of the ATHENA algorithms
The algorithms implemented so far for particle selection (slimming and skimming only), are:
  • ElectronHandler: implements the electron selection,
  • PhotonHandler: implements the photon selection,
  • MuonHandler: muon selection,
  • TauHandler: tau selection: basic, implements pt, eta and overlap with the already selected objects,
  • BJetHandler: b-jet selection,
  • ParticleJetHandler: general jet selection and jet-quark matching: useful for the in situ calibration study,
  • MissingETHandler: selection of MissingET?
  • TriggerHandler: used to dump the TriggerDecision? into a UserDataTree?, all menu items (passed and prescale value) are stored into the UserDataTree? written into the output DPD.
  • EventVariables: implements a set of topological variables computed from the selected electrons, muons, and jets
  • HadronicWBosonBuilder: implements several methods for W-boson reconstruction
  • HadronicTopQuarkBuilder: implements several methods for top-quark reconstruction
  • TopQuarkAnalysis: a library like for top quark analysis, this algorithm runs on the selected particles
  • TruthProcessHandler
  • IROOTDumper: a generic interface to dump all the above objects information into a flat ntuple also known as a D3PD
  • D3PDReader: allows from the produced D3PD, to reconstruct ATHENA objects and reuse all the above algorithms

Tools for electron selection

We implemented a set of selection methods for the electrons which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT)

  • src/ARAElectron.cxx : the source code implementing the different methods
  • src/ElectronHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
ElectronContainer* ARAElectron::doPreselection(const ElectronContainer* EC, double CutPt, double CutEta)
EC is the input ElectronContainer?, CutPt? is given in MeV? and CutEta? is the eta range cut. It returns an ElectronContainer? (vector of Electrons) which fulfill these selection criteria
ElectronContainer* ARAElectron::doPreselection(const ElectronContainer* EC, double CutPt,double CutEta,double CutIsolationEnergy)
same as before but with an isolation energy cut in a cone of R=0.2 around the electron cluster
ElectronContainer* ARAElectron::doPreselection(const ElectronContainer* EC,  // input electron container
                                               double CutPt, // Pt cut
                                               double CutEta, // eta cut
                                               double CutIsolationEnergy, // isolation energy around the electron (calorimeter like)
                                               int CutElectronIdentification, // choose among ElectronLoose, ElectronMedium and ElectronTight PID styles
                                               bool CutElectronTrackMatch,  // match the electron to a track
                                               bool CutCustomisedSelection, // customise the electron selection using the 32 bits for isEM flag
                                               unsigned int CutAuthorMask, // author mask
                                               bool CutUseIsEMMask, // use the isEM mask 
                                               int CutIsEMMask, // mask for the isEM
                                               const JetCollection* PJC, // particle Jet container already inserted
                                               double CutOverlap // deltaR cut between the electron and the jet
                                               )
This method is more sophisticated, it includes a isEM bit mask selection and overlap removal with jets. it returns ElectronContainer?, a vector of electrons
ElectronContainer* ARAElectron::doPreselection(const ElectronContainer* EC, 
                                               double CutPt,
                                               double CutEta,
                                               double CutIsolationEnergy,
                                               const JetCollection* PJC,
                                               double CutROverlap
                                               )
selects electrons with isolation energy and overlap removal with respect to jets
Analysis::Electron* ARAElectron::matchTrueElectron(const TruthParticle *E, const ElectronContainer *EC, double& deltaR)
 
given a True MC electron particle, and a vector of reconstructed electrons, it returns the closest reconstructed electron to this true particle and the value of R. it returns an Electron object
bool ARAElectron::isGood(const Analysis::Electron* E )
given a reconstructed electron object, it returns true or false if this electron is a medium reconstructed algorithm reconstructed electron with a matching track.
bool ARAElectron::isGood(const Analysis::Electron* E,double CutPt, double CutEta)
checks whether an electron fulfills cuts on eta and Pt
bool ARAElectron::isGoodIsEM(const Analysis::Electron* E, int CutIsEMMask) 
checks whether an electron fulfills a given isEM bit mask
bool ARAElectron::isGoodAuthorMask(const Analysis::Electron *E, unsigned int CutAuthorMask)
checks whether an electron fulfills a some author algorithms (Loose, Medium or Tight). The Author mask is defined as a bit Mask!
bool ARAElectron::isGood(const Analysis::Electron* E, double CutPt, double CutEta, unsigned int CutAuthorMask, bool CutUseIsEMMask, int CutIsEMMask)
checks whether an electron E fulfills some Pt, eta, author, isEM masks (advanced selection criteria)
bool ARAElectron::isGood(const Analysis::Electron* E, double CutPt, double CutEta, int CutIsEMMask)
checks whether an Electron fulfills selection criteria for Pt, eta and isEM bit mask
bool ARAElectron::isGood(const TruthParticle *P,double CutPt, double CutEta)
Checks whether a true electron (MC Truth!) fulfills Pt and eta cuts

How to call the Electron tool from ATHENA ?

You can see how this is done in the already implemented python job option files. Below, we give two algorithm implementation examples. We first import the ElectronHandler? algorithm. Then we implement the two algorithms (we can in principle in the same job implement as many as we want, given that we give them a different name...

The first algorithm called ElectronHandlerMediumWithTrackWithBTagging reads the electrons stored in the AOD (or the DPD) and called ElectronAODCollection, and selects the ones which fulfill some kinematic cuts. We require that the selected electrons do not overlap with already inserted electrons. looks for electrons and checks that these objects do not overlap with already selected b-jets (see later).

The second algorithm called ElectronHandlerDefault, applies a simple cut on the ElectronAODCollection and stores the selected objects in StoreGate? in an ElectronContainer? called myElectronAODCollection

from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import ElectronHandler
thisAlg = ElectronHandler("ElectronHandlerMediumWithTrackWithBTagging")
thisAlg.InputElectronContainerName   = "ElectronAODCollection"
thisAlg.CutElectronPt    =  20*GeV
thisAlg.CutElectronEta   =  2.5
thisAlg.CutElectronIsolationEnergy = 6*GeV
#- electron Identification a set of standard masks/cuts applied to the Analysis::Electron::isem() flag
#  0 -> egammaPID::ElectronLoose  (default)
#  1 -> egammaPID::ElectronMedium 
#  2 -> egammaPID::ElectronTight
thisAlg.CutElectronIdentification = 1
# we require that this electron matches a track
thisAlg.CutElectronTrackMatch = True
# we want this electron not to overlap with an already inserted b-jet
thisAlg.InputParticleJetContainerName   = "myBJets"
# overlap cut for electrons-b-jets
thisAlg.CutDeltaRElectronJet = 0.4
# these good electrons output container
thisAlg.OutputElectronContainerName  = "myElectronsMediumWithTrackWithBTagging"
# add this algorithm to the algorithm sequence
topSequence +=[thisAlg]

#------------------------------------------------------------------------------------------------------------------------------------
#- now select electron to be able to rerun on this DPD
thisAlg = ElectronHandler("ElectronHandlerDefault")
thisAlg.InputElectronContainerName   = "ElectronAODCollection"
thisAlg.OutputElectronContainerName  = "myElectronAODCollection"
thisAlg.CutElectronPt    =  10*GeV
thisAlg.CutElectronEta   =  3.5
#- if set to true, the electrons are required to be EGAMMA ones and loosely identified
topSequence +=[thisAlg]


How to call the Electron tool from PyROOT? ?

once the ATHENA environment is configured as explained in details below, we can import the ARAElectron in PyROOT? (or in ROOT, but CINT has some limitations, thus PyROOT? is prefered)

import sys
import user
import ROOT
import PyCintex
import AthenaROOTAccess.transientTree

# we import our ARAElectron
from ROOT import ARAElectron

# we create two ARAElectron objects
# the first one with b-tagging
m_ARAElectronMediumWithTrackWithBTagging = ROOT.ARAElectron()

#the second one to select our electrons with pt, eta cuts only
m_ARAElectronDefault = ROOT.ARAElectron()

Tools for Muon selection

We implemented a set of selection methods for the muons which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT) Of course some of the methods are redundant to what was described previously for the electron case and could be factorized in a Template Class, but, our scope here is to be as simplistic as possible.
  • src/ARAMuo.cxx : the source code implementing the different methods
  • src/MuonHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
bool ARAMuon::isGood(const Analysis::Muon *M,double CutPt, double CutEta)
checks whether a Muon fulfills pt and eta cuts
Analysis::MuonContainer* ARAMuon::doPreselection(const Analysis::MuonContainer* MC, 
                                                 double CutPt,
                                                 double CutEta,
                                                 double CutIsolationEnergy,
                                                 bool CutIsHighPt
                                                 )
returns the list of muons which fulfill pt, eta, isolation energy (cone of 0.2 around the track) and whether the Muon is reconstructed with the HighPt? algorithm.
Analysis::MuonContainer* ARAMuon::doPreselection(const Analysis::MuonContainer* MC, 
                                                 double CutPt,
                                                 double CutEta,
                                                 double CutIsolationEnergy,
                                                 bool CutIsHighPt,
                                                 const JetCollection* PJC,
                                                 double CutROverlap
                                                 )
returns the list of muons but this time with an overlap removal with already inserted jets. Muons within the CutROverlap? R are rejected. We could think about adding these muons to the jet. This would be implemented then in the ARAParticleJet

Tools for Jet selection

We implemented a set of selection methods for jets which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT) Of course some of the methods are redundant to what was described previously for the electron case and could be factorized in a Template Class, but, our scope here is to be as simplistic as possible.
  • src/ARAParticleJet.cxx : the source code implementing the different methods
  • src/ParticleJetHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
JetCollection* ARAParticleJet::doPreselection(const JetCollection* JC,
                                              const JetCollection* BC,
                                              const ElectronContainer* EC, 
                                              const Analysis::MuonContainer* MC,
                                              double CutPt,
                                              double CutEta,
                                              double CutDeltaRJetBJet,
                                              double CutDeltaRJetElectron,
                                              double CutDeltaRJetMuon
                                              )
given a set of B-Jets (can be set to NULL), electrons EC (can be NULL) and muons MC (can be NULL), we select jets from the input JetCollectionJC?. We require pt, eta cuts and overlap removal with the other objects
JetCollection* ARAParticleJet::doPreselection(const JetCollection* JC,const TruthParticleContainer* TPC,const McEventCollection* MCEC)
we loop over all true particles and keep from our collection JC, the ones which are matching quark and gluons
JetCollection* ARAParticleJet::doPreselection(const JetCollection* JC,const TruthParticleContainer* TPC,const McEventCollection* MCEC, double CutDeltaR)
we select the jets which are the closest to our quarks and gluons with a maximal allowed deltaR cut
TruthParticleContainer* ARAParticleJet::getLightQuarksFromWBosonDecay(TruthParticleContainer* iTPC)
given a vector of true particles, we extract a vector of light quarks which are the W-boson daughters

Tools for b-jet selection

We implemented a set of selection methods for the b-jets which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT) This algorithm could be factorised with the ARAParticleJet described previously
  • src/ARABJet.cxx : the source code implementing the different methods
  • src/BJetHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
bool ARABJet::isGood(const Jet *J,double CutPt, double CutEta, double CutBJetWeight)
checks whether a jet fulfills pt, eta and b-tagging probability (IP2D, SV1, etc...)
JetCollection* ARABJet::doPreselection(const JetCollection* JC,
                                       const ElectronContainer* EC, 
                                       const Analysis::MuonContainer* MC,
                                       double CutPt,
                                       double CutEta,
                                       double CutBJetWeight,
                                       double CutDeltaRJetElectron,
                                       double CutDeltaRJetMuon
                                       )
returns list of jets which do not overlap with already inserted leptons (can be NULL) and with pt, eta and b-tagging probability
JetCollection* ARABJet::doPreselection(const JetCollection* JC,
                                       double CutPt,
                                       double CutEta,
                                       double CutBJetWeight
                                       )
returns the list of b-jets with a b-tagging weight cut.

Tools for MissingET? selection

We implemented a set of selection methods for the MissingET? which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT) This algorithm could be used to recompute the missing ET.
  • src/ARAMissingET.cxx : the source code implementing the different methods
  • src/MissingETHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
bool ARAMissingET::isGood(const MissingET *MET, double CutEt)
given a Missing ET object, checks whether it is higher than CutEt?
MissingET* ARAMissingET::doPreselection(const MissingET* MET, 
                                        double CutEt
                                        )
returns the missing ET above CutET?, if below returns NULL. could be used to redefine the missingET

Tools for hadronic top quark candidate reconstruction

We implemented a set of reconstruction methods for the hadronic top quark which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT)

  • src/ARAHadronicTopQuarkBuilder.cxx : the source code implementing the different methods for top quark reconstruction and matching
  • src/HadronicTopQuarkBuilder.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
bool ARAHadronicTopQuarkBuilder::isGood(const CompositeParticle *J,double CutPt, double CutEta)
given a top composite particle (a top composite particle is made of a b-jet and a W-boson composite particle (the W-boson composite particle is made of light jets), we check whether it fulfills pt and eta range cuts
CompositeParticleContainer* ARAHadronicTopQuarkBuilder::build(const JetCollection* JC, const IParticleContainer* IJC,
                                                              const JetCollection* BC, const IParticleContainer* IBC, 
                                                              const CompositeParticleContainer* WC, 
                                                              const ElectronContainer* EC, 
                                                              const Analysis::MuonContainer* MC, 
                                                              int ReconstructionMethod)
given a set of jets, b-jets, electrons, muons and W composite particles, and the reconstruction method (6 methods available so far), this method returns the built top candidates

CompositeParticleContainer* ARAHadronicTopQuarkBuilder::buildHighestPtObjectWithoutBTaggingInfo(const JetCollection* JC
, const IParticleContainer* IJC )
builds the highest pt object by looping over all jets (no b-tagging information is required. The returned object is a composite particle made of the three jets which combined give the highest pt object
std::vector<int> ARAHadronicTopQuarkBuilder::getHighestPtObjectWithoutBTaggingInfoIndices(const JetCollection* JC)
this method is indeed a factorization of the previous one. we return the indexes for the jets which combined give the highest pt object
CompositeParticleContainer* ARAHadronicTopQuarkBuilder::buildHighestPtObjectWithBTaggingInfo(const JetCollection* JC, 
   const IParticleContainer* IJC, 
   const JetCollection* BC, 
   const IParticleContainer* IBC)
same as before, but this time, with the b-tagging information included
CompositeParticleContainer* ARAHadronicTopQuarkBuilder::buildThreeJetsClosestInDeltaRWithoutBTaggingInfo(const JetCollection* JC, 
   const IParticleContainer* IJC)
build the top composite particle as the three jets the closest in deltaR
CompositeParticleContainer* ARAHadronicTopQuarkBuilder::buildThreeJetsClosestInDeltaRWithBTaggingInfo(const JetCollection* JC, 
        const IParticleContainer* IJC, 
        const JetCollection* BC, 
        const IParticleContainer* IBC)
same as before but this time, we disentangle the b-jets from the light jets.
CompositeParticleContainer* ARAHadronicTopQuarkBuilder::buildBJetClosestInDeltaRWithHadronicWBoson(const JetCollection* BC, 
             const IParticleContainer* IBC, 
             const CompositeParticleContainer* WC)
we find the b-jet the closest with the W-composite particles (a W-composite particle is made of light jets)
CompositeParticleContainer* ARAHadronicTopQuarkBuilder::buildHighestPtObjectWithBTaggingInfoWithHadronicWBoson(const JetCollection* BC, 
            const IParticleContainer* IBC, 
            const CompositeParticleContainer* WC)
this time we return the highest pt object when combining the W composite particles and the b jets.

Tools for leptonic top quark candidate reconstruction

needs to be IMPLEMENTED

Tools for hadronic w boson candidate reconstruction

We implemented a set of selection methods for the w-bosons which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT)

  • src/ARAHadronicWBosonBuilder.cxx : the source code implementing the different methods
  • src/HadronicWBosonBuilder.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
bool ARAHadronicWBosonBuilder::isGood(const CompositeParticle *J,double CutPt, double CutEta)
tells whether a W-boson composite particle candidate fulfills some selection criteria
CompositeParticleContainer* ARAHadronicWBosonBuilder::build(const JetCollection* JC, const IParticleContainer* IPC, int ReconstructionMethod)
interface to the different methods (# 0 -> all combinations, # 1 -> closest in delta R)
CompositeParticleContainer* ARAHadronicWBosonBuilder::buildAllCombinations(const JetCollection* JC, const IParticleContainer *IPC)
returns all Ws built as a 2 from N combinatorics! At least one W composite particle!
CompositeParticleContainer* ARAHadronicWBosonBuilder::buildClosestInDeltaR(const JetCollection* JC, const IParticleContainer* IPC )
return the W composite particle as the two jets the closest in deltaR
 CompositeParticleContainer* ARAHadronicWBosonBuilder::build(const JetCollection* JC,
                                                                                                                const IParticleContainer* IPC, 
                                                                                                                double WPDGMass, double CutWMassWindow)
returns the two jet combination which is the closest to the PDG Mass and within a given mass window

Tools for leptonic w boson candidate reconstruction

See src/ARALeptonicWBosonBuilder and look at the method called build. The neutrino equation is solved by using the NeutrinoUtils?::candidatesFromWMass (central ATLAS package which avoids then software duplication)
TCompositeParticleContainer* ARALeptonicWBosonBuilder::build(const ElectronContainer* EC, const Analysis::MuonContainer* MC, const MissingET* MET, int reconstructionMethod)

Tools for Monte Carlo Truth selection and analysis

We implemented a set of selection methods for the the MonteCarlo? Truth which can be called from both ATHENA or ROOT (since the genreflex dictionary tool was used to create the relevant class description for ROOT)
  • src/ARATruthProcess.cxx : the source code implementing the different methods
  • src/TruthProcessHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm

The methods, implemented so far, are:

Method Description
int ARATruthProcess::getProcessId(const TruthParticleContainer* TPC)
returns the process ID. so far works only for AODs or for DPD which contains the native SpclMC?/GEN_AOD information. The channel is anyhow recorded in the EventVariables? object. Maria Costa ported it to run with ACERMC samples as well.

   * 0xx indicates unknown type of event.                                                          *
   * 1xx indicates a true ttbar event.                                                             *
   * 2xx indicates a WW event.                                                                     *
   * 3xx indicates a WZ event.                                                                     *
   * 4xx indicates a ZZ event.                                                                     *
   * 5xx indicates a W+N jets event.                                                               *
   *                                                                                               *
   * 100 indicates a ttbar event of unknown type.                                                  *
   * 12x is a dileptonic ttbar decay.                                                              *
   * 14x is a semileptonic ttbar decay.                                                            *
   * 16x is a hadronic ttbar decay.                                                                *
   *                                                                                               *
   * 121 is a dileptonic decay with two electrons.                                                 *
   * 122 is a dileptonic decay with one electron, one muon.                                        *
   * 123 is a dileptonic decay with one electron, one tau.                                         *
   * 124 is a dileptonic decay with two muons.                                                     *
   * 125 is a dileptonic decay with one muon, one tau.                                             *
   * 126 is a dileptonic decay with two tau leptons.                                               *
   * 141 is a semileptonic decay to an electron, u and d quarks.                                   *
   * 142 is a semileptonic decay to an electron, c and s quarks.                                   *
   * 143 is a semileptonic decay to a muon, u and d quarks.                                        *
   * 144 is a semileptonic decay to a muon, c and s quarks.                                        *
   * 145 is a semileptonic decay to a tau (non hadronic decay) lepton, u and d quarks.                                  *
   * 146 is a semileptonic decay to a tau (non hadronic decay) lepton, c and s quarks.                                  *
   * 147 is a semileptonic decay to a tau (hadronic decay) lepton, u and d quarks                                  *
   * 148 is a semileptonic decay to a tau (hadronic decay) lepton, c and s quarks                                  *
   * 161 is a hadronic decay where both W bosons decay to u and d quarks.                          *
   * 162 is a hadronic decay where one W boson decays to u and d quarks, the other to c and s.     *
   * 163 is a hadronic decay where both W bosons decay to c and s quarks.                          *

const TruthParticle* ARATruthProcess::getLeptonicTopQuark(const TruthParticleContainer* TPC)
extracts the top true particle which decays semi-leptonically
const TruthParticle* ARATruthProcess::getLeptonicWBoson(const TruthParticleContainer* TPC)
returns a W-boson which decays leptonically
const TruthParticle* ARATruthProcess::getHadronicTopQuark(const TruthParticleContainer* TPC)
returns the hadronic top quark true particle
const TruthParticle* ARATruthProcess::getHadronicWBoson(const TruthParticleContainer* TPC)
returns the true hadronic W boson which decays hadronically

Tools for Trigger studies

the Trigger information is stored in the UserDataTree?. We store all the menu-items and whether they are passed or failed. Prescales are stored

  • src/ARATrigger.cxx : the source code implementing the different methods
  • src/TriggerHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm. It includes the UserDataSvc? call sequence

Event shape variables

On top of all the previous algorithms, we store in the DPD an object called EventVariables with relevant variables for a multivariate analysis
  • src/ARAEventVariables.cxx : the source code implementing the different methods
  • src/EventVariablesHandler.cxx : the ATHENA Algorithm wrapper which allows us to call it as an ATHENA algorithm. It includes the UserDataSvc? call sequence

Software installation

The ARATopQuarkAnalysis installation is rather easy. You need first to set your ATHENA environment for release 14.2.21. In these sections, we show how to install it, at CERN, CCIN2P3 and LPC. The latest package tag is not expected to compile with releases older than ATHENA release 15 (tag above ARATopQuarkAnalysis-00-00-82)

Installation at CERN

Installing release 14.2.21 on lxplus

first connect on LXPLUS and configure your ATHENA
ssh lxplus.cern.ch

Create your working area. Several approaches can be used. We present the most simplistic one. Check first that you've got a $HOME/scratch0 area. If not, you need to ask for one. The next thing to do is to check whether you've got enough space by using the fs lq command: We first symlink the <scratch0 to athena. This will allow us to have the same framework, on LXPLUS, CCALISL432 and CLRATLSERV04

# 
cd $HOME
ln -sf $HOME/scratch0 athena
Then, we prepare our ATHENA environment. First we create a directory for release 14.2.21
cd $HOME/athena
mkdir 14.2.21
cd 14.2.21
In directory 14.2.21, create a file 14.2.21.setup that you need to source each time you want to use ATHENA. This file looks like this:
# we want to use the AtlasOffline 14.2.21 with the 32 mode bit mode.
source /afs/cern.ch/atlas/software/releases/14.2.21/cmtsite/setup.sh -tag=AtlasOffline,14.2.21,setup,32
source /afs/cern.ch/atlas/software/releases/14.2.21/AtlasOffline/14.2.21/AtlasOfflineRunTime/cmt/setup.sh
# We prepend the CMTPATH with our TEST_AREA
export CMTPATH=$HOME/athena/14.2.21:$CMTPATH
export CVS_RSH="ssh"
export CVSROOT=":ext:`logname`@atlas-sw.cern.ch:/atlascvs"

Then, simply source the $HOME/athena/14.2.21/14.2.21.setup script and your ATHENA environment will be configured. Do this each time you want to use ATHENA.

cd $HOME/athena/14.2.21
source 14.2.21.setup
You can check your CMTPATH variable, by simply doing an echo $CMTPATH

Now you're ready to install the software. Go to section

Installation at CCIN2P3

Installing the ARATopQuarkAnalysis on ccalisl432 nodes requires first to setup the ssh client such that we don't give our password each time we want to checkout an ATHENA package.

setting up the ssh authentification at CCIN2P3

first connect to the ccalisl432.in2p3.fr. Then use the ssh-keygen command to generate both private and public keys. the private key, you will keep it on ccalisl432 whereas the public key, will be put on the machine you want to login to without password

ssh ccalisl432.in2p3.fr
ssh-keygen -t rsa
# don't give any passphrase
this will generate two files idid_rsa and id_rsa.pub in the $HOME/.ssh directory. The id_rsa.pub as we will see needs to be copied to lxplus. Then, we need to add to the $HOME/.ssh/ the following config file.
Host atlas-sw.cern.ch
StrictHostKeyChecking no
ForwardX11 no

Then, we need to add the id_rsa.pub. before that we need to make sure that we have the right domain name. edit the id_rsa.pub file, and check that we have the right domain name: .in2p3.fr

Let's continue with the configuration on the ssh server side:

# connect to lxplus
ssh lxplus.cern.ch

# generate the ssh keys (if you want for instance to connect to another machine from lxplus without password)
ssh-keygen -t rsa

# copy from ccalisl432.in2p3.fr the public key and put it in your public directory. we call it authorized_keys
# this is required since we have to deal with AFS tokens...
cd $HOME/public
scp ccalisl432.in2p3.fr:.ssh/id_rsa.pub authorized_keys
cd $HOME/.ssh

# we symlink it from the $HOME/.ssh directory
ln -sf $HOME/public/authorized_keys

Then connect to ccalisl432.in2p3.fr and try to connect without password. If you followed closely the previous steps, it should work. But, you need to be aware of one thing: ssh and AFS are two different things. You managed to login lxplus, but you don't have AFS rights (even if it's your $HOME directory. In order to be able to work on lxplus, you need to do a kinit and provide again your password.

kinit
You can of course always comment in the authorized_keys file, the public key of the computer from which you connect to lxplus. All what we explained here is for cvs purposes only!

Now you're ready to configure ATHENA.

installing ARATopQuarkAnalysis at CCIN2P3

Installing release 14.2.21 on ccalisl432
We try to keep a similar directory structure as the one that we presented previously for the installation when using lxplus. We first create a directory $HOME/athena

# 
cd $HOME
mkdir $HOME/athena
Then, we prepare our ATHENA environment. First we create a directory for release 14.2.21
cd $HOME/athena
mkdir 14.2.21
cd 14.2.21
In directory 14.2.21, create a file 14.2.21.setup that you need to source each time you want to use ATHENA. This file looks like this:
# we want to use the AtlasOffline 14.2.21 with the 32 mode bit mode.

source /afs/in2p3.fr/group/atlas/sw/prod/releases/rel_14-5/cmtsite/setup.sh -tag=AtlasOffline,14.2.21,setup,32
source /afs/in2p3.fr/group/atlas/sw/prod/releases/rel_14-5/AtlasOffline/14.2.21/AtlasOfflineRunTime/cmt/setup.sh
export CMTPATH=$HOME/athena/14.2.21:$CMTPATH

export CVS_RSH="ssh"
export CVSROOT=':ext:YOURLOGINFORLXPLUS@atlas-sw.cern.ch:/atlascvs'

Then, simply source the $HOME/athena/14.2.21/14.2.21.setup script and your ATHENA environment will be configured. Do this each time you want to use ATHENA.
cd $HOME/athena/14.2.21
source 14.2.21.setup
You can check your CMTPATH variable, by simply doing an echo $CMTPATH

Now you're ready to install the software. Go to section

Installation at LPC

This part is redundant to what is explained for ccalisl432.in2p3. Follow the explanation given in the section given above. Installing the ARATopQuarkAnalysis on clratlserv04 node (or any node from which you can have access to /AtlasDisk where the ATHENA kit is installed, requires first to setup the ssh client such that we don't give our password each time we want to checkout an ATHENA package.

setting up the ssh authentification at LPC

first connect to the clratlserv04.in2p3.fr. Then use the ssh-keygen command to generate both private and public keys. the private key, you will keep it on clratlserv04 whereas the public key, will be put on the machine you want to login to without password
ssh clratlserv04.in2p3.fr
ssh-keygen -t rsa
# don't give any passphrase!!!
this will generate two files id_rsa and id_rsa.pub in the $HOME/.ssh directory. The id_rsa.pub as we will see needs to be copied to lxplus. Then, we need to add to the $HOME/.ssh/ the following config file.
Host atlas-sw.cern.ch
StrictHostKeyChecking no
ForwardX11 no

Then, we need to add the id_rsa.pub. before that we need to make sure that we have the right domain name. edit the id_rsa.pub file, and check that we have the right domain name: .in2p3.fr

Let's continue with the configuration on the ssh server side:

# connect to lxplus
ssh lxplus.cern.ch

# generate the ssh keys (if you want for instance to connect to another machine from lxplus without password)
ssh-keygen -t rsa

# copy from clratlserv04.in2p3.fr the public key and put it in your public directory. we call it authorized_keys
# this is required since we have to deal with AFS tokens...
cd $HOME/public
# if the $HOME/public/authorized_keys file exists already, you need to simply append it with the clratlserv04 public key!
scp clratlserv04.in2p3.fr:.ssh/id_rsa.pub authorized_keys
cd $HOME/.ssh

# we symlink it from the $HOME/.ssh directory
ln -sf $HOME/public/authorized_keys

Then connect to clratlserv04.in2p3.fr and try to connect to CERN lxplus nodes without password. If you followed closely the previous steps, it should work. But, you need to be aware of one thing: ssh and AFS are two different things. You managed to login lxplus, but you don't have AFS rights (even if it's your $HOME directory. In order to be able to work on lxplus, you need to do a kinit and provide again your password.

kinit
You can of course always comment in the authorized_keys file, the public key of the computer from which you connect to lxplus. All what we explained here is for cvs purposes only!

Now you're ready to configure ATHENA.

installing ARATopQuarkAnalysis at LPC

The ATHENA kit is installed on /AtlasDisk/. Any node which can see this disk, can be used.Here we use clratlserv04

Installing release 14.2.21 on clratlserv04
We try to keep a similar directory structure as the one that we presented previously for the installation when using lxplus. We first create a directory $HOME/athena

# 
cd $HOME
mkdir $HOME/athena
Then, we prepare our ATHENA environment. First we create a directory for release 14.2.21
cd $HOME/athena
mkdir 14.2.21
cd 14.2.21
In directory 14.2.21, create a file 14.2.21.setup that you need to source each time you want to use ATHENA. This file looks like this:
#!/bin/bash 

MY_ATHENA_TEST_AREA=/users/divers/atlas/$LOGNAME/athena/14.2.21 

# use AtlasOffline
source /AtlasDisk/software/releases/14.2.21/cmtsite/setup.sh -tag=AtlasOffline,14.2.21,setup
# runtime
source /AtlasDisk/software/releases/14.2.21/AtlasOffline/14.2.21/AtlasOfflineRunTime/cmt/setup.sh

# prepend with my working area
export CMTPATH=${MY_ATHENA_TEST_AREA}:$CMTPATH

export CVS_RSH="ssh"
export CVSROOT=':ext:YOURLOGINFORLXPLUS@atlas-sw.cern.ch:/atlascvs'

Then, simply source the $HOME/athena/14.2.21/14.2.21.setup script and your ATHENA environment will be configured. Do this each time you want to use ATHENA.

cd $HOME/athena/14.2.21
source 14.2.21.setup
You can check your CMTPATH variable, by simply doing an echo $CMTPATH

Now you're ready to install the software. Go to section

Installation

Athena 14.2.21

Simply source the $HOME/athena/14.2.21/14.2.21.setup script and your ATHENA environment will be configured. Do this each time you want to use ATHENA.

cd $HOME/athena/14.2.21
source 14.2.21.setup
You can check your CMTPATH variable, by simply doing an echo $CMTPATH

In order to be able to use AthenaROOTAccess?, and the UserDataSvc?, you need to check out the relevant packages. These are listed in these twiki: AthenaROOTAccess and UserDataSvc

Let's check first the required tags for AthenaROOTAccess?

# go the the TEST_AREA
cd $HOME/athena/14.2.21
# check out the packages
cmt co -r AthenaROOTAccess-00-05-26          PhysicsAnalysis/AthenaROOTAccess
cmt co -r TrigInDetTruthEvent-00-00-20       Trigger/TrigTruthEvent/TrigInDetTruthEvent
cmt co -r  DataModelAthenaPool-01-04-02      Control/DataModelAthenaPool
cmt co -r  TrigEventTPCnv-00-00-71           Trigger/TrigEvent/TrigEventTPCnv                                       <-------------------------- this package might not compile, since CMT assumes /usr/lib/libgfortran.so.1 being present!
cmt co -r  TrigEventAthenaPool-00-01-52      Trigger/TrigEvent/TrigEventAthenaPool
cmt co -r  TrigTruthEventTPCnv-00-00-06      Trigger/TrigTruthEvent/TrigTruthEventTPCnv
cmt co -r  TrigTruthEventAthenaPool-00-00-05 Trigger/TrigTruthEvent/TrigTruthEventAthenaPool
cmt co -r PyDumper-00-00-08 Event/PyDumper
Same for UserDataSvc?:
cmt co -r AthenaServices-01-33-08            Control/AthenaServices             
cmt co -r  AthenaKernel-00-21-01-06       Control/AthenaKernel             
cmt co -r UserDataExamples-00-04-06      Control/AthenaExamples/UserDataExamples
cmt co -r AraTool-00-01-04                        PhysicsAnalysis/AraTool
cmt co -r AraToolExample-00-01-03      PhysicsAnalysis/AraToolExample          

Then, you need to compile all these packages, once for all. to do this, use the cmt br source setup.sh; cmt br make command which will compile them properly.

cd $HOME/athena/14.2.21
cd Control/AthenaExamples/UserDataExamples/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.21
cd PhysicsAnalysis/AraToolExample/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.21
cd PhysicsAnalysis/AthenaROOTAccess/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.21
cd Control/DataModelAthenaPool/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.21
cd Trigger/TrigTruthEvent/TrigInDetTruthEvent/cmt
cmt br source setup.sh; cmt br make

# etc...

In order to be able to use the CompositeParticle?, you need to check out this package tag, not available with 14.2.21

cd  $HOME/athena/14.2.21
cmt co -r ParticleEventTPCnv-00-01-06 PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv
cd PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/cmt
cmt br source setup.sh; cmt br make

Now, we are ready to download the ARATopQuarkAnalysis package and compile it. Let's install the ARATopQuarkAnalysis. In order to be able to use it for GRID job submition, you need to put it in a directory known to GANGA

cd $HOME/athena/14.2.21
cd PhysicsAnalysis
cvs co -d ARATopQuarkAnalysis groups/LPC/ARATopQuarkAnalysis
cd  ARATopQuarkAnalysis/cmt
cmt config
cmt br source setup.sh; cmt br make
If you did not manage to compile this package, let me know.

Athena 14.2.24

Simply source the $HOME/athena/14.2.24/14.2.24.setup script and your ATHENA environment will be configured. Do this each time you want to use ATHENA.

cd $HOME/athena/14.2.24
source 14.2.24.setup
You can check your CMTPATH variable, by simply doing an echo $CMTPATH

In order to be able to use AthenaROOTAccess?, and the UserDataSvc?, you need to check out the relevant packages. These are listed in these twiki: AthenaROOTAccess and UserDataSvc

Let's check first the required tags for AthenaROOTAccess?

# go the the TEST_AREA
cd $HOME/athena/14.2.24
# check out the packages
cmt co -r AthenaROOTAccess-00-05-29          PhysicsAnalysis/AthenaROOTAccess
cmt co -r TrigInDetTruthEvent-00-00-20       Trigger/TrigTruthEvent/TrigInDetTruthEvent
cmt co -r  DataModelAthenaPool-01-04-02      Control/DataModelAthenaPool
cmt co -r EventBookkeeperAthenaPool-00-00-02 Event/EventBookkeeperAthenaPool
cmt co -r EventBookkeeperMetaData-00-00-04 Event/EventBookkeeperMetaData
cmt co -r EventBookkeeperTools-00-00-03 Event/EventBookkeeperTools
cmt co -r EventBookkeeperTPCnv-00-00-03 Event/EventBookkeeperTPCnv

Same for UserDataSvc:

cmt co -r AthenaServices-01-33-07-07            Control/AthenaServices             
cmt co -r  AthenaKernel-00-21-01-51       Control/AthenaKernel             
cmt co -r UserDataExamples-00-04-06      Control/AthenaExamples/UserDataExamples
cmt co -r AraTool-00-01-04                        PhysicsAnalysis/AraTool
cmt co -r AraToolExample-00-01-03      PhysicsAnalysis/AraToolExample   

If you need the Trigger Package

cmt co -r TrigInDetTruthEvent-00-00-20       Trigger/TrigTruthEvent/TrigInDetTruthEvent
cmt co -r  TrigTruthEventTPCnv-00-00-06      Trigger/TrigTruthEvent/TrigTruthEventTPCnv
cmt co -r  TrigTruthEventAthenaPool-00-00-05 Trigger/TrigTruthEvent/TrigTruthEventAthenaPool

If you install the Trigger Package you have to go into the directory :

Trigger/TrigTruthEvent/TrigTruthEventTPCnv/cmt
and add those two lines at the end of the setup file:
macro_remove FORTRAN_libset "$(GFO)/$(GFO_LIBS)/libgfortran.so.1"
macro_remove AtlasFortranPolicy_linkopts "$(GFO)/$(GFO_LIBS)/libgfortran.so.1"

Then, you need to compile all these packages, once for all. to do this, use the cmt br source setup.sh; cmt br make command which will compile them properly.

cd $HOME/athena/14.2.24
cd Control/AthenaExamples/UserDataExamples/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.24
cd PhysicsAnalysis/AraToolExample/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.24
cd PhysicsAnalysis/AthenaROOTAccess/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.24
cd Control/DataModelAthenaPool/cmt
cmt br source setup.sh; cmt br make

cd $HOME/athena/14.2.24
cd Trigger/TrigTruthEvent/TrigInDetTruthEvent/cmt
cmt br source setup.sh; cmt br make

# etc...

In order to be able to use the CompositeParticle?, you need to check out this package tag, not available with 14.2.24

cd  $HOME/athena/14.2.24
cmt co -r ParticleEventTPCnv-00-01-06 PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv
cd PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/cmt
cmt br source setup.sh; cmt br make

Now, we are ready to download the ARATopQuarkAnalysis package and compile it. Let's install the ARATopQuarkAnalysis. In order to be able to use it for GRID job submition, you need to put it in a directory known to GANGA

cd $HOME/athena/14.2.24
cd PhysicsAnalysis
cvs co -d ARATopQuarkAnalysis groups/LPC/ARATopQuarkAnalysis
cd  ARATopQuarkAnalysis/cmt
cmt config
cmt br source setup.sh; cmt br make
If you did not manage to compile this package, let me know.

List of required tags for 14.5.2 (obsolete for tags above ARATopQuarkAnalysis-00-00-81)

This release works with a tag older than: ARATopQuarkAnalysis-00-00-81. You should upgrade to release 15, in order to get the ARALHAPDFTool to compile properly.

For release 14.5.2, you need to checkout only these two tags:

AthenaROOTAccess-00-05-43
Navigation-00-06-09-02

cd $HOME/athena/14.5.2
cmt co -r AthenaROOTAccess-00-05-43  PhysicsAnalysis/AthenaROOTAccess
cmt co -r Navigation-00-06-09-02  Control/Navigation
cd PhysicsAnalysis
cvs co -d ARATopQuarkAnalysis groups/LPC/ARATopQuarkAnalysis
cd  ARATopQuarkAnalysis/cmt
cmt config
cmt br source setup.sh; cmt br make
cd $HOME/athena/14.5.2/PhysicsAnalysis/AthenaROOTAccess
cd cmt
cmt br source setup.sh
cmt br make

In order to work with PYROOT, and be able to call all the above algorithms from ROOT, you need add at the beginning of your PYROOT session. First you need to import the uuid package (stands for univeral unique identifier used here to generate the uid from the host

 
          import uuid
           ROOT.AthenaBarCodeImpl.setDefaultHash (uuid.uuid1().hex)

List of required tags for 15.3.0 (RECOMMENDED)

the following installation instructions were tested with both releases 15.3.0 and 15.4.0 and are thus valid. We illustrate them for the case of 15.3.0.

The package was ported to release 15.2.0 and checked against the two compilers: gcc 3.4/gcc4.3.3 Here are the explanations on how to set it up.

First, you need to setup your ATHENA session

mkdir -p $HOME/athena/15.3.0/PhysicsAnalysis
cd $HOME/athena/15.3.0
In this folder, you will put this setup.sh script:
#!/bin/bash 
MY_ATHENA_RELEASE_AREA=/AtlasDisk/software/releases/15.3.0 
MY_ATHENA_TEST_AREA=/users/divers/atlas/ghodbane/athena/15.3.0 

source ${MY_ATHENA_RELEASE_AREA}/cmtsite/setup.sh -tag=AtlasProduction,15.3.0,setup,32
source ${MY_ATHENA_RELEASE_AREA}/AtlasProduction/15.3.0/AtlasProductionRunTime/cmt/setup.sh
export CMTPATH=${MY_ATHENA_TEST_AREA}:$CMTPATH
export TDAQ_ERS_NO_SIGNAL_HANDLERS=1

Then, you will simply source the setup.sh script.

Now, you can checkout the ARATopQuarkAnalysis You need first to setup CVS:

MY_LXPLUS_LOGIN=ghodbane <------------------ USE YOUR LOGIN!!!!!

You can then checkout the package:

export CVS_RSH="ssh"
export CVSROOT=":ext:${MY_LXPLUS_LOGIN}@atlas-sw.cern.ch:/atlascvs"

Finally you checkout the package:

cd  $HOME/athena/15.3.0/PhysicsAnalysis
cvs co -d ARATopQuarkAnalysis groups/LPC/ARATopQuarkAnalysis

You can then compile the package:

cd $HOME/athena/15.3.0/PhysicsAnalysis/ARATopQuarkAnalysis/cmt
cmt config
source setup.sh
make

You're ready to produce D2(3)PDs! and you can give it a try with the share/TopQuarkAnalysis_AODtoD3PD_jobOptions.py. Simply edit this script, fix the name for the AOD (it can be an AOD from release 14, it's fine and you will then produce the D3PD from the AOD like:

cd $HOME/athena/15.3.0/PhysicsAnalysis/ARATopQuarkAnalysis/run
source $HOME/athena/15.3.0/setup.sh
source $HOME/athena/15.3.0/PhysicsAnalysis/ARATopQuarkAnalysis/cmt/setup.sh
athena $HOME/athena/15.3.0/PhysicsAnalysis/ARATopQuarkAnalysis/share/TopQuarkAnalysis_AODtoD3PD_jobOptions.py &> log

This will produce a D3PD called D3PD.pool.root, that you can either analyse with with ROOT, or even better with pyROOT, through the macros/analysis_noBtag.py for instance!

Finally, you might have some troubles with the fix to the libgfortran.so if it's installed under /usr/lib, simply edit the requirements file and remove these two lines:

macro_remove FORTRAN_libset "$(GFO)/$(GFO_LIBS)/libgfortran.so.1"
macro_remove AtlasFortranPolicy_linkopts "$(GFO)/$(GFO_LIBS)/libgfortran.so.1"

Installing 15.5.2

First, you need to setup your ATHENA session

mkdir -p $HOME/athena/15.5.2/PhysicsAnalysis
cd $HOME/athena/15.5.2
In this folder, you will put this setup.sh script:
#!/bin/bash 
source /AtlasDisk/software/releases/15.5.2/cmtsite/setup.sh -tag=AtlasProduction,15.5.2,setup,32
source /AtlasDisk/software/releases/15.5.2/AtlasProduction/15.5.2/AtlasProductionRunTime/cmt/setup.sh
export CMTPATH=$HOME/athena/15.5.2:$CMTPATH

Then, you will simply source the setup.sh script.

You can then checkout the package:

export CVS_RSH="ssh"
export CVSROOT=":ext:${MY_LXPLUS_LOGIN}@atlas-sw.cern.ch:/atlascvs"
cd $HOME/athena/15.5.2/PhysicsAnalysis
cvs co -d ARATopQuarkAnalysis groups/LPC/ARATopQuarkAnalysis

Then you just need to compile your package.

cd $HOME/athena/15.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/cmt
cmt config
source setup.sh
make 

After the compilation, you need to fix one setup file :

emacs -nw $HOME/athena/15.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/setup.sh  <------------- Inside replace 15.6.1 by 15.5.2

DPD production

Introduction

The current atlas Event Data Model introduces a new data format, the Derived Physics Dataset (DPD) with the aim to reduce further the size of the analysis objects. Thus, a DPD is defined as a set of data which is a subset of ESD or AOD data content with the possible addition of analysis data, analysis data being defined as quantities derived from data in ESD or AOD. Reducing the size of an event is done in three steps:

* Skimming: selecting only interesting events based on some event level quantity like e.g.:

* number of electrons

* Missing ET

The skimming can be implemented cutting directly on TAG files.

* Thinning: selecting only interesting objects from a container, like e.g.:
* keep all electrons with pT > 20 GeV??
* Slimming: selecting only interesting properties of an object, like e.g.:
* drop some of the calorimeter informations out of an electron
Some useful acronyms that you need to be familiar with:
* A D1PD is defined as a centrally produced DPD from an AOD or a set of AODs using the working group DPD tool maker, like e.g. for the top working group: TopPhysDPDMaker?
* A D2PD is defined as a privately made, or customised DPD produced from a D1PD or an AOD or an ESD!
* A D3PD is defined as an ntuple made from a D1PD or a D2PD or an AOD. This is somehow similar to the EventView??/TopView/TopPhysDPDMaker approach.
The ARATopQuarkAnalysis, allows us to produce D2PD POOL files and analyse them. In the following sections, we show ho to do this.

Create a generic D2PD from an AOD

A set of python job-option files are provided, such that you can produce a D2PD. All these scripts are located in the ARATopQuarkAnalysis/share directory. Here we show how these scripts can be used to produce a D2PD from an AOD for release 14.5.2. The commands are relevant for all releases.

Production of a D2PD from an AOD.

configure as usual your ATHENA 14.5.2 session.
                source ~/athena/14.5.2/14.5.2.sh
                cd ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/
                source cmt/setup.sh

We will use this AOD merged Mcatnlo ttbar AOD, with about 5000 reconstructed events):

               mc08.105200.T1_McAtNlo_Jimmy.merge.AOD.e357_s462_d147_r641_t53_tid065446/AOD.065446._00047.pool.root.1

You can find this AOD on the grid and copy it locally, using the dq2-get tool (you need to setup your GRID environment to do that:

dq2-get -f AOD.065446._00047.pool.root.1 mc08.105200.T1_McAtNlo_Jimmy.merge.AOD.e357_s462_d147_r641_t53_tid065446

We can first check the AOD contents using the checkFile.py utility.

                checkFile.py /AtlasDisk/users/ghodbane/AOD/mc08.105200.T1_McAtNlo_Jimmy.merge.AOD.e357_s462_d147_r641_t53_tid065446/AOD.065446._00047.pool.root.1  &> AOD.contents
By looking at the contents of the AOD.contents, you will see all the container names, we will make use of to produce our D2PD. For instance, you will see a container called ElectronAODCollection
The ElectronAODCollection is an ElectronContainer (a container is something similar to a std::vector) of objects of type Analysis::Electron. Each of these objects is a reconstructed electrons and you can access to its reconstructed information (see src/ARAElectron.cxx to see how this is done in this case).

Now let's produce our D2PD!
use share/TopQuarkAODtoD2PD_jobOptions.py and produce a D2PD from this AOD. Let's look first at some of its contents:

You set the AOD name here:

#------------------------------------------------------------------------
# The AOD input file
if not 'm_AODName' in dir():
    m_AODName = 'AOD.pool.root'

Then these lines below tell ATHENA to load our libraries:

#------------------------------------------------------------------------
# give the library 
theApp.Dlls   += ["ARATopQuarkAnalysis"]
theApp.Dlls   += ["ARATopQuarkAnalysisDict"]
theApp.Dlls   += ["EventVariables"]
theApp.Dlls   += ["EventVariablesDict"]
theApp.Dlls   += ["TCompositeParticle"]
theApp.Dlls   += ["TCompositeParticleContainer"]
theApp.Dlls   += ["TCompositeParticleDict"]

The truth top and W/Z boson vertices are extracted from the GEN_AOD container by this call sequence:

#------------------------------------------------------------------------
#- use this already implemented Filter for finding our light jets
from McParticleAlgs.McParticleAlgsConf import McAodFilter
thisAlg = Algorithm( "McAodFilter" )
thisAlg.DoGenAod                           = True
thisAlg.McVtxFilterTool.McEvents           = "GEN_AOD"
thisAlg.McVtxFilterTool.McEventsOutput     = "R_GEN_AOD"
thisAlg.McVtxFilterTool.DoSignalProcessVtx = True
thisAlg.McVtxFilterTool.DecayPatterns  = [ "6 -> 24 + 5" ]
# W-boson vertices
thisAlg.McVtxFilterTool.DecayPatterns += [ "24 -> 1|2|3|4|5|-1|-2|-3|-4|-5 + 1|2|3|4|5" ]
thisAlg.McVtxFilterTool.DecayPatterns += [ "24 -> 11|13|15 + -12|-14|-16" ]
# Z0 bosonvertices
thisAlg.McVtxFilterTool.DecayPatterns += [ "23 -> 1|2|3|4|5|6 + -1|-2|-3|-4|-5|-6" ]
thisAlg.McVtxFilterTool.DecayPatterns += [ "23 -> 11|12|13|14|15|16 + -11|-12|-13|-14|-15|-16" ]
# Location of the AOD-like collection
thisAlg.DoTruthParticles                          = True
thisAlg.TruthParticleCnvTool.McEvents             = "R_GEN_AOD"
thisAlg.TruthParticleCnvTool.TruthParticlesOutput = "R_SpclMC"
thisAlg.OutputLevel                      = INFO
thisAlg.McVtxFilterTool.OutputLevel      = INFO
thisAlg.TruthParticleCnvTool.OutputLevel = INFO
topSequence +=[thisAlg]

The ARATopQuarkAnalysis algorithms are then imported

from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import ElectronHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import PhotonHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import MuonHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import TauHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import ParticleJetHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import BJetHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import EventVariablesHandler
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import HadronicWBosonBuilder
from ARATopQuarkAnalysis.ARATopQuarkAnalysisConf import HadronicTopQuarkBuilder
The our selection algorithms are implemented. For instance, to dump all electrons into our D2PD, we do:
#------------------------------------------------------------------------
thisAlg = ParticleJetHandler("R_ParticleJetHandler")
thisAlg.InputParticleJetContainerName    = "Cone4H1TowerJets"
thisAlg.CutJetPt        =  0*GeV
thisAlg.CutJetEta       =  10.0
thisAlg.OutputParticleJetContainerName   = "R_Jets"
# add this algorithm to the algorithm sequence!
topSequence +=[thisAlg]

The top analysis selection with b-tagging is implemented like:

#------------------------------------------------------------------------
#                             Two b-tag analysis (TB)
#------------------------------------------------------------------------

#------------------------------------------------------------------------
thisAlg = BJetHandler("B_BJetHandler")
thisAlg.InputBJetContainerName           = "Cone4H1TowerJets"
thisAlg.OutputBJetContainerName          = "B_BJets"
thisAlg.CutJetPt        =  40*GeV
thisAlg.CutJetEta       =  2.5
thisAlg.CutBJetWeight   =  6
topSequence +=[thisAlg]

#------------------------------------------------------------------------
thisAlg = ElectronHandler("B_ElectronHandler")
thisAlg.InputElectronContainerName   = "ElectronAODCollection"
thisAlg.CutElectronPt    =  20*GeV
thisAlg.CutElectronEta   =  2.5
thisAlg.CutElectronIsolationEnergy = 6*GeV
#- electron Identification a set of standard masks/cuts applied to the Analysis::Electron::isem() flag
#  0 -> egammaPID::ElectronLoose  (default)
#  1 -> egammaPID::ElectronMedium 
#  2 -> egammaPID::ElectronTight
thisAlg.CutElectronIdentification = 1
# we require that this electron matches a track
thisAlg.CutElectronTrackMatch = True
# we want this electron not to overlap with an already inserted b-jet
thisAlg.InputParticleJetContainerName   = "B_BJets"
# overlap cut for electrons-b-jets
thisAlg.CutDeltaRElectronJet = 0.4
# these good electrons output container
thisAlg.OutputElectronContainerName  = "B_Electrons"
# add this algorithm to the algorithm sequence
topSequence +=[thisAlg]

#------------------------------------------------------------------------
thisAlg = MuonHandler("B_MuonHandler")
thisAlg.InputMuonContainerName   = "StacoMuonCollection"
thisAlg.InputParticleJetContainerName   = "B_BJets"
thisAlg.OutputMuonContainerName  = "B_Muons"
thisAlg.CutMuonPt    =  20*GeV
thisAlg.CutMuonEta   =  2.5
thisAlg.CutMuonIsolationEnergy   =  6*GeV
thisAlg.CutMuonIsHighPt = True
thisAlg.CutDeltaRMuonJet = 0.4
topSequence +=[thisAlg]

#------------------------------------------------------------------------
thisAlg = ParticleJetHandler("B_ParticleJetHandler")
thisAlg.InputParticleJetContainerName    = "Cone4H1TowerJets"
thisAlg.InputBJetContainerName           = "B_BJets"
thisAlg.InputElectronContainerName       = "B_Electrons"
thisAlg.InputMuonContainerName           = "B_Muons"
thisAlg.CutJetPt        =  20*GeV
thisAlg.CutJetEta       =  2.5
thisAlg.CutDeltaRJetCharge   =  0.4
thisAlg.CutDeltaRJetBJet     =  0.4
thisAlg.CutDeltaRJetElectron =  0.4
thisAlg.CutDeltaRJetMuon     =  0.4
thisAlg.OutputParticleJetContainerName   = "B_LightJets"
topSequence +=[thisAlg]

#------------------------------------------------------------------------
thisAlg = HadronicWBosonBuilder("HadronicWBosonBuilder_M0")
thisAlg.InputParticleJetContainerName    = "B_LightJets"
thisAlg.OutputHadronicWBosonContainerName= "B_w_jj_M0"
# W-boson reconstruction methods
# 0 -> all combinations
# 1 -> closest in delta R
thisAlg.ReconstructionMethod             = 0
topSequence +=[thisAlg]

#------------------------------------------------------------------------
thisAlg = HadronicWBosonBuilder("HadronicWBosonBuilder_M1")
thisAlg.InputParticleJetContainerName    = "B_LightJets"
thisAlg.OutputHadronicWBosonContainerName= "B_w_jj_M1"
# W-boson reconstruction methods
# 0 -> all combinations
# 1 -> closest in delta R
thisAlg.ReconstructionMethod             = 1
topSequence +=[thisAlg]

#------------------------------------------------------------------------
thisAlg = HadronicTopQuarkBuilder("B_HadronicTopQuarkBuilder_M1")
thisAlg.InputParticleJetContainerName    = "B_LightJets"
thisAlg.InputBJetContainerName    = "B_BJets"
thisAlg.OutputHadronicTopQuarkContainerName= "B_t_bjj_M1"
# hadronic top reconstruction methods
# 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
# 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
# 2 -> find the three jets the closest in delta R (no b-tagging)
# 3 -> find the three jets the closest in delta R (with b-tagging)
# 4 -> find the b-jet closest to the hadronic W boson 
# 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
# 6 -> all combinations without b-tagging
# 7 -> all combinations with b-tagging
thisAlg.ReconstructionMethod             = 1
topSequence +=[thisAlg]

#------------------------------------------------------------------------
# hadronic Top Quark candidates
thisAlg = HadronicTopQuarkBuilder("B_HadronicTopQuarkBuilder_M3")
thisAlg.InputParticleJetContainerName    = "B_LightJets"
thisAlg.InputBJetContainerName    = "B_BJets"
thisAlg.OutputHadronicTopQuarkContainerName= "B_t_bjj_M3"
# hadronic top reconstruction methods
# 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
# 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
# 2 -> find the three jets the closest in delta R (no b-tagging)
# 3 -> find the three jets the closest in delta R (with b-tagging)
# 4 -> find the b-jet closest to the hadronic W boson 
# 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
# 6 -> all combinations without b-tagging
# 7 -> all combinations with b-tagging
thisAlg.ReconstructionMethod             = 3
topSequence +=[thisAlg]

#------------------------------------------------------------------------
# hadronic Top Quark candidates
thisAlg = HadronicTopQuarkBuilder("B_HadronicTopQuarkBuilder_M4_w_jj_M0")
thisAlg.InputBJetContainerName           = "B_BJets"
thisAlg.InputHadronicWBosonContainerName  = "B_w_jj_M0"
thisAlg.OutputHadronicTopQuarkContainerName= "B_t_bjj_M4_w_jj_M0"
# hadronic top reconstruction methods
# 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
# 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
# 2 -> find the three jets the closest in delta R (no b-tagging)
# 3 -> find the three jets the closest in delta R (with b-tagging)
# 4 -> find the b-jet closest to the hadronic W boson 
# 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
# 6 -> all combinations without b-tagging
# 7 -> all combinations with b-tagging
thisAlg.ReconstructionMethod             = 4
topSequence +=[thisAlg]

#------------------------------------------------------------------------
# hadronic Top Quark candidates
thisAlg = HadronicTopQuarkBuilder("B_HadronicTopQuarkBuilder_M4_w_jj_M1")
thisAlg.InputBJetContainerName           = "B_BJets"
thisAlg.InputHadronicWBosonContainerName  = "B_w_jj_M1"
thisAlg.OutputHadronicTopQuarkContainerName= "B_t_bjj_M4_w_jj_M1"
# hadronic top reconstruction methods
# 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
# 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
# 2 -> find the three jets the closest in delta R (no b-tagging)
# 3 -> find the three jets the closest in delta R (with b-tagging)
# 4 -> find the b-jet closest to the hadronic W boson 
# 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
# 6 -> all combinations without b-tagging
# 7 -> all combinations with b-tagging
thisAlg.ReconstructionMethod             = 4
topSequence +=[thisAlg]

#------------------------------------------------------------------------
# hadronic Top Quark candidates
thisAlg = HadronicTopQuarkBuilder("B_HadronicTopQuarkBuilder_M5_w_jj_M1")
thisAlg.InputBJetContainerName           = "B_BJets"
thisAlg.InputHadronicWBosonContainerName  = "B_w_jj_M1"
thisAlg.OutputHadronicTopQuarkContainerName= "B_t_bjj_M5_w_jj_M1"
# hadronic top reconstruction methods
# 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
# 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
# 2 -> find the three jets the closest in delta R (no b-tagging)
# 3 -> find the three jets the closest in delta R (with b-tagging)
# 4 -> find the b-jet closest to the hadronic W boson 
# 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
# 6 -> all combinations without b-tagging
# 7 -> all combinations with b-tagging
thisAlg.ReconstructionMethod             = 5
topSequence +=[thisAlg]

#------------------------------------------------------------------------
# Event variables
thisAlg = EventVariablesHandler("EventVariablesHandler")
thisAlg.InputParticleJetContainerName     = "B_LightJets"
thisAlg.InputBJetContainerName            = "B_BJets"
thisAlg.InputElectronContainerName        = "B_Electrons"
thisAlg.InputMuonContainerName            = "B_Muons"
thisAlg.InputMcEventCollectionName        = "GEN_AOD"
thisAlg.InputTruthParticleContainerName   = "SpclMC"
thisAlg.OutputEventVariablesContainerName = "B_EventVariables"
topSequence +=[thisAlg]

Finally, the objects selected or built by the algorithms are stored into our D2PD by this call sequence:

#------------------------------------------------------------------------
from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
StreamDPD = MSMgr.NewStream( "StreamDPD" )
# event book-keepers
StreamDPD.AddMetaDataItem("EventBookkeeperCollection#EventBookkeepers")
# Metadata
StreamDPD.AddMetaDataItem('IOVMetaDataContainer#*')
# Lumiblock
StreamDPD.AddMetaDataItem('LumiBlockCollection#*')
#
StreamDPD.AddItem('EventInfo#*')
# Missing ET
StreamDPD.AddItem('MissingET#MET_RefFinal')
StreamDPD.AddItem('ElectronContainer#R_Electrons')
StreamDPD.AddItem('egDetailContainer#egDetailAOD')
StreamDPD.AddItem('Analysis::MuonContainer#R_Muons')
# Clusters (useful for rerunning a jet algorithm for instance)
StreamDPD.AddItem('CaloClusterContainer#CaloCalTopoCluster')
StreamDPD.AddItem('CaloClusterContainer#egClusterCollection')
# Jets
StreamDPD.AddItem('JetCollection#R_Jets')
# Jet Key Mapping (still required for b-tagging, i guess)
StreamDPD.AddItem('JetKeyDescriptor#JetKeyMap')
# Truth
StreamDPD.AddItem('TruthParticleContainer#SpclMC')
StreamDPD.AddItem('McEventCollection#GEN_AOD')
StreamDPD.AddItem('TruthParticleContainer#R_SpclMC')
StreamDPD.AddItem('McEventCollection#R_GEN_AOD')
# Track particle candidates
StreamDPD.AddItem('Rec::TrackParticleContainer#TrackParticleCandidate')
StreamDPD.AddItem('Rec::TrackParticleContainer#StacoTrackParticles')
StreamDPD.AddItem('JetCollection#R_quarks')
StreamDPD.AddItem('CompositeParticleContainer#R_w_qq_M1')
StreamDPD.AddItem('EventVariables#R_EventVariables')
# objects for the 2-b tag analysis
StreamDPD.AddItem('JetCollection#B_BJets')
StreamDPD.AddItem('Analysis::MuonContainer#B_Muons')
StreamDPD.AddItem('ElectronContainer#B_Electrons')
StreamDPD.AddItem('JetCollection#B_LightJets')
StreamDPD.AddItem('CompositeParticleContainer#B_w_jj_M0')
StreamDPD.AddItem('CompositeParticleContainer#B_w_jj_M1')
StreamDPD.AddItem('CompositeParticleContainer#B_t_bjj_M1')
StreamDPD.AddItem('CompositeParticleContainer#B_t_bjj_M3')
StreamDPD.AddItem('CompositeParticleContainer#B_t_bjj_M4_w_jj_M0')
StreamDPD.AddItem('CompositeParticleContainer#B_t_bjj_M4_w_jj_M1')
StreamDPD.AddItem('CompositeParticleContainer#B_t_bjj_M5_w_jj_M1')
StreamDPD.AddItem('EventVariables#B_EventVariables')
# objects for the 0-b tag analysis
StreamDPD.AddItem('Analysis::MuonContainer#Z_Muons')
StreamDPD.AddItem('ElectronContainer#Z_Electrons')
StreamDPD.AddItem('JetCollection#Z_Jets')
StreamDPD.AddItem('CompositeParticleContainer#Z_w_jj_M0')
StreamDPD.AddItem('CompositeParticleContainer#Z_w_jj_M1')
StreamDPD.AddItem('CompositeParticleContainer#Z_t_bjj_M0')
StreamDPD.AddItem('CompositeParticleContainer#Z_t_bjj_M2')
StreamDPD.AddItem('EventVariables#Z_EventVariables')
# trigger LVL1
StreamDPD.AddItem("LVL1_ROI#LVL1_ROI")

The totla number of events is set at this line (set it to -1 if you want to process all events):

#------------------------------------------------------------------------
# Number of Events to process
theApp.EvtMax = 100

Let's run this script:

 
         source ~/athena/14.5.2/14.5.2.sh
                        source ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/cmt/setup.sh
         cd ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/run
                        athena ../share/TopQuarkAODtoD2PD_jobOptions.py &> log.AODtoD2PD
                       less log.AODtoD2PD
You will produce a D2PD (a ROOT/POOL file) called StreamDPD.pool.root with the ATHENA objects you set in:
StreamDPD = MSMgr.NewStream( "StreamDPD" )
You can of course check that it contains the objects you wanted to store in it, by using the checkFile.py utility:
                         checkFile.py StreamDPD.pool.root

You can then use this D2PD and make some plots through the AthenaROOTAccess?, like:

                        get_files test.py
Then, edit the test.py and change
                                aodFile = 'AOD.pool.root'
to
                                aodFile = 'StreamDPD.pool.root'

you can then start pyROOT and plot for instance the phi distributions for the electrons selected with the b-tagging analysis!

                                pyroot.py -i test.py
                                tt.Draw('B_Electrons.phi()')

Create a D3PD from this D2PD

to create a D3PD from the StreamDPD.pool.root produced in the previous section, simply use the script share/TopQuarkAnalysis_D2PDtoD3PD_jobOptions.py. It should produce a ROOT file called D3PD.pool.root with a TTree called D3PD. Again, you can use the pyROOT to view its branches.
            pyroot.py -i
            from ROOT import *
            f = TFile.Open('D3PD.pool.root')
            D3PD = f.Get('D3PD') 
            D3PD.Print()
            D3PD.Draw('Z_w_jj_M1_m:Z_t_bjj_M0_m')

Now, you can use the pyROOT analysis package to analyse these D3PD.

Create a ROOT-uple (D3PD) from the AOD

You can easily create a D3PD from the AOD. a script called share/TopQuarkAnalysis_AODtoD3PD_jobOptions.py is provided and dumps from an AOD a D3PD.pool.root file with the selected objects for an analysis with or without b-tagging To produce the D3PD from the AOD, you need to
         source ~/athena/14.5.2/14.5.2.sh
         source ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/cmt/setup.sh
         cd ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/run
         athena ../share/TopQuarkAODtoD3PD_jobOptions.py &> log.AODtoD3PD   
The produced D3PD.pool.root can be viewed with pyROOT:
            pyroot.py -i
            from ROOT import *
            f = TFile.Open('D3PD.pool.root')
            D3PD = f.Get('D3PD') 
            D3PD.Print()
            D3PD.Draw('Z_w_jj_M1_m:Z_t_bjj_M0_m')

It can be used to perform an analysis with the macros/analysis_noBtag.py or macros/analysis_2btag.py macros.

Create a HBOOK-uple (D3PD) from the AOD

In order to create an HBOOK file, you simply need to use the share/TopQuarkAnalysis_HBOOK_jobOptions.py script, which will simply dump jets, electrons, muons, Trigger information, etc... into an HBOOK file you can then analyse with the PAW.
         source ~/athena/14.5.2/14.5.2.sh
         source ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/cmt/setup.sh
         cd ~/athena/14.5.2/PhysicsAnalysis/ARATopQuarkAnalysis/run
         athena ../share/TopQuarkAnalysis_HBOOK_jobOptions.py &> log.AODtoHBOOK   
The produced d3pd.pool.hbook can be analysed with paw.
paw
hi/fil 1 d3pd.pool.hbook
You can view all variables implemented in this D3PD HBOOK file, by looking into the /HBOOK.Contents file. You can additional ones, by looking into the src/HBOOKDumper.cxx file and the classes which are called there.

Produce D2PD with the GRID using GANGA

A set of scripts to run large scale production with GANGA is provided in the grid directory. you can also find some scripts in directory scripts to use batch mode systems like e.g. BQS.

PyROOT? and C++ analysis

The D3PD analysis implemented through the macros/analyser.py macro! See it below:

import os
import sys
import getopt
import string
import random
import re
import time
import string
import user
try:
    import ROOT
    import uuid
    ROOT.AthenaBarCodeImpl.setDefaultHash (uuid.uuid1().hex)
    from  GaudiKernel.SystemOfUnits import GeV,picobarn
    from ROOT import D3PDReader
    from ROOT import ARAElectron
    from ROOT import ARAMuon
    from ROOT import ARABJet
    from ROOT import ARAParticleJet
    from ROOT import ARAMissingET
    from ROOT import ARAHadronicWBosonBuilder
    from ROOT import ARAHadronicTopQuarkBuilder
    from ROOT import ARATTbarLeptonJetsBuilder
    from ROOT import ARATruthProcess
except:
    sys.exit("FATAL: you need to configure ATHENA environmnent first!")

from analyser import *

# implement an analyser object
m_analyser = analyser()
# parse the user options
m_userOptDict = m_analyser.parseUserOpts(sys.argv)
m_msgLevel     = m_userOptDict['msgLevel']
m_processID    = m_userOptDict['processID']
m_taskID       = m_userOptDict['taskID']
m_configFile   = m_userOptDict['configFile']
m_nEntries     = m_userOptDict['nEntries']
m_Luminosity   = m_userOptDict['Luminosity']
m_D3PDLocation = m_userOptDict['D3PDLocation']

# define the verbosity level
m_analyser.setMsgStreamLevel(m_msgLevel)

# given the user inputs, find which datasets to use
m_datasets = m_analyser.getDatasets(m_configFile,m_processID,m_taskID)

# prepare timer
m_timer = timer()

# use ATLAS plot style for histograms
m_analyser.setATLASPlotStyle()

# loop over all datasets:  note, this is not the right approach to use in the end, it' more clever to have a batch job per dataset
for m_dataset in m_datasets:

    # verbosity level first
    m_dataset.setMsgStreamLevel(m_msgLevel)

    # keep track of timing
    m_timer.start()

    m_dataset.msgLevel = m_msgLevel
    m_D3PDReader = ROOT.D3PDReader()
    
    m_D3PDReader.setD3PDFormat(m_dataset.D3PDFormat)
    m_MsgStreamD3PDR = ROOT.MsgStream(0,"D3PDReader")
    m_MsgStreamD3PDR.setLevel(m_dataset.msgLevel)
    
    m_D3PDReader.setMsgStream(m_MsgStreamD3PDR)

    # we consider the no-b-tagging case
    m_D3PDReader.setBTaggingMode(False)

    # Analysis Tools Wrapper
    m_IAnalysisToolsWrapper = ROOT.IAnalysisToolsWrapper()
    
    # our hadronic W builder tool
    m_ARAHadronicWBosonBuilder = ROOT.ARAHadronicWBosonBuilder()
    m_MsgStreamWBH = ROOT.MsgStream(0,"ARAHadronicWBosonBuilder")
    m_MsgStreamWBH.setLevel(m_dataset.msgLevel)
    m_ARAHadronicWBosonBuilder.setMsgStream(m_MsgStreamWBH)

    # our hadronic Top builder tool
    m_ARAHadronicTopQuarkBuilder = ROOT.ARAHadronicTopQuarkBuilder()
    m_MsgStreamTBH = ROOT.MsgStream(0,"ARAHadronicTopQuarkBuilder")
    m_MsgStreamTBH.setLevel(m_dataset.msgLevel)
    m_ARAHadronicTopQuarkBuilder.setMsgStream(m_MsgStreamTBH)

    # our ttbar lepton + jets builder tool
    m_ARATTbarLeptonJetsBuilder = ROOT.ARATTbarLeptonJetsBuilder()
    m_MsgStreamBJJBLV = ROOT.MsgStream(0,"ARATTbarLeptonJetsBuilder")
    m_MsgStreamBJJBLV.setLevel(m_dataset.msgLevel)
    m_ARATTbarLeptonJetsBuilder.setMsgStream(m_MsgStreamBJJBLV)

    # ARATruthProcess
    m_ARATruthProcess = ROOT.ARATruthProcess()
    m_MsgStreamTP = ROOT.MsgStream(0,"ARATruthProcess")
    m_MsgStreamTP.setLevel(m_dataset.msgLevel)
    m_ARATruthProcess.setMsgStream(m_MsgStreamTP)
    
    m_analyser.MsgStream(INFO,"analysing dataset")

    m_D3PDReader.chainD3PDTTrees(m_dataset.D3PDList)
    m_dataset.createROOTOutputFile(m_dataset.D3PDTFileName)

    # book some predefined histograms
    m_dataset.bookHistogram('h1_eventWeight')
    m_dataset.bookHistogram('h1_eventWeightEvent')
    m_dataset.bookTrueProcessHistograms()
    m_dataset.bookCorrelationHistogram()
    m_dataset.bookElectronHistograms()
    m_dataset.bookMuonHistograms()
    # this is a cumulated histogram from the two above
    m_dataset.bookLeptonHistograms()
    #
    m_dataset.bookJetHistograms()

    # book some already predefined histograms for the w boson
    m_dataset.bookHadronicWBosonHistograms('w_jj_M0')
    m_dataset.bookHadronicWBosonHistograms('w_jj_M1')

    # book some already predifined histograms for the top
    m_dataset.bookHadronicTopQuarkHistograms('t_bjj_M0')
    m_dataset.bookHadronicTopQuarkHistograms('t_bjj_M0_WConstraint')
    m_dataset.bookHadronicTopQuarkHistograms('t_bjj_M2')
    m_dataset.bookHadronicTopQuarkHistograms('t_bjj_M6')

    m_dataset.entries = m_D3PDReader.getEntries()
    
    # clone the TTree, only good events will be kept
    # note this approach is the most optimal one, since the cloned tree
    # allows us then, to use the D3PDReader

    m_dataset.TFile.cd()
    m_dataset.TTree = m_D3PDReader.getTTree().CloneTree(0)
    if m_nEntries > m_D3PDReader.getEntries():
        m_nEntries = m_D3PDReader.getEntries()

    if m_nEntries == -1:
        entries = m_D3PDReader.getEntries()
    else:
        entries = m_nEntries

    m_analyser.MsgStream(INFO,"current dataset contains "  + str(entries) + " events")
    m_numberOfInitialEvents         = entries
    m_numberOfInitialWeightedEvents = 0
    m_numberOfFinalEvents           = 0
    m_numberOfFinalWeightedEvents   = 0
    for entry in range(entries):
        m_D3PDReader.getEntry(entry)
        
        # increase the number of initial events including weight
        m_numberOfInitialWeightedEvents += m_D3PDReader.getTTree().truth_eventWeight
        m_dataset.getHistogram('h1_eventWeight').Fill(m_D3PDReader.getTTree().truth_eventWeight)

        m_dataset.eventWeight = m_D3PDReader.getTTree().truth_eventWeight * m_Luminosity * m_dataset.XSection / float(m_numberOfInitialEvents)
        m_dataset.getHistogram('h1_eventWeightEvent').Fill(m_dataset.eventWeight)

        EI = m_D3PDReader.getEventInfo()
        if entry % 1000 == 0:
            m_analyser.MsgStream(INFO, "Event id=" + str(EI.event_ID().event_number()) + " processID=" + str( m_D3PDReader.getProcessId()))

        EC = m_D3PDReader.getElectrons()
        m_IAnalysisToolsWrapper.sortPT(EC)

        nLeptons = 0
        if EC:
            nLeptons = EC.size()

        MC = m_D3PDReader.getMuons()
        m_IAnalysisToolsWrapper.sortPT(MC)
        if MC:
            nLeptons = nLeptons + MC.size()
        if nLeptons < 1:
            continue
        
        # all these jets were already selected such that they don't overlap.
        JC = m_D3PDReader.getJets(20*GeV,2.5)
        m_IAnalysisToolsWrapper.sortPT(JC)

        MET= m_D3PDReader.getMissingET()
        if not MET or not JC:
            continue
        if MET.et() < 20*GeV:
            continue
        if JC.size() < 4:
            continue
        # now we require that three of the selected jets are above 40 GeV, and the 4th one above 20 GeV
        nLPtJets = 0
        nHPtJets = 0
        for i in range(JC.size()):
            J = JC.at(i)
            if J.pt() > 20*GeV:
                nLPtJets = nLPtJets + 1
            if J.pt() > 40*GeV:
                nHPtJets = nHPtJets + 1
        if  nLPtJets < 4:
            continue
        if  nHPtJets < 3:
            continue

        # keep track of this event
        #m_dataset.TTree.Fill()

        # increase the number of good events
        m_numberOfFinalEvents += 1
        m_numberOfFinalWeightedEvents +=  m_D3PDReader.getTTree().truth_eventWeight
        # fill our quality assurance histograms
        m_dataset.getHistogram('h1_lepton_nParticle').Fill(nLeptons)

        m_dataset.fillElectronHistograms(EC)
        m_dataset.fillMuonHistograms(MC)
        m_dataset.fillJetHistograms(JC,EC,MC)

        # reconstruct our hadronic W-boson
        # 0 -> all combinations
        # 1 -> closest in deltaR
        WCPC_M0 = m_ARAHadronicWBosonBuilder.build(JC,0)
        # fill additionnal histograms (final ones)
        m_dataset.getHistogram('h1_w_jj_M0_nParticle').Fill(WCPC_M0.size())
        for i  in range(WCPC_M0.size()):
            WCP = WCPC_M0.at(i)
            m_dataset.getHistogram('h1_w_jj_M0_pt').Fill(WCP.pt(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M0_e').Fill(WCP.e(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M0_m').Fill(WCP.m(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M0_eta').Fill(WCP.eta(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M0_phi').Fill(WCP.phi(),m_dataset.eventWeight)
            Jets = WCP.getJets()
            J1 = Jets.at(0)
            J2 = Jets.at(1)
            m_dataset.getHistogram('h1_w_jj_M0_jj_deltaR').Fill(J1.hlv().deltaR(J2.hlv()),m_dataset.eventWeight)

        # reconstruct our hadronic W-boson
        # 0 -> all combinations
        # 1 -> closest in deltaR
        WCPC_M1 = m_ARAHadronicWBosonBuilder.build(JC,1)
        m_dataset.getHistogram('h1_w_jj_M1_nParticle').Fill(WCPC_M1.size(),m_dataset.eventWeight)
        for i  in range(WCPC_M1.size()):
            WCP = WCPC_M1.at(i)
            m_dataset.getHistogram('h1_w_jj_M1_pt').Fill(WCP.pt(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M1_e').Fill(WCP.e(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M1_m').Fill(WCP.m(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M1_eta').Fill(WCP.eta(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_w_jj_M1_phi').Fill(WCP.phi(),m_dataset.eventWeight)
            Jets = WCP.getJets()
            J1 = Jets.at(0)
            J2 = Jets.at(1)
            m_dataset.getHistogram('h1_w_jj_M1_jj_deltaR').Fill(J1.hlv().deltaR(J2.hlv()),m_dataset.eventWeight)

        # reconstruct our hadronic top quark candidate
        # hadronic top reconstruction methods
        # 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
        # 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
        # 2 -> find the three jets the closest in delta R (no b-tagging)
        # 3 -> find the three jets the closest in delta R (with b-tagging)
        # 4 -> find the b-jet closest to the hadronic W boson 
        # 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
        # 6 -> all combinations without b-tagging
        # 7 -> all combinations with b-tagging
        BC   = ROOT.JetCollection()
        WCPC = ROOT.TCompositeParticleContainer()
        TCPC_M0 = m_ARAHadronicTopQuarkBuilder.build(JC,BC,WCPC,EC,MC,0)
        m_dataset.getHistogram('h1_t_bjj_M0_nParticle').Fill(TCPC_M0.size(),m_dataset.eventWeight)
        for i  in range(TCPC_M0.size()):
            TCP = TCPC_M0.at(i)
            m_dataset.getHistogram('h1_t_bjj_M0_pt').Fill(TCP.pt(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M0_e').Fill(TCP.e(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M0_m').Fill(TCP.m(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M0_eta').Fill(TCP.eta(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M0_phi').Fill(TCP.phi(),m_dataset.eventWeight)
            # add the W Mass constraint!
            Jets = TCP.getJets()
            dMass01 = ROOT.TMath.Abs(( Jets.at(0).hlv() + Jets.at(1).hlv()).m() - 80.4*GeV)
            dMass02 = ROOT.TMath.Abs(( Jets.at(0).hlv() + Jets.at(2).hlv()).m() - 80.4*GeV)
            dMass12 = ROOT.TMath.Abs(( Jets.at(1).hlv() + Jets.at(2).hlv()).m() - 80.4*GeV)
            if dMass01 < 20*GeV or dMass02 < 20*GeV  or dMass12 < 20*GeV:
                m_dataset.getHistogram('h1_t_bjj_M0_WConstraint_pt').Fill(TCP.pt(),m_dataset.eventWeight)
                m_dataset.getHistogram('h1_t_bjj_M0_WConstraint_e').Fill(TCP.e(),m_dataset.eventWeight)
                m_dataset.getHistogram('h1_t_bjj_M0_WConstraint_m').Fill(TCP.m(),m_dataset.eventWeight)
                m_dataset.getHistogram('h1_t_bjj_M0_WConstraint_eta').Fill(TCP.eta(),m_dataset.eventWeight)
                m_dataset.getHistogram('h1_t_bjj_M0_WConstraint_phi').Fill(TCP.phi(),m_dataset.eventWeight)
              
        # reconstruct our hadronic top quark candidate
        # hadronic top reconstruction methods
        # 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
        # 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
        # 2 -> find the three jets the closest in delta R (no b-tagging)
        # 3 -> find the three jets the closest in delta R (with b-tagging)
        # 4 -> find the b-jet closest to the hadronic W boson 
        # 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
        # 6 -> all combinations without b-tagging
        # 7 -> all combinations with b-tagging
        BC = ROOT.JetCollection()
        TCPC_M2 = m_ARAHadronicTopQuarkBuilder.build(JC,BC,WCPC,EC,MC,2)
        m_dataset.getHistogram('h1_t_bjj_M2_nParticle').Fill(TCPC_M2.size(),m_dataset.eventWeight)
        for i  in range(TCPC_M2.size()):
            TCP = TCPC_M2.at(i)
            m_dataset.getHistogram('h1_t_bjj_M2_pt').Fill(TCP.pt(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M2_e').Fill(TCP.e(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M2_m').Fill(TCP.m(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M2_eta').Fill(TCP.eta(),m_dataset.eventWeight)


        # reconstruct our hadronic top quark candidate
        # hadronic top reconstruction methods
        # 0 -> all three jets combinations which give the highest pt-object (no b-tagging)
        # 1 -> all three jets combinations which give the highest pt-object (with b-tagging)
        # 2 -> find the three jets the closest in delta R (no b-tagging)
        # 3 -> find the three jets the closest in delta R (with b-tagging)
        # 4 -> find the b-jet closest to the hadronic W boson 
        # 5 -> find the b-jet which combined to the hadronic W boson gives the highest pt object
        # 6 -> all combinations without b-tagging
        # 7 -> all combinations with b-tagging
        BC = ROOT.JetCollection()
        TCPC_M6 = m_ARAHadronicTopQuarkBuilder.build(JC,BC,WCPC,EC,MC,6)
        m_dataset.getHistogram('h1_t_bjj_M6_nParticle').Fill(TCPC_M6.size(),m_dataset.eventWeight)
        for i  in range(TCPC_M6.size()):
            TCP = TCPC_M6.at(i)
            m_dataset.getHistogram('h1_t_bjj_M6_pt').Fill(TCP.pt(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M6_e').Fill(TCP.e(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M6_m').Fill(TCP.m(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M6_eta').Fill(TCP.eta(),m_dataset.eventWeight)
            m_dataset.getHistogram('h1_t_bjj_M6_phi').Fill(TCP.phi(),m_dataset.eventWeight)

            
    m_dataset.TFile.cd()
    m_dataset.TTree.Write()
    m_dataset.writeHistograms()
    # close the current TFile
    m_dataset.TFile.Close()
    m_timer.stop()
    m_analyser.MsgStream(INFO," Process-id for the current dataset                       = " + str(m_dataset.ProcessID))
    m_analyser.MsgStream(INFO," Task-id for the current dataset                          = " + str(m_dataset.TaskID))
    m_analyser.MsgStream(INFO," Number of available events for this dataset              = " + str(m_dataset.entries))
    m_analyser.MsgStream(INFO," Cross section for the current dataset (pb)               = " + str(m_dataset.XSection))
    m_analyser.MsgStream(INFO," Luminosity (1/pb)                                        = " + str(m_dataset.entries/m_dataset.XSection))
    m_analyser.MsgStream(INFO," Number of initial events for this dataset                = " + str(m_numberOfInitialEvents))
    m_analyser.MsgStream(INFO," Number of initial events for this dataset (with weights) = " + str(m_numberOfInitialWeightedEvents))
    m_analyser.MsgStream(INFO," Luminosity (1/pb)                                        = " + str(m_numberOfInitialEvents/m_dataset.XSection))
    m_analyser.MsgStream(INFO," Luminosity (1/pb) (with weights)                         = " + str(m_numberOfInitialWeightedEvents/m_dataset.XSection))
    m_analyser.MsgStream(INFO," Number of selected events                                = " + str(m_numberOfFinalEvents))
    m_analyser.MsgStream(INFO," Number of selected events (with weights)                 = " + str(m_numberOfFinalWeightedEvents))
    m_analyser.MsgStream(INFO," Luminosity (1/pb)                                        = " + str(m_numberOfFinalEvents/m_dataset.XSection))
    m_analyser.MsgStream(INFO," Luminosity (1/pb) (with weights)                         = " + str(m_numberOfFinalWeightedEvents/m_dataset.XSection))
    m_analyser.MsgStream(INFO," Efficiency (%)                                           = " + str(m_numberOfFinalEvents*100./m_numberOfInitialEvents))
    m_analyser.MsgStream(INFO," Efficiency (%) (with weights)                            = " + str(m_numberOfFinalWeightedEvents*100./m_numberOfInitialWeightedEvents))
    m_analyser.MsgStream(INFO," Start time for this dataset processing                   = " + str(m_timer.startTime))
    m_analyser.MsgStream(INFO," Stop time for this dataset processing                    = " + str(m_timer.stopTime))
    m_analyser.MsgStream(INFO," Elapsed time for this dataset processing (s)             = " + str(m_timer.elapsedTime))
    m_analyser.MsgStream(INFO," Event processing rate (Hz)                               = " + str(m_numberOfInitialEvents/float(m_timer.elapsedTime)))
    

-- NabilGhodbane? - 23 Sep 2008

last updated, 08/2008.
%=-
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r29 < r28 < r27 < r26 < r25 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback