Skip to content

Commit

Permalink
WIP first version of turbo and persist-reco lessons.
Browse files Browse the repository at this point in the history
  • Loading branch information
roelaaij committed May 19, 2016
1 parent c6ab43e commit f01e6b6
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 10 deletions.
60 changes: 60 additions & 0 deletions 19-turbo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
layout: page
title: Second steps in LHCb
subtitle: Turbo Stream
minutes: 30
---

> ## Learning Objectives {.objectives}
>
> * Learn about persited reconstruction
> * Learn how to make new candidates from turbo candidate and other persisted objects
> * Learn how to make an NTuple from these new candidates.
Online-offline reco the same
Online reconstructed candidates stored in raw event
Tesla pulls them out puts them back in the memory

The file used in the [lesson about the HLT ](05-hlt-intro.html) can also be
used for this lesson: `root://eoslhcb.cern.ch//eos/lhcb/user/r/raaij/Impactkit/00051318_00000509_1.turbo.mdst`.

Python file that defines the data:
~~~ {.python}
# data.py
from GaudiConf import IOHelper
prefix = 'root://eoslhcb.cern.ch/'
fname = '/eos/lhcb/user/r/raaij/Impactkit/00051318_00000509_1.turbo.mdst'
IOHelper('ROOT').inputFiles([prefix + fname], clear=True)
~~~

Basic script for making a turbo NTuple `turbo_intro.py`
~~~ {.python}
# DaVinci configuration
from Configurables import DaVinci
DaVinci().DataType = '2016'
DaVinci().EvtMax = 1000
DaVinci().TupleFile = turbo.root'
# Turbo locations:
turbo_loc = '/Event/Turbo/{0}/Particles'
dz_line = 'Hlt2CharmHadD02KmPipTurbo'
# Make a DecayTreeTuple
from Configurables import DecayTreeTuple
from DecayTreeTuple import Configuration
dtt = DecayTreeTuple('TupleD0ToKpi')
dtt.Inputs = [turbo_loc.format(dz_line)]
dtt.Decay = '[D0 -> K- pi+]CC'
dtt.addBranches({
'D0': '[D0 -> K- pi+]CC'
})
DaVinci().UserAlgorithms = [dtt]
~~~

Then we run it!

```shell
lb-run DaVinci gaudirun.py turbo_persistreco.py data.py
```
89 changes: 89 additions & 0 deletions 20-persist-reco.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
layout: page
title: Second steps in LHCb
subtitle: Persisted Reconstruction
minutes: 45
---

> ## Learning Objectives {.objectives}
>
> * Learn about persited reconstruction
> * Learn how to make new candidates from turbo candidate and other persisted objects
> * Learn how to make an NTuple from these new candidates.
Now we want to use the PersistReco to make something more from the candidates,
in this case a D* -> (D0 -> K pi) pi.

Create a new script, `turbo_persistreco.py`, based on `turbo_intro.py` from the
previous lesson to contain your configuration.

There are some general options needed to configure DaVinci to recreate the
particles created in the HLT.
~~~ {.python}
# Turbo with PersistReco
from Configurables import DstConf, TurboConf
DstConf().Turbo = True
TurboConf().PersistReco = True
~~~

Then we need to get the particles that we want to create the D* from and combine
them.

> ## Persisted Particles {.challenge}
>
> Use a GaudiPython script to find out which particles are persisted from the
> online reconstruction.
~~~ {.python}
# Get the D0 and the pions
from PhysSelPython.Wrappers import DataOnDemand, Selection, SelectionSequence
dz = DataOnDemand(turbo_loc.format(dz_line))
pions = DataOnDemand('Phys/StdAllNoPIDsPions/Particles')
# Combine them
from GaudiConfUtils.ConfigurableGenerators import CombineParticles
dst = CombineParticles(
DecayDescriptors = ['[D*(2010)+ -> D0 pi+]cc'],
CombinationCut = "(ADAMASS('D*(2010)+') < 80 * MeV)",
MotherCut = "VFASPF(VCHI2/VDOF) < 6 & ADMASS('D*(2010)+') < 60 * MeV"
)
~~~

To run our combination, we create a selection and a selection sequence.
~~~ {.python}
dst_sel = Selection(
'Sel_DstToD0pi',
Algorithm = dst,
RequiredSelections = [dz, pions]
)
dst_selseq = SelectionSequence(
'SelSeq_DstToD0pi',
TopSelection = dst_sel
)
~~~

Finally, we create the `DecayTreeTuple` for the D* and use the output of our selection
sequence as its input.

~~~ {.python}
# D* in the tuple
dtt_dst = DecayTreeTuple('TupleDstToD0pi_D0ToKpi_PersistReco')
dtt_dst.Inputs = dst_selseq.outputLocations()
dtt_dst.Decay = '[D*(2010)+ -> ^(D0 -> ^K- ^pi+) ^pi+]CC'
dtt_dst.addBranches({
'Dst': '[D*(2010)+ -> (D0 -> K- pi+) pi+]CC',
'Dst_pi': '[D*(2010)+ -> (D0 -> K- pi+) ^pi+]CC',
'D0': '[D*(2010)+ -> ^(D0 -> K- pi+) pi+]CC',
'D0_K': '[D*(2010)+ -> (D0 -> ^K- pi+) pi+]CC',
'D0_pi': '[D*(2010)+ -> (D0 -> K- ^pi+) pi+]CC',
})
DaVinci().UserAlgorithms = [dst_selseq.sequence(), dtt_dst]
~~~

Then we run it!

```shell
lb-run DaVinci gaudirun.py turbo_persistreco.py data.py
```
22 changes: 12 additions & 10 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ layout: lesson
title: Second analysis steps in LHCb
---

These are the lessons for the second-stage workshop of the [Starterkit
These are the lessons for the second-stage workshop of the [Starterkit
series][starterkit].
They build on those from [the first workshop][first-ana], teaching LHCb
They build on those from [the first workshop][first-ana], teaching LHCb
software that's more advanced and more focused on specific tasks.

Unlike the first workshop, there may be some lessons here that aren't
applicable to everyone's analysis, but all the lessons should still provide a
Unlike the first workshop, there may be some lessons here that aren't
applicable to everyone's analysis, but all the lessons should still provide a
useful insight in to how things work under the hood.
It may also be that some lessons don't depend on any others; the prerequisites
It may also be that some lessons don't depend on any others; the prerequisites
will be clearly stated at the beginning of each lesson.

If you have any problems or questions, you can [open an
issue][second-ana-issues] on the [GitHub repository where these lessons are
developed][second-ana-repo], or you can [send an email to
If you have any problems or questions, you can [open an
issue][second-ana-issues] on the [GitHub repository where these lessons are
developed][second-ana-repo], or you can [send an email to
`[email protected]`](mailto:[email protected]).

> ## Prerequisites {.prereq}
>
> Before starting, you should be familiar with the [first analysis
> steps](https://lhcb.github.io/first-analysis-steps/) and satisfy all of its
> Before starting, you should be familiar with the [first analysis
> steps](https://lhcb.github.io/first-analysis-steps/) and satisfy all of its
> prerequisites.
>
Expand All @@ -36,6 +36,8 @@ developed][second-ana-repo], or you can [send an email to
1. [Reuse particles from a decay tree](18-filter-in-trees.html)
1. [HLT intro](18-hlt-intro.html)
1. [TisTos DIY](18-tistos-diy.html)
1. [Turbo](19-turbo.html)
1. [Turbo+PersistReco](20-persist-reco.html)

## Other Resources

Expand Down

0 comments on commit f01e6b6

Please sign in to comment.