====== 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 [[https://twiki.cern.ch/twiki/bin/view/LHCb/DaVinciTutorial4 | DaVinciTutorial4]].
===== Preparations =====
* login to **lxplus**
* make sure you have a [[https://lhcb.physik.uzh.ch/grid:grid | Grid]]-Certificate
*
===== Create Python Configuration =====
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, [[davinci:particletable | look at the ParticleTable]].
For a list of availbale funtors for CombinationCut and MotherCut, [[loki:lists | check the Loki references]].
=====Running=====
* Set environment for Ganga
SetupProject Ganga
* maybe you need to create a new config file
ganga -g
* start
ganga
* prepare job
t = JobTemplate( application = DaVinci( ))
t.application.optsfile = File( "~/example/myOptions.py" )
* add input data
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
* create a job and run it
j = Job( t, backend = Interactive() )
j.submit()
==== Running outside Ganga (locally)====
=== Prepare Data Files ===
* run the Bookkeeping-GUI
lhcb_bkk
* select
MC / MC09 / Beam5TeV-VeloClosed-MagDown-Nu1 / MC09-Sim03Reco02-withTruth / 24142000 / DST
* double-click on **Nb of Files/Events** and select all files
* click **Advanced Save**
* give Filename (e.g. "myFiles.py"), select **PFN(s)** and **CERN**
* click **save**
=== Run ===
SetupProject DaVinci
gaudirun.py myOptions.py myFiles.py
===== Looking at the output =====
The Algorithm creates a file called histograms.root.
* If run with gaudirun.py it should be in the working directory.
* If run with ganga it can be found at **~/gangadir/workspace//LocalAMGA//output/**
Start root and have a look at the histograms.
===== More Info =====
You can find more info at following locations:
* [[ganga:ganga | Ganga]]
* [[davinci:davinci | DaVinci]]