Table of Contents

DaVinci Example

This example creates a simple selection for J/psi → mu+ mu- using the Particle Selection Framework (i.e. CombineParticle). It is a simplified version of the algorithm described in DaVinciTutorial4.

Preparations

Create Python Configuration

myOptions.py
from Gaudi.Configuration import *                                          
from GaudiKernel.SystemOfUnits import MeV, GeV
from Configurables import CombineParticles
from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand
 
# prepare input data
_muons = DataOnDemand('_stdLooseMuons', Location = 'StdLooseMuons')
 
# create algorithm
myalg = CombineParticles("myalg")
 
# define decay and cuts
myalg.DecayDescriptor = "J/psi(1S) -> mu+ mu-"
myalg.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
myalg.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
 
# add plots to algorithm
from Configurables import LoKi__Hybrid__PlotTool as PlotTool
myalg.HistoProduce = True
myalg.addTool ( PlotTool ( 'DaughtersPlots' ) )
myalg.DaughtersPlots.Histos = {
   'P'  : ('momentum' , 0*GeV ,30*GeV) ,
   'M'  : ('mass'     ,0*GeV,1*GeV)
   }
myalg.addTool( PlotTool ( "MotherPlots" ) )
myalg.MotherPlots.Histos = {
   "P"  : ('momentum',0*GeV,100*GeV) ,
   "M"  : ('mass',0*GeV,4*GeV)
   }
 
# create selection
# Selection needs to be defined after all changes to the Algorithm
LooseJpsi2MuMu = Selection("seqLooseJPsi2MuMu", Algorithm = myalg, RequiredSelections =[ _muons ])
 
# start selection sequence
mySeq = SelectionSequence("mySeq", TopSelection = LooseJpsi2MuMu)
 
# configure the application.
from Configurables import DaVinci
DaVinci().UserAlgorithms = [ mySeq.sequence() ]
DaVinci().HistogramFile  = "histograms.root"    # Histogram file
DaVinci().EvtMax         = 1000                  # Number of events to loop over
DaVinci().DataType       = "MC09"               # Default anyway
DaVinci().Simulation     = True                 # It's MC

For more details about the names used in the DecayDescriptor, look at the ParticleTable. For a list of availbale funtors for CombinationCut and MotherCut, check the Loki references.

Running

SetupProject Ganga
ganga -g
ganga
t = JobTemplate( application = DaVinci( ))
t.application.optsfile = File( "~/example/myOptions.py" )
t.inputdata = browseBK()
# select MC / MC09 / Beam5TeV-VeloClosed-MagDown-Nu1 / MC09-Sim03Reco02-withTruth / 24142000 / DST
# you could instead use an python option file with the data locations 
# (see below on how to generate one)
#t.application.optsfile.append(  File( "~/example/myOptions.py" )  )
# the Ganga-Manual marks this as depreciated
j = Job( t, backend = Interactive() )
j.submit()

Running outside Ganga (locally)

Prepare Data Files

lhcb_bkk
MC / MC09 / Beam5TeV-VeloClosed-MagDown-Nu1 / MC09-Sim03Reco02-withTruth / 24142000 / DST

Run

SetupProject DaVinci
gaudirun.py myOptions.py myFiles.py

Looking at the output

The Algorithm creates a file called histograms.root.

Start root and have a look at the histograms.

More Info

You can find more info at following locations: