Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turbo #31

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 18-hlt-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ available in HLT2 is the same as the offline reconstruction, physics analysis
can be done with the candidates created in HLT2. If a line is configured to be a
Turbo line, all information on the candidates that it selects is stored in the
raw event. These candidates can be resurrected later by the Tesla application and
written to a microDST. This is similar to stripping streams that go to
microDST, where only candidates that are used in passing selections are
available to analysts. The Turbo stream is different because information that
written to a microDST. This is similar to stripping streams that go to
microDST, where only candidates that are used in passing selections are
available to analysts. The Turbo stream is different because information that
is not saved is lost forever.

We will now have a look at some of the candidates stored by the HLT. We will use the script we
[used last time](http://lhcb.github.io/first-analysis-steps/05-interactive-dst.html)
as a starting point, and the file
`root://eoslhcb.cern.ch//eos/lhcb/user/r/raaij/Impactkit/00051318_00000509_1.turbo.mdst`.
This file contains some 2016 Turbo events from [run
This file contains some 2016 Turbo events from [run
174252](http://lbrundb.cern.ch/rundb/run/174252/). Fire up your
favourite editor, open the script and save a copy to work on as
`hlt_info.py`. There are a few things in the script that we don't need and can
Expand Down Expand Up @@ -83,7 +83,7 @@ The HLT1 selections that are most efficient for hadronic charm and beauty decays
in Run 2 are called Hlt1TrackMVA and Hlt1TwoTrackMVA. Use the advance function
to find an event that was accepted by either of these trigger selections.

The DecReports only contains the decisions for each line, 1 or 0. The
The DecReports only contains the decisions for each line, 1 or 0. The
candidates themselves are stored in the
SelReports ("Hlt{1,2}/SelReports"). Get the HLT1 SelReports from the event store
and retrieve the one for one of the TrackMVA selections using the selReport function,
Expand Down
62 changes: 62 additions & 0 deletions 19-turbo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
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 ](18-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_intro.py data.py
```
93 changes: 93 additions & 0 deletions 20-persist-reco.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
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
[lesson about turbo ](19-turbo.html) 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 inspired by
> [another lesson](http://lhcb.github.io/first-analysis-steps/05-interactive-dst.html)
> to find out which particles are persisted from the
> online reconstruction by exploring the transient event store.

~~~ {.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 Stream](19-turbo.html)
1. [Persisted Reconstruction](20-persist-reco.html)
1. [Managing files in Ganga](01-managing-files-with-ganga.html)
1. [Using Ganga with local projects](01-ganga-with-cmake.html)

Expand Down